1*83d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
2254d68b6SMasahiro Yamada /*
3254d68b6SMasahiro Yamada * Adapted from Linux v2.6.36 kernel: arch/powerpc/kernel/asm-offsets.c
4254d68b6SMasahiro Yamada *
5254d68b6SMasahiro Yamada * This program is used to generate definitions needed by
6254d68b6SMasahiro Yamada * assembly language modules.
7254d68b6SMasahiro Yamada *
8254d68b6SMasahiro Yamada * We use the technique used in the OSF Mach kernel code:
9254d68b6SMasahiro Yamada * generate asm statements containing #defines,
10254d68b6SMasahiro Yamada * compile this file to assembler, and then extract the
11254d68b6SMasahiro Yamada * #defines from the assembly-language output.
12254d68b6SMasahiro Yamada */
13254d68b6SMasahiro Yamada
14254d68b6SMasahiro Yamada #include <common.h>
15254d68b6SMasahiro Yamada #include <linux/kbuild.h>
16c54bcf68SMasahiro Yamada #include <linux/arm-smccc.h>
17254d68b6SMasahiro Yamada
18254d68b6SMasahiro Yamada #if defined(CONFIG_MX25) || defined(CONFIG_MX27) || defined(CONFIG_MX35) \
19254d68b6SMasahiro Yamada || defined(CONFIG_MX51) || defined(CONFIG_MX53)
20254d68b6SMasahiro Yamada #include <asm/arch/imx-regs.h>
21254d68b6SMasahiro Yamada #endif
22254d68b6SMasahiro Yamada
main(void)23254d68b6SMasahiro Yamada int main(void)
24254d68b6SMasahiro Yamada {
25254d68b6SMasahiro Yamada /*
26254d68b6SMasahiro Yamada * TODO : Check if each entry in this file is really necessary.
27254d68b6SMasahiro Yamada * - struct esdramc_regs
28254d68b6SMasahiro Yamada * - struct max_regs
29254d68b6SMasahiro Yamada * - struct aips_regs
30254d68b6SMasahiro Yamada * - struct aipi_regs
31254d68b6SMasahiro Yamada * - struct clkctl
32254d68b6SMasahiro Yamada * - struct dpll
33254d68b6SMasahiro Yamada * are used only for generating asm-offsets.h.
34254d68b6SMasahiro Yamada * It means their offset addresses are referenced only from assembly
35254d68b6SMasahiro Yamada * code. Is it better to define the macros directly in headers?
36254d68b6SMasahiro Yamada */
37254d68b6SMasahiro Yamada
38254d68b6SMasahiro Yamada #if defined(CONFIG_MX25)
39254d68b6SMasahiro Yamada /* Clock Control Module */
40254d68b6SMasahiro Yamada DEFINE(CCM_CCTL, offsetof(struct ccm_regs, cctl));
41254d68b6SMasahiro Yamada DEFINE(CCM_CGCR0, offsetof(struct ccm_regs, cgr0));
42254d68b6SMasahiro Yamada DEFINE(CCM_CGCR1, offsetof(struct ccm_regs, cgr1));
43254d68b6SMasahiro Yamada DEFINE(CCM_CGCR2, offsetof(struct ccm_regs, cgr2));
44254d68b6SMasahiro Yamada DEFINE(CCM_PCDR2, offsetof(struct ccm_regs, pcdr[2]));
45254d68b6SMasahiro Yamada DEFINE(CCM_MCR, offsetof(struct ccm_regs, mcr));
46254d68b6SMasahiro Yamada
47254d68b6SMasahiro Yamada /* Enhanced SDRAM Controller */
48254d68b6SMasahiro Yamada DEFINE(ESDRAMC_ESDCTL0, offsetof(struct esdramc_regs, ctl0));
49254d68b6SMasahiro Yamada DEFINE(ESDRAMC_ESDCFG0, offsetof(struct esdramc_regs, cfg0));
50254d68b6SMasahiro Yamada DEFINE(ESDRAMC_ESDMISC, offsetof(struct esdramc_regs, misc));
51254d68b6SMasahiro Yamada
52254d68b6SMasahiro Yamada /* Multi-Layer AHB Crossbar Switch */
53254d68b6SMasahiro Yamada DEFINE(MAX_MPR0, offsetof(struct max_regs, mpr0));
54254d68b6SMasahiro Yamada DEFINE(MAX_SGPCR0, offsetof(struct max_regs, sgpcr0));
55254d68b6SMasahiro Yamada DEFINE(MAX_MPR1, offsetof(struct max_regs, mpr1));
56254d68b6SMasahiro Yamada DEFINE(MAX_SGPCR1, offsetof(struct max_regs, sgpcr1));
57254d68b6SMasahiro Yamada DEFINE(MAX_MPR2, offsetof(struct max_regs, mpr2));
58254d68b6SMasahiro Yamada DEFINE(MAX_SGPCR2, offsetof(struct max_regs, sgpcr2));
59254d68b6SMasahiro Yamada DEFINE(MAX_MPR3, offsetof(struct max_regs, mpr3));
60254d68b6SMasahiro Yamada DEFINE(MAX_SGPCR3, offsetof(struct max_regs, sgpcr3));
61254d68b6SMasahiro Yamada DEFINE(MAX_MPR4, offsetof(struct max_regs, mpr4));
62254d68b6SMasahiro Yamada DEFINE(MAX_SGPCR4, offsetof(struct max_regs, sgpcr4));
63254d68b6SMasahiro Yamada DEFINE(MAX_MGPCR0, offsetof(struct max_regs, mgpcr0));
64254d68b6SMasahiro Yamada DEFINE(MAX_MGPCR1, offsetof(struct max_regs, mgpcr1));
65254d68b6SMasahiro Yamada DEFINE(MAX_MGPCR2, offsetof(struct max_regs, mgpcr2));
66254d68b6SMasahiro Yamada DEFINE(MAX_MGPCR3, offsetof(struct max_regs, mgpcr3));
67254d68b6SMasahiro Yamada DEFINE(MAX_MGPCR4, offsetof(struct max_regs, mgpcr4));
68254d68b6SMasahiro Yamada
69254d68b6SMasahiro Yamada /* AHB <-> IP-Bus Interface */
70254d68b6SMasahiro Yamada DEFINE(AIPS_MPR_0_7, offsetof(struct aips_regs, mpr_0_7));
71254d68b6SMasahiro Yamada DEFINE(AIPS_MPR_8_15, offsetof(struct aips_regs, mpr_8_15));
72254d68b6SMasahiro Yamada #endif
73254d68b6SMasahiro Yamada
74254d68b6SMasahiro Yamada #if defined(CONFIG_MX27)
75254d68b6SMasahiro Yamada DEFINE(AIPI1_PSR0, IMX_AIPI1_BASE + offsetof(struct aipi_regs, psr0));
76254d68b6SMasahiro Yamada DEFINE(AIPI1_PSR1, IMX_AIPI1_BASE + offsetof(struct aipi_regs, psr1));
77254d68b6SMasahiro Yamada DEFINE(AIPI2_PSR0, IMX_AIPI2_BASE + offsetof(struct aipi_regs, psr0));
78254d68b6SMasahiro Yamada DEFINE(AIPI2_PSR1, IMX_AIPI2_BASE + offsetof(struct aipi_regs, psr1));
79254d68b6SMasahiro Yamada
80254d68b6SMasahiro Yamada DEFINE(CSCR, IMX_PLL_BASE + offsetof(struct pll_regs, cscr));
81254d68b6SMasahiro Yamada DEFINE(MPCTL0, IMX_PLL_BASE + offsetof(struct pll_regs, mpctl0));
82254d68b6SMasahiro Yamada DEFINE(SPCTL0, IMX_PLL_BASE + offsetof(struct pll_regs, spctl0));
83254d68b6SMasahiro Yamada DEFINE(PCDR0, IMX_PLL_BASE + offsetof(struct pll_regs, pcdr0));
84254d68b6SMasahiro Yamada DEFINE(PCDR1, IMX_PLL_BASE + offsetof(struct pll_regs, pcdr1));
85254d68b6SMasahiro Yamada DEFINE(PCCR0, IMX_PLL_BASE + offsetof(struct pll_regs, pccr0));
86254d68b6SMasahiro Yamada DEFINE(PCCR1, IMX_PLL_BASE + offsetof(struct pll_regs, pccr1));
87254d68b6SMasahiro Yamada
88254d68b6SMasahiro Yamada DEFINE(ESDCTL0_ROF, offsetof(struct esdramc_regs, esdctl0));
89254d68b6SMasahiro Yamada DEFINE(ESDCFG0_ROF, offsetof(struct esdramc_regs, esdcfg0));
90254d68b6SMasahiro Yamada DEFINE(ESDCTL1_ROF, offsetof(struct esdramc_regs, esdctl1));
91254d68b6SMasahiro Yamada DEFINE(ESDCFG1_ROF, offsetof(struct esdramc_regs, esdcfg1));
92254d68b6SMasahiro Yamada DEFINE(ESDMISC_ROF, offsetof(struct esdramc_regs, esdmisc));
93254d68b6SMasahiro Yamada
94254d68b6SMasahiro Yamada DEFINE(GPCR, IMX_SYSTEM_CTL_BASE +
95254d68b6SMasahiro Yamada offsetof(struct system_control_regs, gpcr));
96254d68b6SMasahiro Yamada DEFINE(FMCR, IMX_SYSTEM_CTL_BASE +
97254d68b6SMasahiro Yamada offsetof(struct system_control_regs, fmcr));
98254d68b6SMasahiro Yamada #endif
99254d68b6SMasahiro Yamada
100254d68b6SMasahiro Yamada #if defined(CONFIG_MX35)
101254d68b6SMasahiro Yamada /* Round up to make sure size gives nice stack alignment */
102254d68b6SMasahiro Yamada DEFINE(CLKCTL_CCMR, offsetof(struct ccm_regs, ccmr));
103254d68b6SMasahiro Yamada DEFINE(CLKCTL_PDR0, offsetof(struct ccm_regs, pdr0));
104254d68b6SMasahiro Yamada DEFINE(CLKCTL_PDR1, offsetof(struct ccm_regs, pdr1));
105254d68b6SMasahiro Yamada DEFINE(CLKCTL_PDR2, offsetof(struct ccm_regs, pdr2));
106254d68b6SMasahiro Yamada DEFINE(CLKCTL_PDR3, offsetof(struct ccm_regs, pdr3));
107254d68b6SMasahiro Yamada DEFINE(CLKCTL_PDR4, offsetof(struct ccm_regs, pdr4));
108254d68b6SMasahiro Yamada DEFINE(CLKCTL_RCSR, offsetof(struct ccm_regs, rcsr));
109254d68b6SMasahiro Yamada DEFINE(CLKCTL_MPCTL, offsetof(struct ccm_regs, mpctl));
110254d68b6SMasahiro Yamada DEFINE(CLKCTL_PPCTL, offsetof(struct ccm_regs, ppctl));
111254d68b6SMasahiro Yamada DEFINE(CLKCTL_ACMR, offsetof(struct ccm_regs, acmr));
112254d68b6SMasahiro Yamada DEFINE(CLKCTL_COSR, offsetof(struct ccm_regs, cosr));
113254d68b6SMasahiro Yamada DEFINE(CLKCTL_CGR0, offsetof(struct ccm_regs, cgr0));
114254d68b6SMasahiro Yamada DEFINE(CLKCTL_CGR1, offsetof(struct ccm_regs, cgr1));
115254d68b6SMasahiro Yamada DEFINE(CLKCTL_CGR2, offsetof(struct ccm_regs, cgr2));
116254d68b6SMasahiro Yamada DEFINE(CLKCTL_CGR3, offsetof(struct ccm_regs, cgr3));
117254d68b6SMasahiro Yamada
118254d68b6SMasahiro Yamada /* Multi-Layer AHB Crossbar Switch */
119254d68b6SMasahiro Yamada DEFINE(MAX_MPR0, offsetof(struct max_regs, mpr0));
120254d68b6SMasahiro Yamada DEFINE(MAX_SGPCR0, offsetof(struct max_regs, sgpcr0));
121254d68b6SMasahiro Yamada DEFINE(MAX_MPR1, offsetof(struct max_regs, mpr1));
122254d68b6SMasahiro Yamada DEFINE(MAX_SGPCR1, offsetof(struct max_regs, sgpcr1));
123254d68b6SMasahiro Yamada DEFINE(MAX_MPR2, offsetof(struct max_regs, mpr2));
124254d68b6SMasahiro Yamada DEFINE(MAX_SGPCR2, offsetof(struct max_regs, sgpcr2));
125254d68b6SMasahiro Yamada DEFINE(MAX_MPR3, offsetof(struct max_regs, mpr3));
126254d68b6SMasahiro Yamada DEFINE(MAX_SGPCR3, offsetof(struct max_regs, sgpcr3));
127254d68b6SMasahiro Yamada DEFINE(MAX_MPR4, offsetof(struct max_regs, mpr4));
128254d68b6SMasahiro Yamada DEFINE(MAX_SGPCR4, offsetof(struct max_regs, sgpcr4));
129254d68b6SMasahiro Yamada DEFINE(MAX_MGPCR0, offsetof(struct max_regs, mgpcr0));
130254d68b6SMasahiro Yamada DEFINE(MAX_MGPCR1, offsetof(struct max_regs, mgpcr1));
131254d68b6SMasahiro Yamada DEFINE(MAX_MGPCR2, offsetof(struct max_regs, mgpcr2));
132254d68b6SMasahiro Yamada DEFINE(MAX_MGPCR3, offsetof(struct max_regs, mgpcr3));
133254d68b6SMasahiro Yamada DEFINE(MAX_MGPCR4, offsetof(struct max_regs, mgpcr4));
134254d68b6SMasahiro Yamada DEFINE(MAX_MGPCR5, offsetof(struct max_regs, mgpcr5));
135254d68b6SMasahiro Yamada
136254d68b6SMasahiro Yamada /* AHB <-> IP-Bus Interface */
137254d68b6SMasahiro Yamada DEFINE(AIPS_MPR_0_7, offsetof(struct aips_regs, mpr_0_7));
138254d68b6SMasahiro Yamada DEFINE(AIPS_MPR_8_15, offsetof(struct aips_regs, mpr_8_15));
139254d68b6SMasahiro Yamada DEFINE(AIPS_PACR_0_7, offsetof(struct aips_regs, pacr_0_7));
140254d68b6SMasahiro Yamada DEFINE(AIPS_PACR_8_15, offsetof(struct aips_regs, pacr_8_15));
141254d68b6SMasahiro Yamada DEFINE(AIPS_PACR_16_23, offsetof(struct aips_regs, pacr_16_23));
142254d68b6SMasahiro Yamada DEFINE(AIPS_PACR_24_31, offsetof(struct aips_regs, pacr_24_31));
143254d68b6SMasahiro Yamada DEFINE(AIPS_OPACR_0_7, offsetof(struct aips_regs, opacr_0_7));
144254d68b6SMasahiro Yamada DEFINE(AIPS_OPACR_8_15, offsetof(struct aips_regs, opacr_8_15));
145254d68b6SMasahiro Yamada DEFINE(AIPS_OPACR_16_23, offsetof(struct aips_regs, opacr_16_23));
146254d68b6SMasahiro Yamada DEFINE(AIPS_OPACR_24_31, offsetof(struct aips_regs, opacr_24_31));
147254d68b6SMasahiro Yamada DEFINE(AIPS_OPACR_32_39, offsetof(struct aips_regs, opacr_32_39));
148254d68b6SMasahiro Yamada #endif
149254d68b6SMasahiro Yamada
150254d68b6SMasahiro Yamada #if defined(CONFIG_MX51) || defined(CONFIG_MX53)
151254d68b6SMasahiro Yamada /* Round up to make sure size gives nice stack alignment */
152254d68b6SMasahiro Yamada DEFINE(CLKCTL_CCMR, offsetof(struct clkctl, ccr));
153254d68b6SMasahiro Yamada DEFINE(CLKCTL_CCDR, offsetof(struct clkctl, ccdr));
154254d68b6SMasahiro Yamada DEFINE(CLKCTL_CSR, offsetof(struct clkctl, csr));
155254d68b6SMasahiro Yamada DEFINE(CLKCTL_CCSR, offsetof(struct clkctl, ccsr));
156254d68b6SMasahiro Yamada DEFINE(CLKCTL_CACRR, offsetof(struct clkctl, cacrr));
157254d68b6SMasahiro Yamada DEFINE(CLKCTL_CBCDR, offsetof(struct clkctl, cbcdr));
158254d68b6SMasahiro Yamada DEFINE(CLKCTL_CBCMR, offsetof(struct clkctl, cbcmr));
159254d68b6SMasahiro Yamada DEFINE(CLKCTL_CSCMR1, offsetof(struct clkctl, cscmr1));
160254d68b6SMasahiro Yamada DEFINE(CLKCTL_CSCMR2, offsetof(struct clkctl, cscmr2));
161254d68b6SMasahiro Yamada DEFINE(CLKCTL_CSCDR1, offsetof(struct clkctl, cscdr1));
162254d68b6SMasahiro Yamada DEFINE(CLKCTL_CS1CDR, offsetof(struct clkctl, cs1cdr));
163254d68b6SMasahiro Yamada DEFINE(CLKCTL_CS2CDR, offsetof(struct clkctl, cs2cdr));
164254d68b6SMasahiro Yamada DEFINE(CLKCTL_CDCDR, offsetof(struct clkctl, cdcdr));
165254d68b6SMasahiro Yamada DEFINE(CLKCTL_CHSCCDR, offsetof(struct clkctl, chsccdr));
166254d68b6SMasahiro Yamada DEFINE(CLKCTL_CSCDR2, offsetof(struct clkctl, cscdr2));
167254d68b6SMasahiro Yamada DEFINE(CLKCTL_CSCDR3, offsetof(struct clkctl, cscdr3));
168254d68b6SMasahiro Yamada DEFINE(CLKCTL_CSCDR4, offsetof(struct clkctl, cscdr4));
169254d68b6SMasahiro Yamada DEFINE(CLKCTL_CWDR, offsetof(struct clkctl, cwdr));
170254d68b6SMasahiro Yamada DEFINE(CLKCTL_CDHIPR, offsetof(struct clkctl, cdhipr));
171254d68b6SMasahiro Yamada DEFINE(CLKCTL_CDCR, offsetof(struct clkctl, cdcr));
172254d68b6SMasahiro Yamada DEFINE(CLKCTL_CTOR, offsetof(struct clkctl, ctor));
173254d68b6SMasahiro Yamada DEFINE(CLKCTL_CLPCR, offsetof(struct clkctl, clpcr));
174254d68b6SMasahiro Yamada DEFINE(CLKCTL_CISR, offsetof(struct clkctl, cisr));
175254d68b6SMasahiro Yamada DEFINE(CLKCTL_CIMR, offsetof(struct clkctl, cimr));
176254d68b6SMasahiro Yamada DEFINE(CLKCTL_CCOSR, offsetof(struct clkctl, ccosr));
177254d68b6SMasahiro Yamada DEFINE(CLKCTL_CGPR, offsetof(struct clkctl, cgpr));
178254d68b6SMasahiro Yamada DEFINE(CLKCTL_CCGR0, offsetof(struct clkctl, ccgr0));
179254d68b6SMasahiro Yamada DEFINE(CLKCTL_CCGR1, offsetof(struct clkctl, ccgr1));
180254d68b6SMasahiro Yamada DEFINE(CLKCTL_CCGR2, offsetof(struct clkctl, ccgr2));
181254d68b6SMasahiro Yamada DEFINE(CLKCTL_CCGR3, offsetof(struct clkctl, ccgr3));
182254d68b6SMasahiro Yamada DEFINE(CLKCTL_CCGR4, offsetof(struct clkctl, ccgr4));
183254d68b6SMasahiro Yamada DEFINE(CLKCTL_CCGR5, offsetof(struct clkctl, ccgr5));
184254d68b6SMasahiro Yamada DEFINE(CLKCTL_CCGR6, offsetof(struct clkctl, ccgr6));
185254d68b6SMasahiro Yamada DEFINE(CLKCTL_CMEOR, offsetof(struct clkctl, cmeor));
186254d68b6SMasahiro Yamada #if defined(CONFIG_MX53)
187254d68b6SMasahiro Yamada DEFINE(CLKCTL_CCGR7, offsetof(struct clkctl, ccgr7));
188254d68b6SMasahiro Yamada #endif
189254d68b6SMasahiro Yamada
190254d68b6SMasahiro Yamada /* DPLL */
191254d68b6SMasahiro Yamada DEFINE(PLL_DP_CTL, offsetof(struct dpll, dp_ctl));
192254d68b6SMasahiro Yamada DEFINE(PLL_DP_CONFIG, offsetof(struct dpll, dp_config));
193254d68b6SMasahiro Yamada DEFINE(PLL_DP_OP, offsetof(struct dpll, dp_op));
194254d68b6SMasahiro Yamada DEFINE(PLL_DP_MFD, offsetof(struct dpll, dp_mfd));
195254d68b6SMasahiro Yamada DEFINE(PLL_DP_MFN, offsetof(struct dpll, dp_mfn));
196254d68b6SMasahiro Yamada DEFINE(PLL_DP_HFS_OP, offsetof(struct dpll, dp_hfs_op));
197254d68b6SMasahiro Yamada DEFINE(PLL_DP_HFS_MFD, offsetof(struct dpll, dp_hfs_mfd));
198254d68b6SMasahiro Yamada DEFINE(PLL_DP_HFS_MFN, offsetof(struct dpll, dp_hfs_mfn));
199254d68b6SMasahiro Yamada #endif
200254d68b6SMasahiro Yamada
201c54bcf68SMasahiro Yamada #ifdef CONFIG_ARM_SMCCC
202c54bcf68SMasahiro Yamada DEFINE(ARM_SMCCC_RES_X0_OFFS, offsetof(struct arm_smccc_res, a0));
203c54bcf68SMasahiro Yamada DEFINE(ARM_SMCCC_RES_X2_OFFS, offsetof(struct arm_smccc_res, a2));
204c54bcf68SMasahiro Yamada DEFINE(ARM_SMCCC_QUIRK_ID_OFFS, offsetof(struct arm_smccc_quirk, id));
205c54bcf68SMasahiro Yamada DEFINE(ARM_SMCCC_QUIRK_STATE_OFFS, offsetof(struct arm_smccc_quirk, state));
206c54bcf68SMasahiro Yamada #endif
207c54bcf68SMasahiro Yamada
208254d68b6SMasahiro Yamada return 0;
209254d68b6SMasahiro Yamada }
210