arm: Add NRF51 SOC non-volatile memory controller
RFC 1/1 arm: Add NRF51 SOC non-volatile memory controller
--- hw/nvram/Makefile.objs | 1 + hw/nvram/nrf51_nvmc.c | 165 ++++++++++++++++++++++++++++++++++ include/hw/nvram/nrf51_nvmc.h | 52 +++++++++++ 3 files changed, 218 insertions(+) create mode 100644 hw/nvram/nrf51_nvmc.c create mode 100644 include/hw/nvram/nrf51_nvmc.h
hw/nvram/Makefile.objs +1 -0
@@ -5,3 +5,4 @@ common-obj-y += fw_cfg.o common-obj-y += chrp_nvram.o common-obj-$(CONFIG_MAC_NVRAM) += mac_nvram.o obj-$(CONFIG_PSERIES) += spapr_nvram.o +obj-$(CONFIG_NRF51_SOC) += nrf51_nvmc.o
hw/nvram/nrf51_nvmc.c new file +165 -0
165 lines not on this page · raw message
include/hw/nvram/nrf51_nvmc.h new file +52 -0
52 lines not on this page · raw message
Signature · 1 line
2.17.1
On 26.06.2018 10:17, Steffen Görtz wrote:
[...]
hw/nvram/nrf51_nvmc.c line 94
Quoted 2 lines
hw/nvram/nrf51_nvmc.c new file +2
-0+static const MemoryRegionOps io_ops = { .read = io_read, .write = io_write, + .endianness =DEVICE_LITTLE_ENDIAN , };
Could you please put the entries on a separate line each? That would be better readable.
hw/nvram/nrf51_nvmc.c line 102
Quoted 7 lines
hw/nvram/nrf51_nvmc.c new file +7
-0+static void nrf51_nvmc_init (Object *obj) +{ +Nrf51NVMCState *s =NRF51_NVMC (obj); +SysBusDevice *sbd =SYS_BUS_DEVICE (obj); + +memory_region_init_io (&s->mmio, obj, &io_ops, s, +TYPE_NRF51_NVMC ,NRF51_NVMC_SIZE );
Please indent the second line of the memory_region_init_io statement.
Quoted 2 lines
(quoted diff) +2
-0+ sysbus_init_mmio(sbd, &s->mmio); +}
[...]
Quoted 26 lines
include/hw/nvram/nrf51_nvmc.h new file +20
-0@@ -0,0 +1,52 @@ +/* +* nrf51_nvmc.h +* +* Copyright 2018 Steffen Görtz <[email protected]> +* +* This code is licensed under the GPL version 2 or later. See +* the COPYING file in the top-level directory. +* +* See Nrf51 reference manual 6 Non-Volatile Memory Controller (NVMC) +* See Nrf51 product sheet 8.22 NVMC specifications +* +* QEMU interface: +* + sysbus MMIO regions 0: Memory Region with registers +* to be mapped to the peripherals instance address by the SOC. +* + page_size property to set the page size in bytes. +* + code_size property to set the code size in number of pages. +* +* Accuracy of the peripheral model: +* + The NVMC is always ready, all requested erase operations succeed +* immediately.
include/hw/nvram/nrf51_nvmc.h line 30
Quoted 10 lines
include/hw/nvram/nrf51_nvmc.h new file +10
-0+* + CONFIG.WEN and CONFIG.EEN flags can be written and read back +* but are not evaluated to check whether a requested write/erase operation +* is legal. +* + Code regions (MPU configuration) are disregarded. +*/ +#ifndef NRF51_NVMC_H +#define NRF51_NVMC_H + +#include "hw/sysbus.h" +#include "qemu/timer.h"
Any reason for including timer.h here? If not, please drop that line.
Quoted 12 lines
include/hw/nvram/nrf51_nvmc.h new file +12
-0+#define TYPE_NRF51_NVMC "nrf51_soc.nvmc" +#define NRF51_NVMC (obj) OBJECT_CHECK(Nrf51NVMCState, (obj), TYPE_NRF51_NVMC) + +typedef struct Nrf51NVMCState { + SysBusDevice parent_obj; + + MemoryRegion mmio; + + uint32_t code_size; + uint16_t page_size; + uint8_t *empty_page; + MemoryRegion *mr;
include/hw/nvram/nrf51_nvmc.h line 52
Quoted 10 lines
include/hw/nvram/nrf51_nvmc.h new file +10
-0+AddressSpace as; + +struct { +uint32_t config:2 ; + } state; + +} Nrf51NVMCState; + + +#endif
Thomas
Hi Thomas,
Quoted 7 lines · Thomas Huth
On 26.06.2018 10:17, Steffen Görtz wrote:
[...]hw/nvram/nrf51_nvmc.c line 94
Quoted 2 lines
hw/nvram/nrf51_nvmc.c new file +2
-0+static const MemoryRegionOps io_ops = { .read = io_read, .write = io_write, + .endianness =DEVICE_LITTLE_ENDIAN , };Could you please put the entries on a separate line each? That would be better readable.
done
Quoted 9 lines
hw/nvram/nrf51_nvmc.c line 102
Quoted 8 lines
hw/nvram/nrf51_nvmc.c new file +7
-0+static void nrf51_nvmc_init (Object *obj) +{ +Nrf51NVMCState *s =NRF51_NVMC (obj); +SysBusDevice *sbd =SYS_BUS_DEVICE (obj); + +memory_region_init_io (&s->mmio, obj, &io_ops, s, +TYPE_NRF51_NVMC ,NRF51_NVMC_SIZE );Please indent the second line of the
memory_region_init_iostatement.
done
Quoted 7 lines
include/hw/nvram/nrf51_nvmc.h line 30
Quoted 5 lines
include/hw/nvram/nrf51_nvmc.h new file +3
-0+sysbus_init_mmio (sbd, &s->mmio); +#include "hw/sysbus.h" +#include "qemu/timer.h" Any reason for including
timer.hhere? If not, please drop that line.
No it was a left over, removed.
Best regards,
Steffen