hardware.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright 2004-2007, 2014 Freescale Semiconductor, Inc. All Rights Reserved.
  4. * Copyright 2008 Juergen Beisert, [email protected]
  5. */
  6. #ifndef __ASM_ARCH_MXC_HARDWARE_H__
  7. #define __ASM_ARCH_MXC_HARDWARE_H__
  8. #ifndef __ASSEMBLY__
  9. #include <asm/io.h>
  10. #include <soc/imx/revision.h>
  11. #endif
  12. #include <linux/sizes.h>
  13. #define addr_in_module(addr, mod) \
  14. ((unsigned long)(addr) - mod ## _BASE_ADDR < mod ## _SIZE)
  15. #define IMX_IO_P2V_MODULE(addr, module) \
  16. (((addr) - module ## _BASE_ADDR) < module ## _SIZE ? \
  17. (addr) - (module ## _BASE_ADDR) + (module ## _BASE_ADDR_VIRT) : 0)
  18. /*
  19. * This is rather complicated for humans and ugly to verify, but for a machine
  20. * it's OK. Still more as it is usually only applied to constants. The upsides
  21. * on using this approach are:
  22. *
  23. * - same mapping on all i.MX machines
  24. * - works for assembler, too
  25. * - no need to nurture #defines for virtual addresses
  26. *
  27. * The downside it, it's hard to verify (but I have a script for that).
  28. *
  29. * Obviously this needs to be injective for each SoC. In general it maps the
  30. * whole address space to [0xf4000000, 0xf5ffffff]. So [0xf6000000,0xfeffffff]
  31. * is free for per-machine use (e.g. KZM_ARM11_01 uses 64MiB there).
  32. *
  33. * It applies the following mappings for the different SoCs:
  34. *
  35. * mx1:
  36. * IO 0x00200000+0x100000 -> 0xf4000000+0x100000
  37. * mx21:
  38. * AIPI 0x10000000+0x100000 -> 0xf4400000+0x100000
  39. * SAHB1 0x80000000+0x100000 -> 0xf5000000+0x100000
  40. * X_MEMC 0xdf000000+0x004000 -> 0xf5f00000+0x004000
  41. * mx25:
  42. * AIPS1 0x43f00000+0x100000 -> 0xf5300000+0x100000
  43. * AIPS2 0x53f00000+0x100000 -> 0xf5700000+0x100000
  44. * AVIC 0x68000000+0x100000 -> 0xf5800000+0x100000
  45. * mx27:
  46. * AIPI 0x10000000+0x100000 -> 0xf4400000+0x100000
  47. * SAHB1 0x80000000+0x100000 -> 0xf5000000+0x100000
  48. * X_MEMC 0xd8000000+0x100000 -> 0xf5c00000+0x100000
  49. * mx31:
  50. * AIPS1 0x43f00000+0x100000 -> 0xf5300000+0x100000
  51. * AIPS2 0x53f00000+0x100000 -> 0xf5700000+0x100000
  52. * AVIC 0x68000000+0x100000 -> 0xf5800000+0x100000
  53. * X_MEMC 0xb8000000+0x010000 -> 0xf5c00000+0x010000
  54. * SPBA0 0x50000000+0x100000 -> 0xf5400000+0x100000
  55. * mx35:
  56. * AIPS1 0x43f00000+0x100000 -> 0xf5300000+0x100000
  57. * AIPS2 0x53f00000+0x100000 -> 0xf5700000+0x100000
  58. * AVIC 0x68000000+0x100000 -> 0xf5800000+0x100000
  59. * X_MEMC 0xb8000000+0x010000 -> 0xf5c00000+0x010000
  60. * SPBA0 0x50000000+0x100000 -> 0xf5400000+0x100000
  61. * mx51:
  62. * TZIC 0x0fffc000+0x004000 -> 0xf4bfc000+0x004000
  63. * IRAM 0x1ffe0000+0x020000 -> 0xf4fe0000+0x020000
  64. * DEBUG 0x60000000+0x100000 -> 0xf5000000+0x100000
  65. * SPBA0 0x70000000+0x100000 -> 0xf5400000+0x100000
  66. * AIPS1 0x73f00000+0x100000 -> 0xf5700000+0x100000
  67. * AIPS2 0x83f00000+0x100000 -> 0xf5300000+0x100000
  68. * mx53:
  69. * TZIC 0x0fffc000+0x004000 -> 0xf4bfc000+0x004000
  70. * DEBUG 0x40000000+0x100000 -> 0xf5000000+0x100000
  71. * SPBA0 0x50000000+0x100000 -> 0xf5400000+0x100000
  72. * AIPS1 0x53f00000+0x100000 -> 0xf5700000+0x100000
  73. * AIPS2 0x63f00000+0x100000 -> 0xf5300000+0x100000
  74. * mx6q:
  75. * SCU 0x00a00000+0x004000 -> 0xf4000000+0x004000
  76. * CCM 0x020c4000+0x004000 -> 0xf42c4000+0x004000
  77. * ANATOP 0x020c8000+0x004000 -> 0xf42c8000+0x004000
  78. * UART4 0x021f0000+0x004000 -> 0xf42f0000+0x004000
  79. */
  80. #define IMX_IO_P2V(x) ( \
  81. (((x) & 0x80000000) >> 7) | \
  82. (0xf4000000 + \
  83. (((x) & 0x50000000) >> 6) + \
  84. (((x) & 0x0b000000) >> 4) + \
  85. (((x) & 0x000fffff))))
  86. #define IMX_IO_ADDRESS(x) IOMEM(IMX_IO_P2V(x))
  87. #include "mxc.h"
  88. #include "mx3x.h"
  89. #include "mx31.h"
  90. #include "mx35.h"
  91. #include "mx2x.h"
  92. #include "mx27.h"
  93. #define imx_map_entry(soc, name, _type) { \
  94. .virtual = soc ## _IO_P2V(soc ## _ ## name ## _BASE_ADDR), \
  95. .pfn = __phys_to_pfn(soc ## _ ## name ## _BASE_ADDR), \
  96. .length = soc ## _ ## name ## _SIZE, \
  97. .type = _type, \
  98. }
  99. #endif /* __ASM_ARCH_MXC_HARDWARE_H__ */