io.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /* arch/arm/mach-msm/io.c
  2. *
  3. * MSM7K, QSD io support
  4. *
  5. * Copyright (C) 2007 Google, Inc.
  6. * Copyright (c) 2008-2010, 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_DEVICE(name) { \
  28. .virtual = (unsigned long) MSM_##name##_BASE, \
  29. .pfn = __phys_to_pfn(MSM_##name##_PHYS), \
  30. .length = MSM_##name##_SIZE, \
  31. .type = MT_DEVICE_NONSHARED, \
  32. }
  33. #if defined(CONFIG_ARCH_MSM7X00A) || defined(CONFIG_ARCH_MSM7X27) \
  34. || defined(CONFIG_ARCH_MSM7X25)
  35. static struct map_desc msm_io_desc[] __initdata = {
  36. MSM_DEVICE(VIC),
  37. MSM_DEVICE(CSR),
  38. MSM_DEVICE(GPT),
  39. MSM_DEVICE(DMOV),
  40. MSM_DEVICE(GPIO1),
  41. MSM_DEVICE(GPIO2),
  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_DEVICE(CSR),
  70. MSM_DEVICE(TMR),
  71. MSM_DEVICE(DMOV),
  72. MSM_DEVICE(GPIO1),
  73. MSM_DEVICE(GPIO2),
  74. MSM_DEVICE(CLK_CTL),
  75. MSM_DEVICE(SIRC),
  76. MSM_DEVICE(SCPLL),
  77. MSM_DEVICE(AD5),
  78. MSM_DEVICE(MDC),
  79. #ifdef CONFIG_MSM_DEBUG_UART
  80. MSM_DEVICE(DEBUG_UART),
  81. #endif
  82. {
  83. .virtual = (unsigned long) MSM_SHARED_RAM_BASE,
  84. .pfn = __phys_to_pfn(MSM_SHARED_RAM_PHYS),
  85. .length = MSM_SHARED_RAM_SIZE,
  86. .type = MT_DEVICE,
  87. },
  88. };
  89. void __init msm_map_qsd8x50_io(void)
  90. {
  91. iotable_init(qsd8x50_io_desc, ARRAY_SIZE(qsd8x50_io_desc));
  92. }
  93. #endif /* CONFIG_ARCH_QSD8X50 */
  94. #ifdef CONFIG_ARCH_MSM7X30
  95. static struct map_desc msm7x30_io_desc[] __initdata = {
  96. MSM_DEVICE(VIC),
  97. MSM_DEVICE(CSR),
  98. MSM_DEVICE(TMR),
  99. MSM_DEVICE(DMOV),
  100. MSM_DEVICE(GPIO1),
  101. MSM_DEVICE(GPIO2),
  102. MSM_DEVICE(CLK_CTL),
  103. MSM_DEVICE(CLK_CTL_SH2),
  104. MSM_DEVICE(AD5),
  105. MSM_DEVICE(MDC),
  106. MSM_DEVICE(ACC),
  107. MSM_DEVICE(SAW),
  108. MSM_DEVICE(GCC),
  109. MSM_DEVICE(TCSR),
  110. #ifdef CONFIG_MSM_DEBUG_UART
  111. MSM_DEVICE(DEBUG_UART),
  112. #endif
  113. {
  114. .virtual = (unsigned long) MSM_SHARED_RAM_BASE,
  115. .pfn = __phys_to_pfn(MSM_SHARED_RAM_PHYS),
  116. .length = MSM_SHARED_RAM_SIZE,
  117. .type = MT_DEVICE,
  118. },
  119. };
  120. void __init msm_map_msm7x30_io(void)
  121. {
  122. iotable_init(msm7x30_io_desc, ARRAY_SIZE(msm7x30_io_desc));
  123. }
  124. #endif /* CONFIG_ARCH_MSM7X30 */
  125. void __iomem *
  126. __msm_ioremap(unsigned long phys_addr, size_t size, unsigned int mtype)
  127. {
  128. if (mtype == MT_DEVICE) {
  129. /* The peripherals in the 88000000 - D0000000 range
  130. * are only accessable by type MT_DEVICE_NONSHARED.
  131. * Adjust mtype as necessary to make this "just work."
  132. */
  133. if ((phys_addr >= 0x88000000) && (phys_addr < 0xD0000000))
  134. mtype = MT_DEVICE_NONSHARED;
  135. }
  136. return __arm_ioremap_caller(phys_addr, size, mtype,
  137. __builtin_return_address(0));
  138. }