Debian Codegraph @

src/mainboard/lenovo/m900/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
8 #define GLOBAL_DEV PNP_DEV(0x2e, 0)
9 /* Change to NCT6687D_SP1 to use COM2 header */
10 #define SERIAL_DEV PNP_DEV(0x2e, NCT6687D_SP2)
11 #define POWER_DEV PNP_DEV(0x2e, NCT6687D_SLEEP_PWR)
12
13 void bootblock_mainboard_early_init(void)
14 {
15 nuvoton_pnp_enter_conf_state(GLOBAL_DEV);
16
17 /*
18 * Replicate non-default vendor settings (mostly multi-function pin
19 * selection settings) in the global LDN. It seems like some bits are
20 * set to non-default values before coreboot configures them; possibly
21 * by the MCU firmware. Comments provided for notable settings.
22 */
23 pnp_write_config(GLOBAL_DEV, 0x13, 0x0c);
24 /* Pins 121, 122 as TACHPWM */
25 pnp_write_config(GLOBAL_DEV, 0x15, 0xf0);
26 /* Pin 125 as TACHPWM */
27 pnp_write_config(GLOBAL_DEV, 0x1a, 0x07);
28 pnp_write_config(GLOBAL_DEV, 0x1b, 0xf0);
29 pnp_write_config(GLOBAL_DEV, 0x1d, 0x08);
30 /* Pins 95, 98, 124 as TACHPWM */
31 pnp_write_config(GLOBAL_DEV, 0x1e, 0xfc);
32 /* Pins 126, 127 as TACHPWM */
33 pnp_write_config(GLOBAL_DEV, 0x1f, 0xf0);
34 pnp_write_config(GLOBAL_DEV, 0x22, 0xbc);
35 pnp_write_config(GLOBAL_DEV, 0x23, 0xdf);
36 /* Route pins 29-36 to COM A (COM2 header) */
37 pnp_write_config(GLOBAL_DEV, 0x24, 0x61);
38 pnp_write_config(GLOBAL_DEV, 0x25, 0xff);
39 /* Route pins to parallel port */
40 pnp_write_config(GLOBAL_DEV, 0x27, 0xbe);
41 pnp_write_config(GLOBAL_DEV, 0x29, 0xfd);
42 /* Route pins 7-13 to COM B (Back panel COM1) */
43 pnp_write_config(GLOBAL_DEV, 0x2a, 0xcf);
44
45 /* Configure pin for PECI */
46 pnp_set_logical_device(POWER_DEV);
47 pnp_write_config(POWER_DEV, 0xf3, 0x0c);
48
49 nuvoton_pnp_exit_conf_state(GLOBAL_DEV);
50
51 /* Back panel COM1 */
52 nuvoton_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE);
53 }