Debian Codegraph @

src/mainboard/msi/ms7e06/bootblock.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <bootblock_common.h>
4 #include <device/pnp_ops.h>
5 #include <superio/nuvoton/common/nuvoton.h>
6 #include <superio/nuvoton/nct6687d/nct6687d.h>
7 #include <superio/nuvoton/nct6687d/nct6687d_ec.h>
8
9 #define GPIO_DEV PNP_DEV(0x4e, NCT6687D_GPIO_0_7)
10 #define SERIAL_DEV PNP_DEV(0x4e, NCT6687D_SP1)
11 #define POWER_DEV PNP_DEV(0x4e, NCT6687D_SLEEP_PWR)
12 #define P80_UART_DEV PNP_DEV(0x4e, NCT6687D_P80_UART)
13 #define EC_DEV PNP_DEV(0x4e, NCT6687D_EC)
14
15 #define EC_IO_BASE 0xa20
16
17 void bootblock_mainboard_early_init(void)
18 {
19 /* Replicate vendor settings for multi-function pins in global config LDN */
20 nuvoton_pnp_enter_conf_state(GPIO_DEV);
21 pnp_write_config(GPIO_DEV, 0x13, 0xff); // IRQ8-15 level triggered, low
22 pnp_write_config(GPIO_DEV, 0x14, 0xff); // IRQ0-7 level triggered, low
23
24 /* Below are multi-pin function */
25 pnp_write_config(GPIO_DEV, 0x15, 0xaa);
26 pnp_write_config(GPIO_DEV, 0x1a, 0x02);
27 pnp_write_config(GPIO_DEV, 0x1b, 0x02);
28 pnp_write_config(GPIO_DEV, 0x1d, 0x00);
29 pnp_write_config(GPIO_DEV, 0x1e, 0xaa);
30 pnp_write_config(GPIO_DEV, 0x1f, 0xb2);
31 pnp_write_config(GPIO_DEV, 0x22, 0xbd);
32 pnp_write_config(GPIO_DEV, 0x23, 0xdf);
33 pnp_write_config(GPIO_DEV, 0x24, 0x39);
34 pnp_write_config(GPIO_DEV, 0x25, 0xfe);
35 pnp_write_config(GPIO_DEV, 0x26, 0x40);
36 pnp_write_config(GPIO_DEV, 0x27, 0x77);
37 pnp_write_config(GPIO_DEV, 0x28, 0x00);
38 pnp_write_config(GPIO_DEV, 0x29, 0xfb);
39 pnp_write_config(GPIO_DEV, 0x2a, 0x80);
40 pnp_write_config(GPIO_DEV, 0x2b, 0x20);
41 pnp_write_config(GPIO_DEV, 0x2c, 0x8a);
42 pnp_write_config(GPIO_DEV, 0x2d, 0xaa);
43
44 /* Set GPIO 06 as high output */
45 pnp_write_config(GPIO_DEV, 0xF0, 0x00);
46 pnp_unset_and_set_config(GPIO_DEV, 0xe0, 0x40, 0x40);
47 pnp_unset_and_set_config(GPIO_DEV, 0xe3, 0x40, 0x00);
48
49 pnp_set_logical_device(POWER_DEV);
50 /* Configure pin for PECI */
51 pnp_write_config(POWER_DEV, 0xf3, 0x80);
52
53 /* Configure power fault detection */
54 pnp_unset_and_set_config(POWER_DEV, 0xf0, 0xF2, 0x30);
55 pnp_unset_and_set_config(POWER_DEV, 0xf0, 0x03, 0x01);
56
57 /* Configure yellow and green LED */
58 pnp_write_config(POWER_DEV, 0xe7, 0x88);
59 pnp_write_config(POWER_DEV, 0xe8, 0x07);
60 pnp_set_logical_device(P80_UART_DEV);
61 pnp_write_config(P80_UART_DEV, 0xe5, 0x0f);
62
63 /* Configure EC */
64 pnp_set_logical_device(EC_DEV);
65 pnp_set_iobase(EC_DEV, PNP_IDX_IO0, EC_IO_BASE);
66 pnp_set_enable(EC_DEV, 1);
67
68 nct6687d_ec_and_or_page_ff(EC_IO_BASE, 6, 0x61, 0x3f, 0xC0);
69 nct6687d_ec_and_or_page(EC_IO_BASE, 0, 0x34, 0xc0, 0x00);
70 nct6687d_ec_and_or_page_ff(EC_IO_BASE, 8, 0x07, 0xff, 0x03);
71 nct6687d_ec_and_or_page(EC_IO_BASE, 0, 0x3d, 0xbf, 0x40);
72 nct6687d_ec_and_or_page_ff(EC_IO_BASE, 8, 0x00, 0xff, 0x01);
73 nct6687d_ec_and_or_page_ff(EC_IO_BASE, 0, 0x34, 0xfb, 0x04);
74
75
76 nuvoton_pnp_exit_conf_state(EC_DEV);
77
78 if (CONFIG(CONSOLE_SERIAL))
79 nuvoton_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
80 }