blob: 97f656af4d41af7fc44dac9a11c0739bd6e60f93 [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
18/* Stumpy USB Reset Disable defined in cmos.layout */
Julius Wernercd49cce2019-03-05 16:53:33 -080019#if CONFIG(USE_OPTION_TABLE)
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020020#include "option_table.h"
21#define CMOS_USB_RESET_DISABLE (CMOS_VSTART_stumpy_usb_reset_disable >> 3)
22#else
23#define CMOS_USB_RESET_DISABLE (400 >> 3)
24#endif
25#define USB_RESET_DISABLE_MAGIC (0xdd) /* Disable if set to this */
26
Elyes HAOUASf5f1b382018-04-26 09:43:03 +020027#define SUPERIO_DEV PNP_DEV(0x2e, 0)
Edward O'Callaghan1b3acb12014-06-01 18:04:05 +100028#define SERIAL_DEV PNP_DEV(0x2e, IT8772F_SP1)
29#define GPIO_DEV PNP_DEV(0x2e, IT8772F_GPIO)
30
Arthur Heymans9c538342019-11-12 16:42:33 +010031void mainboard_late_rcba_config(void)
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020032{
Kyösti Mälkki6f499062015-06-06 11:52:24 +030033 /*
34 * GFX INTA -> PIRQA (MSI)
35 * D28IP_P1IP WLAN INTA -> PIRQB
36 * D28IP_P4IP ETH0 INTB -> PIRQC
37 * D29IP_E1P EHCI1 INTA -> PIRQD
38 * D26IP_E2P EHCI2 INTA -> PIRQE
39 * D31IP_SIP SATA INTA -> PIRQF (MSI)
40 * D31IP_SMIP SMBUS INTB -> PIRQG
41 * D31IP_TTIP THRT INTC -> PIRQH
42 * D27IP_ZIP HDA INTA -> PIRQG (MSI)
43 */
44
45 /* Device interrupt pin register (board specific) */
46 RCBA32(D31IP) = (INTC << D31IP_TTIP) | (NOINT << D31IP_SIP2) |
47 (INTB << D31IP_SMIP) | (INTA << D31IP_SIP);
48 RCBA32(D30IP) = (NOINT << D30IP_PIP);
49 RCBA32(D29IP) = (INTA << D29IP_E1P);
50 RCBA32(D28IP) = (INTA << D28IP_P1IP) | (INTC << D28IP_P3IP) |
51 (INTB << D28IP_P4IP);
52 RCBA32(D27IP) = (INTA << D27IP_ZIP);
53 RCBA32(D26IP) = (INTA << D26IP_E2P);
54 RCBA32(D25IP) = (NOINT << D25IP_LIP);
55 RCBA32(D22IP) = (NOINT << D22IP_MEI1IP);
56
57 /* Device interrupt route registers */
58 DIR_ROUTE(D31IR, PIRQF, PIRQG, PIRQH, PIRQA);
59 DIR_ROUTE(D29IR, PIRQD, PIRQE, PIRQF, PIRQG);
60 DIR_ROUTE(D28IR, PIRQB, PIRQC, PIRQD, PIRQE);
61 DIR_ROUTE(D27IR, PIRQG, PIRQH, PIRQA, PIRQB);
62 DIR_ROUTE(D26IR, PIRQE, PIRQF, PIRQG, PIRQH);
63 DIR_ROUTE(D25IR, PIRQA, PIRQB, PIRQC, PIRQD);
64 DIR_ROUTE(D22IR, PIRQA, PIRQB, PIRQC, PIRQD);
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020065}
66
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020067static void setup_sio_gpios(void)
68{
69 /*
70 * GPIO10 as USBPWRON12#
71 * GPIO12 as USBPWRON13#
72 */
Elyes HAOUASf5f1b382018-04-26 09:43:03 +020073 it8772f_gpio_setup(SUPERIO_DEV, 1, 0x05, 0x05, 0x00, 0x05, 0x05);
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020074
75 /*
76 * GPIO22 as wake SCI#
77 */
Elyes HAOUASf5f1b382018-04-26 09:43:03 +020078 it8772f_gpio_setup(SUPERIO_DEV, 2, 0x04, 0x04, 0x00, 0x04, 0x04);
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020079
80 /*
81 * GPIO32 as EXTSMI#
82 */
Elyes HAOUASf5f1b382018-04-26 09:43:03 +020083 it8772f_gpio_setup(SUPERIO_DEV, 3, 0x04, 0x04, 0x00, 0x04, 0x04);
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020084
85 /*
86 * GPIO45 as LED_POWER#
87 */
Matt DeVillierffae7462016-11-07 16:43:03 -060088 it8772f_gpio_led(GPIO_DEV, 4 /* set */, (0x1 << 5) /* select */,
89 (0x1 << 5) /* polarity */, (0x1 << 5) /* 1 = pullup */,
Elyes HAOUASa5aad2e2016-09-19 09:47:16 -060090 (0x1 << 5) /* output */, (0x1 << 5) /* 1 = Simple IO function */,
david80ef7b72015-01-19 17:11:36 +080091 SIO_GPIO_BLINK_GPIO45, IT8772F_GPIO_BLINK_FREQUENCY_1_HZ);
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020092
93 /*
94 * GPIO51 as USBPWRON8#
95 * GPIO52 as USBPWRON1#
96 */
Elyes HAOUASf5f1b382018-04-26 09:43:03 +020097 it8772f_gpio_setup(SUPERIO_DEV, 5, 0x06, 0x06, 0x00, 0x06, 0x06);
98 it8772f_gpio_setup(SUPERIO_DEV, 6, 0x00, 0x00, 0x00, 0x00, 0x00);
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020099}
100
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100101void mainboard_fill_pei_data(struct pei_data *pei_data)
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200102{
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100103 struct pei_data pei_data_template = {
Edward O'Callaghanb27d3602014-05-24 02:40:31 +1000104 .pei_version = PEI_VERSION,
Angel Ponsd9e58dc2021-01-20 01:22:20 +0100105 .mchbar = CONFIG_FIXED_MCHBAR_MMIO_BASE,
106 .dmibar = CONFIG_FIXED_DMIBAR_MMIO_BASE,
107 .epbar = CONFIG_FIXED_EPBAR_MMIO_BASE,
Shelley Chen4e9bb332021-10-20 15:43:45 -0700108 .pciexbar = CONFIG_ECAM_MMCONF_BASE_ADDRESS,
Angel Ponsb21bffa2020-07-03 01:02:28 +0200109 .smbusbar = CONFIG_FIXED_SMBUS_IO_BASE,
Edward O'Callaghanb27d3602014-05-24 02:40:31 +1000110 .wdbbar = 0x4000000,
111 .wdbsize = 0x1000,
Felix Held972d9f22022-02-23 16:32:20 +0100112 .hpet_address = HPET_BASE_ADDRESS,
Angel Pons92717ff2020-09-14 16:22:22 +0200113 .rcba = (uintptr_t)DEFAULT_RCBA,
Edward O'Callaghanb27d3602014-05-24 02:40:31 +1000114 .pmbase = DEFAULT_PMBASE,
115 .gpiobase = DEFAULT_GPIOBASE,
116 .thermalbase = 0xfed08000,
117 .system_type = 0, // 0 Mobile, 1 Desktop/Server
118 .tseg_size = CONFIG_SMM_TSEG_SIZE,
119 .spd_addresses = { 0xa0, 0x00,0xa4,0x00 },
120 .ts_addresses = { 0x00, 0x00, 0x00, 0x00 },
121 .ec_present = 0,
Edward O'Callaghanb27d3602014-05-24 02:40:31 +1000122 .max_ddr3_freq = 1333,
123 .usb_port_config = {
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200124 { 1, 0, 0x0080 }, /* P0: Front port (OC0) */
125 { 1, 1, 0x0040 }, /* P1: Back port (OC1) */
126 { 1, 0, 0x0040 }, /* P2: MINIPCIE1 (no OC) */
127 { 1, 0, 0x0040 }, /* P3: MMC (no OC) */
128 { 1, 2, 0x0080 }, /* P4: Front port (OC2) */
129 { 0, 0, 0x0000 }, /* P5: Empty */
130 { 0, 0, 0x0000 }, /* P6: Empty */
131 { 0, 0, 0x0000 }, /* P7: Empty */
132 { 1, 4, 0x0040 }, /* P8: Back port (OC4) */
133 { 1, 4, 0x0040 }, /* P9: MINIPCIE3 (no OC) */
134 { 1, 4, 0x0040 }, /* P10: BLUETOOTH (no OC) */
135 { 0, 4, 0x0000 }, /* P11: Empty */
136 { 1, 6, 0x0040 }, /* P12: Back port (OC6) */
137 { 1, 5, 0x0040 }, /* P13: Back port (OC5) */
138 },
139 };
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100140 *pei_data = pei_data_template;
141}
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200142
Kyösti Mälkkie258b9a2016-11-18 19:59:23 +0200143void mainboard_get_spd(spd_raw_data *spd, bool id_only)
Vladimir Serbinenkod2990c92016-02-10 02:52:42 +0100144{
Kyösti Mälkkie258b9a2016-11-18 19:59:23 +0200145 read_spd(&spd[0], 0x50, id_only);
146 read_spd(&spd[2], 0x52, id_only);
Vladimir Serbinenkod2990c92016-02-10 02:52:42 +0100147}
148
149const struct southbridge_usb_port mainboard_usb_ports[] = {
Elyes HAOUAS44f558e2020-02-24 13:26:04 +0100150 /* enabled power USB oc pin */
Vladimir Serbinenkod2990c92016-02-10 02:52:42 +0100151 { 1, 1, 0 }, /* P0: Front port (OC0) */
152 { 1, 0, 1 }, /* P1: Back port (OC1) */
153 { 1, 0, -1 }, /* P2: MINIPCIE1 (no OC) */
154 { 1, 0, -1 }, /* P3: MMC (no OC) */
155 { 1, 1, 2 }, /* P4: Front port (OC2) */
156 { 0, 0, -1 }, /* P5: Empty */
157 { 0, 0, -1 }, /* P6: Empty */
158 { 0, 0, -1 }, /* P7: Empty */
159 { 1, 0, 4 }, /* P8: Back port (OC4) */
160 { 1, 0, -1 }, /* P9: MINIPCIE3 (no OC) */
161 { 1, 0, -1 }, /* P10: BLUETOOTH (no OC) */
162 { 0, 0, -1 }, /* P11: Empty */
163 { 1, 0, 6 }, /* P12: Back port (OC6) */
164 { 1, 0, 5 }, /* P13: Back port (OC5) */
165};
166
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100167int mainboard_should_reset_usb(int s3resume)
168{
169 if (s3resume) {
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200170 /*
171 * For Stumpy the back USB ports are reset on resume
172 * so default to resetting the controller to make the
173 * kernel happy. There is a CMOS flag to disable the
174 * controller reset in case the kernel can tolerate
175 * the device power loss better in the future.
176 */
177 u8 magic = cmos_read(CMOS_USB_RESET_DISABLE);
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200178 if (magic == USB_RESET_DISABLE_MAGIC) {
179 printk(BIOS_DEBUG, "USB Controller Reset Disabled\n");
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100180 return 0;
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200181 } else {
182 printk(BIOS_DEBUG, "USB Controller Reset Enabled\n");
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100183 return 1;
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200184 }
185 } else {
186 /* Ensure USB reset on resume is enabled at boot */
187 cmos_write(0, CMOS_USB_RESET_DISABLE);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100188 return 1;
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200189 }
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100190}
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200191
Arthur Heymansfa5d0f82019-11-12 19:11:50 +0100192void bootblock_mainboard_early_init(void)
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100193{
Nico Huber25128a72019-11-17 01:24:44 +0100194 if (CONFIG(DRIVERS_UART_8250IO))
195 try_enabling_LPC47N207_uart();
196
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100197 setup_sio_gpios();
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200198
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100199 /* Early SuperIO setup */
Elyes HAOUASf5f1b382018-04-26 09:43:03 +0200200 it8772f_ac_resume_southbridge(SUPERIO_DEV);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100201 ite_kill_watchdog(GPIO_DEV);
202 ite_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200203}