From patchwork Mon Apr 12 21:15:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Chemparathy X-Patchwork-Id: 92090 Received: from arroyo.ext.ti.com (arroyo.ext.ti.com [192.94.94.40]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o3CLImPb003220 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 12 Apr 2010 21:19:24 GMT Received: from dlep36.itg.ti.com ([157.170.170.91]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id o3CLGta7031433 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 12 Apr 2010 16:16:55 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep36.itg.ti.com (8.13.8/8.13.8) with ESMTP id o3CLGtUn022793; Mon, 12 Apr 2010 16:16:55 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id C74138067D; Mon, 12 Apr 2010 16:16:13 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dlep36.itg.ti.com (dlep36.itg.ti.com [157.170.170.91]) by linux.omap.com (Postfix) with ESMTP id 2EC8E80628 for ; Mon, 12 Apr 2010 16:15:39 -0500 (CDT) Received: from legion.dal.design.ti.com (localhost [127.0.0.1]) by dlep36.itg.ti.com (8.13.8/8.13.8) with ESMTP id o3CLFaNj021448; Mon, 12 Apr 2010 16:15:36 -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 o3CLFZZ20696; Mon, 12 Apr 2010 16:15:35 -0500 (CDT) Received: by gtrgwdeb (Postfix, from userid 39959) id 654AB1E292E; Mon, 12 Apr 2010 17:15:35 -0400 (EDT) From: Cyril Chemparathy To: davinci-linux-open-source@linux.davincidsp.com Subject: [PATCH 1/8] Davinci: iotable based ioremap() interception Date: Mon, 12 Apr 2010 17:15:26 -0400 Message-Id: <1271106933-13911-2-git-send-email-cyril@ti.com> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1271106933-13911-1-git-send-email-cyril@ti.com> References: <1271106933-13911-1-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@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com X-Greylist: Sender succeeded STARTTLS authentication, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 12 Apr 2010 21:19:25 +0000 (UTC) diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c index 122e61a..168f277 100644 --- a/arch/arm/mach-davinci/da830.c +++ b/arch/arm/mach-davinci/da830.c @@ -1206,9 +1206,14 @@ static struct davinci_soc_info davinci_soc_info_da830 = { .emac_pdata = &da8xx_emac_pdata, }; +#define da830_early_ioremap(p, s) \ + __davinci_ioremap(p, s, \ + davinci_soc_info_da830.io_desc, \ + davinci_soc_info_da830.io_desc_num) + void __init da830_init(void) { - da8xx_syscfg0_base = ioremap(DA8XX_SYSCFG0_BASE, SZ_4K); + da8xx_syscfg0_base = da830_early_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 d0fd756..27eb32e 100644 --- a/arch/arm/mach-davinci/da850.c +++ b/arch/arm/mach-davinci/da850.c @@ -1093,15 +1093,20 @@ static struct davinci_soc_info davinci_soc_info_da850 = { .sram_len = SZ_8K, }; +#define da850_early_ioremap(p, s) \ + __davinci_ioremap(p, s, \ + davinci_soc_info_da850.io_desc, \ + davinci_soc_info_da850.io_desc_num) + void __init da850_init(void) { unsigned int v; - da8xx_syscfg0_base = ioremap(DA8XX_SYSCFG0_BASE, SZ_4K); + da8xx_syscfg0_base = da850_early_ioremap(DA8XX_SYSCFG0_BASE, SZ_4K); if (WARN(!da8xx_syscfg0_base, "Unable to map syscfg0 module")) return; - da8xx_syscfg1_base = ioremap(DA8XX_SYSCFG1_BASE, SZ_4K); + da8xx_syscfg1_base = da850_early_ioremap(DA8XX_SYSCFG1_BASE, SZ_4K); if (WARN(!da8xx_syscfg1_base, "Unable to map syscfg1 module")) return; diff --git a/arch/arm/mach-davinci/include/mach/io.h b/arch/arm/mach-davinci/include/mach/io.h index 62b0a90..4aa301c 100644 --- a/arch/arm/mach-davinci/include/mach/io.h +++ b/arch/arm/mach-davinci/include/mach/io.h @@ -25,6 +25,10 @@ #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 p, size_t size, + struct map_desc *io_desc, int io_desc_num); void __iomem *davinci_ioremap(unsigned long phys, size_t size, unsigned int type); void davinci_iounmap(volatile void __iomem *addr); diff --git a/arch/arm/mach-davinci/io.c b/arch/arm/mach-davinci/io.c index a1c0b6b..3a62f14 100644 --- a/arch/arm/mach-davinci/io.c +++ b/arch/arm/mach-davinci/io.c @@ -12,17 +12,42 @@ #include #include +#include -#define BETWEEN(p, st, sz) ((p) >= (st) && (p) < ((st) + (sz))) -#define XLATE(p, pst, vst) ((void __iomem *)((p) - (pst) + (vst))) +#include + +/* + * Remap io addresses based on a soc-specific io-descriptor table. This is + * useful in early arch init code before davinci_common_init(). After + * davinci_common_init(), regular ioremap() calls should be used. + */ +void __iomem *__davinci_ioremap(unsigned long p, size_t size, + struct map_desc *io_desc, int io_desc_num) +{ + int i; + + for (i = 0; i < io_desc_num; i++, io_desc++) { + unsigned long iophys = __pfn_to_phys(io_desc->pfn); + unsigned long iosize = io_desc->length; + + if (p >= iophys && (p + size) <= (iophys + iosize)) + return __io(io_desc->virtual + p - iophys); + } + + return NULL; +} /* * 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); + void __iomem *ret; + + ret = __davinci_ioremap(p, size, davinci_soc_info.io_desc, + davinci_soc_info.io_desc_num); + if (ret) + return ret; return __arm_ioremap_caller(p, size, type, __builtin_return_address(0)); }