From patchwork Mon Nov 12 08:52:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenyou Yang X-Patchwork-Id: 1726871 Return-Path: X-Original-To: patchwork-spi-devel-general@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by patchwork2.kernel.org (Postfix) with ESMTP id DFFECDFE80 for ; Mon, 12 Nov 2012 08:56:37 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1TXpor-0007zO-If; Mon, 12 Nov 2012 08:56:37 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1TXpoq-0007zI-O8 for spi-devel-general@lists.sourceforge.net; Mon, 12 Nov 2012 08:56:36 +0000 Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of atmel.com designates 204.2.163.5 as permitted sender) client-ip=204.2.163.5; envelope-from=Wenyou.Yang@atmel.com; helo=sjogate2.atmel.com; Received: from newsmtp5.atmel.com ([204.2.163.5] helo=sjogate2.atmel.com) by sog-mx-1.v43.ch3.sourceforge.com with esmtp (Exim 4.76) id 1TXpol-0006fV-17 for spi-devel-general@lists.sourceforge.net; Mon, 12 Nov 2012 08:56:36 +0000 Received: from penbh01.corp.atmel.com ([10.168.5.31]) by sjogate2.atmel.com (8.13.6/8.13.6) with ESMTP id qAC8oZEL029478; Mon, 12 Nov 2012 00:51:11 -0800 (PST) Received: from penmb01.corp.atmel.com ([10.168.5.33]) by penbh01.corp.atmel.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 12 Nov 2012 16:56:13 +0800 Received: from shaarm01.corp.atmel.com ([10.217.6.34]) by penmb01.corp.atmel.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 12 Nov 2012 16:56:12 +0800 From: Wenyou Yang To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 08/17] spi/atmel_spi: Fix spi-atmel driver to adapt to slave_config changes Date: Mon, 12 Nov 2012 16:52:28 +0800 Message-Id: <1352710357-3265-9-git-send-email-wenyou.yang@atmel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1352710357-3265-1-git-send-email-wenyou.yang@atmel.com> References: <1352710357-3265-1-git-send-email-wenyou.yang@atmel.com> X-OriginalArrivalTime: 12 Nov 2012 08:56:12.0957 (UTC) FILETIME=[911824D0:01CDC0B3] X-Spam-Score: -1.7 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record -0.2 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-Headers-End: 1TXpol-0006fV-17 Cc: Richard Genoud , JM.Lin@atmel.com, nicolas.ferre@atmel.com, wenyou.yang@atmel.com, spi-devel-general@lists.sourceforge.net X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: spi-devel-general-bounces@lists.sourceforge.net From: Richard Genoud This is the following of the patch e2b35f3dbfc080f15b72834d08f04f0269dbe9be Signed-off-by: Richard Genoud Cc: grant.likely@secretlab.ca Cc: spi-devel-general@lists.sourceforge.net --- drivers/spi/spi-atmel.c | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index 4cb5f05..00e729b 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -409,14 +409,21 @@ static bool filter(struct dma_chan *chan, void *slave) static int __devinit atmel_spi_configure_dma(struct atmel_spi *as) { struct at_dma_slave *sdata = (struct at_dma_slave *)&as->data.dma_slave; + struct dma_slave_config slave_config; + int err; + + memset(&slave_config, 0, sizeof(slave_config)); + slave_config.dst_addr = (dma_addr_t)as->phybase + SPI_TDR; + slave_config.src_addr = (dma_addr_t)as->phybase + SPI_RDR; + slave_config.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; + slave_config.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; + slave_config.src_maxburst = 1; + slave_config.dst_maxburst = 1; + slave_config.device_fc = false; if (sdata && sdata->dma_dev) { dma_cap_mask_t mask; - /* setup DMA addresses */ - sdata->rx_reg = (dma_addr_t)as->phybase + SPI_RDR; - sdata->tx_reg = (dma_addr_t)as->phybase + SPI_TDR; - /* Try to grab two DMA channels */ dma_cap_zero(mask); dma_cap_set(DMA_SLAVE, mask); @@ -426,13 +433,26 @@ static int __devinit atmel_spi_configure_dma(struct atmel_spi *as) dma_request_channel(mask, filter, sdata); } if (!as->dma.chan_rx || !as->dma.chan_tx) { - if (as->dma.chan_rx) - dma_release_channel(as->dma.chan_rx); - if (as->dma.chan_tx) - dma_release_channel(as->dma.chan_tx); dev_err(&as->pdev->dev, "DMA channel not available, " \ "unable to use SPI\n"); - return -EBUSY; + err = -EBUSY; + goto error; + } + + slave_config.direction = DMA_TO_DEVICE; + if (dmaengine_slave_config(as->dma.chan_tx, &slave_config)) { + dev_err(&as->pdev->dev, + "failed to configure tx dma channel\n"); + err = -EINVAL; + goto error; + } + + slave_config.direction = DMA_FROM_DEVICE; + if (dmaengine_slave_config(as->dma.chan_rx, &slave_config)) { + dev_err(&as->pdev->dev, + "failed to configure rx dma channel\n"); + err = -EINVAL; + goto error; } dev_info(&as->pdev->dev, "Using %s (tx) and " \ @@ -441,6 +461,12 @@ static int __devinit atmel_spi_configure_dma(struct atmel_spi *as) dma_chan_name(as->dma.chan_rx)); return 0; +error: + if (as->dma.chan_rx) + dma_release_channel(as->dma.chan_rx); + if (as->dma.chan_tx) + dma_release_channel(as->dma.chan_tx); + return err; } static void atmel_spi_stop_dma(struct atmel_spi *as)