1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 #define __SIMPLE_DEVICE__
6 #include <device/device.h>
7 #include <device/pnp_ops.h>
8 #include <superio/nuvoton/common/nuvoton.h>
9 #include <superio/nuvoton/nct6776/nct6776.h>
10 #include <southbridge/intel/lynxpoint/pch.h>
12 #define GPIO1_DEV PNP_DEV(0x2e, NCT6776_WDT1_GPIO01A_V)
13 #define NUVOTON_ENTRY_KEY 0x87
14 #define NUVOTON_EXIT_KEY 0xAA
16 /* Enable configuration: pass entry key '0x87' into index port dev
18 void nuvoton_pnp_enter_conf_state(pnp_devfn_t dev
)
21 outb(NUVOTON_ENTRY_KEY
, port
);
22 outb(NUVOTON_ENTRY_KEY
, port
);
25 /* Disable configuration: pass exit key '0xAA' into index port dev. */
26 void nuvoton_pnp_exit_conf_state(pnp_devfn_t dev
)
29 outb(NUVOTON_EXIT_KEY
, port
);
32 static void turn_off_leds(void *unused
)
34 nuvoton_pnp_enter_conf_state(GPIO1_DEV
);
36 pnp_set_logical_device(GPIO1_DEV
);
38 pnp_write_config(GPIO1_DEV
, 0xf0, 0xff);
39 pnp_write_config(GPIO1_DEV
, 0xf1, 0xff);
40 pnp_write_config(GPIO1_DEV
, 0x27, 0xd0);
42 nuvoton_pnp_exit_conf_state(GPIO1_DEV
);
45 BOOT_STATE_INIT_ENTRY(BS_OS_RESUME
, BS_ON_ENTRY
, turn_off_leds
, NULL
);
46 BOOT_STATE_INIT_ENTRY(BS_PAYLOAD_BOOT
, BS_ON_ENTRY
, turn_off_leds
, NULL
);