Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 2 | |
Kyösti Mälkki | de64078 | 2019-12-03 07:30:26 +0200 | [diff] [blame] | 3 | #include <arch/bootblock.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 4 | #include <device/pci_ops.h> |
Angel Pons | c9ee2c0 | 2020-06-21 17:58:59 +0200 | [diff] [blame] | 5 | #include <southbridge/intel/common/early_spi.h> |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 6 | #include "pch.h" |
| 7 | |
Keith Hui | 885e8cb | 2023-11-27 00:15:59 -0500 | [diff] [blame] | 8 | static void setup_port80(void) |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 9 | { |
Keith Hui | 885e8cb | 2023-11-27 00:15:59 -0500 | [diff] [blame] | 10 | /* Enable port 80 POST */ |
| 11 | if (CONFIG(POST_DEVICE_PCI_PCIE)) |
| 12 | RCBA32(GCS) |= 0x04; /* ... on PCI(e) */ |
| 13 | else |
| 14 | RCBA32(GCS) &= (~0x04); /* ... on LPC */ |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 15 | } |
| 16 | |
Duncan Laurie | 2a700ec | 2012-10-08 15:26:54 -0700 | [diff] [blame] | 17 | static void set_spi_speed(void) |
| 18 | { |
| 19 | u32 fdod; |
| 20 | u8 ssfc; |
| 21 | |
| 22 | /* Observe SPI Descriptor Component Section 0 */ |
| 23 | RCBA32(0x38b0) = 0x1000; |
| 24 | |
| 25 | /* Extract the Write/Erase SPI Frequency from descriptor */ |
| 26 | fdod = RCBA32(0x38b4); |
| 27 | fdod >>= 24; |
| 28 | fdod &= 7; |
| 29 | |
| 30 | /* Set Software Sequence frequency to match */ |
| 31 | ssfc = RCBA8(0x3893); |
| 32 | ssfc &= ~7; |
| 33 | ssfc |= fdod; |
| 34 | RCBA8(0x3893) = ssfc; |
| 35 | } |
| 36 | |
Arthur Heymans | 360d947 | 2019-11-12 18:11:03 +0100 | [diff] [blame] | 37 | void bootblock_early_southbridge_init(void) |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 38 | { |
Angel Pons | c9ee2c0 | 2020-06-21 17:58:59 +0200 | [diff] [blame] | 39 | enable_spi_prefetching_and_caching(); |
Arthur Heymans | 360d947 | 2019-11-12 18:11:03 +0100 | [diff] [blame] | 40 | |
| 41 | early_pch_init(); |
| 42 | |
Keith Hui | 885e8cb | 2023-11-27 00:15:59 -0500 | [diff] [blame] | 43 | setup_port80(); |
Duncan Laurie | 2a700ec | 2012-10-08 15:26:54 -0700 | [diff] [blame] | 44 | set_spi_speed(); |
Duncan Laurie | 8e515d3 | 2012-06-23 15:43:41 -0700 | [diff] [blame] | 45 | |
| 46 | /* Enable upper 128bytes of CMOS */ |
| 47 | RCBA32(RC) = (1 << 2); |
Stefan Reinauer | 8e07382 | 2012-04-04 00:07:22 +0200 | [diff] [blame] | 48 | } |