From patchwork Fri Jul 20 14:56:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 10537683 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2A79F603B5 for ; Fri, 20 Jul 2018 15:13:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25AC8297B3 for ; Fri, 20 Jul 2018 15:13:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19A70297D0; Fri, 20 Jul 2018 15:13:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A470E297B3 for ; Fri, 20 Jul 2018 15:13:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=+OE0ZWn/2vrRzfzkEkDzIrJd+GgChACj9740ULq9fjI=; b=kWidJWc+fYx/VrplFDMdkscof9 x+GcNKKcgsJzsPtUPQBoZMx/cokPuSJbpnnISqpjfNhiv7rYumJBRuBfxZcSbJLpN/bJdMWjt5G4q TcCKt+D6esp6GmQ6soUp6XKFvvtDGv1MQAejFszjivD3nASIkLWLiAoOqJBs6C60IpIXHnrxOHhKy L6Tz2GYtzh+FT24VCjDAHJFUlVRPmyTnGP3b3ksYSkeZYUf5t4AmLsxCFYFWEc5edaE3oUk7d2wz5 32FRu/eJO+KvxN8jHzyQH76o0P0JIKecehM4PzPbEguXt6R8dIr0fKgeU8RzjNZnUCzNYQMM9xlBo BrO3lANA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fgX6F-0004Pf-4t; Fri, 20 Jul 2018 15:13:43 +0000 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fgWpn-0004Pr-IU for linux-arm-kernel@lists.infradead.org; Fri, 20 Jul 2018 14:56:46 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 34BDE207E8; Fri, 20 Jul 2018 16:56:42 +0200 (CEST) Received: from localhost (AAubervilliers-681-1-78-122.w90-88.abo.wanadoo.fr [90.88.20.122]) by mail.bootlin.com (Postfix) with ESMTPSA id 0695620949; Fri, 20 Jul 2018 16:56:14 +0200 (CEST) From: Maxime Ripard To: Mark Rutland , Rob Herring , Frank Rowand , Chen-Yu Tsai , Maxime Ripard Subject: [PATCH RESEND 4/7] of: address: Add support for the dma-parent property Date: Fri, 20 Jul 2018 16:56:07 +0200 Message-Id: <70c2bc34aef2006e371de70988dc66926a4f4642.1532098561.git-series.maxime.ripard@bootlin.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180720_075643_745469_8F530402 X-CRM114-Status: GOOD ( 14.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Thomas Petazzoni , Arnd Bergmann , dri-devel@lists.freedesktop.org, Paul Kocialkowski , Yong Deng , Robin Murphy , Dave Martin , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Some SoCs have devices that are using a separate bus from the main bus to perform DMA. These buses might have some restrictions and/or different mapping than from the CPU side, so we'd need to express those using the usual dma-ranges, but using a different DT node than the node's parent. Add support for a dma-parent property that links to the DMA bus used by the device in such a case. Signed-off-by: Maxime Ripard --- drivers/of/address.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/of/address.c b/drivers/of/address.c index 9e637bf8102c..e4c8207871d1 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -680,10 +680,18 @@ EXPORT_SYMBOL(of_translate_address); u64 of_translate_dma_address(struct device_node *dev, const __be32 *in_addr) { + struct of_phandle_args args; + struct device_node *parent = NULL; struct device_node *host; u64 ret; - ret = __of_translate_address(dev, NULL, in_addr, "dma-ranges", &host); + ret = of_parse_phandle_with_args(dev, "dma-parent", + "#dma-parent-cells", + 0, &args); + if (!ret) + parent = args.np; + + ret = __of_translate_address(dev, parent, in_addr, "dma-ranges", &host); if (host) { of_node_put(host); @@ -909,11 +917,21 @@ int of_dma_get_range(struct device_node *np, u64 *dma_addr, u64 *paddr, u64 *siz return -EINVAL; while (1) { + struct of_phandle_args args; + naddr = of_n_addr_cells(node); nsize = of_n_size_cells(node); - node = of_get_next_parent(node); - if (!node) - break; + + ret = of_parse_phandle_with_args(node, "dma-parent", + "#dma-parent-cells", + 0, &args); + if (!ret) { + node = args.np; + } else { + node = of_get_next_parent(node); + if (!node) + break; + } ranges = of_get_property(node, "dma-ranges", &len);