blob: 03cb8d70a373b1203179430ec2831f716aacacbe [file] [log] [blame]
Stefan Reinauere1ae4b22012-04-27 23:20:58 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2010 coresystems GmbH
5 * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020015 */
16
Arthur Heymansfa5d0f82019-11-12 19:11:50 +010017#include <bootblock_common.h>
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020018#include <stdint.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020019#include <device/pci_ops.h>
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020020#include <device/pci_def.h>
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020021#include <cpu/x86/lapic.h>
22#include <pc80/mc146818rtc.h>
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020023#include <console/console.h>
Kyösti Mälkkie3ddee02014-05-03 10:45:28 +030024#include <bootmode.h>
Edward O'Callaghan1b3acb12014-06-01 18:04:05 +100025#include <superio/ite/common/ite.h>
26#include <superio/ite/it8772f/it8772f.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110027#include <northbridge/intel/sandybridge/sandybridge.h>
28#include <northbridge/intel/sandybridge/raminit.h>
Vladimir Serbinenkod2990c92016-02-10 02:52:42 +010029#include <northbridge/intel/sandybridge/raminit_native.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110030#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe8e66f42016-02-06 17:42:42 +010031#include <southbridge/intel/common/gpio.h>
Julius Wernercd49cce2019-03-05 16:53:33 -080032#if CONFIG(DRIVERS_UART_8250IO)
Edward O'Callaghan74834e02015-01-04 04:17:35 +110033#include <superio/smsc/lpc47n207/lpc47n207.h>
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020034#endif
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020035
36/* Stumpy USB Reset Disable defined in cmos.layout */
Julius Wernercd49cce2019-03-05 16:53:33 -080037#if CONFIG(USE_OPTION_TABLE)
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020038#include "option_table.h"
39#define CMOS_USB_RESET_DISABLE (CMOS_VSTART_stumpy_usb_reset_disable >> 3)
40#else
41#define CMOS_USB_RESET_DISABLE (400 >> 3)
42#endif
43#define USB_RESET_DISABLE_MAGIC (0xdd) /* Disable if set to this */
44
Elyes HAOUASf5f1b382018-04-26 09:43:03 +020045#define SUPERIO_DEV PNP_DEV(0x2e, 0)
Edward O'Callaghan1b3acb12014-06-01 18:04:05 +100046#define SERIAL_DEV PNP_DEV(0x2e, IT8772F_SP1)
47#define GPIO_DEV PNP_DEV(0x2e, IT8772F_GPIO)
48
Arthur Heymans2b28a162019-11-12 17:21:08 +010049void mainboard_pch_lpc_setup(void)
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020050{
51 /* Set COM1/COM2 decode range */
52 pci_write_config16(PCH_LPC_DEV, LPC_IO_DEC, 0x0010);
53
Julius Wernercd49cce2019-03-05 16:53:33 -080054#if CONFIG(DRIVERS_UART_8250IO)
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020055 /* Enable SuperIO + PS/2 Keyboard/Mouse + COM1 + lpc47n207 config*/
56 pci_write_config16(PCH_LPC_DEV, LPC_EN, CNF1_LPC_EN | KBC_LPC_EN |\
57 CNF2_LPC_EN | COMA_LPC_EN);
58
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020059 try_enabling_LPC47N207_uart();
60#else
61 /* Enable SuperIO + PS/2 Keyboard/Mouse */
62 pci_write_config16(PCH_LPC_DEV, LPC_EN, CNF1_LPC_EN | KBC_LPC_EN);
63#endif
64}
65
Arthur Heymans9c538342019-11-12 16:42:33 +010066void mainboard_late_rcba_config(void)
Stefan Reinauere1ae4b22012-04-27 23:20:58 +020067{
Kyösti Mälkki6f499062015-06-06 11:52:24 +030068 /*
69 * GFX INTA -> PIRQA (MSI)
70 * D28IP_P1IP WLAN INTA -> PIRQB
71 * D28IP_P4IP ETH0 INTB -> PIRQC
72 * D29IP_E1P EHCI1 INTA -> PIRQD
73 * D26IP_E2P EHCI2 INTA -> PIRQE
74 * D31IP_SIP SATA INTA -> PIRQF (MSI)
75 * D31IP_SMIP SMBUS INTB -> PIRQG
76 * D31IP_TTIP THRT INTC -> PIRQH
77 * D27IP_ZIP HDA INTA -> PIRQG (MSI)
78 */
79
80 /* Device interrupt pin register (board specific) */
81 RCBA32(D31IP) = (INTC << D31IP_TTIP) | (NOINT << D31IP_SIP2) |
82 (INTB << D31IP_SMIP) | (INTA << D31IP_SIP);
83 RCBA32(D30IP) = (NOINT << D30IP_PIP);
84 RCBA32(D29IP) = (INTA << D29IP_E1P);
85 RCBA32(D28IP) = (INTA << D28IP_P1IP) | (INTC << D28IP_P3IP) |
86 (INTB << D28IP_P4IP);
87 RCBA32(D27IP) = (INTA << D27IP_ZIP);
88 RCBA32(D26IP) = (INTA << D26IP_E2P);
89 RCBA32(D25IP) = (NOINT << D25IP_LIP);
90 RCBA32(D22IP) = (NOINT << D22IP_MEI1IP);
91
92 /* Device interrupt route registers */
93 DIR_ROUTE(D31IR, PIRQF, PIRQG, PIRQH, PIRQA);
94 DIR_ROUTE(D29IR, PIRQD, PIRQE, PIRQF, PIRQG);
95 DIR_ROUTE(D28IR, PIRQB, PIRQC, PIRQD, PIRQE);
96 DIR_ROUTE(D27IR, PIRQG, PIRQH, PIRQA, PIRQB);
97 DIR_ROUTE(D26IR, PIRQE, PIRQF, PIRQG, PIRQH);
98 DIR_ROUTE(D25IR, PIRQA, PIRQB, PIRQC, PIRQD);
99 DIR_ROUTE(D22IR, PIRQA, PIRQB, PIRQC, PIRQD);
100
101 /* Enable IOAPIC (generic) */
Arthur Heymans58a89532018-06-12 22:58:19 +0200102 RCBA16(OIC) = 0x0100;
Kyösti Mälkki6f499062015-06-06 11:52:24 +0300103 /* PCH BWG says to read back the IOAPIC enable register */
Arthur Heymans58a89532018-06-12 22:58:19 +0200104 (void) RCBA16(OIC);
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200105}
106
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200107static void setup_sio_gpios(void)
108{
109 /*
110 * GPIO10 as USBPWRON12#
111 * GPIO12 as USBPWRON13#
112 */
Elyes HAOUASf5f1b382018-04-26 09:43:03 +0200113 it8772f_gpio_setup(SUPERIO_DEV, 1, 0x05, 0x05, 0x00, 0x05, 0x05);
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200114
115 /*
116 * GPIO22 as wake SCI#
117 */
Elyes HAOUASf5f1b382018-04-26 09:43:03 +0200118 it8772f_gpio_setup(SUPERIO_DEV, 2, 0x04, 0x04, 0x00, 0x04, 0x04);
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200119
120 /*
121 * GPIO32 as EXTSMI#
122 */
Elyes HAOUASf5f1b382018-04-26 09:43:03 +0200123 it8772f_gpio_setup(SUPERIO_DEV, 3, 0x04, 0x04, 0x00, 0x04, 0x04);
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200124
125 /*
126 * GPIO45 as LED_POWER#
127 */
Matt DeVillierffae7462016-11-07 16:43:03 -0600128 it8772f_gpio_led(GPIO_DEV, 4 /* set */, (0x1 << 5) /* select */,
129 (0x1 << 5) /* polarity */, (0x1 << 5) /* 1 = pullup */,
Elyes HAOUASa5aad2e2016-09-19 09:47:16 -0600130 (0x1 << 5) /* output */, (0x1 << 5) /* 1 = Simple IO function */,
david80ef7b72015-01-19 17:11:36 +0800131 SIO_GPIO_BLINK_GPIO45, IT8772F_GPIO_BLINK_FREQUENCY_1_HZ);
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200132
133 /*
134 * GPIO51 as USBPWRON8#
135 * GPIO52 as USBPWRON1#
136 */
Elyes HAOUASf5f1b382018-04-26 09:43:03 +0200137 it8772f_gpio_setup(SUPERIO_DEV, 5, 0x06, 0x06, 0x00, 0x06, 0x06);
138 it8772f_gpio_setup(SUPERIO_DEV, 6, 0x00, 0x00, 0x00, 0x00, 0x00);
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200139}
140
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100141void mainboard_fill_pei_data(struct pei_data *pei_data)
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200142{
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100143 struct pei_data pei_data_template = {
Edward O'Callaghanb27d3602014-05-24 02:40:31 +1000144 .pei_version = PEI_VERSION,
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800145 .mchbar = (uintptr_t)DEFAULT_MCHBAR,
146 .dmibar = (uintptr_t)DEFAULT_DMIBAR,
Edward O'Callaghanb27d3602014-05-24 02:40:31 +1000147 .epbar = DEFAULT_EPBAR,
148 .pciexbar = CONFIG_MMCONF_BASE_ADDRESS,
149 .smbusbar = SMBUS_IO_BASE,
150 .wdbbar = 0x4000000,
151 .wdbsize = 0x1000,
152 .hpet_address = CONFIG_HPET_ADDRESS,
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -0800153 .rcba = (uintptr_t)DEFAULT_RCBABASE,
Edward O'Callaghanb27d3602014-05-24 02:40:31 +1000154 .pmbase = DEFAULT_PMBASE,
155 .gpiobase = DEFAULT_GPIOBASE,
156 .thermalbase = 0xfed08000,
157 .system_type = 0, // 0 Mobile, 1 Desktop/Server
158 .tseg_size = CONFIG_SMM_TSEG_SIZE,
159 .spd_addresses = { 0xa0, 0x00,0xa4,0x00 },
160 .ts_addresses = { 0x00, 0x00, 0x00, 0x00 },
161 .ec_present = 0,
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200162 // 0 = leave channel enabled
163 // 1 = disable dimm 0 on channel
164 // 2 = disable dimm 1 on channel
165 // 3 = disable dimm 0+1 on channel
Edward O'Callaghanb27d3602014-05-24 02:40:31 +1000166 .dimm_channel0_disabled = 2,
167 .dimm_channel1_disabled = 2,
168 .max_ddr3_freq = 1333,
169 .usb_port_config = {
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200170 { 1, 0, 0x0080 }, /* P0: Front port (OC0) */
171 { 1, 1, 0x0040 }, /* P1: Back port (OC1) */
172 { 1, 0, 0x0040 }, /* P2: MINIPCIE1 (no OC) */
173 { 1, 0, 0x0040 }, /* P3: MMC (no OC) */
174 { 1, 2, 0x0080 }, /* P4: Front port (OC2) */
175 { 0, 0, 0x0000 }, /* P5: Empty */
176 { 0, 0, 0x0000 }, /* P6: Empty */
177 { 0, 0, 0x0000 }, /* P7: Empty */
178 { 1, 4, 0x0040 }, /* P8: Back port (OC4) */
179 { 1, 4, 0x0040 }, /* P9: MINIPCIE3 (no OC) */
180 { 1, 4, 0x0040 }, /* P10: BLUETOOTH (no OC) */
181 { 0, 4, 0x0000 }, /* P11: Empty */
182 { 1, 6, 0x0040 }, /* P12: Back port (OC6) */
183 { 1, 5, 0x0040 }, /* P13: Back port (OC5) */
184 },
185 };
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100186 *pei_data = pei_data_template;
187}
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200188
Kyösti Mälkkie258b9a2016-11-18 19:59:23 +0200189void mainboard_get_spd(spd_raw_data *spd, bool id_only)
Vladimir Serbinenkod2990c92016-02-10 02:52:42 +0100190{
Kyösti Mälkkie258b9a2016-11-18 19:59:23 +0200191 read_spd(&spd[0], 0x50, id_only);
192 read_spd(&spd[2], 0x52, id_only);
Vladimir Serbinenkod2990c92016-02-10 02:52:42 +0100193}
194
195const struct southbridge_usb_port mainboard_usb_ports[] = {
196 /* enabled power usb oc pin */
197 { 1, 1, 0 }, /* P0: Front port (OC0) */
198 { 1, 0, 1 }, /* P1: Back port (OC1) */
199 { 1, 0, -1 }, /* P2: MINIPCIE1 (no OC) */
200 { 1, 0, -1 }, /* P3: MMC (no OC) */
201 { 1, 1, 2 }, /* P4: Front port (OC2) */
202 { 0, 0, -1 }, /* P5: Empty */
203 { 0, 0, -1 }, /* P6: Empty */
204 { 0, 0, -1 }, /* P7: Empty */
205 { 1, 0, 4 }, /* P8: Back port (OC4) */
206 { 1, 0, -1 }, /* P9: MINIPCIE3 (no OC) */
207 { 1, 0, -1 }, /* P10: BLUETOOTH (no OC) */
208 { 0, 0, -1 }, /* P11: Empty */
209 { 1, 0, 6 }, /* P12: Back port (OC6) */
210 { 1, 0, 5 }, /* P13: Back port (OC5) */
211};
212
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100213void mainboard_early_init(int s3resume)
214{
Kyösti Mälkkie3ddee02014-05-03 10:45:28 +0300215 init_bootmode_straps();
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100216}
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200217
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100218int mainboard_should_reset_usb(int s3resume)
219{
220 if (s3resume) {
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200221 /*
222 * For Stumpy the back USB ports are reset on resume
223 * so default to resetting the controller to make the
224 * kernel happy. There is a CMOS flag to disable the
225 * controller reset in case the kernel can tolerate
226 * the device power loss better in the future.
227 */
228 u8 magic = cmos_read(CMOS_USB_RESET_DISABLE);
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200229 if (magic == USB_RESET_DISABLE_MAGIC) {
230 printk(BIOS_DEBUG, "USB Controller Reset Disabled\n");
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100231 return 0;
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200232 } else {
233 printk(BIOS_DEBUG, "USB Controller Reset Enabled\n");
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100234 return 1;
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200235 }
236 } else {
237 /* Ensure USB reset on resume is enabled at boot */
238 cmos_write(0, CMOS_USB_RESET_DISABLE);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100239 return 1;
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200240 }
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100241}
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200242
Arthur Heymansfa5d0f82019-11-12 19:11:50 +0100243void bootblock_mainboard_early_init(void)
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100244{
245 setup_sio_gpios();
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200246
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100247 /* Early SuperIO setup */
Elyes HAOUASf5f1b382018-04-26 09:43:03 +0200248 it8772f_ac_resume_southbridge(SUPERIO_DEV);
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100249 ite_kill_watchdog(GPIO_DEV);
250 ite_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
Stefan Reinauere1ae4b22012-04-27 23:20:58 +0200251}