io.c 3.8 KB

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