mirror of
https://github.com/qemu/qemu.git
synced 2024-11-24 19:33:39 +08:00
arm: Instantiate NRF51 special NVM's and NVMC
Instantiates UICR, FICR, FLASH and NVMC in nRF51 SOC. Signed-off-by: Steffen Görtz <contrib@steffen-goertz.de> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 20190201023357.22596-3-stefanha@redhat.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
c0d4eb8352
commit
4d744b25d3
@ -29,8 +29,10 @@
|
||||
* are supported in the future, add a sub-class of NRF51SoC for
|
||||
* the specific variants
|
||||
*/
|
||||
#define NRF51822_FLASH_SIZE (256 * NRF51_PAGE_SIZE)
|
||||
#define NRF51822_SRAM_SIZE (16 * NRF51_PAGE_SIZE)
|
||||
#define NRF51822_FLASH_PAGES 256
|
||||
#define NRF51822_SRAM_PAGES 16
|
||||
#define NRF51822_FLASH_SIZE (NRF51822_FLASH_PAGES * NRF51_PAGE_SIZE)
|
||||
#define NRF51822_SRAM_SIZE (NRF51822_SRAM_PAGES * NRF51_PAGE_SIZE)
|
||||
|
||||
#define BASE_TO_IRQ(base) ((base >> 12) & 0x1F)
|
||||
|
||||
@ -81,14 +83,6 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
|
||||
|
||||
memory_region_add_subregion_overlap(&s->container, 0, s->board_memory, -1);
|
||||
|
||||
memory_region_init_rom(&s->flash, OBJECT(s), "nrf51.flash", s->flash_size,
|
||||
&err);
|
||||
if (err) {
|
||||
error_propagate(errp, err);
|
||||
return;
|
||||
}
|
||||
memory_region_add_subregion(&s->container, NRF51_FLASH_BASE, &s->flash);
|
||||
|
||||
memory_region_init_ram(&s->sram, OBJECT(s), "nrf51.sram", s->sram_size,
|
||||
&err);
|
||||
if (err) {
|
||||
@ -122,6 +116,29 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
|
||||
qdev_get_gpio_in(DEVICE(&s->cpu),
|
||||
BASE_TO_IRQ(NRF51_RNG_BASE)));
|
||||
|
||||
/* UICR, FICR, NVMC, FLASH */
|
||||
object_property_set_uint(OBJECT(&s->nvm), s->flash_size, "flash-size",
|
||||
&err);
|
||||
if (err) {
|
||||
error_propagate(errp, err);
|
||||
return;
|
||||
}
|
||||
|
||||
object_property_set_bool(OBJECT(&s->nvm), true, "realized", &err);
|
||||
if (err) {
|
||||
error_propagate(errp, err);
|
||||
return;
|
||||
}
|
||||
|
||||
mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->nvm), 0);
|
||||
memory_region_add_subregion_overlap(&s->container, NRF51_NVMC_BASE, mr, 0);
|
||||
mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->nvm), 1);
|
||||
memory_region_add_subregion_overlap(&s->container, NRF51_FICR_BASE, mr, 0);
|
||||
mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->nvm), 2);
|
||||
memory_region_add_subregion_overlap(&s->container, NRF51_UICR_BASE, mr, 0);
|
||||
mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->nvm), 3);
|
||||
memory_region_add_subregion_overlap(&s->container, NRF51_FLASH_BASE, mr, 0);
|
||||
|
||||
/* GPIO */
|
||||
object_property_set_bool(OBJECT(&s->gpio), true, "realized", &err);
|
||||
if (err) {
|
||||
@ -159,8 +176,6 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
|
||||
|
||||
create_unimplemented_device("nrf51_soc.io", NRF51_IOMEM_BASE,
|
||||
NRF51_IOMEM_SIZE);
|
||||
create_unimplemented_device("nrf51_soc.ficr", NRF51_FICR_BASE,
|
||||
NRF51_FICR_SIZE);
|
||||
create_unimplemented_device("nrf51_soc.private",
|
||||
NRF51_PRIVATE_BASE, NRF51_PRIVATE_SIZE);
|
||||
}
|
||||
@ -187,6 +202,8 @@ static void nrf51_soc_init(Object *obj)
|
||||
sysbus_init_child_obj(obj, "rng", &s->rng, sizeof(s->rng),
|
||||
TYPE_NRF51_RNG);
|
||||
|
||||
sysbus_init_child_obj(obj, "nvm", &s->nvm, sizeof(s->nvm), TYPE_NRF51_NVM);
|
||||
|
||||
sysbus_init_child_obj(obj, "gpio", &s->gpio, sizeof(s->gpio),
|
||||
TYPE_NRF51_GPIO);
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "hw/char/nrf51_uart.h"
|
||||
#include "hw/misc/nrf51_rng.h"
|
||||
#include "hw/gpio/nrf51_gpio.h"
|
||||
#include "hw/nvram/nrf51_nvm.h"
|
||||
#include "hw/timer/nrf51_timer.h"
|
||||
|
||||
#define TYPE_NRF51_SOC "nrf51-soc"
|
||||
@ -32,6 +33,7 @@ typedef struct NRF51State {
|
||||
|
||||
NRF51UARTState uart;
|
||||
NRF51RNGState rng;
|
||||
NRF51NVMState nvm;
|
||||
NRF51GPIOState gpio;
|
||||
NRF51TimerState timer[NRF51_NUM_TIMERS];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user