io.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * iop13xx custom ioremap implementation
  3. * Copyright (c) 2005-2006, Intel Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  16. * Place - Suite 330, Boston, MA 02111-1307 USA.
  17. *
  18. */
  19. #include <linux/kernel.h>
  20. #include <linux/module.h>
  21. #include <linux/io.h>
  22. #include <mach/hardware.h>
  23. #include "pci.h"
  24. void * __iomem __iop13xx_io(unsigned long io_addr)
  25. {
  26. void __iomem * io_virt;
  27. switch (io_addr) {
  28. case IOP13XX_PCIE_LOWER_IO_PA ... IOP13XX_PCIE_UPPER_IO_PA:
  29. io_virt = (void *) IOP13XX_PCIE_IO_PHYS_TO_VIRT(io_addr);
  30. break;
  31. case IOP13XX_PCIX_LOWER_IO_PA ... IOP13XX_PCIX_UPPER_IO_PA:
  32. io_virt = (void *) IOP13XX_PCIX_IO_PHYS_TO_VIRT(io_addr);
  33. break;
  34. default:
  35. BUG();
  36. }
  37. return io_virt;
  38. }
  39. EXPORT_SYMBOL(__iop13xx_io);
  40. static void __iomem *__iop13xx_ioremap_caller(unsigned long cookie,
  41. size_t size, unsigned int mtype, void *caller)
  42. {
  43. void __iomem * retval;
  44. switch (cookie) {
  45. case IOP13XX_PCIX_LOWER_MEM_RA ... IOP13XX_PCIX_UPPER_MEM_RA:
  46. if (unlikely(!iop13xx_atux_mem_base))
  47. retval = NULL;
  48. else
  49. retval = (void *)(iop13xx_atux_mem_base +
  50. (cookie - IOP13XX_PCIX_LOWER_MEM_RA));
  51. break;
  52. case IOP13XX_PCIE_LOWER_MEM_RA ... IOP13XX_PCIE_UPPER_MEM_RA:
  53. if (unlikely(!iop13xx_atue_mem_base))
  54. retval = NULL;
  55. else
  56. retval = (void *)(iop13xx_atue_mem_base +
  57. (cookie - IOP13XX_PCIE_LOWER_MEM_RA));
  58. break;
  59. case IOP13XX_PBI_LOWER_MEM_RA ... IOP13XX_PBI_UPPER_MEM_RA:
  60. retval = __arm_ioremap_caller(IOP13XX_PBI_LOWER_MEM_PA +
  61. (cookie - IOP13XX_PBI_LOWER_MEM_RA),
  62. size, mtype, __builtin_return_address(0));
  63. break;
  64. case IOP13XX_PCIE_LOWER_IO_PA ... IOP13XX_PCIE_UPPER_IO_PA:
  65. retval = (void *) IOP13XX_PCIE_IO_PHYS_TO_VIRT(cookie);
  66. break;
  67. case IOP13XX_PCIX_LOWER_IO_PA ... IOP13XX_PCIX_UPPER_IO_PA:
  68. retval = (void *) IOP13XX_PCIX_IO_PHYS_TO_VIRT(cookie);
  69. break;
  70. case IOP13XX_PMMR_PHYS_MEM_BASE ... IOP13XX_PMMR_UPPER_MEM_PA:
  71. retval = (void *) IOP13XX_PMMR_PHYS_TO_VIRT(cookie);
  72. break;
  73. default:
  74. retval = __arm_ioremap_caller(cookie, size, mtype,
  75. caller);
  76. }
  77. return retval;
  78. }
  79. static void __iop13xx_iounmap(volatile void __iomem *addr)
  80. {
  81. if (iop13xx_atue_mem_base)
  82. if (addr >= (void __iomem *) iop13xx_atue_mem_base &&
  83. addr < (void __iomem *) (iop13xx_atue_mem_base +
  84. iop13xx_atue_mem_size))
  85. goto skip;
  86. if (iop13xx_atux_mem_base)
  87. if (addr >= (void __iomem *) iop13xx_atux_mem_base &&
  88. addr < (void __iomem *) (iop13xx_atux_mem_base +
  89. iop13xx_atux_mem_size))
  90. goto skip;
  91. switch ((u32) addr) {
  92. case IOP13XX_PCIE_LOWER_IO_VA ... IOP13XX_PCIE_UPPER_IO_VA:
  93. case IOP13XX_PCIX_LOWER_IO_VA ... IOP13XX_PCIX_UPPER_IO_VA:
  94. case IOP13XX_PMMR_VIRT_MEM_BASE ... IOP13XX_PMMR_UPPER_MEM_VA:
  95. goto skip;
  96. }
  97. __iounmap(addr);
  98. skip:
  99. return;
  100. }
  101. void __init iop13xx_init_early(void)
  102. {
  103. arch_ioremap_caller = __iop13xx_ioremap_caller;
  104. arch_iounmap = __iop13xx_iounmap;
  105. }