diff --git a/src/mainboard/asrock/fatal1ty_z87_professional/Makefile.mk b/src/mainboard/asrock/fatal1ty_z87_professional/Makefile.mk index de5aa51b34..93f729d787 100644 --- a/src/mainboard/asrock/fatal1ty_z87_professional/Makefile.mk +++ b/src/mainboard/asrock/fatal1ty_z87_professional/Makefile.mk @@ -4,5 +4,3 @@ bootblock-y += bootblock.c bootblock-y += gpio.c romstage-y += gpio.c ramstage-$(CONFIG_MAINBOARD_USE_LIBGFXINIT) += gma-mainboard.ads -smm-y += nuvoton.c -ramstage-y += nuvoton.c diff --git a/src/mainboard/asrock/fatal1ty_z87_professional/nuvoton.c b/src/mainboard/asrock/fatal1ty_z87_professional/nuvoton.c deleted file mode 100644 index 56453329cb..0000000000 --- a/src/mainboard/asrock/fatal1ty_z87_professional/nuvoton.c +++ /dev/null @@ -1,24 +0,0 @@ -/* 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/Makefile.mk b/src/mainboard/asrock/z87_extreme4/Makefile.mk index 58368c333e..c3cf55d397 100644 --- a/src/mainboard/asrock/z87_extreme4/Makefile.mk +++ b/src/mainboard/asrock/z87_extreme4/Makefile.mk @@ -4,5 +4,3 @@ 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/nuvoton.c b/src/mainboard/asrock/z87_extreme4/nuvoton.c deleted file mode 100644 index 56453329cb..0000000000 --- a/src/mainboard/asrock/z87_extreme4/nuvoton.c +++ /dev/null @@ -1,24 +0,0 @@ -/* 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/superio/nuvoton/common/early_serial.c b/src/superio/nuvoton/common/early_serial.c index f86e7a27d0..f0162a8f9d 100644 --- a/src/superio/nuvoton/common/early_serial.c +++ b/src/superio/nuvoton/common/early_serial.c @@ -2,21 +2,6 @@ /* * A generic romstage (pre-ram) driver for Nuvoton variant Super I/O chips. - * - * The following is derived directly from the vendor Nuvoton's data-sheets: - * - * To toggle between `configuration mode` and `normal operation mode` as to - * manipulate the various LDN's in Nuvoton Super I/O's we are required to - * pass magic numbers `passwords keys`. - * - * NUVOTON_ENTRY_KEY := enable configuration : 0x87 - * NUVOTON_EXIT_KEY := disable configuration : 0xAA - * - * To modify a LDN's configuration register, we use the index port to select - * the index of the LDN and then write to the data port to alter the - * parameters. A default index, data port pair is 0x4E, 0x4F respectively, a - * user modified pair is 0x2E, 0x2F respectively. - * */ #include @@ -25,25 +10,6 @@ #include #include "nuvoton.h" -#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); -} - /* Bring up early serial debugging output before the RAM is initialized. */ void nuvoton_enable_serial(pnp_devfn_t dev, u16 iobase) { diff --git a/src/superio/nuvoton/common/nuvoton.h b/src/superio/nuvoton/common/nuvoton.h index 0243c69b3e..77eafeb240 100644 --- a/src/superio/nuvoton/common/nuvoton.h +++ b/src/superio/nuvoton/common/nuvoton.h @@ -7,8 +7,32 @@ #include #include -void nuvoton_pnp_enter_conf_state(pnp_devfn_t dev); -void nuvoton_pnp_exit_conf_state(pnp_devfn_t dev); +#if ENV_PNP_SIMPLE_DEVICE +#include + +/* + * To toggle between `configuration mode` and `normal operation mode` as to + * manipulate the various LDN's in Nuvoton Super I/O's we are required to + * pass magic numbers `passwords keys`. + */ +#define NUVOTON_ENTRY_KEY 0x87 +#define NUVOTON_EXIT_KEY 0xAA + +static __always_inline void nuvoton_pnp_enter_conf_state(pnp_devfn_t dev) +{ + u16 port = dev >> 8; + outb(NUVOTON_ENTRY_KEY, port); + outb(NUVOTON_ENTRY_KEY, port); +} + +static __always_inline void nuvoton_pnp_exit_conf_state(pnp_devfn_t dev) +{ + u16 port = dev >> 8; + outb(NUVOTON_EXIT_KEY, port); +} + +#endif /* SIMPLE_DEVICE */ + void nuvoton_enable_serial(pnp_devfn_t dev, u16 iobase); #endif