lkml.org 
[lkml]   [2016]   [Nov]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] spi: davinci: Allow device tree devices to use DMA
From
Date
On Saturday 19 November 2016 10:11 AM, David Lechner wrote:
> This makes SPI devices specified in a device tree use DMA when the master
> controller has DMA configured.
>
> Since device tree is supposed to only describe the hardware, adding a
> configuration option to device tree to enable DMA per-device would not be
> acceptable. So, this is the best we can do for now to get SPI devices
> working with DMA when using device tree.
>
> Unfortunately, this excludes the possibility of using one SPI device with
> DMA and one without on the same master.
>
> I have tested this on LEGO MINDSTORMS EV3 using the NOR flash. Reading the
> flash memory would fail with -EIO when DMA is not enabled for the device.
>
> Signed-off-by: David Lechner <david@lechnology.com>
> ---
> 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)

This should be

if (!(IS_ERR(dpsi->dma_rx) || IS_ERR(dspi->dma_tx))

> + spicfg->io_type = SPI_IO_TYPE_DMA;

Otherwise looks good to me.

Thanks,
Sekhar

\
 
 \ /
  Last update: 2016-11-20 14:00    [W:0.068 / U:1.948 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site