blob: a2f89e7873fbc90a03bfb6fc7b12b9f0e3ca0330 [file] [log] [blame]
Jonathan A. Kollasch3e4f7a32020-01-10 13:23:02 -06001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
3
Jonathan A. Kollasch3e4f7a32020-01-10 13:23:02 -06004#include <stdint.h>
Jonathan A. Kollasch3e4f7a32020-01-10 13:23:02 -06005#include <device/pci_ops.h>
6#include <device/pnp_def.h>
7#include <device/pnp_ops.h>
Jonathan A. Kollasch3e4f7a32020-01-10 13:23:02 -06008#include <bootblock_common.h>
9#include <northbridge/intel/sandybridge/sandybridge.h>
10#include <northbridge/intel/sandybridge/raminit_native.h>
11#include <southbridge/intel/bd82x6x/pch.h>
Jonathan A. Kollasch3e4f7a32020-01-10 13:23:02 -060012#include <superio/nuvoton/common/nuvoton.h>
13#include <superio/nuvoton/nct6776/nct6776.h>
14#include <superio/nuvoton/wpcm450/wpcm450.h>
Elyes HAOUAS2b75ce22020-04-29 07:41:33 +020015
Jonathan A. Kollasch3e4f7a32020-01-10 13:23:02 -060016#include "x9scl.h"
17
18#define SERIAL_DEV PNP_DEV(X9SCL_NCT6776_PNP_BASE, NCT6776_SP1)
19#define KCS_DEV PNP_DEV(X9SCL_WPCM450_PNP_BASE, 0x11)
20
21#define SUPERIO_INITVAL(reg, data) {(reg), (data)}
22#define SUPERIO_BANK(x) SUPERIO_INITVAL(0x07, (x))
23
24const struct southbridge_usb_port mainboard_usb_ports[] = {
25 { 1, 0, 0 }, /* ? USB0 1d.0 port 1 */
26 { 1, 0, 0 }, /* ? USB1 1d.0 port 2 */
27 { 1, 0, 1 }, /* ? USB2 1d.0 port 3 */
28 { 1, 0, 1 }, /* ? USB3 1d.0 port 4 */
29 { 1, 0, 2 }, /* ? USB4 1d.0 port 5 */
30 { 1, 0, 2 }, /* ? USB5 1d.0 port 6 */
31 { 1, 0, 3 }, /* ? ??? 1a.0 port 1 */
32 { 1, 0, 3 }, /* ? BMC 1a.0 port 2 */
33 { 1, 0, 4 }, /* ? ??? 1a.0 port 3 */
34 { 1, 0, 4 }, /* ? USB11 1a.0 port 4 */
35 { 1, 0, 6 }, /* ? USB12 1a.0 port 5 */
36 { 1, 0, 5 }, /* ? USB13 1a.0 port 6 */
37 { 1, 0, 5 },
38 { 1, 0, 6 },
39};
40
41static const uint8_t superio_initvals[][2] = {
42 /* Global config registers */
43 SUPERIO_INITVAL(0x1a, 0xc8),
44 SUPERIO_INITVAL(0x1b, 0x68),
45 SUPERIO_INITVAL(0x1c, 0x83),
46 SUPERIO_INITVAL(0x24, 0x24),
47 //SUPERIO_INITVAL(0x27, 0x00),
48 SUPERIO_INITVAL(0x2a, 0x00),
49 SUPERIO_INITVAL(0x2b, 0x42),
50 SUPERIO_INITVAL(0x2c, 0x80),
51
52 SUPERIO_BANK(0x9), /* GPIO[2345] */
53 SUPERIO_INITVAL(0x30, 0x0c),
54 SUPERIO_INITVAL(0xe0, 0xcf),
55 SUPERIO_INITVAL(0xe4, 0xbd),
56 SUPERIO_INITVAL(0xe5, 0x42),
57 SUPERIO_INITVAL(0xe9, 0x10),
58 SUPERIO_INITVAL(0xea, 0x40),
59 SUPERIO_INITVAL(0xf0, 0xff),
60 SUPERIO_INITVAL(0xf1, 0x02),
61
62 SUPERIO_BANK(0xb), /* HWM & LED */
63 SUPERIO_INITVAL(0xf7, 0x07),
64 SUPERIO_INITVAL(0xf8, 0x40),
65 SUPERIO_INITVAL(0x30, 0x01),
66 SUPERIO_INITVAL(0x60, X9SCL_NCT6776_HWM_BASE >> 8),
67 SUPERIO_INITVAL(0x61, X9SCL_NCT6776_HWM_BASE & 0xff),
68
69 SUPERIO_BANK(0x5), /* KBC */
70 SUPERIO_INITVAL(0xf0, 0x83),
71 SUPERIO_INITVAL(0x30, 0x01),
72
73 SUPERIO_BANK(0x0), /* FDC */
74 SUPERIO_INITVAL(0x30, 0x80),
75
76#if 0
77 SUPERIO_BANK(8),
78 SUPERIO_INITVAL(0x30, 0x0a),
79 SUPERIO_INITVAL(0x60, X9SCL_NCT6776_GPIO_BASE >> 8),
80 SUPERIO_INITVAL(0x61, X9SCL_NCT6776_GPIO_BASE & 0xff),
81 SUPERIO_INITVAL(0xe1, 0xf9),
82
83 SUPERIO_BANK(0xa),
84 SUPERIO_INITVAL(0xe4, 0x60),
85#endif
86};
87
88
89static void superio_init(void)
90{
91 const pnp_devfn_t dev = PNP_DEV(X9SCL_NCT6776_PNP_BASE, 0);
92
93 nuvoton_pnp_enter_conf_state(dev);
94 for (size_t i = 0; i < ARRAY_SIZE(superio_initvals); i++)
95 pnp_write_config(dev, superio_initvals[i][0], superio_initvals[i][1]);
96 nuvoton_pnp_exit_conf_state(dev);
97}
98
99static void bmc_init(void)
100{
101 pnp_devfn_t dev = KCS_DEV;
102
103 pnp_write_config(dev, 0x21, 0x11);
104
105 pnp_set_logical_device(dev);
106 pnp_set_enable(dev, 0);
107 pnp_set_iobase(dev, PNP_IDX_IO0, X9SCL_WPCM450_KCS_BASE + 0);
108 pnp_set_iobase(dev, PNP_IDX_IO1, X9SCL_WPCM450_KCS_BASE + 1);
109 pnp_set_iobase(dev, PNP_IDX_IRQ0, 0);
110 pnp_set_enable(dev, 1);
111
112#if 0
113 //wpcm450_enable_dev(WPCM450_SP2, X9SCL_WPCM450_PNP_BASE, 0x03e8);
114 //wpcm450_enable_dev(WPCM450_SP1, X9SCL_WPCM450_PNP_BASE, 0x02e8);
115#endif
116
117#if 0
118 dev = PNP_DEV(X9SCL_WPCM450_PNP_BASE, WPCM450_SP2);
119 pnp_set_logical_device(dev);
120 pnp_set_enable(dev, 0);
121 pnp_set_iobase(dev, PNP_IDX_IO0, 0x03e8);
122 pnp_set_enable(dev, 1);
123
124 dev = PNP_DEV(X9SCL_WPCM450_PNP_BASE, WPCM450_SP1);
125 pnp_set_logical_device(dev);
126 pnp_set_enable(dev, 0);
127 pnp_set_iobase(dev, PNP_IDX_IO0, 0x02e8);
128 pnp_set_enable(dev, 0);
129#endif
130}
131
132void bootblock_mainboard_early_init(void)
133{
134 nuvoton_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
135 superio_init();
136 bmc_init();
137}
138
139void mainboard_get_spd(spd_raw_data *spd, bool id_only)
140{
141 read_spd(&spd[0], 0x50, id_only);
142 read_spd(&spd[1], 0x51, id_only);
143 read_spd(&spd[2], 0x52, id_only);
144 read_spd(&spd[3], 0x53, id_only);
145}
146
147void mainboard_early_init(int s3resume)
148{
149 /* Disable IGD VGA decode, no GTT or GFX stolen */
150 pci_write_config16(PCI_DEV(0, 0, 0), GGC, 2);
151}