1 /* 2 * Nuvoton NPCM7xx SoC family. 3 * 4 * Copyright 2020 Google LLC 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License as published by the 8 * Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * for more details. 15 */ 16 #ifndef NPCM7XX_H 17 #define NPCM7XX_H 18 19 #include "hw/boards.h" 20 #include "hw/cpu/a9mpcore.h" 21 #include "hw/mem/npcm7xx_mc.h" 22 #include "hw/misc/npcm7xx_clk.h" 23 #include "hw/misc/npcm7xx_gcr.h" 24 #include "hw/misc/npcm7xx_rng.h" 25 #include "hw/nvram/npcm7xx_otp.h" 26 #include "hw/timer/npcm7xx_timer.h" 27 #include "hw/ssi/npcm7xx_fiu.h" 28 #include "hw/usb/hcd-ehci.h" 29 #include "hw/usb/hcd-ohci.h" 30 #include "target/arm/cpu.h" 31 32 #define NPCM7XX_MAX_NUM_CPUS (2) 33 34 /* The first half of the address space is reserved for DDR4 DRAM. */ 35 #define NPCM7XX_DRAM_BA (0x00000000) 36 #define NPCM7XX_DRAM_SZ (2 * GiB) 37 38 /* Magic addresses for setting up direct kernel booting and SMP boot stubs. */ 39 #define NPCM7XX_LOADER_START (0x00000000) /* Start of SDRAM */ 40 #define NPCM7XX_SMP_LOADER_START (0xffff0000) /* Boot ROM */ 41 #define NPCM7XX_SMP_BOOTREG_ADDR (0xf080013c) /* GCR.SCRPAD */ 42 #define NPCM7XX_GIC_CPU_IF_ADDR (0xf03fe100) /* GIC within A9 */ 43 #define NPCM7XX_BOARD_SETUP_ADDR (0xffff1000) /* Boot ROM */ 44 45 typedef struct NPCM7xxMachine { 46 MachineState parent; 47 } NPCM7xxMachine; 48 49 #define TYPE_NPCM7XX_MACHINE MACHINE_TYPE_NAME("npcm7xx") 50 #define NPCM7XX_MACHINE(obj) \ 51 OBJECT_CHECK(NPCM7xxMachine, (obj), TYPE_NPCM7XX_MACHINE) 52 53 typedef struct NPCM7xxMachineClass { 54 MachineClass parent; 55 56 const char *soc_type; 57 } NPCM7xxMachineClass; 58 59 #define NPCM7XX_MACHINE_CLASS(klass) \ 60 OBJECT_CLASS_CHECK(NPCM7xxMachineClass, (klass), TYPE_NPCM7XX_MACHINE) 61 #define NPCM7XX_MACHINE_GET_CLASS(obj) \ 62 OBJECT_GET_CLASS(NPCM7xxMachineClass, (obj), TYPE_NPCM7XX_MACHINE) 63 64 typedef struct NPCM7xxState { 65 DeviceState parent; 66 67 ARMCPU cpu[NPCM7XX_MAX_NUM_CPUS]; 68 A9MPPrivState a9mpcore; 69 70 MemoryRegion sram; 71 MemoryRegion irom; 72 MemoryRegion ram3; 73 MemoryRegion *dram; 74 75 NPCM7xxGCRState gcr; 76 NPCM7xxCLKState clk; 77 NPCM7xxTimerCtrlState tim[3]; 78 NPCM7xxOTPState key_storage; 79 NPCM7xxOTPState fuse_array; 80 NPCM7xxMCState mc; 81 NPCM7xxRNGState rng; 82 EHCISysBusState ehci; 83 OHCISysBusState ohci; 84 NPCM7xxFIUState fiu[2]; 85 } NPCM7xxState; 86 87 #define TYPE_NPCM7XX "npcm7xx" 88 #define NPCM7XX(obj) OBJECT_CHECK(NPCM7xxState, (obj), TYPE_NPCM7XX) 89 90 #define TYPE_NPCM730 "npcm730" 91 #define TYPE_NPCM750 "npcm750" 92 93 typedef struct NPCM7xxClass { 94 DeviceClass parent; 95 96 /* Bitmask of modules that are permanently disabled on this chip. */ 97 uint32_t disabled_modules; 98 /* Number of CPU cores enabled in this SoC class (may be 1 or 2). */ 99 uint32_t num_cpus; 100 } NPCM7xxClass; 101 102 #define NPCM7XX_CLASS(klass) \ 103 OBJECT_CLASS_CHECK(NPCM7xxClass, (klass), TYPE_NPCM7XX) 104 #define NPCM7XX_GET_CLASS(obj) \ 105 OBJECT_GET_CLASS(NPCM7xxClass, (obj), TYPE_NPCM7XX) 106 107 /** 108 * npcm7xx_load_kernel - Loads memory with everything needed to boot 109 * @machine - The machine containing the SoC to be booted. 110 * @soc - The SoC containing the CPU to be booted. 111 * 112 * This will set up the ARM boot info structure for the specific NPCM7xx 113 * derivative and call arm_load_kernel() to set up loading of the kernel, etc. 114 * into memory, if requested by the user. 115 */ 116 void npcm7xx_load_kernel(MachineState *machine, NPCM7xxState *soc); 117 118 #endif /* NPCM7XX_H */ 119