blob: 8ea60a8b2495d33f6d7f26c844b39b6f4e12d1a2 [file] [log] [blame]
Kevin Hilman7c6337e2007-04-30 19:37:19 +01001/*
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 Kingfced80c2008-09-06 12:10:45 +010012#include <linux/io.h>
Kevin Hilman7c6337e2007-04-30 19:37:19 +010013
14#include <asm/tlb.h>
Cyril Chemparathybcd6a1c2010-05-07 17:06:39 -040015#include <asm/mach/map.h>
Vladimir Barinov3e062b02007-06-05 16:36:55 +010016
Cyril Chemparathybcd6a1c2010-05-07 17:06:39 -040017#include <mach/common.h>
Kevin Hilmanf5c122d2009-04-14 07:04:16 -050018
19/*
20 * Intercept ioremap() requests for addresses in our fixed mapping regions.
21 */
22void __iomem *davinci_ioremap(unsigned long p, size_t size, unsigned int type)
Vladimir Barinov3e062b02007-06-05 16:36:55 +010023{
Cyril Chemparathybcd6a1c2010-05-07 17:06:39 -040024 struct map_desc *desc = davinci_soc_info.io_desc;
25 int desc_num = davinci_soc_info.io_desc_num;
26 int i;
Kevin Hilmanf5c122d2009-04-14 07:04:16 -050027
Cyril Chemparathybcd6a1c2010-05-07 17:06:39 -040028 for (i = 0; i < desc_num; i++, desc++) {
29 unsigned long iophys = __pfn_to_phys(desc->pfn);
30 unsigned long iosize = desc->length;
31
32 if (p >= iophys && (p + size) <= (iophys + iosize))
33 return __io(desc->virtual + p - iophys);
34 }
35
36 return __arm_ioremap_caller(p, size, type,
37 __builtin_return_address(0));
Vladimir Barinov3e062b02007-06-05 16:36:55 +010038}
Kevin Hilmanf5c122d2009-04-14 07:04:16 -050039EXPORT_SYMBOL(davinci_ioremap);
40
41void davinci_iounmap(volatile void __iomem *addr)
42{
43 unsigned long virt = (unsigned long)addr;
44
45 if (virt >= VMALLOC_START && virt < VMALLOC_END)
46 __iounmap(addr);
47}
48EXPORT_SYMBOL(davinci_iounmap);