blob: 0bc5884e6a4682879eab263e7102c0c00a9eff71 [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>
Stefan Reinauer6651da32012-04-27 23:16:30 +020020#include <cpu/x86/lapic.h>
Kyösti Mälkki2a3f9f52019-08-26 13:59:54 +030021#include <superio/smsc/sio1007/sio1007.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110022#include <northbridge/intel/sandybridge/sandybridge.h>
23#include <northbridge/intel/sandybridge/raminit.h>
Vladimir Serbinenkocf0e9022016-02-10 03:09:46 +010024#include <northbridge/intel/sandybridge/raminit_native.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110025#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe8e66f42016-02-06 17:42:42 +010026#include <southbridge/intel/common/gpio.h>
Stefan Reinauer6651da32012-04-27 23:16:30 +020027
Marc Jonesc4b6f3b2013-11-05 17:47:37 -070028#define SIO_PORT 0x164e
29
Arthur Heymansfa5d0f82019-11-12 19:11:50 +010030void bootblock_mainboard_early_init(void)
Stefan Reinauer6651da32012-04-27 23:16:30 +020031{
Marc Jonesc4b6f3b2013-11-05 17:47:37 -070032 const u16 port = SIO_PORT;
Stefan Reinauer6651da32012-04-27 23:16:30 +020033 const u16 runtime_port = 0x180;
34
Nico Huber052e3ef2019-11-17 01:35:14 +010035 sio1007_enable_uart_at(port);
36
Stefan Reinauer6651da32012-04-27 23:16:30 +020037 /* Turn on configuration mode. */
38 outb(0x55, port);
39
40 /* Set the GPIO direction, polarity, and type. */
41 sio1007_setreg(port, 0x31, 1 << 0, 1 << 0);
42 sio1007_setreg(port, 0x32, 0 << 0, 1 << 0);
43 sio1007_setreg(port, 0x33, 0 << 0, 1 << 0);
44
45 /* Set the base address for the runtime register block. */
46 sio1007_setreg(port, 0x30, runtime_port >> 4, 0xff);
47 sio1007_setreg(port, 0x21, runtime_port >> 12, 0xff);
48
49 /* Turn on address decoding for it. */
50 sio1007_setreg(port, 0x3a, 1 << 1, 1 << 1);
51
52 /* Set the value of GPIO 10 by changing GP1, bit 0. */
53 u8 byte;
54 byte = inb(runtime_port + 0xc);
55 byte |= (1 << 0);
56 outb(byte, runtime_port + 0xc);
57
58 /* Turn off address decoding for it. */
59 sio1007_setreg(port, 0x3a, 0 << 1, 1 << 1);
60
61 /* Turn off configuration mode. */
62 outb(0xaa, port);
63}
64
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010065void mainboard_fill_pei_data(struct pei_data *pei_data)
Stefan Reinauer6651da32012-04-27 23:16:30 +020066{
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010067 struct pei_data pei_data_template = {
Edward O'Callaghanea4ae2f2014-05-24 02:08:04 +100068 .pei_version = PEI_VERSION,
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080069 .mchbar = (uintptr_t)DEFAULT_MCHBAR,
70 .dmibar = (uintptr_t)DEFAULT_DMIBAR,
Edward O'Callaghanea4ae2f2014-05-24 02:08:04 +100071 .epbar = DEFAULT_EPBAR,
72 .pciexbar = CONFIG_MMCONF_BASE_ADDRESS,
73 .smbusbar = SMBUS_IO_BASE,
74 .wdbbar = 0x4000000,
75 .wdbsize = 0x1000,
76 .hpet_address = CONFIG_HPET_ADDRESS,
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080077 .rcba = (uintptr_t)DEFAULT_RCBABASE,
Edward O'Callaghanea4ae2f2014-05-24 02:08:04 +100078 .pmbase = DEFAULT_PMBASE,
79 .gpiobase = DEFAULT_GPIOBASE,
80 .thermalbase = 0xfed08000,
81 .system_type = 0, // 0 Mobile, 1 Desktop/Server
82 .tseg_size = CONFIG_SMM_TSEG_SIZE,
83 .spd_addresses = { 0xa0, 0x00, 0xa4, 0x00 },
84 .ts_addresses = { 0x00, 0x00, 0x00, 0x00 },
85 .ec_present = 0,
Stefan Reinauer6651da32012-04-27 23:16:30 +020086 // 0 = leave channel enabled
87 // 1 = disable dimm 0 on channel
88 // 2 = disable dimm 1 on channel
89 // 3 = disable dimm 0+1 on channel
Edward O'Callaghanea4ae2f2014-05-24 02:08:04 +100090 .dimm_channel0_disabled = 2,
91 .dimm_channel1_disabled = 2,
92 .max_ddr3_freq = 1600,
93 .usb_port_config = {
Stefan Reinauer6651da32012-04-27 23:16:30 +020094 { 1, 0, 0x0040 }, /* P0: Front port (OC0) */
95 { 1, 1, 0x0040 }, /* P1: Back port (OC1) */
96 { 1, 0, 0x0040 }, /* P2: MINIPCIE1 (no OC) */
97 { 1, 0, 0x0040 }, /* P3: MMC (no OC) */
98 { 1, 2, 0x0040 }, /* P4: Front port (OC2) */
99 { 0, 0, 0x0000 }, /* P5: Empty */
100 { 0, 0, 0x0000 }, /* P6: Empty */
101 { 0, 0, 0x0000 }, /* P7: Empty */
102 { 1, 4, 0x0040 }, /* P8: Back port (OC4) */
103 { 1, 4, 0x0040 }, /* P9: MINIPCIE3 (no OC) */
104 { 1, 4, 0x0040 }, /* P10: BLUETOOTH (no OC) */
105 { 0, 4, 0x0000 }, /* P11: Empty */
106 { 1, 6, 0x0040 }, /* P12: Back port (OC6) */
107 { 1, 5, 0x0040 }, /* P13: Back port (OC5) */
108 },
109 };
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100110 *pei_data = pei_data_template;
111}
Stefan Reinauer6651da32012-04-27 23:16:30 +0200112
Vladimir Serbinenkocf0e9022016-02-10 03:09:46 +0100113const struct southbridge_usb_port mainboard_usb_ports[] = {
Elyes HAOUAS44f558e2020-02-24 13:26:04 +0100114 /* enabled power USB oc pin */
Vladimir Serbinenkocf0e9022016-02-10 03:09:46 +0100115 { 1, 0, 0 }, /* P0: Front port (OC0) */
116 { 1, 0, 1 }, /* P1: Back port (OC1) */
117 { 1, 0, -1 }, /* P2: MINIPCIE1 (no OC) */
118 { 1, 0, -1 }, /* P3: MMC (no OC) */
119 { 1, 0, 2 }, /* P4: Front port (OC2) */
120 { 0, 0, -1 }, /* P5: Empty */
121 { 0, 0, -1 }, /* P6: Empty */
122 { 0, 0, -1 }, /* P7: Empty */
123 { 1, 0, 4 }, /* P8: Back port (OC4) */
124 { 1, 0, -1 }, /* P9: MINIPCIE3 (no OC) */
125 { 1, 0, -1 }, /* P10: BLUETOOTH (no OC) */
126 { 0, 0, -1 }, /* P11: Empty */
127 { 1, 0, 6 }, /* P12: Back port (OC6) */
128 { 1, 0, 5 }, /* P13: Back port (OC5) */
129};
130
Peter Lemenkov498f1cc2019-02-07 10:48:10 +0100131void mainboard_get_spd(spd_raw_data *spd, bool id_only)
132{
Kyösti Mälkkie258b9a2016-11-18 19:59:23 +0200133 read_spd(&spd[0], 0x50, id_only);
134 read_spd(&spd[2], 0x52, id_only);
Vladimir Serbinenkocf0e9022016-02-10 03:09:46 +0100135}
136
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100137int mainboard_should_reset_usb(int s3resume)
138{
139 return !s3resume;
Stefan Reinauer6651da32012-04-27 23:16:30 +0200140}