Re: [PATCH 15/23] spi: s3c64xx: move to generic dmaengine API

2013-03-06 Thread Padma Venkat
Hi Arnd,

On Tue, Mar 5, 2013 at 11:12 PM, Arnd Bergmann a...@arndb.de wrote:
 The spi-s3c64xx uses a Samsung proprietary interface for
 talking to the DMA engine, which does not work with
 multiplatform kernels. Since the driver can also operate
 in PIO mode without any DMA, older platforms that do
 not support the DMA engine API will still work, although
 slower.

 The conversion was rather mechanical, since the samsung
 interface is just a shallow wrapper around the dmaengine
 interface.

 Signed-off-by: Arnd Bergmann a...@arndb.de
 ---
  arch/arm/plat-samsung/devs.c  |  10 +++
  drivers/spi/spi-s3c64xx.c | 107 
 ++
  include/linux/platform_data/spi-s3c64xx.h |   3 +
  3 files changed, 62 insertions(+), 58 deletions(-)

 diff --git a/arch/arm/plat-samsung/devs.c b/arch/arm/plat-samsung/devs.c
 index 76209c9..58fb02a 100644
 --- a/arch/arm/plat-samsung/devs.c
 +++ b/arch/arm/plat-samsung/devs.c
 @@ -10,6 +10,7 @@
   * published by the Free Software Foundation.
  */

 +#include linux/amba/pl330.h
  #include linux/kernel.h
  #include linux/types.h
  #include linux/interrupt.h
 @@ -1551,6 +1552,9 @@ void __init s3c64xx_spi0_set_platdata(int 
 (*cfg_gpio)(void), int src_clk_nr,
 pd.num_cs = num_cs;
 pd.src_clk_nr = src_clk_nr;
 pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi0_cfg_gpio;
 +#ifdef CONFIG_PL330_DMA
 +   pd.filter = pl330_filter;
 +#endif

 s3c_set_platdata(pd, sizeof(pd), s3c64xx_device_spi0);
  }
 @@ -1589,6 +1593,9 @@ void __init s3c64xx_spi1_set_platdata(int 
 (*cfg_gpio)(void), int src_clk_nr,
 pd.num_cs = num_cs;
 pd.src_clk_nr = src_clk_nr;
 pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi1_cfg_gpio;
 +#ifdef CONFIG_PL330_DMA
 +   pd.filter = pl330_filter;
 +#endif

 s3c_set_platdata(pd, sizeof(pd), s3c64xx_device_spi1);
  }
 @@ -1627,6 +1634,9 @@ void __init s3c64xx_spi2_set_platdata(int 
 (*cfg_gpio)(void), int src_clk_nr,
 pd.num_cs = num_cs;
 pd.src_clk_nr = src_clk_nr;
 pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi2_cfg_gpio;
 +#ifdef CONFIG_PL330_DMA
 +   pd.filter = pl330_filter;
 +#endif

 s3c_set_platdata(pd, sizeof(pd), s3c64xx_device_spi2);
  }
 diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
 index e862ab8..9be07a6 100644
 --- a/drivers/spi/spi-s3c64xx.c
 +++ b/drivers/spi/spi-s3c64xx.c
 @@ -22,8 +22,10 @@
  #include linux/workqueue.h
  #include linux/interrupt.h
  #include linux/delay.h
 +#include linux/amba/pl330.h
  #include linux/clk.h
  #include linux/dma-mapping.h
 +#include linux/dmaengine.h
  #include linux/platform_device.h
  #include linux/pm_runtime.h
  #include linux/spi/spi.h
 @@ -31,7 +33,6 @@
  #include linux/of.h
  #include linux/of_gpio.h

 -#include mach/dma.h
  #include linux/platform_data/spi-s3c64xx.h

  #define MAX_SPI_PORTS  3
 @@ -131,9 +132,9 @@
  #define TXBUSY(13)

  struct s3c64xx_spi_dma_data {
 -   unsignedch;
 +   struct dma_chan *ch;
 enum dma_transfer_direction direction;
 -   enum dma_ch dmach;
 +   unsigned int request;
  };

  /**
 @@ -195,16 +196,11 @@ struct s3c64xx_spi_driver_data {
 unsignedcur_speed;
 struct s3c64xx_spi_dma_data rx_dma;
 struct s3c64xx_spi_dma_data tx_dma;
 -   struct samsung_dma_ops  *ops;
 struct s3c64xx_spi_port_config  *port_conf;
 unsigned intport_id;
 unsigned long   gpios[4];
  };

 -static struct s3c2410_dma_client s3c64xx_spi_dma_client = {
 -   .name = samsung-spi-dma,
 -};
 -
  static void flush_fifo(struct s3c64xx_spi_driver_data *sdd)
  {
 void __iomem *regs = sdd-regs;
 @@ -285,50 +281,42 @@ static void prepare_dma(struct s3c64xx_spi_dma_data 
 *dma,
 unsigned len, dma_addr_t buf)
  {
 struct s3c64xx_spi_driver_data *sdd;
 -   struct samsung_dma_prep info;
 -   struct samsung_dma_config config;
 +   struct dma_slave_config config;
 +   struct scatterlist sg;
 +   struct dma_async_tx_descriptor *desc;

 if (dma-direction == DMA_DEV_TO_MEM) {
 sdd = container_of((void *)dma,
 struct s3c64xx_spi_driver_data, rx_dma);
 -   config.direction = sdd-rx_dma.direction;
 -   config.fifo = sdd-sfr_start + S3C64XX_SPI_RX_DATA;
 -   config.width = sdd-cur_bpw / 8;
 -   sdd-ops-config(sdd-rx_dma.ch, config);
 +   config.direction = dma-direction;
 +   config.src_addr = sdd-sfr_start + S3C64XX_SPI_RX_DATA;
 +   config.src_addr_width = sdd-cur_bpw / 8;
 +   config.src_maxburst = 1;
 +   dmaengine_slave_config(dma-ch, config);
 } else {
 sdd = container_of((void *)dma,
 struct 

[PATCH 15/23] spi: s3c64xx: move to generic dmaengine API

2013-03-05 Thread Arnd Bergmann
The spi-s3c64xx uses a Samsung proprietary interface for
talking to the DMA engine, which does not work with
multiplatform kernels. Since the driver can also operate
in PIO mode without any DMA, older platforms that do
not support the DMA engine API will still work, although
slower.

The conversion was rather mechanical, since the samsung
interface is just a shallow wrapper around the dmaengine
interface.

Signed-off-by: Arnd Bergmann a...@arndb.de
---
 arch/arm/plat-samsung/devs.c  |  10 +++
 drivers/spi/spi-s3c64xx.c | 107 ++
 include/linux/platform_data/spi-s3c64xx.h |   3 +
 3 files changed, 62 insertions(+), 58 deletions(-)

diff --git a/arch/arm/plat-samsung/devs.c b/arch/arm/plat-samsung/devs.c
index 76209c9..58fb02a 100644
--- a/arch/arm/plat-samsung/devs.c
+++ b/arch/arm/plat-samsung/devs.c
@@ -10,6 +10,7 @@
  * published by the Free Software Foundation.
 */
 
+#include linux/amba/pl330.h
 #include linux/kernel.h
 #include linux/types.h
 #include linux/interrupt.h
@@ -1551,6 +1552,9 @@ void __init s3c64xx_spi0_set_platdata(int 
(*cfg_gpio)(void), int src_clk_nr,
pd.num_cs = num_cs;
pd.src_clk_nr = src_clk_nr;
pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi0_cfg_gpio;
+#ifdef CONFIG_PL330_DMA
+   pd.filter = pl330_filter;
+#endif
 
s3c_set_platdata(pd, sizeof(pd), s3c64xx_device_spi0);
 }
@@ -1589,6 +1593,9 @@ void __init s3c64xx_spi1_set_platdata(int 
(*cfg_gpio)(void), int src_clk_nr,
pd.num_cs = num_cs;
pd.src_clk_nr = src_clk_nr;
pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi1_cfg_gpio;
+#ifdef CONFIG_PL330_DMA
+   pd.filter = pl330_filter;
+#endif
 
s3c_set_platdata(pd, sizeof(pd), s3c64xx_device_spi1);
 }
@@ -1627,6 +1634,9 @@ void __init s3c64xx_spi2_set_platdata(int 
(*cfg_gpio)(void), int src_clk_nr,
pd.num_cs = num_cs;
pd.src_clk_nr = src_clk_nr;
pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi2_cfg_gpio;
+#ifdef CONFIG_PL330_DMA
+   pd.filter = pl330_filter;
+#endif
 
s3c_set_platdata(pd, sizeof(pd), s3c64xx_device_spi2);
 }
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index e862ab8..9be07a6 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -22,8 +22,10 @@
 #include linux/workqueue.h
 #include linux/interrupt.h
 #include linux/delay.h
+#include linux/amba/pl330.h
 #include linux/clk.h
 #include linux/dma-mapping.h
+#include linux/dmaengine.h
 #include linux/platform_device.h
 #include linux/pm_runtime.h
 #include linux/spi/spi.h
@@ -31,7 +33,6 @@
 #include linux/of.h
 #include linux/of_gpio.h
 
-#include mach/dma.h
 #include linux/platform_data/spi-s3c64xx.h
 
 #define MAX_SPI_PORTS  3
@@ -131,9 +132,9 @@
 #define TXBUSY(13)
 
 struct s3c64xx_spi_dma_data {
-   unsignedch;
+   struct dma_chan *ch;
enum dma_transfer_direction direction;
-   enum dma_ch dmach;
+   unsigned int request;
 };
 
 /**
@@ -195,16 +196,11 @@ struct s3c64xx_spi_driver_data {
unsignedcur_speed;
struct s3c64xx_spi_dma_data rx_dma;
struct s3c64xx_spi_dma_data tx_dma;
-   struct samsung_dma_ops  *ops;
struct s3c64xx_spi_port_config  *port_conf;
unsigned intport_id;
unsigned long   gpios[4];
 };
 
-static struct s3c2410_dma_client s3c64xx_spi_dma_client = {
-   .name = samsung-spi-dma,
-};
-
 static void flush_fifo(struct s3c64xx_spi_driver_data *sdd)
 {
void __iomem *regs = sdd-regs;
@@ -285,50 +281,42 @@ static void prepare_dma(struct s3c64xx_spi_dma_data *dma,
unsigned len, dma_addr_t buf)
 {
struct s3c64xx_spi_driver_data *sdd;
-   struct samsung_dma_prep info;
-   struct samsung_dma_config config;
+   struct dma_slave_config config;
+   struct scatterlist sg;
+   struct dma_async_tx_descriptor *desc;
 
if (dma-direction == DMA_DEV_TO_MEM) {
sdd = container_of((void *)dma,
struct s3c64xx_spi_driver_data, rx_dma);
-   config.direction = sdd-rx_dma.direction;
-   config.fifo = sdd-sfr_start + S3C64XX_SPI_RX_DATA;
-   config.width = sdd-cur_bpw / 8;
-   sdd-ops-config(sdd-rx_dma.ch, config);
+   config.direction = dma-direction;
+   config.src_addr = sdd-sfr_start + S3C64XX_SPI_RX_DATA;
+   config.src_addr_width = sdd-cur_bpw / 8;
+   config.src_maxburst = 1;
+   dmaengine_slave_config(dma-ch, config);
} else {
sdd = container_of((void *)dma,
struct s3c64xx_spi_driver_data, tx_dma);
-   config.direction =  sdd-tx_dma.direction;
-   config.fifo = sdd-sfr_start + S3C64XX_SPI_TX_DATA;
-   config.width =