12d8f048cSHavard Skinnemoen /* 22d8f048cSHavard Skinnemoen * Nuvoton NPCM7xx SoC family. 32d8f048cSHavard Skinnemoen * 42d8f048cSHavard Skinnemoen * Copyright 2020 Google LLC 52d8f048cSHavard Skinnemoen * 62d8f048cSHavard Skinnemoen * This program is free software; you can redistribute it and/or modify it 72d8f048cSHavard Skinnemoen * under the terms of the GNU General Public License as published by the 82d8f048cSHavard Skinnemoen * Free Software Foundation; either version 2 of the License, or 92d8f048cSHavard Skinnemoen * (at your option) any later version. 102d8f048cSHavard Skinnemoen * 112d8f048cSHavard Skinnemoen * This program is distributed in the hope that it will be useful, but WITHOUT 122d8f048cSHavard Skinnemoen * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 132d8f048cSHavard Skinnemoen * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 142d8f048cSHavard Skinnemoen * for more details. 152d8f048cSHavard Skinnemoen */ 162d8f048cSHavard Skinnemoen #ifndef NPCM7XX_H 172d8f048cSHavard Skinnemoen #define NPCM7XX_H 182d8f048cSHavard Skinnemoen 192d8f048cSHavard Skinnemoen #include "hw/boards.h" 202d8f048cSHavard Skinnemoen #include "hw/cpu/a9mpcore.h" 21*1351f892SHavard Skinnemoen #include "hw/mem/npcm7xx_mc.h" 222d8f048cSHavard Skinnemoen #include "hw/misc/npcm7xx_clk.h" 232d8f048cSHavard Skinnemoen #include "hw/misc/npcm7xx_gcr.h" 24c752bb07SHavard Skinnemoen #include "hw/nvram/npcm7xx_otp.h" 252d8f048cSHavard Skinnemoen #include "hw/timer/npcm7xx_timer.h" 262d8f048cSHavard Skinnemoen #include "target/arm/cpu.h" 272d8f048cSHavard Skinnemoen 282d8f048cSHavard Skinnemoen #define NPCM7XX_MAX_NUM_CPUS (2) 292d8f048cSHavard Skinnemoen 302d8f048cSHavard Skinnemoen /* The first half of the address space is reserved for DDR4 DRAM. */ 312d8f048cSHavard Skinnemoen #define NPCM7XX_DRAM_BA (0x00000000) 322d8f048cSHavard Skinnemoen #define NPCM7XX_DRAM_SZ (2 * GiB) 332d8f048cSHavard Skinnemoen 342d8f048cSHavard Skinnemoen /* Magic addresses for setting up direct kernel booting and SMP boot stubs. */ 352d8f048cSHavard Skinnemoen #define NPCM7XX_LOADER_START (0x00000000) /* Start of SDRAM */ 362d8f048cSHavard Skinnemoen #define NPCM7XX_SMP_LOADER_START (0xffff0000) /* Boot ROM */ 372d8f048cSHavard Skinnemoen #define NPCM7XX_SMP_BOOTREG_ADDR (0xf080013c) /* GCR.SCRPAD */ 382d8f048cSHavard Skinnemoen #define NPCM7XX_GIC_CPU_IF_ADDR (0xf03fe100) /* GIC within A9 */ 392d8f048cSHavard Skinnemoen 40b773acf4SHavard Skinnemoen typedef struct NPCM7xxMachine { 41b773acf4SHavard Skinnemoen MachineState parent; 42b773acf4SHavard Skinnemoen } NPCM7xxMachine; 43b773acf4SHavard Skinnemoen 44b773acf4SHavard Skinnemoen #define TYPE_NPCM7XX_MACHINE MACHINE_TYPE_NAME("npcm7xx") 45b773acf4SHavard Skinnemoen #define NPCM7XX_MACHINE(obj) \ 46b773acf4SHavard Skinnemoen OBJECT_CHECK(NPCM7xxMachine, (obj), TYPE_NPCM7XX_MACHINE) 47b773acf4SHavard Skinnemoen 48b773acf4SHavard Skinnemoen typedef struct NPCM7xxMachineClass { 49b773acf4SHavard Skinnemoen MachineClass parent; 50b773acf4SHavard Skinnemoen 51b773acf4SHavard Skinnemoen const char *soc_type; 52b773acf4SHavard Skinnemoen } NPCM7xxMachineClass; 53b773acf4SHavard Skinnemoen 54b773acf4SHavard Skinnemoen #define NPCM7XX_MACHINE_CLASS(klass) \ 55b773acf4SHavard Skinnemoen OBJECT_CLASS_CHECK(NPCM7xxMachineClass, (klass), TYPE_NPCM7XX_MACHINE) 56b773acf4SHavard Skinnemoen #define NPCM7XX_MACHINE_GET_CLASS(obj) \ 57b773acf4SHavard Skinnemoen OBJECT_GET_CLASS(NPCM7xxMachineClass, (obj), TYPE_NPCM7XX_MACHINE) 58b773acf4SHavard Skinnemoen 592d8f048cSHavard Skinnemoen typedef struct NPCM7xxState { 602d8f048cSHavard Skinnemoen DeviceState parent; 612d8f048cSHavard Skinnemoen 622d8f048cSHavard Skinnemoen ARMCPU cpu[NPCM7XX_MAX_NUM_CPUS]; 632d8f048cSHavard Skinnemoen A9MPPrivState a9mpcore; 642d8f048cSHavard Skinnemoen 652d8f048cSHavard Skinnemoen MemoryRegion sram; 662d8f048cSHavard Skinnemoen MemoryRegion irom; 672d8f048cSHavard Skinnemoen MemoryRegion ram3; 682d8f048cSHavard Skinnemoen MemoryRegion *dram; 692d8f048cSHavard Skinnemoen 702d8f048cSHavard Skinnemoen NPCM7xxGCRState gcr; 712d8f048cSHavard Skinnemoen NPCM7xxCLKState clk; 722d8f048cSHavard Skinnemoen NPCM7xxTimerCtrlState tim[3]; 73c752bb07SHavard Skinnemoen NPCM7xxOTPState key_storage; 74c752bb07SHavard Skinnemoen NPCM7xxOTPState fuse_array; 75*1351f892SHavard Skinnemoen NPCM7xxMCState mc; 762d8f048cSHavard Skinnemoen } NPCM7xxState; 772d8f048cSHavard Skinnemoen 782d8f048cSHavard Skinnemoen #define TYPE_NPCM7XX "npcm7xx" 792d8f048cSHavard Skinnemoen #define NPCM7XX(obj) OBJECT_CHECK(NPCM7xxState, (obj), TYPE_NPCM7XX) 802d8f048cSHavard Skinnemoen 812d8f048cSHavard Skinnemoen #define TYPE_NPCM730 "npcm730" 822d8f048cSHavard Skinnemoen #define TYPE_NPCM750 "npcm750" 832d8f048cSHavard Skinnemoen 842d8f048cSHavard Skinnemoen typedef struct NPCM7xxClass { 852d8f048cSHavard Skinnemoen DeviceClass parent; 862d8f048cSHavard Skinnemoen 872d8f048cSHavard Skinnemoen /* Bitmask of modules that are permanently disabled on this chip. */ 882d8f048cSHavard Skinnemoen uint32_t disabled_modules; 892d8f048cSHavard Skinnemoen /* Number of CPU cores enabled in this SoC class (may be 1 or 2). */ 902d8f048cSHavard Skinnemoen uint32_t num_cpus; 912d8f048cSHavard Skinnemoen } NPCM7xxClass; 922d8f048cSHavard Skinnemoen 932d8f048cSHavard Skinnemoen #define NPCM7XX_CLASS(klass) \ 942d8f048cSHavard Skinnemoen OBJECT_CLASS_CHECK(NPCM7xxClass, (klass), TYPE_NPCM7XX) 952d8f048cSHavard Skinnemoen #define NPCM7XX_GET_CLASS(obj) \ 962d8f048cSHavard Skinnemoen OBJECT_GET_CLASS(NPCM7xxClass, (obj), TYPE_NPCM7XX) 972d8f048cSHavard Skinnemoen 982d8f048cSHavard Skinnemoen /** 992d8f048cSHavard Skinnemoen * npcm7xx_load_kernel - Loads memory with everything needed to boot 1002d8f048cSHavard Skinnemoen * @machine - The machine containing the SoC to be booted. 1012d8f048cSHavard Skinnemoen * @soc - The SoC containing the CPU to be booted. 1022d8f048cSHavard Skinnemoen * 1032d8f048cSHavard Skinnemoen * This will set up the ARM boot info structure for the specific NPCM7xx 1042d8f048cSHavard Skinnemoen * derivative and call arm_load_kernel() to set up loading of the kernel, etc. 1052d8f048cSHavard Skinnemoen * into memory, if requested by the user. 1062d8f048cSHavard Skinnemoen */ 1072d8f048cSHavard Skinnemoen void npcm7xx_load_kernel(MachineState *machine, NPCM7xxState *soc); 1082d8f048cSHavard Skinnemoen 1092d8f048cSHavard Skinnemoen #endif /* NPCM7XX_H */ 110