From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S939374AbdAFD1l (ORCPT ); Thu, 5 Jan 2017 22:27:41 -0500 Received: from vern.gendns.com ([206.190.152.46]:57771 "EHLO vern.gendns.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752858AbdAFD1e (ORCPT ); Thu, 5 Jan 2017 22:27:34 -0500 From: David Lechner To: Mark Brown Cc: David Lechner , nsekhar@ti.com, khilman@kernel.org, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RESEND] spi: davinci: Allow device tree devices to use DMA Date: Thu, 5 Jan 2017 21:26:17 -0600 Message-Id: <1483673177-31516-1-git-send-email-david@lechnology.com> X-Mailer: git-send-email 2.7.4 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This allows SPI devices specified in a device tree to use DMA when the master controller. Since device tree is supposed to only describe the hardware, adding such a configuration option to device tree would not be acceptable. So, this is the best we can do for now to get SPI devices working with DMA. Unfortunately, this excludes the possibility of using one SPI device with DMA and one without on the same master. Signed-off-by: David Lechner --- When I originally submitted this patch, there was some discussion as to whether dspi->dma_rx should be changed to return an error rather than being null. However, I prefer it the way it is and don't see a compelling reason to change it. drivers/spi/spi-davinci.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c index d36c11b..c6cf73a 100644 --- a/drivers/spi/spi-davinci.c +++ b/drivers/spi/spi-davinci.c @@ -388,6 +388,7 @@ static int davinci_spi_setup_transfer(struct spi_device *spi, static int davinci_spi_of_setup(struct spi_device *spi) { struct davinci_spi_config *spicfg = spi->controller_data; + struct davinci_spi *dspi = spi_master_get_devdata(spi->master); struct device_node *np = spi->dev.of_node; u32 prop; @@ -400,6 +401,9 @@ static int davinci_spi_of_setup(struct spi_device *spi) if (!of_property_read_u32(np, "ti,spi-wdelay", &prop)) spicfg->wdelay = (u8)prop; spi->controller_data = spicfg; + /* Use DMA for device if master supports it */ + if (dspi->dma_rx) + spicfg->io_type = SPI_IO_TYPE_DMA; } return 0; -- 2.7.4