hw/nvram: hw/arm: Introduce Xilinx eFUSE and BBRAM
Subsystems (2)
cover hw/nvram: hw/arm: Introduce Xilinx eFUSE and BBRAM
This series implements the Xilinx eFUSE and BBRAM devices for the Versal and ZynqMP product families.
Furthermore, both new devices are connected to the xlnx-versal-virt board and the xlnx-zcu102 board.
See changes in docs/system/arm/xlnx-versal-virt.rst for detail.
Tong Ho (9):
docs/system/arm: xlnx-versal-virt: BBRAM and eFUSE Usage hw/nvram: Introduce Xilinx eFuse QOM
hw/nvram: Introduce Xilinx Versal eFuse device hw/nvram: Introduce Xilinx ZynqMP eFuse device hw/nvram: Introduce Xilinx battery-backed ram hw/arm: xlnx-versal: Add Xilinx BBRAM device hw/arm: xlnx-versal: Add Xilinx eFUSE device hw/arm: xlnx-zynqmp: Add Xilinx BBRAM device hw/arm: xlnx-zynqmp: Add Xilinx eFUSE device
docs/system/arm/xlnx-versal-virt.rst | 49 ++ hw/arm/xlnx-versal-virt.c | 57 ++ hw/arm/xlnx-versal.c | 57 ++ hw/arm/xlnx-zynqmp.c | 50 ++ hw/nvram/Kconfig | 17 + hw/nvram/meson.build | 11 + hw/nvram/xlnx-bbram.c | 536 +++++++++++++++++ hw/nvram/xlnx-efuse-crc.c | 118 ++++ hw/nvram/xlnx-efuse.c | 253 ++++++++ hw/nvram/xlnx-versal-efuse-cache.c | 141 +++++ hw/nvram/xlnx-versal-efuse-ctrl.c | 786 ++++++++++++++++++++++++ hw/nvram/xlnx-zynqmp-efuse.c | 861 +++++++++++++++++++++++++++ include/hw/arm/xlnx-versal.h | 17 + include/hw/arm/xlnx-zynqmp.h | 5 + include/hw/nvram/xlnx-bbram.h | 55 ++ include/hw/nvram/xlnx-efuse.h | 80 +++ include/hw/nvram/xlnx-versal-efuse.h | 62 ++ include/hw/nvram/xlnx-zynqmp-efuse.h | 45 ++ 18 files changed, 3200 insertions(+) create mode 100644 hw/nvram/xlnx-bbram.c create mode 100644 hw/nvram/xlnx-efuse-crc.c create mode 100644 hw/nvram/xlnx-efuse.c create mode 100644 hw/nvram/xlnx-versal-efuse-cache.c create mode 100644 hw/nvram/xlnx-versal-efuse-ctrl.c create mode 100644 hw/nvram/xlnx-zynqmp-efuse.c create mode 100644 include/hw/nvram/xlnx-bbram.h create mode 100644 include/hw/nvram/xlnx-efuse.h create mode 100644 include/hw/nvram/xlnx-versal-efuse.h create mode 100644 include/hw/nvram/xlnx-zynqmp-efuse.h
Signature · 1 line
2.25.1
PATCH 1/9 docs/system/arm: xlnx-versal-virt: BBRAM and eFUSE Usage
Add BBRAM and eFUSE usage to the Xilinx Versal Virt board document.
--- docs/system/arm/xlnx-versal-virt.rst | 49 ++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
docs/system/arm/xlnx-versal-virt.rst +49 -0
@@ -32,6 +32,8 @@ Implemented devices: - OCM (256KB of On Chip Memory) - XRAM (4MB of on chip Accelerator RAM) - DDR memory +- BBRAM (36 bytes of Battery-backed RAM) +- eFUSE (3072 bytes of one-time field-programmable bit array) QEMU does not yet model any other devices, including the PL and the AI Engine.
@@ -175,3 +177,50 @@ Run the following at the U-Boot prompt: fdt set /chosen/dom0 reg <0x00000000 0x40000000 0x0 0x03100000> booti 30000000 - 20000000 +BBRAM File Backend +"""""""""""""""""" +BBRAM can have an optional file backend, which must a seekable +binary file with a size of 36 bytes or larger. A file with all +binary 0s is a 'blank'. + +To add a file-backend for the BBRAM: + +.. code-block:: bash + + -drive if=pflash,index=0,file=versal-bbram.bin,format=raw + +To use a different index value, N, from default of 0, add: + +.. code-block:: bash + + -global xlnx,bbram-ctrl.drive-index=N + +eFUSE File Backend +"""""""""""""""""" +eFUSE can have an optional file backend, which must a seekable +binary file with a size of 3072 bytes or larger. A file with all +binary 0s is a 'blank'. + +To add a file-backend for the eFUSE: + +.. code-block:: bash + + -drive if=pflash,index=1,file=versal-efuse.bin,format=raw + +To use a different index value, N, from default of 1, add: + +.. code-block:: bash + + -global xlnx,efuse.drive-index=N + +.. warning:: + In actual physical Versal, BBRAM and eFUSE contain sensitive data. + The QEMU device models do **not** encrypt nor obfuscate any data + when holding them in models' memory or when writing them to their + file backends. + + Thus, a file backend should be used with caution, and 'format=luks' + is highly recommended (albeit with usage complexity). + + Better yet, do not use actual product data when running guest image + on this Xilinx Versal Virt board. |
Signature · 1 line
2.25.1
PATCH 2/9 hw/nvram: Introduce Xilinx eFuse QOM
In reply to Tong HoThis introduces the QOM for Xilinx eFuse, an one-time field-programmable storage bit array.
The actual mmio interface to the array varies by device families and will be provided in different change-sets.
--- hw/nvram/xlnx-efuse-crc.c | 118 ++++++++++++++++ hw/nvram/xlnx-efuse.c | 253 ++++++++++++++++++++++++++++++++++ include/hw/nvram/xlnx-efuse.h | 80 +++++++++++ 3 files changed, 451 insertions(+) create mode 100644 hw/nvram/xlnx-efuse-crc.c create mode 100644 hw/nvram/xlnx-efuse.c create mode 100644 include/hw/nvram/xlnx-efuse.h
hw/nvram/xlnx-efuse-crc.c new file +118 -0
@@ -0,0 +1,118 @@ +/* +* Xilinx eFuse/bbram CRC calculator +* +* Copyright (c) 2021 Xilinx Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +* THE SOFTWARE. +*/ +#include "hw/nvram/xlnx-efuse.h" + +static uint32_t xlnx_efuse_u37_crc (uint32_t prev_crc,uint32_t data, +uint32_t addr) +{ +/* A table for 7-bit slicing */ +static const uint32_t crc_tab[128 ] = { +0x00000000 ,0xe13b70f7 ,0xc79a971f ,0x26a1e7e8 , +0x8ad958cf ,0x6be22838 ,0x4d43cfd0 ,0xac78bf27 , +0x105ec76f ,0xf165b798 ,0xd7c45070 ,0x36ff2087 , +0x9a879fa0 ,0x7bbcef57 ,0x5d1d08bf ,0xbc267848 , +0x20bd8ede ,0xc186fe29 ,0xe72719c1 ,0x061c6936 , +0xaa64d611 ,0x4b5fa6e6 ,0x6dfe410e ,0x8cc531f9 , +0x30e349b1 ,0xd1d83946 ,0xf779deae ,0x1642ae59 , +0xba3a117e ,0x5b016189 ,0x7da08661 ,0x9c9bf696 , +0x417b1dbc ,0xa0406d4b ,0x86e18aa3 ,0x67dafa54 , +0xcba24573 ,0x2a993584 ,0x0c38d26c ,0xed03a29b , +0x5125dad3 ,0xb01eaa24 ,0x96bf4dcc ,0x77843d3b , +0xdbfc821c ,0x3ac7f2eb ,0x1c661503 ,0xfd5d65f4 , +0x61c69362 ,0x80fde395 ,0xa65c047d ,0x4767748a , +0xeb1fcbad ,0x0a24bb5a ,0x2c855cb2 ,0xcdbe2c45 , +0x7198540d ,0x90a324fa ,0xb602c312 ,0x5739b3e5 , +0xfb410cc2 ,0x1a7a7c35 ,0x3cdb9bdd ,0xdde0eb2a , +0x82f63b78 ,0x63cd4b8f ,0x456cac67 ,0xa457dc90 , +0x082f63b7 ,0xe9141340 ,0xcfb5f4a8 ,0x2e8e845f , +0x92a8fc17 ,0x73938ce0 ,0x55326b08 ,0xb4091bff , +0x1871a4d8 ,0xf94ad42f ,0xdfeb33c7 ,0x3ed04330 , +0xa24bb5a6 ,0x4370c551 ,0x65d122b9 ,0x84ea524e , +0x2892ed69 ,0xc9a99d9e ,0xef087a76 ,0x0e330a81 , +0xb21572c9 ,0x532e023e ,0x758fe5d6 ,0x94b49521 , +0x38cc2a06 ,0xd9f75af1 ,0xff56bd19 ,0x1e6dcdee , +0xc38d26c4 ,0x22b65633 ,0x0417b1db ,0xe52cc12c , +0x49547e0b ,0xa86f0efc ,0x8ecee914 ,0x6ff599e3 , +0xd3d3e1ab ,0x32e8915c ,0x144976b4 ,0xf5720643 , +0x590ab964 ,0xb831c993 ,0x9e902e7b ,0x7fab5e8c , +0xe330a81a ,0x020bd8ed ,0x24aa3f05 ,0xc5914ff2 , +0x69e9f0d5 ,0x88d28022 ,0xae7367ca ,0x4f48173d , +0xf36e6f75 ,0x12551f82 ,0x34f4f86a ,0xd5cf889d , +0x79b737ba ,0x988c474d ,0xbe2da0a5 ,0x5f16d052 + }; + +/* +* eFuse calculation is shown here: +* https://github.com/Xilinx/embeddedsw/blob/release-2019.2/lib/sw_services/xilskey/src/xilskey_utils.c#L1496 +* +* Each u32 word is appended a 5-bit value, for a total of 37 bits; see: +* https://github.com/Xilinx/embeddedsw/blob/release-2019.2/lib/sw_services/xilskey/src/xilskey_utils.c#L1356 +*/ +uint32_t crc = prev_crc; +const unsigned rshf =7 ; +const uint32_t im = (1 << rshf) -1 ; +const uint32_t rm = (1 << (32 - rshf)) -1 ; +const uint32_t i2 = (1 <<2 ) -1 ; +const uint32_t r2 = (1 <<30 ) -1 ; + +unsigned j; +uint32_t i, r; +uint64_t w; + + w = (uint64_t )(addr) <<32 ; + w |= data; + +/* Feed 35 bits, in 5 rounds, each a slice of 7 bits */ +for (j =0 ; j <5 ; j++) { + r = rm & (crc >> rshf); + i = im & (crc ^ w); + crc = crc_tab[i] ^ r; + + w >>= rshf; + } + +/* Feed the remaining 2 bits */ + r = r2 & (crc >>2 ); + i = i2 & (crc ^ w); + crc = crc_tab[i << (rshf -2 )] ^ r; + +return crc; +} + +uint32_t xlnx_efuse_calc_crc (const uint32_t *data,unsigned u32_cnt, +unsigned zpads) +{ +uint32_t crc =0 ; +unsigned index; + +for (index = zpads; index; index--) { + crc =xlnx_efuse_u37_crc (crc,0 , (index + u32_cnt)); + } + +for (index = u32_cnt; index; index--) { + crc =xlnx_efuse_u37_crc (crc, data[index -1 ], index); + } + +return crc; +}
hw/nvram/xlnx-efuse.c new file +253 -0
253 lines not on this page · raw message
include/hw/nvram/xlnx-efuse.h new file +80 -0
80 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 3/9 hw/nvram: Introduce Xilinx Versal eFuse device
In reply to Tong HoThis implements the Xilinx Versal eFuse, an one-time field-programmable non-volatile storage device. There is only one such device in the Xilinx Versal product family.
The command argument:
-drive if=pflash,index=N,...
Can be used to optionally connect the storage array to a backend storage, such that field-programmed values in one invocation can be made available to next invocation.
The backend storage must be a seekable binary file, and its size must be 3072 bytes or larger. A file with all binary 0's is a 'blank'.
The drive 'index' value N has a default value of 1, but can be changed using command argument:
-global xlnx,efuse.drive-index=N
This device has two separate mmio interfaces, a controller and a flatten readback.
The controller provides interfaces for field-programming, configuration, control, and status.
The flatten readback is a cache to provide a byte-accessible read-only interface to efficiently read efuse array.
--- hw/nvram/Kconfig | 8 + hw/nvram/meson.build | 8 + hw/nvram/xlnx-versal-efuse-cache.c | 141 +++++ hw/nvram/xlnx-versal-efuse-ctrl.c | 786 +++++++++++++++++++++++++++ include/hw/nvram/xlnx-versal-efuse.h | 62 +++ 5 files changed, 1005 insertions(+) create mode 100644 hw/nvram/xlnx-versal-efuse-cache.c create mode 100644 hw/nvram/xlnx-versal-efuse-ctrl.c create mode 100644 include/hw/nvram/xlnx-versal-efuse.h
hw/nvram/Kconfig +8 -0
@@ -15,3 +15,11 @@ config NMC93XX_EEPROM config CHRP_NVRAM bool + +config XLNX_EFUSE + bool + +config XLNX_EFUSE_VERSAL + bool + default y if XLNX_VERSAL + select XLNX_EFUSE
hw/nvram/meson.build +8 -0
@@ -9,5 +9,13 @@ 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')) +softmmu_ss.add(when: 'CONFIG_XLNX_EFUSE', if_true: files('xlnx-efuse.c')) +softmmu_ss.add(when: 'CONFIG_XLNX_EFUSE_VERSAL', if_true: files( + 'xlnx-versal-efuse-cache.c', + 'xlnx-versal-efuse-ctrl.c')) +if 'CONFIG_XLNX_BBRAM' in config_all or \ + 'CONFIG_XLNX_EFUSE' in config_all + softmmu_ss.add(files('xlnx-efuse-crc.c')) +endif specific_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr_nvram.c'))
hw/nvram/xlnx-versal-efuse-cache.c new file +141 -0
141 lines not on this page · raw message
hw/nvram/xlnx-versal-efuse-ctrl.c new file +786 -0
786 lines not on this page · raw message
include/hw/nvram/xlnx-versal-efuse.h new file +62 -0
62 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 4/9 hw/nvram: Introduce Xilinx ZynqMP eFuse device
In reply to Tong HoThis implements the Xilinx ZynqMP eFuse, an one-time field-programmable non-volatile storage device. There is only one such device in the Xilinx ZynqMP product family.
The command argument:
-drive if=pflash,index=N,...
Can be used to optionally connect the storage array to a backend storage, such that field-programmed values in one invocation can be made available to next invocation.
The backend storage must be a seekable binary file, and its size must be 768 bytes or larger. A file with all binary 0's is a 'blank'.
The drive 'index' value N has a default value of 3, but can be changed using command argument:
-global xlnx,efuse.drive-index=N
--- hw/nvram/Kconfig | 5 + hw/nvram/meson.build | 2 + hw/nvram/xlnx-zynqmp-efuse.c | 861 +++++++++++++++++++++++++++ include/hw/nvram/xlnx-zynqmp-efuse.h | 45 ++ 4 files changed, 913 insertions(+) create mode 100644 hw/nvram/xlnx-zynqmp-efuse.c create mode 100644 include/hw/nvram/xlnx-zynqmp-efuse.h
hw/nvram/Kconfig +5 -0
@@ -23,3 +23,8 @@ config XLNX_EFUSE_VERSAL bool default y if XLNX_VERSAL select XLNX_EFUSE + +config XLNX_EFUSE_ZYNQMP + bool + default y if XLNX_ZYNQMP + select XLNX_EFUSE
hw/nvram/meson.build +2 -0
@@ -13,6 +13,8 @@ softmmu_ss.add(when: 'CONFIG_XLNX_EFUSE', if_true: files('xlnx-efuse.c')) softmmu_ss.add(when: 'CONFIG_XLNX_EFUSE_VERSAL', if_true: files( 'xlnx-versal-efuse-cache.c', 'xlnx-versal-efuse-ctrl.c')) +softmmu_ss.add(when: 'CONFIG_XLNX_EFUSE_ZYNQMP', if_true: files( + 'xlnx-zynqmp-efuse.c')) if 'CONFIG_XLNX_BBRAM' in config_all or \ 'CONFIG_XLNX_EFUSE' in config_all softmmu_ss.add(files('xlnx-efuse-crc.c'))
hw/nvram/xlnx-zynqmp-efuse.c new file +861 -0
861 lines not on this page · raw message
include/hw/nvram/xlnx-zynqmp-efuse.h new file +45 -0
45 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 5/9 hw/nvram: Introduce Xilinx battery-backed ram
In reply to Tong HoThis device is present in Versal and ZynqMP product families to store a 256-bit encryption key.
--- hw/nvram/Kconfig | 4 + hw/nvram/meson.build | 1 + hw/nvram/xlnx-bbram.c | 536 ++++++++++++++++++++++++++++++++++ include/hw/nvram/xlnx-bbram.h | 55 ++++ 4 files changed, 596 insertions(+) create mode 100644 hw/nvram/xlnx-bbram.c create mode 100644 include/hw/nvram/xlnx-bbram.h
hw/nvram/Kconfig +4 -0
@@ -28,3 +28,7 @@ config XLNX_EFUSE_ZYNQMP bool default y if XLNX_ZYNQMP select XLNX_EFUSE + +config XLNX_BBRAM + bool + default y if (XLNX_VERSAL || XLNX_ZYNQMP)
hw/nvram/meson.build +1 -0
@@ -9,6 +9,7 @@ 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')) +softmmu_ss.add(when: 'CONFIG_XLNX_BBRAM', if_true: files('xlnx-bbram.c', 'xlnx-efuse-crc.c')) softmmu_ss.add(when: 'CONFIG_XLNX_EFUSE', if_true: files('xlnx-efuse.c')) softmmu_ss.add(when: 'CONFIG_XLNX_EFUSE_VERSAL', if_true: files( 'xlnx-versal-efuse-cache.c',
hw/nvram/xlnx-bbram.c new file +536 -0
536 lines not on this page · raw message
include/hw/nvram/xlnx-bbram.h new file +55 -0
55 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 6/9 hw/arm: xlnx-versal: Add Xilinx BBRAM device
In reply to Tong HoConnect the support for Versal Battery-Backed RAM (BBRAM)
--- hw/arm/xlnx-versal-virt.c | 21 +++++++++++++++++++++ hw/arm/xlnx-versal.c | 18 ++++++++++++++++++ include/hw/arm/xlnx-versal.h | 5 +++++ 3 files changed, 44 insertions(+)
hw/arm/xlnx-versal-virt.c +21 -0
@@ -356,6 +356,26 @@ static void fdt_add_rtc_node(VersalVirt *s)g_free (name); } +static void fdt_add_bbram_node (VersalVirt *s) +{ +const char compat[] =TYPE_XLNX_BBRAM ; +const char interrupt_names[] ="bbram-error" ; +char *name =g_strdup_printf ("/bbram@%x" ,MM_PMC_BBRAM_CTRL ); + +qemu_fdt_add_subnode (s->fdt, name); + +qemu_fdt_setprop_cells (s->fdt, name,"interrupts" , +GIC_FDT_IRQ_TYPE_SPI ,VERSAL_BBRAM_APB_IRQ_0 , +GIC_FDT_IRQ_FLAGS_LEVEL_HI ); +qemu_fdt_setprop (s->fdt, name,"interrupt-names" , + interrupt_names,sizeof (interrupt_names)); +qemu_fdt_setprop_sized_cells (s->fdt, name,"reg" , +2 ,MM_PMC_BBRAM_CTRL , +2 ,MM_PMC_BBRAM_CTRL_SIZE ); +qemu_fdt_setprop (s->fdt, name,"compatible" , compat,sizeof (compat)); +g_free (name); +} +static void fdt_nop_memory_nodes (void *fdt,Error **errp) {Error *err =NULL ;
@@ -570,6 +590,7 @@ static void versal_virt_init(MachineState *machine)fdt_add_usb_xhci_nodes (s);fdt_add_sd_nodes (s);fdt_add_rtc_node (s); +fdt_add_bbram_node (s);fdt_add_cpu_nodes (s, psci_conduit);fdt_add_clk_node (s,"/clk125" ,125000000 , s->phandle.clk_125Mhz);fdt_add_clk_node (s,"/clk25" ,25000000 , s->phandle.clk_25Mhz);
hw/arm/xlnx-versal.c +18 -0
@@ -312,6 +312,23 @@ static void versal_create_xrams(Versal *s, qemu_irq *pic) } } +static void versal_create_bbram (Versal *s,qemu_irq *pic) +{ +SysBusDevice *sbd; + +object_initialize_child_with_props (OBJECT (s),"bbram" , &s->pmc.bbram, +sizeof (s->pmc.bbram),TYPE_XLNX_BBRAM , + &error_fatal, +"crc-zpads" ,"0" , +NULL ); + sbd =SYS_BUS_DEVICE (&s->pmc.bbram); + +sysbus_realize (sbd, &error_fatal); +memory_region_add_subregion (&s->mr_ps,MM_PMC_BBRAM_CTRL , +sysbus_mmio_get_region (sbd,0 )); +sysbus_connect_irq (sbd,0 , pic[VERSAL_BBRAM_APB_IRQ_0 ]); +} +/* This takes the board allocated linear DDR memory and creates aliases * for each split DDR range/aperture on the Versal address map. */
@@ -398,6 +415,7 @@ static void versal_realize(DeviceState *dev, Error **errp)versal_create_sds (s, pic);versal_create_rtc (s, pic);versal_create_xrams (s, pic); +versal_create_bbram (s, pic);versal_map_ddr (s);versal_unimp (s);
include/hw/arm/xlnx-versal.h +5 -0
@@ -24,6 +24,7 @@#include "qom/object.h" #include "hw/usb/xlnx-usb-subsystem.h" #include "hw/misc/xlnx-versal-xramc.h" +#include "hw/nvram/xlnx-bbram.h" #define TYPE_XLNX_VERSAL "xlnx-versal"OBJECT_DECLARE_SIMPLE_TYPE (Versal,XLNX_VERSAL )
@@ -79,6 +80,7 @@ struct Versal { } iou;XlnxZynqMPRTC rtc; +XlnxBBRam bbram; } pmc;struct {
@@ -105,6 +107,7 @@ struct Versal {#define VERSAL_GEM1_WAKE_IRQ_0 59#define VERSAL_ADMA_IRQ_0 60#define VERSAL_XRAM_IRQ_0 79 +#define VERSAL_BBRAM_APB_IRQ_0 121#define VERSAL_RTC_APB_ERR_IRQ 121#define VERSAL_SD0_IRQ_0 126#define VERSAL_RTC_ALARM_IRQ 142
@@ -170,6 +173,8 @@ struct Versal {#define MM_PMC_SD0 0xf1040000U#define MM_PMC_SD0_SIZE 0x10000 +#define MM_PMC_BBRAM_CTRL 0xf11f0000 +#define MM_PMC_BBRAM_CTRL_SIZE 0x00050#define MM_PMC_CRP 0xf1260000U#define MM_PMC_CRP_SIZE 0x10000#define MM_PMC_RTC 0xf12a0000
Signature · 1 line
2.25.1
PATCH 7/9 hw/arm: xlnx-versal: Add Xilinx eFUSE device
In reply to Tong HoConnect the support for Versal eFUSE one-time field-programmable bit array.
--- hw/arm/xlnx-versal-virt.c | 36 +++++++++++++++++++++++++++++++++ hw/arm/xlnx-versal.c | 39 ++++++++++++++++++++++++++++++++++++ include/hw/arm/xlnx-versal.h | 12 +++++++++++ 3 files changed, 87 insertions(+)
hw/arm/xlnx-versal-virt.c +36 -0
@@ -376,6 +376,40 @@ static void fdt_add_bbram_node(VersalVirt *s)g_free (name); } +static void fdt_add_efuse_ctrl_node (VersalVirt *s) +{ +const char compat[] =TYPE_XLNX_VERSAL_EFUSE_CTRL ; +const char interrupt_names[] ="pmc_efuse" ; +char *name =g_strdup_printf ("/pmc_efuse@%x" ,MM_PMC_EFUSE_CTRL ); + +qemu_fdt_add_subnode (s->fdt, name); + +qemu_fdt_setprop_cells (s->fdt, name,"interrupts" , +GIC_FDT_IRQ_TYPE_SPI ,VERSAL_EFUSE_IRQ , +GIC_FDT_IRQ_FLAGS_LEVEL_HI ); +qemu_fdt_setprop (s->fdt, name,"interrupt-names" , + interrupt_names,sizeof (interrupt_names)); +qemu_fdt_setprop_sized_cells (s->fdt, name,"reg" , +2 ,MM_PMC_EFUSE_CTRL , +2 ,MM_PMC_EFUSE_CTRL_SIZE ); +qemu_fdt_setprop (s->fdt, name,"compatible" , compat,sizeof (compat)); +g_free (name); +} + +static void fdt_add_efuse_cache_node (VersalVirt *s) +{ +const char compat[] =TYPE_XLNX_VERSAL_EFUSE_CACHE ; +char *name =g_strdup_printf ("/xlnx_pmc_efuse_cache@%x" ,MM_PMC_EFUSE_CACHE ); + +qemu_fdt_add_subnode (s->fdt, name); + +qemu_fdt_setprop_sized_cells (s->fdt, name,"reg" , +2 ,MM_PMC_EFUSE_CACHE , +2 ,MM_PMC_EFUSE_CACHE_SIZE ); +qemu_fdt_setprop (s->fdt, name,"compatible" , compat,sizeof (compat)); +g_free (name); +} +static void fdt_nop_memory_nodes (void *fdt,Error **errp) {Error *err =NULL ;
@@ -591,6 +625,8 @@ static void versal_virt_init(MachineState *machine)fdt_add_sd_nodes (s);fdt_add_rtc_node (s);fdt_add_bbram_node (s); +fdt_add_efuse_ctrl_node (s); +fdt_add_efuse_cache_node (s);fdt_add_cpu_nodes (s, psci_conduit);fdt_add_clk_node (s,"/clk125" ,125000000 , s->phandle.clk_125Mhz);fdt_add_clk_node (s,"/clk25" ,25000000 , s->phandle.clk_25Mhz);
hw/arm/xlnx-versal.c +39 -0
@@ -329,6 +329,44 @@ static void versal_create_bbram(Versal *s, qemu_irq *pic)sysbus_connect_irq (sbd,0 , pic[VERSAL_BBRAM_APB_IRQ_0 ]); } +static void versal_realize_efuse_part (Versal *s,Object *dev,hwaddr base) +{ +SysBusDevice *part =SYS_BUS_DEVICE (dev); + +object_property_set_link (OBJECT (part),"efuse" , +OBJECT (&s->pmc.efuse.bits), &error_abort); + +sysbus_realize (part, &error_abort); +memory_region_add_subregion (&s->mr_ps, base, +sysbus_mmio_get_region (part,0 )); +} + +static void versal_create_efuse (Versal *s,qemu_irq *pic) +{ +Object *bits =OBJECT (&s->pmc.efuse.bits); +Object *ctrl =OBJECT (&s->pmc.efuse.ctrl); +Object *cache =OBJECT (&s->pmc.efuse.cache); + +object_initialize_child (OBJECT (s),"efuse-ctrl" , &s->pmc.efuse.ctrl, +TYPE_XLNX_VERSAL_EFUSE_CTRL ); + +object_initialize_child (OBJECT (s),"efuse-cache" , &s->pmc.efuse.cache, +TYPE_XLNX_VERSAL_EFUSE_CACHE ); + +object_initialize_child_with_props (ctrl,"efuse-bits" , bits, +sizeof (s->pmc.efuse.bits), +TYPE_XLNX_EFUSE , &error_abort, +"efuse-nr" ,"3" , +"efuse-size" ,"8192" , +NULL ); + +qdev_realize (DEVICE (bits),NULL , &error_abort); +versal_realize_efuse_part (s, ctrl,MM_PMC_EFUSE_CTRL ); +versal_realize_efuse_part (s, cache,MM_PMC_EFUSE_CACHE ); + +sysbus_connect_irq (SYS_BUS_DEVICE (ctrl),0 , pic[VERSAL_EFUSE_IRQ ]); +} +/* This takes the board allocated linear DDR memory and creates aliases * for each split DDR range/aperture on the Versal address map. */
@@ -416,6 +454,7 @@ static void versal_realize(DeviceState *dev, Error **errp)versal_create_rtc (s, pic);versal_create_xrams (s, pic);versal_create_bbram (s, pic); +versal_create_efuse (s, pic);versal_map_ddr (s);versal_unimp (s);
include/hw/arm/xlnx-versal.h +12 -0
@@ -25,6 +25,7 @@#include "hw/usb/xlnx-usb-subsystem.h" #include "hw/misc/xlnx-versal-xramc.h" #include "hw/nvram/xlnx-bbram.h" +#include "hw/nvram/xlnx-versal-efuse.h" #define TYPE_XLNX_VERSAL "xlnx-versal"OBJECT_DECLARE_SIMPLE_TYPE (Versal,XLNX_VERSAL )
@@ -81,6 +82,11 @@ struct Versal {XlnxZynqMPRTC rtc;XlnxBBRam bbram; +struct { +XlnxVersalEFuseCtrl ctrl; +XlnxVersalEFuseCache cache; +XLNXEFuse bits; + } efuse; } pmc;struct {
@@ -110,6 +116,7 @@ struct Versal {#define VERSAL_BBRAM_APB_IRQ_0 121#define VERSAL_RTC_APB_ERR_IRQ 121#define VERSAL_SD0_IRQ_0 126 +#define VERSAL_EFUSE_IRQ 139#define VERSAL_RTC_ALARM_IRQ 142#define VERSAL_RTC_SECONDS_IRQ 143
@@ -175,6 +182,11 @@ struct Versal {#define MM_PMC_SD0_SIZE 0x10000#define MM_PMC_BBRAM_CTRL 0xf11f0000#define MM_PMC_BBRAM_CTRL_SIZE 0x00050 +#define MM_PMC_EFUSE_CTRL 0xf1240000 +#define MM_PMC_EFUSE_CTRL_SIZE 0x00104 +#define MM_PMC_EFUSE_CACHE 0xf1250000 +#define MM_PMC_EFUSE_CACHE_SIZE 0x00C00 +#define MM_PMC_CRP 0xf1260000U#define MM_PMC_CRP_SIZE 0x10000#define MM_PMC_RTC 0xf12a0000
Signature · 1 line
2.25.1
PATCH 8/9 hw/arm: xlnx-zynqmp: Add Xilinx BBRAM device
In reply to Tong HoConnect the support for Xilinx ZynqMP Battery-Backed RAM (BBRAM)
--- hw/arm/xlnx-zynqmp.c | 21 +++++++++++++++++++++ include/hw/arm/xlnx-zynqmp.h | 2 ++ 2 files changed, 23 insertions(+)
hw/arm/xlnx-zynqmp.c +21 -0
@@ -62,6 +62,9 @@#define RTC_ADDR 0xffa60000#define RTC_IRQ 26 +#define BBRAM_ADDR 0xffcd0000 +#define BBRAM_IRQ 11 +#define SDHCI_CAPABILITIES 0x280737ec6481/* Datasheet: UG1085 (v1.7) */ static const uint64_t gem_addr[XLNX_ZYNQMP_NUM_GEMS ] = {
@@ -222,6 +225,22 @@ static void xlnx_zynqmp_create_rpu(MachineState *ms, XlnxZynqMPState *s,qdev_realize (DEVICE (&s->rpu_cluster),NULL , &error_fatal); } +static void xlnx_zynqmp_create_bbram (XlnxZynqMPState *s,qemu_irq *gic) +{ +SysBusDevice *sbd; + +object_initialize_child_with_props (OBJECT (s),"bbram" , &s->bbram, +sizeof (s->bbram),TYPE_XLNX_BBRAM , + &error_fatal, +"crc-zpads" ,"1" , +NULL ); + sbd =SYS_BUS_DEVICE (&s->bbram); + +sysbus_realize (sbd, &error_fatal); +sysbus_mmio_map (sbd,0 ,BBRAM_ADDR ); +sysbus_connect_irq (sbd,0 , gic[BBRAM_IRQ ]); +} +static void xlnx_zynqmp_init (Object *obj) {MachineState *ms =MACHINE (qdev_get_machine ());
@@ -616,6 +635,8 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)sysbus_mmio_map (SYS_BUS_DEVICE (&s->rtc),0 ,RTC_ADDR );sysbus_connect_irq (SYS_BUS_DEVICE (&s->rtc),0 , gic_spi[RTC_IRQ ]); +xlnx_zynqmp_create_bbram (s, gic_spi); +for (i =0 ; i <XLNX_ZYNQMP_NUM_GDMA_CH ; i++) {if (!object_property_set_uint (OBJECT (&s->gdma[i]),"bus-width" ,128 , errp)) {
include/hw/arm/xlnx-zynqmp.h +2 -0
@@ -36,6 +36,7 @@#include "qom/object.h" #include "net/can_emu.h" #include "hw/dma/xlnx_csu_dma.h" +#include "hw/nvram/xlnx-bbram.h" #define TYPE_XLNX_ZYNQMP "xlnx-zynqmp"OBJECT_DECLARE_SIMPLE_TYPE (XlnxZynqMPState,XLNX_ZYNQMP )
@@ -95,6 +96,7 @@ struct XlnxZynqMPState {MemoryRegion *ddr_ram;MemoryRegion ddr_ram_low, ddr_ram_high; +XlnxBBRam bbram;CadenceGEMState gem[XLNX_ZYNQMP_NUM_GEMS ];CadenceUARTState uart[XLNX_ZYNQMP_NUM_UARTS ];
Signature · 1 line
2.25.1
PATCH 9/9 hw/arm: xlnx-zynqmp: Add Xilinx eFUSE device
In reply to Tong HoConnect the support for ZynqMP eFUSE one-time field-programmable bit array.
--- hw/arm/xlnx-zynqmp.c | 29 +++++++++++++++++++++++++++++ include/hw/arm/xlnx-zynqmp.h | 3 +++ 2 files changed, 32 insertions(+)
hw/arm/xlnx-zynqmp.c +29 -0
@@ -65,6 +65,9 @@#define BBRAM_ADDR 0xffcd0000#define BBRAM_IRQ 11 +#define EFUSE_ADDR 0xffcc0000 +#define EFUSE_IRQ 87 +#define SDHCI_CAPABILITIES 0x280737ec6481/* Datasheet: UG1085 (v1.7) */ static const uint64_t gem_addr[XLNX_ZYNQMP_NUM_GEMS ] = {
@@ -241,6 +244,31 @@ static void xlnx_zynqmp_create_bbram(XlnxZynqMPState *s, qemu_irq *gic)sysbus_connect_irq (sbd,0 , gic[BBRAM_IRQ ]); } +static void xlnx_zynqmp_create_efuse (XlnxZynqMPState *s,qemu_irq *gic) +{ +Object *bits =OBJECT (&s->efuse_bits); +Object *ctrl =OBJECT (&s->efuse); +SysBusDevice *sbd; + +object_initialize_child (OBJECT (s),"efuse" , &s->efuse, +TYPE_XLNX_ZYNQMP_EFUSE ); + +object_initialize_child_with_props (ctrl,"efuse-bits" , bits, +sizeof (s->efuse_bits), +TYPE_XLNX_EFUSE , &error_abort, +"efuse-nr" ,"3" , +"efuse-size" ,"2048" , +NULL ); + +qdev_realize (DEVICE (bits),NULL , &error_abort); +object_property_set_link (ctrl,"efuse" , bits, &error_abort); + + sbd =SYS_BUS_DEVICE (ctrl); +sysbus_realize (sbd, &error_abort); +sysbus_mmio_map (sbd,0 ,EFUSE_ADDR ); +sysbus_connect_irq (sbd,0 , gic[EFUSE_IRQ ]); +} +static void xlnx_zynqmp_init (Object *obj) {MachineState *ms =MACHINE (qdev_get_machine ());
@@ -636,6 +664,7 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->rtc),0 , gic_spi[RTC_IRQ ]);xlnx_zynqmp_create_bbram (s, gic_spi); +xlnx_zynqmp_create_efuse (s, gic_spi); for (i = 0; i < XLNX_ZYNQMP_NUM_GDMA_CH; i++) { if (!object_property_set_uint(OBJECT(&s->gdma[i]), "bus-width", 128,
include/hw/arm/xlnx-zynqmp.h +3 -0
@@ -37,6 +37,7 @@#include "net/can_emu.h" #include "hw/dma/xlnx_csu_dma.h" #include "hw/nvram/xlnx-bbram.h" +#include "hw/nvram/xlnx-zynqmp-efuse.h" #define TYPE_XLNX_ZYNQMP "xlnx-zynqmp"OBJECT_DECLARE_SIMPLE_TYPE (XlnxZynqMPState,XLNX_ZYNQMP )
@@ -97,6 +98,8 @@ struct XlnxZynqMPState {MemoryRegion *ddr_ram;MemoryRegion ddr_ram_low, ddr_ram_high;XlnxBBRam bbram; +XlnxZynqMPEFuse efuse; +XLNXEFuse efuse_bits;CadenceGEMState gem[XLNX_ZYNQMP_NUM_GEMS ];CadenceUARTState uart[XLNX_ZYNQMP_NUM_UARTS ];
Signature · 1 line
2.25.1
Quoted 5 lines · Tong Ho
This series implements the Xilinx eFUSE and BBRAM devices for the Versal and ZynqMP product families.
Furthermore, both new devices are connected to the xlnx-versal-virt board and the xlnx-zcu102 board.
Hi Tong,
A few general comments.
Patch #1 should probably be moved to be the last patch of the series.
I think we should remove the commands about register generation "Partially generated by xregqemu.py". It may be confusing to others since it's not a tool we run in the build process but rather a one off extraction of reg definitions...
Thanks!
Edgar