xref: /openbmc/qemu/include/hw/arm/fsl-imx7.h (revision cdd684b8)
1 /*
2  * Copyright (c) 2018, Impinj, Inc.
3  *
4  * i.MX7 SoC definitions
5  *
6  * Author: Andrey Smirnov <andrew.smirnov@gmail.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  */
18 
19 #ifndef FSL_IMX7_H
20 #define FSL_IMX7_H
21 
22 #include "hw/arm/boot.h"
23 #include "hw/cpu/a15mpcore.h"
24 #include "hw/intc/imx_gpcv2.h"
25 #include "hw/misc/imx7_ccm.h"
26 #include "hw/misc/imx7_snvs.h"
27 #include "hw/misc/imx7_gpr.h"
28 #include "hw/misc/imx6_src.h"
29 #include "hw/watchdog/wdt_imx2.h"
30 #include "hw/gpio/imx_gpio.h"
31 #include "hw/char/imx_serial.h"
32 #include "hw/timer/imx_gpt.h"
33 #include "hw/timer/imx_epit.h"
34 #include "hw/i2c/imx_i2c.h"
35 #include "hw/sd/sdhci.h"
36 #include "hw/ssi/imx_spi.h"
37 #include "hw/net/imx_fec.h"
38 #include "hw/pci-host/designware.h"
39 #include "hw/usb/chipidea.h"
40 #include "cpu.h"
41 #include "qom/object.h"
42 
43 #define TYPE_FSL_IMX7 "fsl-imx7"
44 OBJECT_DECLARE_SIMPLE_TYPE(FslIMX7State, FSL_IMX7)
45 
46 enum FslIMX7Configuration {
47     FSL_IMX7_NUM_CPUS         = 2,
48     FSL_IMX7_NUM_UARTS        = 7,
49     FSL_IMX7_NUM_ETHS         = 2,
50     FSL_IMX7_ETH_NUM_TX_RINGS = 3,
51     FSL_IMX7_NUM_USDHCS       = 3,
52     FSL_IMX7_NUM_WDTS         = 4,
53     FSL_IMX7_NUM_GPTS         = 4,
54     FSL_IMX7_NUM_IOMUXCS      = 2,
55     FSL_IMX7_NUM_GPIOS        = 7,
56     FSL_IMX7_NUM_I2CS         = 4,
57     FSL_IMX7_NUM_ECSPIS       = 4,
58     FSL_IMX7_NUM_USBS         = 3,
59     FSL_IMX7_NUM_ADCS         = 2,
60 };
61 
62 struct FslIMX7State {
63     /*< private >*/
64     DeviceState    parent_obj;
65 
66     /*< public >*/
67     ARMCPU             cpu[FSL_IMX7_NUM_CPUS];
68     A15MPPrivState     a7mpcore;
69     IMXGPTState        gpt[FSL_IMX7_NUM_GPTS];
70     IMXGPIOState       gpio[FSL_IMX7_NUM_GPIOS];
71     IMX7CCMState       ccm;
72     IMX7AnalogState    analog;
73     IMX7SNVSState      snvs;
74     IMXGPCv2State      gpcv2;
75     IMXSPIState        spi[FSL_IMX7_NUM_ECSPIS];
76     IMXI2CState        i2c[FSL_IMX7_NUM_I2CS];
77     IMXSerialState     uart[FSL_IMX7_NUM_UARTS];
78     IMXFECState        eth[FSL_IMX7_NUM_ETHS];
79     SDHCIState         usdhc[FSL_IMX7_NUM_USDHCS];
80     IMX2WdtState       wdt[FSL_IMX7_NUM_WDTS];
81     IMX7GPRState       gpr;
82     ChipideaState      usb[FSL_IMX7_NUM_USBS];
83     DesignwarePCIEHost pcie;
84     uint32_t           phy_num[FSL_IMX7_NUM_ETHS];
85     bool               phy_connected[FSL_IMX7_NUM_ETHS];
86 };
87 
88 enum FslIMX7MemoryMap {
89     FSL_IMX7_MMDC_ADDR            = 0x80000000,
90     FSL_IMX7_MMDC_SIZE            = 2 * 1024 * 1024 * 1024UL,
91 
92     FSL_IMX7_GPIO1_ADDR           = 0x30200000,
93     FSL_IMX7_GPIO2_ADDR           = 0x30210000,
94     FSL_IMX7_GPIO3_ADDR           = 0x30220000,
95     FSL_IMX7_GPIO4_ADDR           = 0x30230000,
96     FSL_IMX7_GPIO5_ADDR           = 0x30240000,
97     FSL_IMX7_GPIO6_ADDR           = 0x30250000,
98     FSL_IMX7_GPIO7_ADDR           = 0x30260000,
99 
100     FSL_IMX7_IOMUXC_LPSR_GPR_ADDR = 0x30270000,
101 
102     FSL_IMX7_WDOG1_ADDR           = 0x30280000,
103     FSL_IMX7_WDOG2_ADDR           = 0x30290000,
104     FSL_IMX7_WDOG3_ADDR           = 0x302A0000,
105     FSL_IMX7_WDOG4_ADDR           = 0x302B0000,
106 
107     FSL_IMX7_IOMUXC_LPSR_ADDR     = 0x302C0000,
108 
109     FSL_IMX7_GPT1_ADDR            = 0x302D0000,
110     FSL_IMX7_GPT2_ADDR            = 0x302E0000,
111     FSL_IMX7_GPT3_ADDR            = 0x302F0000,
112     FSL_IMX7_GPT4_ADDR            = 0x30300000,
113 
114     FSL_IMX7_IOMUXC_ADDR          = 0x30330000,
115     FSL_IMX7_IOMUXC_GPR_ADDR      = 0x30340000,
116     FSL_IMX7_IOMUXCn_SIZE         = 0x1000,
117 
118     FSL_IMX7_OCOTP_ADDR           = 0x30350000,
119     FSL_IMX7_OCOTP_SIZE           = 0x10000,
120 
121     FSL_IMX7_ANALOG_ADDR          = 0x30360000,
122     FSL_IMX7_SNVS_ADDR            = 0x30370000,
123     FSL_IMX7_CCM_ADDR             = 0x30380000,
124 
125     FSL_IMX7_SRC_ADDR             = 0x30390000,
126     FSL_IMX7_SRC_SIZE             = 0x1000,
127 
128     FSL_IMX7_ADC1_ADDR            = 0x30610000,
129     FSL_IMX7_ADC2_ADDR            = 0x30620000,
130     FSL_IMX7_ADCn_SIZE            = 0x1000,
131 
132     FSL_IMX7_PWM1_ADDR            = 0x30660000,
133     FSL_IMX7_PWM2_ADDR            = 0x30670000,
134     FSL_IMX7_PWM3_ADDR            = 0x30680000,
135     FSL_IMX7_PWM4_ADDR            = 0x30690000,
136     FSL_IMX7_PWMn_SIZE            = 0x10000,
137 
138     FSL_IMX7_PCIE_PHY_ADDR        = 0x306D0000,
139     FSL_IMX7_PCIE_PHY_SIZE        = 0x10000,
140 
141     FSL_IMX7_GPC_ADDR             = 0x303A0000,
142 
143     FSL_IMX7_CAAM_ADDR            = 0x30900000,
144     FSL_IMX7_CAAM_SIZE            = 0x40000,
145 
146     FSL_IMX7_CAN1_ADDR            = 0x30A00000,
147     FSL_IMX7_CAN2_ADDR            = 0x30A10000,
148     FSL_IMX7_CANn_SIZE            = 0x10000,
149 
150     FSL_IMX7_I2C1_ADDR            = 0x30A20000,
151     FSL_IMX7_I2C2_ADDR            = 0x30A30000,
152     FSL_IMX7_I2C3_ADDR            = 0x30A40000,
153     FSL_IMX7_I2C4_ADDR            = 0x30A50000,
154 
155     FSL_IMX7_ECSPI1_ADDR          = 0x30820000,
156     FSL_IMX7_ECSPI2_ADDR          = 0x30830000,
157     FSL_IMX7_ECSPI3_ADDR          = 0x30840000,
158     FSL_IMX7_ECSPI4_ADDR          = 0x30630000,
159 
160     FSL_IMX7_LCDIF_ADDR           = 0x30730000,
161     FSL_IMX7_LCDIF_SIZE           = 0x1000,
162 
163     FSL_IMX7_UART1_ADDR           = 0x30860000,
164     /*
165      * Some versions of the reference manual claim that UART2 is @
166      * 0x30870000, but experiments with HW + DT files in upstream
167      * Linux kernel show that not to be true and that block is
168      * acutally located @ 0x30890000
169      */
170     FSL_IMX7_UART2_ADDR           = 0x30890000,
171     FSL_IMX7_UART3_ADDR           = 0x30880000,
172     FSL_IMX7_UART4_ADDR           = 0x30A60000,
173     FSL_IMX7_UART5_ADDR           = 0x30A70000,
174     FSL_IMX7_UART6_ADDR           = 0x30A80000,
175     FSL_IMX7_UART7_ADDR           = 0x30A90000,
176 
177     FSL_IMX7_SAI1_ADDR            = 0x308A0000,
178     FSL_IMX7_SAI2_ADDR            = 0x308B0000,
179     FSL_IMX7_SAI3_ADDR            = 0x308C0000,
180     FSL_IMX7_SAIn_SIZE            = 0x10000,
181 
182     FSL_IMX7_ENET1_ADDR           = 0x30BE0000,
183     FSL_IMX7_ENET2_ADDR           = 0x30BF0000,
184 
185     FSL_IMX7_USB1_ADDR            = 0x30B10000,
186     FSL_IMX7_USBMISC1_ADDR        = 0x30B10200,
187     FSL_IMX7_USB2_ADDR            = 0x30B20000,
188     FSL_IMX7_USBMISC2_ADDR        = 0x30B20200,
189     FSL_IMX7_USB3_ADDR            = 0x30B30000,
190     FSL_IMX7_USBMISC3_ADDR        = 0x30B30200,
191     FSL_IMX7_USBMISCn_SIZE        = 0x200,
192 
193     FSL_IMX7_USDHC1_ADDR          = 0x30B40000,
194     FSL_IMX7_USDHC2_ADDR          = 0x30B50000,
195     FSL_IMX7_USDHC3_ADDR          = 0x30B60000,
196 
197     FSL_IMX7_SDMA_ADDR            = 0x30BD0000,
198     FSL_IMX7_SDMA_SIZE            = 0x1000,
199 
200     FSL_IMX7_A7MPCORE_ADDR        = 0x31000000,
201     FSL_IMX7_A7MPCORE_DAP_ADDR    = 0x30000000,
202 
203     FSL_IMX7_PCIE_REG_ADDR        = 0x33800000,
204     FSL_IMX7_PCIE_REG_SIZE        = 16 * 1024,
205 
206     FSL_IMX7_GPR_ADDR             = 0x30340000,
207 
208     FSL_IMX7_DMA_APBH_ADDR        = 0x33000000,
209     FSL_IMX7_DMA_APBH_SIZE        = 0x2000,
210 };
211 
212 enum FslIMX7IRQs {
213     FSL_IMX7_USDHC1_IRQ   = 22,
214     FSL_IMX7_USDHC2_IRQ   = 23,
215     FSL_IMX7_USDHC3_IRQ   = 24,
216 
217     FSL_IMX7_UART1_IRQ    = 26,
218     FSL_IMX7_UART2_IRQ    = 27,
219     FSL_IMX7_UART3_IRQ    = 28,
220     FSL_IMX7_UART4_IRQ    = 29,
221     FSL_IMX7_UART5_IRQ    = 30,
222     FSL_IMX7_UART6_IRQ    = 16,
223 
224     FSL_IMX7_ECSPI1_IRQ   = 31,
225     FSL_IMX7_ECSPI2_IRQ   = 32,
226     FSL_IMX7_ECSPI3_IRQ   = 33,
227     FSL_IMX7_ECSPI4_IRQ   = 34,
228 
229     FSL_IMX7_I2C1_IRQ     = 35,
230     FSL_IMX7_I2C2_IRQ     = 36,
231     FSL_IMX7_I2C3_IRQ     = 37,
232     FSL_IMX7_I2C4_IRQ     = 38,
233 
234     FSL_IMX7_USB1_IRQ     = 43,
235     FSL_IMX7_USB2_IRQ     = 42,
236     FSL_IMX7_USB3_IRQ     = 40,
237 
238     FSL_IMX7_GPT1_IRQ     = 55,
239     FSL_IMX7_GPT2_IRQ     = 54,
240     FSL_IMX7_GPT3_IRQ     = 53,
241     FSL_IMX7_GPT4_IRQ     = 52,
242 
243     FSL_IMX7_GPIO1_LOW_IRQ  = 64,
244     FSL_IMX7_GPIO1_HIGH_IRQ = 65,
245     FSL_IMX7_GPIO2_LOW_IRQ  = 66,
246     FSL_IMX7_GPIO2_HIGH_IRQ = 67,
247     FSL_IMX7_GPIO3_LOW_IRQ  = 68,
248     FSL_IMX7_GPIO3_HIGH_IRQ = 69,
249     FSL_IMX7_GPIO4_LOW_IRQ  = 70,
250     FSL_IMX7_GPIO4_HIGH_IRQ = 71,
251     FSL_IMX7_GPIO5_LOW_IRQ  = 72,
252     FSL_IMX7_GPIO5_HIGH_IRQ = 73,
253     FSL_IMX7_GPIO6_LOW_IRQ  = 74,
254     FSL_IMX7_GPIO6_HIGH_IRQ = 75,
255     FSL_IMX7_GPIO7_LOW_IRQ  = 76,
256     FSL_IMX7_GPIO7_HIGH_IRQ = 77,
257 
258     FSL_IMX7_WDOG1_IRQ    = 78,
259     FSL_IMX7_WDOG2_IRQ    = 79,
260     FSL_IMX7_WDOG3_IRQ    = 10,
261     FSL_IMX7_WDOG4_IRQ    = 109,
262 
263     FSL_IMX7_PCI_INTA_IRQ = 125,
264     FSL_IMX7_PCI_INTB_IRQ = 124,
265     FSL_IMX7_PCI_INTC_IRQ = 123,
266     FSL_IMX7_PCI_INTD_IRQ = 122,
267 
268     FSL_IMX7_UART7_IRQ    = 126,
269 
270 #define FSL_IMX7_ENET_IRQ(i, n)  ((n) + ((i) ? 100 : 118))
271 
272     FSL_IMX7_MAX_IRQ      = 128,
273 };
274 
275 #endif /* FSL_IMX7_H */
276