1ae0c4d1aSHao Wu /* 2ae0c4d1aSHao Wu * Nuvoton NPCM8xx SoC family. 3ae0c4d1aSHao Wu * 4ae0c4d1aSHao Wu * Copyright 2022 Google LLC 5ae0c4d1aSHao Wu * 6ae0c4d1aSHao Wu * This program is free software; you can redistribute it and/or modify it 7ae0c4d1aSHao Wu * under the terms of the GNU General Public License as published by the 8ae0c4d1aSHao Wu * Free Software Foundation; either version 2 of the License, or 9ae0c4d1aSHao Wu * (at your option) any later version. 10ae0c4d1aSHao Wu * 11ae0c4d1aSHao Wu * This program is distributed in the hope that it will be useful, but WITHOUT 12ae0c4d1aSHao Wu * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13ae0c4d1aSHao Wu * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14ae0c4d1aSHao Wu * for more details. 15ae0c4d1aSHao Wu */ 16ae0c4d1aSHao Wu #ifndef NPCM8XX_H 17ae0c4d1aSHao Wu #define NPCM8XX_H 18ae0c4d1aSHao Wu 19ae0c4d1aSHao Wu #include "hw/adc/npcm7xx_adc.h" 20ae0c4d1aSHao Wu #include "hw/core/split-irq.h" 21ae0c4d1aSHao Wu #include "hw/cpu/cluster.h" 22ae0c4d1aSHao Wu #include "hw/gpio/npcm7xx_gpio.h" 23ae0c4d1aSHao Wu #include "hw/i2c/npcm7xx_smbus.h" 24ae0c4d1aSHao Wu #include "hw/intc/arm_gic_common.h" 25ae0c4d1aSHao Wu #include "hw/mem/npcm7xx_mc.h" 26ae0c4d1aSHao Wu #include "hw/misc/npcm_clk.h" 27ae0c4d1aSHao Wu #include "hw/misc/npcm_gcr.h" 28ae0c4d1aSHao Wu #include "hw/misc/npcm7xx_mft.h" 29ae0c4d1aSHao Wu #include "hw/misc/npcm7xx_pwm.h" 30ae0c4d1aSHao Wu #include "hw/misc/npcm7xx_rng.h" 31ae0c4d1aSHao Wu #include "hw/net/npcm7xx_emc.h" 32ae0c4d1aSHao Wu #include "hw/nvram/npcm7xx_otp.h" 33ae0c4d1aSHao Wu #include "hw/sd/npcm7xx_sdhci.h" 34ae0c4d1aSHao Wu #include "hw/timer/npcm7xx_timer.h" 35ae0c4d1aSHao Wu #include "hw/ssi/npcm7xx_fiu.h" 36ae0c4d1aSHao Wu #include "hw/usb/hcd-ehci.h" 37ae0c4d1aSHao Wu #include "hw/usb/hcd-ohci.h" 38ae0c4d1aSHao Wu #include "target/arm/cpu.h" 39ae0c4d1aSHao Wu 40ae0c4d1aSHao Wu #define NPCM8XX_MAX_NUM_CPUS (4) 41ae0c4d1aSHao Wu 42ae0c4d1aSHao Wu /* The first half of the address space is reserved for DDR4 DRAM. */ 43ae0c4d1aSHao Wu #define NPCM8XX_DRAM_BA (0x00000000) 44ae0c4d1aSHao Wu #define NPCM8XX_DRAM_SZ (2 * GiB) 45ae0c4d1aSHao Wu 46ae0c4d1aSHao Wu /* Magic addresses for setting up direct kernel booting and SMP boot stubs. */ 47ae0c4d1aSHao Wu #define NPCM8XX_LOADER_START (0x00000000) /* Start of SDRAM */ 48ae0c4d1aSHao Wu #define NPCM8XX_SMP_LOADER_START (0xffff0000) /* Boot ROM */ 49ae0c4d1aSHao Wu #define NPCM8XX_SMP_BOOTREG_ADDR (0xf080013c) /* GCR.SCRPAD */ 50ae0c4d1aSHao Wu #define NPCM8XX_BOARD_SETUP_ADDR (0xffff1000) /* Boot ROM */ 51ae0c4d1aSHao Wu 52ae0c4d1aSHao Wu #define NPCM8XX_NR_PWM_MODULES 3 53ae0c4d1aSHao Wu 54*7e70eb3cSHao Wu struct NPCM8xxMachine { 55*7e70eb3cSHao Wu MachineState parent_obj; 56*7e70eb3cSHao Wu 57*7e70eb3cSHao Wu /* 58*7e70eb3cSHao Wu * PWM fan splitter. each splitter connects to one PWM output and 59*7e70eb3cSHao Wu * multiple MFT inputs. 60*7e70eb3cSHao Wu */ 61*7e70eb3cSHao Wu SplitIRQ fan_splitter[NPCM8XX_NR_PWM_MODULES * 62*7e70eb3cSHao Wu NPCM7XX_PWM_PER_MODULE]; 63*7e70eb3cSHao Wu }; 64*7e70eb3cSHao Wu 65*7e70eb3cSHao Wu 66*7e70eb3cSHao Wu struct NPCM8xxMachineClass { 67*7e70eb3cSHao Wu MachineClass parent_class; 68*7e70eb3cSHao Wu 69*7e70eb3cSHao Wu const char *soc_type; 70*7e70eb3cSHao Wu }; 71*7e70eb3cSHao Wu 72*7e70eb3cSHao Wu #define TYPE_NPCM8XX_MACHINE MACHINE_TYPE_NAME("npcm8xx") 73*7e70eb3cSHao Wu OBJECT_DECLARE_TYPE(NPCM8xxMachine, NPCM8xxMachineClass, NPCM8XX_MACHINE) 74*7e70eb3cSHao Wu 75ae0c4d1aSHao Wu struct NPCM8xxState { 76ae0c4d1aSHao Wu DeviceState parent_obj; 77ae0c4d1aSHao Wu 78ae0c4d1aSHao Wu ARMCPU cpu[NPCM8XX_MAX_NUM_CPUS]; 79ae0c4d1aSHao Wu CPUClusterState cpu_cluster; 80ae0c4d1aSHao Wu GICState gic; 81ae0c4d1aSHao Wu 82ae0c4d1aSHao Wu MemoryRegion sram; 83ae0c4d1aSHao Wu MemoryRegion irom; 84ae0c4d1aSHao Wu MemoryRegion ram3; 85ae0c4d1aSHao Wu MemoryRegion *dram; 86ae0c4d1aSHao Wu 87ae0c4d1aSHao Wu NPCMGCRState gcr; 88ae0c4d1aSHao Wu NPCMCLKState clk; 89ae0c4d1aSHao Wu NPCM7xxTimerCtrlState tim[3]; 90ae0c4d1aSHao Wu NPCM7xxADCState adc; 91ae0c4d1aSHao Wu NPCM7xxPWMState pwm[NPCM8XX_NR_PWM_MODULES]; 92ae0c4d1aSHao Wu NPCM7xxMFTState mft[8]; 93ae0c4d1aSHao Wu NPCM7xxOTPState fuse_array; 94ae0c4d1aSHao Wu NPCM7xxMCState mc; 95ae0c4d1aSHao Wu NPCM7xxRNGState rng; 96ae0c4d1aSHao Wu NPCM7xxGPIOState gpio[8]; 97ae0c4d1aSHao Wu NPCM7xxSMBusState smbus[27]; 98ae0c4d1aSHao Wu EHCISysBusState ehci[2]; 99ae0c4d1aSHao Wu OHCISysBusState ohci[2]; 100ae0c4d1aSHao Wu NPCM7xxFIUState fiu[3]; 101ae0c4d1aSHao Wu NPCM7xxSDHCIState mmc; 102ae0c4d1aSHao Wu }; 103ae0c4d1aSHao Wu 104ae0c4d1aSHao Wu struct NPCM8xxClass { 105ae0c4d1aSHao Wu DeviceClass parent_class; 106ae0c4d1aSHao Wu 107ae0c4d1aSHao Wu /* Bitmask of modules that are permanently disabled on this chip. */ 108ae0c4d1aSHao Wu uint32_t disabled_modules; 109ae0c4d1aSHao Wu /* Number of CPU cores enabled in this SoC class. */ 110ae0c4d1aSHao Wu uint32_t num_cpus; 111ae0c4d1aSHao Wu }; 112ae0c4d1aSHao Wu 113ae0c4d1aSHao Wu #define TYPE_NPCM8XX "npcm8xx" 114ae0c4d1aSHao Wu OBJECT_DECLARE_TYPE(NPCM8xxState, NPCM8xxClass, NPCM8XX) 115ae0c4d1aSHao Wu 116ae0c4d1aSHao Wu /** 117ae0c4d1aSHao Wu * npcm8xx_load_kernel - Loads memory with everything needed to boot 118ae0c4d1aSHao Wu * @machine - The machine containing the SoC to be booted. 119ae0c4d1aSHao Wu * @soc - The SoC containing the CPU to be booted. 120ae0c4d1aSHao Wu * 121ae0c4d1aSHao Wu * This will set up the ARM boot info structure for the specific NPCM8xx 122ae0c4d1aSHao Wu * derivative and call arm_load_kernel() to set up loading of the kernel, etc. 123ae0c4d1aSHao Wu * into memory, if requested by the user. 124ae0c4d1aSHao Wu */ 125ae0c4d1aSHao Wu void npcm8xx_load_kernel(MachineState *machine, NPCM8xxState *soc); 126ae0c4d1aSHao Wu 127ae0c4d1aSHao Wu #endif /* NPCM8XX_H */ 128