mxs.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * Copyright (C) 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. */
  18. #ifndef __MACH_MXS_H__
  19. #define __MACH_MXS_H__
  20. #ifndef __ASSEMBLER__
  21. #include <linux/io.h>
  22. #endif
  23. #include <asm/mach-types.h>
  24. #include <mach/digctl.h>
  25. #include <mach/hardware.h>
  26. /*
  27. * IO addresses common to MXS-based
  28. */
  29. #define MXS_IO_BASE_ADDR 0x80000000
  30. #define MXS_IO_SIZE SZ_1M
  31. #define MXS_ICOLL_BASE_ADDR (MXS_IO_BASE_ADDR + 0x000000)
  32. #define MXS_APBH_DMA_BASE_ADDR (MXS_IO_BASE_ADDR + 0x004000)
  33. #define MXS_BCH_BASE_ADDR (MXS_IO_BASE_ADDR + 0x00a000)
  34. #define MXS_GPMI_BASE_ADDR (MXS_IO_BASE_ADDR + 0x00c000)
  35. #define MXS_PINCTRL_BASE_ADDR (MXS_IO_BASE_ADDR + 0x018000)
  36. #define MXS_DIGCTL_BASE_ADDR (MXS_IO_BASE_ADDR + 0x01c000)
  37. #define MXS_APBX_DMA_BASE_ADDR (MXS_IO_BASE_ADDR + 0x024000)
  38. #define MXS_DCP_BASE_ADDR (MXS_IO_BASE_ADDR + 0x028000)
  39. #define MXS_PXP_BASE_ADDR (MXS_IO_BASE_ADDR + 0x02a000)
  40. #define MXS_OCOTP_BASE_ADDR (MXS_IO_BASE_ADDR + 0x02c000)
  41. #define MXS_AXI_AHB0_BASE_ADDR (MXS_IO_BASE_ADDR + 0x02e000)
  42. #define MXS_LCDIF_BASE_ADDR (MXS_IO_BASE_ADDR + 0x030000)
  43. #define MXS_CLKCTRL_BASE_ADDR (MXS_IO_BASE_ADDR + 0x040000)
  44. #define MXS_SAIF0_BASE_ADDR (MXS_IO_BASE_ADDR + 0x042000)
  45. #define MXS_POWER_BASE_ADDR (MXS_IO_BASE_ADDR + 0x044000)
  46. #define MXS_SAIF1_BASE_ADDR (MXS_IO_BASE_ADDR + 0x046000)
  47. #define MXS_LRADC_BASE_ADDR (MXS_IO_BASE_ADDR + 0x050000)
  48. #define MXS_SPDIF_BASE_ADDR (MXS_IO_BASE_ADDR + 0x054000)
  49. #define MXS_I2C0_BASE_ADDR (MXS_IO_BASE_ADDR + 0x058000)
  50. #define MXS_PWM_BASE_ADDR (MXS_IO_BASE_ADDR + 0x064000)
  51. #define MXS_TIMROT_BASE_ADDR (MXS_IO_BASE_ADDR + 0x068000)
  52. #define MXS_AUART1_BASE_ADDR (MXS_IO_BASE_ADDR + 0x06c000)
  53. #define MXS_AUART2_BASE_ADDR (MXS_IO_BASE_ADDR + 0x06e000)
  54. #define MXS_DRAM_BASE_ADDR (MXS_IO_BASE_ADDR + 0x0e0000)
  55. /*
  56. * It maps the whole address space to [0xf4000000, 0xf50fffff].
  57. *
  58. * OCRAM 0x00000000+0x020000 -> 0xf4000000+0x020000
  59. * IO 0x80000000+0x100000 -> 0xf5000000+0x100000
  60. */
  61. #define MXS_IO_P2V(x) (0xf4000000 + \
  62. (((x) & 0x80000000) >> 7) + \
  63. (((x) & 0x000fffff)))
  64. #define MXS_IO_ADDRESS(x) IOMEM(MXS_IO_P2V(x))
  65. #define mxs_map_entry(soc, name, _type) { \
  66. .virtual = soc ## _IO_P2V(soc ## _ ## name ## _BASE_ADDR), \
  67. .pfn = __phys_to_pfn(soc ## _ ## name ## _BASE_ADDR), \
  68. .length = soc ## _ ## name ## _SIZE, \
  69. .type = _type, \
  70. }
  71. #define MXS_GPIO_NR(bank, nr) ((bank) * 32 + (nr))
  72. #define MXS_SET_ADDR 0x4
  73. #define MXS_CLR_ADDR 0x8
  74. #define MXS_TOG_ADDR 0xc
  75. #ifndef __ASSEMBLER__
  76. static inline void __mxs_setl(u32 mask, void __iomem *reg)
  77. {
  78. __raw_writel(mask, reg + MXS_SET_ADDR);
  79. }
  80. static inline void __mxs_clrl(u32 mask, void __iomem *reg)
  81. {
  82. __raw_writel(mask, reg + MXS_CLR_ADDR);
  83. }
  84. static inline void __mxs_togl(u32 mask, void __iomem *reg)
  85. {
  86. __raw_writel(mask, reg + MXS_TOG_ADDR);
  87. }
  88. /*
  89. * MXS CPU types
  90. */
  91. #define MXS_CHIPID (MXS_IO_ADDRESS(MXS_DIGCTL_BASE_ADDR) + HW_DIGCTL_CHIPID)
  92. static inline int cpu_is_mx23(void)
  93. {
  94. return ((__raw_readl(MXS_CHIPID) >> 16) == 0x3780);
  95. }
  96. static inline int cpu_is_mx28(void)
  97. {
  98. return ((__raw_readl(MXS_CHIPID) >> 16) == 0x2800);
  99. }
  100. #endif
  101. #endif /* __MACH_MXS_H__ */