blob: 67b95cdca0f930b202179b7554aa510d59ecb3f0 [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Aaron Durbin76c37002012-10-30 09:03:43 -05003
Kyösti Mälkkide640782019-12-03 07:30:26 +02004#include <arch/bootblock.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02005#include <device/pci_ops.h>
Aaron Durbin76c37002012-10-30 09:03:43 -05006#include "pch.h"
7
Aaron Durbin76c37002012-10-30 09:03:43 -05008/*
9 * Enable Prefetching and Caching.
10 */
11static void enable_spi_prefetch(void)
12{
13 u8 reg8;
Edward O'Callaghan9a817ef2014-10-26 10:12:15 +110014 pci_devfn_t dev;
Aaron Durbin76c37002012-10-30 09:03:43 -050015
16 dev = PCI_DEV(0, 0x1f, 0);
17
18 reg8 = pci_read_config8(dev, 0xdc);
19 reg8 &= ~(3 << 2);
20 reg8 |= (2 << 2); /* Prefetching and Caching Enabled */
21 pci_write_config8(dev, 0xdc, reg8);
22}
23
24
25static void map_rcba(void)
26{
Edward O'Callaghan9a817ef2014-10-26 10:12:15 +110027 pci_devfn_t dev = PCI_DEV(0, 0x1f, 0);
Aaron Durbin76c37002012-10-30 09:03:43 -050028
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080029 pci_write_config32(dev, RCBA, (uintptr_t)DEFAULT_RCBA | 1);
Aaron Durbin76c37002012-10-30 09:03:43 -050030}
31
32static void enable_port80_on_lpc(void)
33{
Kyösti Mälkkib544c002019-01-06 10:41:41 +020034 /* Enable port 80 POST on LPC. The chipset does this by default,
Aaron Durbin76c37002012-10-30 09:03:43 -050035 * but it doesn't appear to hurt anything. */
36 u32 gcs = RCBA32(GCS);
37 gcs = gcs & ~0x4;
38 RCBA32(GCS) = gcs;
39}
40
41static void set_spi_speed(void)
42{
43 u32 fdod;
44 u8 ssfc;
45
46 /* Observe SPI Descriptor Component Section 0 */
47 SPIBAR32(FDOC) = 0x1000;
48
49 /* Extract the Write/Erase SPI Frequency from descriptor */
50 fdod = SPIBAR32(FDOD);
51 fdod >>= 24;
52 fdod &= 7;
53
54 /* Set Software Sequence frequency to match */
55 ssfc = SPIBAR8(SSFC + 2);
56 ssfc &= ~7;
57 ssfc |= fdod;
58 SPIBAR8(SSFC + 2) = ssfc;
59}
60
Arthur Heymans8e646e72018-06-05 11:19:22 +020061void bootblock_early_southbridge_init(void)
Aaron Durbin76c37002012-10-30 09:03:43 -050062{
Aaron Durbin76c37002012-10-30 09:03:43 -050063 map_rcba();
64 enable_spi_prefetch();
65 enable_port80_on_lpc();
66 set_spi_speed();
67
68 /* Enable upper 128bytes of CMOS */
69 RCBA32(RC) = (1 << 2);
Arthur Heymansd893a262018-12-19 16:54:06 +010070
71 pch_enable_lpc();
72 mainboard_config_superio();
Aaron Durbin76c37002012-10-30 09:03:43 -050073}