RE: [PATCH 2/3] davinci: spi: add replacement SPI driver

2010-06-10 Thread Sudhakar Rajashekhara
Hi,

On Mon, Jun 07, 2010 at 20:39:07, Brian Niebuhr wrote:
> 
> Signed-off-by: Brian Niebuhr 
> ---
>  arch/arm/mach-davinci/include/mach/spi.h |   41 +-
>  drivers/spi/davinci_spi.c|  936 
> ++
>  drivers/spi/davinci_spi.h|  186 ++
>  3 files changed, 1149 insertions(+), 14 deletions(-)
>  create mode 100644 drivers/spi/davinci_spi.c
>  create mode 100644 drivers/spi/davinci_spi.h
> 
> diff --git a/arch/arm/mach-davinci/include/mach/spi.h 
> b/arch/arm/mach-davinci/include/mach/spi.h
> index 910efbf..10c39d8 100644
> --- a/arch/arm/mach-davinci/include/mach/spi.h
> +++ b/arch/arm/mach-davinci/include/mach/spi.h
> @@ -19,26 +19,39 @@
>  #ifndef __ARCH_ARM_DAVINCI_SPI_H
>  #define __ARCH_ARM_DAVINCI_SPI_H
>  
> +#define SPI_INTERN_CS0xFF
> +
> +/* resource flags for IORESOURCE_DMA resources */
> +#define IORESOURCE_DMA_RX_CHAN   0x01
> +#define IORESOURCE_DMA_TX_CHAN   0x02
> +#define IORESOURCE_DMA_EVENT_Q   0x04
> +
>  enum {
> - SPI_VERSION_1, /* For DM355/DM365/DM6467 */
> + SPI_VERSION_1, /* For DM355/DM365/DM6467*/

Above line in the patch is not required.

[...]

> +/*
> + * davinci_spi_probe - probe function for SPI Master Controller
> + * @pdev: platform_device structure which contains plateform specific data
> + *
> + * According to Linux Device Model this function will be invoked by Linux
> + * with plateform_device struct which contains the device specific info.
> + * This function will map the SPI controller's memory, register IRQ,
> + * Reset SPI controller and setting its registers to default value.
> + * It will invoke spi_bitbang_start to create work queue so that client 
> driver
> + * can register transfer method to work queue.
> + */
> +static int davinci_spi_probe(struct platform_device *pdev)
> +{

[...]

> +
> + davinci_spi->version = pdata->version;
> +
> + davinci_spi->bitbang.flags = SPI_NO_CS | SPI_LSB_FIRST | SPI_LOOP;
> + if (davinci_spi->version == SPI_VERSION_2)
> + davinci_spi->bitbang.flags |= SPI_READY;
> +
> + dma_rx_chan = davinci_spi_get_dma_by_flag(pdev, IORESOURCE_DMA_RX_CHAN);
> + dma_tx_chan = davinci_spi_get_dma_by_flag(pdev, IORESOURCE_DMA_TX_CHAN);
> + dma_eventq  = davinci_spi_get_dma_by_flag(pdev, IORESOURCE_DMA_EVENT_Q);
> + davinci_spi->dma_channels.dma_rx_channel = -1;
> + davinci_spi->dma_channels.dma_rx_sync_dev = dma_rx_chan;
> + davinci_spi->dma_channels.dma_tx_channel = -1;
> + davinci_spi->dma_channels.dma_tx_sync_dev = dma_tx_chan;
> + davinci_spi->dma_channels.dummy_param_slot = -1;
> + davinci_spi->dma_channels.eventq = dma_eventq;

Can the above configurations be done only in case if DMA mode?

[...]

> + ret = spi_bitbang_start(&davinci_spi->bitbang);
> + if (ret != 0)
> + goto free_clk;
> +
> + dev_info(&pdev->dev, "Controller at 0x%p \n", davinci_spi->base);
> +

Some way of informing the user about the mode in which the driver is
working is desirable.

Regards,
Sudhakar


___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source


RE: [PATCH 2/3] davinci: spi: add replacement SPI driver

2010-06-14 Thread Brian Niebuhr
> > diff --git a/arch/arm/mach-davinci/include/mach/spi.h 
> b/arch/arm/mach-davinci/include/mach/spi.h
> > index 910efbf..10c39d8 100644
> > --- a/arch/arm/mach-davinci/include/mach/spi.h
> > +++ b/arch/arm/mach-davinci/include/mach/spi.h
> > @@ -19,26 +19,39 @@
> >  #ifndef __ARCH_ARM_DAVINCI_SPI_H
> >  #define __ARCH_ARM_DAVINCI_SPI_H
> >  
> > +#define SPI_INTERN_CS  0xFF
> > +
> > +/* resource flags for IORESOURCE_DMA resources */
> > +#define IORESOURCE_DMA_RX_CHAN 0x01
> > +#define IORESOURCE_DMA_TX_CHAN 0x02
> > +#define IORESOURCE_DMA_EVENT_Q 0x04
> > +
> >  enum {
> > -   SPI_VERSION_1, /* For DM355/DM365/DM6467 */
> > +   SPI_VERSION_1, /* For DM355/DM365/DM6467*/
> 
> Above line in the patch is not required.

Right.
 
> > +
> > +   davinci_spi->version = pdata->version;
> > +
> > +   davinci_spi->bitbang.flags = SPI_NO_CS | SPI_LSB_FIRST 
> | SPI_LOOP;
> > +   if (davinci_spi->version == SPI_VERSION_2)
> > +   davinci_spi->bitbang.flags |= SPI_READY;
> > +
> > +   dma_rx_chan = davinci_spi_get_dma_by_flag(pdev, 
> IORESOURCE_DMA_RX_CHAN);
> > +   dma_tx_chan = davinci_spi_get_dma_by_flag(pdev, 
> IORESOURCE_DMA_TX_CHAN);
> > +   dma_eventq  = davinci_spi_get_dma_by_flag(pdev, 
> IORESOURCE_DMA_EVENT_Q);
> > +   davinci_spi->dma_channels.dma_rx_channel = -1;
> > +   davinci_spi->dma_channels.dma_rx_sync_dev = dma_rx_chan;
> > +   davinci_spi->dma_channels.dma_tx_channel = -1;
> > +   davinci_spi->dma_channels.dma_tx_sync_dev = dma_tx_chan;
> > +   davinci_spi->dma_channels.dummy_param_slot = -1;
> > +   davinci_spi->dma_channels.eventq = dma_eventq;
> 
> Can the above configurations be done only in case if DMA mode?

DMA mode is selected on a per-device basis.  This initialization is for
the controller, so it needs to be prepared to handle DMA if a device
uses it.  If DMA is not required, no DMA resource need be assigned to
the controller.

> Some way of informing the user about the mode in which the driver is
> working is desirable.

Yes, I'll try to come up with something.

___
Davinci-linux-open-source mailing list
Davinci-linux-open-source@linux.davincidsp.com
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source