io.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/arch/arm/mach-omap1/io.c
  4. *
  5. * OMAP1 I/O mapping code
  6. */
  7. #include <linux/module.h>
  8. #include <linux/kernel.h>
  9. #include <linux/init.h>
  10. #include <linux/io.h>
  11. #include <linux/omap-dma.h>
  12. #include <asm/tlb.h>
  13. #include <asm/mach/map.h>
  14. #include "tc.h"
  15. #include "iomap.h"
  16. #include "common.h"
  17. /*
  18. * The machine specific code may provide the extra mapping besides the
  19. * default mapping provided here.
  20. */
  21. #if defined (CONFIG_ARCH_OMAP730) || defined (CONFIG_ARCH_OMAP850)
  22. static struct map_desc omap7xx_io_desc[] __initdata = {
  23. {
  24. .virtual = OMAP1_IO_VIRT,
  25. .pfn = __phys_to_pfn(OMAP1_IO_PHYS),
  26. .length = OMAP1_IO_SIZE,
  27. .type = MT_DEVICE
  28. },
  29. {
  30. .virtual = OMAP7XX_DSP_BASE,
  31. .pfn = __phys_to_pfn(OMAP7XX_DSP_START),
  32. .length = OMAP7XX_DSP_SIZE,
  33. .type = MT_DEVICE
  34. }, {
  35. .virtual = OMAP7XX_DSPREG_BASE,
  36. .pfn = __phys_to_pfn(OMAP7XX_DSPREG_START),
  37. .length = OMAP7XX_DSPREG_SIZE,
  38. .type = MT_DEVICE
  39. }
  40. };
  41. #endif
  42. #ifdef CONFIG_ARCH_OMAP15XX
  43. static struct map_desc omap1510_io_desc[] __initdata = {
  44. {
  45. .virtual = OMAP1_IO_VIRT,
  46. .pfn = __phys_to_pfn(OMAP1_IO_PHYS),
  47. .length = OMAP1_IO_SIZE,
  48. .type = MT_DEVICE
  49. },
  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 = OMAP1_IO_VIRT,
  67. .pfn = __phys_to_pfn(OMAP1_IO_PHYS),
  68. .length = OMAP1_IO_SIZE,
  69. .type = MT_DEVICE
  70. },
  71. {
  72. .virtual = OMAP16XX_DSP_BASE,
  73. .pfn = __phys_to_pfn(OMAP16XX_DSP_START),
  74. .length = OMAP16XX_DSP_SIZE,
  75. .type = MT_DEVICE
  76. }, {
  77. .virtual = OMAP16XX_DSPREG_BASE,
  78. .pfn = __phys_to_pfn(OMAP16XX_DSPREG_START),
  79. .length = OMAP16XX_DSPREG_SIZE,
  80. .type = MT_DEVICE
  81. }
  82. };
  83. #endif
  84. #if defined (CONFIG_ARCH_OMAP730) || defined (CONFIG_ARCH_OMAP850)
  85. void __init omap7xx_map_io(void)
  86. {
  87. iotable_init(omap7xx_io_desc, ARRAY_SIZE(omap7xx_io_desc));
  88. }
  89. #endif
  90. #ifdef CONFIG_ARCH_OMAP15XX
  91. void __init omap15xx_map_io(void)
  92. {
  93. iotable_init(omap1510_io_desc, ARRAY_SIZE(omap1510_io_desc));
  94. }
  95. #endif
  96. #if defined(CONFIG_ARCH_OMAP16XX)
  97. void __init omap16xx_map_io(void)
  98. {
  99. iotable_init(omap16xx_io_desc, ARRAY_SIZE(omap16xx_io_desc));
  100. }
  101. #endif
  102. /*
  103. * Common low-level hardware init for omap1.
  104. */
  105. void __init omap1_init_early(void)
  106. {
  107. omap_check_revision();
  108. /* REVISIT: Refer to OMAP5910 Errata, Advisory SYS_1: "Timeout Abort
  109. * on a Posted Write in the TIPB Bridge".
  110. */
  111. omap_writew(0x0, MPU_PUBLIC_TIPB_CNTL);
  112. omap_writew(0x0, MPU_PRIVATE_TIPB_CNTL);
  113. }
  114. void __init omap1_init_late(void)
  115. {
  116. omap_serial_wakeup_init();
  117. }
  118. /*
  119. * NOTE: Please use ioremap + __raw_read/write where possible instead of these
  120. */
  121. u8 omap_readb(u32 pa)
  122. {
  123. return __raw_readb(OMAP1_IO_ADDRESS(pa));
  124. }
  125. EXPORT_SYMBOL(omap_readb);
  126. u16 omap_readw(u32 pa)
  127. {
  128. return __raw_readw(OMAP1_IO_ADDRESS(pa));
  129. }
  130. EXPORT_SYMBOL(omap_readw);
  131. u32 omap_readl(u32 pa)
  132. {
  133. return __raw_readl(OMAP1_IO_ADDRESS(pa));
  134. }
  135. EXPORT_SYMBOL(omap_readl);
  136. void omap_writeb(u8 v, u32 pa)
  137. {
  138. __raw_writeb(v, OMAP1_IO_ADDRESS(pa));
  139. }
  140. EXPORT_SYMBOL(omap_writeb);
  141. void omap_writew(u16 v, u32 pa)
  142. {
  143. __raw_writew(v, OMAP1_IO_ADDRESS(pa));
  144. }
  145. EXPORT_SYMBOL(omap_writew);
  146. void omap_writel(u32 v, u32 pa)
  147. {
  148. __raw_writel(v, OMAP1_IO_ADDRESS(pa));
  149. }
  150. EXPORT_SYMBOL(omap_writel);