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 <stdint.h>
5 #include <string.h>
6 #include <device/pci_ops.h>
7 #include <console/console.h>
13 #include "ec/google/chromeec/ec.h"
14 #include <cbfs.h>
15 
17 
19 {
20  /* Enable additional 0x200..0x207 for EC */
22 }
23 
25 {
26  /*
27  * GFX INTA -> PIRQA (MSI)
28  * D28IP_P3IP WLAN INTA -> PIRQB
29  * D29IP_E1P EHCI1 INTA -> PIRQD
30  * D26IP_E2P EHCI2 INTA -> PIRQF
31  * D31IP_SIP SATA INTA -> PIRQF (MSI)
32  * D31IP_SMIP SMBUS INTB -> PIRQH
33  * D31IP_TTIP THRT INTC -> PIRQA
34  * D27IP_ZIP HDA INTA -> PIRQA (MSI)
35  *
36  * TRACKPAD -> PIRQE (Edge Triggered)
37  * TOUCHSCREEN -> PIRQG (Edge Triggered)
38  */
39 
40  /* Device interrupt pin register (board specific) */
41  RCBA32(D31IP) = (INTC << D31IP_TTIP) | (NOINT << D31IP_SIP2) |
42  (INTB << D31IP_SMIP) | (INTA << D31IP_SIP);
43  RCBA32(D30IP) = (NOINT << D30IP_PIP);
44  RCBA32(D29IP) = (INTA << D29IP_E1P);
45  RCBA32(D28IP) = (INTA << D28IP_P3IP);
46  RCBA32(D27IP) = (INTA << D27IP_ZIP);
47  RCBA32(D26IP) = (INTA << D26IP_E2P);
48  RCBA32(D25IP) = (NOINT << D25IP_LIP);
50 
51  /* Device interrupt route registers */
59 }
60 
61 static uint8_t *locate_spd(void)
62 {
63  const int gpio_vector[] = {41, 42, 43, 10, -1};
64  uint8_t *spd_file;
65  size_t spd_file_len;
66  int spd_index = get_gpios(gpio_vector);
67 
68  printk(BIOS_DEBUG, "spd index %d\n", spd_index);
69  spd_file = cbfs_map("spd.bin", &spd_file_len);
70  if (!spd_file)
71  die("SPD data not found.");
72 
73  if (spd_file_len < ((spd_index + 1) * 256)) {
74  printk(BIOS_ERR, "spd index override to 0 - old hardware?\n");
75  spd_index = 0;
76  }
77 
78  if (spd_file_len < 256)
79  die("Missing SPD data.");
80 
81  return spd_file + spd_index * 256;
82 }
83 
85 {
86  struct pei_data pei_data_template = {
88  .mchbar = CONFIG_FIXED_MCHBAR_MMIO_BASE,
89  .dmibar = CONFIG_FIXED_DMIBAR_MMIO_BASE,
90  .epbar = CONFIG_FIXED_EPBAR_MMIO_BASE,
91  .pciexbar = CONFIG_ECAM_MMCONF_BASE_ADDRESS,
92  .smbusbar = CONFIG_FIXED_SMBUS_IO_BASE,
93  .wdbbar = 0x4000000,
94  .wdbsize = 0x1000,
95  .hpet_address = HPET_BASE_ADDRESS,
96  .rcba = (uintptr_t)DEFAULT_RCBA,
99  .thermalbase = 0xfed08000,
100  .system_type = 0, // 0 Mobile, 1 Desktop/Server
101  .tseg_size = CONFIG_SMM_TSEG_SIZE,
102  .ts_addresses = { 0x00, 0x00, 0x00, 0x00 },
103  .ec_present = 1,
104  .ddr3lv_support = 1,
105  .max_ddr3_freq = 1600,
106  .usb_port_config = {
107  /* Empty and onboard Ports 0-7, set to un-used pin OC3 */
108  { 0, 3, 0x0000 }, /* P0: Empty */
109  { 1, 0, 0x0040 }, /* P1: Left USB 1 (OC0) */
110  { 1, 1, 0x0040 }, /* P2: Left USB 2 (OC1) */
111  { 1, 3, 0x0040 }, /* P3: SDCARD (no OC) */
112  { 0, 3, 0x0000 }, /* P4: Empty */
113  { 1, 3, 0x0040 }, /* P5: WWAN (no OC) */
114  { 0, 3, 0x0000 }, /* P6: Empty */
115  { 0, 3, 0x0000 }, /* P7: Empty */
116  /* Empty and onboard Ports 8-13, set to un-used pin OC4 */
117  { 1, 4, 0x0040 }, /* P8: Camera (no OC) */
118  { 1, 4, 0x0040 }, /* P9: Bluetooth (no OC) */
119  { 0, 4, 0x0000 }, /* P10: Empty */
120  { 0, 4, 0x0000 }, /* P11: Empty */
121  { 0, 4, 0x0000 }, /* P12: Empty */
122  { 0, 4, 0x0000 }, /* P13: Empty */
123  },
124  };
125  *pei_data = pei_data_template;
126  /* LINK has 2 channels of memory down, so spd_data[0] and [2]
127  both need to be populated */
129  sizeof(pei_data->spd_data[0]));
131  sizeof(pei_data->spd_data[0]));
132 }
133 
134 const struct southbridge_usb_port mainboard_usb_ports[] = {
135  /* enabled power USB oc pin */
136  { 0, 0, -1 }, /* P0: Empty */
137  { 1, 0, 0 }, /* P1: Left USB 1 (OC0) */
138  { 1, 0, 1 }, /* P2: Left USB 2 (OC1) */
139  { 1, 0, -1 }, /* P3: SDCARD (no OC) */
140  { 0, 0, -1 }, /* P4: Empty */
141  { 1, 0, -1 }, /* P5: WWAN (no OC) */
142  { 0, 0, -1 }, /* P6: Empty */
143  { 0, 0, -1 }, /* P7: Empty */
144  { 1, 0, -1 }, /* P8: Camera (no OC) */
145  { 1, 0, -1 }, /* P9: Bluetooth (no OC) */
146  { 0, 0, -1 }, /* P10: Empty */
147  { 0, 0, -1 }, /* P11: Empty */
148  { 0, 0, -1 }, /* P12: Empty */
149  { 0, 0, -1 }, /* P13: Empty */
150 };
151 
152 void mainboard_get_spd(spd_raw_data *spd, bool id_only)
153 {
154  /* LINK has 2 channels of memory down, so spd_data[0] and [2]
155  both need to be populated */
156  memcpy(&spd[0], locate_spd(), 128);
157  memcpy(&spd[2], &spd[0], 128);
158 }
159 
160 void mainboard_early_init(int s3resume)
161 {
162  if (!s3resume) {
163  /* This is the fastest way to let users know
164  * the Intel CPU is now alive.
165  */
167  }
168 }
169 
170 int mainboard_should_reset_usb(int s3resume)
171 {
172  return !s3resume;
173 }
#define HPET_BASE_ADDRESS
Definition: hpet.h:6
void * memcpy(void *dest, const void *src, size_t n)
Definition: memcpy.c:7
#define PIRQH
Definition: irq.h:101
#define PIRQC
Definition: irq.h:96
#define PIRQA
Definition: irq.h:94
#define PIRQD
Definition: irq.h:97
#define PIRQB
Definition: irq.h:95
#define PIRQF
Definition: irq.h:99
#define PIRQE
Definition: irq.h:98
#define PIRQG
Definition: irq.h:100
static void * cbfs_map(const char *name, size_t *size_out)
Definition: cbfs.h:246
#define printk(level,...)
Definition: stdlib.h:16
void __noreturn die(const char *fmt,...)
Definition: die.c:17
int google_chromeec_kbbacklight(int percent)
Definition: ec.c:75
u8 spd_raw_data[256]
Definition: ddr3.h:156
static __always_inline void pci_or_config16(const struct device *dev, u16 reg, u16 ormask)
Definition: pci_ops.h:180
#define DEFAULT_PMBASE
Definition: iomap.h:14
#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_late_rcba_config(void)
Definition: early_init.c:6
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
static const int spd_index[32]
Definition: memory.c:10
void mainboard_early_init(void)
Definition: early_init.c:13
#define PEI_VERSION
Definition: pei_data.h:9
#define GAMEL_LPC_EN
Definition: lpc.h:42
#define LPC_EN
Definition: lpc.h:36
#define D28IP_P3IP
Definition: rcba.h:71
#define D31IP_TTIP
Definition: rcba.h:57
#define D25IP
Definition: rcba.h:78
#define D31IR
Definition: rcba.h:87
#define D22IP
Definition: rcba.h:80
#define D26IR
Definition: rcba.h:92
#define D31IP_SMIP
Definition: rcba.h:59
#define D28IR
Definition: rcba.h:90
#define INTA
Definition: rcba.h:21
#define D26IP_E2P
Definition: rcba.h:77
#define D31IP
Definition: rcba.h:56
#define D31IP_SIP2
Definition: rcba.h:58
#define D30IP_PIP
Definition: rcba.h:62
#define D22IR
Definition: rcba.h:95
#define D29IP
Definition: rcba.h:63
#define D25IR
Definition: rcba.h:93
#define DIR_ROUTE(a, b, c, d)
Definition: rcba.h:116
#define D29IR
Definition: rcba.h:89
#define D25IP_LIP
Definition: rcba.h:79
#define D27IP
Definition: rcba.h:74
#define D27IP_ZIP
Definition: rcba.h:75
#define D27IR
Definition: rcba.h:91
#define NOINT
Definition: rcba.h:20
#define D30IP
Definition: rcba.h:61
#define INTC
Definition: rcba.h:23
#define D26IP
Definition: rcba.h:76
#define D29IP_E1P
Definition: rcba.h:64
#define D28IP
Definition: rcba.h:65
#define D31IP_SIP
Definition: rcba.h:60
#define INTB
Definition: rcba.h:22
#define D22IP_MEI1IP
Definition: rcba.h:84
#define PCH_LPC_DEV
Definition: lpc.h:7
#define DEFAULT_GPIOBASE
Definition: pch.h:22
unsigned int get_gpios(const int *gpio_num_array)
Definition: gpio.c:107
#define DEFAULT_RCBA
Definition: rcba.h:6
#define RCBA32(x)
Definition: rcba.h:14
static u16 pmbase
Definition: smi.c:27
unsigned long uintptr_t
Definition: stdint.h:21
unsigned char uint8_t
Definition: stdint.h:8
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
uint8_t ts_addresses[4]
Definition: pei_data.h:37
uint8_t spd_data[4][SPD_LEN]
Definition: pei_data.h:85
uint32_t thermalbase
Definition: pei_data.h:33