Add Nuvoton NPCM730/NPCM750 SoCs and two BMC machines
v9 cover Add Nuvoton NPCM730/NPCM750 SoCs and two BMC machines
This should be fully reviewed now, but the Timer patch may deserve another look, as I fixed a few bugs in it. Huge thanks to everyone who reviewed and/or tested this patchset, it has clearly improved a lot since I started.
I also pushed this and the previous patchsets to my qemu fork on github. The branches are named npcm7xx-v[1-9].
https://github.com/hskinnemoen/qemu
This patch series models enough of the Nuvoton NPCM730 and NPCM750 SoCs to boot an OpenBMC image built for quanta-gsj. This includes device models for:
- Global Configuration Registers
- Clock Control
- Timers
- Fuses
- Memory Controller
- Flash Controller
These modules, along with the existing Cortex A9 CPU cores and built-in peripherals, are integrated into a NPCM730 or NPCM750 SoC, which in turn form the foundation for the quanta-gsj and npcm750-evb machines, respectively. The two SoCs are very similar; the only difference is that NPCM730 is missing some peripherals that NPCM750 has, and which are not considered essential for datacenter use (e.g. graphics controllers). For more information, see
https://www.nuvoton.com/products/cloud-computing/ibmc/
Both quanta-gsj and npcm750-evb correspond to real boards supported by OpenBMC. At the end of the series, qemu can boot an OpenBMC image built for one of these boards with some minor modifications.
The patches in this series were developed by Google and reviewed by Nuvoton. We will be maintaining the machine and peripheral support together.
The data sheet for these SoCs is not generally available. Please let me know if more comments are needed to understand the device behavior.
Changes since v8:
- Add missing class_size initializer for TYPE_NPCM7XX_OTP.
- Timer bug fixes:
- Interrupt Enable bit should not be reserved.
- Update expiration time and/or time remaining on prescaler changes.
- Warn when CEN and CRST are both set, and force CEN to zero.
- Fix crash when the timer is loaded with zero cycles, and CEN is set and cleared in the same cycle (found by Alexander Bulekov's fuzz testing).
- Update CACT when CEN changes.
- De-assert interrupts when TISR bits are cleared by guest writes.
- Load the bootrom for direct kernel boot if it's available, but don't error out if it's not.
- Add the usual openbmc password to the arm/nuvoton docs.
Changes since v7:
- Move register enums to .c files throughout, leaving a single NPCM7XX_FOO_NR_REGS definition behind in the .h file. A QEMU_BUILD_BUG_ON should alert anyone accidentally expanding the register enum that they need to update the corresponding NR_REGS define, which in turn has a comment reminding them to update the vmstate version_id as well.
- Skip loading the bootrom if a kernel filename is provided by the user.
- New patch adding a board setup stub to tweak clocks before booting directly into the kernel.
- Add stuff to meson files instead of Makefiles.
- Try to disable the slowest drivers and services to speed up the flash boot acceptance test a bit. This is somewhat based on the following systemd-analyze blame report:
https://gist.github.com/hskinnemoen/475cb0676530cd2cebaa1754cf16ca97
Changes since v6:
- Use size_to_str to report DRAM sizes in npcm7xx_gcr.
- Simplify the interrupt logic in npcm7xx_timer.
- Update global bios_name instead of temporary.
- Add npcm7xx_bootrom to MAINTAINERS and pc-bios/README.
- Use a predefined name for the gsj boot image in the acceptance test.
Changes since v5:
- Boot ROM included, as a git submodule and a binary blob, and loaded by default, so the -bios option is usually not necessary anymore.
- Two acceptance tests added (openbmc image boot, and direct kernel boot).
- npcm7xx_load_kernel() moved to SoC code.
- NPCM7XX_TIMER_REF_HZ definition moved to CLK header.
- Comments added clarifying available SPI flash chip selects.
- Error handling adjustments:
- Errors from CPU and GCR realization are propagated through the SoC since they may be triggered by user-configurable parameters.
- Machine init uses error_fatal instead of error_abort for SoC realization flash init. This makes error messages more helpful.
- Comments added to indicate whether peripherals may fail to realize.
- Use ERRP_GUARD() instead of Error *err when possible.
- Default CPU type is now set, and attempting to set it to anything else will fail.
- Format string fixes (use HWADDR_PRIx, etc.)
- Simplified memory size encoding and error checking in npcm7xx_gcr.
- Encapsulate non-obvious pointer subtraction into helper functions in the FIU and TIMER modules.
- Incorporate review feedback into the FIU module:
- Add select/deselect trace events.
- Use npcm7xx_fiu_{de,}select() consistently.
- Use extract/deposit in more places for consistency.
- Use -Wimplicit-fallthrough compatible fallthrough comments.
- Use qdev_init_gpio_out_named instead of sysbus_init_irq for chip selects.
- Incorporate review feedback into the TIMER module:
- Assert that we never pause a timer that has already expired, instead of trying to handle it. This should be safe since QEMU_CLOCK_VIRTUAL is stopped while this code is running.
- Simplify the switch blocks in the read and write handlers.
I made a change to error out if a flash drive was not specified, but reverted it because it caused make check to fail (qom-test). When specifying a NULL block device, the m25p flash device initializes its in-memory storage with 0xff and doesn't attempt to write anything back. This seems correct to me.
Changes since v4:
- OTP cleanups suggested by Philippe Mathieu-Daudé.
- Added fuse array definitions based on public Nuvoton bootblock code.
- Moved class structure to .c file since it's only used internally.
- Readability improvements.
- Split the first patch and folded parts of it into three other patches so that CONFIG_NPCM7XX is only enabled after the initial NPCM7xx machine support is added.
- DRAM init moved to machine init code.
- Consistently use lower-case hex literals.
- Switched to fine-grained unimplemented devices, based on public bootblock source code. Added a tiny SRAM that got left out previously.
- Simplified error handling in npcm7xx_realize() since the board code will abort anyway, and SoCs are not hot-pluggable.
Changes since v3:
- License headers are now GPL v2-or-later throughout.
- Added vmstate throughout (except the memory controller, which doesn't really have any state worth saving). Successfully booted a gsj image with two stop/savevm/quit/loadvm cycles along the way.
- JFFS2 really doesn't like it if I let qemu keep running after savevm, and then jump back in time with loadvm. I assume this is expected.
- Fixed an error API violation in npcm7xx_realize, removed pointless error check after object_property_set_link().
- Switched the OTP device to use an embedded array instead of a g_malloc0'd one because I couldn't figure out how to set up vmstate for the latter.
Changes since v2:
- Simplified the MAINTAINERS entry.
- Added link to OpenPOWER jenkins for gsj BMC images.
- Reverted the smpboot change, back to byte swapping.
- Adapted to upstream API changes:
- sysbus_init_child_obj -> object_initialize_child
- object_property_set_bool -> qdev_realize / sysbus_realize
- ssi_create_slave_no_init -> qdev_new
- qdev_init_nofail -> qdev_realize_and_unref
- ssi_auto_connect_slaves removed
- Moved Boot ROM loading from soc to machine init.
- Plumbed power-on-straps property from GCR to the machine init code so it can be properly initialized. Turns out npcm750 memory init doesn't work without this. npcm730 is fine either way, though I'm not sure why.
- Reworked the flash init code so it looks more like aspeed (i.e. the flash device gets added even if there's no drive).
Changes since v1 (requested by reviewers):
- Clarify the source of CLK reset values.
- Made smpboot a constant byte array, eliinated byte swapping.
- NPCM7xxState now stores an array of ARMCPUs, not pointers to ARMCPUs.
- Clarify why EL3 is disabled.
- Introduce NPCM7XX_NUM_IRQ constant.
- Set the number of CPUs according to SoC variant, and disallow command line overrides (i.e. you can no longer override the number of CPUs with the -smp parameter). This is trying to follow the spirit of
https://patchwork.kernel.org/patch/11595407/.
- Switch register operations to DEVICE_LITTLE_ENDIAN throughout.
- Machine documentation added (new patch).
Changes since v1 to support flash booting:
- GCR reset value changes to get past memory initialization when booting from flash (patches 2 and 5):
- INTCR2 now indicates that the DDR controller is initialized.
- INTCR3 is initialized according to DDR memory size. A realize() method was implemented to achieve this.
- Refactor the machine initialization a bit to make it easier to drop in machine-specific flash initialization (patch 6).
- Extend the series with additional patches to enable booting from flash:
- Boot ROM (through the -bios option).
- OTP (fuse) controller.
- Memory Controller stub (just enough to skip memory training).
- Flash controller.
- Board-specific flash initialization.
Thanks for reviewing,
Havard
Havard Skinnemoen (14):
hw/misc: Add NPCM7xx System Global Control Registers device model hw/misc: Add NPCM7xx Clock Controller device model hw/timer: Add NPCM7xx Timer device model
hw/arm: Add NPCM730 and NPCM750 SoC models
hw/arm: Add two NPCM7xx-based machines
roms: Add virtual Boot ROM for NPCM7xx SoCs
hw/arm: Load -bios image as a boot ROM for npcm7xx hw/nvram: NPCM7xx OTP device model
hw/mem: Stubbed out NPCM7xx Memory Controller model hw/ssi: NPCM7xx Flash Interface Unit device model hw/arm: Wire up BMC boot flash for npcm750-evb and quanta-gsj hw/arm/npcm7xx: add board setup stub for CPU and UART clocks docs/system: Add Nuvoton machine documentation tests/acceptance: console boot tests for quanta-gsj
docs/system/arm/nuvoton.rst | 92 ++++ docs/system/target-arm.rst | 1 + default-configs/arm-softmmu.mak | 1 + include/hw/arm/npcm7xx.h | 112 +++++ include/hw/mem/npcm7xx_mc.h | 36 ++ include/hw/misc/npcm7xx_clk.h | 48 +++ include/hw/misc/npcm7xx_gcr.h | 43 ++ include/hw/nvram/npcm7xx_otp.h | 79 ++++ include/hw/ssi/npcm7xx_fiu.h | 73 ++++ include/hw/timer/npcm7xx_timer.h | 78 ++++ hw/arm/npcm7xx.c | 532 +++++++++++++++++++++++ hw/arm/npcm7xx_boards.c | 197 +++++++++ hw/mem/npcm7xx_mc.c | 84 ++++ hw/misc/npcm7xx_clk.c | 266 ++++++++++++ hw/misc/npcm7xx_gcr.c | 269 ++++++++++++ hw/nvram/npcm7xx_otp.c | 440 +++++++++++++++++++ hw/ssi/npcm7xx_fiu.c | 572 +++++++++++++++++++++++++ hw/timer/npcm7xx_timer.c | 543 +++++++++++++++++++++++ .gitmodules | 3 + MAINTAINERS | 10 + hw/arm/Kconfig | 9 + hw/arm/meson.build | 1 + hw/mem/meson.build | 1 + hw/misc/meson.build | 4 + hw/misc/trace-events | 8 + hw/nvram/meson.build | 1 + hw/ssi/meson.build | 1 + hw/ssi/trace-events | 11 + hw/timer/meson.build | 1 + hw/timer/trace-events | 5 + pc-bios/README | 6 + pc-bios/meson.build | 1 + pc-bios/npcm7xx_bootrom.bin | Bin 0 -> 768 bytes roms/Makefile | 7 + roms/vbootrom | 1 + tests/acceptance/boot_linux_console.py | 83 ++++ 36 files changed, 3619 insertions(+) create mode 100644 docs/system/arm/nuvoton.rst create mode 100644 include/hw/arm/npcm7xx.h create mode 100644 include/hw/mem/npcm7xx_mc.h create mode 100644 include/hw/misc/npcm7xx_clk.h create mode 100644 include/hw/misc/npcm7xx_gcr.h create mode 100644 include/hw/nvram/npcm7xx_otp.h create mode 100644 include/hw/ssi/npcm7xx_fiu.h create mode 100644 include/hw/timer/npcm7xx_timer.h create mode 100644 hw/arm/npcm7xx.c create mode 100644 hw/arm/npcm7xx_boards.c create mode 100644 hw/mem/npcm7xx_mc.c create mode 100644 hw/misc/npcm7xx_clk.c create mode 100644 hw/misc/npcm7xx_gcr.c create mode 100644 hw/nvram/npcm7xx_otp.c create mode 100644 hw/ssi/npcm7xx_fiu.c create mode 100644 hw/timer/npcm7xx_timer.c create mode 100644 pc-bios/npcm7xx_bootrom.bin create mode 160000 roms/vbootrom
Signature · 1 line
2.28.0.526.ge36021eeef-goog
PATCH v9 3/14 hw/timer: Add NPCM7xx Timer device model
The NPCM730 and NPCM750 SoCs have three timer modules each holding five timers and some shared registers (e.g. interrupt status).
Each timer runs at 25 MHz divided by a prescaler, and counts down from a configurable initial value to zero. When zero is reached, the interrupt flag for the timer is set, and the timer is disabled (one-shot mode) or reloaded from its initial value (periodic mode).
This implementation is sufficient to boot a Linux kernel configured for NPCM750. Note that the kernel does not seem to actually turn on the interrupts.
--- include/hw/timer/npcm7xx_timer.h | 78 +++++ hw/timer/npcm7xx_timer.c | 543 +++++++++++++++++++++++++++++++ hw/timer/meson.build | 1 + hw/timer/trace-events | 5 + 4 files changed, 627 insertions(+) create mode 100644 include/hw/timer/npcm7xx_timer.h create mode 100644 hw/timer/npcm7xx_timer.c
include/hw/timer/npcm7xx_timer.h new file +78 -0
@@ -0,0 +1,78 @@ +/* +* Nuvoton NPCM7xx Timer Controller +* +* Copyright 2020 Google LLC +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* for more details. +*/ +#ifndef NPCM7XX_TIMER_H +#define NPCM7XX_TIMER_H + +#include "exec/memory.h" +#include "hw/sysbus.h" +#include "qemu/timer.h" + +/* Each Timer Module (TIM) instance holds five 25 MHz timers. */ +#define NPCM7XX_TIMERS_PER_CTRL (5) + +/* +* Number of registers in our device state structure. Don't change this without +* incrementing the version_id in the vmstate. +*/ +#define NPCM7XX_TIMER_NR_REGS (0x54 / sizeof(uint32_t)) + +typedef struct NPCM7xxTimerCtrlState NPCM7xxTimerCtrlState ; + +/** +* struct NPCM7xxTimer - Individual timer state. +* @irq: GIC interrupt line to fire on expiration (if enabled). +* @qtimer: QEMU timer that notifies us on expiration. +* @expires_ns: Absolute virtual expiration time. +* @remaining_ns: Remaining time until expiration if timer is paused. +* @tcsr: The Timer Control and Status Register. +* @ticr: The Timer Initial Count Register. +*/ +typedef struct NPCM7xxTimer { +NPCM7xxTimerCtrlState *ctrl; + +qemu_irq irq; +QEMUTimer qtimer; +int64_t expires_ns; +int64_t remaining_ns; + +uint32_t tcsr; +uint32_t ticr; +}NPCM7xxTimer ; + +/** +* struct NPCM7xxTimerCtrlState - Timer Module device state. +* @parent: System bus device. +* @iomem: Memory region through which registers are accessed. +* @tisr: The Timer Interrupt Status Register. +* @wtcr: The Watchdog Timer Control Register. +* @timer: The five individual timers managed by this module. +*/ +struct NPCM7xxTimerCtrlState { +SysBusDevice parent; + +MemoryRegion iomem; + +uint32_t tisr; +uint32_t wtcr; + +NPCM7xxTimer timer[NPCM7XX_TIMERS_PER_CTRL ]; +}; + +#define TYPE_NPCM7XX_TIMER "npcm7xx-timer" +#define NPCM7XX_TIMER (obj) \ + OBJECT_CHECK(NPCM7xxTimerCtrlState, (obj), TYPE_NPCM7XX_TIMER) + +#endif /* NPCM7XX_TIMER_H */
hw/timer/npcm7xx_timer.c new file +543 -0
543 lines not on this page · raw message
hw/timer/meson.build +1 -0
@@ -23,6 +23,7 @@ softmmu_ss.add(when: 'CONFIG_LM32', if_true: files('lm32_timer.c')) softmmu_ss.add(when: 'CONFIG_MILKYMIST', if_true: files('milkymist-sysctl.c')) softmmu_ss.add(when: 'CONFIG_MIPS_CPS', if_true: files('mips_gictimer.c')) softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('mss-timer.c')) +softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_timer.c')) softmmu_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_timer.c')) softmmu_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_gptimer.c')) softmmu_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_synctimer.c'))
hw/timer/trace-events +5 -0
@@ -66,6 +66,11 @@ cmsdk_apb_dualtimer_read(uint64_t offset, uint64_t data, unsigned size) "CMSDK A cmsdk_apb_dualtimer_write(uint64_t offset, uint64_t data, unsigned size) "CMSDK APB dualtimer write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" cmsdk_apb_dualtimer_reset(void) "CMSDK APB dualtimer: reset" +# npcm7xx_timer.c +npcm7xx_timer_read(const char *id, uint64_t offset, uint64_t value) " %s offset: 0x%04" PRIx64 " value 0x%08" PRIx64 +npcm7xx_timer_write(const char *id, uint64_t offset, uint64_t value) "%s offset: 0x%04" PRIx64 " value 0x%08" PRIx64 +npcm7xx_timer_irq(const char *id, int timer, int state) "%s timer %d state %d" + # nrf51_timer.c nrf51_timer_read(uint8_t timer_id, uint64_t addr, uint32_t value, unsigned size) "timer %u read addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u" nrf51_timer_write(uint8_t timer_id, uint64_t addr, uint32_t value, unsigned size) "timer %u write addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u"
Signature · 1 line
2.28.0.526.ge36021eeef-goog
PATCH v9 1/14 hw/misc: Add NPCM7xx System Global Control Registers device model
In reply to Havard Skinnemoen viaImplement a device model for the System Global Control Registers in the NPCM730 and NPCM750 BMC SoCs.
This is primarily used to enable SMP boot (the boot ROM spins reading the SCRPAD register) and DDR memory initialization; other registers are best effort for now.
The reset values of the MDLR and PWRON registers are determined by the SoC variant (730 vs 750) and board straps respectively.
--- include/hw/misc/npcm7xx_gcr.h | 43 ++++++ hw/misc/npcm7xx_gcr.c | 269 ++++++++++++++++++++++++++++++++++ MAINTAINERS | 8 + hw/arm/Kconfig | 3 + hw/misc/meson.build | 3 + hw/misc/trace-events | 4 + 6 files changed, 330 insertions(+) create mode 100644 include/hw/misc/npcm7xx_gcr.h create mode 100644 hw/misc/npcm7xx_gcr.c
include/hw/misc/npcm7xx_gcr.h new file +43 -0
@@ -0,0 +1,43 @@ +/* +* Nuvoton NPCM7xx System Global Control Registers. +* +* Copyright 2020 Google LLC +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* for more details. +*/ +#ifndef NPCM7XX_GCR_H +#define NPCM7XX_GCR_H + +#include "exec/memory.h" +#include "hw/sysbus.h" + +/* +* Number of registers in our device state structure. Don't change this without +* incrementing the version_id in the vmstate. +*/ +#define NPCM7XX_GCR_NR_REGS (0x148 / sizeof(uint32_t)) + +typedef struct NPCM7xxGCRState { +SysBusDevice parent; + +MemoryRegion iomem; + +uint32_t regs[NPCM7XX_GCR_NR_REGS ]; + +uint32_t reset_pwron; +uint32_t reset_mdlr; +uint32_t reset_intcr3; +}NPCM7xxGCRState ; + +#define TYPE_NPCM7XX_GCR "npcm7xx-gcr" +#define NPCM7XX_GCR (obj) OBJECT_CHECK(NPCM7xxGCRState, (obj), TYPE_NPCM7XX_GCR) + +#endif /* NPCM7XX_GCR_H */
hw/misc/npcm7xx_gcr.c new file +269 -0
269 lines not on this page · raw message
MAINTAINERS +8 -0
@@ -750,6 +750,14 @@ S: Odd Fixes F: hw/arm/musicpal.c F: docs/system/arm/musicpal.rst +Nuvoton NPCM7xx +M: Havard Skinnemoen <[email protected]> +M: Tyrone Ting <[email protected]> +L: [email protected] +S: Supported +F: hw/*/npcm7xx* +F: include/hw/*/npcm7xx* + nSeries M: Andrzej Zaborowski <[email protected]> M: Peter Maydell <[email protected]>
hw/arm/Kconfig +3 -0
@@ -355,6 +355,9 @@ config XLNX_VERSAL select VIRTIO_MMIO select UNIMP +config NPCM7XX + bool + config FSL_IMX25 bool select IMX
hw/misc/meson.build +3 -0
@@ -50,6 +50,9 @@ softmmu_ss.add(when: 'CONFIG_IMX', if_true: files( )) softmmu_ss.add(when: 'CONFIG_MILKYMIST', if_true: files('milkymist-hpdmc.c', 'milkymist-pfpu.c')) softmmu_ss.add(when: 'CONFIG_MAINSTONE', if_true: files('mst_fpga.c')) +softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files( + 'npcm7xx_gcr.c', +)) softmmu_ss.add(when: 'CONFIG_OMAP', if_true: files( 'omap_clk.c', 'omap_gpmc.c',
hw/misc/trace-events +4 -0
@@ -111,6 +111,10 @@ mos6522_set_sr_int(void) "set sr_int" mos6522_write(uint64_t addr, uint64_t val) "reg=0x%"PRIx64 " val=0x%"PRIx64 mos6522_read(uint64_t addr, unsigned val) "reg=0x%"PRIx64 " val=0x%x" +# npcm7xx_gcr.c +npcm7xx_gcr_read(uint64_t offset, uint32_t value) " offset: 0x%04" PRIx64 " value: 0x%08" PRIx32 +npcm7xx_gcr_write(uint64_t offset, uint32_t value) "offset: 0x%04" PRIx64 " value: 0x%08" PRIx32 + # stm32f4xx_syscfg stm32f4xx_syscfg_set_irq(int gpio, int line, int level) "Interupt: GPIO: %d, Line: %d; Level: %d" stm32f4xx_pulse_exti(int irq) "Pulse EXTI: %d"
Signature · 1 line
2.28.0.526.ge36021eeef-goog
PATCH v9 2/14 hw/misc: Add NPCM7xx Clock Controller device model
In reply to Havard Skinnemoen viaEnough functionality to boot the Linux kernel has been implemented. This includes:
- Correct power-on reset values so the various clock rates can be accurately calculated.
- Clock enables stick around when written.
In addition, a best effort attempt to implement SECCNT and CNTR25M was made even though I don't think the kernel needs them.
--- include/hw/misc/npcm7xx_clk.h | 48 ++++++ hw/misc/npcm7xx_clk.c | 266 ++++++++++++++++++++++++++++++++++ hw/misc/meson.build | 1 + hw/misc/trace-events | 4 + 4 files changed, 319 insertions(+) create mode 100644 include/hw/misc/npcm7xx_clk.h create mode 100644 hw/misc/npcm7xx_clk.c
include/hw/misc/npcm7xx_clk.h new file +48 -0
@@ -0,0 +1,48 @@ +/* +* Nuvoton NPCM7xx Clock Control Registers. +* +* Copyright 2020 Google LLC +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* for more details. +*/ +#ifndef NPCM7XX_CLK_H +#define NPCM7XX_CLK_H + +#include "exec/memory.h" +#include "hw/sysbus.h" + +/* +* The reference clock frequency for the timer modules, and the SECCNT and +* CNTR25M registers in this module, is always 25 MHz. +*/ +#define NPCM7XX_TIMER_REF_HZ (25000000) + +/* +* Number of registers in our device state structure. Don't change this without +* incrementing the version_id in the vmstate. +*/ +#define NPCM7XX_CLK_NR_REGS (0x70 / sizeof(uint32_t)) + +typedef struct NPCM7xxCLKState { +SysBusDevice parent; + +MemoryRegion iomem; + +uint32_t regs[NPCM7XX_CLK_NR_REGS ]; + +/* Time reference for SECCNT and CNTR25M, initialized by power on reset */ +int64_t ref_ns; +}NPCM7xxCLKState ; + +#define TYPE_NPCM7XX_CLK "npcm7xx-clk" +#define NPCM7XX_CLK (obj) OBJECT_CHECK(NPCM7xxCLKState, (obj), TYPE_NPCM7XX_CLK) + +#endif /* NPCM7XX_CLK_H */
hw/misc/npcm7xx_clk.c new file +266 -0
266 lines not on this page · raw message
hw/misc/meson.build +1 -0
@@ -51,6 +51,7 @@ softmmu_ss.add(when: 'CONFIG_IMX', if_true: files( softmmu_ss.add(when: 'CONFIG_MILKYMIST', if_true: files('milkymist-hpdmc.c', 'milkymist-pfpu.c')) softmmu_ss.add(when: 'CONFIG_MAINSTONE', if_true: files('mst_fpga.c')) softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files( + 'npcm7xx_clk.c', 'npcm7xx_gcr.c', )) softmmu_ss.add(when: 'CONFIG_OMAP', if_true: files(
hw/misc/trace-events +4 -0
@@ -111,6 +111,10 @@ mos6522_set_sr_int(void) "set sr_int" mos6522_write(uint64_t addr, uint64_t val) "reg=0x%"PRIx64 " val=0x%"PRIx64 mos6522_read(uint64_t addr, unsigned val) "reg=0x%"PRIx64 " val=0x%x" +# npcm7xx_clk.c +npcm7xx_clk_read(uint64_t offset, uint32_t value) " offset: 0x%04" PRIx64 " value: 0x%08" PRIx32 +npcm7xx_clk_write(uint64_t offset, uint32_t value) "offset: 0x%04" PRIx64 " value: 0x%08" PRIx32 + # npcm7xx_gcr.c npcm7xx_gcr_read(uint64_t offset, uint32_t value) " offset: 0x%04" PRIx64 " value: 0x%08" PRIx32 npcm7xx_gcr_write(uint64_t offset, uint32_t value) "offset: 0x%04" PRIx64 " value: 0x%08" PRIx32
Signature · 1 line
2.28.0.526.ge36021eeef-goog
PATCH v9 6/14 roms: Add virtual Boot ROM for NPCM7xx SoCs
In reply to Havard Skinnemoen viaThis is a minimalistic boot ROM written specifically for use with QEMU. It supports loading the second-stage loader from SPI flash into RAM, SMP boot, and not much else.
--- .gitmodules | 3 +++ MAINTAINERS | 2 ++ pc-bios/README | 6 ++++++ pc-bios/meson.build | 1 + pc-bios/npcm7xx_bootrom.bin | Bin 0 -> 768 bytes roms/Makefile | 7 +++++++ roms/vbootrom | 1 + 7 files changed, 20 insertions(+) create mode 100644 pc-bios/npcm7xx_bootrom.bin create mode 160000 roms/vbootrom
.gitmodules +3 -0
@@ -61,3 +61,6 @@ [submodule "meson"] path = meson url = https://github.com/mesonbuild/meson/ +[submodule "roms/vbootrom"] + path = roms/vbootrom + url = https://github.com/google/vbootrom.git
MAINTAINERS +2 -0
@@ -757,6 +757,8 @@ L: [email protected] S: Supported F: hw/*/npcm7xx* F: include/hw/*/npcm7xx* +F: pc-bios/npcm7xx_bootrom.bin +F: roms/vbootrom nSeries M: Andrzej Zaborowski <[email protected]>
pc-bios/README +6 -0
@@ -71,3 +71,9 @@ ("Simplified BSD License" or "FreeBSD License", SPDX: BSD-2-Clause). OpenSBI source code also contains code reused from other projects desribed here: https://github.com/riscv/opensbi/blob/master/ThirdPartyNotices.md. + +- npcm7xx_bootrom.bin is a simplified, free (Apache 2.0) boot ROM for Nuvoton + NPCM7xx BMC devices. It currently implements the bare minimum to load, parse, + initialize and run boot images stored in SPI flash, but may grow more + features over time as needed. The source code is available at: + https://github.com/google/vbootrom
pc-bios/meson.build +1 -0
@@ -81,6 +81,7 @@ blobs = files( 'opensbi-riscv64-generic-fw_dynamic.bin', 'opensbi-riscv32-generic-fw_dynamic.elf', 'opensbi-riscv64-generic-fw_dynamic.elf', + 'npcm7xx_bootrom.bin', ) if install_blobs
pc-bios/npcm7xx_bootrom.bin new file binary +0 -0
roms/Makefile +7 -0
@@ -34,6 +34,7 @@ find-cross-gcc = $(firstword $(wildcard $(patsubst %ld,%gcc,$(call find-cross-ld # finally strip off path + toolname so we get the prefix find-cross-prefix = $(subst gcc,,$(notdir $(call find-cross-gcc,$(1)))) +arm_cross_prefix := $(call find-cross-prefix,arm) powerpc64_cross_prefix := $(call find-cross-prefix,powerpc64) powerpc_cross_prefix := $(call find-cross-prefix,powerpc) x86_64_cross_prefix := $(call find-cross-prefix,x86_64)
@@ -63,6 +64,7 @@ default help: @echo " skiboot -- update skiboot.lid" @echo " u-boot.e500 -- update u-boot.e500" @echo " u-boot.sam460 -- update u-boot.sam460" + @echo " npcm7xx_bootrom -- update vbootrom for npcm7xx" @echo " efi -- update UEFI (edk2) platform firmware" @echo " opensbi32-generic -- update OpenSBI for 32-bit generic machine" @echo " opensbi64-generic -- update OpenSBI for 64-bit generic machine"
@@ -184,6 +186,10 @@ bios-microvm: $(MAKE) -C qboot cp qboot/bios.bin ../pc-bios/bios-microvm.bin +npcm7xx_bootrom: + $(MAKE) -C vbootrom CROSS_COMPILE=$(arm_cross_prefix) + cp vbootrom/npcm7xx_bootrom.bin ../pc-bios/npcm7xx_bootrom.bin + clean: rm -rf seabios/.config seabios/out seabios/builds $(MAKE) -C sgabios clean
@@ -197,3 +203,4 @@ clean: $(MAKE) -f Makefile.edk2 clean $(MAKE) -C opensbi clean $(MAKE) -C qboot clean + $(MAKE) -C vbootrom clean
roms/vbootrom new file +1 -0
@@ -0,0 +1 @@ +Subproject commit 0c37a43527f0ee2b9584e7fb2fdc805e902635ac
Signature · 1 line
2.28.0.526.ge36021eeef-goog
PATCH v9 4/14 hw/arm: Add NPCM730 and NPCM750 SoC models
In reply to Havard Skinnemoen viaThe Nuvoton NPCM7xx SoC family are used to implement Baseboard Management Controllers in servers. While the family includes four SoCs, this patch implements limited support for two of them: NPCM730 (targeted for Data Center applications) and NPCM750 (targeted for Enterprise applications).
This patch includes little more than the bare minimum needed to boot a Linux kernel built with NPCM7xx support in direct-kernel mode:
- Two Cortex-A9 CPU cores with built-in periperhals.
- Global Configuration Registers.
- Clock Management.
- 3 Timer Modules with 5 timers each.
- 4 serial ports.
The chips themselves have a lot more features, some of which will be added to the model at a later stage.
--- include/hw/arm/npcm7xx.h | 85 ++++++++ hw/arm/npcm7xx.c | 407 +++++++++++++++++++++++++++++++++++++++ hw/arm/Kconfig | 5 + hw/arm/meson.build | 1 + 4 files changed, 498 insertions(+) create mode 100644 include/hw/arm/npcm7xx.h create mode 100644 hw/arm/npcm7xx.c
include/hw/arm/npcm7xx.h new file +85 -0
@@ -0,0 +1,85 @@ +/* +* Nuvoton NPCM7xx SoC family. +* +* Copyright 2020 Google LLC +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* for more details. +*/ +#ifndef NPCM7XX_H +#define NPCM7XX_H + +#include "hw/boards.h" +#include "hw/cpu/a9mpcore.h" +#include "hw/misc/npcm7xx_clk.h" +#include "hw/misc/npcm7xx_gcr.h" +#include "hw/timer/npcm7xx_timer.h" +#include "target/arm/cpu.h" + +#define NPCM7XX_MAX_NUM_CPUS (2) + +/* The first half of the address space is reserved for DDR4 DRAM. */ +#define NPCM7XX_DRAM_BA (0x00000000) +#define NPCM7XX_DRAM_SZ (2 * GiB) + +/* Magic addresses for setting up direct kernel booting and SMP boot stubs. */ +#define NPCM7XX_LOADER_START (0x00000000)/* Start of SDRAM */ +#define NPCM7XX_SMP_LOADER_START (0xffff0000)/* Boot ROM */ +#define NPCM7XX_SMP_BOOTREG_ADDR (0xf080013c)/* GCR.SCRPAD */ +#define NPCM7XX_GIC_CPU_IF_ADDR (0xf03fe100)/* GIC within A9 */ + +typedef struct NPCM7xxState { +DeviceState parent; + +ARMCPU cpu[NPCM7XX_MAX_NUM_CPUS ]; +A9MPPrivState a9mpcore; + +MemoryRegion sram; +MemoryRegion irom; +MemoryRegion ram3; +MemoryRegion *dram; + +NPCM7xxGCRState gcr; +NPCM7xxCLKState clk; +NPCM7xxTimerCtrlState tim[3 ]; +}NPCM7xxState ; + +#define TYPE_NPCM7XX "npcm7xx" +#define NPCM7XX (obj) OBJECT_CHECK(NPCM7xxState, (obj), TYPE_NPCM7XX) + +#define TYPE_NPCM730 "npcm730" +#define TYPE_NPCM750 "npcm750" + +typedef struct NPCM7xxClass { +DeviceClass parent; + +/* Bitmask of modules that are permanently disabled on this chip. */ +uint32_t disabled_modules; +/* Number of CPU cores enabled in this SoC class (may be 1 or 2). */ +uint32_t num_cpus; +}NPCM7xxClass ; + +#define NPCM7XX_CLASS (klass) \ + OBJECT_CLASS_CHECK(NPCM7xxClass, (klass), TYPE_NPCM7XX) +#define NPCM7XX_GET_CLASS (obj) \ + OBJECT_GET_CLASS(NPCM7xxClass, (obj), TYPE_NPCM7XX) + +/** +* npcm7xx_load_kernel - Loads memory with everything needed to boot +* @machine - The machine containing the SoC to be booted. +* @soc - The SoC containing the CPU to be booted. +* +* This will set up the ARM boot info structure for the specific NPCM7xx +* derivative and call arm_load_kernel() to set up loading of the kernel, etc. +* into memory, if requested by the user. +*/ +void npcm7xx_load_kernel (MachineState *machine,NPCM7xxState *soc); + +#endif /* NPCM7XX_H */
hw/arm/npcm7xx.c new file +407 -0
407 lines not on this page · raw message
hw/arm/Kconfig +5 -0
@@ -357,6 +357,11 @@ config XLNX_VERSAL config NPCM7XX bool + select A9MPCORE + select ARM_GIC + select PL310 # cache controller + select SERIAL + select UNIMP config FSL_IMX25 bool
hw/arm/meson.build +1 -0
@@ -13,6 +13,7 @@ arm_ss.add(when: 'CONFIG_MICROBIT', if_true: files('microbit.c')) arm_ss.add(when: 'CONFIG_MUSICPAL', if_true: files('musicpal.c')) arm_ss.add(when: 'CONFIG_NETDUINO2', if_true: files('netduino2.c')) arm_ss.add(when: 'CONFIG_NETDUINOPLUS2', if_true: files('netduinoplus2.c')) +arm_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx.c')) arm_ss.add(when: 'CONFIG_NSERIES', if_true: files('nseries.c')) arm_ss.add(when: 'CONFIG_SX1', if_true: files('omap_sx1.c')) arm_ss.add(when: 'CONFIG_CHEETAH', if_true: files('palm.c'))
Signature · 1 line
2.28.0.526.ge36021eeef-goog
PATCH v9 5/14 hw/arm: Add two NPCM7xx-based machines
In reply to Havard Skinnemoen viaThis adds two new machines, both supported by OpenBMC:
- npcm750-evb: Nuvoton NPCM750 Evaluation Board.
- quanta-gsj: A board with a NPCM730 chip.
They rely on the NPCM7xx SoC device to do the heavy lifting. They are almost completely identical at the moment, apart from the SoC type, which currently only changes the reset contents of one register (GCR.MDLR), but they might grow apart a bit more as more functionality is added.
Both machines can boot the Linux kernel into /bin/sh.
--- default-configs/arm-softmmu.mak | 1 + include/hw/arm/npcm7xx.h | 19 +++++ hw/arm/npcm7xx_boards.c | 145 ++++++++++++++++++++++++++++++++ hw/arm/meson.build | 2 +- 4 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 hw/arm/npcm7xx_boards.c
default-configs/arm-softmmu.mak +1 -0
@@ -27,6 +27,7 @@ CONFIG_GUMSTIX=y CONFIG_SPITZ=y CONFIG_TOSA=y CONFIG_Z2=y +CONFIG_NPCM7XX=y CONFIG_COLLIE=y CONFIG_ASPEED_SOC=y CONFIG_NETDUINO2=y
include/hw/arm/npcm7xx.h +19 -0
@@ -35,6 +35,25 @@#define NPCM7XX_SMP_BOOTREG_ADDR (0xf080013c)/* GCR.SCRPAD */ #define NPCM7XX_GIC_CPU_IF_ADDR (0xf03fe100)/* GIC within A9 */ +typedef struct NPCM7xxMachine { +MachineState parent; +}NPCM7xxMachine ; + +#define TYPE_NPCM7XX_MACHINE MACHINE_TYPE_NAME("npcm7xx") +#define NPCM7XX_MACHINE (obj) \ + OBJECT_CHECK(NPCM7xxMachine, (obj), TYPE_NPCM7XX_MACHINE) + +typedef struct NPCM7xxMachineClass { +MachineClass parent; + +const char *soc_type; +}NPCM7xxMachineClass ; + +#define NPCM7XX_MACHINE_CLASS (klass) \ + OBJECT_CLASS_CHECK(NPCM7xxMachineClass, (klass), TYPE_NPCM7XX_MACHINE) +#define NPCM7XX_MACHINE_GET_CLASS (obj) \ + OBJECT_GET_CLASS(NPCM7xxMachineClass, (obj), TYPE_NPCM7XX_MACHINE) + typedef struct NPCM7xxState { DeviceState parent;
hw/arm/npcm7xx_boards.c new file +145 -0
145 lines not on this page · raw message
hw/arm/meson.build +1 -1
@@ -13,7 +13,7 @@ arm_ss.add(when: 'CONFIG_MICROBIT', if_true: files('microbit.c')) arm_ss.add(when: 'CONFIG_MUSICPAL', if_true: files('musicpal.c')) arm_ss.add(when: 'CONFIG_NETDUINO2', if_true: files('netduino2.c')) arm_ss.add(when: 'CONFIG_NETDUINOPLUS2', if_true: files('netduinoplus2.c')) -arm_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx.c')) +arm_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx.c', 'npcm7xx_boards.c')) arm_ss.add(when: 'CONFIG_NSERIES', if_true: files('nseries.c')) arm_ss.add(when: 'CONFIG_SX1', if_true: files('omap_sx1.c')) arm_ss.add(when: 'CONFIG_CHEETAH', if_true: files('palm.c'))
Signature · 1 line
2.28.0.526.ge36021eeef-goog
PATCH v9 7/14 hw/arm: Load -bios image as a boot ROM for npcm7xx
In reply to Havard Skinnemoen viaIf a -bios option is specified on the command line, load the image into the internal ROM memory region, which contains the first instructions run by the CPU after reset.
If -bios is not specified, the vbootrom included with qemu is loaded by default.
--- hw/arm/npcm7xx_boards.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
hw/arm/npcm7xx_boards.c +32 -0
@@ -19,12 +19,42 @@#include "exec/address-spaces.h" #include "hw/arm/npcm7xx.h" #include "hw/core/cpu.h" +#include "hw/loader.h" #include "qapi/error.h" +#include "qemu-common.h" #include "qemu/units.h" +#include "sysemu/sysemu.h" #define NPCM750_EVB_POWER_ON_STRAPS 0x00001ff7#define QUANTA_GSJ_POWER_ON_STRAPS 0x00001fff +static const char npcm7xx_default_bootrom[] ="npcm7xx_bootrom.bin" ; + +static void npcm7xx_load_bootrom (MachineState *machine,NPCM7xxState *soc) +{ + g_autofree char *filename = NULL; +int ret; + +if (!bios_name) { + bios_name = npcm7xx_default_bootrom; + } + + filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name); +if (!filename) { +error_report ("Could not find ROM image '%s'" , bios_name); +if (!machine->kernel_filename) { +/* We can't boot without a bootrom or a kernel image. */ +exit (1 ); + } +return ; + } + ret =load_image_mr (filename, &soc->irom); +if (ret <0 ) { +error_report ("Failed to load ROM image '%s'" , filename); +exit (1 ); + } +} +static void npcm7xx_connect_dram (NPCM7xxState *soc,MemoryRegion *dram) {memory_region_add_subregion (get_system_memory (),NPCM7XX_DRAM_BA , dram);
@@ -61,6 +91,7 @@ static void npcm750_evb_init(MachineState *machine)npcm7xx_connect_dram (soc, machine->ram);qdev_realize (DEVICE (soc),NULL , &error_fatal); +npcm7xx_load_bootrom (machine, soc);npcm7xx_load_kernel (machine, soc); }
@@ -72,6 +103,7 @@ static void quanta_gsj_init(MachineState *machine)npcm7xx_connect_dram (soc, machine->ram);qdev_realize (DEVICE (soc),NULL , &error_fatal); +npcm7xx_load_bootrom (machine, soc);npcm7xx_load_kernel (machine, soc); }
Signature · 1 line
2.28.0.526.ge36021eeef-goog
PATCH v9 9/14 hw/mem: Stubbed out NPCM7xx Memory Controller model
In reply to Havard Skinnemoen viaThis just implements the bare minimum to cause the boot block to skip memory initialization.
--- include/hw/arm/npcm7xx.h | 2 + include/hw/mem/npcm7xx_mc.h | 36 ++++++++++++++++ hw/arm/npcm7xx.c | 6 +++ hw/mem/npcm7xx_mc.c | 84 +++++++++++++++++++++++++++++++++++++ hw/mem/meson.build | 1 + 5 files changed, 129 insertions(+) create mode 100644 include/hw/mem/npcm7xx_mc.h create mode 100644 hw/mem/npcm7xx_mc.c
include/hw/arm/npcm7xx.h +2 -0
@@ -18,6 +18,7 @@#include "hw/boards.h" #include "hw/cpu/a9mpcore.h" +#include "hw/mem/npcm7xx_mc.h" #include "hw/misc/npcm7xx_clk.h" #include "hw/misc/npcm7xx_gcr.h" #include "hw/nvram/npcm7xx_otp.h"
@@ -71,6 +72,7 @@ typedef struct NPCM7xxState {NPCM7xxTimerCtrlState tim[3 ];NPCM7xxOTPState key_storage;NPCM7xxOTPState fuse_array; +NPCM7xxMCState mc; } NPCM7xxState;#define TYPE_NPCM7XX "npcm7xx"
include/hw/mem/npcm7xx_mc.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* Nuvoton NPCM7xx Memory Controller stub +* +* Copyright 2020 Google LLC +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* for more details. +*/ +#ifndef NPCM7XX_MC_H +#define NPCM7XX_MC_H + +#include "exec/memory.h" +#include "hw/sysbus.h" + +/** +* struct NPCM7xxMCState - Device state for the memory controller. +* @parent: System bus device. +* @mmio: Memory region through which registers are accessed. +*/ +typedef struct NPCM7xxMCState { +SysBusDevice parent; + +MemoryRegion mmio; +}NPCM7xxMCState ; + +#define TYPE_NPCM7XX_MC "npcm7xx-mc" +#define NPCM7XX_MC (obj) OBJECT_CHECK(NPCM7xxMCState, (obj), TYPE_NPCM7XX_MC) + +#endif /* NPCM7XX_MC_H */
hw/arm/npcm7xx.c +6 -0
@@ -43,6 +43,7 @@#define NPCM7XX_CPUP_BA (0xf03fe000)#define NPCM7XX_GCR_BA (0xf0800000)#define NPCM7XX_CLK_BA (0xf0801000) +#define NPCM7XX_MC_BA (0xf0824000)/* Internal AHB SRAM */ #define NPCM7XX_RAM3_BA (0xc0008000)
@@ -186,6 +187,7 @@ static void npcm7xx_init(Object *obj) TYPE_NPCM7XX_KEY_STORAGE);object_initialize_child (obj,"otp2" , &s->fuse_array,TYPE_NPCM7XX_FUSE_ARRAY ); +object_initialize_child (obj,"mc" , &s->mc,TYPE_NPCM7XX_MC );for (i =0 ; i <ARRAY_SIZE (s->tim); i++) {object_initialize_child (obj,"tim[*]" , &s->tim[i],TYPE_NPCM7XX_TIMER );
@@ -261,6 +263,10 @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)sysbus_mmio_map (SYS_BUS_DEVICE (&s->fuse_array),0 ,NPCM7XX_OTP2_BA );npcm7xx_init_fuses (s); +/* Fake Memory Controller (MC). Cannot fail. */ +sysbus_realize (SYS_BUS_DEVICE (&s->mc), &error_abort); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->mc),0 ,NPCM7XX_MC_BA ); +/* Timer Modules (TIM). Cannot fail. */ QEMU_BUILD_BUG_ON (ARRAY_SIZE (npcm7xx_tim_addr) !=ARRAY_SIZE (s->tim));for (i =0 ; i <ARRAY_SIZE (s->tim); i++) {
hw/mem/npcm7xx_mc.c new file +84 -0
84 lines not on this page · raw message
hw/mem/meson.build +1 -0
@@ -1,6 +1,7 @@ mem_ss = ss.source_set() mem_ss.add(files('memory-device.c')) mem_ss.add(when: 'CONFIG_DIMM', if_true: files('pc-dimm.c')) +mem_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_mc.c')) mem_ss.add(when: 'CONFIG_NVDIMM', if_true: files('nvdimm.c')) softmmu_ss.add_all(when: 'CONFIG_MEM_DEVICE', if_true: mem_ss)
Signature · 1 line
2.28.0.526.ge36021eeef-goog
PATCH v9 12/14 hw/arm/npcm7xx: add board setup stub for CPU and UART clocks
In reply to Havard Skinnemoen viaWhen booting directly into a kernel, bypassing the boot loader, the CPU and UART clocks are not set up correctly. This makes the system appear very slow, and causes the initrd boot test to fail when optimization is off.
The UART clock must run at 24 MHz. The default 25 MHz reference clock cannot achieve this, so switch to PLL2/2 @ 480 MHz, which works perfectly with the default /20 divider.
The CPU clock should run at 800 MHz, so switch it to PLL1/2. PLL1 runs at 800 MHz by default, so we need to double the feedback divider as well to make it run at 1600 MHz (so PLL1/2 runs at 800 MHz).
We don't bother checking for PLL lock because we know our emulated PLLs lock instantly.
--- include/hw/arm/npcm7xx.h | 1 + hw/arm/npcm7xx.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+)
include/hw/arm/npcm7xx.h +1 -0
@@ -37,6 +37,7 @@#define NPCM7XX_SMP_LOADER_START (0xffff0000)/* Boot ROM */ #define NPCM7XX_SMP_BOOTREG_ADDR (0xf080013c)/* GCR.SCRPAD */ #define NPCM7XX_GIC_CPU_IF_ADDR (0xf03fe100)/* GIC within A9 */ +#define NPCM7XX_BOARD_SETUP_ADDR (0xffff1000)/* Boot ROM */ typedef struct NPCM7xxMachine { MachineState parent;
hw/arm/npcm7xx.c +32 -0
@@ -55,6 +55,13 @@#define NPCM7XX_ROM_BA (0xffff0000)#define NPCM7XX_ROM_SZ (64 * KiB) +/* Clock configuration values to be fixed up when bypassing bootloader */ + +/* Run PLL1 at 1600 MHz */ +#define NPCM7XX_PLLCON1_FIXUP_VAL (0x00402101) +/* Run the CPU from PLL1 and UART from PLL2 */ +#define NPCM7XX_CLKSEL_FIXUP_VAL (0x004aaba9) +/* * Interrupt lines going into the GIC. This does not include internal Cortex-A9 * interrupts.
@@ -132,6 +139,29 @@ static const struct { }, }; +static void npcm7xx_write_board_setup (ARMCPU *cpu, +const struct arm_boot_info *info) +{ +uint32_t board_setup[] = { +0xe59f0010 ,/* ldr r0, clk_base_addr */ +0xe59f1010 ,/* ldr r1, pllcon1_value */ +0xe5801010 ,/* str r1, [r0, #16] */ +0xe59f100c ,/* ldr r1, clksel_value */ +0xe5801004 ,/* str r1, [r0, #4] */ +0xe12fff1e ,/* bx lr */ +NPCM7XX_CLK_BA , +NPCM7XX_PLLCON1_FIXUP_VAL , +NPCM7XX_CLKSEL_FIXUP_VAL , + }; +int i; + +for (i =0 ; i <ARRAY_SIZE (board_setup); i++) { + board_setup[i] =tswap32 (board_setup[i]); + } +rom_add_blob_fixed ("board-setup" , board_setup,sizeof (board_setup), + info->board_setup_addr); +} +static void npcm7xx_write_secondary_boot (ARMCPU *cpu,const struct arm_boot_info *info) {
@@ -170,6 +200,8 @@ static struct arm_boot_info npcm7xx_binfo = { .gic_cpu_if_addr = NPCM7XX_GIC_CPU_IF_ADDR, .write_secondary_boot = npcm7xx_write_secondary_boot, .board_id = -1, + .board_setup_addr = NPCM7XX_BOARD_SETUP_ADDR, + .write_board_setup = npcm7xx_write_board_setup, };void npcm7xx_load_kernel (MachineState *machine,NPCM7xxState *soc)
Signature · 1 line
2.28.0.526.ge36021eeef-goog
PATCH v9 8/14 hw/nvram: NPCM7xx OTP device model
In reply to Havard Skinnemoen viaThis supports reading and writing OTP fuses and keys. Only fuse reading has been tested. Protection is not implemented.
--- include/hw/arm/npcm7xx.h | 3 + include/hw/nvram/npcm7xx_otp.h | 79 ++++++ hw/arm/npcm7xx.c | 29 +++ hw/nvram/npcm7xx_otp.c | 440 +++++++++++++++++++++++++++++++++ hw/nvram/meson.build | 1 + 5 files changed, 552 insertions(+) create mode 100644 include/hw/nvram/npcm7xx_otp.h create mode 100644 hw/nvram/npcm7xx_otp.c
include/hw/arm/npcm7xx.h +3 -0
@@ -20,6 +20,7 @@#include "hw/cpu/a9mpcore.h" #include "hw/misc/npcm7xx_clk.h" #include "hw/misc/npcm7xx_gcr.h" +#include "hw/nvram/npcm7xx_otp.h" #include "hw/timer/npcm7xx_timer.h" #include "target/arm/cpu.h"
@@ -68,6 +69,8 @@ typedef struct NPCM7xxState {NPCM7xxGCRState gcr;NPCM7xxCLKState clk;NPCM7xxTimerCtrlState tim[3 ]; +NPCM7xxOTPState key_storage; +NPCM7xxOTPState fuse_array; } NPCM7xxState;#define TYPE_NPCM7XX "npcm7xx"
include/hw/nvram/npcm7xx_otp.h new file +79 -0
79 lines not on this page · raw message
hw/arm/npcm7xx.c +29 -0
@@ -34,6 +34,10 @@#define NPCM7XX_MMIO_BA (0x80000000)#define NPCM7XX_MMIO_SZ (0x7ffd0000) +/* OTP key storage and fuse strap array */ +#define NPCM7XX_OTP1_BA (0xf0189000) +#define NPCM7XX_OTP2_BA (0xf018a000) +/* Core system modules. */ #define NPCM7XX_L2C_BA (0xf03fc000)#define NPCM7XX_CPUP_BA (0xf03fe000)
@@ -144,6 +148,20 @@ void npcm7xx_load_kernel(MachineState *machine, NPCM7xxState *soc)arm_load_kernel (&soc->cpu[0 ], machine, &npcm7xx_binfo); } +static void npcm7xx_init_fuses (NPCM7xxState *s) +{ +NPCM7xxClass *nc =NPCM7XX_GET_CLASS (s); +uint32_t value; + +/* +* The initial mask of disabled modules indicates the chip derivative (e.g. +* NPCM750 or NPCM730). +*/ + value =tswap32 (nc->disabled_modules); +npcm7xx_otp_array_write (&s->fuse_array, &value,NPCM7XX_FUSE_DERIVATIVE , +sizeof (value)); +} +static qemu_irq npcm7xx_irq (NPCM7xxState *s,int n) {return qdev_get_gpio_in (DEVICE (&s->a9mpcore), n);
@@ -164,6 +182,10 @@ static void npcm7xx_init(Object *obj)object_property_add_alias (obj,"power-on-straps" ,OBJECT (&s->gcr),"power-on-straps" );object_initialize_child (obj,"clk" , &s->clk,TYPE_NPCM7XX_CLK ); +object_initialize_child (obj,"otp1" , &s->key_storage, +TYPE_NPCM7XX_KEY_STORAGE ); +object_initialize_child (obj,"otp2" , &s->fuse_array, +TYPE_NPCM7XX_FUSE_ARRAY );for (i =0 ; i <ARRAY_SIZE (s->tim); i++) {object_initialize_child (obj,"tim[*]" , &s->tim[i],TYPE_NPCM7XX_TIMER );
@@ -232,6 +254,13 @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)sysbus_realize (SYS_BUS_DEVICE (&s->clk), &error_abort);sysbus_mmio_map (SYS_BUS_DEVICE (&s->clk),0 ,NPCM7XX_CLK_BA ); +/* OTP key storage and fuse strap array. Cannot fail. */ +sysbus_realize (SYS_BUS_DEVICE (&s->key_storage), &error_abort); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->key_storage),0 ,NPCM7XX_OTP1_BA ); +sysbus_realize (SYS_BUS_DEVICE (&s->fuse_array), &error_abort); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->fuse_array),0 ,NPCM7XX_OTP2_BA ); +npcm7xx_init_fuses (s); +/* Timer Modules (TIM). Cannot fail. */ QEMU_BUILD_BUG_ON (ARRAY_SIZE (npcm7xx_tim_addr) !=ARRAY_SIZE (s->tim));for (i =0 ; i <ARRAY_SIZE (s->tim); i++) {
hw/nvram/npcm7xx_otp.c new file +440 -0
440 lines not on this page · raw message
hw/nvram/meson.build +1 -0
@@ -4,6 +4,7 @@ softmmu_ss.add(when: 'CONFIG_DS1225Y', if_true: files('ds1225y.c')) softmmu_ss.add(when: 'CONFIG_NMC93XX_EEPROM', if_true: files('eeprom93xx.c')) softmmu_ss.add(when: 'CONFIG_AT24C', if_true: files('eeprom_at24c.c')) softmmu_ss.add(when: 'CONFIG_MAC_NVRAM', if_true: files('mac_nvram.c')) +softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_otp.c')) softmmu_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_nvm.c')) specific_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr_nvram.c'))
Signature · 1 line
2.28.0.526.ge36021eeef-goog
Re: [PATCH v9 08/14] hw/nvram: NPCM7xx OTP device model
Hi,
(old patch)
Quoted 31 lines · Havard Skinnemoen
This supports reading and writing OTP fuses and keys. Only fuse reading has been tested. Protection is not implemented.
Reviewed-by Avi Fishman <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Tested-by Alexander Bulekov <[email protected]>Signed-off-by Havard Skinnemoen <[email protected]>--- include/hw/arm/npcm7xx.h | 3 + include/hw/nvram/npcm7xx_otp.h | 79 ++++++ hw/arm/npcm7xx.c | 29 +++ hw/nvram/npcm7xx_otp.c | 440 +++++++++++++++++++++++++++++++++ hw/nvram/meson.build | 1 + 5 files changed, 552 insertions(+)create mode 100644
include/hw/nvram/npcm7xx_otp.hcreate mode 100644hw/nvram/npcm7xx_otp.cinclude/hw/nvram/npcm7xx_otp.h new file +12
-0+/** +* npcm7xx_otp_array_write - ECC encode and write data to OTP array. +* @s: OTP module. +* @data: Data to be encoded and written. +* @offset: Offset of first byte to be written in the OTP array. +* @len: Number of bytes before ECC encoding. +* +* Each nibble of data is encoded into a byte, so the number of bytes written +* to the array will be @len * 2. +*/ +extern void npcm7xx_otp_array_write (NPCM7xxOTPState *s,const void *data, +unsigned int offset,unsigned int len);
include/hw/nvram/npcm7xx_otp.h
Quoted 10 lines
include/hw/nvram/npcm7xx_otp.h new file +10
-0+static void npcm7xx_init_fuses (NPCM7xxState *s) +{ +NPCM7xxClass *nc =NPCM7XX_GET_CLASS (s); +uint32_t value; + +/* +* The initial mask of disabled modules indicates the chip derivative (e.g. +* NPCM750 or NPCM730). +*/ + value =tswap32 (nc->disabled_modules);
In which endianness do you want this 32-bit fuse value to be written?
I suppose you used a little-endian host, so we want it big-endian in the OTP? In that case it would be better to use cpu_to_be32(), to be able to use the OTP on a big-endian host such s390x.
hw/arm/npcm7xx.c void npcm7xx_load_kernel(MachineState *machine, NPCM7xxState *soc) · line 163
Quoted 3 lines
hw/arm/npcm7xx.c +3
-0+npcm7xx_otp_array_write (&s->fuse_array, &value,NPCM7XX_FUSE_DERIVATIVE , +sizeof (value)); +}
For completeness:
Quoted 7 lines
(quoted diff) +7
-0+static void npcm730_class_init(ObjectClass *oc, void *data) +{ + NPCM7xxClass *nc = NPCM7XX_CLASS(oc); + + /* NPCM730 is optimized for data center use, so no graphics, etc. */ + nc->disabled_modules = 0x00300395; + nc->num_cpus = 2;
Review
Quoted 10 lines
(quoted diff) +10
-0+} + +static void npcm750_class_init(ObjectClass *oc, void *data) +{ + NPCM7xxClass *nc = NPCM7XX_CLASS(oc); + + /* NPCM750 has 2 cores and a full set of peripherals */ + nc->disabled_modules = 0x00000000; + nc->num_cpus = 2; +}
Thanks,
Phil.
Re: [PATCH v9 08/14] hw/nvram: NPCM7xx OTP device model
Tyrone, Hao, ping?
Quoted 86 lines · Philippe Mathieu-Daudé
Hi,
(old patch)
Quoted 41 lines · Havard Skinnemoen
This supports reading and writing OTP fuses and keys. Only fuse reading has been tested. Protection is not implemented.
Reviewed-by Avi Fishman <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Tested-by Alexander Bulekov <[email protected]>Signed-off-by Havard Skinnemoen <[email protected]>---
include/hw/arm/npcm7xx.h | 3 +include/hw/nvram/npcm7xx_otp.h| 79 ++++++ hw/arm/npcm7xx.c | 29 +++ hw/nvram/npcm7xx_otp.c | 440 +++++++++++++++++++++++++++++++++ hw/nvram/meson.build | 1 +5 files changed, 552 insertions(+)create mode 100644
include/hw/nvram/npcm7xx_otp.hcreate mode 100644hw/nvram/npcm7xx_otp.c+/**
+ *npcm7xx_otp_array_write- ECC encode and write data to OTP array.
+ * @s: OTP module.
+ * @data: Data to be encoded and written.
+ * @offset: Offset of first byte to be written in the OTP array.
+ * @len: Number of bytes before ECC encoding.
+ *
+ * Each nibble of data is encoded into a byte, so the number of bytes written
+ * to the array will be @len * 2.
+ */
+extern void npcm7xx_otp_array_write(NPCM7xxOTPState *s, const void *data,
+ unsigned int offset, unsigned int len);hw/arm/npcm7xx.c +7
-0+static void npcm7xx_init_fuses (NPCM7xxState *s) +{ + NPCM7xxClass *nc = NPCM7XX_GET_CLASS(s); + uint32_t value; + + /* +* The initial mask of disabled modules indicates the chip Quoted 4 lines
derivative (e.g.
+ * NPCM750 or NPCM730).
+ */
+ value =tswap32(nc->disabled_modules);In which endianness do you want this 32-bit fuse value to be written?
I suppose you used a little-endian host, so we want it big-endian in the OTP? In that case it would be better to use
cpu_to_be32(), to be able to use the OTP on a big-endian host such s390x.Quoted 4 lines
+ npcm7xx_otp_array_write(&s->fuse_array, &value,
NPCM7XX_FUSE_DERIVATIVE,
+ sizeof(value)); +}For completeness:
Review
Quoted 5 lines
(quoted diff) +5
-0+static void npcm730_class_init(ObjectClass *oc, void *data) +{ + NPCM7xxClass *nc = NPCM7XX_CLASS(oc); + + /* NPCM730 is optimized for data center use, so no graphics,etc. */
hw/nvram/npcm7xx_otp.c line 103
Quoted 12 lines
+
nc->disabled_modules=0x00300395;
+nc->num_cpus= 2;hw/nvram/npcm7xx_otp.c new file +10
-0+} + +static void npcm750_class_init (ObjectClass *oc,void *data) +{ + NPCM7xxClass *nc = NPCM7XX_CLASS(oc); + + /* NPCM750 has 2 cores and a full set of peripherals */ + nc->disabled_modules = 0x00000000; + nc->num_cpus = 2; +}Thanks,
Phil.
RE: [PATCH v9 08/14] hw/nvram: NPCM7xx OTP device model
Hi Philippe:
We're checking it internally.
I'm sorry for the late response.
Thank you.
Regards,
Tyrone
-----Original Message-----
From: Philippe Mathieu-Daudé <[email protected]>
Sent: Thursday, February 23, 2023 6:44 PM
To: Havard Skinnemoen <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; IS20 Avi Fishman <[email protected]>; CS20 KFTing <[email protected]>; Alexander Bulekov <[email protected]>; Shengtan Mao <[email protected]>; Hao Wu <[email protected]>; Chris Rauer <[email protected]>
Subject: Re: [PATCH v9 08/14] hw/nvram: NPCM7xx OTP device model
Tyrone, Hao, ping?
Quoted 74 lines · Philippe Mathieu-Daudé
Hi,
(old patch)
Quoted 44 lines · Havard Skinnemoen
This supports reading and writing OTP fuses and keys. Only fuse reading has been tested. Protection is not implemented.
Reviewed-by Avi Fishman <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Tested-by Alexander Bulekov <[email protected]>Signed-off-by Havard Skinnemoen <[email protected]>--- include/hw/arm/npcm7xx.h | 3 + include/hw/nvram/npcm7xx_otp.h | 79 ++++++ hw/arm/npcm7xx.c | 29 +++ hw/nvram/npcm7xx_otp.c | 440 +++++++++++++++++++++++++++++++++ hw/nvram/meson.build | 1 + 5 files changed, 552 insertions(+)create mode 100644
include/hw/nvram/npcm7xx_otp.hcreate mode 100644hw/nvram/npcm7xx_otp.cinclude/hw/nvram/npcm7xx_otp.h new file +9
-0+/** +* npcm7xx_otp_array_write - ECC encode and write data to OTP array. +* @s: OTP module. +* @data: Data to be encoded and written. +* @offset: Offset of first byte to be written in the OTP array. +* @len: Number of bytes before ECC encoding. +* +* Each nibble of data is encoded into a byte, so the number of +bytes written
+ * to the array will be @len * 2.
+ */
+extern void npcm7xx_otp_array_write(NPCM7xxOTPState *s, const void *data,(quoted diff) +2
-0+ unsigned int offset, unsigned +intlen);
hw/arm/npcm7xx.c +6
-0+static void npcm7xx_init_fuses (NPCM7xxState *s) { +NPCM7xxClass *nc =NPCM7XX_GET_CLASS (s); +uint32_t value; + +/* +* The initial mask of disabled modules indicates the chip derivative (e.g.
hw/arm/npcm7xx.c void npcm7xx_load_kernel(MachineState *machine, NPCM7xxState *soc) · line 160
Quoted 3 lines
hw/arm/npcm7xx.c +3
-0+* NPCM750 or NPCM730). +*/ + value =tswap32 (nc->disabled_modules);In which endianness do you want this 32-bit fuse value to be written?
I suppose you used a little-endian host, so we want it big-endian in the OTP? In that case it would be better to use
cpu_to_be32(), to be able to use the OTP on a big-endian host such s390x.Quoted 3 lines
+ npcm7xx_otp_array_write(&s->fuse_array, &value,
NPCM7XX_FUSE_DERIVATIVE,
+ sizeof(value)); }For completeness:
Review
Quoted 2 lines
(quoted diff) +2
-0+static void npcm730_class_init(ObjectClass *oc, void *data) > +{ + NPCM7xxClass *nc = NPCM7XX_CLASS(oc); > + > + /* NPCM730is optimized for data center use, so no graphics, etc. */ > +
nc->disabled_modules=0x00300395; > +nc->num_cpus= 2; > +} >(quoted diff) +2
-0+ > +static void npcm750_class_init(ObjectClass *oc, void *data) > +{ > + NPCM7xxClass *nc = NPCM7XX_CLASS(oc); > + > + /*NPCM750 has 2 cores and a full set of peripherals */ > +
nc->disabled_modules=0x00000000; > +nc->num_cpus= 2; > +}
Quoted 3 lines
Thanks,
Phil.
________________________________
________________________________
The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.
RE: [PATCH v9 08/14] hw/nvram: NPCM7xx OTP device model
In reply to Philippe Mathieu-DaudéHi,
Inside
Quoted 48 lines
-----Original Message-----
From: Philippe Mathieu-Daudé <[email protected]>
Sent: Thursday, December 22, 2022 5:03 PM
To: Havard Skinnemoen <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; IS20 Avi Fishman <[email protected]>; CS20 KFTing <[email protected]>; Alexander Bulekov <[email protected]>; Shengtan Mao <[email protected]>; Hao Wu <[email protected]>; Chris Rauer <[email protected]>; CS20 KFTing <[email protected]>
Subject: Re: [PATCH v9 08/14] hw/nvram: NPCM7xx OTP device modelHi,
(old patch)
Quoted 19 lines · Havard Skinnemoen
This supports reading and writing OTP fuses and keys. Only fuse reading has been tested. Protection is not implemented.
Reviewed-by Avi Fishman <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Tested-by Alexander Bulekov <[email protected]>Signed-off-by Havard Skinnemoen <[email protected]>--- include/hw/arm/npcm7xx.h | 3 + include/hw/nvram/npcm7xx_otp.h | 79 ++++++ hw/arm/npcm7xx.c | 29 +++ hw/nvram/npcm7xx_otp.c | 440 +++++++++++++++++++++++++++++++++ hw/nvram/meson.build | 1 + 5 files changed, 552 insertions(+)create mode 100644
include/hw/nvram/npcm7xx_otp.hcreate mode 100644hw/nvram/npcm7xx_otp.cinclude/hw/nvram/npcm7xx_otp.h new file +1
-0+/** include/hw/nvram/npcm7xx_otp.h
Quoted 10 lines
include/hw/nvram/npcm7xx_otp.h new file +10
-0+* npcm7xx_otp_array_write - ECC encode and write data to OTP array. +* @s: OTP module. +* @data: Data to be encoded and written. +* @offset: Offset of first byte to be written in the OTP array. +* @len: Number of bytes before ECC encoding. +* +* Each nibble of data is encoded into a byte, so the number of bytes written +* to the array will be @len * 2. +*/ +extern void npcm7xx_otp_array_write(NPCM7xxOTPState *s, const void*data,
Quoted 1 line
+ unsigned int offset, unsigned int len);
Quoted 12 lines
hw/arm/npcm7xx.c void npcm7xx_load_kernel(MachineState *machine, NPCM7xxState *soc) · line 160
Quoted 10 lines
hw/arm/npcm7xx.c +10
-0+static void npcm7xx_init_fuses (NPCM7xxState *s) +{ +NPCM7xxClass *nc =NPCM7XX_GET_CLASS (s); +uint32_t value; + +/* +* The initial mask of disabled modules indicates the chip derivative (e.g. +* NPCM750 or NPCM730). +*/ + value =tswap32 (nc->disabled_modules);In which endianness do you want this 32-bit fuse value to be written?
It should be little endian, I am not sure why there is a swap here. Unless the nc->disabled_modules for some reason is coming swapped so we swap it back.
Quoted 4 lines
I suppose you used a little-endian host, so we want it big-endian in the OTP? In that case it would be better to use
cpu_to_be32(), to be able to use the OTP on a big-endian host such s390x.
So according to what I said then use cpu_to_le32()
Quoted 28 lines
Quoted 2 lines
+ npcm7xx_otp_array_write(&s->fuse_array, &value,
NPCM7XX_FUSE_DERIVATIVE,hw/arm/npcm7xx.c void npcm7xx_load_kernel(MachineState *machine, NPCM7xxState *soc) · line 163
Quoted 2 lines
hw/arm/npcm7xx.c +2
-0+ sizeof(value)); +}For completeness:
Quoted 7 lines
(quoted diff) +7
-0+static void npcm730_class_init(ObjectClass *oc, void *data) +{ + NPCM7xxClass *nc = NPCM7XX_CLASS(oc); + + /* NPCM730 is optimized for data center use, so no graphics, etc. */ + nc->disabled_modules = 0x00300395; + nc->num_cpus = 2;Review
Quoted 10 lines
(quoted diff) +10
-0+} + +static void npcm750_class_init(ObjectClass *oc, void *data) +{ + NPCM7xxClass *nc = NPCM7XX_CLASS(oc); + + /* NPCM750 has 2 cores and a full set of peripherals */ + nc->disabled_modules = 0x00000000; + nc->num_cpus = 2; +}Thanks,
Quoted 1 line
Phil.
________________________________
________________________________
The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.
Re: [PATCH v9 08/14] hw/nvram: NPCM7xx OTP device model
Quoted 70 lines · On 5/3/23 08:41, [email protected] wrote:
Hi,
Inside
Quoted 48 lines
-----Original Message-----
From: Philippe Mathieu-Daudé <[email protected]>
Sent: Thursday, December 22, 2022 5:03 PM
To: Havard Skinnemoen <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; IS20 Avi Fishman <[email protected]>; CS20 KFTing <[email protected]>; Alexander Bulekov <[email protected]>; Shengtan Mao <[email protected]>; Hao Wu <[email protected]>; Chris Rauer <[email protected]>; CS20 KFTing <[email protected]>
Subject: Re: [PATCH v9 08/14] hw/nvram: NPCM7xx OTP device modelHi,
(old patch)
Quoted 19 lines · Havard Skinnemoen
This supports reading and writing OTP fuses and keys. Only fuse reading has been tested. Protection is not implemented.
Reviewed-by Avi Fishman <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Tested-by Alexander Bulekov <[email protected]>Signed-off-by Havard Skinnemoen <[email protected]>--- include/hw/arm/npcm7xx.h | 3 + include/hw/nvram/npcm7xx_otp.h | 79 ++++++ hw/arm/npcm7xx.c | 29 +++ hw/nvram/npcm7xx_otp.c | 440 +++++++++++++++++++++++++++++++++ hw/nvram/meson.build | 1 + 5 files changed, 552 insertions(+)create mode 100644
include/hw/nvram/npcm7xx_otp.hcreate mode 100644hw/nvram/npcm7xx_otp.cinclude/hw/nvram/npcm7xx_otp.h new file +1
-0+/** include/hw/nvram/npcm7xx_otp.h
Quoted 10 lines
include/hw/nvram/npcm7xx_otp.h new file +10
-0+* npcm7xx_otp_array_write - ECC encode and write data to OTP array. +* @s: OTP module. +* @data: Data to be encoded and written. +* @offset: Offset of first byte to be written in the OTP array. +* @len: Number of bytes before ECC encoding. +* +* Each nibble of data is encoded into a byte, so the number of bytes written +* to the array will be @len * 2. +*/ +extern void npcm7xx_otp_array_write(NPCM7xxOTPState *s, const void*data,
Quoted 1 line
+ unsigned int offset, unsigned int len);
Quoted 12 lines
hw/arm/npcm7xx.c void npcm7xx_load_kernel(MachineState *machine, NPCM7xxState *soc) · line 160
Quoted 10 lines
hw/arm/npcm7xx.c +10
-0+static void npcm7xx_init_fuses (NPCM7xxState *s) +{ +NPCM7xxClass *nc =NPCM7XX_GET_CLASS (s); +uint32_t value; + +/* +* The initial mask of disabled modules indicates the chip derivative (e.g. +* NPCM750 or NPCM730). +*/ + value =tswap32 (nc->disabled_modules);In which endianness do you want this 32-bit fuse value to be written?
It should be little endian, I am not sure why there is a swap here. Unless the
nc->disabled_modulesfor some reason is coming swapped so we swap it back.Quoted 1 line
Quoted 5 lines
Quoted 3 lines
I suppose you used a little-endian host, so we want it big-endian in the OTP? In that case it would be better to use
cpu_to_be32(), to be able to use the OTP on a big-endian host such s390x.So according to what I said then use
cpu_to_le32()
Thank you Avi!
PATCH v9 10/14 hw/ssi: NPCM7xx Flash Interface Unit device model
In reply to Havard Skinnemoen viaThis implements a device model for the NPCM7xx SPI flash controller.
Direct reads and writes, and user-mode transactions have been tested in various modes. Protection features are not implemented yet.
All the FIU instances are available in the SoC's address space, regardless of whether or not they're connected to actual flash chips.
--- include/hw/arm/npcm7xx.h | 2 + include/hw/ssi/npcm7xx_fiu.h | 73 +++++ hw/arm/npcm7xx.c | 58 ++++ hw/ssi/npcm7xx_fiu.c | 572 +++++++++++++++++++++++++++++++++++ hw/arm/Kconfig | 1 + hw/ssi/meson.build | 1 + hw/ssi/trace-events | 11 + 7 files changed, 718 insertions(+) create mode 100644 include/hw/ssi/npcm7xx_fiu.h create mode 100644 hw/ssi/npcm7xx_fiu.c
include/hw/arm/npcm7xx.h +2 -0
@@ -23,6 +23,7 @@#include "hw/misc/npcm7xx_gcr.h" #include "hw/nvram/npcm7xx_otp.h" #include "hw/timer/npcm7xx_timer.h" +#include "hw/ssi/npcm7xx_fiu.h" #include "target/arm/cpu.h" #define NPCM7XX_MAX_NUM_CPUS (2)
@@ -73,6 +74,7 @@ typedef struct NPCM7xxState {NPCM7xxOTPState key_storage;NPCM7xxOTPState fuse_array;NPCM7xxMCState mc; +NPCM7xxFIUState fiu[2 ]; } NPCM7xxState;#define TYPE_NPCM7XX "npcm7xx"
include/hw/ssi/npcm7xx_fiu.h new file +73 -0
73 lines not on this page · raw message
hw/arm/npcm7xx.c +58 -0
76 lines not on this page · raw message
hw/ssi/npcm7xx_fiu.c new file +572 -0
572 lines not on this page · raw message
hw/arm/Kconfig +1 -0
@@ -361,6 +361,7 @@ config NPCM7XX select ARM_GIC select PL310 # cache controller select SERIAL + select SSI select UNIMP config FSL_IMX25
hw/ssi/meson.build +1 -0
@@ -1,5 +1,6 @@ softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_smc.c')) softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('mss-spi.c')) +softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_fiu.c')) softmmu_ss.add(when: 'CONFIG_PL022', if_true: files('pl022.c')) softmmu_ss.add(when: 'CONFIG_SSI', if_true: files('ssi.c')) softmmu_ss.add(when: 'CONFIG_STM32F2XX_SPI', if_true: files('stm32f2xx_spi.c'))
hw/ssi/trace-events +11 -0
@@ -9,3 +9,14 @@ aspeed_smc_dma_checksum(uint32_t addr, uint32_t data) "0x%08x: 0x%08x" aspeed_smc_dma_rw(const char *dir, uint32_t flash_addr, uint32_t dram_addr, uint32_t size) "%s flash:@0x%08x dram:@0x%08x size:0x%08x" aspeed_smc_write(uint64_t addr, uint32_t size, uint64_t data) "@0x%" PRIx64 " size %u: 0x%" PRIx64 aspeed_smc_flash_select(int cs, const char *prefix) "CS%d %sselect" + +# npcm7xx_fiu.c + +npcm7xx_fiu_enter_reset(const char *id, int reset_type) "%s reset type: %d" +npcm7xx_fiu_hold_reset(const char *id) "%s" +npcm7xx_fiu_select(const char *id, int cs) "%s select CS%d" +npcm7xx_fiu_deselect(const char *id, int cs) "%s deselect CS%d" +npcm7xx_fiu_ctrl_read(const char *id, uint64_t addr, uint32_t data) "%s offset: 0x%04" PRIx64 " value: 0x%08" PRIx32 +npcm7xx_fiu_ctrl_write(const char *id, uint64_t addr, uint32_t data) "%s offset: 0x%04" PRIx64 " value: 0x%08" PRIx32 +npcm7xx_fiu_flash_read(const char *id, int cs, uint64_t addr, unsigned int size, uint64_t value) "%s[%d] offset: 0x%08" PRIx64 " size: %u value: 0x%" PRIx64 +npcm7xx_fiu_flash_write(const char *id, int cs, uint64_t addr, unsigned int size, uint64_t value) "%s[%d] offset: 0x%08" PRIx64 " size: %u value: 0x%" PRIx64
Signature · 1 line
2.28.0.526.ge36021eeef-goog
PATCH v9 11/14 hw/arm: Wire up BMC boot flash for npcm750-evb and quanta-gsj
In reply to Havard Skinnemoen viaThis allows these NPCM7xx-based boards to boot from a flash image, e.g. one built with OpenBMC. For example like this:
IMAGE=${OPENBMC}/build/tmp/deploy/images/gsj/image-bmc
qemu-system-arm -machine quanta-gsj -nographic \
-drive file=${IMAGE},if=mtd,bus=0,unit=0,format=raw,snapshot=on--- hw/arm/npcm7xx_boards.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
hw/arm/npcm7xx_boards.c +20 -0
@@ -20,6 +20,7 @@#include "hw/arm/npcm7xx.h" #include "hw/core/cpu.h" #include "hw/loader.h" +#include "hw/qdev-properties.h" #include "qapi/error.h" #include "qemu-common.h" #include "qemu/units.h"
@@ -55,6 +56,22 @@ static void npcm7xx_load_bootrom(MachineState *machine, NPCM7xxState *soc) } } +static void npcm7xx_connect_flash (NPCM7xxFIUState *fiu,int cs_no, +const char *flash_type,DriveInfo *dinfo) +{ +DeviceState *flash; +qemu_irq flash_cs; + + flash =qdev_new (flash_type); +if (dinfo) { +qdev_prop_set_drive (flash,"drive" ,blk_by_legacy_dinfo (dinfo)); + } +qdev_realize_and_unref (flash,BUS (fiu->spi), &error_fatal); + + flash_cs =qdev_get_gpio_in_named (flash,SSI_GPIO_CS ,0 ); +qdev_connect_gpio_out_named (DEVICE (fiu),"cs" , cs_no, flash_cs); +} +static void npcm7xx_connect_dram (NPCM7xxState *soc,MemoryRegion *dram) {memory_region_add_subregion (get_system_memory (),NPCM7XX_DRAM_BA , dram);
@@ -92,6 +109,7 @@ static void npcm750_evb_init(MachineState *machine)qdev_realize (DEVICE (soc),NULL , &error_fatal);npcm7xx_load_bootrom (machine, soc); +npcm7xx_connect_flash (&soc->fiu[0 ],0 ,"w25q256" ,drive_get (IF_MTD ,0 ,0 ));npcm7xx_load_kernel (machine, soc); }
@@ -104,6 +122,8 @@ static void quanta_gsj_init(MachineState *machine)qdev_realize (DEVICE (soc),NULL , &error_fatal);npcm7xx_load_bootrom (machine, soc); +npcm7xx_connect_flash (&soc->fiu[0 ],0 ,"mx25l25635e" , +drive_get (IF_MTD ,0 ,0 ));npcm7xx_load_kernel (machine, soc); }
Signature · 1 line
2.28.0.526.ge36021eeef-goog
Re: [PATCH v9 11/14] hw/arm: Wire up BMC boot flash for npcm750-evb and quanta-gsj
Quoted 52 lines · Havard Skinnemoen via
This allows these NPCM7xx-based boards to boot from a flash image, e.g. one built with OpenBMC. For example like this:
IMAGE=${OPENBMC}/build/tmp/deploy/images/gsj/image-bmc
qemu-system-arm -machine quanta-gsj -nographic \ -drive file=${IMAGE},if=mtd,bus=0,unit=0,format=raw,snapshot=onReviewed-by Tyrone Ting <[email protected]>Reviewed-by Cédric Le Goater <[email protected]>Tested-by Cédric Le Goater <[email protected]>Signed-off-by Havard Skinnemoen <[email protected]>--- hw/arm/npcm7xx_boards.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)hw/arm/npcm7xx_boards.c +17
-0@@ -20,6 +20,7 @@#include "hw/arm/npcm7xx.h" #include "hw/core/cpu.h" #include "hw/loader.h" +#include "hw/qdev-properties.h" #include "qapi/error.h" #include "qemu-common.h" #include "qemu/units.h" @@ -55,6 +56,22 @@ static void npcm7xx_load_bootrom(MachineState *machine, NPCM7xxState *soc) } } +static void npcm7xx_connect_flash (NPCM7xxFIUState *fiu,int cs_no, +const char *flash_type,DriveInfo *dinfo) +{ +DeviceState *flash; +qemu_irq flash_cs; + + flash =qdev_new (flash_type); +if (dinfo) { +qdev_prop_set_drive (flash,"drive" ,blk_by_legacy_dinfo (dinfo)); + } +qdev_realize_and_unref (flash,BUS (fiu->spi), &error_fatal); + + flash_cs =qdev_get_gpio_in_named (flash,SSI_GPIO_CS ,0 ); +qdev_connect_gpio_out_named (DEVICE (fiu),"cs" , cs_no, flash_cs); +} +static void npcm7xx_connect_dram (NPCM7xxState *soc,MemoryRegion *dram) {memory_region_add_subregion (get_system_memory (),NPCM7XX_DRAM_BA , dram);
hw/arm/npcm7xx_boards.c static void npcm750_evb_init(MachineState *machine) · line 112
Quoted 4 lines
hw/arm/npcm7xx_boards.c +1
-0@@ -92,6 +109,7 @@ static void npcm750_evb_init(MachineState *machine)qdev_realize (DEVICE (soc),NULL , &error_fatal);npcm7xx_load_bootrom (machine, soc); +npcm7xx_connect_flash (&soc->fiu[0 ],0 ,"w25q256" ,drive_get (IF_MTD ,0 ,0 ));
Nitpicking: add definition for '0' magic number
(consider as future cleanup).
hw/arm/npcm7xx_boards.c static void quanta_gsj_init(MachineState *machine) · line 126
Quoted 9 lines
hw/arm/npcm7xx_boards.c +2
-0npcm7xx_load_kernel (machine, soc); }@@ -104,6 +122,8 @@ static void quanta_gsj_init(MachineState *machine)qdev_realize (DEVICE (soc),NULL , &error_fatal);npcm7xx_load_bootrom (machine, soc); +npcm7xx_connect_flash (&soc->fiu[0 ],0 ,"mx25l25635e" , +drive_get (IF_MTD ,0 ,0 ));
Quoted 4 lines
hw/arm/npcm7xx_boards.c +0
-0npcm7xx_load_kernel (machine, soc); }
Re: [PATCH v9 11/14] hw/arm: Wire up BMC boot flash for npcm750-evb and quanta-gsj
Quoted 60 lines · Philippe Mathieu-Daudé
hw/arm/npcm7xx_boards.c static void npcm7xx_load_bootrom(MachineState
Quoted 29 lines · Havard Skinnemoen via
This allows these NPCM7xx-based boards to boot from a flash image, e.g. one built with OpenBMC. For example like this:
IMAGE=${OPENBMC}/build/tmp/deploy/images/gsj/image-bmc
qemu-system-arm -machine quanta-gsj -nographic \ -drive file=${IMAGE},if=mtd,bus=0,unit=0,format=raw,snapshot=onReviewed-by Tyrone Ting <[email protected]>Reviewed-by Cédric Le Goater <[email protected]>Tested-by Cédric Le Goater <[email protected]>Signed-off-by Havard Skinnemoen <[email protected]>--- hw/arm/npcm7xx_boards.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)hw/arm/npcm7xx_boards.c +1
-0@@ -20,6 +20,7 @@#include "hw/arm/npcm7xx.h" #include "hw/core/cpu.h" #include "hw/loader.h" +#include "hw/qdev-properties.h" #include "qapi/error.h" #include "qemu-common.h" #include "qemu/units.h" @@ -55,6 +56,22 @@ static void npcm7xx_load_bootrom(MachineState*machine, NPCM7xxState *soc)
hw/arm/npcm7xx_boards.c static void npcm7xx_load_bootrom(MachineState *machine, NPCM7xxState *soc)
Quoted 5 lines
hw/arm/npcm7xx_boards.c +2
-0} } +static void npcm7xx_connect_flash (NPCM7xxFIUState *fiu,int cs_no, + const char *flash_type, DriveInfo*dinfo)
Quoted 7 lines
hw/arm/npcm7xx_boards.c +7
-0+{ +DeviceState *flash; +qemu_irq flash_cs; + + flash =qdev_new (flash_type); +if (dinfo) { +qdev_prop_set_drive (flash,"drive" ,blk_by_legacy_dinfo (dinfo));hw/arm/npcm7xx_boards.c static void npcm7xx_load_bootrom(MachineState *machine, NPCM7xxState *soc)
Quoted 10 lines
hw/arm/npcm7xx_boards.c +7
-0+ } +qdev_realize_and_unref (flash,BUS (fiu->spi), &error_fatal); + + flash_cs =qdev_get_gpio_in_named (flash,SSI_GPIO_CS ,0 ); +qdev_connect_gpio_out_named (DEVICE (fiu),"cs" , cs_no, flash_cs); +} +static void npcm7xx_connect_dram (NPCM7xxState *soc,MemoryRegion *dram) { memory_region_add_subregion(get_system_memory(), NPCM7XX_DRAM_BA,dram);
Quoted 3 lines
hw/arm/npcm7xx_boards.c +0
-0@@ -92,6 +109,7 @@ static void npcm750_evb_init(MachineState *machine)qdev_realize (DEVICE (soc),NULL , &error_fatal);
Quoted 7 lines
hw/arm/npcm7xx_boards.c static void npcm750_evb_init(MachineState *machine) · line 112
Quoted 2 lines
hw/arm/npcm7xx_boards.c +1
-0npcm7xx_load_bootrom (machine, soc); + npcm7xx_connect_flash(&soc->fiu[0], 0, "w25q256", drive_get(IF_MTD,0, 0));
Nitpicking: add definition for '0' magic number
(consider as future cleanup).
Thanks. I've made the change, but won't send it out until this series is merged, or I'll fold it in if I need to do another iteration for other reasons.
Quoted 17 lines
npcm7xx_load_kernel(machine, soc);hw/arm/npcm7xx_boards.c static void quanta_gsj_init(MachineState *machine) · line 126
Quoted 8 lines
hw/arm/npcm7xx_boards.c +2
-0}@@ -104,6 +122,8 @@ static void quanta_gsj_init(MachineState *machine)qdev_realize (DEVICE (soc),NULL , &error_fatal);npcm7xx_load_bootrom (machine, soc); +npcm7xx_connect_flash (&soc->fiu[0 ],0 ,"mx25l25635e" , +drive_get (IF_MTD ,0 ,0 ));Reviewed-by Philippe Mathieu-Daudé <[email protected]>Quoted 4 lines
hw/arm/npcm7xx_boards.c +0
-0npcm7xx_load_kernel (machine, soc); }
PATCH v9 13/14 docs/system: Add Nuvoton machine documentation
In reply to Havard Skinnemoen via--- docs/system/arm/nuvoton.rst | 92 +++++++++++++++++++++++++++++++++++++ docs/system/target-arm.rst | 1 + 2 files changed, 93 insertions(+) create mode 100644 docs/system/arm/nuvoton.rst
docs/system/arm/nuvoton.rst new file +92 -0
@@ -0,0 +1,92 @@ +Nuvoton iBMC boards (``npcm750-evb``, ``quanta-gsj``) +===================================================== + +The `Nuvoton iBMC`_ chips (NPCM7xx) are a family of ARM-based SoCs that are +designed to be used as Baseboard Management Controllers (BMCs) in various +servers. They all feature one or two ARM Cortex A9 CPU cores, as well as an +assortment of peripherals targeted for either Enterprise or Data Center / +Hyperscale applications. The former is a superset of the latter, so NPCM750 has +all the peripherals of NPCM730 and more. + +.. _Nuvoton iBMC: https://www.nuvoton.com/products/cloud-computing/ibmc/ + +The NPCM750 SoC has two Cortex A9 cores and is targeted for the Enterprise +segment. The following machines are based on this chip : + +- ``npcm750-evb`` Nuvoton NPCM750 Evaluation board + +The NPCM730 SoC has two Cortex A9 cores and is targeted for Data Center and +Hyperscale applications. The following machines are based on this chip : + +- ``quanta-gsj`` Quanta GSJ server BMC + +There are also two more SoCs, NPCM710 and NPCM705, which are single-core +variants of NPCM750 and NPCM730, respectively. These are currently not +supported by QEMU. + +Supported devices +----------------- + + * SMP (Dual Core Cortex-A9) + * Cortex-A9MPCore built-in peripherals: SCU, GIC, Global Timer, Private Timer + and Watchdog. + * SRAM, ROM and DRAM mappings + * System Global Control Registers (GCR) + * Clock and reset controller (CLK) + * Timer controller (TIM) + * Serial ports (16550-based) + * DDR4 memory controller (dummy interface indicating memory training is done) + * OTP controllers (no protection features) + * Flash Interface Unit (FIU; no protection features) + +Missing devices +--------------- + + * GPIO controller + * LPC/eSPI host-to-BMC interface, including + + * Keyboard and mouse controller interface (KBCI) + * Keyboard Controller Style (KCS) channels + * BIOS POST code FIFO + * System Wake-up Control (SWC) + * Shared memory (SHM) + * eSPI slave interface + + * Ethernet controllers (GMAC and EMC) + * USB host (USBH) + * USB device (USBD) + * SMBus controller (SMBF) + * Peripheral SPI controller (PSPI) + * Analog to Digital Converter (ADC) + * SD/MMC host + * Random Number Generator (RNG) + * PECI interface + * Pulse Width Modulation (PWM) + * Tachometer + * PCI and PCIe root complex and bridges + * VDM and MCTP support + * Serial I/O expansion + * LPC/eSPI host + * Coprocessor + * Graphics + * Video capture + * Encoding compression engine + * Security features + +Boot options +------------ + +The Nuvoton machines can boot from an OpenBMC firmware image, or directly into +a kernel using the ``-kernel`` option. OpenBMC images for `quanta-gsj` and +possibly others can be downloaded from the OpenPOWER jenkins : + + https://openpower.xyz/ + +The firmware image should be attached as an MTD drive. Example : + +.. code-block:: bash + + $ qemu-system-arm -machine quanta-gsj -nographic \ + -drive file=image-bmc,if=mtd,bus=0,unit=0,format=raw + +The default root password for test images is usually ``0penBmc``.
docs/system/target-arm.rst +1 -0
@@ -86,6 +86,7 @@ undocumented; you can get a complete list by running arm/musicpal arm/gumstix arm/nseries + arm/nuvoton arm/orangepi arm/palm arm/xscale
Signature · 1 line
2.28.0.526.ge36021eeef-goog
PATCH v9 14/14 tests/acceptance: console boot tests for quanta-gsj
In reply to Havard Skinnemoen viaThis adds two acceptance tests for the quanta-gsj machine.
One test downloads a lightly patched openbmc flash image from github and verifies that it boots all the way to the login prompt.
The other test downloads a kernel, initrd and dtb built from the same openbmc source and verifies that the kernel detects all CPUs and boots to the point where it can't find the root filesystem (because we have no flash image in this case).
--- tests/acceptance/boot_linux_console.py | 83 ++++++++++++++++++++++++++ 1 file changed, 83 insertions(+)
tests/acceptance/boot_linux_console.py +83 -0
@@ -568,6 +568,89 @@ class BootLinuxConsole(LinuxKernelTest): 'sda') # cubieboard's reboot is not functioning; omit reboot test. + def test_arm_quanta_gsj(self): + """ + :avocado: tags=arch:arm + :avocado: tags=machine:quanta-gsj + """ + # 25 MiB compressed, 32 MiB uncompressed. + image_url = ( + 'https://github.com/hskinnemoen/openbmc/releases/download/' + '20200711-gsj-qemu-0/obmc-phosphor-image-gsj.static.mtd.gz') + image_hash = '14895e634923345cb5c8776037ff7876df96f6b1' + image_path_gz = self.fetch_asset(image_url, asset_hash=image_hash) + image_name = 'obmc.mtd' + image_path = os.path.join(self.workdir, image_name) + archive.gzip_uncompress(image_path_gz, image_path) + + self.vm.set_console() + drive_args = 'file=' + image_path + ',if=mtd,bus=0,unit=0' + self.vm.add_args('-drive', drive_args) + self.vm.launch() + + # Disable drivers and services that stall for a long time during boot, + # to avoid running past the 90-second timeout. These may be removed + # as the corresponding device support is added. + kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + ( + 'console=${console} ' + 'mem=${mem} ' + 'initcall_blacklist=npcm_i2c_bus_driver_init ' + 'systemd.mask=systemd-random-seed.service ' + 'systemd.mask=dropbearkey.service ' + ) + + self.wait_for_console_pattern('> BootBlock by Nuvoton') + self.wait_for_console_pattern('>Device: Poleg BMC NPCM730') + self.wait_for_console_pattern('>Skip DDR init.') + self.wait_for_console_pattern('U-Boot ') + interrupt_interactive_console_until_pattern( + self, 'Hit any key to stop autoboot:', 'U-Boot>') + exec_command_and_wait_for_pattern( + self, "setenv bootargs ${bootargs} " + kernel_command_line, + 'U-Boot>') + exec_command_and_wait_for_pattern( + self, 'run romboot', 'Booting Kernel from flash') + self.wait_for_console_pattern('Booting Linux on physical CPU 0x0') + self.wait_for_console_pattern('CPU1: thread -1, cpu 1, socket 0') + self.wait_for_console_pattern('OpenBMC Project Reference Distro') + self.wait_for_console_pattern('gsj login:') + + def test_arm_quanta_gsj_initrd(self): + """ + :avocado: tags=arch:arm + :avocado: tags=machine:quanta-gsj + """ + initrd_url = ( + 'https://github.com/hskinnemoen/openbmc/releases/download/' + '20200711-gsj-qemu-0/obmc-phosphor-initramfs-gsj.cpio.xz') + initrd_hash = '98fefe5d7e56727b1eb17d5c00311b1b5c945300' + initrd_path = self.fetch_asset(initrd_url, asset_hash=initrd_hash) + kernel_url = ( + 'https://github.com/hskinnemoen/openbmc/releases/download/' + '20200711-gsj-qemu-0/uImage-gsj.bin') + kernel_hash = 'fa67b2f141d56d39b3c54305c0e8a899c99eb2c7' + kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash) + dtb_url = ( + 'https://github.com/hskinnemoen/openbmc/releases/download/' + '20200711-gsj-qemu-0/nuvoton-npcm730-gsj.dtb') + dtb_hash = '18315f7006d7b688d8312d5c727eecd819aa36a4' + dtb_path = self.fetch_asset(dtb_url, asset_hash=dtb_hash) + + self.vm.set_console() + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + + 'console=ttyS0,115200n8 ' + 'earlycon=uart8250,mmio32,0xf0001000') + self.vm.add_args('-kernel', kernel_path, + '-initrd', initrd_path, + '-dtb', dtb_path, + '-append', kernel_command_line) + self.vm.launch() + + self.wait_for_console_pattern('Booting Linux on physical CPU 0x0') + self.wait_for_console_pattern('CPU1: thread -1, cpu 1, socket 0') + self.wait_for_console_pattern( + 'Give root password for system maintenance') + def test_arm_orangepi(self): """ :avocado: tags=arch:arm
Signature · 1 line
2.28.0.526.ge36021eeef-goog
Quoted 3 lines · Havard Skinnemoen via
This should be fully reviewed now, but the Timer patch may deserve another look, as I fixed a few bugs in it. Huge thanks to everyone who reviewed and/or tested this patchset, it has clearly improved a lot since I started.
Yes, all patches reviewed.
Very good quality. I also learned while reviewing your patches, so thanks for your contribution :)
Quoted 15 lines
I also pushed this and the previous patchsets to my qemu fork on github. The branches are named npcm7xx-v[1-9].
https://github.com/hskinnemoen/qemu
This patch series models enough of the Nuvoton NPCM730 and NPCM750 SoCs to boot an OpenBMC image built for quanta-gsj. This includes device models for:
- Global Configuration Registers
- Clock Control
- Timers
- Fuses
- Memory Controller
- Flash Controller
Peter Maydell
AppliedQuoted 5 lines · Havard Skinnemoen
This should be fully reviewed now, but the Timer patch may deserve another look, as I fixed a few bugs in it. Huge thanks to everyone who reviewed and/or tested this patchset, it has clearly improved a lot since I started.
Quoted 7 lines
I also pushed this and the previous patchsets to my qemu fork on github. The branches are named npcm7xx-v[1-9].
https://github.com/hskinnemoen/qemu
This patch series models enough of the Nuvoton NPCM730 and NPCM750 SoCs to boot an OpenBMC image built for quanta-gsj.
Applied to target-arm.next, thanks.
-- PMM