From patchwork Mon Jun 2 13:38:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 4282051 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 05EC3BEEAA for ; Mon, 2 Jun 2014 13:39:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 30D00202A1 for ; Mon, 2 Jun 2014 13:39:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3DDB82018E for ; Mon, 2 Jun 2014 13:39:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754781AbaFBNin (ORCPT ); Mon, 2 Jun 2014 09:38:43 -0400 Received: from michel.telenet-ops.be ([195.130.137.88]:33586 "EHLO michel.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754787AbaFBNid (ORCPT ); Mon, 2 Jun 2014 09:38:33 -0400 Received: from ayla.of.borg ([84.193.72.141]) by michel.telenet-ops.be with bizsmtp id 9ReX1o00S32ts5g06ReXfB; Mon, 02 Jun 2014 15:38:31 +0200 Received: from geert by ayla.of.borg with local (Exim 4.76) (envelope-from ) id 1WrSRb-0007iq-7Q; Mon, 02 Jun 2014 15:38:31 +0200 From: Geert Uytterhoeven To: Mark Brown Cc: Yoshihiro Shimoda , Magnus Damm , linux-spi@vger.kernel.org, linux-sh@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 09/18] spi: rspi: SPI DMA core needs both RX and TX DMA to function Date: Mon, 2 Jun 2014 15:38:11 +0200 Message-Id: <1401716301-29612-10-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1401716301-29612-1-git-send-email-geert+renesas@glider.be> References: <1401716301-29612-1-git-send-email-geert+renesas@glider.be> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The SPI DMA core framework needs both RX and TX DMA to function. As a preparation for converting the driver to use this framework, fall back to PIO if no DMA channel or only one DMA channel is available. This affects only RSPI, which could do DMA transfers for TX-only before. RSPI-RZ and QSPI (at least for Single SPI Transfers) will need both RX and TX DMA anyway. Signed-off-by: Geert Uytterhoeven --- drivers/spi/spi-rspi.c | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c index 1ec51cb00203..7b993f75a3cf 100644 --- a/drivers/spi/spi-rspi.c +++ b/drivers/spi/spi-rspi.c @@ -640,10 +640,6 @@ end_tx_mapped: static int rspi_is_dma(const struct rspi_data *rspi, struct spi_transfer *t) { - /* If the module receives data by DMAC, it also needs TX DMAC */ - if (t->rx_buf) - return rspi->chan_tx && rspi->chan_rx; - if (rspi->chan_tx) return 1; @@ -985,29 +981,25 @@ static int rspi_request_dma(struct device *dev, struct rspi_data *rspi, { const struct rspi_plat_data *rspi_pd = dev_get_platdata(dev); - if (!rspi_pd) + if (!rspi_pd || !rspi_pd->dma_rx_id || !rspi_pd->dma_tx_id) return 0; /* The driver assumes no error. */ - /* If the module receives data by DMAC, it also needs TX DMAC */ - if (rspi_pd->dma_rx_id && rspi_pd->dma_tx_id) { - rspi->chan_rx = rspi_request_dma_chan(dev, DMA_DEV_TO_MEM, - rspi_pd->dma_rx_id, - res->start + RSPI_SPDR); - if (!rspi->chan_rx) - return -ENODEV; + rspi->chan_rx = rspi_request_dma_chan(dev, DMA_DEV_TO_MEM, + rspi_pd->dma_rx_id, + res->start + RSPI_SPDR); + if (!rspi->chan_rx) + return -ENODEV; - dev_info(dev, "Use DMA when rx.\n"); - } - if (rspi_pd->dma_tx_id) { - rspi->chan_tx = rspi_request_dma_chan(dev, DMA_MEM_TO_DEV, - rspi_pd->dma_tx_id, - res->start + RSPI_SPDR); - if (!rspi->chan_tx) - return -ENODEV; - - dev_info(dev, "Use DMA when tx\n"); + rspi->chan_tx = rspi_request_dma_chan(dev, DMA_MEM_TO_DEV, + rspi_pd->dma_tx_id, + res->start + RSPI_SPDR); + if (!rspi->chan_tx) { + dma_release_channel(rspi->chan_rx); + rspi->chan_rx = NULL; + return -ENODEV; } + dev_info(dev, "DMA available"); return 0; }