io.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. static void __iomem *__iop13xx_ioremap_caller(phys_addr_t cookie,
  25. size_t size, unsigned int mtype, void *caller)
  26. {
  27. void __iomem * retval;
  28. switch (cookie) {
  29. case IOP13XX_PCIX_LOWER_MEM_RA ... IOP13XX_PCIX_UPPER_MEM_RA:
  30. if (unlikely(!iop13xx_atux_mem_base))
  31. retval = NULL;
  32. else
  33. retval = (iop13xx_atux_mem_base +
  34. (cookie - IOP13XX_PCIX_LOWER_MEM_RA));
  35. break;
  36. case IOP13XX_PCIE_LOWER_MEM_RA ... IOP13XX_PCIE_UPPER_MEM_RA:
  37. if (unlikely(!iop13xx_atue_mem_base))
  38. retval = NULL;
  39. else
  40. retval = (iop13xx_atue_mem_base +
  41. (cookie - IOP13XX_PCIE_LOWER_MEM_RA));
  42. break;
  43. case IOP13XX_PBI_LOWER_MEM_RA ... IOP13XX_PBI_UPPER_MEM_RA:
  44. retval = __arm_ioremap_caller(IOP13XX_PBI_LOWER_MEM_PA +
  45. (cookie - IOP13XX_PBI_LOWER_MEM_RA),
  46. size, mtype, __builtin_return_address(0));
  47. break;
  48. case IOP13XX_PMMR_PHYS_MEM_BASE ... IOP13XX_PMMR_UPPER_MEM_PA:
  49. retval = IOP13XX_PMMR_PHYS_TO_VIRT(cookie);
  50. break;
  51. default:
  52. retval = __arm_ioremap_caller(cookie, size, mtype,
  53. caller);
  54. }
  55. return retval;
  56. }
  57. static void __iop13xx_iounmap(volatile void __iomem *addr)
  58. {
  59. if (iop13xx_atue_mem_base)
  60. if (addr >= (void __iomem *) iop13xx_atue_mem_base &&
  61. addr < (void __iomem *) (iop13xx_atue_mem_base +
  62. iop13xx_atue_mem_size))
  63. goto skip;
  64. if (iop13xx_atux_mem_base)
  65. if (addr >= (void __iomem *) iop13xx_atux_mem_base &&
  66. addr < (void __iomem *) (iop13xx_atux_mem_base +
  67. iop13xx_atux_mem_size))
  68. goto skip;
  69. switch ((u32) addr) {
  70. case (u32)IOP13XX_PMMR_VIRT_MEM_BASE ... (u32)IOP13XX_PMMR_UPPER_MEM_VA:
  71. goto skip;
  72. }
  73. __iounmap(addr);
  74. skip:
  75. return;
  76. }
  77. void __init iop13xx_init_early(void)
  78. {
  79. arch_ioremap_caller = __iop13xx_ioremap_caller;
  80. arch_iounmap = __iop13xx_iounmap;
  81. }