docs: convert README, CODING_STYLE and HACKING to RST syntax
[qemu/ar7.git] / include / hw / nvram / nrf51_nvm.h
blob3792e4a9fec9ee09ae5b9e6c8b1efad666d1591a
1 /*
2 * Nordic Semiconductor nRF51 non-volatile memory
4 * It provides an interface to erase regions in flash memory.
5 * Furthermore it provides the user and factory information registers.
7 * QEMU interface:
8 * + sysbus MMIO regions 0: NVMC peripheral registers
9 * + sysbus MMIO regions 1: FICR peripheral registers
10 * + sysbus MMIO regions 2: UICR peripheral registers
11 * + flash-size property: flash size in bytes.
13 * Accuracy of the peripheral model:
14 * + Code regions (MPU configuration) are disregarded.
16 * Copyright 2018 Steffen Görtz <contrib@steffen-goertz.de>
18 * This code is licensed under the GPL version 2 or later. See
19 * the COPYING file in the top-level directory.
22 #ifndef NRF51_NVM_H
23 #define NRF51_NVM_H
25 #include "hw/sysbus.h"
26 #define TYPE_NRF51_NVM "nrf51_soc.nvm"
27 #define NRF51_NVM(obj) OBJECT_CHECK(NRF51NVMState, (obj), TYPE_NRF51_NVM)
29 #define NRF51_UICR_FIXTURE_SIZE 64
31 #define NRF51_NVMC_SIZE 0x1000
33 #define NRF51_NVMC_READY 0x400
34 #define NRF51_NVMC_READY_READY 0x01
35 #define NRF51_NVMC_CONFIG 0x504
36 #define NRF51_NVMC_CONFIG_MASK 0x03
37 #define NRF51_NVMC_CONFIG_WEN 0x01
38 #define NRF51_NVMC_CONFIG_EEN 0x02
39 #define NRF51_NVMC_ERASEPCR1 0x508
40 #define NRF51_NVMC_ERASEPCR0 0x510
41 #define NRF51_NVMC_ERASEALL 0x50C
42 #define NRF51_NVMC_ERASEUICR 0x514
43 #define NRF51_NVMC_ERASE 0x01
45 #define NRF51_UICR_SIZE 0x100
47 typedef struct NRF51NVMState {
48 SysBusDevice parent_obj;
50 MemoryRegion mmio;
51 MemoryRegion ficr;
52 MemoryRegion uicr;
53 MemoryRegion flash;
55 uint32_t uicr_content[NRF51_UICR_FIXTURE_SIZE];
56 uint32_t flash_size;
57 uint8_t *storage;
59 uint32_t config;
61 } NRF51NVMState;
64 #endif