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 <arch/bootblock.h>
4 #include <device/pci_ops.h>
6 #include "pch.h"
7 #include "chip.h"
8 
9 static void enable_port80_on_lpc(void)
10 {
11  RCBA32(GCS) &= ~4;
12 }
13 
14 static void set_spi_speed(void)
15 {
16  u32 fdod;
17  u8 ssfc;
18 
19  /* Observe SPI Descriptor Component Section 0 */
20  RCBA32(0x38b0) = 0x1000;
21 
22  /* Extract the Write/Erase SPI Frequency from descriptor */
23  fdod = RCBA32(0x38b4);
24  fdod >>= 24;
25  fdod &= 7;
26 
27  /* Set Software Sequence frequency to match */
28  ssfc = RCBA8(0x3893);
29  ssfc &= ~7;
30  ssfc |= fdod;
31  RCBA8(0x3893) = ssfc;
32 }
33 
34 static void early_lpc_init(void)
35 {
36  const struct device *dev = pcidev_on_root(0x1f, 0);
37  const struct southbridge_intel_ibexpeak_config *config = NULL;
38 
39  /*
40  * Enable some common LPC IO ranges:
41  * - 0x2e/0x2f, 0x4e/0x4f often SuperIO
42  * - 0x60/0x64, 0x62/0x66 often KBC/EC
43  * - 0x3f0-0x3f5/0x3f7 FDD
44  * - 0x378-0x37f and 0x778-0x77f LPT
45  * - 0x2f8-0x2ff COMB
46  * - 0x3f8-0x3ff COMA
47  * - 0x208-0x20f GAMEH
48  * - 0x200-0x207 GAMEL
49  */
55 
56  /* Clear PWR_FLR */
59 
62 
63  /* Set up generic decode ranges */
64  if (!dev)
65  return;
66  if (dev->chip_info)
67  config = dev->chip_info;
68  if (!config)
69  return;
70 
75 }
76 
78 {
80 
81  /* Enable RCBA */
82  pci_devfn_t lpc_dev = PCI_DEV(0, 0x1f, 0);
83  pci_write_config32(lpc_dev, RCBA, CONFIG_FIXED_RCBA_MMIO_BASE | 1);
84 
86  set_spi_speed();
87 
88  /* Enable upper 128bytes of CMOS */
89  RCBA32(RC) = (1 << 2);
90 
92 }
void __weak bootblock_early_southbridge_init(void)
Definition: bootblock.c:17
DEVTREE_CONST struct device * pcidev_on_root(uint8_t dev, uint8_t fn)
Definition: device_const.c:260
static void enable_spi_prefetching_and_caching(void)
Definition: early_spi.h:8
static __always_inline void pci_write_config32(const struct device *dev, u16 reg, u32 val)
Definition: pci_ops.h:76
static __always_inline u32 pci_read_config32(const struct device *dev, u16 reg)
Definition: pci_ops.h:58
static __always_inline u8 pci_read_config8(const struct device *dev, u16 reg)
Definition: pci_ops.h:46
static __always_inline void pci_write_config16(const struct device *dev, u16 reg, u16 val)
Definition: pci_ops.h:70
static __always_inline void pci_write_config8(const struct device *dev, u16 reg, u8 val)
Definition: pci_ops.h:64
#define ETR3
Definition: pmc.h:41
#define ETR3_CF9GR
CF9h Global Reset.
Definition: pmc.h:43
enum board_config config
Definition: memory.c:448
#define PCI_DEV(SEGBUS, DEV, FN)
Definition: pci_type.h:14
u32 pci_devfn_t
Definition: pci_type.h:8
#define RCBA
Definition: lpc.h:17
#define GCS
Definition: lpc.h:36
#define FDD_LPC_EN
Definition: lpc.h:43
#define GAMEL_LPC_EN
Definition: lpc.h:42
#define LPT_LPC_EN
Definition: lpc.h:44
#define GAMEH_LPC_EN
Definition: lpc.h:41
#define COMB_LPC_EN
Definition: lpc.h:45
#define KBC_LPC_EN
Definition: lpc.h:40
#define LPC_GEN1_DEC
Definition: lpc.h:47
#define MC_LPC_EN
Definition: lpc.h:39
#define GEN_PMCON_3
Definition: lpc.h:63
#define COMA_LPC_EN
Definition: lpc.h:46
#define LPC_GEN2_DEC
Definition: lpc.h:48
#define LPC_GEN3_DEC
Definition: lpc.h:49
#define CNF2_LPC_EN
Definition: lpc.h:37
#define CNF1_LPC_EN
Definition: lpc.h:38
#define LPC_GEN4_DEC
Definition: lpc.h:50
#define LPC_IO_DEC
Definition: lpc.h:35
#define LPC_EN
Definition: lpc.h:36
#define RC
Definition: rcba.h:120
#define PCH_LPC_DEV
Definition: lpc.h:7
#define RCBA8(x)
Definition: rcba.h:12
#define RCBA32(x)
Definition: rcba.h:14
static void early_lpc_init(void)
Definition: bootblock.c:34
static void enable_port80_on_lpc(void)
Definition: bootblock.c:9
static void set_spi_speed(void)
Definition: bootblock.c:14
#define NULL
Definition: stddef.h:19
uint32_t u32
Definition: stdint.h:51
uint8_t u8
Definition: stdint.h:45
Definition: device.h:107
DEVTREE_CONST void * chip_info
Definition: device.h:164