coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
romstage.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <arch/romstage.h>
4 #include <arch/io.h>
5 #include <cf9_reset.h>
6 #include <console/console.h>
7 #include <device/pci_ops.h>
8 #include <soc/fiamux.h>
9 #include <device/mmio.h>
10 #include <soc/iomap.h>
11 #include <soc/pci_devs.h>
12 #include <soc/pcr.h>
13 #include <soc/pmc.h>
14 #include <soc/romstage.h>
15 #include <soc/smbus.h>
16 #include <soc/soc_util.h>
17 #include <soc/hob_mem.h>
18 
20 
21 #if CONFIG(DISPLAY_HOBS)
22 static void display_fsp_smbios_memory_info_hob(void)
23 {
24  const FSP_SMBIOS_MEMORY_INFO *memory_info_hob;
25 
26  /* Get the memory info HOB */
27  memory_info_hob = soc_get_fsp_smbios_memory_info_hob();
28 
29  if (memory_info_hob == NULL)
30  return;
31 
33 }
34 #endif
35 
36 static void early_pmc_init(void)
37 {
38  /* PMC (B0:D31:F2). */
40 
41  /* Is PMC present */
42  if (pci_read_config16(dev, 0) == 0xffff) {
43  printk(BIOS_ERR, "PMC controller (B0:D31:F2) does not present!\n");
44  return;
45  }
46 
47  uint32_t pwrm_base =
49  if (!pwrm_base) {
50  printk(BIOS_ERR, "PWRM base address is not configured!\n");
51  return;
52  }
53 
54  /* Workaround for sighting report (doc#: 560805) v1.86.
55  42. System Might Hang In AC Power Loss
56  Problem :
57  When removing and reapplying AC power to the board,
58  the system might hang at serial output
59  'RESET required : change of frequency'
60  due to PMC ROM change on B0.
61  Implication :
62  1. This issue is only shown in B0 stepping.
63  2. This issue does not impact a system without an RTC battery.
64  Alternative workaround :
65  Remove RTC battery on the board if possible.
66  Status : Plan Fix.
67  */
69  if (!(pci_read_config32(dev, GEN_PMCON_B)
71  if (read32((void *)(pwrm_base + 0x124))
72  & ((1 << 11) | (1 << 12))) {
73  /* Performs a global reset */
75  "Requesting Global Reset...\n");
78  | ETR3_CF9GR);
79  full_reset();
80  }
81  }
82  }
83 }
84 
85 static void early_tco_init(void)
86 {
87  /* SMBUS (B0:D31:F4). */
89 
90  /* Configure TCO base address */
91  if (pci_read_config16(dev, TCOBASE) == 0xffff) {
92  printk(BIOS_ERR, "SMBus controller (B0:D31:F4) does not present!\n");
93  return;
94  }
95  uint16_t tco_ctl = pci_read_config16(dev, TCOCTL);
96  if (tco_ctl & TCOBASE_LOCK) {
97  printk(BIOS_ERR, "TCO base register already has been locked!\n");
98  } else {
99  pci_write_config16(dev, TCOCTL, tco_ctl & (~TCOBASE_EN));
101  pci_write_config16(dev, TCOCTL, tco_ctl | TCOBASE_EN);
102  }
103 
104  uint16_t tco_base = pci_read_config16(dev, TCOBASE) & MASK_TCOBASE;
105  printk(BIOS_DEBUG, "TCO base address set to 0x%x!\n", tco_base);
106 
107  /* Disable the TCO timer expiration from causing a system reset */
110 
111  /* Halt the TCO timer */
112  uint16_t reg16 = inw(tco_base + TCO1_CNT);
113  reg16 |= TCO_TMR_HLT;
114  outw(reg16, tco_base + TCO1_CNT);
115 
116  /* Clear the Second TCO status bit */
117  reg16 = inw(tco_base + TCO2_STS);
118  reg16 |= TCO2_STS_SECOND_TO;
119  outw(reg16, tco_base + TCO2_STS);
120 }
121 
123 {
124  printk(BIOS_DEBUG, "FSP TempRamInit was successful...\n");
125 
127  early_tco_init();
128  early_pmc_init();
129 
130  fsp_memory_init(false);
131 
132 #if CONFIG(DISPLAY_HOBS)
133  display_fsp_smbios_memory_info_hob();
134 #endif
135 }
136 
138 {
139  FSPM_UPD *mupd = container_of(m_cfg, FSPM_UPD, FspmConfig);
140  size_t num;
141  uint16_t supported_hsio_lanes;
142  BL_HSIO_INFORMATION *hsio_config;
143 
144  /* Set the parameters for MemoryInit */
145  m_cfg->PcdEnableIQAT = CONFIG(IQAT_ENABLE);
146 
147  /* if ME HECI communication is disabled, apply default one*/
148  if (mupd->FspmConfig.PcdMeHeciCommunication == 0) {
149 
150  /* Configure FIA MUX PCD */
151  /* Assume the validating silicon has max lanes. */
152  supported_hsio_lanes = BL_ME_FIA_MUX_LANE_NUM_MAX;
153 
154  num = mainboard_get_hsio_config(&hsio_config);
155 
156  if (get_fiamux_hsio_info(supported_hsio_lanes, num,
157  &hsio_config))
158  die("HSIO Configuration is invalid, please correct "
159  "it!");
160 
161  /* Check the requested FIA MUX Configuration */
162  if (!(&hsio_config->FiaConfig)) {
163  die("Requested FIA MUX Configuration is invalid,"
164  " please correct it!");
165  }
166 
167  mupd->FspmConfig.PcdHsioLanesNumber =
168  (uint32_t)hsio_config->NumLanesSupported;
169  mupd->FspmConfig.PcdFiaMuxConfigPtr =
170  (uint32_t)&hsio_config->FiaConfig;
171  }
172 }
173 
175 {
176  /* Do nothing */
177 }
178 
180 {
181  FSP_M_CONFIG *m_cfg = &mupd->FspmConfig;
182 
183  soc_memory_init_params(m_cfg);
184 
186 }
static uint32_t read32(const void *addr)
Definition: mmio.h:22
#define TCO2_STS_SECOND_TO
Definition: pm.h:61
void full_reset(void)
Definition: cf9_reset.c:45
#define printk(level,...)
Definition: stdlib.h:16
void __noreturn die(const char *fmt,...)
Definition: die.c:17
#define PCH_PCR_ADDRESS(Pid, Offset)
Definition: pcr.h:10
@ PID_SMB
Definition: pcr.h:15
u16 inw(u16 port)
void outw(u16 val, u16 port)
@ CONFIG
Definition: dsi_common.h:201
int get_fiamux_hsio_info(uint16_t num_of_lanes, size_t num_of_entry, BL_HSIO_INFORMATION **config)
Definition: fiamux.c:14
void fsp_memory_init(bool s3wake)
Definition: memory_init.c:350
#define FSP_M_CONFIG
Definition: fsp_upd.h:8
static const FSP_SMBIOS_MEMORY_INFO * soc_get_fsp_smbios_memory_info_hob(void)
Definition: hob_mem.h:21
#define container_of(ptr, type, member)
container_of - cast a member of a structure out to the containing structure
Definition: helpers.h:33
static __always_inline void pci_write_config32(const struct device *dev, u16 reg, u32 val)
Definition: pci_ops.h:76
static __always_inline u16 pci_read_config16(const struct device *dev, u16 reg)
Definition: pci_ops.h:52
static __always_inline u32 pci_read_config32(const struct device *dev, u16 reg)
Definition: pci_ops.h:58
static __always_inline void pci_write_config16(const struct device *dev, u16 reg, u16 val)
Definition: pci_ops.h:70
#define GEN_PMCON_B
Definition: pmc.h:53
#define DEFAULT_TCO_BASE
Definition: iomap.h:17
#define ETR3
Definition: pmc.h:41
#define ETR3_CF9GR
CF9h Global Reset.
Definition: pmc.h:43
#define GEN_PMCON_B_RTC_PWR_STS
Definition: pmc.h:38
#define MASK_PMC_PWRM_BASE
Definition: pmc.h:34
#define PMC_PWRM_BASE
Definition: pmc.h:33
uint8_t silicon_stepping(void)
Definition: soc_util.c:225
#define MMIO32_OR(x, or)
Definition: soc_util.h:59
@ SILICON_REV_DENVERTON_B0
Definition: soc_util.h:14
size_t mainboard_get_hsio_config(BL_HSIO_INFORMATION **p_hsio_config)
Definition: hsio.c:7
unsigned int version[2]
Definition: edid.c:55
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
void mainboard_memory_init_params(FSPM_UPD *mupd)
Definition: romstage.c:22
void mainboard_romstage_entry(void)
Definition: romstage.c:6
void mainboard_config_gpios(void)
Definition: romstage.c:70
#define PCI_DEV(SEGBUS, DEV, FN)
Definition: pci_type.h:14
u32 pci_devfn_t
Definition: pci_type.h:8
const struct smm_save_state_ops *legacy_ops __weak
Definition: save_state.c:8
#define SMBUS_DEV
Definition: pci_devs.h:115
#define SMBUS_FUNC
Definition: pci_devs.h:116
#define PCH_DEV_PMC
Definition: pci_devs.h:236
#define TCO_TMR_HLT
Definition: smbus.h:14
#define TCO2_STS
Definition: smbus.h:9
#define TCO1_CNT
Definition: smbus.h:12
void platform_fsp_memory_init_params_cb(FSPM_UPD *mupd, uint32_t version)
Definition: romstage.c:279
void soc_memory_init_params(struct romstage_params *params, MEMORY_INIT_UPD *upd)
Definition: romstage.c:99
void soc_display_fsp_smbios_memory_info_hob(const FSP_SMBIOS_MEMORY_INFO *memory_info_hob)
Definition: hob_display.c:60
#define PCR_SMBUS_GC
Definition: smbus.h:40
#define PCR_SMBUS_GC_NR
Definition: smbus.h:42
#define TCOBASE_LOCK
Definition: smbus.h:18
#define TCOBASE_EN
Definition: smbus.h:17
#define MASK_TCOBASE
Definition: smbus.h:15
static void early_tco_init(void)
Definition: romstage.c:85
static void early_pmc_init(void)
Definition: romstage.c:36
#define NULL
Definition: stddef.h:19
unsigned short uint16_t
Definition: stdint.h:11
unsigned int uint32_t
Definition: stdint.h:14
#define TCOBASE
Definition: tco.c:21
#define TCOCTL
Definition: tco.c:22