Debian Codegraph @

src/mainboard/asrock/z87_extreme4/smihandler.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <cpu/x86/smm.h>
4 #include <device/pnp_ops.h>
5 #include <southbridge/intel/lynxpoint/pch.h>
6 #include <superio/nuvoton/common/nuvoton.h>
7 #include <superio/nuvoton/nct6776/nct6776.h>
8
9 #define GPIO1_DEV PNP_DEV(0x2e, NCT6776_WDT1_GPIO01A_V)
10 #define NUVOTON_ENTRY_KEY 0x87
11 #define NUVOTON_EXIT_KEY 0xAA
12
13 /* Enable configuration: pass entry key '0x87' into index port dev
14 * two times. */
15 void nuvoton_pnp_enter_conf_state(pnp_devfn_t dev)
16 {
17 u16 port = dev >> 8;
18 outb(NUVOTON_ENTRY_KEY, port);
19 outb(NUVOTON_ENTRY_KEY, port);
20 }
21
22 /* Disable configuration: pass exit key '0xAA' into index port dev. */
23 void nuvoton_pnp_exit_conf_state(pnp_devfn_t dev)
24 {
25 u16 port = dev >> 8;
26 outb(NUVOTON_EXIT_KEY, port);
27 }
28
29 void mainboard_smi_sleep(u8 slp_typ)
30 {
31 /*
32 * Cut off power to LEDs when system goes to sleep.
33 */
34 if (slp_typ >= ACPI_S3) {
35
36 nuvoton_pnp_enter_conf_state(GPIO1_DEV);
37
38 pnp_set_logical_device(GPIO1_DEV);
39
40 pnp_write_config(GPIO1_DEV, 0xf0, 0xff);
41 pnp_write_config(GPIO1_DEV, 0xf1, 0xff);
42
43 nuvoton_pnp_exit_conf_state(GPIO1_DEV);
44 }
45 }