io.c 3.7 KB

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