Angel Pons | 182dbde | 2020-04-02 23:49:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [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 | 4c7ef81 | 2020-06-21 18:04:57 +0200 | [diff] [blame] | 5 | #include <southbridge/intel/common/early_spi.h> |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 6 | #include "pch.h" |
| 7 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 8 | static void map_rcba(void) |
| 9 | { |
Angel Pons | 90cdf70 | 2020-10-24 23:00:34 +0200 | [diff] [blame] | 10 | pci_write_config32(PCH_LPC_DEV, RCBA, (uintptr_t)DEFAULT_RCBA | 1); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 11 | } |
| 12 | |
| 13 | static void enable_port80_on_lpc(void) |
| 14 | { |
Kyösti Mälkki | b544c00 | 2019-01-06 10:41:41 +0200 | [diff] [blame] | 15 | /* Enable port 80 POST on LPC. The chipset does this by default, |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 16 | * but it doesn't appear to hurt anything. */ |
| 17 | u32 gcs = RCBA32(GCS); |
| 18 | gcs = gcs & ~0x4; |
| 19 | RCBA32(GCS) = gcs; |
| 20 | } |
| 21 | |
| 22 | static void set_spi_speed(void) |
| 23 | { |
| 24 | u32 fdod; |
| 25 | u8 ssfc; |
| 26 | |
| 27 | /* Observe SPI Descriptor Component Section 0 */ |
| 28 | SPIBAR32(FDOC) = 0x1000; |
| 29 | |
| 30 | /* Extract the Write/Erase SPI Frequency from descriptor */ |
| 31 | fdod = SPIBAR32(FDOD); |
| 32 | fdod >>= 24; |
| 33 | fdod &= 7; |
| 34 | |
| 35 | /* Set Software Sequence frequency to match */ |
| 36 | ssfc = SPIBAR8(SSFC + 2); |
| 37 | ssfc &= ~7; |
| 38 | ssfc |= fdod; |
| 39 | SPIBAR8(SSFC + 2) = ssfc; |
| 40 | } |
| 41 | |
Arthur Heymans | 8e646e7 | 2018-06-05 11:19:22 +0200 | [diff] [blame] | 42 | void bootblock_early_southbridge_init(void) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 43 | { |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 44 | map_rcba(); |
Angel Pons | 4c7ef81 | 2020-06-21 18:04:57 +0200 | [diff] [blame] | 45 | enable_spi_prefetching_and_caching(); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 46 | enable_port80_on_lpc(); |
| 47 | set_spi_speed(); |
| 48 | |
| 49 | /* Enable upper 128bytes of CMOS */ |
| 50 | RCBA32(RC) = (1 << 2); |
Arthur Heymans | d893a26 | 2018-12-19 16:54:06 +0100 | [diff] [blame] | 51 | |
| 52 | pch_enable_lpc(); |
| 53 | mainboard_config_superio(); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 54 | } |