1 /* 2 * ARM SSE (Subsystems for Embedded): IoTKit 3 * 4 * Copyright (c) 2018 Linaro Limited 5 * Written by Peter Maydell 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 or 9 * (at your option) any later version. 10 */ 11 12 /* 13 * This is a model of the Arm "Subsystems for Embedded" family of 14 * hardware, which include the IoT Kit and the SSE-050, SSE-100 and 15 * SSE-200. Currently we model only the Arm IoT Kit which is documented in 16 * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ecm0601256/index.html 17 * It contains: 18 * a Cortex-M33 19 * the IDAU 20 * some timers and watchdogs 21 * two peripheral protection controllers 22 * a memory protection controller 23 * a security controller 24 * a bus fabric which arranges that some parts of the address 25 * space are secure and non-secure aliases of each other 26 * 27 * QEMU interface: 28 * + QOM property "memory" is a MemoryRegion containing the devices provided 29 * by the board model. 30 * + QOM property "MAINCLK" is the frequency of the main system clock 31 * + QOM property "EXP_NUMIRQ" sets the number of expansion interrupts 32 * + Named GPIO inputs "EXP_IRQ" 0..n are the expansion interrupts, which 33 * are wired to the NVIC lines 32 .. n+32 34 * + sysbus MMIO region 0 is the "AHB Slave Expansion" which allows 35 * bus master devices in the board model to make transactions into 36 * all the devices and memory areas in the IoTKit 37 * Controlling up to 4 AHB expansion PPBs which a system using the IoTKit 38 * might provide: 39 * + named GPIO outputs apb_ppcexp{0,1,2,3}_nonsec[0..15] 40 * + named GPIO outputs apb_ppcexp{0,1,2,3}_ap[0..15] 41 * + named GPIO outputs apb_ppcexp{0,1,2,3}_irq_enable 42 * + named GPIO outputs apb_ppcexp{0,1,2,3}_irq_clear 43 * + named GPIO inputs apb_ppcexp{0,1,2,3}_irq_status 44 * Controlling each of the 4 expansion AHB PPCs which a system using the IoTKit 45 * might provide: 46 * + named GPIO outputs ahb_ppcexp{0,1,2,3}_nonsec[0..15] 47 * + named GPIO outputs ahb_ppcexp{0,1,2,3}_ap[0..15] 48 * + named GPIO outputs ahb_ppcexp{0,1,2,3}_irq_enable 49 * + named GPIO outputs ahb_ppcexp{0,1,2,3}_irq_clear 50 * + named GPIO inputs ahb_ppcexp{0,1,2,3}_irq_status 51 * Controlling each of the 16 expansion MPCs which a system using the IoTKit 52 * might provide: 53 * + named GPIO inputs mpcexp_status[0..15] 54 * Controlling each of the 16 expansion MSCs which a system using the IoTKit 55 * might provide: 56 * + named GPIO inputs mscexp_status[0..15] 57 * + named GPIO outputs mscexp_clear[0..15] 58 * + named GPIO outputs mscexp_ns[0..15] 59 */ 60 61 #ifndef ARMSSE_H 62 #define ARMSSE_H 63 64 #include "hw/sysbus.h" 65 #include "hw/arm/armv7m.h" 66 #include "hw/misc/iotkit-secctl.h" 67 #include "hw/misc/tz-ppc.h" 68 #include "hw/misc/tz-mpc.h" 69 #include "hw/timer/cmsdk-apb-timer.h" 70 #include "hw/timer/cmsdk-apb-dualtimer.h" 71 #include "hw/watchdog/cmsdk-apb-watchdog.h" 72 #include "hw/misc/iotkit-sysctl.h" 73 #include "hw/misc/iotkit-sysinfo.h" 74 #include "hw/or-irq.h" 75 #include "hw/core/split-irq.h" 76 77 #define TYPE_ARMSSE "arm-sse" 78 #define ARMSSE(obj) OBJECT_CHECK(ARMSSE, (obj), TYPE_ARMSSE) 79 80 /* 81 * These type names are for specific IoTKit subsystems; other than 82 * instantiating them, code using these devices should always handle 83 * them via the ARMSSE base class, so they have no IOTKIT() etc macros. 84 */ 85 #define TYPE_IOTKIT "iotkit" 86 87 /* We have an IRQ splitter and an OR gate input for each external PPC 88 * and the 2 internal PPCs 89 */ 90 #define NUM_EXTERNAL_PPCS (IOTS_NUM_AHB_EXP_PPC + IOTS_NUM_APB_EXP_PPC) 91 #define NUM_PPCS (NUM_EXTERNAL_PPCS + 2) 92 93 typedef struct ARMSSE { 94 /*< private >*/ 95 SysBusDevice parent_obj; 96 97 /*< public >*/ 98 ARMv7MState armv7m; 99 IoTKitSecCtl secctl; 100 TZPPC apb_ppc0; 101 TZPPC apb_ppc1; 102 TZMPC mpc; 103 CMSDKAPBTIMER timer0; 104 CMSDKAPBTIMER timer1; 105 CMSDKAPBTIMER s32ktimer; 106 qemu_or_irq ppc_irq_orgate; 107 SplitIRQ sec_resp_splitter; 108 SplitIRQ ppc_irq_splitter[NUM_PPCS]; 109 SplitIRQ mpc_irq_splitter[IOTS_NUM_EXP_MPC + IOTS_NUM_MPC]; 110 qemu_or_irq mpc_irq_orgate; 111 qemu_or_irq nmi_orgate; 112 113 CMSDKAPBDualTimer dualtimer; 114 115 CMSDKAPBWatchdog s32kwatchdog; 116 CMSDKAPBWatchdog nswatchdog; 117 CMSDKAPBWatchdog swatchdog; 118 119 IoTKitSysCtl sysctl; 120 IoTKitSysCtl sysinfo; 121 122 MemoryRegion container; 123 MemoryRegion alias1; 124 MemoryRegion alias2; 125 MemoryRegion alias3; 126 MemoryRegion sram0; 127 128 qemu_irq *exp_irqs; 129 qemu_irq ppc0_irq; 130 qemu_irq ppc1_irq; 131 qemu_irq sec_resp_cfg; 132 qemu_irq sec_resp_cfg_in; 133 qemu_irq nsc_cfg_in; 134 135 qemu_irq irq_status_in[NUM_EXTERNAL_PPCS]; 136 qemu_irq mpcexp_status_in[IOTS_NUM_EXP_MPC]; 137 138 uint32_t nsccfg; 139 140 /* Properties */ 141 MemoryRegion *board_memory; 142 uint32_t exp_numirq; 143 uint32_t mainclk_frq; 144 } ARMSSE; 145 146 typedef struct ARMSSEInfo ARMSSEInfo; 147 148 typedef struct ARMSSEClass { 149 DeviceClass parent_class; 150 const ARMSSEInfo *info; 151 } ARMSSEClass; 152 153 #define ARMSSE_CLASS(klass) \ 154 OBJECT_CLASS_CHECK(ARMSSEClass, (klass), TYPE_ARMSSE) 155 #define ARMSSE_GET_CLASS(obj) \ 156 OBJECT_GET_CLASS(ARMSSEClass, (obj), TYPE_ARMSSE) 157 158 #endif 159