io.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 <asm/hardware.h>
  22. #include <asm/io.h>
  23. void * __iomem __iop13xx_ioremap(unsigned long cookie, size_t size,
  24. unsigned long flags)
  25. {
  26. void __iomem * retval;
  27. switch (cookie) {
  28. case IOP13XX_PCIX_LOWER_MEM_RA ... IOP13XX_PCIX_UPPER_MEM_RA:
  29. if (unlikely(!iop13xx_atux_mem_base))
  30. retval = NULL;
  31. else
  32. retval = (void *)(iop13xx_atux_mem_base +
  33. (cookie - IOP13XX_PCIX_LOWER_MEM_RA));
  34. break;
  35. case IOP13XX_PCIE_LOWER_MEM_RA ... IOP13XX_PCIE_UPPER_MEM_RA:
  36. if (unlikely(!iop13xx_atue_mem_base))
  37. retval = NULL;
  38. else
  39. retval = (void *)(iop13xx_atue_mem_base +
  40. (cookie - IOP13XX_PCIE_LOWER_MEM_RA));
  41. break;
  42. case IOP13XX_PBI_LOWER_MEM_RA ... IOP13XX_PBI_UPPER_MEM_RA:
  43. retval = __ioremap(IOP13XX_PBI_LOWER_MEM_PA +
  44. (cookie - IOP13XX_PBI_LOWER_MEM_RA),
  45. size, flags);
  46. break;
  47. case IOP13XX_PCIE_LOWER_IO_PA ... IOP13XX_PCIE_UPPER_IO_PA:
  48. retval = (void *) IOP13XX_PCIE_IO_PHYS_TO_VIRT(cookie);
  49. break;
  50. case IOP13XX_PCIX_LOWER_IO_PA ... IOP13XX_PCIX_UPPER_IO_PA:
  51. retval = (void *) IOP13XX_PCIX_IO_PHYS_TO_VIRT(cookie);
  52. break;
  53. case IOP13XX_PMMR_PHYS_MEM_BASE ... IOP13XX_PMMR_UPPER_MEM_PA:
  54. retval = (void *) IOP13XX_PMMR_PHYS_TO_VIRT(cookie);
  55. break;
  56. default:
  57. retval = __ioremap(cookie, size, flags);
  58. }
  59. return retval;
  60. }
  61. EXPORT_SYMBOL(__iop13xx_ioremap);
  62. void __iop13xx_iounmap(void __iomem *addr)
  63. {
  64. extern void __iounmap(volatile void __iomem *addr);
  65. if (iop13xx_atue_mem_base)
  66. if (addr >= (void __iomem *) iop13xx_atue_mem_base &&
  67. addr < (void __iomem *) (iop13xx_atue_mem_base +
  68. iop13xx_atue_mem_size))
  69. goto skip;
  70. if (iop13xx_atux_mem_base)
  71. if (addr >= (void __iomem *) iop13xx_atux_mem_base &&
  72. addr < (void __iomem *) (iop13xx_atux_mem_base +
  73. iop13xx_atux_mem_size))
  74. goto skip;
  75. switch ((u32) addr) {
  76. case IOP13XX_PCIE_LOWER_IO_VA ... IOP13XX_PCIE_UPPER_IO_VA:
  77. case IOP13XX_PCIX_LOWER_IO_VA ... IOP13XX_PCIX_UPPER_IO_VA:
  78. case IOP13XX_PMMR_VIRT_MEM_BASE ... IOP13XX_PMMR_UPPER_MEM_VA:
  79. goto skip;
  80. }
  81. __iounmap(addr);
  82. skip:
  83. return;
  84. }
  85. EXPORT_SYMBOL(__iop13xx_iounmap);