master
h 145 lines 4.82 KB
Raw
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/core/boards.h"
20 #include "hw/adc/npcm7xx_adc.h"
21 #include "hw/core/split-irq.h"
22 #include "hw/arm/boot.h"
23 #include "hw/cpu/a9mpcore.h"
24 #include "hw/gpio/npcm7xx_gpio.h"
25 #include "hw/i2c/npcm7xx_smbus.h"
26 #include "hw/mem/npcm7xx_mc.h"
27 #include "hw/misc/npcm_clk.h"
28 #include "hw/misc/npcm_gcr.h"
29 #include "hw/misc/npcm7xx_mft.h"
30 #include "hw/misc/npcm7xx_pwm.h"
31 #include "hw/misc/npcm7xx_rng.h"
32 #include "hw/net/npcm7xx_emc.h"
33 #include "hw/net/npcm_gmac.h"
34 #include "hw/nvram/npcm7xx_otp.h"
35 #include "hw/timer/npcm7xx_timer.h"
36 #include "hw/ssi/npcm7xx_fiu.h"
37 #include "hw/ssi/npcm_pspi.h"
38 #include "hw/usb/hcd-ehci.h"
39 #include "hw/usb/hcd-ohci.h"
40 #include "target/arm/cpu.h"
41 #include "hw/sd/npcm7xx_sdhci.h"
42
43 #define NPCM7XX_MAX_NUM_CPUS (2)
44
45 /* The first half of the address space is reserved for DDR4 DRAM. */
46 #define NPCM7XX_DRAM_BA (0x00000000)
47 #define NPCM7XX_DRAM_SZ (2 * GiB)
48
49 /* Magic addresses for setting up direct kernel booting and SMP boot stubs. */
50 #define NPCM7XX_LOADER_START (0x00000000) /* Start of SDRAM */
51 #define NPCM7XX_SMP_LOADER_START (0xffff0000) /* Boot ROM */
52 #define NPCM7XX_SMP_BOOTREG_ADDR (0xf080013c) /* GCR.SCRPAD */
53 #define NPCM7XX_GIC_CPU_IF_ADDR (0xf03fe100) /* GIC within A9 */
54 #define NPCM7XX_BOARD_SETUP_ADDR (0xffff1000) /* Boot ROM */
55
56 #define NPCM7XX_NR_PWM_MODULES 2
57
58 struct NPCM7xxMachine {
59 MachineState parent;
60 /*
61 * PWM fan splitter. each splitter connects to one PWM output and
62 * multiple MFT inputs.
63 */
64 SplitIRQ fan_splitter[NPCM7XX_NR_PWM_MODULES *
65 NPCM7XX_PWM_PER_MODULE];
66 struct arm_boot_info bootinfo;
67 };
68
69 #define TYPE_NPCM7XX_MACHINE MACHINE_TYPE_NAME("npcm7xx")
70 OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxMachine, NPCM7XX_MACHINE)
71
72 typedef struct NPCM7xxMachineClass {
73 MachineClass parent;
74
75 const char *soc_type;
76 } NPCM7xxMachineClass;
77
78 #define NPCM7XX_MACHINE_CLASS(klass) \
79 OBJECT_CLASS_CHECK(NPCM7xxMachineClass, (klass), TYPE_NPCM7XX_MACHINE)
80 #define NPCM7XX_MACHINE_GET_CLASS(obj) \
81 OBJECT_GET_CLASS(NPCM7xxMachineClass, (obj), TYPE_NPCM7XX_MACHINE)
82
83 struct NPCM7xxState {
84 DeviceState parent;
85
86 ARMCPU cpu[NPCM7XX_MAX_NUM_CPUS];
87 A9MPPrivState a9mpcore;
88
89 MemoryRegion sram;
90 MemoryRegion irom;
91 MemoryRegion ram3;
92 MemoryRegion *dram;
93
94 NPCMGCRState gcr;
95 NPCMCLKState clk;
96 NPCM7xxTimerCtrlState tim[3];
97 NPCM7xxADCState adc;
98 NPCM7xxPWMState pwm[NPCM7XX_NR_PWM_MODULES];
99 NPCM7xxMFTState mft[8];
100 NPCM7xxOTPState key_storage;
101 NPCM7xxOTPState fuse_array;
102 NPCM7xxMCState mc;
103 NPCM7xxRNGState rng;
104 NPCM7xxGPIOState gpio[8];
105 NPCM7xxSMBusState smbus[16];
106 EHCISysBusState ehci;
107 OHCISysBusState ohci;
108 NPCM7xxFIUState fiu[2];
109 NPCM7xxEMCState emc[2];
110 NPCMGMACState gmac[2];
111 NPCM7xxSDHCIState mmc;
112 NPCMPSPIState pspi[2];
113 };
114
115 #define TYPE_NPCM7XX "npcm7xx"
116 OBJECT_DECLARE_TYPE(NPCM7xxState, NPCM7xxClass, NPCM7XX)
117
118 #define TYPE_NPCM730 "npcm730"
119 #define TYPE_NPCM750 "npcm750"
120
121 typedef struct NPCM7xxClass {
122 DeviceClass parent;
123
124 /* Bitmask of modules that are permanently disabled on this chip. */
125 uint32_t disabled_modules;
126 /* Number of CPU cores enabled in this SoC class (may be 1 or 2). */
127 uint32_t num_cpus;
128 } NPCM7xxClass;
129
130 /**
131 * npcm7xx_load_kernel - Loads memory with everything needed to boot
132 * @machine - The machine containing the SoC to be booted.
133 * @soc - The SoC containing the CPU to be booted.
134 * @binfo - Caller owned boot info structure to be filled in.
135 *
136 * This will set up the ARM boot info structure for the specific NPCM7xx
137 * derivative and call arm_load_kernel() to set up loading of the kernel, etc.
138 * into memory, if requested by the user. The boot info is owned by the
139 * caller because arm_load_kernel() keeps a pointer to it for the lifetime
140 * of the CPUs.
141 */
142 void npcm7xx_load_kernel(MachineState *machine, NPCM7xxState *soc,
143 struct arm_boot_info *binfo);
144
145 #endif /* NPCM7XX_H */