blob: d3842f83f5987dc23c7257fe35163e1919b08680 [file] [log] [blame]
Angel Pons1731d462020-04-03 01:21:31 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Hal Martinde7f8d32017-10-28 10:58:08 +00002
Arthur Heymansfa5d0f82019-11-12 19:11:50 +01003#include <bootblock_common.h>
Hal Martinde7f8d32017-10-28 10:58:08 +00004#include <stdint.h>
Hal Martinde7f8d32017-10-28 10:58:08 +00005#include <arch/io.h>
Elyes HAOUAS4ad14462018-06-16 18:29:33 +02006#include <northbridge/intel/sandybridge/raminit_native.h>
Kyösti Mälkki2a3f9f52019-08-26 13:59:54 +03007#include <superio/smsc/sio1007/sio1007.h>
Patrick Rudolphda9302a2019-03-24 17:01:41 +01008#include <southbridge/intel/bd82x6x/pch.h>
Hal Martinaba468b2017-12-05 20:52:09 +00009
10#define SIO_PORT 0x164e
Hal Martinde7f8d32017-10-28 10:58:08 +000011
Hal Martinde7f8d32017-10-28 10:58:08 +000012const struct southbridge_usb_port mainboard_usb_ports[] = {
13 { 1, 1, 0 },
14 { 1, 1, 0 },
15 { 1, 1, 1 },
16 { 1, 1, 1 },
17 { 1, 0, 2 },
18 { 1, 0, 2 },
19 { 1, 0, 3 },
20 { 1, 0, 3 },
21 { 1, 1, 4 },
22 { 1, 1, 4 },
23 { 1, 0, 5 },
24 { 1, 0, 5 },
25 { 1, 0, 6 },
26 { 1, 0, 6 },
27};
28
Arthur Heymansfa5d0f82019-11-12 19:11:50 +010029void bootblock_mainboard_early_init(void)
Hal Martinde7f8d32017-10-28 10:58:08 +000030{
Hal Martinaba468b2017-12-05 20:52:09 +000031 const u16 port = SIO_PORT;
32 const u16 runtime_port = 0x180;
33
Nico Huberce206972019-11-17 00:42:57 +010034 /* Enable COM1 if requested */
35 if (CONFIG(DRIVERS_UART_8250IO))
36 sio1007_enable_uart_at(port);
37
Hal Martinaba468b2017-12-05 20:52:09 +000038 /* Turn on configuration mode. */
39 outb(0x55, port);
40
41 /* Set the GPIO direction, polarity, and type. */
42 sio1007_setreg(port, 0x31, 1 << 0, 1 << 0);
43 sio1007_setreg(port, 0x32, 0 << 0, 1 << 0);
44 sio1007_setreg(port, 0x33, 0 << 0, 1 << 0);
45
46 /* Set the base address for the runtime register block. */
47 sio1007_setreg(port, 0x30, runtime_port >> 4, 0xff);
48 sio1007_setreg(port, 0x21, runtime_port >> 12, 0xff);
49
50 /* Turn on address decoding for it. */
51 sio1007_setreg(port, 0x3a, 1 << 1, 1 << 1);
52
53 /* Set the value of GPIO 10 by changing GP1, bit 0. */
54 u8 byte;
55 byte = inb(runtime_port + 0xc);
56 byte |= (1 << 0);
57 outb(byte, runtime_port + 0xc);
58
59 /* Turn off address decoding for it. */
60 sio1007_setreg(port, 0x3a, 0 << 1, 1 << 1);
61
62 /* Turn off configuration mode. */
63 outb(0xaa, port);
Hal Martinde7f8d32017-10-28 10:58:08 +000064}
65
66void mainboard_get_spd(spd_raw_data *spd, bool id_only)
67{
68 read_spd(&spd[0], 0x50, id_only);
69 read_spd(&spd[2], 0x52, id_only);
70}