From patchwork Fri Feb 21 04:24:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 3693561 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6BAF09F1EE for ; Fri, 21 Feb 2014 04:25:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7DA7A2013A for ; Fri, 21 Feb 2014 04:25:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7FD6A20115 for ; Fri, 21 Feb 2014 04:25:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752769AbaBUEZD (ORCPT ); Thu, 20 Feb 2014 23:25:03 -0500 Received: from devils.ext.ti.com ([198.47.26.153]:50353 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752456AbaBUEZB (ORCPT ); Thu, 20 Feb 2014 23:25:01 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id s1L4Oab2011337; Thu, 20 Feb 2014 22:24:36 -0600 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id s1L4OaQj014233; Thu, 20 Feb 2014 22:24:36 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.174.1; Thu, 20 Feb 2014 22:24:36 -0600 Received: from legion.dal.design.ti.com (legion.dal.design.ti.com [128.247.22.53]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id s1L4Oag7030357; Thu, 20 Feb 2014 22:24:36 -0600 Received: from joel-laptop.itg.ti.com (j-172-22-146-196.vpn.ti.com [172.22.146.196]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id s1L4ORt05815; Thu, 20 Feb 2014 22:24:27 -0600 (CST) From: Joel Fernandes To: Linux OMAP List , Linux ARM Kernel List , Linux Kernel Mailing List CC: , Joel Fernandes Subject: [PATCH] ARM: EDMA: Use platform_get_resource functions for DT Date: Thu, 20 Feb 2014 22:24:21 -0600 Message-ID: <1392956661-28787-1-git-send-email-joelf@ti.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, EDMA driver uses of_address_to_resource for getting Channel controller and x-bar register resources. Use platform_get_resource_by_name instead regardless of whether its DT-boot or not, document the new reg-names properties. Also, while at it get rid of the assumption in the code that "CC" is at reg index 0 in the DT and xbar is at offset 1. Instead use reg-names to get the memory resource in concern keeping things much cleaner and simpler. This also makes it possible to have multiple channel controllers. Signed-off-by: Joel Fernandes --- Documentation/devicetree/bindings/dma/ti-edma.txt | 7 ++++++ arch/arm/boot/dts/am33xx.dtsi | 1 + arch/arm/boot/dts/am4372.dtsi | 1 + arch/arm/common/edma.c | 28 ++++++++++----------- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/Documentation/devicetree/bindings/dma/ti-edma.txt b/Documentation/devicetree/bindings/dma/ti-edma.txt index 9fbbdb7..176e42b 100644 --- a/Documentation/devicetree/bindings/dma/ti-edma.txt +++ b/Documentation/devicetree/bindings/dma/ti-edma.txt @@ -8,6 +8,12 @@ Required properties: Clients should use a single channel number per DMA request. - dma-channels: Specify total DMA channels per CC - reg: Memory map for accessing module +- reg-names: Since there can be different memory regions, each reg + entry should correspond to one of the following reg-names (X being 0 to N): + edma_ccX: memory map for Xth Channel Controller + edma_tcX: memory map for Xth Transfer Controller + Additionally there can be a memory map for xbar (in control module): + edma_xbar: memory map for xbar access. - interrupt-parent: Interrupt controller the interrupt is routed through - interrupts: Exactly 3 interrupts need to be specified in the order: 1. Transfer completion interrupt. @@ -21,6 +27,7 @@ Example: edma: edma@49000000 { reg = <0x49000000 0x10000>; + reg-names = "edma_cc0"; interrupt-parent = <&intc>; interrupts = <12 13 14>; compatible = "ti,edma3"; diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi index 2b66e67..55f5723 100644 --- a/arch/arm/boot/dts/am33xx.dtsi +++ b/arch/arm/boot/dts/am33xx.dtsi @@ -123,6 +123,7 @@ ti,hwmods = "tpcc", "tptc0", "tptc1", "tptc2"; reg = <0x49000000 0x10000>, <0x44e10f90 0x10>; + reg-names = "edma_cc0", "edma_xbar"; interrupts = <12 13 14>; #dma-cells = <1>; dma-channels = <64>; diff --git a/arch/arm/boot/dts/am4372.dtsi b/arch/arm/boot/dts/am4372.dtsi index babdc84..1323a97 100644 --- a/arch/arm/boot/dts/am4372.dtsi +++ b/arch/arm/boot/dts/am4372.dtsi @@ -100,6 +100,7 @@ ti,hwmods = "tpcc", "tptc0", "tptc1", "tptc2"; reg = <0x49000000 0x10000>, <0x44e10f90 0x10>; + reg-names = "edma_cc0", "edma_xbar"; interrupts = , , ; diff --git a/arch/arm/common/edma.c b/arch/arm/common/edma.c index dc95efc..ae0ccae 100644 --- a/arch/arm/common/edma.c +++ b/arch/arm/common/edma.c @@ -1458,10 +1458,11 @@ static int edma_xbar_event_map(struct device *dev, struct edma_soc_info *pdata, int len) { int ret, i; - struct resource res; + struct resource *res; void __iomem *xbar; const s16 (*xbar_chans)[2]; u32 shift, offset, mux; + struct platform_device *pdev; xbar_chans = devm_kzalloc(dev, len/sizeof(s16) + 2*sizeof(s16), @@ -1469,11 +1470,14 @@ static int edma_xbar_event_map(struct device *dev, if (!xbar_chans) return -ENOMEM; - ret = of_address_to_resource(node, 1, &res); - if (ret) + pdev = to_platform_device(dev); + res = platform_get_resource_byname(pdev, + IORESOURCE_MEM, + "edma_xbar"); + if (!res) return -EIO; - xbar = devm_ioremap(dev, res.start, resource_size(&res)); + xbar = devm_ioremap(dev, res->start, resource_size(res)); if (!xbar) return -ENOMEM; @@ -1614,7 +1618,6 @@ static int edma_probe(struct platform_device *pdev) int irq[EDMA_MAX_CC] = {0, 0}; int err_irq[EDMA_MAX_CC] = {0, 0}; struct resource *r[EDMA_MAX_CC] = {NULL}; - struct resource res[EDMA_MAX_CC]; char res_name[10]; char irq_name[10]; struct device_node *node = pdev->dev.of_node; @@ -1653,16 +1656,11 @@ static int edma_probe(struct platform_device *pdev) return -ENODEV; break; } - if (node) { - ret = of_address_to_resource(node, j, &res[j]); - if (!ret) - r[j] = &res[j]; - } else { - sprintf(res_name, "edma_cc%d", j); - r[j] = platform_get_resource_byname(pdev, - IORESOURCE_MEM, - res_name); - } + + sprintf(res_name, "edma_cc%d", j); + r[j] = platform_get_resource_byname(pdev, + IORESOURCE_MEM, + res_name); if (!r[j]) { if (found) break;