blob: 94a46550b21136ea87221ef0e235eb70367f59e7 [file] [log] [blame]
Stefan Reinauer6651da32012-04-27 23:16:30 +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 Reinauer6651da32012-04-27 23:16:30 +020015 */
16
Arthur Heymansfa5d0f82019-11-12 19:11:50 +010017#include <bootblock_common.h>
Stefan Reinauer6651da32012-04-27 23:16:30 +020018#include <stdint.h>
Stefan Reinauer6651da32012-04-27 23:16:30 +020019#include <arch/io.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020020#include <device/pci_ops.h>
Stefan Reinauer6651da32012-04-27 23:16:30 +020021#include <device/pci_def.h>
Stefan Reinauer6651da32012-04-27 23:16:30 +020022#include <cpu/x86/lapic.h>
Kyösti Mälkki2a3f9f52019-08-26 13:59:54 +030023#include <superio/smsc/sio1007/sio1007.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110024#include <northbridge/intel/sandybridge/sandybridge.h>
25#include <northbridge/intel/sandybridge/raminit.h>
Vladimir Serbinenkocf0e9022016-02-10 03:09:46 +010026#include <northbridge/intel/sandybridge/raminit_native.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110027#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe8e66f42016-02-06 17:42:42 +010028#include <southbridge/intel/common/gpio.h>
Stefan Reinauer6651da32012-04-27 23:16:30 +020029
Marc Jonesc4b6f3b2013-11-05 17:47:37 -070030#define SIO_PORT 0x164e
31
Arthur Heymans2b28a162019-11-12 17:21:08 +010032void mainboard_pch_lpc_setup(void)
Stefan Reinauer6651da32012-04-27 23:16:30 +020033{
Elyes HAOUAS4b73fa92018-06-08 19:00:44 +020034 pci_devfn_t dev = PCH_LPC_DEV;
Stefan Reinauer6651da32012-04-27 23:16:30 +020035
Marc Jonesc4b6f3b2013-11-05 17:47:37 -070036 /* Enable SuperIO + PS/2 Keyboard/Mouse */
37 u16 lpc_config = CNF1_LPC_EN | CNF2_LPC_EN | KBC_LPC_EN;
Stefan Reinauer6651da32012-04-27 23:16:30 +020038 pci_write_config16(dev, LPC_EN, lpc_config);
39
Marc Jonesc4b6f3b2013-11-05 17:47:37 -070040 /* Enable COM1 */
41 if (sio1007_enable_uart_at(SIO_PORT)) {
42 pci_write_config16(dev, LPC_EN,
43 lpc_config | COMA_LPC_EN);
Stefan Reinauer6651da32012-04-27 23:16:30 +020044 }
45}
46
Arthur Heymansfa5d0f82019-11-12 19:11:50 +010047void bootblock_mainboard_early_init(void)
Stefan Reinauer6651da32012-04-27 23:16:30 +020048{
Marc Jonesc4b6f3b2013-11-05 17:47:37 -070049 const u16 port = SIO_PORT;
Stefan Reinauer6651da32012-04-27 23:16:30 +020050 const u16 runtime_port = 0x180;
51
52 /* Turn on configuration mode. */
53 outb(0x55, port);
54
55 /* Set the GPIO direction, polarity, and type. */
56 sio1007_setreg(port, 0x31, 1 << 0, 1 << 0);
57 sio1007_setreg(port, 0x32, 0 << 0, 1 << 0);
58 sio1007_setreg(port, 0x33, 0 << 0, 1 << 0);
59
60 /* Set the base address for the runtime register block. */
61 sio1007_setreg(port, 0x30, runtime_port >> 4, 0xff);
62 sio1007_setreg(port, 0x21, runtime_port >> 12, 0xff);
63
64 /* Turn on address decoding for it. */
65 sio1007_setreg(port, 0x3a, 1 << 1, 1 << 1);
66
67 /* Set the value of GPIO 10 by changing GP1, bit 0. */
68 u8 byte;
69 byte = inb(runtime_port + 0xc);
70 byte |= (1 << 0);
71 outb(byte, runtime_port + 0xc);
72
73 /* Turn off address decoding for it. */
74 sio1007_setreg(port, 0x3a, 0 << 1, 1 << 1);
75
76 /* Turn off configuration mode. */
77 outb(0xaa, port);
78}
79
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010080void mainboard_fill_pei_data(struct pei_data *pei_data)
Stefan Reinauer6651da32012-04-27 23:16:30 +020081{
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010082 struct pei_data pei_data_template = {
Edward O'Callaghanea4ae2f2014-05-24 02:08:04 +100083 .pei_version = PEI_VERSION,
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080084 .mchbar = (uintptr_t)DEFAULT_MCHBAR,
85 .dmibar = (uintptr_t)DEFAULT_DMIBAR,
Edward O'Callaghanea4ae2f2014-05-24 02:08:04 +100086 .epbar = DEFAULT_EPBAR,
87 .pciexbar = CONFIG_MMCONF_BASE_ADDRESS,
88 .smbusbar = SMBUS_IO_BASE,
89 .wdbbar = 0x4000000,
90 .wdbsize = 0x1000,
91 .hpet_address = CONFIG_HPET_ADDRESS,
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080092 .rcba = (uintptr_t)DEFAULT_RCBABASE,
Edward O'Callaghanea4ae2f2014-05-24 02:08:04 +100093 .pmbase = DEFAULT_PMBASE,
94 .gpiobase = DEFAULT_GPIOBASE,
95 .thermalbase = 0xfed08000,
96 .system_type = 0, // 0 Mobile, 1 Desktop/Server
97 .tseg_size = CONFIG_SMM_TSEG_SIZE,
98 .spd_addresses = { 0xa0, 0x00, 0xa4, 0x00 },
99 .ts_addresses = { 0x00, 0x00, 0x00, 0x00 },
100 .ec_present = 0,
Stefan Reinauer6651da32012-04-27 23:16:30 +0200101 // 0 = leave channel enabled
102 // 1 = disable dimm 0 on channel
103 // 2 = disable dimm 1 on channel
104 // 3 = disable dimm 0+1 on channel
Edward O'Callaghanea4ae2f2014-05-24 02:08:04 +1000105 .dimm_channel0_disabled = 2,
106 .dimm_channel1_disabled = 2,
107 .max_ddr3_freq = 1600,
108 .usb_port_config = {
Stefan Reinauer6651da32012-04-27 23:16:30 +0200109 { 1, 0, 0x0040 }, /* P0: Front port (OC0) */
110 { 1, 1, 0x0040 }, /* P1: Back port (OC1) */
111 { 1, 0, 0x0040 }, /* P2: MINIPCIE1 (no OC) */
112 { 1, 0, 0x0040 }, /* P3: MMC (no OC) */
113 { 1, 2, 0x0040 }, /* P4: Front port (OC2) */
114 { 0, 0, 0x0000 }, /* P5: Empty */
115 { 0, 0, 0x0000 }, /* P6: Empty */
116 { 0, 0, 0x0000 }, /* P7: Empty */
117 { 1, 4, 0x0040 }, /* P8: Back port (OC4) */
118 { 1, 4, 0x0040 }, /* P9: MINIPCIE3 (no OC) */
119 { 1, 4, 0x0040 }, /* P10: BLUETOOTH (no OC) */
120 { 0, 4, 0x0000 }, /* P11: Empty */
121 { 1, 6, 0x0040 }, /* P12: Back port (OC6) */
122 { 1, 5, 0x0040 }, /* P13: Back port (OC5) */
123 },
124 };
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100125 *pei_data = pei_data_template;
126}
Stefan Reinauer6651da32012-04-27 23:16:30 +0200127
Vladimir Serbinenkocf0e9022016-02-10 03:09:46 +0100128const struct southbridge_usb_port mainboard_usb_ports[] = {
129 /* enabled power usb oc pin */
130 { 1, 0, 0 }, /* P0: Front port (OC0) */
131 { 1, 0, 1 }, /* P1: Back port (OC1) */
132 { 1, 0, -1 }, /* P2: MINIPCIE1 (no OC) */
133 { 1, 0, -1 }, /* P3: MMC (no OC) */
134 { 1, 0, 2 }, /* P4: Front port (OC2) */
135 { 0, 0, -1 }, /* P5: Empty */
136 { 0, 0, -1 }, /* P6: Empty */
137 { 0, 0, -1 }, /* P7: Empty */
138 { 1, 0, 4 }, /* P8: Back port (OC4) */
139 { 1, 0, -1 }, /* P9: MINIPCIE3 (no OC) */
140 { 1, 0, -1 }, /* P10: BLUETOOTH (no OC) */
141 { 0, 0, -1 }, /* P11: Empty */
142 { 1, 0, 6 }, /* P12: Back port (OC6) */
143 { 1, 0, 5 }, /* P13: Back port (OC5) */
144};
145
Peter Lemenkov498f1cc2019-02-07 10:48:10 +0100146void mainboard_get_spd(spd_raw_data *spd, bool id_only)
147{
Kyösti Mälkkie258b9a2016-11-18 19:59:23 +0200148 read_spd(&spd[0], 0x50, id_only);
149 read_spd(&spd[2], 0x52, id_only);
Vladimir Serbinenkocf0e9022016-02-10 03:09:46 +0100150}
151
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100152int mainboard_should_reset_usb(int s3resume)
153{
154 return !s3resume;
Stefan Reinauer6651da32012-04-27 23:16:30 +0200155}