coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
bootblock.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <amdblocks/acpimmio.h>
4 #include <arch/bootblock.h>
5 #include <device/pci_ops.h>
6 
7 static void enable_rom(void)
8 {
9  u16 word;
10  u32 dword;
11  const pci_devfn_t dev = PCI_DEV(0, 0x14, 0x03);
12  /* SB800 LPC Bridge 0:20:3:44h.
13  * BIT6: Port Enable for serial port 0x3f8-0x3ff
14  * BIT29: Port Enable for KBC port 0x60 and 0x64
15  * BIT30: Port Enable for ACPI Micro-Controller port 0x66 and 0x62
16  */
17  dword = pci_s_read_config32(dev, 0x44);
18  //dword |= (1<<6) | (1<<29) | (1<<30);
19  /* Turn on all of LPC IO Port decode enable */
20  dword = 0xffffffff;
21  pci_s_write_config32(dev, 0x44, dword);
22 
23  /* SB800 LPC Bridge 0:20:3:48h.
24  * BIT0: Port Enable for SuperIO 0x2E-0x2F
25  * BIT1: Port Enable for SuperIO 0x4E-0x4F
26  * BIT4: Port Enable for LPC ROM Address Arrage2 (0x68-0x6C)
27  * BIT6: Port Enable for RTC IO 0x70-0x73
28  * BIT21: Port Enable for Port 0x80
29  */
30  dword = pci_s_read_config32(dev, 0x48);
31  dword |= (1 << 0) | (1 << 1) | (1 << 4) | (1 << 6) | (1 << 21);
32  pci_s_write_config32(dev, 0x48, dword);
33 
34  /* Enable ROM access */
35  word = pci_s_read_config16(dev, 0x6c);
36  word = 0x10000 - (CONFIG_COREBOOT_ROMSIZE_KB >> 6);
37  pci_s_write_config16(dev, 0x6c, word);
38 }
39 
40 static void enable_prefetch(void)
41 {
42  u32 dword;
43  const pci_devfn_t dev = PCI_DEV(0, 0x14, 0x03);
44 
45  /* Enable PrefetchEnSPIFromHost */
46  dword = pci_s_read_config32(dev, 0xb8);
47  pci_s_write_config32(dev, 0xb8, dword | (1 << 24));
48 }
49 
50 static void enable_spi_fast_mode(void)
51 {
52  u32 dword;
53  const pci_devfn_t dev = PCI_DEV(0, 0x14, 0x03);
54 
55  // set temp MMIO base
56  volatile u32 *spi_base = (void *)0xa0000000;
57  u32 save = pci_s_read_config32(dev, 0xa0);
58  pci_s_write_config32(dev, 0xa0, (u32) spi_base | 2);
59 
60  // early enable of SPI 33 MHz fast mode read
61  dword = spi_base[3];
62  spi_base[3] = (dword & ~(3 << 14)) | (1 << 14);
63  spi_base[0] = spi_base[0] | (1 << 18); // fast read enable
64 
65  pci_s_write_config32(dev, 0xa0, save);
66 }
67 
68 static void enable_clocks(void)
69 {
70  u32 reg32;
71 
72  // Program SB800 MiscClkCntrl register to configure clock output on the
73  // 14M_25M_48M_OSC ball usually used for the Super-I/O.
74  // Almost all SIOs need 48 MHz, only the SMSC SCH311x wants 14 MHz,
75  // which is the SB800's power up default. We could switch back to 14
76  // in the mainboard's romstage.c, but then the clock frequency would
77  // change twice.
78  reg32 = misc_read32(0x40);
79  reg32 &= ~((1 << 2) | (3 << 0)); // enable, 14 MHz (power up default)
80 #if !CONFIG(SUPERIO_WANTS_14MHZ_CLOCK)
81  reg32 |= 2 << 0; // Device_CLK1_sel = 48 MHz
82 #endif
83  misc_write32(0x40, reg32);
84 }
85 
87 {
88  /* Setup the ROM access for 2M */
89  enable_rom();
92 
93  // Program AcpiMmioEn to enable MMIO access to MiscCntrl register
95  enable_clocks();
96 }
static uint32_t misc_read32(uint8_t reg)
Definition: acpimmio.h:266
static void misc_write32(uint8_t reg, uint32_t value)
Definition: acpimmio.h:281
void __weak bootblock_early_southbridge_init(void)
Definition: bootblock.c:17
static uintptr_t spi_base
Definition: fch_spi_util.c:12
void enable_acpimmio_decode_pm24(void)
Definition: mmio_util.c:45
static __always_inline uint32_t pci_s_read_config32(pci_devfn_t dev, uint16_t reg)
Definition: pci_io_cfg.h:92
static __always_inline uint16_t pci_s_read_config16(pci_devfn_t dev, uint16_t reg)
Definition: pci_io_cfg.h:86
static __always_inline void pci_s_write_config16(pci_devfn_t dev, uint16_t reg, uint16_t value)
Definition: pci_io_cfg.h:104
static __always_inline void pci_s_write_config32(pci_devfn_t dev, uint16_t reg, uint32_t value)
Definition: pci_io_cfg.h:110
#define PCI_DEV(SEGBUS, DEV, FN)
Definition: pci_type.h:14
u32 pci_devfn_t
Definition: pci_type.h:8
static unsigned int word
Definition: uart.c:88
static void enable_clocks(void)
Definition: bootblock.c:68
static void enable_spi_fast_mode(void)
Definition: bootblock.c:50
static void enable_rom(void)
Definition: bootblock.c:7
static void enable_prefetch(void)
Definition: bootblock.c:40
uint32_t u32
Definition: stdint.h:51
uint16_t u16
Definition: stdint.h:48