From 0c2a3002d9fcffc9b22d1c39fc27ff8ebf9875bc Mon Sep 17 00:00:00 2001 From: Keith Hui Date: Sun, 28 Dec 2025 19:50:37 -0500 Subject: [PATCH] mb/asrock/z87_extreme4: Temporarily refactor nuvoton_pnp_*_conf_state() As the pair of non-ramstage Nuvoton SIO config mode entry/exit functions see wider use, they are being moved to sio/nuvoton/common. This mainboard carries 2 local copies. This preparatory patch moves them out of smihandler.c and mainboard.c into a temporary C file to prevent build breakage. It is to be removed when the shared copy is in place. WARNING: Disassembly of compiled SMM code shows a possible stack issue. Do not flash a binary with this patch applied but without the final shared version above. Change-Id: I7a5394478281ac3b92d257e2f0201264b95bb4e5 Signed-off-by: Keith Hui Reviewed-on: https://review.coreboot.org/c/coreboot/+/90656 Tested-by: build bot (Jenkins) Reviewed-by: Matt DeVillier --- src/mainboard/asrock/z87_extreme4/Makefile.mk | 2 ++ src/mainboard/asrock/z87_extreme4/mainboard.c | 18 -------------- src/mainboard/asrock/z87_extreme4/nuvoton.c | 24 +++++++++++++++++++ .../asrock/z87_extreme4/smihandler.c | 18 -------------- 4 files changed, 26 insertions(+), 36 deletions(-) create mode 100644 src/mainboard/asrock/z87_extreme4/nuvoton.c diff --git a/src/mainboard/asrock/z87_extreme4/Makefile.mk b/src/mainboard/asrock/z87_extreme4/Makefile.mk index c3cf55d397..58368c333e 100644 --- a/src/mainboard/asrock/z87_extreme4/Makefile.mk +++ b/src/mainboard/asrock/z87_extreme4/Makefile.mk @@ -4,3 +4,5 @@ bootblock-y += bootblock.c bootblock-y += gpio.c romstage-y += gpio.c ramstage-$(CONFIG_MAINBOARD_USE_LIBGFXINIT) += gma-mainboard.ads +ramstage-y += nuvoton.c +smm-y += nuvoton.c diff --git a/src/mainboard/asrock/z87_extreme4/mainboard.c b/src/mainboard/asrock/z87_extreme4/mainboard.c index 1e62d65d2e..8e30e3c61c 100644 --- a/src/mainboard/asrock/z87_extreme4/mainboard.c +++ b/src/mainboard/asrock/z87_extreme4/mainboard.c @@ -10,24 +10,6 @@ #include #define GPIO1_DEV PNP_DEV(0x2e, NCT6776_WDT1_GPIO01A_V) -#define NUVOTON_ENTRY_KEY 0x87 -#define NUVOTON_EXIT_KEY 0xAA - -/* Enable configuration: pass entry key '0x87' into index port dev - * two times. */ -void nuvoton_pnp_enter_conf_state(pnp_devfn_t dev) -{ - u16 port = dev >> 8; - outb(NUVOTON_ENTRY_KEY, port); - outb(NUVOTON_ENTRY_KEY, port); -} - -/* Disable configuration: pass exit key '0xAA' into index port dev. */ -void nuvoton_pnp_exit_conf_state(pnp_devfn_t dev) -{ - u16 port = dev >> 8; - outb(NUVOTON_EXIT_KEY, port); -} static void turn_off_leds(void *unused) { diff --git a/src/mainboard/asrock/z87_extreme4/nuvoton.c b/src/mainboard/asrock/z87_extreme4/nuvoton.c new file mode 100644 index 0000000000..56453329cb --- /dev/null +++ b/src/mainboard/asrock/z87_extreme4/nuvoton.c @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include + +#define NUVOTON_ENTRY_KEY 0x87 +#define NUVOTON_EXIT_KEY 0xAA + +/* Enable configuration: pass entry key '0x87' into index port dev + * two times. */ +void nuvoton_pnp_enter_conf_state(pnp_devfn_t dev) +{ + u16 port = dev >> 8; + outb(NUVOTON_ENTRY_KEY, port); + outb(NUVOTON_ENTRY_KEY, port); +} + +/* Disable configuration: pass exit key '0xAA' into index port dev. */ +void nuvoton_pnp_exit_conf_state(pnp_devfn_t dev) +{ + u16 port = dev >> 8; + outb(NUVOTON_EXIT_KEY, port); +} diff --git a/src/mainboard/asrock/z87_extreme4/smihandler.c b/src/mainboard/asrock/z87_extreme4/smihandler.c index d6ebcef9a0..462316a692 100644 --- a/src/mainboard/asrock/z87_extreme4/smihandler.c +++ b/src/mainboard/asrock/z87_extreme4/smihandler.c @@ -7,24 +7,6 @@ #include #define GPIO1_DEV PNP_DEV(0x2e, NCT6776_WDT1_GPIO01A_V) -#define NUVOTON_ENTRY_KEY 0x87 -#define NUVOTON_EXIT_KEY 0xAA - -/* Enable configuration: pass entry key '0x87' into index port dev - * two times. */ -void nuvoton_pnp_enter_conf_state(pnp_devfn_t dev) -{ - u16 port = dev >> 8; - outb(NUVOTON_ENTRY_KEY, port); - outb(NUVOTON_ENTRY_KEY, port); -} - -/* Disable configuration: pass exit key '0xAA' into index port dev. */ -void nuvoton_pnp_exit_conf_state(pnp_devfn_t dev) -{ - u16 port = dev >> 8; - outb(NUVOTON_EXIT_KEY, port); -} void mainboard_smi_sleep(u8 slp_typ) {