blob: 14fc2528d928160dee01399143957d117638097e [file] [log] [blame]
Angel Ponsd32b6de2020-04-03 01:23:13 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauere1ae4b22012-04-27 23:20:58 +02002
Felix Held972d9f22022-02-23 16:32:20 +01003#include <arch/hpet.h>
Arthur Heymansfa5d0f82019-11-12 19:11:50 +01004#include <bootblock_common.h>
Stefan Reinauere1ae4b22012-04-27 23:20:58 +02005#include <stdint.h>
Stefan Reinauere1ae4b22012-04-27 23:20:58 +02006#include <pc80/mc146818rtc.h>
Stefan Reinauere1ae4b22012-04-27 23:20:58 +02007#include <console/console.h>
Kyösti Mälkkie3ddee02014-05-03 10:45:28 +03008#include <bootmode.h>
Edward O'Callaghan1b3acb12014-06-01 18:04:05 +10009#include <superio/ite/common/ite.h>
10#include <superio/ite/it8772f/it8772f.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110011#include <northbridge/intel/sandybridge/sandybridge.h>
12#include <northbridge/intel/sandybridge/raminit.h>
Vladimir Serbinenkod2990c92016-02-10 02:52:42 +010013#include <northbridge/intel/sandybridge/raminit_native.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110014#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe8e66f42016-02-06 17:42:42 +010015#include <southbridge/intel/common/gpio.h>
Edward O'Callaghan74834e02015-01-04 04:17:35 +110016#include <superio/smsc/lpc47n207/lpc47n207.h>
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020017
Elyes HAOUASf5f1b382018-04-26 09:43:03 +020018#define SUPERIO_DEV PNP_DEV(0x2e, 0)
Edward O'Callaghan1b3acb12014-06-01 18:04:05 +100019#define SERIAL_DEV PNP_DEV(0x2e, IT8772F_SP1)
20#define GPIO_DEV PNP_DEV(0x2e, IT8772F_GPIO)
21
Arthur Heymans9c538342019-11-12 16:42:33 +010022void mainboard_late_rcba_config(void)
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020023{
Kyösti Mälkki6f499062015-06-06 11:52:24 +030024 /*
25 * GFX INTA -> PIRQA (MSI)
26 * D28IP_P1IP WLAN INTA -> PIRQB
27 * D28IP_P4IP ETH0 INTB -> PIRQC
28 * D29IP_E1P EHCI1 INTA -> PIRQD
29 * D26IP_E2P EHCI2 INTA -> PIRQE
30 * D31IP_SIP SATA INTA -> PIRQF (MSI)
31 * D31IP_SMIP SMBUS INTB -> PIRQG
32 * D31IP_TTIP THRT INTC -> PIRQH
33 * D27IP_ZIP HDA INTA -> PIRQG (MSI)
34 */
35
36 /* Device interrupt pin register (board specific) */
37 RCBA32(D31IP) = (INTC << D31IP_TTIP) | (NOINT << D31IP_SIP2) |
38 (INTB << D31IP_SMIP) | (INTA << D31IP_SIP);
39 RCBA32(D30IP) = (NOINT << D30IP_PIP);
40 RCBA32(D29IP) = (INTA << D29IP_E1P);
41 RCBA32(D28IP) = (INTA << D28IP_P1IP) | (INTC << D28IP_P3IP) |
42 (INTB << D28IP_P4IP);
43 RCBA32(D27IP) = (INTA << D27IP_ZIP);
44 RCBA32(D26IP) = (INTA << D26IP_E2P);
45 RCBA32(D25IP) = (NOINT << D25IP_LIP);
46 RCBA32(D22IP) = (NOINT << D22IP_MEI1IP);
47
48 /* Device interrupt route registers */
49 DIR_ROUTE(D31IR, PIRQF, PIRQG, PIRQH, PIRQA);
50 DIR_ROUTE(D29IR, PIRQD, PIRQE, PIRQF, PIRQG);
51 DIR_ROUTE(D28IR, PIRQB, PIRQC, PIRQD, PIRQE);
52 DIR_ROUTE(D27IR, PIRQG, PIRQH, PIRQA, PIRQB);
53 DIR_ROUTE(D26IR, PIRQE, PIRQF, PIRQG, PIRQH);
54 DIR_ROUTE(D25IR, PIRQA, PIRQB, PIRQC, PIRQD);
55 DIR_ROUTE(D22IR, PIRQA, PIRQB, PIRQC, PIRQD);
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020056}
57
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020058static void setup_sio_gpios(void)
59{
60 /*
61 * GPIO10 as USBPWRON12#
62 * GPIO12 as USBPWRON13#
63 */
Elyes HAOUASf5f1b382018-04-26 09:43:03 +020064 it8772f_gpio_setup(SUPERIO_DEV, 1, 0x05, 0x05, 0x00, 0x05, 0x05);
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020065
66 /*
67 * GPIO22 as wake SCI#
68 */
Elyes HAOUASf5f1b382018-04-26 09:43:03 +020069 it8772f_gpio_setup(SUPERIO_DEV, 2, 0x04, 0x04, 0x00, 0x04, 0x04);
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020070
71 /*
72 * GPIO32 as EXTSMI#
73 */
Elyes HAOUASf5f1b382018-04-26 09:43:03 +020074 it8772f_gpio_setup(SUPERIO_DEV, 3, 0x04, 0x04, 0x00, 0x04, 0x04);
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020075
76 /*
77 * GPIO45 as LED_POWER#
78 */
Matt DeVillierffae7462016-11-07 16:43:03 -060079 it8772f_gpio_led(GPIO_DEV, 4 /* set */, (0x1 << 5) /* select */,
80 (0x1 << 5) /* polarity */, (0x1 << 5) /* 1 = pullup */,
Elyes HAOUASa5aad2e2016-09-19 09:47:16 -060081 (0x1 << 5) /* output */, (0x1 << 5) /* 1 = Simple IO function */,
david80ef7b72015-01-19 17:11:36 +080082 SIO_GPIO_BLINK_GPIO45, IT8772F_GPIO_BLINK_FREQUENCY_1_HZ);
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020083
84 /*
85 * GPIO51 as USBPWRON8#
86 * GPIO52 as USBPWRON1#
87 */
Elyes HAOUASf5f1b382018-04-26 09:43:03 +020088 it8772f_gpio_setup(SUPERIO_DEV, 5, 0x06, 0x06, 0x00, 0x06, 0x06);
89 it8772f_gpio_setup(SUPERIO_DEV, 6, 0x00, 0x00, 0x00, 0x00, 0x00);
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020090}
91
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010092void mainboard_fill_pei_data(struct pei_data *pei_data)
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020093{
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010094 struct pei_data pei_data_template = {
Edward O'Callaghanb27d3602014-05-24 02:40:31 +100095 .pei_version = PEI_VERSION,
Angel Ponsd9e58dc2021-01-20 01:22:20 +010096 .mchbar = CONFIG_FIXED_MCHBAR_MMIO_BASE,
97 .dmibar = CONFIG_FIXED_DMIBAR_MMIO_BASE,
98 .epbar = CONFIG_FIXED_EPBAR_MMIO_BASE,
Shelley Chen4e9bb332021-10-20 15:43:45 -070099 .pciexbar = CONFIG_ECAM_MMCONF_BASE_ADDRESS,
Angel Ponsb21bffa2020-07-03 01:02:28 +0200100 .smbusbar = CONFIG_FIXED_SMBUS_IO_BASE,
Edward O'Callaghanb27d3602014-05-24 02:40:31 +1000101 .wdbbar = 0x4000000,
102 .wdbsize = 0x1000,
Felix Held972d9f22022-02-23 16:32:20 +0100103 .hpet_address = HPET_BASE_ADDRESS,
Angel Pons92717ff2020-09-14 16:22:22 +0200104 .rcba = (uintptr_t)DEFAULT_RCBA,
Edward O'Callaghanb27d3602014-05-24 02:40:31 +1000105 .pmbase = DEFAULT_PMBASE,
106 .gpiobase = DEFAULT_GPIOBASE,
107 .thermalbase = 0xfed08000,
108 .system_type = 0, // 0 Mobile, 1 Desktop/Server
109 .tseg_size = CONFIG_SMM_TSEG_SIZE,
110 .spd_addresses = { 0xa0, 0x00,0xa4,0x00 },
111 .ts_addresses = { 0x00, 0x00, 0x00, 0x00 },
112 .ec_present = 0,
Edward O'Callaghanb27d3602014-05-24 02:40:31 +1000113 .max_ddr3_freq = 1333,
114 .usb_port_config = {
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200115 { 1, 0, 0x0080 }, /* P0: Front port (OC0) */
116 { 1, 1, 0x0040 }, /* P1: Back port (OC1) */
117 { 1, 0, 0x0040 }, /* P2: MINIPCIE1 (no OC) */
118 { 1, 0, 0x0040 }, /* P3: MMC (no OC) */
119 { 1, 2, 0x0080 }, /* P4: Front port (OC2) */
120 { 0, 0, 0x0000 }, /* P5: Empty */
121 { 0, 0, 0x0000 }, /* P6: Empty */
122 { 0, 0, 0x0000 }, /* P7: Empty */
123 { 1, 4, 0x0040 }, /* P8: Back port (OC4) */
124 { 1, 4, 0x0040 }, /* P9: MINIPCIE3 (no OC) */
125 { 1, 4, 0x0040 }, /* P10: BLUETOOTH (no OC) */
126 { 0, 4, 0x0000 }, /* P11: Empty */
127 { 1, 6, 0x0040 }, /* P12: Back port (OC6) */
128 { 1, 5, 0x0040 }, /* P13: Back port (OC5) */
129 },
130 };
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100131 *pei_data = pei_data_template;
132}
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200133
Kyösti Mälkkie258b9a2016-11-18 19:59:23 +0200134void mainboard_get_spd(spd_raw_data *spd, bool id_only)
Vladimir Serbinenkod2990c92016-02-10 02:52:42 +0100135{
Kyösti Mälkkie258b9a2016-11-18 19:59:23 +0200136 read_spd(&spd[0], 0x50, id_only);
137 read_spd(&spd[2], 0x52, id_only);
Vladimir Serbinenkod2990c92016-02-10 02:52:42 +0100138}
139
140const struct southbridge_usb_port mainboard_usb_ports[] = {
Elyes HAOUAS44f558e2020-02-24 13:26:04 +0100141 /* enabled power USB oc pin */
Vladimir Serbinenkod2990c92016-02-10 02:52:42 +0100142 { 1, 1, 0 }, /* P0: Front port (OC0) */
143 { 1, 0, 1 }, /* P1: Back port (OC1) */
144 { 1, 0, -1 }, /* P2: MINIPCIE1 (no OC) */
145 { 1, 0, -1 }, /* P3: MMC (no OC) */
146 { 1, 1, 2 }, /* P4: Front port (OC2) */
147 { 0, 0, -1 }, /* P5: Empty */
148 { 0, 0, -1 }, /* P6: Empty */
149 { 0, 0, -1 }, /* P7: Empty */
150 { 1, 0, 4 }, /* P8: Back port (OC4) */
151 { 1, 0, -1 }, /* P9: MINIPCIE3 (no OC) */
152 { 1, 0, -1 }, /* P10: BLUETOOTH (no OC) */
153 { 0, 0, -1 }, /* P11: Empty */
154 { 1, 0, 6 }, /* P12: Back port (OC6) */
155 { 1, 0, 5 }, /* P13: Back port (OC5) */
156};
157
Arthur Heymansfa5d0f82019-11-12 19:11:50 +0100158void bootblock_mainboard_early_init(void)
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100159{
Nico Huber25128a72019-11-17 01:24:44 +0100160 if (CONFIG(DRIVERS_UART_8250IO))
161 try_enabling_LPC47N207_uart();
162
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100163 setup_sio_gpios();
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200164
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100165 /* Early SuperIO setup */
Elyes HAOUASf5f1b382018-04-26 09:43:03 +0200166 it8772f_ac_resume_southbridge(SUPERIO_DEV);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100167 ite_kill_watchdog(GPIO_DEV);
168 ite_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200169}