Re: [PATCH v3] shdma: add R-Car Audio DMAC peri peri driver

2014-03-29 Thread Vinod Koul
On Mon, Mar 10, 2014 at 06:11:50PM -0700, Kuninori Morimoto wrote:
> From: Kuninori Morimoto 
> 
> Add support Audio DMAC peri peri driver
> for Renesas R-Car Gen2 SoC, using 'shdma-base'
> DMA driver framework.
> 
> Signed-off-by: Kuninori Morimoto 

Please run checkpatch *everytime* you generate a patch. I have fixes a simple
format error :(

Applied, now

-- 
~Vinod
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3] shdma: add R-Car Audio DMAC peri peri driver

2014-03-29 Thread Vinod Koul
On Mon, Mar 10, 2014 at 06:11:50PM -0700, Kuninori Morimoto wrote:
 From: Kuninori Morimoto kuninori.morimoto...@renesas.com
 
 Add support Audio DMAC peri peri driver
 for Renesas R-Car Gen2 SoC, using 'shdma-base'
 DMA driver framework.
 
 Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com

Please run checkpatch *everytime* you generate a patch. I have fixes a simple
format error :(

Applied, now

-- 
~Vinod
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3] shdma: add R-Car Audio DMAC peri peri driver

2014-03-24 Thread Kuninori Morimoto

Hi Vinod, and all

Could you please teach me current status of this patch ??

> From: Kuninori Morimoto 
> 
> Add support Audio DMAC peri peri driver
> for Renesas R-Car Gen2 SoC, using 'shdma-base'
> DMA driver framework.
> 
> Signed-off-by: Kuninori Morimoto 
> ---
> v2 -> v3
> 
>  - modiry copyright
>  - use %pad for dma_addr_t
>  - use sizeof(*hoge) for devm_kzalloc()
> 
>  drivers/dma/sh/Kconfig |6 +
>  drivers/dma/sh/Makefile|1 +
>  drivers/dma/sh/rcar-audmapp.c  |  320 
> 
>  include/linux/platform_data/dma-rcar-audmapp.h |   34 +++
>  4 files changed, 361 insertions(+)
>  create mode 100644 drivers/dma/sh/rcar-audmapp.c
>  create mode 100644 include/linux/platform_data/dma-rcar-audmapp.h
> 
> diff --git a/drivers/dma/sh/Kconfig b/drivers/dma/sh/Kconfig
> index dadd9e01..b4c8138 100644
> --- a/drivers/dma/sh/Kconfig
> +++ b/drivers/dma/sh/Kconfig
> @@ -29,6 +29,12 @@ config RCAR_HPB_DMAE
>   help
> Enable support for the Renesas R-Car series DMA controllers.
>  
> +config RCAR_AUDMAC_PP
> + tristate "Renesas R-Car Audio DMAC Peripheral Peripheral support"
> + depends on SH_DMAE_BASE
> + help
> +   Enable support for the Renesas R-Car Audio DMAC Peripheral Peripheral 
> controllers.
> +
>  config SHDMA_R8A73A4
>   def_bool y
>   depends on ARCH_R8A73A4 && SH_DMAE != n
> diff --git a/drivers/dma/sh/Makefile b/drivers/dma/sh/Makefile
> index e856af2..1ce88b2 100644
> --- a/drivers/dma/sh/Makefile
> +++ b/drivers/dma/sh/Makefile
> @@ -7,3 +7,4 @@ endif
>  shdma-objs := $(shdma-y)
>  obj-$(CONFIG_SUDMAC) += sudmac.o
>  obj-$(CONFIG_RCAR_HPB_DMAE) += rcar-hpbdma.o
> +obj-$(CONFIG_RCAR_AUDMAC_PP) += rcar-audmapp.o
> diff --git a/drivers/dma/sh/rcar-audmapp.c b/drivers/dma/sh/rcar-audmapp.c
> new file mode 100644
> index 000..72d7475
> --- /dev/null
> +++ b/drivers/dma/sh/rcar-audmapp.c
> @@ -0,0 +1,320 @@
> +/*
> + * This is for Renesas R-Car Audio-DMAC-peri-peri.
> + *
> + * Copyright (C) 2014 Renesas Electronics Corporation
> + * Copyright (C) 2014 Kuninori Morimoto 
> + *
> + * based on the drivers/dma/sh/shdma.c
> + *
> + * Copyright (C) 2011-2012 Guennadi Liakhovetski 
> + * Copyright (C) 2009 Nobuhiro Iwamatsu 
> + * Copyright (C) 2009 Renesas Solutions, Inc. All rights reserved.
> + * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
> + *
> + * This is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/*
> + * DMA register
> + */
> +#define PDMASAR  0x00
> +#define PDMADAR  0x04
> +#define PDMACHCR 0x0c
> +
> +/* PDMACHCR */
> +#define PDMACHCR_DE  (1 << 0)
> +
> +#define AUDMAPP_MAX_CHANNELS 29
> +
> +/* Default MEMCPY transfer size = 2^2 = 4 bytes */
> +#define LOG2_DEFAULT_XFER_SIZE   2
> +#define AUDMAPP_SLAVE_NUMBER 256
> +#define AUDMAPP_LEN_MAX  (16 * 1024 * 1024)
> +
> +struct audmapp_chan {
> + struct shdma_chan shdma_chan;
> + struct audmapp_slave_config *config;
> + void __iomem *base;
> +};
> +
> +struct audmapp_device {
> + struct shdma_dev shdma_dev;
> + struct audmapp_pdata *pdata;
> + struct device *dev;
> + void __iomem *chan_reg;
> +};
> +
> +#define to_chan(chan) container_of(chan, struct audmapp_chan, shdma_chan)
> +#define to_dev(chan) container_of(chan->shdma_chan.dma_chan.device,  \
> +   struct audmapp_device, shdma_dev.dma_dev)
> +
> +static void audmapp_write(struct audmapp_chan *auchan, u32 data, u32 reg)
> +{
> + struct audmapp_device *audev = to_dev(auchan);
> + struct device *dev = audev->dev;
> +
> + dev_dbg(dev, "w %p : %08x\n", auchan->base + reg, data);
> +
> + iowrite32(data, auchan->base + reg);
> +}
> +
> +static u32 audmapp_read(struct audmapp_chan *auchan, u32 reg)
> +{
> + return ioread32(auchan->base + reg);
> +}
> +
> +static void audmapp_halt(struct shdma_chan *schan)
> +{
> + struct audmapp_chan *auchan = to_chan(schan);
> + int i;
> +
> + audmapp_write(auchan, 0, PDMACHCR);
> +
> + for(i = 0; i < 1024; i++) {
> + if (0 == audmapp_read(auchan, PDMACHCR))
> + return;
> + udelay(1);
> + }
> +}
> +
> +static void audmapp_start_xfer(struct shdma_chan *schan,
> +struct shdma_desc *sdecs)
> +{
> + struct audmapp_chan *auchan = to_chan(schan);
> + struct audmapp_device *audev = to_dev(auchan);
> + struct audmapp_slave_config *cfg = auchan->config;
> + struct device *dev = audev->dev;
> + u32 chcr = cfg->chcr | PDMACHCR_DE;
> +
> + dev_dbg(dev, "src/dst/chcr 

Re: [PATCH v3] shdma: add R-Car Audio DMAC peri peri driver

2014-03-24 Thread Kuninori Morimoto

Hi Vinod, and all

Could you please teach me current status of this patch ??

 From: Kuninori Morimoto kuninori.morimoto...@renesas.com
 
 Add support Audio DMAC peri peri driver
 for Renesas R-Car Gen2 SoC, using 'shdma-base'
 DMA driver framework.
 
 Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
 ---
 v2 - v3
 
  - modiry copyright
  - use %pad for dma_addr_t
  - use sizeof(*hoge) for devm_kzalloc()
 
  drivers/dma/sh/Kconfig |6 +
  drivers/dma/sh/Makefile|1 +
  drivers/dma/sh/rcar-audmapp.c  |  320 
 
  include/linux/platform_data/dma-rcar-audmapp.h |   34 +++
  4 files changed, 361 insertions(+)
  create mode 100644 drivers/dma/sh/rcar-audmapp.c
  create mode 100644 include/linux/platform_data/dma-rcar-audmapp.h
 
 diff --git a/drivers/dma/sh/Kconfig b/drivers/dma/sh/Kconfig
 index dadd9e01..b4c8138 100644
 --- a/drivers/dma/sh/Kconfig
 +++ b/drivers/dma/sh/Kconfig
 @@ -29,6 +29,12 @@ config RCAR_HPB_DMAE
   help
 Enable support for the Renesas R-Car series DMA controllers.
  
 +config RCAR_AUDMAC_PP
 + tristate Renesas R-Car Audio DMAC Peripheral Peripheral support
 + depends on SH_DMAE_BASE
 + help
 +   Enable support for the Renesas R-Car Audio DMAC Peripheral Peripheral 
 controllers.
 +
  config SHDMA_R8A73A4
   def_bool y
   depends on ARCH_R8A73A4  SH_DMAE != n
 diff --git a/drivers/dma/sh/Makefile b/drivers/dma/sh/Makefile
 index e856af2..1ce88b2 100644
 --- a/drivers/dma/sh/Makefile
 +++ b/drivers/dma/sh/Makefile
 @@ -7,3 +7,4 @@ endif
  shdma-objs := $(shdma-y)
  obj-$(CONFIG_SUDMAC) += sudmac.o
  obj-$(CONFIG_RCAR_HPB_DMAE) += rcar-hpbdma.o
 +obj-$(CONFIG_RCAR_AUDMAC_PP) += rcar-audmapp.o
 diff --git a/drivers/dma/sh/rcar-audmapp.c b/drivers/dma/sh/rcar-audmapp.c
 new file mode 100644
 index 000..72d7475
 --- /dev/null
 +++ b/drivers/dma/sh/rcar-audmapp.c
 @@ -0,0 +1,320 @@
 +/*
 + * This is for Renesas R-Car Audio-DMAC-peri-peri.
 + *
 + * Copyright (C) 2014 Renesas Electronics Corporation
 + * Copyright (C) 2014 Kuninori Morimoto kuninori.morimoto...@renesas.com
 + *
 + * based on the drivers/dma/sh/shdma.c
 + *
 + * Copyright (C) 2011-2012 Guennadi Liakhovetski g.liakhovet...@gmx.de
 + * Copyright (C) 2009 Nobuhiro Iwamatsu iwamatsu.nobuh...@renesas.com
 + * Copyright (C) 2009 Renesas Solutions, Inc. All rights reserved.
 + * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
 + *
 + * This is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation; either version 2 of the License, or
 + * (at your option) any later version.
 + *
 + */
 +#include linux/delay.h
 +#include linux/init.h
 +#include linux/module.h
 +#include linux/slab.h
 +#include linux/dmaengine.h
 +#include linux/platform_data/dma-rcar-audmapp.h
 +#include linux/platform_device.h
 +#include linux/shdma-base.h
 +
 +/*
 + * DMA register
 + */
 +#define PDMASAR  0x00
 +#define PDMADAR  0x04
 +#define PDMACHCR 0x0c
 +
 +/* PDMACHCR */
 +#define PDMACHCR_DE  (1  0)
 +
 +#define AUDMAPP_MAX_CHANNELS 29
 +
 +/* Default MEMCPY transfer size = 2^2 = 4 bytes */
 +#define LOG2_DEFAULT_XFER_SIZE   2
 +#define AUDMAPP_SLAVE_NUMBER 256
 +#define AUDMAPP_LEN_MAX  (16 * 1024 * 1024)
 +
 +struct audmapp_chan {
 + struct shdma_chan shdma_chan;
 + struct audmapp_slave_config *config;
 + void __iomem *base;
 +};
 +
 +struct audmapp_device {
 + struct shdma_dev shdma_dev;
 + struct audmapp_pdata *pdata;
 + struct device *dev;
 + void __iomem *chan_reg;
 +};
 +
 +#define to_chan(chan) container_of(chan, struct audmapp_chan, shdma_chan)
 +#define to_dev(chan) container_of(chan-shdma_chan.dma_chan.device,  \
 +   struct audmapp_device, shdma_dev.dma_dev)
 +
 +static void audmapp_write(struct audmapp_chan *auchan, u32 data, u32 reg)
 +{
 + struct audmapp_device *audev = to_dev(auchan);
 + struct device *dev = audev-dev;
 +
 + dev_dbg(dev, w %p : %08x\n, auchan-base + reg, data);
 +
 + iowrite32(data, auchan-base + reg);
 +}
 +
 +static u32 audmapp_read(struct audmapp_chan *auchan, u32 reg)
 +{
 + return ioread32(auchan-base + reg);
 +}
 +
 +static void audmapp_halt(struct shdma_chan *schan)
 +{
 + struct audmapp_chan *auchan = to_chan(schan);
 + int i;
 +
 + audmapp_write(auchan, 0, PDMACHCR);
 +
 + for(i = 0; i  1024; i++) {
 + if (0 == audmapp_read(auchan, PDMACHCR))
 + return;
 + udelay(1);
 + }
 +}
 +
 +static void audmapp_start_xfer(struct shdma_chan *schan,
 +struct shdma_desc *sdecs)
 +{
 + struct audmapp_chan *auchan = to_chan(schan);
 + struct audmapp_device *audev = to_dev(auchan);
 + struct audmapp_slave_config *cfg = auchan-config;
 

[PATCH v3] shdma: add R-Car Audio DMAC peri peri driver

2014-03-10 Thread Kuninori Morimoto
From: Kuninori Morimoto 

Add support Audio DMAC peri peri driver
for Renesas R-Car Gen2 SoC, using 'shdma-base'
DMA driver framework.

Signed-off-by: Kuninori Morimoto 
---
v2 -> v3

 - modiry copyright
 - use %pad for dma_addr_t
 - use sizeof(*hoge) for devm_kzalloc()

 drivers/dma/sh/Kconfig |6 +
 drivers/dma/sh/Makefile|1 +
 drivers/dma/sh/rcar-audmapp.c  |  320 
 include/linux/platform_data/dma-rcar-audmapp.h |   34 +++
 4 files changed, 361 insertions(+)
 create mode 100644 drivers/dma/sh/rcar-audmapp.c
 create mode 100644 include/linux/platform_data/dma-rcar-audmapp.h

diff --git a/drivers/dma/sh/Kconfig b/drivers/dma/sh/Kconfig
index dadd9e01..b4c8138 100644
--- a/drivers/dma/sh/Kconfig
+++ b/drivers/dma/sh/Kconfig
@@ -29,6 +29,12 @@ config RCAR_HPB_DMAE
help
  Enable support for the Renesas R-Car series DMA controllers.
 
+config RCAR_AUDMAC_PP
+   tristate "Renesas R-Car Audio DMAC Peripheral Peripheral support"
+   depends on SH_DMAE_BASE
+   help
+ Enable support for the Renesas R-Car Audio DMAC Peripheral Peripheral 
controllers.
+
 config SHDMA_R8A73A4
def_bool y
depends on ARCH_R8A73A4 && SH_DMAE != n
diff --git a/drivers/dma/sh/Makefile b/drivers/dma/sh/Makefile
index e856af2..1ce88b2 100644
--- a/drivers/dma/sh/Makefile
+++ b/drivers/dma/sh/Makefile
@@ -7,3 +7,4 @@ endif
 shdma-objs := $(shdma-y)
 obj-$(CONFIG_SUDMAC) += sudmac.o
 obj-$(CONFIG_RCAR_HPB_DMAE) += rcar-hpbdma.o
+obj-$(CONFIG_RCAR_AUDMAC_PP) += rcar-audmapp.o
diff --git a/drivers/dma/sh/rcar-audmapp.c b/drivers/dma/sh/rcar-audmapp.c
new file mode 100644
index 000..72d7475
--- /dev/null
+++ b/drivers/dma/sh/rcar-audmapp.c
@@ -0,0 +1,320 @@
+/*
+ * This is for Renesas R-Car Audio-DMAC-peri-peri.
+ *
+ * Copyright (C) 2014 Renesas Electronics Corporation
+ * Copyright (C) 2014 Kuninori Morimoto 
+ *
+ * based on the drivers/dma/sh/shdma.c
+ *
+ * Copyright (C) 2011-2012 Guennadi Liakhovetski 
+ * Copyright (C) 2009 Nobuhiro Iwamatsu 
+ * Copyright (C) 2009 Renesas Solutions, Inc. All rights reserved.
+ * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * DMA register
+ */
+#define PDMASAR0x00
+#define PDMADAR0x04
+#define PDMACHCR   0x0c
+
+/* PDMACHCR */
+#define PDMACHCR_DE(1 << 0)
+
+#define AUDMAPP_MAX_CHANNELS   29
+
+/* Default MEMCPY transfer size = 2^2 = 4 bytes */
+#define LOG2_DEFAULT_XFER_SIZE 2
+#define AUDMAPP_SLAVE_NUMBER   256
+#define AUDMAPP_LEN_MAX(16 * 1024 * 1024)
+
+struct audmapp_chan {
+   struct shdma_chan shdma_chan;
+   struct audmapp_slave_config *config;
+   void __iomem *base;
+};
+
+struct audmapp_device {
+   struct shdma_dev shdma_dev;
+   struct audmapp_pdata *pdata;
+   struct device *dev;
+   void __iomem *chan_reg;
+};
+
+#define to_chan(chan) container_of(chan, struct audmapp_chan, shdma_chan)
+#define to_dev(chan) container_of(chan->shdma_chan.dma_chan.device,\
+ struct audmapp_device, shdma_dev.dma_dev)
+
+static void audmapp_write(struct audmapp_chan *auchan, u32 data, u32 reg)
+{
+   struct audmapp_device *audev = to_dev(auchan);
+   struct device *dev = audev->dev;
+
+   dev_dbg(dev, "w %p : %08x\n", auchan->base + reg, data);
+
+   iowrite32(data, auchan->base + reg);
+}
+
+static u32 audmapp_read(struct audmapp_chan *auchan, u32 reg)
+{
+   return ioread32(auchan->base + reg);
+}
+
+static void audmapp_halt(struct shdma_chan *schan)
+{
+   struct audmapp_chan *auchan = to_chan(schan);
+   int i;
+
+   audmapp_write(auchan, 0, PDMACHCR);
+
+   for(i = 0; i < 1024; i++) {
+   if (0 == audmapp_read(auchan, PDMACHCR))
+   return;
+   udelay(1);
+   }
+}
+
+static void audmapp_start_xfer(struct shdma_chan *schan,
+  struct shdma_desc *sdecs)
+{
+   struct audmapp_chan *auchan = to_chan(schan);
+   struct audmapp_device *audev = to_dev(auchan);
+   struct audmapp_slave_config *cfg = auchan->config;
+   struct device *dev = audev->dev;
+   u32 chcr = cfg->chcr | PDMACHCR_DE;
+
+   dev_dbg(dev, "src/dst/chcr = %pad/%pad/%x\n",
+   >src, >dst, cfg->chcr);
+
+   audmapp_write(auchan, cfg->src, PDMASAR);
+   audmapp_write(auchan, cfg->dst, PDMADAR);
+   audmapp_write(auchan, chcr, PDMACHCR);
+}
+
+static struct audmapp_slave_config *
+audmapp_find_slave(struct audmapp_chan *auchan, int 

Re: [PATCH v3] shdma: add R-Car Audio DMAC peri peri driver

2014-03-10 Thread Shevchenko, Andriy
On Sun, 2014-03-09 at 19:25 -0700, Kuninori Morimoto wrote:
> From: Kuninori Morimoto 
> 
> Add support Audio DMAC peri peri driver
> for Renesas R-Car Gen2 SoC, using 'shdma-base'
> DMA driver framework.
> 
> Signed-off-by: Kuninori Morimoto 
> ---
> v2 -> v3

My previous mail is applicable to this version too.

-- 
Andy Shevchenko 
Intel Finland Oy
-
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki 
Business Identity Code: 0357606 - 4 
Domiciled in Helsinki 

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


Re: [PATCH v3] shdma: add R-Car Audio DMAC peri peri driver

2014-03-10 Thread Shevchenko, Andriy
On Sun, 2014-03-09 at 19:25 -0700, Kuninori Morimoto wrote:
 From: Kuninori Morimoto kuninori.morimoto...@renesas.com
 
 Add support Audio DMAC peri peri driver
 for Renesas R-Car Gen2 SoC, using 'shdma-base'
 DMA driver framework.
 
 Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
 ---
 v2 - v3

My previous mail is applicable to this version too.

-- 
Andy Shevchenko andriy.shevche...@intel.com
Intel Finland Oy
-
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki 
Business Identity Code: 0357606 - 4 
Domiciled in Helsinki 

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


[PATCH v3] shdma: add R-Car Audio DMAC peri peri driver

2014-03-10 Thread Kuninori Morimoto
From: Kuninori Morimoto kuninori.morimoto...@renesas.com

Add support Audio DMAC peri peri driver
for Renesas R-Car Gen2 SoC, using 'shdma-base'
DMA driver framework.

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
v2 - v3

 - modiry copyright
 - use %pad for dma_addr_t
 - use sizeof(*hoge) for devm_kzalloc()

 drivers/dma/sh/Kconfig |6 +
 drivers/dma/sh/Makefile|1 +
 drivers/dma/sh/rcar-audmapp.c  |  320 
 include/linux/platform_data/dma-rcar-audmapp.h |   34 +++
 4 files changed, 361 insertions(+)
 create mode 100644 drivers/dma/sh/rcar-audmapp.c
 create mode 100644 include/linux/platform_data/dma-rcar-audmapp.h

diff --git a/drivers/dma/sh/Kconfig b/drivers/dma/sh/Kconfig
index dadd9e01..b4c8138 100644
--- a/drivers/dma/sh/Kconfig
+++ b/drivers/dma/sh/Kconfig
@@ -29,6 +29,12 @@ config RCAR_HPB_DMAE
help
  Enable support for the Renesas R-Car series DMA controllers.
 
+config RCAR_AUDMAC_PP
+   tristate Renesas R-Car Audio DMAC Peripheral Peripheral support
+   depends on SH_DMAE_BASE
+   help
+ Enable support for the Renesas R-Car Audio DMAC Peripheral Peripheral 
controllers.
+
 config SHDMA_R8A73A4
def_bool y
depends on ARCH_R8A73A4  SH_DMAE != n
diff --git a/drivers/dma/sh/Makefile b/drivers/dma/sh/Makefile
index e856af2..1ce88b2 100644
--- a/drivers/dma/sh/Makefile
+++ b/drivers/dma/sh/Makefile
@@ -7,3 +7,4 @@ endif
 shdma-objs := $(shdma-y)
 obj-$(CONFIG_SUDMAC) += sudmac.o
 obj-$(CONFIG_RCAR_HPB_DMAE) += rcar-hpbdma.o
+obj-$(CONFIG_RCAR_AUDMAC_PP) += rcar-audmapp.o
diff --git a/drivers/dma/sh/rcar-audmapp.c b/drivers/dma/sh/rcar-audmapp.c
new file mode 100644
index 000..72d7475
--- /dev/null
+++ b/drivers/dma/sh/rcar-audmapp.c
@@ -0,0 +1,320 @@
+/*
+ * This is for Renesas R-Car Audio-DMAC-peri-peri.
+ *
+ * Copyright (C) 2014 Renesas Electronics Corporation
+ * Copyright (C) 2014 Kuninori Morimoto kuninori.morimoto...@renesas.com
+ *
+ * based on the drivers/dma/sh/shdma.c
+ *
+ * Copyright (C) 2011-2012 Guennadi Liakhovetski g.liakhovet...@gmx.de
+ * Copyright (C) 2009 Nobuhiro Iwamatsu iwamatsu.nobuh...@renesas.com
+ * Copyright (C) 2009 Renesas Solutions, Inc. All rights reserved.
+ * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+#include linux/delay.h
+#include linux/init.h
+#include linux/module.h
+#include linux/slab.h
+#include linux/dmaengine.h
+#include linux/platform_data/dma-rcar-audmapp.h
+#include linux/platform_device.h
+#include linux/shdma-base.h
+
+/*
+ * DMA register
+ */
+#define PDMASAR0x00
+#define PDMADAR0x04
+#define PDMACHCR   0x0c
+
+/* PDMACHCR */
+#define PDMACHCR_DE(1  0)
+
+#define AUDMAPP_MAX_CHANNELS   29
+
+/* Default MEMCPY transfer size = 2^2 = 4 bytes */
+#define LOG2_DEFAULT_XFER_SIZE 2
+#define AUDMAPP_SLAVE_NUMBER   256
+#define AUDMAPP_LEN_MAX(16 * 1024 * 1024)
+
+struct audmapp_chan {
+   struct shdma_chan shdma_chan;
+   struct audmapp_slave_config *config;
+   void __iomem *base;
+};
+
+struct audmapp_device {
+   struct shdma_dev shdma_dev;
+   struct audmapp_pdata *pdata;
+   struct device *dev;
+   void __iomem *chan_reg;
+};
+
+#define to_chan(chan) container_of(chan, struct audmapp_chan, shdma_chan)
+#define to_dev(chan) container_of(chan-shdma_chan.dma_chan.device,\
+ struct audmapp_device, shdma_dev.dma_dev)
+
+static void audmapp_write(struct audmapp_chan *auchan, u32 data, u32 reg)
+{
+   struct audmapp_device *audev = to_dev(auchan);
+   struct device *dev = audev-dev;
+
+   dev_dbg(dev, w %p : %08x\n, auchan-base + reg, data);
+
+   iowrite32(data, auchan-base + reg);
+}
+
+static u32 audmapp_read(struct audmapp_chan *auchan, u32 reg)
+{
+   return ioread32(auchan-base + reg);
+}
+
+static void audmapp_halt(struct shdma_chan *schan)
+{
+   struct audmapp_chan *auchan = to_chan(schan);
+   int i;
+
+   audmapp_write(auchan, 0, PDMACHCR);
+
+   for(i = 0; i  1024; i++) {
+   if (0 == audmapp_read(auchan, PDMACHCR))
+   return;
+   udelay(1);
+   }
+}
+
+static void audmapp_start_xfer(struct shdma_chan *schan,
+  struct shdma_desc *sdecs)
+{
+   struct audmapp_chan *auchan = to_chan(schan);
+   struct audmapp_device *audev = to_dev(auchan);
+   struct audmapp_slave_config *cfg = auchan-config;
+   struct device *dev = audev-dev;
+   u32 chcr = cfg-chcr | PDMACHCR_DE;
+
+   dev_dbg(dev, src/dst/chcr = %pad/%pad/%x\n,
+   

[PATCH v3] shdma: add R-Car Audio DMAC peri peri driver

2014-03-09 Thread Kuninori Morimoto
From: Kuninori Morimoto 

Add support Audio DMAC peri peri driver
for Renesas R-Car Gen2 SoC, using 'shdma-base'
DMA driver framework.

Signed-off-by: Kuninori Morimoto 
---
v2 -> v3

 - remove error message when devm_kzalloc() was failed

 drivers/dma/sh/Kconfig |6 +
 drivers/dma/sh/Makefile|1 +
 drivers/dma/sh/rcar-audmapp.c  |  321 
 include/linux/platform_data/dma-rcar-audmapp.h |   34 +++
 4 files changed, 362 insertions(+)
 create mode 100644 drivers/dma/sh/rcar-audmapp.c
 create mode 100644 include/linux/platform_data/dma-rcar-audmapp.h

diff --git a/drivers/dma/sh/Kconfig b/drivers/dma/sh/Kconfig
index dadd9e01..b4c8138 100644
--- a/drivers/dma/sh/Kconfig
+++ b/drivers/dma/sh/Kconfig
@@ -29,6 +29,12 @@ config RCAR_HPB_DMAE
help
  Enable support for the Renesas R-Car series DMA controllers.
 
+config RCAR_AUDMAC_PP
+   tristate "Renesas R-Car Audio DMAC Peripheral Peripheral support"
+   depends on SH_DMAE_BASE
+   help
+ Enable support for the Renesas R-Car Audio DMAC Peripheral Peripheral 
controllers.
+
 config SHDMA_R8A73A4
def_bool y
depends on ARCH_R8A73A4 && SH_DMAE != n
diff --git a/drivers/dma/sh/Makefile b/drivers/dma/sh/Makefile
index e856af2..1ce88b2 100644
--- a/drivers/dma/sh/Makefile
+++ b/drivers/dma/sh/Makefile
@@ -7,3 +7,4 @@ endif
 shdma-objs := $(shdma-y)
 obj-$(CONFIG_SUDMAC) += sudmac.o
 obj-$(CONFIG_RCAR_HPB_DMAE) += rcar-hpbdma.o
+obj-$(CONFIG_RCAR_AUDMAC_PP) += rcar-audmapp.o
diff --git a/drivers/dma/sh/rcar-audmapp.c b/drivers/dma/sh/rcar-audmapp.c
new file mode 100644
index 000..884ad3b80
--- /dev/null
+++ b/drivers/dma/sh/rcar-audmapp.c
@@ -0,0 +1,321 @@
+/*
+ * drivers/dma/sh/rcar-audmapp.c
+ *
+ * Copyright (C) 2013 Renesas Electronics Corporation
+ * Copyright (C) 2013 Kuninori Morimoto 
+ *
+ * based on the drivers/dma/sh/shdma.c
+ *
+ * Copyright (C) 2011-2012 Guennadi Liakhovetski 
+ * Copyright (C) 2009 Nobuhiro Iwamatsu 
+ * Copyright (C) 2009 Renesas Solutions, Inc. All rights reserved.
+ * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * DMA register
+ */
+#define PDMASAR0x00
+#define PDMADAR0x04
+#define PDMACHCR   0x0c
+
+/* PDMACHCR */
+#define PDMACHCR_DE(1 << 0)
+
+#define AUDMAPP_MAX_CHANNELS   29
+
+/* Default MEMCPY transfer size = 2^2 = 4 bytes */
+#define LOG2_DEFAULT_XFER_SIZE 2
+#define AUDMAPP_SLAVE_NUMBER   256
+#define AUDMAPP_LEN_MAX(16 * 1024 * 1024)
+
+struct audmapp_chan {
+   struct shdma_chan shdma_chan;
+   struct audmapp_slave_config *config;
+   void __iomem *base;
+};
+
+struct audmapp_device {
+   struct shdma_dev shdma_dev;
+   struct audmapp_pdata *pdata;
+   struct device *dev;
+   void __iomem *chan_reg;
+};
+
+#define to_chan(chan) container_of(chan, struct audmapp_chan, shdma_chan)
+#define to_dev(chan) container_of(chan->shdma_chan.dma_chan.device,\
+ struct audmapp_device, shdma_dev.dma_dev)
+
+static void audmapp_write(struct audmapp_chan *auchan, u32 data, u32 reg)
+{
+   struct audmapp_device *audev = to_dev(auchan);
+   struct device *dev = audev->dev;
+
+   dev_dbg(dev, "w %p : %08x\n", auchan->base + reg, data);
+
+   iowrite32(data, auchan->base + reg);
+}
+
+static u32 audmapp_read(struct audmapp_chan *auchan, u32 reg)
+{
+   return ioread32(auchan->base + reg);
+}
+
+static void audmapp_halt(struct shdma_chan *schan)
+{
+   struct audmapp_chan *auchan = to_chan(schan);
+   int i;
+
+   audmapp_write(auchan, 0, PDMACHCR);
+
+   for(i = 0; i < 1024; i++) {
+   if (0 == audmapp_read(auchan, PDMACHCR))
+   return;
+   udelay(1);
+   }
+}
+
+static void audmapp_start_xfer(struct shdma_chan *schan,
+  struct shdma_desc *sdecs)
+{
+   struct audmapp_chan *auchan = to_chan(schan);
+   struct audmapp_device *audev = to_dev(auchan);
+   struct audmapp_slave_config *cfg = auchan->config;
+   struct device *dev = audev->dev;
+   u32 chcr = cfg->chcr | PDMACHCR_DE;
+
+   dev_dbg(dev, "src/dst/chcr = %x/%x/%x\n",
+   cfg->src, cfg->dst, cfg->chcr);
+
+   audmapp_write(auchan, cfg->src, PDMASAR);
+   audmapp_write(auchan, cfg->dst, PDMADAR);
+   audmapp_write(auchan, chcr, PDMACHCR);
+}
+
+static struct audmapp_slave_config *
+audmapp_find_slave(struct audmapp_chan *auchan, int slave_id)
+{
+   struct audmapp_device 

[PATCH v3] shdma: add R-Car Audio DMAC peri peri driver

2014-03-09 Thread Kuninori Morimoto
From: Kuninori Morimoto kuninori.morimoto...@renesas.com

Add support Audio DMAC peri peri driver
for Renesas R-Car Gen2 SoC, using 'shdma-base'
DMA driver framework.

Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com
---
v2 - v3

 - remove error message when devm_kzalloc() was failed

 drivers/dma/sh/Kconfig |6 +
 drivers/dma/sh/Makefile|1 +
 drivers/dma/sh/rcar-audmapp.c  |  321 
 include/linux/platform_data/dma-rcar-audmapp.h |   34 +++
 4 files changed, 362 insertions(+)
 create mode 100644 drivers/dma/sh/rcar-audmapp.c
 create mode 100644 include/linux/platform_data/dma-rcar-audmapp.h

diff --git a/drivers/dma/sh/Kconfig b/drivers/dma/sh/Kconfig
index dadd9e01..b4c8138 100644
--- a/drivers/dma/sh/Kconfig
+++ b/drivers/dma/sh/Kconfig
@@ -29,6 +29,12 @@ config RCAR_HPB_DMAE
help
  Enable support for the Renesas R-Car series DMA controllers.
 
+config RCAR_AUDMAC_PP
+   tristate Renesas R-Car Audio DMAC Peripheral Peripheral support
+   depends on SH_DMAE_BASE
+   help
+ Enable support for the Renesas R-Car Audio DMAC Peripheral Peripheral 
controllers.
+
 config SHDMA_R8A73A4
def_bool y
depends on ARCH_R8A73A4  SH_DMAE != n
diff --git a/drivers/dma/sh/Makefile b/drivers/dma/sh/Makefile
index e856af2..1ce88b2 100644
--- a/drivers/dma/sh/Makefile
+++ b/drivers/dma/sh/Makefile
@@ -7,3 +7,4 @@ endif
 shdma-objs := $(shdma-y)
 obj-$(CONFIG_SUDMAC) += sudmac.o
 obj-$(CONFIG_RCAR_HPB_DMAE) += rcar-hpbdma.o
+obj-$(CONFIG_RCAR_AUDMAC_PP) += rcar-audmapp.o
diff --git a/drivers/dma/sh/rcar-audmapp.c b/drivers/dma/sh/rcar-audmapp.c
new file mode 100644
index 000..884ad3b80
--- /dev/null
+++ b/drivers/dma/sh/rcar-audmapp.c
@@ -0,0 +1,321 @@
+/*
+ * drivers/dma/sh/rcar-audmapp.c
+ *
+ * Copyright (C) 2013 Renesas Electronics Corporation
+ * Copyright (C) 2013 Kuninori Morimoto kuninori.morimoto...@renesas.com
+ *
+ * based on the drivers/dma/sh/shdma.c
+ *
+ * Copyright (C) 2011-2012 Guennadi Liakhovetski g.liakhovet...@gmx.de
+ * Copyright (C) 2009 Nobuhiro Iwamatsu iwamatsu.nobuh...@renesas.com
+ * Copyright (C) 2009 Renesas Solutions, Inc. All rights reserved.
+ * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ */
+#include linux/delay.h
+#include linux/init.h
+#include linux/module.h
+#include linux/slab.h
+#include linux/dmaengine.h
+#include linux/platform_data/dma-rcar-audmapp.h
+#include linux/platform_device.h
+#include linux/shdma-base.h
+
+/*
+ * DMA register
+ */
+#define PDMASAR0x00
+#define PDMADAR0x04
+#define PDMACHCR   0x0c
+
+/* PDMACHCR */
+#define PDMACHCR_DE(1  0)
+
+#define AUDMAPP_MAX_CHANNELS   29
+
+/* Default MEMCPY transfer size = 2^2 = 4 bytes */
+#define LOG2_DEFAULT_XFER_SIZE 2
+#define AUDMAPP_SLAVE_NUMBER   256
+#define AUDMAPP_LEN_MAX(16 * 1024 * 1024)
+
+struct audmapp_chan {
+   struct shdma_chan shdma_chan;
+   struct audmapp_slave_config *config;
+   void __iomem *base;
+};
+
+struct audmapp_device {
+   struct shdma_dev shdma_dev;
+   struct audmapp_pdata *pdata;
+   struct device *dev;
+   void __iomem *chan_reg;
+};
+
+#define to_chan(chan) container_of(chan, struct audmapp_chan, shdma_chan)
+#define to_dev(chan) container_of(chan-shdma_chan.dma_chan.device,\
+ struct audmapp_device, shdma_dev.dma_dev)
+
+static void audmapp_write(struct audmapp_chan *auchan, u32 data, u32 reg)
+{
+   struct audmapp_device *audev = to_dev(auchan);
+   struct device *dev = audev-dev;
+
+   dev_dbg(dev, w %p : %08x\n, auchan-base + reg, data);
+
+   iowrite32(data, auchan-base + reg);
+}
+
+static u32 audmapp_read(struct audmapp_chan *auchan, u32 reg)
+{
+   return ioread32(auchan-base + reg);
+}
+
+static void audmapp_halt(struct shdma_chan *schan)
+{
+   struct audmapp_chan *auchan = to_chan(schan);
+   int i;
+
+   audmapp_write(auchan, 0, PDMACHCR);
+
+   for(i = 0; i  1024; i++) {
+   if (0 == audmapp_read(auchan, PDMACHCR))
+   return;
+   udelay(1);
+   }
+}
+
+static void audmapp_start_xfer(struct shdma_chan *schan,
+  struct shdma_desc *sdecs)
+{
+   struct audmapp_chan *auchan = to_chan(schan);
+   struct audmapp_device *audev = to_dev(auchan);
+   struct audmapp_slave_config *cfg = auchan-config;
+   struct device *dev = audev-dev;
+   u32 chcr = cfg-chcr | PDMACHCR_DE;
+
+   dev_dbg(dev, src/dst/chcr = %x/%x/%x\n,
+   cfg-src, cfg-dst, cfg-chcr);
+
+