From patchwork Wed Apr 18 09:18:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hiroshi Doyu X-Patchwork-Id: 7914 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 987D923E4C for ; Wed, 18 Apr 2012 09:19:02 +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 27550A18763 for ; Wed, 18 Apr 2012 09:19:02 +0000 (UTC) Received: by iage36 with SMTP id e36so13935311iag.11 for ; Wed, 18 Apr 2012 02:19:01 -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=f49smeA/U+zm+D1lik+GLv+w1xpPU7XDpH3407wmIZ4=; b=ETu7GERyHmoPMrExAovSSt2v05zq4RiUxfwSuwPlcboaWsgQjOEOMTysvNd9P+wWew teFQMXyt64wyCdZvRHZSBYXcBEL4cLeUT+rj+7T4Y9KGaM/8GcnloNDxayatCAFBHBTu bSH5UnIU5WimSQbMuLqyNIbaXr+WbmUo7w2eXTMYncJTq2dVE/9l3NlSVJ1wraZ4zNXG AE+DyokALdAyVccJ8M96hxURvdSYtf4gkXVjl2NfhvjjW2aBRw3QBDMZFyrZBe7aMLQ/ h6El+O2cVUwaXmFIkLJCzpLccbrcVN5svuZcgHWKP/dzLxtkVdHZgoPHJ64WR/qHfGrl /AOA== Received: by 10.43.49.201 with SMTP id vb9mr859214icb.35.1334740741484; Wed, 18 Apr 2012 02:19:01 -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 x6csp204423ibt; Wed, 18 Apr 2012 02:19:00 -0700 (PDT) Received: by 10.180.96.228 with SMTP id dv4mr14975509wib.14.1334740734729; Wed, 18 Apr 2012 02:18:54 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id x8si24844496wec.57.2012.04.18.02.18.53; Wed, 18 Apr 2012 02:18:54 -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 1SKR2H-000255-MP; Wed, 18 Apr 2012 09:18:49 +0000 Received: from hqemgate03.nvidia.com ([216.228.121.140]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SKR2F-00024z-LQ for linaro-mm-sig@lists.linaro.org; Wed, 18 Apr 2012 09:18:48 +0000 Received: from hqnvupgp07.nvidia.com (Not Verified[216.228.121.13]) by hqemgate03.nvidia.com id ; Wed, 18 Apr 2012 02:34:21 -0700 Received: from hqemhub02.nvidia.com ([172.17.108.22]) by hqnvupgp07.nvidia.com (PGP Universal service); Wed, 18 Apr 2012 02:18:29 -0700 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Wed, 18 Apr 2012 02:18:29 -0700 Received: from deemhub02.nvidia.com (10.21.69.138) by hqemhub02.nvidia.com (172.20.150.31) with Microsoft SMTP Server (TLS) id 8.3.245.1; Wed, 18 Apr 2012 02:18:29 -0700 Received: from DEMAIL01.nvidia.com ([10.21.69.140]) by deemhub02.nvidia.com ([10.21.69.138]) with mapi; Wed, 18 Apr 2012 11:18:26 +0200 From: Hiroshi Doyu To: "devicetree-discuss@lists.ozlabs.org" , "arnd@arndb.de" Date: Wed, 18 Apr 2012 11:18:24 +0200 Thread-Topic: [PATCH 1/1] arm/dts: Tegra30: Add device tree support for SMMU Thread-Index: Ac0dRDYfc3GH1C5dTg6hX5HrlbSriw== Message-ID: <20120418.121824.1894043789811063795.hdoyu@nvidia.com> References: <20120418054140.GA17506@avionic-0098.adnet.avionic-design.de><20120418.094448.2234414220947028341.hdoyu@nvidia.com><201204180731.54064.arnd@arndb.de> In-Reply-To: <201204180731.54064.arnd@arndb.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" , "thierry.reding@avionic-design.de" , "linaro-mm-sig@lists.linaro.org" , "iommu@lists.linux-foundation.org" , "linux-tegra@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" Subject: Re: [Linaro-mm-sig] [PATCH 1/1] arm/dts: Tegra30: Add device tree support for SMMU 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: ALoCoQn0x2r6KqR79jMZ62a3lPg/R/Wm2ABJHsXI7EKhaueJxXgDggIAPStp2Ts6GpIWDUKBauVc From: Arnd Bergmann Subject: Re: [PATCH 1/1] arm/dts: Tegra30: Add device tree support for SMMU Date: Wed, 18 Apr 2012 09:31:53 +0200 Message-ID: <201204180731.54064.arnd@arndb.de> > On Wednesday 18 April 2012, Hiroshi Doyu wrote: > > If we can consider IOMMU as one of the implementation of DMA(Direct > > Memory Access), the prefix "dma-(window)" may make sense here. Then, > > we don't have to introduce a new concept "IO virtual address(iova)" in > > addition to the existing "bus address"(?) > > > > Anyway, either name would be ok for me;) > > I would just use dma-window, without the "ibm," prefix but following the > same conventions. Note that the of_parse_dma_window function is currently > only defined in powerpc specific code, and should get moved to > drivers/of from arch/powerpc/kernel/prom_parse.c. Something like below? At least, I verified that this works with "tegra-smmu". >From 67c1dd493637c9e972d04e061a8e67049687021a 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..1db1ccd --- /dev/null +++ b/drivers/of/of_dma.c @@ -0,0 +1,35 @@ +/* + * Stealed 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 u32 *dma_window; + u32 cells; + const unsigned char *prop; + + dma_window = dma_window_prop; + + /* busno is always one cell */ + if (busno) + *busno = *(dma_window++); + + prop = of_get_property(dn, "#dma-address-cells", NULL); + if (!prop) + prop = of_get_property(dn, "#address-cells", NULL); + + cells = prop ? *(u32 *)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 ? *(u32 *)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 */