From patchwork Fri Sep 1 00:31:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9933203 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 F27426016C for ; Fri, 1 Sep 2017 00:35:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DBC5D27165 for ; Fri, 1 Sep 2017 00:35:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE43827853; Fri, 1 Sep 2017 00:35:17 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A9AB27165 for ; Fri, 1 Sep 2017 00:35:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751367AbdIAAfQ (ORCPT ); Thu, 31 Aug 2017 20:35:16 -0400 Received: from foss.arm.com ([217.140.101.70]:34238 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751345AbdIAAfQ (ORCPT ); Thu, 31 Aug 2017 20:35:16 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 710842B; Thu, 31 Aug 2017 17:35:15 -0700 (PDT) Received: from slackpad.lan (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 776603F58F; Thu, 31 Aug 2017 17:35:13 -0700 (PDT) From: Andre Przywara To: =?UTF-8?q?Stefan=20Br=C3=BCns?= Cc: linux-sunxi@googlegroups.com, Maxime Ripard , Chen-Yu Tsai , devicetree@vger.kernel.org, dmaengine@vger.kernel.org, Vinod Koul , Rob Herring , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] dmaengine: sun6i: Add support for Allwinner A64 Date: Fri, 1 Sep 2017 01:31:35 +0100 Message-Id: <20170901003135.10058-1-andre.przywara@arm.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170830233609.13855-4-stefan.bruens@rwth-aachen.de> References: <20170830233609.13855-4-stefan.bruens@rwth-aachen.de> MIME-Version: 1.0 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, On 31/08/17 00:36, Stefan BrĂ¼ns wrote: > The A64 SoC has the same dma engine as the H3 (sun8i), with a > reduced amount of physical channels. Add the proper config data > and compatible string to support it. ... > diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c > index 5f4eee4513e5..6a17c5d63582 100644 > --- a/drivers/dma/sun6i-dma.c > +++ b/drivers/dma/sun6i-dma.c > @@ -1068,6 +1068,12 @@ static struct sun6i_dma_config sun8i_h3_dma_cfg = { > .nr_max_vchans = 34, > .dmac_variant = DMAC_VARIANT_H3, > }; > + > +static struct sun6i_dma_config sun50i_a64_dma_cfg = { > + .nr_max_channels = 8, > + .nr_max_requests = 27, > + .nr_max_vchans = 38, > + .dmac_variant = DMAC_VARIANT_H3, > }; > > static const struct of_device_id sun6i_dma_match[] = { > @@ -1075,6 +1081,7 @@ static const struct of_device_id sun6i_dma_match[] = { > { .compatible = "allwinner,sun8i-a23-dma", .data = &sun8i_a23_dma_cfg }, > { .compatible = "allwinner,sun8i-a83t-dma", .data = &sun8i_a83t_dma_cfg }, > { .compatible = "allwinner,sun8i-h3-dma", .data = &sun8i_h3_dma_cfg }, > + { .compatible = "allwinner,sun50i-a64-dma", .data = &sun50i_a64_dma_cfg }, > { /* sentinel */ } > }; > MODULE_DEVICE_TABLE(of, sun6i_dma_match); I was wondering if should use the opportunity to expose those values as DT properties instead of hard-wiring them to a compatible string in the driver every time we add support for a new SoC? We could introduce a new compatible string (say: "allwinner,sunxi-dma"), then describe properties for the number of channels and requests and vchans and parse those from the DT at probe time. With this we might be able to support future SoCs without Linux *driver* changes, by just providing the right DT. This would have worked already for instance for the A83T support, which just changed those values. For instance with this quick patch below (just compile tested, and without your refactoring). The DT node would then read something like: dma: dma-controller@01c02000 { compatible = "allwinner,sun50i-a64-dma", "allwinner,sunxi-dma"; reg = <0x01c02000 0x1000>; interrupts = ; clocks = <&ccu CLK_BUS_DMA>; resets = <&ccu RST_BUS_DMA>; #dma-cells = <1>; allwinner,max_channels = <8>; allwinner,max_requests = <27>; allwinner,max_vchans = <38>; }; Cheers, Andre. diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c index a2358780ab2c..5ae8032f2065 100644 --- a/drivers/dma/sun6i-dma.c +++ b/drivers/dma/sun6i-dma.c @@ -1033,6 +1033,7 @@ static const struct of_device_id sun6i_dma_match[] = { { .compatible = "allwinner,sun8i-a23-dma", .data = &sun8i_a23_dma_cfg }, { .compatible = "allwinner,sun8i-a83t-dma", .data = &sun8i_a83t_dma_cfg }, { .compatible = "allwinner,sun8i-h3-dma", .data = &sun8i_h3_dma_cfg }, + { .compatible = "allwinner,sunxi-dma", .data = NULL }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, sun6i_dma_match); @@ -1051,7 +1052,43 @@ static int sun6i_dma_probe(struct platform_device *pdev) device = of_match_device(sun6i_dma_match, &pdev->dev); if (!device) return -ENODEV; - sdc->cfg = device->data; + if (!device->data) { + struct sun6i_dma_config *config; + + config = devm_kmalloc(&pdev->dev, sizeof(*config), GFP_KERNEL); + if (!config) + return -ENOMEM; + + ret = of_property_read_u32(pdev->dev.of_node, + "allwinner,max_channels", + &config->nr_max_channels); + if (ret) { + dev_err(&pdev->dev, + "missing allwinner,max_channels property\n"); + return ret; + } + + ret = of_property_read_u32(pdev->dev.of_node, + "allwinner,max_requests", + &config->nr_max_requests); + if (ret) { + dev_err(&pdev->dev, + "missing allwinner,max_requests property\n"); + return ret; + } + + ret = of_property_read_u32(pdev->dev.of_node, + "allwinner,max_vchans", + &config->nr_max_vchans); + if (ret) { + dev_err(&pdev->dev, + "missing allwinner,max_vchans property\n"); + return ret; + } + sdc->cfg = config; + } else { + sdc->cfg = device->data; + } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); sdc->base = devm_ioremap_resource(&pdev->dev, res);