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 <arch/hpet.h>
4 #include <bootblock_common.h>
5 #include <stdint.h>
6 #include <device/pnp_def.h>
7 #include <device/pnp_ops.h>
8 #include <device/pci_ops.h>
9 #include <device/pci_def.h>
16 
18 {
19  /* Set COM3/COM1 decode ranges: 0x3e8/0x3f8 */
21 
22  /* Enable KBC on 0x06/0x64 (KBC),
23  * EC on 0x62/0x66 (MC),
24  * EC on 0x20c-0x20f (GAMEH),
25  * Super I/O on 0x2e/0x2f (CNF1),
26  * COM1/COM3 decode ranges. */
31 }
32 
34 {
35  int lvds_3v = 0; /* 0 (5V) or 1 (3V3) */
36  int dis_bl_inv = 1; /* backlight inversion: 1 = disabled, 0 = enabled */
37  const pnp_devfn_t dev = PNP_DEV(0x2e, 0x9);
39  pnp_write_config(dev, 0x29, 0x02); /* Pins 119, 120 are GPIO21, 20 */
40  pnp_write_config(dev, PNP_IDX_EN, 0x03); /* Enable GPIO2+3 */
41  pnp_write_config(dev, 0x2a, 0x01); /* Pins 62, 63, 65, 66 are
42  GPIO27, 26, 25, 24 */
43  pnp_write_config(dev, 0x2c, 0xc3); /* Pin 90 is GPIO32,
44  Pins 78~85 are UART B */
45  pnp_write_config(dev, 0x2d, 0x00); /* Pins 67, 68, 70~73, 75, 77 are
46  GPIO57~50 */
48  /* Values can only be changed, when devices are enabled. */
49  pnp_write_config(dev, 0xe3, 0xdd); /* GPIO2 bits 1, 5 are output */
50  pnp_write_config(dev, 0xe4, (dis_bl_inv << 5) | (lvds_3v << 1)); /* GPIO2 bits 1, 5 */
51  /* Disable suspend LED during normal operation */
52  pnp_write_config(dev, PNP_IDX_MSC3, 0x40);
54 }
55 
57 {
58  struct pei_data pei_data_template = {
60  .mchbar = CONFIG_FIXED_MCHBAR_MMIO_BASE,
61  .dmibar = CONFIG_FIXED_DMIBAR_MMIO_BASE,
62  .epbar = CONFIG_FIXED_EPBAR_MMIO_BASE,
63  .pciexbar = CONFIG_ECAM_MMCONF_BASE_ADDRESS,
64  .smbusbar = CONFIG_FIXED_SMBUS_IO_BASE,
65  .wdbbar = 0x4000000,
66  .wdbsize = 0x1000,
67  .hpet_address = HPET_BASE_ADDRESS,
68  .rcba = (uintptr_t)DEFAULT_RCBA,
71  .thermalbase = 0xfed08000,
72  .system_type = 0, /* 0 Mobile, 1 Desktop/Server */
73  .tseg_size = CONFIG_SMM_TSEG_SIZE,
74  .spd_addresses = { 0xA0, 0x00,0xA4,0x00 },
75  .ts_addresses = { 0x00, 0x00, 0x00, 0x00 },
76  .ec_present = 1,
77  .gbe_enable = 1,
78  .ddr3lv_support = 0,
79  .max_ddr3_freq = 1600,
80  .usb_port_config = {
81  /* enabled USB oc pin length */
82  { 1, 0, 0x0040 }, /* P0: lower left USB 3.0 (OC0) */
83  { 1, 0, 0x0040 }, /* P1: upper left USB 3.0 (OC0) */
84  { 1, 0, 0x0040 }, /* P2: lower right USB 3.0 (OC0) */
85  { 1, 0, 0x0040 }, /* P3: upper right USB 3.0 (OC0) */
86  { 1, 0, 0x0040 }, /* P4: lower USB 2.0 (OC0) */
87  { 1, 0, 0x0040 }, /* P5: upper USB 2.0 (OC0) */
88  { 1, 0, 0x0040 }, /* P6: front panel USB 2.0 (OC0) */
89  { 1, 0, 0x0040 }, /* P7: front panel USB 2.0 (OC0) */
90  { 1, 4, 0x0040 }, /* P8: internal USB 2.0 (OC4) */
91  { 1, 4, 0x0040 }, /* P9: internal USB 2.0 (OC4) */
92  { 1, 4, 0x0040 }, /* P10: internal USB 2.0 (OC4) */
93  { 1, 4, 0x0040 }, /* P11: internal USB 2.0 (OC4) */
94  { 1, 4, 0x0040 }, /* P12: internal USB 2.0 (OC4) */
95  { 1, 4, 0x0040 }, /* P13: internal USB 2.0 (OC4) */
96  },
97  .usb3 = {
98  .mode = 3, /* Smart Auto? */
99  .hs_port_switch_mask = 0xf, /* All four ports. */
100  .preboot_support = 1, /* preOS driver? */
101  .xhci_streams = 1, /* Enable. */
102  },
103  .pcie_init = 1,
104  };
105  *pei_data = pei_data_template;
106 }
107 
108 const struct southbridge_usb_port mainboard_usb_ports[] = {
109  /* enabled power USB oc pin */
110  { 1, 0, 0 }, /* P0: lower left USB 3.0 (OC0) */
111  { 1, 0, 0 }, /* P1: upper left USB 3.0 (OC0) */
112  { 1, 0, 0 }, /* P2: lower right USB 3.0 (OC0) */
113  { 1, 0, 0 }, /* P3: upper right USB 3.0 (OC0) */
114  { 1, 0, 0 }, /* P4: lower USB 2.0 (OC0) */
115  { 1, 0, 0 }, /* P5: upper USB 2.0 (OC0) */
116  { 1, 0, 0 }, /* P6: front panel USB 2.0 (OC0) */
117  { 1, 0, 0 }, /* P7: front panel USB 2.0 (OC0) */
118  { 1, 0, 4 }, /* P8: internal USB 2.0 (OC4) */
119  { 1, 0, 4 }, /* P9: internal USB 2.0 (OC4) */
120  { 1, 0, 4 }, /* P10: internal USB 2.0 (OC4) */
121  { 1, 0, 4 }, /* P11: internal USB 2.0 (OC4) */
122  { 1, 0, 4 }, /* P12: internal USB 2.0 (OC4) */
123  { 1, 0, 4 }, /* P13: internal USB 2.0 (OC4) */
124 };
125 
126 void mainboard_get_spd(spd_raw_data *spd, bool id_only)
127 {
128  read_spd(&spd[0], 0x50, id_only);
129  read_spd(&spd[2], 0x52, id_only);
130 }
131 
132 void mainboard_early_init(int s3resume)
133 {
134  /* Enable PEG10 (1x16) */
135  pci_write_config32(PCI_DEV(0, 0, 0), DEVEN,
136  pci_read_config32(PCI_DEV(0, 0, 0), DEVEN) |
137  DEVEN_PEG10);
138 }
139 
140 int mainboard_should_reset_usb(int s3resume)
141 {
142  return !s3resume;
143 }
#define HPET_BASE_ADDRESS
Definition: hpet.h:6
#define DEVEN
Definition: host_bridge.h:16
u8 spd_raw_data[256]
Definition: ddr3.h:156
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 void pci_write_config16(const struct device *dev, u16 reg, u16 val)
Definition: pci_ops.h:70
#define DEFAULT_PMBASE
Definition: iomap.h:14
#define DEVEN_PEG10
Definition: host_bridge.h:11
void bootblock_mainboard_early_init(void)
Definition: early_init.c:11
void mainboard_get_spd(spd_raw_data *spd, bool id_only)
Definition: early_init.c:25
const struct southbridge_usb_port mainboard_usb_ports[]
Definition: early_init.c:8
void mainboard_fill_pei_data(struct pei_data *pei)
Definition: early_init.c:58
int mainboard_should_reset_usb(int s3resume)
Definition: early_init.c:53
void mainboard_early_init(void)
Definition: early_init.c:13
#define PEI_VERSION
Definition: pei_data.h:9
void read_spd(spd_raw_data *spd, u8 addr, bool id_only)
Definition: raminit.c:138
#define PCI_DEV(SEGBUS, DEV, FN)
Definition: pci_type.h:14
#define PNP_IDX_MSC3
Definition: pnp_def.h:17
#define PNP_IDX_EN
Definition: pnp_def.h:4
void pnp_set_logical_device(struct device *dev)
Definition: pnp_device.c:59
void pnp_write_config(struct device *dev, u8 reg, u8 value)
Definition: pnp_device.c:38
#define PNP_DEV(PORT, FUNC)
Definition: pnp_type.h:10
u32 pnp_devfn_t
Definition: pnp_type.h:8
#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 COMA_LPC_EN
Definition: lpc.h:46
#define CNF1_LPC_EN
Definition: lpc.h:38
#define LPC_IO_DEC
Definition: lpc.h:35
#define LPC_EN
Definition: lpc.h:36
#define PCH_LPC_DEV
Definition: lpc.h:7
#define DEFAULT_GPIOBASE
Definition: pch.h:22
#define DEFAULT_RCBA
Definition: rcba.h:6
static u16 pmbase
Definition: smi.c:27
unsigned long uintptr_t
Definition: stdint.h:21
uint8_t spd_addresses[4]
Definition: pei_data.h:60
uint32_t tseg_size
Definition: pei_data.h:59
uint32_t system_type
Definition: pei_data.h:58
uint32_t gpiobase
Definition: pei_data.h:55
uint32_t pei_version
Definition: pei_data.h:43
uint32_t thermalbase
Definition: pei_data.h:33
void pnp_exit_conf_state(pnp_devfn_t dev)
Definition: early_init.c:40
void pnp_enter_conf_state(pnp_devfn_t dev)
Definition: early_init.c:32