io.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #include <linux/module.h>
  2. #include <linux/io.h>
  3. #include <linux/mm.h>
  4. #include <mach/omap730.h>
  5. #include <mach/omap1510.h>
  6. #include <mach/omap16xx.h>
  7. #include <mach/omap24xx.h>
  8. #include <mach/omap34xx.h>
  9. #define BETWEEN(p,st,sz) ((p) >= (st) && (p) < ((st) + (sz)))
  10. #define XLATE(p,pst,vst) ((void __iomem *)((p) - (pst) + (vst)))
  11. /*
  12. * Intercept ioremap() requests for addresses in our fixed mapping regions.
  13. */
  14. void __iomem *omap_ioremap(unsigned long p, size_t size, unsigned int type)
  15. {
  16. #ifdef CONFIG_ARCH_OMAP1
  17. if (cpu_class_is_omap1()) {
  18. if (BETWEEN(p, IO_PHYS, IO_SIZE))
  19. return XLATE(p, IO_PHYS, IO_VIRT);
  20. }
  21. if (cpu_is_omap730()) {
  22. if (BETWEEN(p, OMAP730_DSP_BASE, OMAP730_DSP_SIZE))
  23. return XLATE(p, OMAP730_DSP_BASE, OMAP730_DSP_START);
  24. if (BETWEEN(p, OMAP730_DSPREG_BASE, OMAP730_DSPREG_SIZE))
  25. return XLATE(p, OMAP730_DSPREG_BASE,
  26. OMAP730_DSPREG_START);
  27. }
  28. if (cpu_is_omap15xx()) {
  29. if (BETWEEN(p, OMAP1510_DSP_BASE, OMAP1510_DSP_SIZE))
  30. return XLATE(p, OMAP1510_DSP_BASE, OMAP1510_DSP_START);
  31. if (BETWEEN(p, OMAP1510_DSPREG_BASE, OMAP1510_DSPREG_SIZE))
  32. return XLATE(p, OMAP1510_DSPREG_BASE,
  33. OMAP1510_DSPREG_START);
  34. }
  35. if (cpu_is_omap16xx()) {
  36. if (BETWEEN(p, OMAP16XX_DSP_BASE, OMAP16XX_DSP_SIZE))
  37. return XLATE(p, OMAP16XX_DSP_BASE, OMAP16XX_DSP_START);
  38. if (BETWEEN(p, OMAP16XX_DSPREG_BASE, OMAP16XX_DSPREG_SIZE))
  39. return XLATE(p, OMAP16XX_DSPREG_BASE,
  40. OMAP16XX_DSPREG_START);
  41. }
  42. #endif
  43. #ifdef CONFIG_ARCH_OMAP2
  44. if (cpu_class_is_omap2()) {
  45. if (BETWEEN(p, L3_24XX_PHYS, L3_24XX_SIZE))
  46. return XLATE(p, L3_24XX_PHYS, L3_24XX_VIRT);
  47. if (BETWEEN(p, L4_24XX_PHYS, L4_24XX_SIZE))
  48. return XLATE(p, L4_24XX_PHYS, L4_24XX_VIRT);
  49. if (BETWEEN(p, DSP_MEM_24XX_PHYS, DSP_MEM_24XX_SIZE))
  50. return XLATE(p, DSP_MEM_24XX_PHYS, DSP_MEM_24XX_VIRT);
  51. if (BETWEEN(p, DSP_IPI_24XX_PHYS, DSP_IPI_24XX_SIZE))
  52. return XLATE(p, DSP_IPI_24XX_PHYS, DSP_IPI_24XX_SIZE);
  53. if (BETWEEN(p, DSP_MMU_24XX_PHYS, DSP_MMU_24XX_SIZE))
  54. return XLATE(p, DSP_MMU_24XX_PHYS, DSP_MMU_24XX_VIRT);
  55. }
  56. #ifdef CONFIG_ARCH_OMAP2430
  57. if (cpu_is_omap2430()) {
  58. if (BETWEEN(p, L4_WK_243X_PHYS, L4_WK_243X_SIZE))
  59. return XLATE(L4_WK_243X_PHYS, L4_WK_243X_VIRT);
  60. if (BETWEEN(p, OMAP243X_GPMC_PHYS, OMAP243X_GPMC_SIZE))
  61. return XLATE(OMAP243X_GPMC_PHYS, OMAP243X_GPMC_VIRT);
  62. }
  63. #endif
  64. #endif
  65. return __arm_ioremap(p, size, type);
  66. }
  67. EXPORT_SYMBOL(omap_ioremap);
  68. void omap_iounmap(volatile void __iomem *addr)
  69. {
  70. unsigned long virt = (unsigned long)addr;
  71. if (virt >= VMALLOC_START && virt < VMALLOC_END)
  72. __iounmap(addr);
  73. }
  74. EXPORT_SYMBOL(omap_iounmap);