From patchwork Tue Aug 14 13:49:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Genoud X-Patchwork-Id: 1319521 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 5B89ADF215 for ; Tue, 14 Aug 2012 13:57:39 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T1HYv-0001ry-Ep; Tue, 14 Aug 2012 13:53:37 +0000 Received: from mail-wg0-f49.google.com ([74.125.82.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1T1HW1-0000aO-Kz for linux-arm-kernel@lists.infradead.org; Tue, 14 Aug 2012 13:50:40 +0000 Received: by mail-wg0-f49.google.com with SMTP id ez12so257818wgb.18 for ; Tue, 14 Aug 2012 06:50:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=yjsY2yRGx2Fqf/l5PQPmmT97kpMwjYtB7nMKPU6PCC8=; b=B2OQ8O2bkU09S4KP+IqfDRgxONnV2fpRY2GiJ6yFEHZyXK6y+dbksLDbj6NAWR+8S5 ZEI3EsKBpragFG7Sg1MOuGvoyz7DNJT7f8nIZ89Ksj4oMsU7I6oKngTNINg01nfqt47C jpSjvGe7e1JUOJSBZMkLlsEIj7hf4MVlydyzd/XrRXb70U2xNJyOYfhsx1MJrBIhJbyz lHw5b54g2eYLaWx5+epOZjfJmF7YZRPnkqwUQd+zsj2QGhtH1JcEmRzCzBYPDktjhBD8 8wiBmRxRCjlLYEgFkIAaRarLORT+GwClPYSbWTnnL0CqIuJ5uqrjCjSU1wXQTpSuKcKt RCkw== Received: by 10.180.107.2 with SMTP id gy2mr28171130wib.2.1344952237231; Tue, 14 Aug 2012 06:50:37 -0700 (PDT) Received: from localhost.localdomain (lyon.paratronic.fr. [213.41.177.106]) by mx.google.com with ESMTPS id eu4sm22509397wib.2.2012.08.14.06.50.36 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 14 Aug 2012 06:50:36 -0700 (PDT) From: Richard Genoud To: Nicolas Ferre Subject: [PATCH 12/23] spi-atmel: Fix spi-atmel driver to adapt to slave_config changes Date: Tue, 14 Aug 2012 15:49:26 +0200 Message-Id: <1344952177-18385-13-git-send-email-richard.genoud@gmail.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1344952177-18385-1-git-send-email-richard.genoud@gmail.com> References: <1344952177-18385-1-git-send-email-richard.genoud@gmail.com> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.49 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (richard.genoud[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Richard Genoud , Jean-Christophe PLAGNIOL-VILLARD , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This is the following of the patch e2b35f3dbfc080f15b72834d08f04f0269dbe9be Signed-off-by: Richard Genoud --- drivers/spi/spi-atmel.c | 45 ++++++++++++++++++++++++++++++++++++--------- 1 files changed, 36 insertions(+), 9 deletions(-) diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c index d90e8fb..28a00ab 100644 --- a/drivers/spi/spi-atmel.c +++ b/drivers/spi/spi-atmel.c @@ -399,17 +399,24 @@ static int __devinit atmel_spi_configure_dma(struct spi_master *master) { struct atmel_spi *as = spi_master_get_devdata(master); struct device *controller = master->dev.parent; + struct dma_slave_config slave_config; struct at_dma_slave *sdata; + int err; sdata = controller->platform_data; + 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); @@ -417,14 +424,28 @@ static int __devinit atmel_spi_configure_dma(struct spi_master *master) if (as->dma.chan_tx) as->dma.chan_rx = 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 " @@ -433,6 +454,12 @@ static int __devinit atmel_spi_configure_dma(struct spi_master *master) 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)