2 * Allwinner H3 System on Chip emulation
4 * Copyright (C) 2019 Niek Linnenbank <nieklinnenbank@gmail.com>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * The Allwinner H3 is a System on Chip containing four ARM Cortex-A7
22 * processor cores. Features and specifications include DDR2/DDR3 memory,
23 * SD/MMC storage cards, 10/100/1000Mbit Ethernet, USB 2.0, HDMI and
24 * various I/O modules.
26 * This implementation is based on the following datasheet:
28 * https://linux-sunxi.org/File:Allwinner_H3_Datasheet_V1.2.pdf
30 * The latest datasheet and more info can be found on the Linux Sunxi wiki:
32 * https://linux-sunxi.org/H3
35 #ifndef HW_ARM_ALLWINNER_H3_H
36 #define HW_ARM_ALLWINNER_H3_H
38 #include "qom/object.h"
39 #include "hw/timer/allwinner-a10-pit.h"
40 #include "hw/intc/arm_gic.h"
41 #include "hw/misc/allwinner-h3-ccu.h"
42 #include "hw/misc/allwinner-cpucfg.h"
43 #include "hw/misc/allwinner-h3-dramc.h"
44 #include "hw/misc/allwinner-h3-sysctrl.h"
45 #include "hw/misc/allwinner-sid.h"
46 #include "hw/sd/allwinner-sdhost.h"
47 #include "hw/net/allwinner-sun8i-emac.h"
48 #include "hw/rtc/allwinner-rtc.h"
49 #include "hw/i2c/allwinner-i2c.h"
50 #include "hw/watchdog/allwinner-wdt.h"
51 #include "target/arm/cpu.h"
52 #include "sysemu/block-backend.h"
55 * Allwinner H3 device list
57 * This enumeration is can be used refer to a particular device in the
58 * Allwinner H3 SoC. For example, the physical memory base address for
59 * each device can be found in the AwH3State object in the memmap member
60 * using the device enum value as index.
103 /** Total number of CPU cores in the H3 SoC */
104 #define AW_H3_NUM_CPUS (4)
107 * Allwinner H3 object model
111 /** Object type for the Allwinner H3 SoC */
112 #define TYPE_AW_H3 "allwinner-h3"
114 /** Convert input object to Allwinner H3 state object */
115 OBJECT_DECLARE_SIMPLE_TYPE(AwH3State
, AW_H3
)
120 * Allwinner H3 object
122 * This struct contains the state of all the devices
123 * which are currently emulated by the H3 SoC code.
127 DeviceState parent_obj
;
130 ARMCPU cpus
[AW_H3_NUM_CPUS
];
131 const hwaddr
*memmap
;
133 AwH3ClockCtlState ccu
;
134 AwCpuCfgState cpucfg
;
135 AwH3DramCtlState dramc
;
136 AwH3SysCtrlState sysctrl
;
143 AwSun8iEmacState emac
;
147 MemoryRegion sram_a1
;
148 MemoryRegion sram_a2
;
153 * Emulate Boot ROM firmware setup functionality.
155 * A real Allwinner H3 SoC contains a Boot ROM
156 * which is the first code that runs right after
157 * the SoC is powered on. The Boot ROM is responsible
158 * for loading user code (e.g. a bootloader) from any
159 * of the supported external devices and writing the
160 * downloaded code to internal SRAM. After loading the SoC
161 * begins executing the code written to SRAM.
163 * This function emulates the Boot ROM by copying 32 KiB
164 * of data from the given block device and writes it to
165 * the start of the first internal SRAM memory.
167 * @s: Allwinner H3 state object pointer
168 * @blk: Block backend device object pointer
170 void allwinner_h3_bootrom_setup(AwH3State
*s
, BlockBackend
*blk
);
172 #endif /* HW_ARM_ALLWINNER_H3_H */