diff options
Diffstat (limited to 'drivers/media/platform/coda.c')
| -rw-r--r-- | drivers/media/platform/coda.c | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c index 20827ba168fc..b931c2a5c7fc 100644 --- a/drivers/media/platform/coda.c +++ b/drivers/media/platform/coda.c | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include <linux/clk.h> | 14 | #include <linux/clk.h> |
| 15 | #include <linux/delay.h> | 15 | #include <linux/delay.h> |
| 16 | #include <linux/firmware.h> | 16 | #include <linux/firmware.h> |
| 17 | #include <linux/genalloc.h> | ||
| 17 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
| 18 | #include <linux/io.h> | 19 | #include <linux/io.h> |
| 19 | #include <linux/irq.h> | 20 | #include <linux/irq.h> |
| @@ -23,7 +24,7 @@ | |||
| 23 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
| 24 | #include <linux/videodev2.h> | 25 | #include <linux/videodev2.h> |
| 25 | #include <linux/of.h> | 26 | #include <linux/of.h> |
| 26 | #include <linux/platform_data/imx-iram.h> | 27 | #include <linux/platform_data/coda.h> |
| 27 | 28 | ||
| 28 | #include <media/v4l2-ctrls.h> | 29 | #include <media/v4l2-ctrls.h> |
| 29 | #include <media/v4l2-device.h> | 30 | #include <media/v4l2-device.h> |
| @@ -43,6 +44,7 @@ | |||
| 43 | #define CODA7_WORK_BUF_SIZE (512 * 1024 + CODA_FMO_BUF_SIZE * 8 * 1024) | 44 | #define CODA7_WORK_BUF_SIZE (512 * 1024 + CODA_FMO_BUF_SIZE * 8 * 1024) |
| 44 | #define CODA_PARA_BUF_SIZE (10 * 1024) | 45 | #define CODA_PARA_BUF_SIZE (10 * 1024) |
| 45 | #define CODA_ISRAM_SIZE (2048 * 2) | 46 | #define CODA_ISRAM_SIZE (2048 * 2) |
| 47 | #define CODADX6_IRAM_SIZE 0xb000 | ||
| 46 | #define CODA7_IRAM_SIZE 0x14000 /* 81920 bytes */ | 48 | #define CODA7_IRAM_SIZE 0x14000 /* 81920 bytes */ |
| 47 | 49 | ||
| 48 | #define CODA_MAX_FRAMEBUFFERS 2 | 50 | #define CODA_MAX_FRAMEBUFFERS 2 |
| @@ -128,7 +130,10 @@ struct coda_dev { | |||
| 128 | 130 | ||
| 129 | struct coda_aux_buf codebuf; | 131 | struct coda_aux_buf codebuf; |
| 130 | struct coda_aux_buf workbuf; | 132 | struct coda_aux_buf workbuf; |
| 133 | struct gen_pool *iram_pool; | ||
| 134 | long unsigned int iram_vaddr; | ||
| 131 | long unsigned int iram_paddr; | 135 | long unsigned int iram_paddr; |
| 136 | unsigned long iram_size; | ||
| 132 | 137 | ||
| 133 | spinlock_t irqlock; | 138 | spinlock_t irqlock; |
| 134 | struct mutex dev_mutex; | 139 | struct mutex dev_mutex; |
| @@ -1926,6 +1931,9 @@ static int coda_probe(struct platform_device *pdev) | |||
| 1926 | const struct of_device_id *of_id = | 1931 | const struct of_device_id *of_id = |
| 1927 | of_match_device(of_match_ptr(coda_dt_ids), &pdev->dev); | 1932 | of_match_device(of_match_ptr(coda_dt_ids), &pdev->dev); |
| 1928 | const struct platform_device_id *pdev_id; | 1933 | const struct platform_device_id *pdev_id; |
| 1934 | struct coda_platform_data *pdata = pdev->dev.platform_data; | ||
| 1935 | struct device_node *np = pdev->dev.of_node; | ||
| 1936 | struct gen_pool *pool; | ||
| 1929 | struct coda_dev *dev; | 1937 | struct coda_dev *dev; |
| 1930 | struct resource *res; | 1938 | struct resource *res; |
| 1931 | int ret, irq; | 1939 | int ret, irq; |
| @@ -1988,6 +1996,16 @@ static int coda_probe(struct platform_device *pdev) | |||
| 1988 | return -ENOENT; | 1996 | return -ENOENT; |
| 1989 | } | 1997 | } |
| 1990 | 1998 | ||
| 1999 | /* Get IRAM pool from device tree or platform data */ | ||
| 2000 | pool = of_get_named_gen_pool(np, "iram", 0); | ||
| 2001 | if (!pool && pdata) | ||
| 2002 | pool = dev_get_gen_pool(pdata->iram_dev); | ||
| 2003 | if (!pool) { | ||
| 2004 | dev_err(&pdev->dev, "iram pool not available\n"); | ||
| 2005 | return -ENOMEM; | ||
| 2006 | } | ||
| 2007 | dev->iram_pool = pool; | ||
| 2008 | |||
| 1991 | ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); | 2009 | ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); |
| 1992 | if (ret) | 2010 | if (ret) |
| 1993 | return ret; | 2011 | return ret; |
| @@ -2022,18 +2040,17 @@ static int coda_probe(struct platform_device *pdev) | |||
| 2022 | return -ENOMEM; | 2040 | return -ENOMEM; |
| 2023 | } | 2041 | } |
| 2024 | 2042 | ||
| 2025 | if (dev->devtype->product == CODA_DX6) { | 2043 | if (dev->devtype->product == CODA_DX6) |
| 2026 | dev->iram_paddr = 0xffff4c00; | 2044 | dev->iram_size = CODADX6_IRAM_SIZE; |
| 2027 | } else { | 2045 | else |
| 2028 | void __iomem *iram_vaddr; | 2046 | dev->iram_size = CODA7_IRAM_SIZE; |
| 2029 | 2047 | dev->iram_vaddr = gen_pool_alloc(dev->iram_pool, dev->iram_size); | |
| 2030 | iram_vaddr = iram_alloc(CODA7_IRAM_SIZE, | 2048 | if (!dev->iram_vaddr) { |
| 2031 | &dev->iram_paddr); | 2049 | dev_err(&pdev->dev, "unable to alloc iram\n"); |
| 2032 | if (!iram_vaddr) { | 2050 | return -ENOMEM; |
| 2033 | dev_err(&pdev->dev, "unable to alloc iram\n"); | ||
| 2034 | return -ENOMEM; | ||
| 2035 | } | ||
| 2036 | } | 2051 | } |
| 2052 | dev->iram_paddr = gen_pool_virt_to_phys(dev->iram_pool, | ||
| 2053 | dev->iram_vaddr); | ||
| 2037 | 2054 | ||
| 2038 | platform_set_drvdata(pdev, dev); | 2055 | platform_set_drvdata(pdev, dev); |
| 2039 | 2056 | ||
| @@ -2050,8 +2067,8 @@ static int coda_remove(struct platform_device *pdev) | |||
| 2050 | if (dev->alloc_ctx) | 2067 | if (dev->alloc_ctx) |
| 2051 | vb2_dma_contig_cleanup_ctx(dev->alloc_ctx); | 2068 | vb2_dma_contig_cleanup_ctx(dev->alloc_ctx); |
| 2052 | v4l2_device_unregister(&dev->v4l2_dev); | 2069 | v4l2_device_unregister(&dev->v4l2_dev); |
| 2053 | if (dev->iram_paddr) | 2070 | if (dev->iram_vaddr) |
| 2054 | iram_free(dev->iram_paddr, CODA7_IRAM_SIZE); | 2071 | gen_pool_free(dev->iram_pool, dev->iram_vaddr, dev->iram_size); |
| 2055 | if (dev->codebuf.vaddr) | 2072 | if (dev->codebuf.vaddr) |
| 2056 | dma_free_coherent(&pdev->dev, dev->codebuf.size, | 2073 | dma_free_coherent(&pdev->dev, dev->codebuf.size, |
| 2057 | &dev->codebuf.vaddr, dev->codebuf.paddr); | 2074 | &dev->codebuf.vaddr, dev->codebuf.paddr); |
