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