From patchwork Thu Apr 18 10:12:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 16212 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CACED23974 for ; Thu, 18 Apr 2013 10:13:54 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id hz11sf4433619vcb.11 for ; Thu, 18 Apr 2013 03:13:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references: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; bh=ZQkN8daenc6oSmLRf59G5cUlf3QcvAILF2CcAg61/Oo=; b=CpiqKMsNEIx9j2OIR8o1QHiS1SNfWHS2qr5/HqHCAqV2Lc7sOOGT1TdJ4UpBuLRQvW EQPFK+2Te5c48UQF3QkdgyFFqO9q5y/luvniWs3xKiBaZi5vFJMr2SK45Bo39XlRGeF4 pzAHyjtmVpB+v+GGrmaB9Z3EGM8Ne55WS67nv2dbMRMhzUWM9w0FkqfFS3Ny+9au73m0 MtyGsiW4oApNkY7NF4OJHSfKuBt5CKjUFQDqTOrBORA4Knxz1KCnrIBxO9ECbXr6Ptqm K4VE2Z6+MW1qYaFXzYHQ30RJL0xysB1JdhytBj+dhdKmdFrplg5X9yEiLT22XMoxljYJ rKyw== X-Received: by 10.236.139.230 with SMTP id c66mr5159461yhj.55.1366279997801; Thu, 18 Apr 2013 03:13:17 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.134.100 with SMTP id pj4ls1464715qeb.70.gmail; Thu, 18 Apr 2013 03:13:17 -0700 (PDT) X-Received: by 10.52.22.202 with SMTP id g10mr6414157vdf.126.1366279997594; Thu, 18 Apr 2013 03:13:17 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id b4si6245795vdw.44.2013.04.18.03.13.17 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 18 Apr 2013 03:13:17 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.182 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id ht11so69890vcb.13 for ; Thu, 18 Apr 2013 03:13:17 -0700 (PDT) X-Received: by 10.52.163.231 with SMTP id yl7mr6535994vdb.57.1366279997433; Thu, 18 Apr 2013 03:13:17 -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 nf2csp115763veb; Thu, 18 Apr 2013 03:13:16 -0700 (PDT) X-Received: by 10.180.83.199 with SMTP id s7mr14748413wiy.19.1366279996452; Thu, 18 Apr 2013 03:13:16 -0700 (PDT) Received: from mail-wi0-x231.google.com (mail-wi0-x231.google.com [2a00:1450:400c:c05::231]) by mx.google.com with ESMTPS id o5si3421271wjy.251.2013.04.18.03.13.16 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 18 Apr 2013 03:13:16 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:400c:c05::231 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=2a00:1450:400c:c05::231; Received: by mail-wi0-f177.google.com with SMTP id hj19so1054567wib.10 for ; Thu, 18 Apr 2013 03:13:16 -0700 (PDT) X-Received: by 10.194.143.50 with SMTP id sb18mr17335188wjb.44.1366279995961; Thu, 18 Apr 2013 03:13:15 -0700 (PDT) Received: from localhost.localdomain (cpc34-aztw25-2-0-cust250.18-1.cable.virginmedia.com. [86.16.136.251]) by mx.google.com with ESMTPS id t7sm30483773wij.2.2013.04.18.03.13.13 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 18 Apr 2013 03:13:14 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: arnd@arndb.de, linus.walleij@stericsson.com, Lee Jones , Vinod Koul , Dan Williams , Per Forlin , Rabin Vincent Subject: [PATCH 24/32] dmaengine: ste_dma40: Supply full Device Tree parsing support Date: Thu, 18 Apr 2013 11:12:06 +0100 Message-Id: <1366279934-30761-25-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1366279934-30761-1-git-send-email-lee.jones@linaro.org> References: <1366279934-30761-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQl4kjO7GB3KMgapm51y59503lZMaLOtC3cFHBz2vR7rCBxfFXIsBh5Zfb2/Uuvid3/LPreM X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.182 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: , Using the new DMA DT bindings and API, we can register the DMA40 driver as Device Tree capable. Now, when a client attempts to allocate a channel using the DMA DT bindings via its own node, we are able to parse the request and allocate a channel in the correct manor. Cc: Vinod Koul Cc: Dan Williams Cc: Per Forlin Cc: Rabin Vincent Signed-off-by: Lee Jones --- .../devicetree/bindings/dma/ste-dma40.txt | 66 ++++++++++++++++++++ drivers/dma/ste_dma40.c | 58 +++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/ste-dma40.txt diff --git a/Documentation/devicetree/bindings/dma/ste-dma40.txt b/Documentation/devicetree/bindings/dma/ste-dma40.txt new file mode 100644 index 0000000..1eb7958 --- /dev/null +++ b/Documentation/devicetree/bindings/dma/ste-dma40.txt @@ -0,0 +1,66 @@ +* DMA40 DMA Controller + +Required properties: +- compatible: "stericsson,dma40" +- reg: Address range of the DMAC registers +- interrupt: Should contain the DMAC interrupt number +- dma-channels: Number of channels supported by hardware +- #dma-cells: must be <3> + +Optional properties: +- interrupt-parent: Should be the phandle for the interrupt controller + that services interrupts for this device + +Example: + + dma: dma-controller@801C0000 { + compatible = "stericsson,db8500-dma40", "stericsson,dma40"; + reg = <0x801C0000 0x1000>; + reg-names = "base"; + interrupt-parent = <&intc>; + interrupts = <0 25 0x4>; + + #dma-cells = <2>; + dma-channels = <0>; /* Zero means read from H/W. */ + }; + +Clients +Required properties: +- dmas: Comma seperated list of dma channel requests +- dma-names: Names of the aforementioned requested channels + +Each dmas request consists of 4 cells: + 1. A phandle pointing to the DMA controller + 2. The DMA request line number (only when 'use fixed channel' is set) + 3. Device Type + 4. A 32bit mask specifying; mode, direction and endianess [NB: This list will grow] + bits 1-2: Mode: + 00: Logical + 01: Physical + 10: Operation + 11: Undefined - will most likely return an error + bits 3-4: Direction: + 00: Mem to Mem + 01: Mem to Dev + 10: Dev to Mem + 11: Dev to Dev + bit 5: Endianess: + 0: Little endian + 1: Big endian + bit 6: Use fixed channel: + 0: Use automatic channel selection + 1: Use DMA request line number + +Example: + + uart@80120000 { + compatible = "arm,pl011", "arm,primecell"; + reg = <0x80120000 0x1000>; + interrupts = <0 11 0x4>; + + dmas = <&dma 0 13 0x8>, /* Logical - DevToMem */ + <&dma 0 13 0x4>; /* Logical - MemToDev */ + dma-names = "rx", "rx"; + + status = "disabled"; + }; diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c index 4782ee7..9115c0e 100644 --- a/drivers/dma/ste_dma40.c +++ b/drivers/dma/ste_dma40.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -2409,6 +2410,56 @@ static void d40_set_prio_realtime(struct d40_chan *d40c) __d40_set_prio_rt(d40c, d40c->dma_cfg.dev_type, false); } +#define D40_DT_FLAGS_MODE(flags) ((flags >> 0) & 0x3) +#define D40_DT_FLAGS_DIR(flags) ((flags >> 2) & 0x3) +#define D40_DT_FLAGS_BIG_ENDIAN(flags) ((flags >> 4) & 0x1) +#define D40_DT_FLAGS_FIXED_CHAN(flags) ((flags >> 5) & 0x1) + +static struct dma_chan *d40_xlate(struct of_phandle_args *dma_spec, + struct of_dma *ofdma) +{ + struct stedma40_chan_cfg cfg; + dma_cap_mask_t cap; + u32 flags; + + memset(&cfg, 0, sizeof(struct stedma40_chan_cfg)); + + dma_cap_zero(cap); + dma_cap_set(DMA_SLAVE, cap); + + cfg.dev_type = dma_spec->args[1]; + flags = dma_spec->args[2]; + + switch (D40_DT_FLAGS_MODE(flags)) { + case 0: cfg.mode = STEDMA40_MODE_LOGICAL; break; + case 1: cfg.mode = STEDMA40_MODE_PHYSICAL; break; + case 2: cfg.mode = STEDMA40_MODE_OPERATION; break; + default: + pr_err("dma40: Unknown mode read from DT (%d)\n", + D40_DT_FLAGS_MODE(flags)); + return NULL; + } + + switch (D40_DT_FLAGS_DIR(flags)) { + case 0: cfg.dir = STEDMA40_MEM_TO_MEM; break; + case 1: cfg.dir = STEDMA40_MEM_TO_PERIPH; break; + case 2: cfg.dir = STEDMA40_PERIPH_TO_MEM; break; + case 3: cfg.dir = STEDMA40_PERIPH_TO_PERIPH; break; + } + + if (cfg.dir == STEDMA40_PERIPH_TO_MEM) + cfg.src_info.big_endian = D40_DT_FLAGS_BIG_ENDIAN(flags); + if (cfg.dir == STEDMA40_MEM_TO_PERIPH) + cfg.dst_info.big_endian = D40_DT_FLAGS_BIG_ENDIAN(flags); + + if (D40_DT_FLAGS_FIXED_CHAN(flags)) { + cfg.phy_channel = dma_spec->args[0]; + cfg.use_fixed_channel = true; + } + + return dma_request_channel(cap, stedma40_filter, &cfg); +} + /* DMA ENGINE functions */ static int d40_alloc_chan_resources(struct dma_chan *chan) { @@ -3615,6 +3666,13 @@ static int __init d40_probe(struct platform_device *pdev) d40_hw_init(base); + if (np) { + err = of_dma_controller_register(np, d40_xlate, NULL); + if (err && err != -ENODEV) + dev_err(&pdev->dev, + "could not register of_dma_controller\n"); + } + dev_info(base->dev, "initialized\n"); return 0;