coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
early_pch.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/device.h>
6 #include <device/pci_def.h>
7 #include <device/smbus_host.h>
9 #include <elog.h>
10 #include "pch.h"
11 #include "chip.h"
12 
13 #if CONFIG(INTEL_LYNXPOINT_LP)
14 #include "lp_gpio.h"
15 #else
17 #endif
18 
20 {
22 
23  /* Check if this is a LPT-LP or WPT-LP device ID */
24  if ((did & 0xff00) == 0x9c00)
25  return PCH_TYPE_ULT;
26 
27  /* Non-LP laptop SKUs have an odd device ID (least significant bit is one) */
28  if (did & 1)
29  return PCH_TYPE_MOBILE;
30 
31  /* Desktop and Server SKUs have an even device ID */
32  return PCH_TYPE_DESKTOP;
33 }
34 
35 static void pch_enable_bars(void)
36 {
37  pci_write_config32(PCH_LPC_DEV, RCBA, CONFIG_FIXED_RCBA_MMIO_BASE | 1);
38 
40  /* Enable ACPI BAR */
42 
44 
45  /* Enable GPIO functionality. */
47 }
48 
49 static void pch_generic_setup(void)
50 {
51  printk(BIOS_DEBUG, "Disabling Watchdog reboot...");
52  RCBA32(GCS) = RCBA32(GCS) | (1 << 5); /* No reset */
53  write_pmbase16(0x60 | 0x08, (1 << 11)); /* halt timer */
54  printk(BIOS_DEBUG, " done.\n");
55 }
56 
57 void pch_enable_lpc(void)
58 {
59  const struct device *dev = pcidev_on_root(0x1f, 0);
61 
62  /* Set COM1/COM2 decode range */
64 
65  /* Enable SuperIO + MC + COM1 + PS/2 Keyboard/Mouse */
66  u16 lpc_config = CNF1_LPC_EN | CNF2_LPC_EN | GAMEL_LPC_EN |
69 
70  /* Set up generic decode ranges */
71  if (!dev)
72  return;
73  if (dev->chip_info)
74  config = dev->chip_info;
75  if (!config)
76  return;
77 
82 }
83 
85 {
86 }
87 
88 void early_pch_init(void)
89 {
91 
92 #if CONFIG(INTEL_LYNXPOINT_LP)
94 #else
96 #endif
98 
99  /* Enable SMBus for reading SPDs. */
100  enable_smbus();
101 
102  /* Enable IOAPIC */
103  RCBA16(OIC) = 0x0100;
104 
105  /* PCH BWG says to read back the IOAPIC enable register */
106  (void)RCBA16(OIC);
107 
108  /* Mainboard RCBA settings */
110 
112 
113  RCBA32(0x2088) = 0x00109000;
114 
115  RCBA32_OR(0x20ac, 1 << 30);
116 
117  if (!pch_is_lp()) {
118  RCBA32_AND_OR(0x2340, ~(0xff << 0), 0x1b << 0);
119  RCBA32_AND_OR(0x2340, ~(0xff << 16), 0x3a << 16);
120 
121  RCBA32(0x2324) = 0x00854c74;
122  }
123 }
#define printk(level,...)
Definition: stdlib.h:16
uint16_t did
Definition: tis.c:16
DEVTREE_CONST struct device * pcidev_on_root(uint8_t dev, uint8_t fn)
Definition: device_const.c:260
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 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 DEFAULT_PMBASE
Definition: iomap.h:14
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
void setup_pch_lp_gpios(const struct pch_lp_gpio_map map[])
Definition: lp_gpio.c:50
const struct pch_gpio_map mainboard_gpio_map
Definition: gpio.c:87
void mainboard_config_rcba(void)
Definition: romstage.c:7
const struct pch_lp_gpio_map mainboard_lp_gpio_map[]
Definition: gpio.c:5
enum board_config config
Definition: memory.c:448
#define PCI_DEVICE_ID
Definition: pci_def.h:9
void write_pmbase16(const u8 addr, const u16 val)
Definition: pmbase.c:43
const struct smm_save_state_ops *legacy_ops __weak
Definition: save_state.c:8
static void enable_smbus(void)
Definition: smbus_host.h:34
#define RCBA
Definition: lpc.h:17
#define GCS
Definition: lpc.h:36
#define GAMEL_LPC_EN
Definition: lpc.h:42
#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 COMA_LPC_EN
Definition: lpc.h:46
#define PMBASE
Definition: lpc.h:8
#define LPC_GEN2_DEC
Definition: lpc.h:48
#define LPC_GEN3_DEC
Definition: lpc.h:49
#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 GPIO_BASE
Definition: lpc.h:21
#define LPC_GEN4_DEC
Definition: lpc.h:50
#define LPC_IO_DEC
Definition: lpc.h:35
#define LPC_EN
Definition: lpc.h:36
#define PCH_DISABLE_ALWAYS
Definition: rcba.h:132
#define OIC
Definition: rcba.h:100
#define FD
Definition: rcba.h:125
#define PCH_LPC_DEV
Definition: lpc.h:7
void early_pch_init(void)
Definition: early_pch.c:299
#define DEFAULT_GPIOBASE
Definition: pch.h:22
void setup_pch_gpios(const struct pch_gpio_map *gpio)
Definition: gpio.c:33
#define RCBA32_OR(x, or)
Definition: rcba.h:22
#define RCBA32_AND_OR(x, and, or)
Definition: rcba.h:21
#define RCBA16(x)
Definition: rcba.h:13
#define RCBA32(x)
Definition: rcba.h:14
void __weak mainboard_config_superio(void)
Definition: early_pch.c:84
static void pch_enable_bars(void)
Definition: early_pch.c:35
enum pch_platform_type get_pch_platform_type(void)
Definition: early_pch.c:19
void pch_enable_lpc(void)
Definition: early_pch.c:57
static void pch_generic_setup(void)
Definition: early_pch.c:49
static int pch_is_lp(void)
Definition: pch.h:104
pch_platform_type
Definition: pch.h:110
@ PCH_TYPE_DESKTOP
Definition: pch.h:112
@ PCH_TYPE_ULT
Definition: pch.h:113
@ PCH_TYPE_MOBILE
Definition: pch.h:111
#define NULL
Definition: stddef.h:19
uint16_t u16
Definition: stdint.h:48
Definition: device.h:107
DEVTREE_CONST void * chip_info
Definition: device.h:164
typedef void(X86APIP X86EMU_intrFuncs)(int num)