io.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /* arch/arm/mach-msm/io.c
  2. *
  3. * MSM7K, QSD io support
  4. *
  5. * Copyright (C) 2007 Google, Inc.
  6. * Copyright (c) 2008-2011, Code Aurora Forum. All rights reserved.
  7. * Author: Brian Swetland <swetland@google.com>
  8. *
  9. * This software is licensed under the terms of the GNU General Public
  10. * License version 2, as published by the Free Software Foundation, and
  11. * may be copied, distributed, and modified under those terms.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. */
  19. #include <linux/kernel.h>
  20. #include <linux/init.h>
  21. #include <linux/io.h>
  22. #include <mach/hardware.h>
  23. #include <asm/page.h>
  24. #include <mach/msm_iomap.h>
  25. #include <asm/mach/map.h>
  26. #include <mach/board.h>
  27. #define MSM_CHIP_DEVICE(name, chip) { \
  28. .virtual = (unsigned long) MSM_##name##_BASE, \
  29. .pfn = __phys_to_pfn(chip##_##name##_PHYS), \
  30. .length = chip##_##name##_SIZE, \
  31. .type = MT_DEVICE_NONSHARED, \
  32. }
  33. #define MSM_DEVICE(name) MSM_CHIP_DEVICE(name, MSM)
  34. #if defined(CONFIG_ARCH_MSM7X00A) || defined(CONFIG_ARCH_MSM7X27) \
  35. || defined(CONFIG_ARCH_MSM7X25)
  36. static struct map_desc msm_io_desc[] __initdata = {
  37. MSM_DEVICE(VIC),
  38. MSM_CHIP_DEVICE(CSR, MSM7X00),
  39. MSM_DEVICE(DMOV),
  40. MSM_CHIP_DEVICE(GPIO1, MSM7X00),
  41. MSM_CHIP_DEVICE(GPIO2, MSM7X00),
  42. MSM_DEVICE(CLK_CTL),
  43. #ifdef CONFIG_MSM_DEBUG_UART
  44. MSM_DEVICE(DEBUG_UART),
  45. #endif
  46. #ifdef CONFIG_ARCH_MSM7X30
  47. MSM_DEVICE(GCC),
  48. #endif
  49. {
  50. .virtual = (unsigned long) MSM_SHARED_RAM_BASE,
  51. .pfn = __phys_to_pfn(MSM_SHARED_RAM_PHYS),
  52. .length = MSM_SHARED_RAM_SIZE,
  53. .type = MT_DEVICE,
  54. },
  55. };
  56. void __init msm_map_common_io(void)
  57. {
  58. /* Make sure the peripheral register window is closed, since
  59. * we will use PTE flags (TEX[1]=1,B=0,C=1) to determine which
  60. * pages are peripheral interface or not.
  61. */
  62. asm("mcr p15, 0, %0, c15, c2, 4" : : "r" (0));
  63. iotable_init(msm_io_desc, ARRAY_SIZE(msm_io_desc));
  64. }
  65. #endif
  66. #ifdef CONFIG_ARCH_QSD8X50
  67. static struct map_desc qsd8x50_io_desc[] __initdata = {
  68. MSM_DEVICE(VIC),
  69. MSM_CHIP_DEVICE(CSR, QSD8X50),
  70. MSM_DEVICE(DMOV),
  71. MSM_CHIP_DEVICE(GPIO1, QSD8X50),
  72. MSM_CHIP_DEVICE(GPIO2, QSD8X50),
  73. MSM_DEVICE(CLK_CTL),
  74. MSM_DEVICE(SIRC),
  75. MSM_DEVICE(SCPLL),
  76. MSM_DEVICE(AD5),
  77. MSM_DEVICE(MDC),
  78. #ifdef CONFIG_MSM_DEBUG_UART
  79. MSM_DEVICE(DEBUG_UART),
  80. #endif
  81. {
  82. .virtual = (unsigned long) MSM_SHARED_RAM_BASE,
  83. .pfn = __phys_to_pfn(MSM_SHARED_RAM_PHYS),
  84. .length = MSM_SHARED_RAM_SIZE,
  85. .type = MT_DEVICE,
  86. },
  87. };
  88. void __init msm_map_qsd8x50_io(void)
  89. {
  90. iotable_init(qsd8x50_io_desc, ARRAY_SIZE(qsd8x50_io_desc));
  91. }
  92. #endif /* CONFIG_ARCH_QSD8X50 */
  93. #ifdef CONFIG_ARCH_MSM8X60
  94. static struct map_desc msm8x60_io_desc[] __initdata = {
  95. MSM_CHIP_DEVICE(QGIC_DIST, MSM8X60),
  96. MSM_CHIP_DEVICE(QGIC_CPU, MSM8X60),
  97. MSM_CHIP_DEVICE(TMR, MSM8X60),
  98. MSM_CHIP_DEVICE(TMR0, MSM8X60),
  99. MSM_DEVICE(ACC),
  100. MSM_DEVICE(GCC),
  101. };
  102. void __init msm_map_msm8x60_io(void)
  103. {
  104. iotable_init(msm8x60_io_desc, ARRAY_SIZE(msm8x60_io_desc));
  105. }
  106. #endif /* CONFIG_ARCH_MSM8X60 */
  107. #ifdef CONFIG_ARCH_MSM8960
  108. static struct map_desc msm8960_io_desc[] __initdata = {
  109. MSM_CHIP_DEVICE(QGIC_DIST, MSM8960),
  110. MSM_CHIP_DEVICE(QGIC_CPU, MSM8960),
  111. MSM_CHIP_DEVICE(TMR, MSM8960),
  112. MSM_CHIP_DEVICE(TMR0, MSM8960),
  113. };
  114. void __init msm_map_msm8960_io(void)
  115. {
  116. iotable_init(msm8960_io_desc, ARRAY_SIZE(msm8960_io_desc));
  117. }
  118. #endif /* CONFIG_ARCH_MSM8960 */
  119. #ifdef CONFIG_ARCH_MSM7X30
  120. static struct map_desc msm7x30_io_desc[] __initdata = {
  121. MSM_DEVICE(VIC),
  122. MSM_CHIP_DEVICE(CSR, MSM7X30),
  123. MSM_DEVICE(DMOV),
  124. MSM_CHIP_DEVICE(GPIO1, MSM7X30),
  125. MSM_CHIP_DEVICE(GPIO2, MSM7X30),
  126. MSM_DEVICE(CLK_CTL),
  127. MSM_DEVICE(CLK_CTL_SH2),
  128. MSM_DEVICE(AD5),
  129. MSM_DEVICE(MDC),
  130. MSM_DEVICE(ACC),
  131. MSM_DEVICE(SAW),
  132. MSM_DEVICE(GCC),
  133. MSM_DEVICE(TCSR),
  134. #ifdef CONFIG_MSM_DEBUG_UART
  135. MSM_DEVICE(DEBUG_UART),
  136. #endif
  137. {
  138. .virtual = (unsigned long) MSM_SHARED_RAM_BASE,
  139. .pfn = __phys_to_pfn(MSM_SHARED_RAM_PHYS),
  140. .length = MSM_SHARED_RAM_SIZE,
  141. .type = MT_DEVICE,
  142. },
  143. };
  144. void __init msm_map_msm7x30_io(void)
  145. {
  146. iotable_init(msm7x30_io_desc, ARRAY_SIZE(msm7x30_io_desc));
  147. }
  148. #endif /* CONFIG_ARCH_MSM7X30 */
  149. void __iomem *
  150. __msm_ioremap(unsigned long phys_addr, size_t size, unsigned int mtype)
  151. {
  152. if (mtype == MT_DEVICE) {
  153. /* The peripherals in the 88000000 - D0000000 range
  154. * are only accessible by type MT_DEVICE_NONSHARED.
  155. * Adjust mtype as necessary to make this "just work."
  156. */
  157. if ((phys_addr >= 0x88000000) && (phys_addr < 0xD0000000))
  158. mtype = MT_DEVICE_NONSHARED;
  159. }
  160. return __arm_ioremap_caller(phys_addr, size, mtype,
  161. __builtin_return_address(0));
  162. }
  163. EXPORT_SYMBOL(__msm_ioremap);