asm-offsets.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Adapted from Linux v2.6.36 kernel: arch/powerpc/kernel/asm-offsets.c
  4. *
  5. * This program is used to generate definitions needed by
  6. * assembly language modules.
  7. *
  8. * We use the technique used in the OSF Mach kernel code:
  9. * generate asm statements containing #defines,
  10. * compile this file to assembler, and then extract the
  11. * #defines from the assembly-language output.
  12. *
  13. * Copyright 2022-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
  14. *
  15. * Authors:
  16. * Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com>
  17. */
  18. #include <common.h>
  19. #include <linux/kbuild.h>
  20. #include <linux/arm-smccc.h>
  21. #if defined(CONFIG_MX51) || defined(CONFIG_MX53)
  22. #include <asm/arch/imx-regs.h>
  23. #endif
  24. int main(void)
  25. {
  26. /*
  27. * TODO : Check if each entry in this file is really necessary.
  28. * - struct esdramc_regs
  29. * - struct max_regs
  30. * - struct aips_regs
  31. * - struct aipi_regs
  32. * - struct clkctl
  33. * - struct dpll
  34. * are used only for generating asm-offsets.h.
  35. * It means their offset addresses are referenced only from assembly
  36. * code. Is it better to define the macros directly in headers?
  37. */
  38. #if defined(CONFIG_MX51) || defined(CONFIG_MX53)
  39. /* Round up to make sure size gives nice stack alignment */
  40. DEFINE(CLKCTL_CCMR, offsetof(struct clkctl, ccr));
  41. DEFINE(CLKCTL_CCDR, offsetof(struct clkctl, ccdr));
  42. DEFINE(CLKCTL_CSR, offsetof(struct clkctl, csr));
  43. DEFINE(CLKCTL_CCSR, offsetof(struct clkctl, ccsr));
  44. DEFINE(CLKCTL_CACRR, offsetof(struct clkctl, cacrr));
  45. DEFINE(CLKCTL_CBCDR, offsetof(struct clkctl, cbcdr));
  46. DEFINE(CLKCTL_CBCMR, offsetof(struct clkctl, cbcmr));
  47. DEFINE(CLKCTL_CSCMR1, offsetof(struct clkctl, cscmr1));
  48. DEFINE(CLKCTL_CSCMR2, offsetof(struct clkctl, cscmr2));
  49. DEFINE(CLKCTL_CSCDR1, offsetof(struct clkctl, cscdr1));
  50. DEFINE(CLKCTL_CS1CDR, offsetof(struct clkctl, cs1cdr));
  51. DEFINE(CLKCTL_CS2CDR, offsetof(struct clkctl, cs2cdr));
  52. DEFINE(CLKCTL_CDCDR, offsetof(struct clkctl, cdcdr));
  53. DEFINE(CLKCTL_CHSCCDR, offsetof(struct clkctl, chsccdr));
  54. DEFINE(CLKCTL_CSCDR2, offsetof(struct clkctl, cscdr2));
  55. DEFINE(CLKCTL_CSCDR3, offsetof(struct clkctl, cscdr3));
  56. DEFINE(CLKCTL_CSCDR4, offsetof(struct clkctl, cscdr4));
  57. DEFINE(CLKCTL_CWDR, offsetof(struct clkctl, cwdr));
  58. DEFINE(CLKCTL_CDHIPR, offsetof(struct clkctl, cdhipr));
  59. DEFINE(CLKCTL_CDCR, offsetof(struct clkctl, cdcr));
  60. DEFINE(CLKCTL_CTOR, offsetof(struct clkctl, ctor));
  61. DEFINE(CLKCTL_CLPCR, offsetof(struct clkctl, clpcr));
  62. DEFINE(CLKCTL_CISR, offsetof(struct clkctl, cisr));
  63. DEFINE(CLKCTL_CIMR, offsetof(struct clkctl, cimr));
  64. DEFINE(CLKCTL_CCOSR, offsetof(struct clkctl, ccosr));
  65. DEFINE(CLKCTL_CGPR, offsetof(struct clkctl, cgpr));
  66. DEFINE(CLKCTL_CCGR0, offsetof(struct clkctl, ccgr0));
  67. DEFINE(CLKCTL_CCGR1, offsetof(struct clkctl, ccgr1));
  68. DEFINE(CLKCTL_CCGR2, offsetof(struct clkctl, ccgr2));
  69. DEFINE(CLKCTL_CCGR3, offsetof(struct clkctl, ccgr3));
  70. DEFINE(CLKCTL_CCGR4, offsetof(struct clkctl, ccgr4));
  71. DEFINE(CLKCTL_CCGR5, offsetof(struct clkctl, ccgr5));
  72. DEFINE(CLKCTL_CCGR6, offsetof(struct clkctl, ccgr6));
  73. DEFINE(CLKCTL_CMEOR, offsetof(struct clkctl, cmeor));
  74. #if defined(CONFIG_MX53)
  75. DEFINE(CLKCTL_CCGR7, offsetof(struct clkctl, ccgr7));
  76. #endif
  77. /* DPLL */
  78. DEFINE(PLL_DP_CTL, offsetof(struct dpll, dp_ctl));
  79. DEFINE(PLL_DP_CONFIG, offsetof(struct dpll, dp_config));
  80. DEFINE(PLL_DP_OP, offsetof(struct dpll, dp_op));
  81. DEFINE(PLL_DP_MFD, offsetof(struct dpll, dp_mfd));
  82. DEFINE(PLL_DP_MFN, offsetof(struct dpll, dp_mfn));
  83. DEFINE(PLL_DP_HFS_OP, offsetof(struct dpll, dp_hfs_op));
  84. DEFINE(PLL_DP_HFS_MFD, offsetof(struct dpll, dp_hfs_mfd));
  85. DEFINE(PLL_DP_HFS_MFN, offsetof(struct dpll, dp_hfs_mfn));
  86. #endif
  87. #ifdef CONFIG_ARM_SMCCC
  88. DEFINE(ARM_SMCCC_RES_X0_OFFS, offsetof(struct arm_smccc_res, a0));
  89. DEFINE(ARM_SMCCC_RES_X2_OFFS, offsetof(struct arm_smccc_res, a2));
  90. DEFINE(ARM_SMCCC_QUIRK_ID_OFFS, offsetof(struct arm_smccc_quirk, id));
  91. DEFINE(ARM_SMCCC_QUIRK_STATE_OFFS, offsetof(struct arm_smccc_quirk, state));
  92. #ifdef CONFIG_ARM64
  93. DEFINE(ARM_SMCCC_1_2_REGS_X0_OFFS, offsetof(struct arm_smccc_1_2_regs, a0));
  94. DEFINE(ARM_SMCCC_1_2_REGS_X2_OFFS, offsetof(struct arm_smccc_1_2_regs, a2));
  95. DEFINE(ARM_SMCCC_1_2_REGS_X4_OFFS, offsetof(struct arm_smccc_1_2_regs, a4));
  96. DEFINE(ARM_SMCCC_1_2_REGS_X6_OFFS, offsetof(struct arm_smccc_1_2_regs, a6));
  97. DEFINE(ARM_SMCCC_1_2_REGS_X8_OFFS, offsetof(struct arm_smccc_1_2_regs, a8));
  98. DEFINE(ARM_SMCCC_1_2_REGS_X10_OFFS, offsetof(struct arm_smccc_1_2_regs, a10));
  99. DEFINE(ARM_SMCCC_1_2_REGS_X12_OFFS, offsetof(struct arm_smccc_1_2_regs, a12));
  100. DEFINE(ARM_SMCCC_1_2_REGS_X14_OFFS, offsetof(struct arm_smccc_1_2_regs, a14));
  101. DEFINE(ARM_SMCCC_1_2_REGS_X16_OFFS, offsetof(struct arm_smccc_1_2_regs, a16));
  102. #endif
  103. #endif
  104. return 0;
  105. }