coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
early_init.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <console/console.h>
4 #include <device/pci_ops.h>
5 #include <device/smbus_host.h>
8 #include "i82801gx.h"
9 #include "chip.h"
10 
12 {
13  const pci_devfn_t d31f0 = PCI_DEV(0, 0x1f, 0);
14  const struct device *dev = pcidev_on_root(0x1f, 0);
16 
17  /* Configure serial IRQs.*/
18  pci_write_config8(d31f0, SERIRQ_CNTL, 0xd0);
19  /*
20  * Enable some common LPC IO ranges:
21  * - 0x2e/0x2f, 0x4e/0x4f often SuperIO
22  * - 0x60/0x64, 0x62/0x66 often KBC/EC
23  * - 0x3f0-0x3f5/0x3f7 FDD
24  * - 0x378-0x37f and 0x778-0x77f LPT
25  * - 0x2f8-0x2ff COMB
26  * - 0x3f8-0x3ff COMA
27  * - 0x208-0x20f GAMEH
28  * - 0x200-0x207 GAMEL
29  */
30  pci_write_config16(d31f0, LPC_IO_DEC, 0x0010);
35 
36  /* Set up generic decode ranges */
37  if (!dev || !dev->chip_info)
38  return;
39  config = dev->chip_info;
40 
41  pci_write_config32(d31f0, GEN1_DEC, config->gen1_dec);
42  pci_write_config32(d31f0, GEN2_DEC, config->gen2_dec);
43  pci_write_config32(d31f0, GEN3_DEC, config->gen3_dec);
44  pci_write_config32(d31f0, GEN4_DEC, config->gen4_dec);
45 }
46 
48 {
49  const pci_devfn_t d31f0 = PCI_DEV(0, 0x1f, 0);
50  pci_write_config32(d31f0, RCBA, CONFIG_FIXED_RCBA_MMIO_BASE | 1);
53 
56 }
57 
58 #define TCO_BASE 0x60
59 
60 #if ENV_ROMSTAGE
61 void i82801gx_early_init(void)
62 {
63  enable_smbus();
64 
65  printk(BIOS_DEBUG, "Setting up static southbridge registers...");
67 
69  printk(BIOS_DEBUG, " done.\n");
70 
71  printk(BIOS_DEBUG, "Disabling Watchdog reboot...");
72  RCBA32(GCS) = RCBA32(GCS) | (1 << 5); /* No reset */
73  write_pmbase16(TCO_BASE + 0x8, (1 << 11)); /* halt timer */
74  write_pmbase16(TCO_BASE + 0x4, (1 << 3)); /* clear timeout */
75  write_pmbase16(TCO_BASE + 0x6, (1 << 1)); /* clear 2nd timeout */
76  printk(BIOS_DEBUG, " done.\n");
77 
78  /* program secondary mlt XXX byte? */
79  pci_write_config8(PCI_DEV(0, 0x1e, 0), SMLT, 0x20);
80 
81  /* reset rtc power status */
83 
84  /* USB transient disconnect */
85  pci_or_config8(PCI_DEV(0, 0x1f, 0), 0xad, 3 << 0);
86 
87  pci_or_config32(PCI_DEV(0, 0x1d, 7), 0xfc, (1 << 29) | (1 << 17));
88 
89  pci_or_config32(PCI_DEV(0, 0x1d, 7), 0xdc, (1 << 31) | (1 << 27));
90 
91  /* Enable IOAPIC */
92  RCBA8(OIC) = 0x03;
93  RCBA8(OIC);
94 
95  /* A lot of CIR bits relate DMI setup which is likely not correctly
96  done for x4x. The issue is also present on ICH10. */
97  if (!CONFIG(NORTHBRIDGE_INTEL_X4X))
99 }
100 #endif
#define GPIO_EN
Definition: pm.h:67
#define printk(level,...)
Definition: stdlib.h:16
DEVTREE_CONST struct device * pcidev_on_root(uint8_t dev, uint8_t fn)
Definition: device_const.c:260
@ CONFIG
Definition: dsi_common.h:201
void ich7_setup_cir(void)
Definition: early_cir.c:8
void i82801gx_early_init(void)
#define GEN2_DEC
Definition: i82801gx.h:89
#define GEN4_DEC
Definition: i82801gx.h:91
#define GEN3_DEC
Definition: i82801gx.h:90
#define GEN1_DEC
Definition: i82801gx.h:88
static __always_inline void pci_or_config32(const struct device *dev, u16 reg, u32 ormask)
Definition: pci_ops.h:191
static __always_inline void pci_write_config32(const struct device *dev, u16 reg, u32 val)
Definition: pci_ops.h:76
static __always_inline void pci_and_config8(const struct device *dev, u16 reg, u8 andmask)
Definition: pci_ops.h:136
static __always_inline void pci_or_config8(const struct device *dev, u16 reg, u8 ormask)
Definition: pci_ops.h:169
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 ACPI_EN
Definition: pmc.h:146
#define RTC_BATTERY_DEAD
Definition: pmc.h:61
#define DEFAULT_PMBASE
Definition: iomap.h:14
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
const struct pch_gpio_map mainboard_gpio_map
Definition: gpio.c:87
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
void write_pmbase16(const u8 addr, const u16 val)
Definition: pmbase.c:43
static void enable_smbus(void)
Definition: smbus_host.h:34
#define SERIRQ_CNTL
Definition: espi.h:21
#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 MC_LPC_EN
Definition: lpc.h:39
#define GEN_PMCON_3
Definition: lpc.h:63
#define COMA_LPC_EN
Definition: lpc.h:46
#define PMBASE
Definition: lpc.h:8
#define GPIO_CNTL
Definition: lpc.h:22
#define CNF2_LPC_EN
Definition: lpc.h:37
#define ACPI_CNTL
Definition: lpc.h:9
#define CNF1_LPC_EN
Definition: lpc.h:38
#define LPC_IO_DEC
Definition: lpc.h:35
#define LPC_EN
Definition: lpc.h:36
#define GPIOBASE
Definition: lpc.h:19
#define OIC
Definition: rcba.h:100
#define SMLT
Definition: pch.h:73
#define DEFAULT_GPIOBASE
Definition: pch.h:22
void setup_pch_gpios(const struct pch_gpio_map *gpio)
Definition: gpio.c:33
#define RCBA8(x)
Definition: rcba.h:12
#define RCBA32(x)
Definition: rcba.h:14
void i82801gx_setup_bars(void)
Definition: early_init.c:47
#define TCO_BASE
Definition: early_init.c:58
void i82801gx_lpc_setup(void)
Definition: early_init.c:11
Definition: device.h:107
DEVTREE_CONST void * chip_info
Definition: device.h:164