[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 09/17] hw/misc: Store DRAM size in NPCM8XX GCR Module
From: |
Hao Wu |
Subject: |
[PATCH 09/17] hw/misc: Store DRAM size in NPCM8XX GCR Module |
Date: |
Thu, 26 Dec 2024 08:22:28 +0000 |
NPCM8XX boot block stores the DRAM size in SCRPAD_B register in GCR
module. Since we don't simulate a detailed memory controller, we
need to store this information directly similar to the NPCM7XX's
INCTR3 register.
Signed-off-by: Hao Wu <wuhaotsh@google.com>
---
hw/misc/npcm_gcr.c | 24 ++++++++++++++++++++++++
include/hw/misc/npcm_gcr.h | 1 +
2 files changed, 25 insertions(+)
diff --git a/hw/misc/npcm_gcr.c b/hw/misc/npcm_gcr.c
index 52d0fa07ea..a4c9643119 100644
--- a/hw/misc/npcm_gcr.c
+++ b/hw/misc/npcm_gcr.c
@@ -279,6 +279,19 @@ static void npcm7xx_gcr_enter_reset(Object *obj, ResetType
type)
s->regs[NPCM7XX_GCR_INTCR3] = s->reset_intcr3;
}
+static void npcm8xx_gcr_enter_reset(Object *obj, ResetType type)
+{
+ NPCMGCRState *s = NPCM_GCR(obj);
+ NPCMGCRClass *c = NPCM_GCR_GET_CLASS(obj);
+
+ memcpy(s->regs, c->cold_reset_values, c->nr_regs * sizeof(uint32_t));
+ /* These 3 registers are at the same location in both 7xx and 8xx. */
+ s->regs[NPCM8XX_GCR_PWRON] = s->reset_pwron;
+ s->regs[NPCM8XX_GCR_MDLR] = s->reset_mdlr;
+ s->regs[NPCM8XX_GCR_INTCR3] = s->reset_intcr3;
+ s->regs[NPCM8XX_GCR_SCRPAD_B] = s->reset_scrpad_b;
+}
+
static void npcm_gcr_realize(DeviceState *dev, Error **errp)
{
ERRP_GUARD();
@@ -322,6 +335,14 @@ static void npcm_gcr_realize(DeviceState *dev, Error
**errp)
*
https://github.com/Nuvoton-Israel/u-boot/blob/2aef993bd2aafeb5408dbaad0f3ce099ee40c4aa/board/nuvoton/poleg/poleg.c#L244
*/
s->reset_intcr3 |= ctz64(dram_size / NPCM7XX_GCR_MIN_DRAM_SIZE) << 8;
+
+ /*
+ * The boot block starting from 0.0.6 for NPCM8xx SoCs stores the DRAM size
+ * in the SCRPAD2 registers. We need to set this field correctly since
+ * the initialization is skipped as we mentioned above.
+ *
https://github.com/Nuvoton-Israel/u-boot/blob/npcm8mnx-v2019.01_tmp/board/nuvoton/arbel/arbel.c#L737
+ */
+ s->reset_scrpad_b = dram_size;
}
static void npcm_gcr_init(Object *obj)
@@ -371,18 +392,21 @@ static void npcm7xx_gcr_class_init(ObjectClass *klass,
void *data)
c->nr_regs = NPCM7XX_GCR_NR_REGS;
c->cold_reset_values = npcm7xx_cold_reset_values;
+ rc->phases.enter = npcm7xx_gcr_enter_reset;
}
static void npcm8xx_gcr_class_init(ObjectClass *klass, void *data)
{
NPCMGCRClass *c = NPCM_GCR_CLASS(klass);
DeviceClass *dc = DEVICE_CLASS(klass);
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
QEMU_BUILD_BUG_ON(NPCM8XX_GCR_REGS_END > NPCM_GCR_MAX_NR_REGS);
QEMU_BUILD_BUG_ON(NPCM8XX_GCR_REGS_END != NPCM8XX_GCR_NR_REGS);
dc->desc = "NPCM8xx System Global Control Registers";
c->nr_regs = NPCM8XX_GCR_NR_REGS;
c->cold_reset_values = npcm8xx_cold_reset_values;
+ rc->phases.enter = npcm8xx_gcr_enter_reset;
}
static const TypeInfo npcm_gcr_info[] = {
diff --git a/include/hw/misc/npcm_gcr.h b/include/hw/misc/npcm_gcr.h
index 9ac76ca9ab..d81bb9afb2 100644
--- a/include/hw/misc/npcm_gcr.h
+++ b/include/hw/misc/npcm_gcr.h
@@ -68,6 +68,7 @@ typedef struct NPCMGCRState {
uint32_t reset_pwron;
uint32_t reset_mdlr;
uint32_t reset_intcr3;
+ uint32_t reset_scrpad_b;
} NPCMGCRState;
typedef struct NPCMGCRClass {
--
2.47.1.613.gc27f4b7a9f-goog
- [PATCH 00/17] Changes since v1:, Hao Wu, 2024/12/26
- [PATCH 01/17] docs/system/arm: Add Description for NPCM8XX SoC, Hao Wu, 2024/12/26
- [PATCH 02/17] roms: Update vbootrom to 1287b6e, Hao Wu, 2024/12/26
- [PATCH 03/17] pc-bios: Add NPCM8XX vBootrom, Hao Wu, 2024/12/26
- [PATCH 04/17] hw/ssi: Make flash size a property in NPCM7XX FIU, Hao Wu, 2024/12/26
- [PATCH 05/17] hw/misc: Rename npcm7xx_gcr to npcm_gcr, Hao Wu, 2024/12/26
- [PATCH 06/17] hw/misc: Move NPCM7XX GCR to NPCM GCR, Hao Wu, 2024/12/26
- [PATCH 07/17] hw/misc: Add nr_regs and cold_reset_values to NPCM GCR, Hao Wu, 2024/12/26
- [PATCH 08/17] hw/misc: Add support for NPCM8XX GCR, Hao Wu, 2024/12/26
- [PATCH 10/17] hw/misc: Support 8-bytes memop in NPCM GCR module, Hao Wu, 2024/12/26
- [PATCH 09/17] hw/misc: Store DRAM size in NPCM8XX GCR Module,
Hao Wu <=
- [PATCH 11/17] hw/misc: Rename npcm7xx_clk to npcm_clk, Hao Wu, 2024/12/26
- [PATCH 12/17] hw/misc: Move NPCM7XX CLK to NPCM CLK, Hao Wu, 2024/12/26
- [PATCH 14/17] hw/misc: Support NPCM8XX CLK Module Registers, Hao Wu, 2024/12/26
- [PATCH 13/17] hw/misc: Add nr_regs and cold_reset_values to NPCM CLK, Hao Wu, 2024/12/26
- [PATCH 15/17] hw/net: Add NPCM8XX PCS Module, Hao Wu, 2024/12/26
- [PATCH 16/17] hw/arm: Add NPCM8XX SoC, Hao Wu, 2024/12/26
- [PATCH 17/17] hw/arm: Add NPCM845 Evaluation board, Hao Wu, 2024/12/26