From patchwork Fri Apr 23 17:56:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Chemparathy X-Patchwork-Id: 94725 Received: from devils.ext.ti.com (devils.ext.ti.com [198.47.26.153]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o3NHxSGd024790 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 23 Apr 2010 18:00:04 GMT Received: from dlep33.itg.ti.com ([157.170.170.112]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id o3NHxSSD001622 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 23 Apr 2010 12:59:28 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep33.itg.ti.com (8.13.7/8.13.7) with ESMTP id o3NHxRxD004034 for ; Fri, 23 Apr 2010 12:59:28 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id E85678062E for ; Fri, 23 Apr 2010 12:59:27 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dlep35.itg.ti.com (dlep35.itg.ti.com [157.170.170.118]) by linux.omap.com (Postfix) with ESMTP id 6222280628 for ; Fri, 23 Apr 2010 12:57:12 -0500 (CDT) Received: from legion.dal.design.ti.com (localhost [127.0.0.1]) by dlep35.itg.ti.com (8.13.7/8.13.7) with ESMTP id o3NHv99U026298; Fri, 23 Apr 2010 12:57:09 -0500 (CDT) Received: from gtrgwdeb (gtrgwdeb.telogy.design.ti.com [158.218.102.24]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id o3NHv9Z01787; Fri, 23 Apr 2010 12:57:09 -0500 (CDT) Received: by gtrgwdeb (Postfix, from userid 39959) id 524811E28EB; Fri, 23 Apr 2010 13:57:08 -0400 (EDT) From: Cyril Chemparathy To: davinci-linux-open-source@linux.davincidsp.com Subject: [PATCH v4 08/13] Davinci: iotable based ioremap() interception Date: Fri, 23 Apr 2010 13:56:59 -0400 Message-Id: <1272045424-19240-9-git-send-email-cyril@ti.com> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1272045424-19240-8-git-send-email-cyril@ti.com> References: <1272045424-19240-1-git-send-email-cyril@ti.com> <1272045424-19240-2-git-send-email-cyril@ti.com> <1272045424-19240-3-git-send-email-cyril@ti.com> <1272045424-19240-4-git-send-email-cyril@ti.com> <1272045424-19240-5-git-send-email-cyril@ti.com> <1272045424-19240-6-git-send-email-cyril@ti.com> <1272045424-19240-7-git-send-email-cyril@ti.com> <1272045424-19240-8-git-send-email-cyril@ti.com> Cc: sshtylyov@mvista.com X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: davinci-linux-open-source-bounces+patchwork-davinci=patchwork.kernel.org@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces+patchwork-davinci=patchwork.kernel.org@linux.davincidsp.com X-Greylist: Sender succeeded STARTTLS authentication, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 23 Apr 2010 18:00:11 +0000 (UTC) diff --git a/arch/arm/mach-davinci/common.c b/arch/arm/mach-davinci/common.c index 94f27cb..aac43b1 100644 --- a/arch/arm/mach-davinci/common.c +++ b/arch/arm/mach-davinci/common.c @@ -65,17 +65,8 @@ void __init davinci_common_init(struct davinci_soc_info *soc_info) memcpy(&davinci_soc_info, soc_info, sizeof(struct davinci_soc_info)); - if (davinci_soc_info.io_desc && (davinci_soc_info.io_desc_num > 0)) - iotable_init(davinci_soc_info.io_desc, - davinci_soc_info.io_desc_num); - - /* - * Normally devicemaps_init() would flush caches and tlb after - * mdesc->map_io(), but we must also do it here because of the CPU - * revision check below. - */ - local_flush_tlb_all(); - flush_cache_all(); + davinci_io_init(davinci_soc_info.io_desc, + davinci_soc_info.io_desc_num); /* * We want to check CPU revision early for cpu_is_xxxx() macros. diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c index 68e5233..4bcdc6f 100644 --- a/arch/arm/mach-davinci/da830.c +++ b/arch/arm/mach-davinci/da830.c @@ -1210,6 +1210,8 @@ static struct davinci_soc_info davinci_soc_info_da830 = { void __init da830_init(void) { + davinci_io_init(da830_io_desc, ARRAY_SIZE(da830_io_desc)); + da8xx_syscfg0_base = ioremap(DA8XX_SYSCFG0_BASE, SZ_4K); if (WARN(!da8xx_syscfg0_base, "Unable to map syscfg0 module")) return; diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c index 8aefcff..c2c2d58 100644 --- a/arch/arm/mach-davinci/da850.c +++ b/arch/arm/mach-davinci/da850.c @@ -1099,6 +1099,8 @@ void __init da850_init(void) { unsigned int v; + davinci_io_init(da850_io_desc, ARRAY_SIZE(da850_io_desc)); + da8xx_syscfg0_base = ioremap(DA8XX_SYSCFG0_BASE, SZ_4K); if (WARN(!da8xx_syscfg0_base, "Unable to map syscfg0 module")) return; diff --git a/arch/arm/mach-davinci/include/mach/io.h b/arch/arm/mach-davinci/include/mach/io.h index 62b0a90..3f456b7 100644 --- a/arch/arm/mach-davinci/include/mach/io.h +++ b/arch/arm/mach-davinci/include/mach/io.h @@ -25,8 +25,13 @@ #define __arch_ioremap(p, s, t) davinci_ioremap(p, s, t) #define __arch_iounmap(v) davinci_iounmap(v) +struct map_desc; + void __iomem *davinci_ioremap(unsigned long phys, size_t size, unsigned int type); void davinci_iounmap(volatile void __iomem *addr); + +void davinci_io_init(struct map_desc *desc, unsigned long desc_num); + #endif #endif /* __ASM_ARCH_IO_H */ diff --git a/arch/arm/mach-davinci/io.c b/arch/arm/mach-davinci/io.c index a1c0b6b..81862ec 100644 --- a/arch/arm/mach-davinci/io.c +++ b/arch/arm/mach-davinci/io.c @@ -12,19 +12,31 @@ #include #include +#include -#define BETWEEN(p, st, sz) ((p) >= (st) && (p) < ((st) + (sz))) -#define XLATE(p, pst, vst) ((void __iomem *)((p) - (pst) + (vst))) +#include + +static struct map_desc *davinci_io_desc; +static unsigned long davinci_io_desc_num; /* * Intercept ioremap() requests for addresses in our fixed mapping regions. */ void __iomem *davinci_ioremap(unsigned long p, size_t size, unsigned int type) { - if (BETWEEN(p, IO_PHYS, IO_SIZE)) - return XLATE(p, IO_PHYS, IO_VIRT); + struct map_desc *desc = davinci_io_desc; + int i; + + for (i = 0; i < davinci_io_desc_num; i++, desc++) { + unsigned long iophys = __pfn_to_phys(desc->pfn); + unsigned long iosize = desc->length; + + if (p >= iophys && (p + size) <= (iophys + iosize)) + return __io(desc->virtual + p - iophys); + } - return __arm_ioremap_caller(p, size, type, __builtin_return_address(0)); + return __arm_ioremap_caller(p, size, type, + __builtin_return_address(0)); } EXPORT_SYMBOL(davinci_ioremap); @@ -36,3 +48,30 @@ void davinci_iounmap(volatile void __iomem *addr) __iounmap(addr); } EXPORT_SYMBOL(davinci_iounmap); + +void __init davinci_io_init(struct map_desc *desc, unsigned long desc_num) +{ + if (!desc || !desc_num) + return; + + /* silently refuse to init twice ...*/ + if (davinci_io_desc) { + /* ... unless things change */ + BUG_ON(davinci_io_desc != desc || + davinci_io_desc_num != desc_num); + return; + } + + davinci_io_desc = desc; + davinci_io_desc_num = desc_num; + + iotable_init(desc, desc_num); + + /* + * Normally devicemaps_init() would flush caches and tlb after + * mdesc->map_io(), but we must also do it here because of the CPU + * revision check below. + */ + local_flush_tlb_all(); + flush_cache_all(); +}