From patchwork Tue Mar 5 12:23:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 2219041 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id B3A0C3FCF6 for ; Tue, 5 Mar 2013 12:29:01 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UCqwn-0002yE-1Z; Tue, 05 Mar 2013 12:26:21 +0000 Received: from tx2ehsobe003.messaging.microsoft.com ([65.55.88.13] helo=tx2outboundpool.messaging.microsoft.com) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UCqvx-0002kW-5g for linux-arm-kernel@lists.infradead.org; Tue, 05 Mar 2013 12:25:31 +0000 Received: from mail143-tx2-R.bigfish.com (10.9.14.228) by TX2EHSOBE010.bigfish.com (10.9.40.30) with Microsoft SMTP Server id 14.1.225.23; Tue, 5 Mar 2013 12:25:27 +0000 Received: from mail143-tx2 (localhost [127.0.0.1]) by mail143-tx2-R.bigfish.com (Postfix) with ESMTP id 675EC20128; Tue, 5 Mar 2013 12:25:27 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 7 X-BigFish: VS7(z1039ozzz1f42h1ee6h1de0h1202h1e76h1d1ah1d2ahzz8275dhz2dh87h2a8h668h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1155h) X-FB-DOMAIN-IP-MATCH: fail Received: from mail143-tx2 (localhost.localdomain [127.0.0.1]) by mail143-tx2 (MessageSwitch) id 1362486324601549_29446; Tue, 5 Mar 2013 12:25:24 +0000 (UTC) Received: from TX2EHSMHS036.bigfish.com (unknown [10.9.14.226]) by mail143-tx2.bigfish.com (Postfix) with ESMTP id 497BB360090; Tue, 5 Mar 2013 12:25:24 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by TX2EHSMHS036.bigfish.com (10.9.99.136) with Microsoft SMTP Server (TLS) id 14.1.225.23; Tue, 5 Mar 2013 12:25:21 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server (TLS) id 14.2.328.11; Tue, 5 Mar 2013 12:25:20 +0000 Received: from S2101-09.ap.freescale.net ([10.192.185.138]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id r25COt6m010636; Tue, 5 Mar 2013 05:25:18 -0700 From: Shawn Guo To: Subject: [PATCH v2 05/12] spi: mxs-spi: move to use generic DMA helper Date: Tue, 5 Mar 2013 20:23:57 +0800 Message-ID: <1362486244-24593-6-git-send-email-shawn.guo@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1362486244-24593-1-git-send-email-shawn.guo@linaro.org> References: <1362486244-24593-1-git-send-email-shawn.guo@linaro.org> MIME-Version: 1.0 X-OriginatorOrg: sigmatel.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130305_072529_353127_5E6FB87A X-CRM114-Status: GOOD ( 20.28 ) X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [65.55.88.13 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Fabio Estevam , Arnd Bergmann , Huang Shijie , Vinod Koul , Marek Vasut , Shawn Guo X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org With the generic DMA device tree helper supported by mxs-dma driver, client devices only need to call dma_request_slave_channel() for requesting a DMA channel from dmaengine. Since mxs is a DT only platform now, along with the changes, the non-DT case handling in probe function also gets removed. Signed-off-by: Shawn Guo Acked-by: Grant Likely --- Documentation/devicetree/bindings/spi/mxs-spi.txt | 12 +++-- drivers/spi/spi-mxs.c | 60 ++++----------------- include/linux/spi/mxs-spi.h | 4 +- 3 files changed, 18 insertions(+), 58 deletions(-) diff --git a/Documentation/devicetree/bindings/spi/mxs-spi.txt b/Documentation/devicetree/bindings/spi/mxs-spi.txt index e2e1395..3499b73 100644 --- a/Documentation/devicetree/bindings/spi/mxs-spi.txt +++ b/Documentation/devicetree/bindings/spi/mxs-spi.txt @@ -3,8 +3,11 @@ Required properties: - compatible: Should be "fsl,-spi", where soc is "imx23" or "imx28" - reg: Offset and length of the register set for the device -- interrupts: Should contain SSP interrupts (error irq first, dma irq second) -- fsl,ssp-dma-channel: APBX DMA channel for the SSP +- interrupts: Should contain SSP ERROR interrupt +- dmas: DMA specifier, consisting of a phandle to DMA controller node + and SSP DMA channel ID. + Refer to dma.txt and fsl-mxs-dma.txt for details. +- dma-names: Must be "rx-tx". Optional properties: - clock-frequency : Input clock frequency to the SPI block in Hz. @@ -17,6 +20,7 @@ ssp0: ssp@80010000 { #size-cells = <0>; compatible = "fsl,imx28-spi"; reg = <0x80010000 0x2000>; - interrupts = <96 82>; - fsl,ssp-dma-channel = <0>; + interrupts = <96>; + dmas = <&dma_apbh 0>; + dma-names = "rx-tx"; }; diff --git a/drivers/spi/spi-mxs.c b/drivers/spi/spi-mxs.c index 22a0af0..7b1c014 100644 --- a/drivers/spi/spi-mxs.c +++ b/drivers/spi/spi-mxs.c @@ -490,21 +490,6 @@ static int mxs_spi_transfer_one(struct spi_master *master, return status; } -static bool mxs_ssp_dma_filter(struct dma_chan *chan, void *param) -{ - struct mxs_ssp *ssp = param; - - if (!mxs_dma_is_apbh(chan)) - return false; - - if (chan->chan_id != ssp->dma_channel) - return false; - - chan->private = &ssp->dma_data; - - return true; -} - static const struct of_device_id mxs_spi_dt_ids[] = { { .compatible = "fsl,imx23-spi", .data = (void *) IMX23_SSP, }, { .compatible = "fsl,imx28-spi", .data = (void *) IMX28_SSP, }, @@ -520,13 +505,12 @@ static int mxs_spi_probe(struct platform_device *pdev) struct spi_master *master; struct mxs_spi *spi; struct mxs_ssp *ssp; - struct resource *iores, *dmares; + struct resource *iores; struct pinctrl *pinctrl; struct clk *clk; void __iomem *base; - int devid, dma_channel, clk_freq; - int ret = 0, irq_err, irq_dma; - dma_cap_mask_t mask; + int devid, clk_freq; + int ret = 0, irq_err; /* * Default clock speed for the SPI core. 160MHz seems to @@ -537,8 +521,7 @@ static int mxs_spi_probe(struct platform_device *pdev) iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); irq_err = platform_get_irq(pdev, 0); - irq_dma = platform_get_irq(pdev, 1); - if (!iores || irq_err < 0 || irq_dma < 0) + if (!iores || irq_err < 0) return -EINVAL; base = devm_ioremap_resource(&pdev->dev, iores); @@ -553,32 +536,11 @@ static int mxs_spi_probe(struct platform_device *pdev) if (IS_ERR(clk)) return PTR_ERR(clk); - if (np) { - devid = (enum mxs_ssp_id) of_id->data; - /* - * TODO: This is a temporary solution and should be changed - * to use generic DMA binding later when the helpers get in. - */ - ret = of_property_read_u32(np, "fsl,ssp-dma-channel", - &dma_channel); - if (ret) { - dev_err(&pdev->dev, - "Failed to get DMA channel\n"); - return -EINVAL; - } - - ret = of_property_read_u32(np, "clock-frequency", - &clk_freq); - if (ret) - clk_freq = clk_freq_default; - } else { - dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0); - if (!dmares) - return -EINVAL; - devid = pdev->id_entry->driver_data; - dma_channel = dmares->start; + devid = (enum mxs_ssp_id) of_id->data; + ret = of_property_read_u32(np, "clock-frequency", + &clk_freq); + if (ret) clk_freq = clk_freq_default; - } master = spi_alloc_master(&pdev->dev, sizeof(*spi)); if (!master) @@ -597,7 +559,6 @@ static int mxs_spi_probe(struct platform_device *pdev) ssp->clk = clk; ssp->base = base; ssp->devid = devid; - ssp->dma_channel = dma_channel; init_completion(&spi->c); @@ -606,10 +567,7 @@ static int mxs_spi_probe(struct platform_device *pdev) if (ret) goto out_master_free; - dma_cap_zero(mask); - dma_cap_set(DMA_SLAVE, mask); - ssp->dma_data.chan_irq = irq_dma; - ssp->dmach = dma_request_channel(mask, mxs_ssp_dma_filter, ssp); + ssp->dmach = dma_request_slave_channel(&pdev->dev, "rx-tx"); if (!ssp->dmach) { dev_err(ssp->dev, "Failed to request DMA\n"); goto out_master_free; diff --git a/include/linux/spi/mxs-spi.h b/include/linux/spi/mxs-spi.h index 61ae130..4835486 100644 --- a/include/linux/spi/mxs-spi.h +++ b/include/linux/spi/mxs-spi.h @@ -24,7 +24,7 @@ #ifndef __LINUX_SPI_MXS_SPI_H__ #define __LINUX_SPI_MXS_SPI_H__ -#include +#include #define ssp_is_old(host) ((host)->devid == IMX23_SSP) @@ -137,9 +137,7 @@ struct mxs_ssp { unsigned int clk_rate; enum mxs_ssp_id devid; - int dma_channel; struct dma_chan *dmach; - struct mxs_dma_data dma_data; unsigned int dma_dir; enum dma_transfer_direction slave_dirn; u32 ssp_pio_words[SSP_PIO_NUM];