From patchwork Wed Apr 14 18:44:47 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Chemparathy X-Patchwork-Id: 92457 Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o3EIlcPa001241 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 14 Apr 2010 18:48:14 GMT Received: from dlep34.itg.ti.com ([157.170.170.115]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id o3EIjF1v018303 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 14 Apr 2010 13:45:16 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep34.itg.ti.com (8.13.7/8.13.7) with ESMTP id o3EIjFSv006320; Wed, 14 Apr 2010 13:45:15 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 4B5E180626; Wed, 14 Apr 2010 13:45:14 -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 C41F980627 for ; Wed, 14 Apr 2010 13:45:08 -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 o3EIj6XQ026313; Wed, 14 Apr 2010 13:45:06 -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 o3EIj5Z05919; Wed, 14 Apr 2010 13:45:05 -0500 (CDT) Received: by gtrgwdeb (Postfix, from userid 39959) id 069CC1E067B; Wed, 14 Apr 2010 14:45:04 -0400 (EDT) From: Cyril Chemparathy To: davinci-linux-open-source@linux.davincidsp.com Subject: [PATCH v3 01/16] Davinci: iotable based ioremap() interception Date: Wed, 14 Apr 2010 14:44:47 -0400 Message-Id: <1271270702-28307-2-git-send-email-cyril@ti.com> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1271270702-28307-1-git-send-email-cyril@ti.com> References: <1271270702-28307-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]); Wed, 14 Apr 2010 18:48:15 +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)); }