blob: c697ef2bf36f03b771c3cb6a75d6aa324d5f9017 [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
Felix Held972d9f22022-02-23 16:32:20 +01003#include <arch/hpet.h>
Arthur Heymansfa5d0f82019-11-12 19:11:50 +01004#include <bootblock_common.h>
Stefan Reinauer6651da32012-04-27 23:16:30 +02005#include <stdint.h>
Stefan Reinauer6651da32012-04-27 23:16:30 +02006#include <arch/io.h>
Kyösti Mälkki2a3f9f52019-08-26 13:59:54 +03007#include <superio/smsc/sio1007/sio1007.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +11008#include <northbridge/intel/sandybridge/sandybridge.h>
9#include <northbridge/intel/sandybridge/raminit.h>
Vladimir Serbinenkocf0e9022016-02-10 03:09:46 +010010#include <northbridge/intel/sandybridge/raminit_native.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110011#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe8e66f42016-02-06 17:42:42 +010012#include <southbridge/intel/common/gpio.h>
Stefan Reinauer6651da32012-04-27 23:16:30 +020013
Marc Jonesc4b6f3b2013-11-05 17:47:37 -070014#define SIO_PORT 0x164e
15
Arthur Heymansfa5d0f82019-11-12 19:11:50 +010016void bootblock_mainboard_early_init(void)
Stefan Reinauer6651da32012-04-27 23:16:30 +020017{
Marc Jonesc4b6f3b2013-11-05 17:47:37 -070018 const u16 port = SIO_PORT;
Stefan Reinauer6651da32012-04-27 23:16:30 +020019 const u16 runtime_port = 0x180;
20
Nico Huber052e3ef2019-11-17 01:35:14 +010021 sio1007_enable_uart_at(port);
22
Stefan Reinauer6651da32012-04-27 23:16:30 +020023 /* Turn on configuration mode. */
24 outb(0x55, port);
25
26 /* Set the GPIO direction, polarity, and type. */
27 sio1007_setreg(port, 0x31, 1 << 0, 1 << 0);
28 sio1007_setreg(port, 0x32, 0 << 0, 1 << 0);
29 sio1007_setreg(port, 0x33, 0 << 0, 1 << 0);
30
31 /* Set the base address for the runtime register block. */
32 sio1007_setreg(port, 0x30, runtime_port >> 4, 0xff);
33 sio1007_setreg(port, 0x21, runtime_port >> 12, 0xff);
34
35 /* Turn on address decoding for it. */
36 sio1007_setreg(port, 0x3a, 1 << 1, 1 << 1);
37
38 /* Set the value of GPIO 10 by changing GP1, bit 0. */
39 u8 byte;
40 byte = inb(runtime_port + 0xc);
41 byte |= (1 << 0);
42 outb(byte, runtime_port + 0xc);
43
44 /* Turn off address decoding for it. */
45 sio1007_setreg(port, 0x3a, 0 << 1, 1 << 1);
46
47 /* Turn off configuration mode. */
48 outb(0xaa, port);
49}
50
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010051void mainboard_fill_pei_data(struct pei_data *pei_data)
Stefan Reinauer6651da32012-04-27 23:16:30 +020052{
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010053 struct pei_data pei_data_template = {
Edward O'Callaghanea4ae2f2014-05-24 02:08:04 +100054 .pei_version = PEI_VERSION,
Angel Ponsd9e58dc2021-01-20 01:22:20 +010055 .mchbar = CONFIG_FIXED_MCHBAR_MMIO_BASE,
56 .dmibar = CONFIG_FIXED_DMIBAR_MMIO_BASE,
57 .epbar = CONFIG_FIXED_EPBAR_MMIO_BASE,
Shelley Chen4e9bb332021-10-20 15:43:45 -070058 .pciexbar = CONFIG_ECAM_MMCONF_BASE_ADDRESS,
Angel Ponsb21bffa2020-07-03 01:02:28 +020059 .smbusbar = CONFIG_FIXED_SMBUS_IO_BASE,
Edward O'Callaghanea4ae2f2014-05-24 02:08:04 +100060 .wdbbar = 0x4000000,
61 .wdbsize = 0x1000,
Felix Held972d9f22022-02-23 16:32:20 +010062 .hpet_address = HPET_BASE_ADDRESS,
Angel Pons92717ff2020-09-14 16:22:22 +020063 .rcba = (uintptr_t)DEFAULT_RCBA,
Edward O'Callaghanea4ae2f2014-05-24 02:08:04 +100064 .pmbase = DEFAULT_PMBASE,
65 .gpiobase = DEFAULT_GPIOBASE,
66 .thermalbase = 0xfed08000,
67 .system_type = 0, // 0 Mobile, 1 Desktop/Server
68 .tseg_size = CONFIG_SMM_TSEG_SIZE,
69 .spd_addresses = { 0xa0, 0x00, 0xa4, 0x00 },
70 .ts_addresses = { 0x00, 0x00, 0x00, 0x00 },
71 .ec_present = 0,
Edward O'Callaghanea4ae2f2014-05-24 02:08:04 +100072 .max_ddr3_freq = 1600,
73 .usb_port_config = {
Stefan Reinauer6651da32012-04-27 23:16:30 +020074 { 1, 0, 0x0040 }, /* P0: Front port (OC0) */
75 { 1, 1, 0x0040 }, /* P1: Back port (OC1) */
76 { 1, 0, 0x0040 }, /* P2: MINIPCIE1 (no OC) */
77 { 1, 0, 0x0040 }, /* P3: MMC (no OC) */
78 { 1, 2, 0x0040 }, /* P4: Front port (OC2) */
79 { 0, 0, 0x0000 }, /* P5: Empty */
80 { 0, 0, 0x0000 }, /* P6: Empty */
81 { 0, 0, 0x0000 }, /* P7: Empty */
82 { 1, 4, 0x0040 }, /* P8: Back port (OC4) */
83 { 1, 4, 0x0040 }, /* P9: MINIPCIE3 (no OC) */
84 { 1, 4, 0x0040 }, /* P10: BLUETOOTH (no OC) */
85 { 0, 4, 0x0000 }, /* P11: Empty */
86 { 1, 6, 0x0040 }, /* P12: Back port (OC6) */
87 { 1, 5, 0x0040 }, /* P13: Back port (OC5) */
88 },
89 };
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +010090 *pei_data = pei_data_template;
91}
Stefan Reinauer6651da32012-04-27 23:16:30 +020092
Vladimir Serbinenkocf0e9022016-02-10 03:09:46 +010093const struct southbridge_usb_port mainboard_usb_ports[] = {
Elyes HAOUAS44f558e2020-02-24 13:26:04 +010094 /* enabled power USB oc pin */
Vladimir Serbinenkocf0e9022016-02-10 03:09:46 +010095 { 1, 0, 0 }, /* P0: Front port (OC0) */
96 { 1, 0, 1 }, /* P1: Back port (OC1) */
97 { 1, 0, -1 }, /* P2: MINIPCIE1 (no OC) */
98 { 1, 0, -1 }, /* P3: MMC (no OC) */
99 { 1, 0, 2 }, /* P4: Front port (OC2) */
100 { 0, 0, -1 }, /* P5: Empty */
101 { 0, 0, -1 }, /* P6: Empty */
102 { 0, 0, -1 }, /* P7: Empty */
103 { 1, 0, 4 }, /* P8: Back port (OC4) */
104 { 1, 0, -1 }, /* P9: MINIPCIE3 (no OC) */
105 { 1, 0, -1 }, /* P10: BLUETOOTH (no OC) */
106 { 0, 0, -1 }, /* P11: Empty */
107 { 1, 0, 6 }, /* P12: Back port (OC6) */
108 { 1, 0, 5 }, /* P13: Back port (OC5) */
109};
110
Peter Lemenkov498f1cc2019-02-07 10:48:10 +0100111void mainboard_get_spd(spd_raw_data *spd, bool id_only)
112{
Kyösti Mälkkie258b9a2016-11-18 19:59:23 +0200113 read_spd(&spd[0], 0x50, id_only);
114 read_spd(&spd[2], 0x52, id_only);
Vladimir Serbinenkocf0e9022016-02-10 03:09:46 +0100115}