xref: /openbmc/qemu/include/hw/arm/npcm7xx.h (revision 4f2fdb10b5f78ba95300648fce74c42d3e4511c7)
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"
2077c05b0bSHao Wu #include "hw/adc/npcm7xx_adc.h"
21a9d3d7b1SHao Wu #include "hw/core/split-irq.h"
222d8f048cSHavard Skinnemoen #include "hw/cpu/a9mpcore.h"
23526dbbe0SHavard Skinnemoen #include "hw/gpio/npcm7xx_gpio.h"
2494e77879SHao Wu #include "hw/i2c/npcm7xx_smbus.h"
251351f892SHavard Skinnemoen #include "hw/mem/npcm7xx_mc.h"
262d8f048cSHavard Skinnemoen #include "hw/misc/npcm7xx_clk.h"
272d8f048cSHavard Skinnemoen #include "hw/misc/npcm7xx_gcr.h"
28fc11115fSHao Wu #include "hw/misc/npcm7xx_mft.h"
291e943c58SHao Wu #include "hw/misc/npcm7xx_pwm.h"
30326ccfe2SHavard Skinnemoen #include "hw/misc/npcm7xx_rng.h"
3177586436SDoug Evans #include "hw/net/npcm7xx_emc.h"
32*21e5326aSHao Wu #include "hw/net/npcm_gmac.h"
33c752bb07SHavard Skinnemoen #include "hw/nvram/npcm7xx_otp.h"
342d8f048cSHavard Skinnemoen #include "hw/timer/npcm7xx_timer.h"
35b821242cSHavard Skinnemoen #include "hw/ssi/npcm7xx_fiu.h"
364d120d7dSHao Wu #include "hw/ssi/npcm_pspi.h"
37e23e7b12SHavard Skinnemoen #include "hw/usb/hcd-ehci.h"
38e23e7b12SHavard Skinnemoen #include "hw/usb/hcd-ohci.h"
392d8f048cSHavard Skinnemoen #include "target/arm/cpu.h"
400a9df6cbSShengtan Mao #include "hw/sd/npcm7xx_sdhci.h"
412d8f048cSHavard Skinnemoen 
422d8f048cSHavard Skinnemoen #define NPCM7XX_MAX_NUM_CPUS    (2)
432d8f048cSHavard Skinnemoen 
442d8f048cSHavard Skinnemoen /* The first half of the address space is reserved for DDR4 DRAM. */
452d8f048cSHavard Skinnemoen #define NPCM7XX_DRAM_BA         (0x00000000)
462d8f048cSHavard Skinnemoen #define NPCM7XX_DRAM_SZ         (2 * GiB)
472d8f048cSHavard Skinnemoen 
482d8f048cSHavard Skinnemoen /* Magic addresses for setting up direct kernel booting and SMP boot stubs. */
492d8f048cSHavard Skinnemoen #define NPCM7XX_LOADER_START            (0x00000000)  /* Start of SDRAM */
502d8f048cSHavard Skinnemoen #define NPCM7XX_SMP_LOADER_START        (0xffff0000)  /* Boot ROM */
512d8f048cSHavard Skinnemoen #define NPCM7XX_SMP_BOOTREG_ADDR        (0xf080013c)  /* GCR.SCRPAD */
522d8f048cSHavard Skinnemoen #define NPCM7XX_GIC_CPU_IF_ADDR         (0xf03fe100)  /* GIC within A9 */
532ddae9ccSHavard Skinnemoen #define NPCM7XX_BOARD_SETUP_ADDR        (0xffff1000)  /* Boot ROM */
542d8f048cSHavard Skinnemoen 
55a9d3d7b1SHao Wu #define NPCM7XX_NR_PWM_MODULES 2
56a9d3d7b1SHao Wu 
57c79aa350SPhilippe Mathieu-Daudé struct NPCM7xxMachine {
58b773acf4SHavard Skinnemoen     MachineState        parent;
59a9d3d7b1SHao Wu     /*
60a9d3d7b1SHao Wu      * PWM fan splitter. each splitter connects to one PWM output and
61a9d3d7b1SHao Wu      * multiple MFT inputs.
62a9d3d7b1SHao Wu      */
63a9d3d7b1SHao Wu     SplitIRQ            fan_splitter[NPCM7XX_NR_PWM_MODULES *
64a9d3d7b1SHao Wu                                      NPCM7XX_PWM_PER_MODULE];
65c79aa350SPhilippe Mathieu-Daudé };
66b773acf4SHavard Skinnemoen 
67b773acf4SHavard Skinnemoen #define TYPE_NPCM7XX_MACHINE MACHINE_TYPE_NAME("npcm7xx")
68c79aa350SPhilippe Mathieu-Daudé OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxMachine, NPCM7XX_MACHINE)
69b773acf4SHavard Skinnemoen 
70b773acf4SHavard Skinnemoen typedef struct NPCM7xxMachineClass {
71b773acf4SHavard Skinnemoen     MachineClass        parent;
72b773acf4SHavard Skinnemoen 
73b773acf4SHavard Skinnemoen     const char          *soc_type;
74b773acf4SHavard Skinnemoen } NPCM7xxMachineClass;
75b773acf4SHavard Skinnemoen 
76b773acf4SHavard Skinnemoen #define NPCM7XX_MACHINE_CLASS(klass)                                    \
77b773acf4SHavard Skinnemoen     OBJECT_CLASS_CHECK(NPCM7xxMachineClass, (klass), TYPE_NPCM7XX_MACHINE)
78b773acf4SHavard Skinnemoen #define NPCM7XX_MACHINE_GET_CLASS(obj)                                  \
79b773acf4SHavard Skinnemoen     OBJECT_GET_CLASS(NPCM7xxMachineClass, (obj), TYPE_NPCM7XX_MACHINE)
80b773acf4SHavard Skinnemoen 
81c79aa350SPhilippe Mathieu-Daudé struct NPCM7xxState {
822d8f048cSHavard Skinnemoen     DeviceState         parent;
832d8f048cSHavard Skinnemoen 
842d8f048cSHavard Skinnemoen     ARMCPU              cpu[NPCM7XX_MAX_NUM_CPUS];
852d8f048cSHavard Skinnemoen     A9MPPrivState       a9mpcore;
862d8f048cSHavard Skinnemoen 
872d8f048cSHavard Skinnemoen     MemoryRegion        sram;
882d8f048cSHavard Skinnemoen     MemoryRegion        irom;
892d8f048cSHavard Skinnemoen     MemoryRegion        ram3;
902d8f048cSHavard Skinnemoen     MemoryRegion        *dram;
912d8f048cSHavard Skinnemoen 
922d8f048cSHavard Skinnemoen     NPCM7xxGCRState     gcr;
932d8f048cSHavard Skinnemoen     NPCM7xxCLKState     clk;
942d8f048cSHavard Skinnemoen     NPCM7xxTimerCtrlState tim[3];
9577c05b0bSHao Wu     NPCM7xxADCState     adc;
96a9d3d7b1SHao Wu     NPCM7xxPWMState     pwm[NPCM7XX_NR_PWM_MODULES];
97fc11115fSHao Wu     NPCM7xxMFTState     mft[8];
98c752bb07SHavard Skinnemoen     NPCM7xxOTPState     key_storage;
99c752bb07SHavard Skinnemoen     NPCM7xxOTPState     fuse_array;
1001351f892SHavard Skinnemoen     NPCM7xxMCState      mc;
101326ccfe2SHavard Skinnemoen     NPCM7xxRNGState     rng;
102526dbbe0SHavard Skinnemoen     NPCM7xxGPIOState    gpio[8];
10394e77879SHao Wu     NPCM7xxSMBusState   smbus[16];
104e23e7b12SHavard Skinnemoen     EHCISysBusState     ehci;
105e23e7b12SHavard Skinnemoen     OHCISysBusState     ohci;
106b821242cSHavard Skinnemoen     NPCM7xxFIUState     fiu[2];
10777586436SDoug Evans     NPCM7xxEMCState     emc[2];
108*21e5326aSHao Wu     NPCMGMACState       gmac[2];
1090a9df6cbSShengtan Mao     NPCM7xxSDHCIState   mmc;
1104d120d7dSHao Wu     NPCMPSPIState       pspi[2];
111c79aa350SPhilippe Mathieu-Daudé };
1122d8f048cSHavard Skinnemoen 
1132d8f048cSHavard Skinnemoen #define TYPE_NPCM7XX    "npcm7xx"
114c79aa350SPhilippe Mathieu-Daudé OBJECT_DECLARE_TYPE(NPCM7xxState, NPCM7xxClass, NPCM7XX)
1152d8f048cSHavard Skinnemoen 
1162d8f048cSHavard Skinnemoen #define TYPE_NPCM730    "npcm730"
1172d8f048cSHavard Skinnemoen #define TYPE_NPCM750    "npcm750"
1182d8f048cSHavard Skinnemoen 
1192d8f048cSHavard Skinnemoen typedef struct NPCM7xxClass {
1202d8f048cSHavard Skinnemoen     DeviceClass         parent;
1212d8f048cSHavard Skinnemoen 
1222d8f048cSHavard Skinnemoen     /* Bitmask of modules that are permanently disabled on this chip. */
1232d8f048cSHavard Skinnemoen     uint32_t            disabled_modules;
1242d8f048cSHavard Skinnemoen     /* Number of CPU cores enabled in this SoC class (may be 1 or 2). */
1252d8f048cSHavard Skinnemoen     uint32_t            num_cpus;
1262d8f048cSHavard Skinnemoen } NPCM7xxClass;
1272d8f048cSHavard Skinnemoen 
1282d8f048cSHavard Skinnemoen /**
1292d8f048cSHavard Skinnemoen  * npcm7xx_load_kernel - Loads memory with everything needed to boot
1302d8f048cSHavard Skinnemoen  * @machine - The machine containing the SoC to be booted.
1312d8f048cSHavard Skinnemoen  * @soc - The SoC containing the CPU to be booted.
1322d8f048cSHavard Skinnemoen  *
1332d8f048cSHavard Skinnemoen  * This will set up the ARM boot info structure for the specific NPCM7xx
1342d8f048cSHavard Skinnemoen  * derivative and call arm_load_kernel() to set up loading of the kernel, etc.
1352d8f048cSHavard Skinnemoen  * into memory, if requested by the user.
1362d8f048cSHavard Skinnemoen  */
1372d8f048cSHavard Skinnemoen void npcm7xx_load_kernel(MachineState *machine, NPCM7xxState *soc);
1382d8f048cSHavard Skinnemoen 
1392d8f048cSHavard Skinnemoen #endif /* NPCM7XX_H */
140