Re: [PATCH v9 RESEND 3/4] media: coda: use genalloc API

2013-03-27 Thread Shawn Guo
On Wed, Mar 20, 2013 at 11:52:46AM +0100, Philipp Zabel wrote:
> This patch depends on "genalloc: add devres support, allow to find
> a managed pool by device", which provides the of_get_named_gen_pool
> and dev_get_gen_pool functions.
> 
> Signed-off-by: Philipp Zabel 
> Acked-By: Javier Martin 
> Acked-by: Grant Likely 
> ---
>  Documentation/devicetree/bindings/media/coda.txt |   30 +++
>  drivers/media/platform/Kconfig   |1 -
>  drivers/media/platform/coda.c|   45 
> +++---
>  include/linux/platform_data/coda.h   |   18 +
>  4 files changed, 79 insertions(+), 15 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/media/coda.txt
>  create mode 100644 include/linux/platform_data/coda.h
> 
> diff --git a/Documentation/devicetree/bindings/media/coda.txt 
> b/Documentation/devicetree/bindings/media/coda.txt
> new file mode 100644
> index 000..2865d04
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/media/coda.txt
> @@ -0,0 +1,30 @@
> +Chips Coda multi-standard codec IP
> +
> +
> +Coda codec IPs are present in i.MX SoCs in various versions,
> +called VPU (Video Processing Unit).
> +
> +Required properties:
> +- compatible : should be "fsl,-src" for i.MX SoCs:

fsl,-vpu

Shawn

> +  (a) "fsl,imx27-vpu" for CodaDx6 present in i.MX27
> +  (b) "fsl,imx53-vpu" for CODA7541 present in i.MX53
> +  (c) "fsl,imx6q-vpu" for CODA960 present in i.MX6q

--
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 v9 RESEND 3/4] media: coda: use genalloc API

2013-03-27 Thread Shawn Guo
On Wed, Mar 20, 2013 at 11:52:46AM +0100, Philipp Zabel wrote:
 This patch depends on genalloc: add devres support, allow to find
 a managed pool by device, which provides the of_get_named_gen_pool
 and dev_get_gen_pool functions.
 
 Signed-off-by: Philipp Zabel p.za...@pengutronix.de
 Acked-By: Javier Martin javier.mar...@vista-silicon.com
 Acked-by: Grant Likely grant.lik...@secretlab.ca
 ---
  Documentation/devicetree/bindings/media/coda.txt |   30 +++
  drivers/media/platform/Kconfig   |1 -
  drivers/media/platform/coda.c|   45 
 +++---
  include/linux/platform_data/coda.h   |   18 +
  4 files changed, 79 insertions(+), 15 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/media/coda.txt
  create mode 100644 include/linux/platform_data/coda.h
 
 diff --git a/Documentation/devicetree/bindings/media/coda.txt 
 b/Documentation/devicetree/bindings/media/coda.txt
 new file mode 100644
 index 000..2865d04
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/media/coda.txt
 @@ -0,0 +1,30 @@
 +ChipsMedia Coda multi-standard codec IP
 +
 +
 +Coda codec IPs are present in i.MX SoCs in various versions,
 +called VPU (Video Processing Unit).
 +
 +Required properties:
 +- compatible : should be fsl,chip-src for i.MX SoCs:

fsl,chip-vpu

Shawn

 +  (a) fsl,imx27-vpu for CodaDx6 present in i.MX27
 +  (b) fsl,imx53-vpu for CODA7541 present in i.MX53
 +  (c) fsl,imx6q-vpu for CODA960 present in i.MX6q

--
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/


[PATCH v9 RESEND 3/4] media: coda: use genalloc API

2013-03-20 Thread Philipp Zabel
This patch depends on "genalloc: add devres support, allow to find
a managed pool by device", which provides the of_get_named_gen_pool
and dev_get_gen_pool functions.

Signed-off-by: Philipp Zabel 
Acked-By: Javier Martin 
Acked-by: Grant Likely 
---
 Documentation/devicetree/bindings/media/coda.txt |   30 +++
 drivers/media/platform/Kconfig   |1 -
 drivers/media/platform/coda.c|   45 +++---
 include/linux/platform_data/coda.h   |   18 +
 4 files changed, 79 insertions(+), 15 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/coda.txt
 create mode 100644 include/linux/platform_data/coda.h

diff --git a/Documentation/devicetree/bindings/media/coda.txt 
b/Documentation/devicetree/bindings/media/coda.txt
new file mode 100644
index 000..2865d04
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/coda.txt
@@ -0,0 +1,30 @@
+Chips Coda multi-standard codec IP
+
+
+Coda codec IPs are present in i.MX SoCs in various versions,
+called VPU (Video Processing Unit).
+
+Required properties:
+- compatible : should be "fsl,-src" for i.MX SoCs:
+  (a) "fsl,imx27-vpu" for CodaDx6 present in i.MX27
+  (b) "fsl,imx53-vpu" for CODA7541 present in i.MX53
+  (c) "fsl,imx6q-vpu" for CODA960 present in i.MX6q
+- reg: should be register base and length as documented in the
+  SoC reference manual
+- interrupts : Should contain the VPU interrupt. For CODA960,
+  a second interrupt is needed for the MJPEG unit.
+- clocks : Should contain the ahb and per clocks, in the order
+  determined by the clock-names property.
+- clock-names : Should be "ahb", "per"
+- iram : phandle pointing to the SRAM device node
+
+Example:
+
+vpu: vpu@63ff4000 {
+   compatible = "fsl,imx53-vpu";
+   reg = <0x63ff4000 0x1000>;
+   interrupts = <9>;
+   clocks = < 63>, < 63>;
+   clock-names = "ahb", "per";
+   iram = <>;
+};
diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 05d7b63..bbf83c1 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -145,7 +145,6 @@ config VIDEO_CODA
depends on VIDEO_DEV && VIDEO_V4L2 && ARCH_MXC
select VIDEOBUF2_DMA_CONTIG
select V4L2_MEM2MEM_DEV
-   select IRAM_ALLOC if SOC_IMX53
---help---
   Coda is a range of video codec IPs that supports
   H.264, MPEG-4, and other video formats.
diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c
index 20827ba..b931c2a 100644
--- a/drivers/media/platform/coda.c
+++ b/drivers/media/platform/coda.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -23,7 +24,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 
 #include 
 #include 
@@ -43,6 +44,7 @@
 #define CODA7_WORK_BUF_SIZE(512 * 1024 + CODA_FMO_BUF_SIZE * 8 * 1024)
 #define CODA_PARA_BUF_SIZE (10 * 1024)
 #define CODA_ISRAM_SIZE(2048 * 2)
+#define CODADX6_IRAM_SIZE  0xb000
 #define CODA7_IRAM_SIZE0x14000 /* 81920 bytes */
 
 #define CODA_MAX_FRAMEBUFFERS  2
@@ -128,7 +130,10 @@ struct coda_dev {
 
struct coda_aux_buf codebuf;
struct coda_aux_buf workbuf;
+   struct gen_pool *iram_pool;
+   long unsigned int   iram_vaddr;
long unsigned int   iram_paddr;
+   unsigned long   iram_size;
 
spinlock_t  irqlock;
struct mutexdev_mutex;
@@ -1926,6 +1931,9 @@ static int coda_probe(struct platform_device *pdev)
const struct of_device_id *of_id =
of_match_device(of_match_ptr(coda_dt_ids), >dev);
const struct platform_device_id *pdev_id;
+   struct coda_platform_data *pdata = pdev->dev.platform_data;
+   struct device_node *np = pdev->dev.of_node;
+   struct gen_pool *pool;
struct coda_dev *dev;
struct resource *res;
int ret, irq;
@@ -1988,6 +1996,16 @@ static int coda_probe(struct platform_device *pdev)
return -ENOENT;
}
 
+   /* Get IRAM pool from device tree or platform data */
+   pool = of_get_named_gen_pool(np, "iram", 0);
+   if (!pool && pdata)
+   pool = dev_get_gen_pool(pdata->iram_dev);
+   if (!pool) {
+   dev_err(>dev, "iram pool not available\n");
+   return -ENOMEM;
+   }
+   dev->iram_pool = pool;
+
ret = v4l2_device_register(>dev, >v4l2_dev);
if (ret)
return ret;
@@ -2022,18 +2040,17 @@ static int coda_probe(struct platform_device *pdev)
return -ENOMEM;
}
 
-   if (dev->devtype->product == CODA_DX6) {
-   dev->iram_paddr = 0x4c00;
-   } else {
-   void __iomem *iram_vaddr;
-
-   iram_vaddr = iram_alloc(CODA7_IRAM_SIZE,
-   

[PATCH v9 RESEND 3/4] media: coda: use genalloc API

2013-03-20 Thread Philipp Zabel
This patch depends on genalloc: add devres support, allow to find
a managed pool by device, which provides the of_get_named_gen_pool
and dev_get_gen_pool functions.

Signed-off-by: Philipp Zabel p.za...@pengutronix.de
Acked-By: Javier Martin javier.mar...@vista-silicon.com
Acked-by: Grant Likely grant.lik...@secretlab.ca
---
 Documentation/devicetree/bindings/media/coda.txt |   30 +++
 drivers/media/platform/Kconfig   |1 -
 drivers/media/platform/coda.c|   45 +++---
 include/linux/platform_data/coda.h   |   18 +
 4 files changed, 79 insertions(+), 15 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/coda.txt
 create mode 100644 include/linux/platform_data/coda.h

diff --git a/Documentation/devicetree/bindings/media/coda.txt 
b/Documentation/devicetree/bindings/media/coda.txt
new file mode 100644
index 000..2865d04
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/coda.txt
@@ -0,0 +1,30 @@
+ChipsMedia Coda multi-standard codec IP
+
+
+Coda codec IPs are present in i.MX SoCs in various versions,
+called VPU (Video Processing Unit).
+
+Required properties:
+- compatible : should be fsl,chip-src for i.MX SoCs:
+  (a) fsl,imx27-vpu for CodaDx6 present in i.MX27
+  (b) fsl,imx53-vpu for CODA7541 present in i.MX53
+  (c) fsl,imx6q-vpu for CODA960 present in i.MX6q
+- reg: should be register base and length as documented in the
+  SoC reference manual
+- interrupts : Should contain the VPU interrupt. For CODA960,
+  a second interrupt is needed for the MJPEG unit.
+- clocks : Should contain the ahb and per clocks, in the order
+  determined by the clock-names property.
+- clock-names : Should be ahb, per
+- iram : phandle pointing to the SRAM device node
+
+Example:
+
+vpu: vpu@63ff4000 {
+   compatible = fsl,imx53-vpu;
+   reg = 0x63ff4000 0x1000;
+   interrupts = 9;
+   clocks = clks 63, clks 63;
+   clock-names = ahb, per;
+   iram = ocram;
+};
diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 05d7b63..bbf83c1 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -145,7 +145,6 @@ config VIDEO_CODA
depends on VIDEO_DEV  VIDEO_V4L2  ARCH_MXC
select VIDEOBUF2_DMA_CONTIG
select V4L2_MEM2MEM_DEV
-   select IRAM_ALLOC if SOC_IMX53
---help---
   Coda is a range of video codec IPs that supports
   H.264, MPEG-4, and other video formats.
diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c
index 20827ba..b931c2a 100644
--- a/drivers/media/platform/coda.c
+++ b/drivers/media/platform/coda.c
@@ -14,6 +14,7 @@
 #include linux/clk.h
 #include linux/delay.h
 #include linux/firmware.h
+#include linux/genalloc.h
 #include linux/interrupt.h
 #include linux/io.h
 #include linux/irq.h
@@ -23,7 +24,7 @@
 #include linux/slab.h
 #include linux/videodev2.h
 #include linux/of.h
-#include linux/platform_data/imx-iram.h
+#include linux/platform_data/coda.h
 
 #include media/v4l2-ctrls.h
 #include media/v4l2-device.h
@@ -43,6 +44,7 @@
 #define CODA7_WORK_BUF_SIZE(512 * 1024 + CODA_FMO_BUF_SIZE * 8 * 1024)
 #define CODA_PARA_BUF_SIZE (10 * 1024)
 #define CODA_ISRAM_SIZE(2048 * 2)
+#define CODADX6_IRAM_SIZE  0xb000
 #define CODA7_IRAM_SIZE0x14000 /* 81920 bytes */
 
 #define CODA_MAX_FRAMEBUFFERS  2
@@ -128,7 +130,10 @@ struct coda_dev {
 
struct coda_aux_buf codebuf;
struct coda_aux_buf workbuf;
+   struct gen_pool *iram_pool;
+   long unsigned int   iram_vaddr;
long unsigned int   iram_paddr;
+   unsigned long   iram_size;
 
spinlock_t  irqlock;
struct mutexdev_mutex;
@@ -1926,6 +1931,9 @@ static int coda_probe(struct platform_device *pdev)
const struct of_device_id *of_id =
of_match_device(of_match_ptr(coda_dt_ids), pdev-dev);
const struct platform_device_id *pdev_id;
+   struct coda_platform_data *pdata = pdev-dev.platform_data;
+   struct device_node *np = pdev-dev.of_node;
+   struct gen_pool *pool;
struct coda_dev *dev;
struct resource *res;
int ret, irq;
@@ -1988,6 +1996,16 @@ static int coda_probe(struct platform_device *pdev)
return -ENOENT;
}
 
+   /* Get IRAM pool from device tree or platform data */
+   pool = of_get_named_gen_pool(np, iram, 0);
+   if (!pool  pdata)
+   pool = dev_get_gen_pool(pdata-iram_dev);
+   if (!pool) {
+   dev_err(pdev-dev, iram pool not available\n);
+   return -ENOMEM;
+   }
+   dev-iram_pool = pool;
+
ret = v4l2_device_register(pdev-dev, dev-v4l2_dev);
if (ret)
return ret;
@@ -2022,18 +2040,17 @@ static int coda_probe(struct platform_device *pdev)