blob: c063bfb10af0de8d29241570da2dcc38323e837c [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Aaron Durbin76c37002012-10-30 09:03:43 -05002
Kyösti Mälkkide640782019-12-03 07:30:26 +02003#include <arch/bootblock.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02004#include <device/pci_ops.h>
Angel Pons4c7ef812020-06-21 18:04:57 +02005#include <southbridge/intel/common/early_spi.h>
Aaron Durbin76c37002012-10-30 09:03:43 -05006#include "pch.h"
7
Aaron Durbin76c37002012-10-30 09:03:43 -05008static void map_rcba(void)
9{
Angel Pons6e732d32021-01-28 13:56:18 +010010 pci_write_config32(PCH_LPC_DEV, RCBA, CONFIG_FIXED_RCBA_MMIO_BASE | 1);
Aaron Durbin76c37002012-10-30 09:03:43 -050011}
12
13static void enable_port80_on_lpc(void)
14{
Kyösti Mälkkib544c002019-01-06 10:41:41 +020015 /* Enable port 80 POST on LPC. The chipset does this by default,
Aaron Durbin76c37002012-10-30 09:03:43 -050016 * but it doesn't appear to hurt anything. */
17 u32 gcs = RCBA32(GCS);
18 gcs = gcs & ~0x4;
19 RCBA32(GCS) = gcs;
20}
21
22static 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 Heymans8e646e72018-06-05 11:19:22 +020042void bootblock_early_southbridge_init(void)
Aaron Durbin76c37002012-10-30 09:03:43 -050043{
Aaron Durbin76c37002012-10-30 09:03:43 -050044 map_rcba();
Angel Pons4c7ef812020-06-21 18:04:57 +020045 enable_spi_prefetching_and_caching();
Aaron Durbin76c37002012-10-30 09:03:43 -050046 enable_port80_on_lpc();
47 set_spi_speed();
48
49 /* Enable upper 128bytes of CMOS */
50 RCBA32(RC) = (1 << 2);
Arthur Heymansd893a262018-12-19 16:54:06 +010051
52 pch_enable_lpc();
53 mainboard_config_superio();
Aaron Durbin76c37002012-10-30 09:03:43 -050054}