From patchwork Thu May 2 09:06:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 16572 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-gg0-f199.google.com (mail-gg0-f199.google.com [209.85.161.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 12B57238EC for ; Thu, 2 May 2013 09:07:38 +0000 (UTC) Received: by mail-gg0-f199.google.com with SMTP id q1sf523617gge.10 for ; Thu, 02 May 2013 02:07:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-beenthere:x-received:received-spf:x-received :x-forwarded-to:x-forwarded-for:delivered-to:x-received:received-spf :from:to:cc:subject:date:message-id:x-mailer:mime-version :x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe :content-type; bh=TPu6ysGAvm3VHqGNjBqq5tQjJr2chnW94j2swXzIjOA=; b=QodsAQFhb7FKmfKy1q1NhIR932zwWEhYGUcUXmo5cgeXAYJshWiq71C3o/pgiD8S2D 5pvQ4awfn4M5nwW6pa11D3zWUvtoTLXdg6PdnhzkNZAYzPOLLRinnVMgwsqvDF9xcSou I1T5lJHlwquTH2VuSXtEkh4n3J9zEIGJauVTI6njNdYNi74UkK9YYNWL1zDvS/dAgDJT VoOllSwZBORopq5MmBj5SjGgeV0y/IpMvF3t8ISbcu3/ReYxlTYNzIqHcbtuPTsOJTn2 TItRszpFCedSD1bjyb7WAEltCPUDkdDKWHw9N32YJgKffWkYRGxd+993YfeyG1qgme3k wbjQ== X-Received: by 10.236.133.98 with SMTP id p62mr4667251yhi.10.1367485651012; Thu, 02 May 2013 02:07:31 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.5.10 with SMTP id o10ls1153965qeo.69.gmail; Thu, 02 May 2013 02:07:30 -0700 (PDT) X-Received: by 10.220.188.201 with SMTP id db9mr1844685vcb.30.1367485650791; Thu, 02 May 2013 02:07:30 -0700 (PDT) Received: from mail-vb0-x235.google.com (mail-vb0-x235.google.com [2607:f8b0:400c:c02::235]) by mx.google.com with ESMTPS id ez9si2535966vdb.94.2013.05.02.02.07.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 02 May 2013 02:07:30 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::235 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::235; Received: by mail-vb0-f53.google.com with SMTP id i3so274067vbh.12 for ; Thu, 02 May 2013 02:07:30 -0700 (PDT) X-Received: by 10.58.173.36 with SMTP id bh4mr1908805vec.9.1367485650601; Thu, 02 May 2013 02:07:30 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp191778veb; Thu, 2 May 2013 02:07:29 -0700 (PDT) X-Received: by 10.15.31.197 with SMTP id y45mr17411119eeu.18.1367485649139; Thu, 02 May 2013 02:07:29 -0700 (PDT) Received: from eu1sys200aog124.obsmtp.com (eu1sys200aog124.obsmtp.com [207.126.144.157]) by mx.google.com with SMTP id k46si6849727eeu.160.2013.05.02.02.06.56 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 02 May 2013 02:07:29 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.157 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.157; Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob124.postini.com ([207.126.147.11]) with SMTP ID DSNKUYIsrKE5bQvY3qPkQLo/VMMSmXAViWKj@postini.com; Thu, 02 May 2013 09:07:29 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id BD466169; Thu, 2 May 2013 09:06:18 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 354A047E9; Thu, 2 May 2013 09:06:10 +0000 (GMT) Received: from exdcvycastm004.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm004", Issuer "exdcvycastm004" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id C95AF24C080; Thu, 2 May 2013 11:06:12 +0200 (CEST) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.2) with Microsoft SMTP Server (TLS) id 8.3.279.5; Thu, 2 May 2013 11:06:25 +0200 From: Linus Walleij To: , Vinod Koul , Arnd Bergmann Cc: Dan Williams , , Linus Walleij Subject: [PATCH 18/23 v2] dma: coh901318: add devicetree support Date: Thu, 2 May 2013 11:06:08 +0200 Message-ID: <1367485568-6116-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.11.3 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQllTJpNHBJyPSQEAYCfXTs/BGbPJu52bRBMXb97MgMO81XsBxziZBIdBbu6rlUePMWD7OZT X-Original-Sender: linus.walleij@stericsson.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::235 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Linus Walleij This adds support for probing the COH 901 318 DMA controller and channels from the device tree. Contains portions of a sketch patch from Arnd Bergmann. Cc: Arnd Bergmann Acked-by: Vinod Koul Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Folded in channel translation, request and filtering from the device tree based on a patch by Arnd Bergmann. - Added device tree binding documentation. --- .../devicetree/bindings/dma/ste-coh901318.txt | 32 ++++++++++++++++ drivers/dma/coh901318.c | 43 ++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/ste-coh901318.txt diff --git a/Documentation/devicetree/bindings/dma/ste-coh901318.txt b/Documentation/devicetree/bindings/dma/ste-coh901318.txt new file mode 100644 index 0000000..091ad05 --- /dev/null +++ b/Documentation/devicetree/bindings/dma/ste-coh901318.txt @@ -0,0 +1,32 @@ +ST-Ericsson COH 901 318 DMA Controller + +This is a DMA controller which has begun as a fork of the +ARM PL08x PrimeCell VHDL code. + +Required properties: +- compatible: should be "stericsson,coh901318" +- reg: register locations and length +- interrupts: the single DMA IRQ +- #dma-cells: must be set to <1>, as the channels on the + COH 901 318 are simple and identified by a single number +- dma-channels: the number of DMA channels handled + +Example: + +dmac: dma-controller@c00020000 { + compatible = "stericsson,coh901318"; + reg = <0xc0020000 0x1000>; + interrupt-parent = <&vica>; + interrupts = <2>; + #dma-cells = <1>; + dma-channels = <40>; +}; + +Consumers example: + +uart0: serial@c0013000 { + compatible = "..."; + (...) + dmas = <&dmac 17 &dmac 18>; + dma-names = "tx", "rx"; +}; diff --git a/drivers/dma/coh901318.c b/drivers/dma/coh901318.c index 797940e..8b22f56 100644 --- a/drivers/dma/coh901318.c +++ b/drivers/dma/coh901318.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "coh901318.h" #include "dmaengine.h" @@ -1788,6 +1789,35 @@ bool coh901318_filter_id(struct dma_chan *chan, void *chan_id) } EXPORT_SYMBOL(coh901318_filter_id); +struct coh901318_filter_args { + struct coh901318_base *base; + unsigned int ch_nr; +}; + +static bool coh901318_filter_base_and_id(struct dma_chan *chan, void *data) +{ + struct coh901318_filter_args *args = data; + + if (&args->base->dma_slave == chan->device && + args->ch_nr == to_coh901318_chan(chan)->id) + return true; + + return false; +} + +static struct dma_chan *coh901318_xlate(struct of_phandle_args *dma_spec, + struct of_dma *ofdma) +{ + struct coh901318_filter_args args = { + .base = ofdma->of_dma_data, + .ch_nr = dma_spec->args[0], + }; + dma_cap_mask_t cap; + dma_cap_zero(cap); + dma_cap_set(DMA_SLAVE, cap); + + return dma_request_channel(cap, coh901318_filter_base_and_id, &args); +} /* * DMA channel allocation */ @@ -2735,12 +2765,19 @@ static int __init coh901318_probe(struct platform_device *pdev) if (err) goto err_register_memcpy; + err = of_dma_controller_register(pdev->dev.of_node, coh901318_xlate, + base); + if (err) + goto err_register_of_dma; + platform_set_drvdata(pdev, base); dev_info(&pdev->dev, "Initialized COH901318 DMA on virtual base 0x%08x\n", (u32) base->virtbase); return err; + err_register_of_dma: + dma_async_device_unregister(&base->dma_memcpy); err_register_memcpy: dma_async_device_unregister(&base->dma_slave); err_register_slave: @@ -2752,17 +2789,23 @@ static int __exit coh901318_remove(struct platform_device *pdev) { struct coh901318_base *base = platform_get_drvdata(pdev); + of_dma_controller_free(pdev->dev.of_node); dma_async_device_unregister(&base->dma_memcpy); dma_async_device_unregister(&base->dma_slave); coh901318_pool_destroy(&base->pool); return 0; } +static const struct of_device_id coh901318_dt_match[] = { + { .compatible = "stericsson,coh901318" }, + {}, +}; static struct platform_driver coh901318_driver = { .remove = __exit_p(coh901318_remove), .driver = { .name = "coh901318", + .of_match_table = coh901318_dt_match, }, };