blob: 54baafb743750d404f83426ffa196088212cde37 [file] [log] [blame]
Angel Pons60ec3652020-04-03 01:22:13 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauer6651da32012-04-27 23:16:30 +02002
Arthur Heymansfa5d0f82019-11-12 19:11:50 +01003#include <bootblock_common.h>
Stefan Reinauer6651da32012-04-27 23:16:30 +02004#include <stdint.h>
Stefan Reinauer6651da32012-04-27 23:16:30 +02005#include <arch/io.h>
Kyösti Mälkki2a3f9f52019-08-26 13:59:54 +03006#include <superio/smsc/sio1007/sio1007.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +11007#include <northbridge/intel/sandybridge/sandybridge.h>
8#include <northbridge/intel/sandybridge/raminit.h>
Vladimir Serbinenkocf0e9022016-02-10 03:09:46 +01009#include <northbridge/intel/sandybridge/raminit_native.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110010#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe8e66f42016-02-06 17:42:42 +010011#include <southbridge/intel/common/gpio.h>
Stefan Reinauer6651da32012-04-27 23:16:30 +020012
Marc Jonesc4b6f3b2013-11-05 17:47:37 -070013#define SIO_PORT 0x164e
14
Arthur Heymansfa5d0f82019-11-12 19:11:50 +010015void bootblock_mainboard_early_init(void)
Stefan Reinauer6651da32012-04-27 23:16:30 +020016{
Marc Jonesc4b6f3b2013-11-05 17:47:37 -070017 const u16 port = SIO_PORT;
Stefan Reinauer6651da32012-04-27 23:16:30 +020018 const u16 runtime_port = 0x180;
19
Nico Huber052e3ef2019-11-17 01:35:14 +010020 sio1007_enable_uart_at(port);
21
Stefan Reinauer6651da32012-04-27 23:16:30 +020022 /* Turn on configuration mode. */
23 outb(0x55, port);
24
25 /* Set the GPIO direction, polarity, and type. */
26 sio1007_setreg(port, 0x31, 1 << 0, 1 << 0);
27 sio1007_setreg(port, 0x32, 0 << 0, 1 << 0);
28 sio1007_setreg(port, 0x33, 0 << 0, 1 << 0);
29
30 /* Set the base address for the runtime register block. */
31 sio1007_setreg(port, 0x30, runtime_port >> 4, 0xff);
32 sio1007_setreg(port, 0x21, runtime_port >> 12, 0xff);
33
34 /* Turn on address decoding for it. */
35 sio1007_setreg(port, 0x3a, 1 << 1, 1 << 1);
36
37 /* Set the value of GPIO 10 by changing GP1, bit 0. */
38 u8 byte;
39 byte = inb(runtime_port + 0xc);
40 byte |= (1 << 0);
41 outb(byte, runtime_port + 0xc);
42
43 /* Turn off address decoding for it. */
44 sio1007_setreg(port, 0x3a, 0 << 1, 1 << 1);
45
46 /* Turn off configuration mode. */
47 outb(0xaa, port);
48}
49
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010050void mainboard_fill_pei_data(struct pei_data *pei_data)
Stefan Reinauer6651da32012-04-27 23:16:30 +020051{
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010052 struct pei_data pei_data_template = {
Edward O'Callaghanea4ae2f2014-05-24 02:08:04 +100053 .pei_version = PEI_VERSION,
Angel Ponsd9e58dc2021-01-20 01:22:20 +010054 .mchbar = CONFIG_FIXED_MCHBAR_MMIO_BASE,
55 .dmibar = CONFIG_FIXED_DMIBAR_MMIO_BASE,
56 .epbar = CONFIG_FIXED_EPBAR_MMIO_BASE,
Shelley Chen4e9bb332021-10-20 15:43:45 -070057 .pciexbar = CONFIG_ECAM_MMCONF_BASE_ADDRESS,
Angel Ponsb21bffa2020-07-03 01:02:28 +020058 .smbusbar = CONFIG_FIXED_SMBUS_IO_BASE,
Edward O'Callaghanea4ae2f2014-05-24 02:08:04 +100059 .wdbbar = 0x4000000,
60 .wdbsize = 0x1000,
61 .hpet_address = CONFIG_HPET_ADDRESS,
Angel Pons92717ff2020-09-14 16:22:22 +020062 .rcba = (uintptr_t)DEFAULT_RCBA,
Edward O'Callaghanea4ae2f2014-05-24 02:08:04 +100063 .pmbase = DEFAULT_PMBASE,
64 .gpiobase = DEFAULT_GPIOBASE,
65 .thermalbase = 0xfed08000,
66 .system_type = 0, // 0 Mobile, 1 Desktop/Server
67 .tseg_size = CONFIG_SMM_TSEG_SIZE,
68 .spd_addresses = { 0xa0, 0x00, 0xa4, 0x00 },
69 .ts_addresses = { 0x00, 0x00, 0x00, 0x00 },
70 .ec_present = 0,
Edward O'Callaghanea4ae2f2014-05-24 02:08:04 +100071 .max_ddr3_freq = 1600,
72 .usb_port_config = {
Stefan Reinauer6651da32012-04-27 23:16:30 +020073 { 1, 0, 0x0040 }, /* P0: Front port (OC0) */
74 { 1, 1, 0x0040 }, /* P1: Back port (OC1) */
75 { 1, 0, 0x0040 }, /* P2: MINIPCIE1 (no OC) */
76 { 1, 0, 0x0040 }, /* P3: MMC (no OC) */
77 { 1, 2, 0x0040 }, /* P4: Front port (OC2) */
78 { 0, 0, 0x0000 }, /* P5: Empty */
79 { 0, 0, 0x0000 }, /* P6: Empty */
80 { 0, 0, 0x0000 }, /* P7: Empty */
81 { 1, 4, 0x0040 }, /* P8: Back port (OC4) */
82 { 1, 4, 0x0040 }, /* P9: MINIPCIE3 (no OC) */
83 { 1, 4, 0x0040 }, /* P10: BLUETOOTH (no OC) */
84 { 0, 4, 0x0000 }, /* P11: Empty */
85 { 1, 6, 0x0040 }, /* P12: Back port (OC6) */
86 { 1, 5, 0x0040 }, /* P13: Back port (OC5) */
87 },
88 };
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010089 *pei_data = pei_data_template;
90}
Stefan Reinauer6651da32012-04-27 23:16:30 +020091
Vladimir Serbinenkocf0e9022016-02-10 03:09:46 +010092const struct southbridge_usb_port mainboard_usb_ports[] = {
Elyes HAOUAS44f558e2020-02-24 13:26:04 +010093 /* enabled power USB oc pin */
Vladimir Serbinenkocf0e9022016-02-10 03:09:46 +010094 { 1, 0, 0 }, /* P0: Front port (OC0) */
95 { 1, 0, 1 }, /* P1: Back port (OC1) */
96 { 1, 0, -1 }, /* P2: MINIPCIE1 (no OC) */
97 { 1, 0, -1 }, /* P3: MMC (no OC) */
98 { 1, 0, 2 }, /* P4: Front port (OC2) */
99 { 0, 0, -1 }, /* P5: Empty */
100 { 0, 0, -1 }, /* P6: Empty */
101 { 0, 0, -1 }, /* P7: Empty */
102 { 1, 0, 4 }, /* P8: Back port (OC4) */
103 { 1, 0, -1 }, /* P9: MINIPCIE3 (no OC) */
104 { 1, 0, -1 }, /* P10: BLUETOOTH (no OC) */
105 { 0, 0, -1 }, /* P11: Empty */
106 { 1, 0, 6 }, /* P12: Back port (OC6) */
107 { 1, 0, 5 }, /* P13: Back port (OC5) */
108};
109
Peter Lemenkov498f1cc2019-02-07 10:48:10 +0100110void mainboard_get_spd(spd_raw_data *spd, bool id_only)
111{
Kyösti Mälkkie258b9a2016-11-18 19:59:23 +0200112 read_spd(&spd[0], 0x50, id_only);
113 read_spd(&spd[2], 0x52, id_only);
Vladimir Serbinenkocf0e9022016-02-10 03:09:46 +0100114}
115
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100116int mainboard_should_reset_usb(int s3resume)
117{
118 return !s3resume;
Stefan Reinauer6651da32012-04-27 23:16:30 +0200119}