From patchwork Wed Apr 18 10:19:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hiroshi Doyu X-Patchwork-Id: 7917 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id B0FB823E49 for ; Wed, 18 Apr 2012 10:19:41 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 494F7A1885E for ; Wed, 18 Apr 2012 10:19:41 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id e36so14013077iag.11 for ; Wed, 18 Apr 2012 03:19:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :x-pgp-universal:from:to:date:thread-topic:thread-index:message-id :references:in-reply-to:accept-language:x-ms-has-attach :x-ms-tnef-correlator:x-nvconfidentiality:acceptlanguage :mime-version:cc:subject:x-beenthere:x-mailman-version:precedence :list-id:list-unsubscribe:list-archive:list-post:list-help :list-subscribe:content-type:content-transfer-encoding:sender :errors-to:x-gm-message-state; bh=oqqhLcSJerhhXdMi3qslcT3W05Uio0eC1JUOGunGFPc=; b=NbWmICO9S7iuYpPuYBodG65yq1qYmE3+BisZvAsfeaDuISBzYujm2RHGn2MdsyllIa mdQvDVcm3EjyiAfRoxaTnxTG5P5kHf1ubZsGtoO915tLrCUWkp62fCh5Q/jKaL6Arik6 Ol5x7dh/r8aOfVeGGHw/EqkTzv6A+c1cO4Q/7bRTmdk3Vc5tAPAzLu+jLuOR1AZDTtAf Q1M75D0PW2oBcMkwa9ZxzBZytwQoQ/xqvDArIHi2GuteV8Tq05DfiYTxtYXVIhcjmiv/ CN0D4mpX3tgf6Sojse+g6DRh3AkPj1VQ5kxg/ZMjrBv3tWOwmXWPAU4zCWL7OqlNXt9x +4JA== Received: by 10.50.193.199 with SMTP id hq7mr1118482igc.49.1334744381006; Wed, 18 Apr 2012 03:19:41 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.137.198 with SMTP id x6csp207145ibt; Wed, 18 Apr 2012 03:19:40 -0700 (PDT) Received: by 10.180.95.34 with SMTP id dh2mr4826972wib.15.1334744373924; Wed, 18 Apr 2012 03:19:33 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id k9si15547092wiw.46.2012.04.18.03.19.32; Wed, 18 Apr 2012 03:19:33 -0700 (PDT) Received-SPF: neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) client-ip=91.189.95.16; Authentication-Results: mx.google.com; spf=neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) smtp.mail=linaro-mm-sig-bounces@lists.linaro.org Received: from localhost ([127.0.0.1] helo=mombin.canonical.com) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SKRyz-00053u-Ue; Wed, 18 Apr 2012 10:19:30 +0000 Received: from hqemgate04.nvidia.com ([216.228.121.35]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SKRyy-00053p-Jk for linaro-mm-sig@lists.linaro.org; Wed, 18 Apr 2012 10:19:28 +0000 Received: from hqnvupgp08.nvidia.com (Not Verified[216.228.121.13]) by hqemgate04.nvidia.com id ; Wed, 18 Apr 2012 03:18:18 -0700 Received: from hqemhub01.nvidia.com ([172.17.108.22]) by hqnvupgp08.nvidia.com (PGP Universal service); Wed, 18 Apr 2012 03:19:11 -0700 X-PGP-Universal: processed; by hqnvupgp08.nvidia.com on Wed, 18 Apr 2012 03:19:11 -0700 Received: from deemhub02.nvidia.com (10.21.69.138) by hqemhub01.nvidia.com (172.20.150.30) with Microsoft SMTP Server (TLS) id 8.3.245.1; Wed, 18 Apr 2012 03:19:11 -0700 Received: from DEMAIL01.nvidia.com ([10.21.69.140]) by deemhub02.nvidia.com ([10.21.69.138]) with mapi; Wed, 18 Apr 2012 12:19:09 +0200 From: Hiroshi Doyu To: "thierry.reding@avionic-design.de" , "devicetree-discuss@lists.ozlabs.org" , "arnd@arndb.de" Date: Wed, 18 Apr 2012 12:19:07 +0200 Thread-Topic: [PATCH 1/1] dt: Add general DMA window parser Thread-Index: Ac0dTLEnV0tlD39CRBWs0Kuv3JB01Q== Message-ID: <20120418.131907.2172387798112620167.hdoyu@nvidia.com> References: <201204180731.54064.arnd@arndb.de><20120418.121824.1894043789811063795.hdoyu@nvidia.com><20120418092613.GA8632@avionic-0098.mockup.avionic-design.de> In-Reply-To: <20120418092613.GA8632@avionic-0098.mockup.avionic-design.de> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-nvconfidentiality: public acceptlanguage: en-US MIME-Version: 1.0 Cc: "swarren@wwwdotorg.org" , "joerg.roedel@amd.com" , "linaro-mm-sig@lists.linaro.org" , "iommu@lists.linux-foundation.org" , "linux-tegra@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Subject: [Linaro-mm-sig] [PATCH 1/1] dt: Add general DMA window parser X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Unified memory management interest group." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linaro-mm-sig-bounces@lists.linaro.org Errors-To: linaro-mm-sig-bounces@lists.linaro.org X-Gm-Message-State: ALoCoQmhRQ2FOwgO4zLIZ8EEWmSaf+XtCKtIgohEMl4dSa2RZ67uylLBmPS8qtCkfWIuYGvmt823 Hi, Try again with fixing Thierry's commnets, Thanks. >From 9a632c24949e46df197a216ca95f684edd1db693 Mon Sep 17 00:00:00 2001 From: Hiroshi DOYU Date: Wed, 18 Apr 2012 12:09:03 +0300 Subject: [PATCH 1/1] dt: Add general DMA window parser This code was stolen from: "arch/microblaze/kernel/prom_parse.c" "arch/powerpc/kernel/prom_parse.c" Once "ibm," prefix is removed from dts file. This generic one could replace the originals. Signed-off-by: Hiroshi DOYU --- drivers/of/Kconfig | 4 ++++ drivers/of/Makefile | 1 + drivers/of/of_dma.c | 35 +++++++++++++++++++++++++++++++++++ include/linux/of_address.h | 10 ++++++++++ 4 files changed, 50 insertions(+), 0 deletions(-) diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index dfba3e6..3b0298b 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig @@ -83,4 +83,8 @@ config OF_MTD depends on MTD def_bool y +config OF_DMA + depends on HAS_DMA + def_bool y + endmenu # OF diff --git a/drivers/of/Makefile b/drivers/of/Makefile index e027f44..711ff5b 100644 --- a/drivers/of/Makefile +++ b/drivers/of/Makefile @@ -11,3 +11,4 @@ obj-$(CONFIG_OF_MDIO) += of_mdio.o obj-$(CONFIG_OF_PCI) += of_pci.o obj-$(CONFIG_OF_PCI_IRQ) += of_pci_irq.o obj-$(CONFIG_OF_MTD) += of_mtd.o +obj-$(CONFIG_OF_DMA) += of_dma.o diff --git a/drivers/of/of_dma.c b/drivers/of/of_dma.c new file mode 100644 index 0000000..a34db5a --- /dev/null +++ b/drivers/of/of_dma.c @@ -0,0 +1,35 @@ +/* + * Stolen from: + * "arch/microblaze/kernel/prom_parse.c" + * "arch/powerpc/kernel/prom_parse.c" + */ + +#include + +void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop, + unsigned long *busno, unsigned long *phys, unsigned long *size) +{ + const __be32 *dma_window; + u32 cells; + const unsigned char *prop; + + dma_window = dma_window_prop; + + /* busno is always one cell */ + if (busno) + *busno = be32_to_cpup(dma_window++); + + prop = of_get_property(dn, "#dma-address-cells", NULL); + if (!prop) + prop = of_get_property(dn, "#address-cells", NULL); + + cells = prop ? *(__be32 *)prop : of_n_addr_cells(dn); + *phys = of_read_number(dma_window, cells); + + dma_window += cells; + + prop = of_get_property(dn, "#dma-size-cells", NULL); + cells = prop ? *(__be32 *)prop : of_n_size_cells(dn); + *size = of_read_number(dma_window, cells); +} + diff --git a/include/linux/of_address.h b/include/linux/of_address.h index 01b925a..2a0f7c6 100644 --- a/include/linux/of_address.h +++ b/include/linux/of_address.h @@ -21,6 +21,10 @@ extern void __iomem *of_iomap(struct device_node *device, int index); extern const u32 *of_get_address(struct device_node *dev, int index, u64 *size, unsigned int *flags); +extern void of_parse_dma_window(struct device_node *dn, + const void *dma_window_prop, unsigned long *busno, + unsigned long *phys, unsigned long *size); + #ifndef pci_address_to_pio static inline unsigned long pci_address_to_pio(phys_addr_t addr) { return -1; } #define pci_address_to_pio pci_address_to_pio @@ -48,6 +52,12 @@ static inline const u32 *of_get_address(struct device_node *dev, int index, { return NULL; } + +static inline void of_parse_dma_window(struct device_node *dn, + const void *dma_window_prop, unsigned long *busno, + unsigned long *phys, unsigned long *size) +{ +} #endif /* CONFIG_OF_ADDRESS */