Dan Williams | 285f5fa | 2006-12-07 02:59:39 +0100 | [diff] [blame] | 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> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 21 | #include <linux/io.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 22 | #include <mach/hardware.h> |
Dan Williams | 285f5fa | 2006-12-07 02:59:39 +0100 | [diff] [blame] | 23 | |
Dan Williams | b0b1d60 | 2006-12-29 01:30:24 +0100 | [diff] [blame] | 24 | void * __iomem __iop13xx_io(unsigned long io_addr) |
| 25 | { |
| 26 | void __iomem * io_virt; |
| 27 | |
| 28 | switch (io_addr) { |
| 29 | case IOP13XX_PCIE_LOWER_IO_PA ... IOP13XX_PCIE_UPPER_IO_PA: |
| 30 | io_virt = (void *) IOP13XX_PCIE_IO_PHYS_TO_VIRT(io_addr); |
| 31 | break; |
| 32 | case IOP13XX_PCIX_LOWER_IO_PA ... IOP13XX_PCIX_UPPER_IO_PA: |
| 33 | io_virt = (void *) IOP13XX_PCIX_IO_PHYS_TO_VIRT(io_addr); |
| 34 | break; |
| 35 | default: |
| 36 | BUG(); |
| 37 | } |
| 38 | |
| 39 | return io_virt; |
| 40 | } |
| 41 | EXPORT_SYMBOL(__iop13xx_io); |
| 42 | |
Dan Williams | 285f5fa | 2006-12-07 02:59:39 +0100 | [diff] [blame] | 43 | void * __iomem __iop13xx_ioremap(unsigned long cookie, size_t size, |
Russell King | 3603ab2 | 2007-05-05 20:59:27 +0100 | [diff] [blame] | 44 | unsigned int mtype) |
Dan Williams | 285f5fa | 2006-12-07 02:59:39 +0100 | [diff] [blame] | 45 | { |
| 46 | void __iomem * retval; |
| 47 | |
| 48 | switch (cookie) { |
| 49 | case IOP13XX_PCIX_LOWER_MEM_RA ... IOP13XX_PCIX_UPPER_MEM_RA: |
| 50 | if (unlikely(!iop13xx_atux_mem_base)) |
| 51 | retval = NULL; |
| 52 | else |
| 53 | retval = (void *)(iop13xx_atux_mem_base + |
| 54 | (cookie - IOP13XX_PCIX_LOWER_MEM_RA)); |
| 55 | break; |
| 56 | case IOP13XX_PCIE_LOWER_MEM_RA ... IOP13XX_PCIE_UPPER_MEM_RA: |
| 57 | if (unlikely(!iop13xx_atue_mem_base)) |
| 58 | retval = NULL; |
| 59 | else |
| 60 | retval = (void *)(iop13xx_atue_mem_base + |
| 61 | (cookie - IOP13XX_PCIE_LOWER_MEM_RA)); |
| 62 | break; |
| 63 | case IOP13XX_PBI_LOWER_MEM_RA ... IOP13XX_PBI_UPPER_MEM_RA: |
Russell King | 3603ab2 | 2007-05-05 20:59:27 +0100 | [diff] [blame] | 64 | retval = __arm_ioremap(IOP13XX_PBI_LOWER_MEM_PA + |
| 65 | (cookie - IOP13XX_PBI_LOWER_MEM_RA), |
| 66 | size, mtype); |
Dan Williams | 285f5fa | 2006-12-07 02:59:39 +0100 | [diff] [blame] | 67 | break; |
| 68 | case IOP13XX_PCIE_LOWER_IO_PA ... IOP13XX_PCIE_UPPER_IO_PA: |
| 69 | retval = (void *) IOP13XX_PCIE_IO_PHYS_TO_VIRT(cookie); |
| 70 | break; |
| 71 | case IOP13XX_PCIX_LOWER_IO_PA ... IOP13XX_PCIX_UPPER_IO_PA: |
| 72 | retval = (void *) IOP13XX_PCIX_IO_PHYS_TO_VIRT(cookie); |
| 73 | break; |
| 74 | case IOP13XX_PMMR_PHYS_MEM_BASE ... IOP13XX_PMMR_UPPER_MEM_PA: |
| 75 | retval = (void *) IOP13XX_PMMR_PHYS_TO_VIRT(cookie); |
| 76 | break; |
| 77 | default: |
Russell King | 3603ab2 | 2007-05-05 20:59:27 +0100 | [diff] [blame] | 78 | retval = __arm_ioremap(cookie, size, mtype); |
Dan Williams | 285f5fa | 2006-12-07 02:59:39 +0100 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | return retval; |
| 82 | } |
| 83 | EXPORT_SYMBOL(__iop13xx_ioremap); |
| 84 | |
| 85 | void __iop13xx_iounmap(void __iomem *addr) |
| 86 | { |
| 87 | extern void __iounmap(volatile void __iomem *addr); |
| 88 | |
| 89 | if (iop13xx_atue_mem_base) |
| 90 | if (addr >= (void __iomem *) iop13xx_atue_mem_base && |
| 91 | addr < (void __iomem *) (iop13xx_atue_mem_base + |
| 92 | iop13xx_atue_mem_size)) |
| 93 | goto skip; |
| 94 | |
| 95 | if (iop13xx_atux_mem_base) |
| 96 | if (addr >= (void __iomem *) iop13xx_atux_mem_base && |
| 97 | addr < (void __iomem *) (iop13xx_atux_mem_base + |
| 98 | iop13xx_atux_mem_size)) |
| 99 | goto skip; |
| 100 | |
| 101 | switch ((u32) addr) { |
| 102 | case IOP13XX_PCIE_LOWER_IO_VA ... IOP13XX_PCIE_UPPER_IO_VA: |
| 103 | case IOP13XX_PCIX_LOWER_IO_VA ... IOP13XX_PCIX_UPPER_IO_VA: |
| 104 | case IOP13XX_PMMR_VIRT_MEM_BASE ... IOP13XX_PMMR_UPPER_MEM_VA: |
| 105 | goto skip; |
| 106 | } |
| 107 | __iounmap(addr); |
| 108 | |
| 109 | skip: |
| 110 | return; |
| 111 | } |
| 112 | EXPORT_SYMBOL(__iop13xx_iounmap); |