blob: a28ae78f28f7db64fc0a2650e585f00ba1f02165 [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
17#include <stdint.h>
Stefan Reinauer6651da32012-04-27 23:16:30 +020018#include <arch/io.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020019#include <device/pci_ops.h>
Stefan Reinauer6651da32012-04-27 23:16:30 +020020#include <device/pci_def.h>
Stefan Reinauer6651da32012-04-27 23:16:30 +020021#include <cpu/x86/lapic.h>
Edward O'Callaghan74834e02015-01-04 04:17:35 +110022#include <superio/smsc/sio1007/chip.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110023#include <northbridge/intel/sandybridge/sandybridge.h>
24#include <northbridge/intel/sandybridge/raminit.h>
Vladimir Serbinenkocf0e9022016-02-10 03:09:46 +010025#include <northbridge/intel/sandybridge/raminit_native.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110026#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe8e66f42016-02-06 17:42:42 +010027#include <southbridge/intel/common/gpio.h>
Stefan Reinauer6651da32012-04-27 23:16:30 +020028
Marc Jonesc4b6f3b2013-11-05 17:47:37 -070029#define SIO_PORT 0x164e
30
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010031void pch_enable_lpc(void)
Stefan Reinauer6651da32012-04-27 23:16:30 +020032{
Elyes HAOUAS4b73fa92018-06-08 19:00:44 +020033 pci_devfn_t dev = PCH_LPC_DEV;
Stefan Reinauer6651da32012-04-27 23:16:30 +020034
35 /* Set COM1/COM2 decode range */
36 pci_write_config16(dev, LPC_IO_DEC, 0x0010);
37
Marc Jonesc4b6f3b2013-11-05 17:47:37 -070038 /* Enable SuperIO + PS/2 Keyboard/Mouse */
39 u16 lpc_config = CNF1_LPC_EN | CNF2_LPC_EN | KBC_LPC_EN;
Stefan Reinauer6651da32012-04-27 23:16:30 +020040 pci_write_config16(dev, LPC_EN, lpc_config);
41
Marc Jonesc4b6f3b2013-11-05 17:47:37 -070042 /* Enable COM1 */
43 if (sio1007_enable_uart_at(SIO_PORT)) {
44 pci_write_config16(dev, LPC_EN,
45 lpc_config | COMA_LPC_EN);
Stefan Reinauer6651da32012-04-27 23:16:30 +020046 }
47}
48
Nico Huberff4025c2018-01-14 12:34:43 +010049void mainboard_rcba_config(void)
Stefan Reinauer6651da32012-04-27 23:16:30 +020050{
Vladimir Serbinenko33b535f2014-10-19 10:13:14 +020051 southbridge_configure_default_intmap();
Stefan Reinauer6651da32012-04-27 23:16:30 +020052}
53
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010054void mainboard_config_superio(void)
Stefan Reinauer6651da32012-04-27 23:16:30 +020055{
Marc Jonesc4b6f3b2013-11-05 17:47:37 -070056 const u16 port = SIO_PORT;
Stefan Reinauer6651da32012-04-27 23:16:30 +020057 const u16 runtime_port = 0x180;
58
59 /* Turn on configuration mode. */
60 outb(0x55, port);
61
62 /* Set the GPIO direction, polarity, and type. */
63 sio1007_setreg(port, 0x31, 1 << 0, 1 << 0);
64 sio1007_setreg(port, 0x32, 0 << 0, 1 << 0);
65 sio1007_setreg(port, 0x33, 0 << 0, 1 << 0);
66
67 /* Set the base address for the runtime register block. */
68 sio1007_setreg(port, 0x30, runtime_port >> 4, 0xff);
69 sio1007_setreg(port, 0x21, runtime_port >> 12, 0xff);
70
71 /* Turn on address decoding for it. */
72 sio1007_setreg(port, 0x3a, 1 << 1, 1 << 1);
73
74 /* Set the value of GPIO 10 by changing GP1, bit 0. */
75 u8 byte;
76 byte = inb(runtime_port + 0xc);
77 byte |= (1 << 0);
78 outb(byte, runtime_port + 0xc);
79
80 /* Turn off address decoding for it. */
81 sio1007_setreg(port, 0x3a, 0 << 1, 1 << 1);
82
83 /* Turn off configuration mode. */
84 outb(0xaa, port);
85}
86
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010087void mainboard_fill_pei_data(struct pei_data *pei_data)
Stefan Reinauer6651da32012-04-27 23:16:30 +020088{
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010089 struct pei_data pei_data_template = {
Edward O'Callaghanea4ae2f2014-05-24 02:08:04 +100090 .pei_version = PEI_VERSION,
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080091 .mchbar = (uintptr_t)DEFAULT_MCHBAR,
92 .dmibar = (uintptr_t)DEFAULT_DMIBAR,
Edward O'Callaghanea4ae2f2014-05-24 02:08:04 +100093 .epbar = DEFAULT_EPBAR,
94 .pciexbar = CONFIG_MMCONF_BASE_ADDRESS,
95 .smbusbar = SMBUS_IO_BASE,
96 .wdbbar = 0x4000000,
97 .wdbsize = 0x1000,
98 .hpet_address = CONFIG_HPET_ADDRESS,
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080099 .rcba = (uintptr_t)DEFAULT_RCBABASE,
Edward O'Callaghanea4ae2f2014-05-24 02:08:04 +1000100 .pmbase = DEFAULT_PMBASE,
101 .gpiobase = DEFAULT_GPIOBASE,
102 .thermalbase = 0xfed08000,
103 .system_type = 0, // 0 Mobile, 1 Desktop/Server
104 .tseg_size = CONFIG_SMM_TSEG_SIZE,
105 .spd_addresses = { 0xa0, 0x00, 0xa4, 0x00 },
106 .ts_addresses = { 0x00, 0x00, 0x00, 0x00 },
107 .ec_present = 0,
Stefan Reinauer6651da32012-04-27 23:16:30 +0200108 // 0 = leave channel enabled
109 // 1 = disable dimm 0 on channel
110 // 2 = disable dimm 1 on channel
111 // 3 = disable dimm 0+1 on channel
Edward O'Callaghanea4ae2f2014-05-24 02:08:04 +1000112 .dimm_channel0_disabled = 2,
113 .dimm_channel1_disabled = 2,
114 .max_ddr3_freq = 1600,
115 .usb_port_config = {
Stefan Reinauer6651da32012-04-27 23:16:30 +0200116 { 1, 0, 0x0040 }, /* P0: Front port (OC0) */
117 { 1, 1, 0x0040 }, /* P1: Back port (OC1) */
118 { 1, 0, 0x0040 }, /* P2: MINIPCIE1 (no OC) */
119 { 1, 0, 0x0040 }, /* P3: MMC (no OC) */
120 { 1, 2, 0x0040 }, /* P4: Front port (OC2) */
121 { 0, 0, 0x0000 }, /* P5: Empty */
122 { 0, 0, 0x0000 }, /* P6: Empty */
123 { 0, 0, 0x0000 }, /* P7: Empty */
124 { 1, 4, 0x0040 }, /* P8: Back port (OC4) */
125 { 1, 4, 0x0040 }, /* P9: MINIPCIE3 (no OC) */
126 { 1, 4, 0x0040 }, /* P10: BLUETOOTH (no OC) */
127 { 0, 4, 0x0000 }, /* P11: Empty */
128 { 1, 6, 0x0040 }, /* P12: Back port (OC6) */
129 { 1, 5, 0x0040 }, /* P13: Back port (OC5) */
130 },
131 };
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100132 *pei_data = pei_data_template;
133}
Stefan Reinauer6651da32012-04-27 23:16:30 +0200134
Vladimir Serbinenkocf0e9022016-02-10 03:09:46 +0100135const struct southbridge_usb_port mainboard_usb_ports[] = {
136 /* enabled power usb oc pin */
137 { 1, 0, 0 }, /* P0: Front port (OC0) */
138 { 1, 0, 1 }, /* P1: Back port (OC1) */
139 { 1, 0, -1 }, /* P2: MINIPCIE1 (no OC) */
140 { 1, 0, -1 }, /* P3: MMC (no OC) */
141 { 1, 0, 2 }, /* P4: Front port (OC2) */
142 { 0, 0, -1 }, /* P5: Empty */
143 { 0, 0, -1 }, /* P6: Empty */
144 { 0, 0, -1 }, /* P7: Empty */
145 { 1, 0, 4 }, /* P8: Back port (OC4) */
146 { 1, 0, -1 }, /* P9: MINIPCIE3 (no OC) */
147 { 1, 0, -1 }, /* P10: BLUETOOTH (no OC) */
148 { 0, 0, -1 }, /* P11: Empty */
149 { 1, 0, 6 }, /* P12: Back port (OC6) */
150 { 1, 0, 5 }, /* P13: Back port (OC5) */
151};
152
Peter Lemenkov498f1cc2019-02-07 10:48:10 +0100153void mainboard_get_spd(spd_raw_data *spd, bool id_only)
154{
Kyösti Mälkkie258b9a2016-11-18 19:59:23 +0200155 read_spd(&spd[0], 0x50, id_only);
156 read_spd(&spd[2], 0x52, id_only);
Vladimir Serbinenkocf0e9022016-02-10 03:09:46 +0100157}
158
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100159void mainboard_early_init(int s3resume)
160{
161}
Stefan Reinauer6651da32012-04-27 23:16:30 +0200162
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100163int mainboard_should_reset_usb(int s3resume)
164{
165 return !s3resume;
Stefan Reinauer6651da32012-04-27 23:16:30 +0200166}