| Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 1 | /* | 
|  | 2 | * DaVinci I/O mapping code | 
|  | 3 | * | 
|  | 4 | * Copyright (C) 2005-2006 Texas Instruments | 
|  | 5 | * | 
|  | 6 | * This program is free software; you can redistribute it and/or modify | 
|  | 7 | * it under the terms of the GNU General Public License version 2 as | 
|  | 8 | * published by the Free Software Foundation. | 
|  | 9 | */ | 
|  | 10 |  | 
|  | 11 | #include <linux/module.h> | 
| Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 12 | #include <linux/io.h> | 
| Kevin Hilman | 7c6337e | 2007-04-30 19:37:19 +0100 | [diff] [blame] | 13 |  | 
|  | 14 | #include <asm/tlb.h> | 
| Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 15 |  | 
| Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame] | 16 | #define BETWEEN(p, st, sz)	((p) >= (st) && (p) < ((st) + (sz))) | 
|  | 17 | #define XLATE(p, pst, vst)	((void __iomem *)((p) - (pst) + (vst))) | 
|  | 18 |  | 
|  | 19 | /* | 
|  | 20 | * Intercept ioremap() requests for addresses in our fixed mapping regions. | 
|  | 21 | */ | 
|  | 22 | void __iomem *davinci_ioremap(unsigned long p, size_t size, unsigned int type) | 
| Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 23 | { | 
| Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame] | 24 | if (BETWEEN(p, IO_PHYS, IO_SIZE)) | 
|  | 25 | return XLATE(p, IO_PHYS, IO_VIRT); | 
|  | 26 |  | 
|  | 27 | return __arm_ioremap(p, size, type); | 
| Vladimir Barinov | 3e062b0 | 2007-06-05 16:36:55 +0100 | [diff] [blame] | 28 | } | 
| Kevin Hilman | f5c122d | 2009-04-14 07:04:16 -0500 | [diff] [blame] | 29 | EXPORT_SYMBOL(davinci_ioremap); | 
|  | 30 |  | 
|  | 31 | void davinci_iounmap(volatile void __iomem *addr) | 
|  | 32 | { | 
|  | 33 | unsigned long virt = (unsigned long)addr; | 
|  | 34 |  | 
|  | 35 | if (virt >= VMALLOC_START && virt < VMALLOC_END) | 
|  | 36 | __iounmap(addr); | 
|  | 37 | } | 
|  | 38 | EXPORT_SYMBOL(davinci_iounmap); |