--- /dev/null
+Chips&Media 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>;
+};
 
 #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>
 #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>
 #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_SIZE                0x14000 /* 81920 bytes */
 
 #define CODA_MAX_FRAMEBUFFERS  2
 
        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 mutex            dev_mutex;
        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;
                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;
                return -ENOMEM;
        }
 
-       if (dev->devtype->product == CODA_DX6) {
-               dev->iram_paddr = 0xffff4c00;
-       } else {
-               void __iomem *iram_vaddr;
-
-               iram_vaddr = iram_alloc(CODA7_IRAM_SIZE,
-                                       &dev->iram_paddr);
-               if (!iram_vaddr) {
-                       dev_err(&pdev->dev, "unable to alloc iram\n");
-                       return -ENOMEM;
-               }
+       if (dev->devtype->product == CODA_DX6)
+               dev->iram_size = CODADX6_IRAM_SIZE;
+       else
+               dev->iram_size = CODA7_IRAM_SIZE;
+       dev->iram_vaddr = gen_pool_alloc(dev->iram_pool, dev->iram_size);
+       if (!dev->iram_vaddr) {
+               dev_err(&pdev->dev, "unable to alloc iram\n");
+               return -ENOMEM;
        }
+       dev->iram_paddr = gen_pool_virt_to_phys(dev->iram_pool,
+                                               dev->iram_vaddr);
 
        platform_set_drvdata(pdev, dev);
 
        if (dev->alloc_ctx)
                vb2_dma_contig_cleanup_ctx(dev->alloc_ctx);
        v4l2_device_unregister(&dev->v4l2_dev);
-       if (dev->iram_paddr)
-               iram_free(dev->iram_paddr, CODA7_IRAM_SIZE);
+       if (dev->iram_vaddr)
+               gen_pool_free(dev->iram_pool, dev->iram_vaddr, dev->iram_size);
        if (dev->codebuf.vaddr)
                dma_free_coherent(&pdev->dev, dev->codebuf.size,
                                  &dev->codebuf.vaddr, dev->codebuf.paddr);