| 1 |
|
| 2 |
|
| 3 |
#include <device/pci_ops.h> |
| 4 |
#include <device/pnp_def.h> |
| 5 |
#include <device/pnp_ops.h> |
| 6 |
#include <bootblock_common.h> |
| 7 |
#include <northbridge/intel/sandybridge/sandybridge.h> |
| 8 |
#include <superio/nuvoton/common/nuvoton.h> |
| 9 |
#include <superio/nuvoton/nct6776/nct6776.h> |
| 10 |
#include <superio/nuvoton/wpcm450/wpcm450.h> |
| 11 |
|
| 12 |
#include "x9scl.h" |
| 13 |
|
| 14 |
#define SERIAL_DEV PNP_DEV(X9SCL_NCT6776_PNP_BASE, NCT6776_SP1) |
| 15 |
#define KCS_DEV PNP_DEV(X9SCL_WPCM450_PNP_BASE, 0x11) |
| 16 |
|
| 17 |
#define SUPERIO_INITVAL(reg, data) {(reg), (data)} |
| 18 |
#define SUPERIO_BANK(x) SUPERIO_INITVAL(0x07, (x)) |
| 19 |
|
| 20 |
static const uint8_t superio_initvals[][2] = { |
| 21 |
|
| 22 |
SUPERIO_INITVAL(0x1a, 0xc8), |
| 23 |
SUPERIO_INITVAL(0x1b, 0x68), |
| 24 |
SUPERIO_INITVAL(0x1c, 0x83), |
| 25 |
SUPERIO_INITVAL(0x24, 0x24), |
| 26 |
SUPERIO_INITVAL(0x2a, 0x00), |
| 27 |
SUPERIO_INITVAL(0x2b, 0x42), |
| 28 |
SUPERIO_INITVAL(0x2c, 0x80), |
| 29 |
|
| 30 |
SUPERIO_BANK(0x9), |
| 31 |
SUPERIO_INITVAL(0x30, 0x0c), |
| 32 |
SUPERIO_INITVAL(0xe0, 0xcf), |
| 33 |
SUPERIO_INITVAL(0xe4, 0xbd), |
| 34 |
SUPERIO_INITVAL(0xe5, 0x42), |
| 35 |
SUPERIO_INITVAL(0xe9, 0x10), |
| 36 |
SUPERIO_INITVAL(0xea, 0x40), |
| 37 |
SUPERIO_INITVAL(0xf0, 0xff), |
| 38 |
SUPERIO_INITVAL(0xf1, 0x02), |
| 39 |
|
| 40 |
SUPERIO_BANK(0xb), |
| 41 |
SUPERIO_INITVAL(0xf7, 0x07), |
| 42 |
SUPERIO_INITVAL(0xf8, 0x40), |
| 43 |
SUPERIO_INITVAL(0x30, 0x01), |
| 44 |
SUPERIO_INITVAL(0x60, X9SCL_NCT6776_HWM_BASE >> 8), |
| 45 |
SUPERIO_INITVAL(0x61, X9SCL_NCT6776_HWM_BASE & 0xff), |
| 46 |
|
| 47 |
SUPERIO_BANK(0x5), |
| 48 |
SUPERIO_INITVAL(0xf0, 0x83), |
| 49 |
SUPERIO_INITVAL(0x30, 0x01), |
| 50 |
|
| 51 |
SUPERIO_BANK(0x0), |
| 52 |
SUPERIO_INITVAL(0x30, 0x80), |
| 53 |
}; |
| 54 |
|
| 55 |
static void superio_init(void) |
| 56 |
{ |
| 57 |
const pnp_devfn_t dev = PNP_DEV(X9SCL_NCT6776_PNP_BASE, 0); |
| 58 |
|
| 59 |
nuvoton_pnp_enter_conf_state(dev); |
| 60 |
for (size_t i = 0; i < ARRAY_SIZE(superio_initvals); i++) |
| 61 |
pnp_write_config(dev, superio_initvals[i][0], superio_initvals[i][1]); |
| 62 |
nuvoton_pnp_exit_conf_state(dev); |
| 63 |
} |
| 64 |
|
| 65 |
static void bmc_init(void) |
| 66 |
{ |
| 67 |
pnp_devfn_t dev = KCS_DEV; |
| 68 |
|
| 69 |
pnp_write_config(dev, 0x21, 0x11); |
| 70 |
|
| 71 |
pnp_set_logical_device(dev); |
| 72 |
pnp_set_enable(dev, 0); |
| 73 |
pnp_set_iobase(dev, PNP_IDX_IO0, X9SCL_WPCM450_KCS_BASE + 0); |
| 74 |
pnp_set_iobase(dev, PNP_IDX_IO1, X9SCL_WPCM450_KCS_BASE + 1); |
| 75 |
pnp_set_iobase(dev, PNP_IDX_IRQ0, 0); |
| 76 |
pnp_set_enable(dev, 1); |
| 77 |
} |
| 78 |
|
| 79 |
void bootblock_mainboard_early_init(void) |
| 80 |
{ |
| 81 |
nuvoton_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE); |
| 82 |
superio_init(); |
| 83 |
bmc_init(); |
| 84 |
} |
| 85 |
|
| 86 |
void mainboard_early_init(int s3resume) |
| 87 |
{ |
| 88 |
|
| 89 |
pci_write_config16(PCI_DEV(0, 0, 0), GGC, 2); |
| 90 |
} |