io.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. * linux/arch/arm/mach-omap1/io.c
  3. *
  4. * OMAP1 I/O mapping code
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/module.h>
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/io.h>
  14. #include <asm/tlb.h>
  15. #include <asm/mach/map.h>
  16. #include <plat/mux.h>
  17. #include <plat/tc.h>
  18. #include "clock.h"
  19. extern void omap_check_revision(void);
  20. /*
  21. * The machine specific code may provide the extra mapping besides the
  22. * default mapping provided here.
  23. */
  24. static struct map_desc omap_io_desc[] __initdata = {
  25. {
  26. .virtual = OMAP1_IO_VIRT,
  27. .pfn = __phys_to_pfn(OMAP1_IO_PHYS),
  28. .length = OMAP1_IO_SIZE,
  29. .type = MT_DEVICE
  30. }
  31. };
  32. #if defined (CONFIG_ARCH_OMAP730) || defined (CONFIG_ARCH_OMAP850)
  33. static struct map_desc omap7xx_io_desc[] __initdata = {
  34. {
  35. .virtual = OMAP7XX_DSP_BASE,
  36. .pfn = __phys_to_pfn(OMAP7XX_DSP_START),
  37. .length = OMAP7XX_DSP_SIZE,
  38. .type = MT_DEVICE
  39. }, {
  40. .virtual = OMAP7XX_DSPREG_BASE,
  41. .pfn = __phys_to_pfn(OMAP7XX_DSPREG_START),
  42. .length = OMAP7XX_DSPREG_SIZE,
  43. .type = MT_DEVICE
  44. }
  45. };
  46. #endif
  47. #ifdef CONFIG_ARCH_OMAP15XX
  48. static struct map_desc omap1510_io_desc[] __initdata = {
  49. {
  50. .virtual = OMAP1510_DSP_BASE,
  51. .pfn = __phys_to_pfn(OMAP1510_DSP_START),
  52. .length = OMAP1510_DSP_SIZE,
  53. .type = MT_DEVICE
  54. }, {
  55. .virtual = OMAP1510_DSPREG_BASE,
  56. .pfn = __phys_to_pfn(OMAP1510_DSPREG_START),
  57. .length = OMAP1510_DSPREG_SIZE,
  58. .type = MT_DEVICE
  59. }
  60. };
  61. #endif
  62. #if defined(CONFIG_ARCH_OMAP16XX)
  63. static struct map_desc omap16xx_io_desc[] __initdata = {
  64. {
  65. .virtual = OMAP16XX_DSP_BASE,
  66. .pfn = __phys_to_pfn(OMAP16XX_DSP_START),
  67. .length = OMAP16XX_DSP_SIZE,
  68. .type = MT_DEVICE
  69. }, {
  70. .virtual = OMAP16XX_DSPREG_BASE,
  71. .pfn = __phys_to_pfn(OMAP16XX_DSPREG_START),
  72. .length = OMAP16XX_DSPREG_SIZE,
  73. .type = MT_DEVICE
  74. }
  75. };
  76. #endif
  77. /*
  78. * Maps common IO regions for omap1
  79. */
  80. static void __init omap1_map_common_io(void)
  81. {
  82. iotable_init(omap_io_desc, ARRAY_SIZE(omap_io_desc));
  83. }
  84. #if defined (CONFIG_ARCH_OMAP730) || defined (CONFIG_ARCH_OMAP850)
  85. void __init omap7xx_map_io(void)
  86. {
  87. omap1_map_common_io();
  88. iotable_init(omap7xx_io_desc, ARRAY_SIZE(omap7xx_io_desc));
  89. }
  90. #endif
  91. #ifdef CONFIG_ARCH_OMAP15XX
  92. void __init omap15xx_map_io(void)
  93. {
  94. omap1_map_common_io();
  95. iotable_init(omap1510_io_desc, ARRAY_SIZE(omap1510_io_desc));
  96. }
  97. #endif
  98. #if defined(CONFIG_ARCH_OMAP16XX)
  99. void __init omap16xx_map_io(void)
  100. {
  101. omap1_map_common_io();
  102. iotable_init(omap16xx_io_desc, ARRAY_SIZE(omap16xx_io_desc));
  103. }
  104. #endif
  105. /*
  106. * Common low-level hardware init for omap1.
  107. */
  108. void omap1_init_early(void)
  109. {
  110. omap_check_revision();
  111. /* REVISIT: Refer to OMAP5910 Errata, Advisory SYS_1: "Timeout Abort
  112. * on a Posted Write in the TIPB Bridge".
  113. */
  114. omap_writew(0x0, MPU_PUBLIC_TIPB_CNTL);
  115. omap_writew(0x0, MPU_PRIVATE_TIPB_CNTL);
  116. /* Must init clocks early to assure that timer interrupt works
  117. */
  118. omap1_clk_init();
  119. omap1_mux_init();
  120. omap_init_consistent_dma_size();
  121. }
  122. /*
  123. * NOTE: Please use ioremap + __raw_read/write where possible instead of these
  124. */
  125. u8 omap_readb(u32 pa)
  126. {
  127. return __raw_readb(OMAP1_IO_ADDRESS(pa));
  128. }
  129. EXPORT_SYMBOL(omap_readb);
  130. u16 omap_readw(u32 pa)
  131. {
  132. return __raw_readw(OMAP1_IO_ADDRESS(pa));
  133. }
  134. EXPORT_SYMBOL(omap_readw);
  135. u32 omap_readl(u32 pa)
  136. {
  137. return __raw_readl(OMAP1_IO_ADDRESS(pa));
  138. }
  139. EXPORT_SYMBOL(omap_readl);
  140. void omap_writeb(u8 v, u32 pa)
  141. {
  142. __raw_writeb(v, OMAP1_IO_ADDRESS(pa));
  143. }
  144. EXPORT_SYMBOL(omap_writeb);
  145. void omap_writew(u16 v, u32 pa)
  146. {
  147. __raw_writew(v, OMAP1_IO_ADDRESS(pa));
  148. }
  149. EXPORT_SYMBOL(omap_writew);
  150. void omap_writel(u32 v, u32 pa)
  151. {
  152. __raw_writel(v, OMAP1_IO_ADDRESS(pa));
  153. }
  154. EXPORT_SYMBOL(omap_writel);