Define NPCM7XX PWRON bit fields
v2 cover Define NPCM7XX PWRON bit fields
Currently, the PWRON STRAP values in NPCM7XX boards are magic numbers. Similar to the aspeed ones in hw/arm/aspeed.c, we define bit fields constants for them and use these fields instead of the magic numbers in the current implementation. The code should behave exactly the same as the existing one.
-- Changes since v1
* Fix errors and apply suggestions Peter made on v1.
Hao Wu (2):
hw/misc: Add PWRON STRAP bit fields in GCR module hw/arm: Use bit fields for NPCM7XX PWRON STRAPs
hw/arm/npcm7xx_boards.c | 24 +++++++++++++++++++----- include/hw/misc/npcm7xx_gcr.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 5 deletions(-)
Signature · 1 line
2.35.1.1178.g4f1659d476-goog
PATCH v2 1/2 hw/misc: Add PWRON STRAP bit fields in GCR module
Similar to the Aspeed code in include/misc/aspeed_scu.h, we define the PWRON STRAP fields in their corresponding module for NPCM7XX.
--- include/hw/misc/npcm7xx_gcr.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
include/hw/misc/npcm7xx_gcr.h +30 -0
@@ -19,6 +19,36 @@#include "exec/memory.h" #include "hw/sysbus.h" +/* +* NPCM7XX PWRON STRAP bit fields +* 12: SPI0 powered by VSBV3 at 1.8V +* 11: System flash attached to BMC +* 10: BSP alternative pins. +* 9:8: Flash UART command route enabled. +* 7: Security enabled. +* 6: HI-Z state control. +* 5: ECC disabled. +* 4: Reserved +* 3: JTAG2 enabled. +* 2:0: CPU and DRAM clock frequency. +*/ +#define NPCM7XX_PWRON_STRAP_SPI0F18 BIT(12) +#define NPCM7XX_PWRON_STRAP_SFAB BIT(11) +#define NPCM7XX_PWRON_STRAP_BSPA BIT(10) +#define NPCM7XX_PWRON_STRAP_FUP (x) ((x) << 8) +#define FUP_NORM_UART2 3 +#define FUP_PROG_UART3 2 +#define FUP_PROG_UART2 1 +#define FUP_NORM_UART3 0 +#define NPCM7XX_PWRON_STRAP_SECEN BIT(7) +#define NPCM7XX_PWRON_STRAP_HIZ BIT(6) +#define NPCM7XX_PWRON_STRAP_ECC BIT(5) +#define NPCM7XX_PWRON_STRAP_RESERVE1 BIT(4) +#define NPCM7XX_PWRON_STRAP_J2EN BIT(3) +#define NPCM7XX_PWRON_STRAP_CKFRQ (x) (x) +#define CKFRQ_SKIPINIT 0x000 +#define CKFRQ_DEFAULT 0x111 +/* * Number of registers in our device state structure. Don't change this without * incrementing the version_id in the vmstate.
Signature · 1 line
2.35.1.1178.g4f1659d476-goog
PATCH v2 2/2 hw/arm: Use bit fields for NPCM7XX PWRON STRAPs
In reply to Hao WuThis patch uses the defined fields to describe PWRON STRAPs for better readability.
--- hw/arm/npcm7xx_boards.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)
hw/arm/npcm7xx_boards.c +19 -5
@@ -30,11 +30,25 @@#include "sysemu/sysemu.h" #include "sysemu/block-backend.h" -#define NPCM750_EVB_POWER_ON_STRAPS 0x00001ff7 -#define QUANTA_GSJ_POWER_ON_STRAPS 0x00001fff -#define QUANTA_GBS_POWER_ON_STRAPS 0x000017ff -#define KUDO_BMC_POWER_ON_STRAPS 0x00001fff -#define MORI_BMC_POWER_ON_STRAPS 0x00001fff +#define NPCM7XX_POWER_ON_STRAPS_DEFAULT ( \ + NPCM7XX_PWRON_STRAP_SPI0F18 | \ + NPCM7XX_PWRON_STRAP_SFAB | \ + NPCM7XX_PWRON_STRAP_BSPA | \ + NPCM7XX_PWRON_STRAP_FUP(FUP_NORM_UART2) | \ + NPCM7XX_PWRON_STRAP_SECEN | \ + NPCM7XX_PWRON_STRAP_HIZ | \ + NPCM7XX_PWRON_STRAP_ECC | \ + NPCM7XX_PWRON_STRAP_RESERVE1 | \ + NPCM7XX_PWRON_STRAP_J2EN | \ + NPCM7XX_PWRON_STRAP_CKFRQ(CKFRQ_DEFAULT)) + +#define NPCM750_EVB_POWER_ON_STRAPS ( \ + NPCM7XX_POWER_ON_STRAPS_DEFAULT & ~NPCM7XX_PWRON_STRAP_J2EN) +#define QUANTA_GSJ_POWER_ON_STRAPS NPCM7XX_POWER_ON_STRAPS_DEFAULT +#define QUANTA_GBS_POWER_ON_STRAPS ( \ + NPCM7XX_POWER_ON_STRAPS_DEFAULT & ~NPCM7XX_PWRON_STRAP_SFAB) +#define KUDO_BMC_POWER_ON_STRAPS NPCM7XX_POWER_ON_STRAPS_DEFAULT +#define MORI_BMC_POWER_ON_STRAPS NPCM7XX_POWER_ON_STRAPS_DEFAULTstatic const char npcm7xx_default_bootrom[] ="npcm7xx_bootrom.bin" ;
Signature · 1 line
2.35.1.1178.g4f1659d476-goog
Peter Maydell
AppliedQuoted 9 lines · Hao Wu
Currently, the PWRON STRAP values in NPCM7XX boards are magic numbers. Similar to the aspeed ones in
hw/arm/aspeed.c, we define bit fields constants for them and use these fields instead of the magic numbers in the current implementation. The code should behave exactly the same as the existing one.-- Changes since v1
* Fix errors and apply suggestions Peter made on v1.
Applied to target-arm.next, thanks.
-- PMM