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 | |
Rob Herring | 17d971e | 2012-02-29 10:58:05 -0600 | [diff] [blame] | 24 | #include "pci.h" |
| 25 | |
Laura Abbott | 9b97173 | 2013-05-16 19:40:22 +0100 | [diff] [blame] | 26 | static void __iomem *__iop13xx_ioremap_caller(phys_addr_t cookie, |
Rob Herring | 1dfe34a | 2012-02-29 10:56:15 -0600 | [diff] [blame] | 27 | size_t size, unsigned int mtype, void *caller) |
Dan Williams | 285f5fa | 2006-12-07 02:59:39 +0100 | [diff] [blame] | 28 | { |
| 29 | void __iomem * retval; |
| 30 | |
| 31 | switch (cookie) { |
| 32 | case IOP13XX_PCIX_LOWER_MEM_RA ... IOP13XX_PCIX_UPPER_MEM_RA: |
| 33 | if (unlikely(!iop13xx_atux_mem_base)) |
| 34 | retval = NULL; |
| 35 | else |
Arnd Bergmann | abf2ba1 | 2012-09-14 20:17:50 +0000 | [diff] [blame] | 36 | retval = (iop13xx_atux_mem_base + |
Dan Williams | 285f5fa | 2006-12-07 02:59:39 +0100 | [diff] [blame] | 37 | (cookie - IOP13XX_PCIX_LOWER_MEM_RA)); |
| 38 | break; |
| 39 | case IOP13XX_PCIE_LOWER_MEM_RA ... IOP13XX_PCIE_UPPER_MEM_RA: |
| 40 | if (unlikely(!iop13xx_atue_mem_base)) |
| 41 | retval = NULL; |
| 42 | else |
Arnd Bergmann | abf2ba1 | 2012-09-14 20:17:50 +0000 | [diff] [blame] | 43 | retval = (iop13xx_atue_mem_base + |
Dan Williams | 285f5fa | 2006-12-07 02:59:39 +0100 | [diff] [blame] | 44 | (cookie - IOP13XX_PCIE_LOWER_MEM_RA)); |
| 45 | break; |
| 46 | case IOP13XX_PBI_LOWER_MEM_RA ... IOP13XX_PBI_UPPER_MEM_RA: |
Russell King | 31aa8fd | 2009-12-18 11:10:03 +0000 | [diff] [blame] | 47 | retval = __arm_ioremap_caller(IOP13XX_PBI_LOWER_MEM_PA + |
Russell King | 3603ab2 | 2007-05-05 20:59:27 +0100 | [diff] [blame] | 48 | (cookie - IOP13XX_PBI_LOWER_MEM_RA), |
Russell King | 31aa8fd | 2009-12-18 11:10:03 +0000 | [diff] [blame] | 49 | size, mtype, __builtin_return_address(0)); |
Dan Williams | 285f5fa | 2006-12-07 02:59:39 +0100 | [diff] [blame] | 50 | break; |
Dan Williams | 285f5fa | 2006-12-07 02:59:39 +0100 | [diff] [blame] | 51 | case IOP13XX_PMMR_PHYS_MEM_BASE ... IOP13XX_PMMR_UPPER_MEM_PA: |
Arnd Bergmann | abf2ba1 | 2012-09-14 20:17:50 +0000 | [diff] [blame] | 52 | retval = IOP13XX_PMMR_PHYS_TO_VIRT(cookie); |
Dan Williams | 285f5fa | 2006-12-07 02:59:39 +0100 | [diff] [blame] | 53 | break; |
| 54 | default: |
Russell King | 31aa8fd | 2009-12-18 11:10:03 +0000 | [diff] [blame] | 55 | retval = __arm_ioremap_caller(cookie, size, mtype, |
Rob Herring | 1dfe34a | 2012-02-29 10:56:15 -0600 | [diff] [blame] | 56 | caller); |
Dan Williams | 285f5fa | 2006-12-07 02:59:39 +0100 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | return retval; |
| 60 | } |
Dan Williams | 285f5fa | 2006-12-07 02:59:39 +0100 | [diff] [blame] | 61 | |
Rob Herring | 1dfe34a | 2012-02-29 10:56:15 -0600 | [diff] [blame] | 62 | static void __iop13xx_iounmap(volatile void __iomem *addr) |
Dan Williams | 285f5fa | 2006-12-07 02:59:39 +0100 | [diff] [blame] | 63 | { |
Dan Williams | 285f5fa | 2006-12-07 02:59:39 +0100 | [diff] [blame] | 64 | if (iop13xx_atue_mem_base) |
| 65 | if (addr >= (void __iomem *) iop13xx_atue_mem_base && |
| 66 | addr < (void __iomem *) (iop13xx_atue_mem_base + |
| 67 | iop13xx_atue_mem_size)) |
| 68 | goto skip; |
| 69 | |
| 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 | |
| 76 | switch ((u32) addr) { |
Arnd Bergmann | abf2ba1 | 2012-09-14 20:17:50 +0000 | [diff] [blame] | 77 | case (u32)IOP13XX_PMMR_VIRT_MEM_BASE ... (u32)IOP13XX_PMMR_UPPER_MEM_VA: |
Dan Williams | 285f5fa | 2006-12-07 02:59:39 +0100 | [diff] [blame] | 78 | goto skip; |
| 79 | } |
| 80 | __iounmap(addr); |
| 81 | |
| 82 | skip: |
| 83 | return; |
| 84 | } |
Rob Herring | 1dfe34a | 2012-02-29 10:56:15 -0600 | [diff] [blame] | 85 | |
| 86 | void __init iop13xx_init_early(void) |
| 87 | { |
| 88 | arch_ioremap_caller = __iop13xx_ioremap_caller; |
| 89 | arch_iounmap = __iop13xx_iounmap; |
| 90 | } |