aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-11-16 10:21:27 -0500
committerSascha Hauer <s.hauer@pengutronix.de>2012-11-16 10:21:27 -0500
commit89a4150331bc07014256714678ce8e9b238fc145 (patch)
tree3a0358208775f29f9e319b506ce849c5dbdc1a06 /drivers/media
parent77b67063bb6bce6d475e910d3b886a606d0d91f7 (diff)
parent68b25325a7fd290b5e472bba0df9cbe8c1a81d8f (diff)
Merge remote-tracking branch 'arm-soc/imx/multiplatform' into x
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/platform/soc_camera/mx2_camera.c95
-rw-r--r--drivers/media/platform/soc_camera/mx3_camera.c2
2 files changed, 72 insertions, 25 deletions
diff --git a/drivers/media/platform/soc_camera/mx2_camera.c b/drivers/media/platform/soc_camera/mx2_camera.c
index 9fd9d1c5b218..e575ae82771d 100644
--- a/drivers/media/platform/soc_camera/mx2_camera.c
+++ b/drivers/media/platform/soc_camera/mx2_camera.c
@@ -41,7 +41,6 @@
41#include <linux/videodev2.h> 41#include <linux/videodev2.h>
42 42
43#include <linux/platform_data/camera-mx2.h> 43#include <linux/platform_data/camera-mx2.h>
44#include <mach/hardware.h>
45 44
46#include <asm/dma.h> 45#include <asm/dma.h>
47 46
@@ -121,11 +120,13 @@
121 120
122#define CSICR1 0x00 121#define CSICR1 0x00
123#define CSICR2 0x04 122#define CSICR2 0x04
124#define CSISR (cpu_is_mx27() ? 0x08 : 0x18) 123#define CSISR_IMX25 0x18
124#define CSISR_IMX27 0x08
125#define CSISTATFIFO 0x0c 125#define CSISTATFIFO 0x0c
126#define CSIRFIFO 0x10 126#define CSIRFIFO 0x10
127#define CSIRXCNT 0x14 127#define CSIRXCNT 0x14
128#define CSICR3 (cpu_is_mx27() ? 0x1C : 0x08) 128#define CSICR3_IMX25 0x08
129#define CSICR3_IMX27 0x1c
129#define CSIDMASA_STATFIFO 0x20 130#define CSIDMASA_STATFIFO 0x20
130#define CSIDMATA_STATFIFO 0x24 131#define CSIDMATA_STATFIFO 0x24
131#define CSIDMASA_FB1 0x28 132#define CSIDMASA_FB1 0x28
@@ -268,6 +269,11 @@ struct mx2_buffer {
268 struct mx2_buf_internal internal; 269 struct mx2_buf_internal internal;
269}; 270};
270 271
272enum mx2_camera_type {
273 IMX25_CAMERA,
274 IMX27_CAMERA,
275};
276
271struct mx2_camera_dev { 277struct mx2_camera_dev {
272 struct device *dev; 278 struct device *dev;
273 struct soc_camera_host soc_host; 279 struct soc_camera_host soc_host;
@@ -291,6 +297,9 @@ struct mx2_camera_dev {
291 struct mx2_buffer *fb2_active; 297 struct mx2_buffer *fb2_active;
292 298
293 u32 csicr1; 299 u32 csicr1;
300 u32 reg_csisr;
301 u32 reg_csicr3;
302 enum mx2_camera_type devtype;
294 303
295 struct mx2_buf_internal buf_discard[2]; 304 struct mx2_buf_internal buf_discard[2];
296 void *discard_buffer; 305 void *discard_buffer;
@@ -303,6 +312,29 @@ struct mx2_camera_dev {
303 struct vb2_alloc_ctx *alloc_ctx; 312 struct vb2_alloc_ctx *alloc_ctx;
304}; 313};
305 314
315static struct platform_device_id mx2_camera_devtype[] = {
316 {
317 .name = "imx25-camera",
318 .driver_data = IMX25_CAMERA,
319 }, {
320 .name = "imx27-camera",
321 .driver_data = IMX27_CAMERA,
322 }, {
323 /* sentinel */
324 }
325};
326MODULE_DEVICE_TABLE(platform, mx2_camera_devtype);
327
328static inline int is_imx25_camera(struct mx2_camera_dev *pcdev)
329{
330 return pcdev->devtype == IMX25_CAMERA;
331}
332
333static inline int is_imx27_camera(struct mx2_camera_dev *pcdev)
334{
335 return pcdev->devtype == IMX27_CAMERA;
336}
337
306static struct mx2_buffer *mx2_ibuf_to_buf(struct mx2_buf_internal *int_buf) 338static struct mx2_buffer *mx2_ibuf_to_buf(struct mx2_buf_internal *int_buf)
307{ 339{
308 return container_of(int_buf, struct mx2_buffer, internal); 340 return container_of(int_buf, struct mx2_buffer, internal);
@@ -434,9 +466,9 @@ static void mx2_camera_deactivate(struct mx2_camera_dev *pcdev)
434 466
435 clk_disable_unprepare(pcdev->clk_csi); 467 clk_disable_unprepare(pcdev->clk_csi);
436 writel(0, pcdev->base_csi + CSICR1); 468 writel(0, pcdev->base_csi + CSICR1);
437 if (cpu_is_mx27()) { 469 if (is_imx27_camera(pcdev)) {
438 writel(0, pcdev->base_emma + PRP_CNTL); 470 writel(0, pcdev->base_emma + PRP_CNTL);
439 } else if (cpu_is_mx25()) { 471 } else if (is_imx25_camera(pcdev)) {
440 spin_lock_irqsave(&pcdev->lock, flags); 472 spin_lock_irqsave(&pcdev->lock, flags);
441 pcdev->fb1_active = NULL; 473 pcdev->fb1_active = NULL;
442 pcdev->fb2_active = NULL; 474 pcdev->fb2_active = NULL;
@@ -466,7 +498,7 @@ static int mx2_camera_add_device(struct soc_camera_device *icd)
466 498
467 csicr1 = CSICR1_MCLKEN; 499 csicr1 = CSICR1_MCLKEN;
468 500
469 if (cpu_is_mx27()) 501 if (is_imx27_camera(pcdev))
470 csicr1 |= CSICR1_PRP_IF_EN | CSICR1_FCC | 502 csicr1 |= CSICR1_PRP_IF_EN | CSICR1_FCC |
471 CSICR1_RXFF_LEVEL(0); 503 CSICR1_RXFF_LEVEL(0);
472 504
@@ -542,7 +574,7 @@ out:
542static irqreturn_t mx25_camera_irq(int irq_csi, void *data) 574static irqreturn_t mx25_camera_irq(int irq_csi, void *data)
543{ 575{
544 struct mx2_camera_dev *pcdev = data; 576 struct mx2_camera_dev *pcdev = data;
545 u32 status = readl(pcdev->base_csi + CSISR); 577 u32 status = readl(pcdev->base_csi + pcdev->reg_csisr);
546 578
547 if (status & CSISR_DMA_TSF_FB1_INT) 579 if (status & CSISR_DMA_TSF_FB1_INT)
548 mx25_camera_frame_done(pcdev, 1, MX2_STATE_DONE); 580 mx25_camera_frame_done(pcdev, 1, MX2_STATE_DONE);
@@ -551,7 +583,7 @@ static irqreturn_t mx25_camera_irq(int irq_csi, void *data)
551 583
552 /* FIXME: handle CSISR_RFF_OR_INT */ 584 /* FIXME: handle CSISR_RFF_OR_INT */
553 585
554 writel(status, pcdev->base_csi + CSISR); 586 writel(status, pcdev->base_csi + pcdev->reg_csisr);
555 587
556 return IRQ_HANDLED; 588 return IRQ_HANDLED;
557} 589}
@@ -636,7 +668,7 @@ static void mx2_videobuf_queue(struct vb2_buffer *vb)
636 buf->state = MX2_STATE_QUEUED; 668 buf->state = MX2_STATE_QUEUED;
637 list_add_tail(&buf->internal.queue, &pcdev->capture); 669 list_add_tail(&buf->internal.queue, &pcdev->capture);
638 670
639 if (cpu_is_mx25()) { 671 if (is_imx25_camera(pcdev)) {
640 u32 csicr3, dma_inten = 0; 672 u32 csicr3, dma_inten = 0;
641 673
642 if (pcdev->fb1_active == NULL) { 674 if (pcdev->fb1_active == NULL) {
@@ -655,20 +687,20 @@ static void mx2_videobuf_queue(struct vb2_buffer *vb)
655 list_del(&buf->internal.queue); 687 list_del(&buf->internal.queue);
656 buf->state = MX2_STATE_ACTIVE; 688 buf->state = MX2_STATE_ACTIVE;
657 689
658 csicr3 = readl(pcdev->base_csi + CSICR3); 690 csicr3 = readl(pcdev->base_csi + pcdev->reg_csicr3);
659 691
660 /* Reflash DMA */ 692 /* Reflash DMA */
661 writel(csicr3 | CSICR3_DMA_REFLASH_RFF, 693 writel(csicr3 | CSICR3_DMA_REFLASH_RFF,
662 pcdev->base_csi + CSICR3); 694 pcdev->base_csi + pcdev->reg_csicr3);
663 695
664 /* clear & enable interrupts */ 696 /* clear & enable interrupts */
665 writel(dma_inten, pcdev->base_csi + CSISR); 697 writel(dma_inten, pcdev->base_csi + pcdev->reg_csisr);
666 pcdev->csicr1 |= dma_inten; 698 pcdev->csicr1 |= dma_inten;
667 writel(pcdev->csicr1, pcdev->base_csi + CSICR1); 699 writel(pcdev->csicr1, pcdev->base_csi + CSICR1);
668 700
669 /* enable DMA */ 701 /* enable DMA */
670 csicr3 |= CSICR3_DMA_REQ_EN_RFF | CSICR3_RXFF_LEVEL(1); 702 csicr3 |= CSICR3_DMA_REQ_EN_RFF | CSICR3_RXFF_LEVEL(1);
671 writel(csicr3, pcdev->base_csi + CSICR3); 703 writel(csicr3, pcdev->base_csi + pcdev->reg_csicr3);
672 } 704 }
673 } 705 }
674 706
@@ -712,7 +744,7 @@ static void mx2_videobuf_release(struct vb2_buffer *vb)
712 */ 744 */
713 745
714 spin_lock_irqsave(&pcdev->lock, flags); 746 spin_lock_irqsave(&pcdev->lock, flags);
715 if (cpu_is_mx25() && buf->state == MX2_STATE_ACTIVE) { 747 if (is_imx25_camera(pcdev) && buf->state == MX2_STATE_ACTIVE) {
716 if (pcdev->fb1_active == buf) { 748 if (pcdev->fb1_active == buf) {
717 pcdev->csicr1 &= ~CSICR1_FB1_DMA_INTEN; 749 pcdev->csicr1 &= ~CSICR1_FB1_DMA_INTEN;
718 writel(0, pcdev->base_csi + CSIDMASA_FB1); 750 writel(0, pcdev->base_csi + CSIDMASA_FB1);
@@ -835,7 +867,7 @@ static int mx2_start_streaming(struct vb2_queue *q, unsigned int count)
835 unsigned long phys; 867 unsigned long phys;
836 int bytesperline; 868 int bytesperline;
837 869
838 if (cpu_is_mx27()) { 870 if (is_imx27_camera(pcdev)) {
839 unsigned long flags; 871 unsigned long flags;
840 if (count < 2) 872 if (count < 2)
841 return -EINVAL; 873 return -EINVAL;
@@ -930,7 +962,7 @@ static int mx2_stop_streaming(struct vb2_queue *q)
930 void *b; 962 void *b;
931 u32 cntl; 963 u32 cntl;
932 964
933 if (cpu_is_mx27()) { 965 if (is_imx27_camera(pcdev)) {
934 spin_lock_irqsave(&pcdev->lock, flags); 966 spin_lock_irqsave(&pcdev->lock, flags);
935 967
936 cntl = readl(pcdev->base_emma + PRP_CNTL); 968 cntl = readl(pcdev->base_emma + PRP_CNTL);
@@ -1082,11 +1114,11 @@ static int mx2_camera_set_bus_param(struct soc_camera_device *icd)
1082 if (bytesperline < 0) 1114 if (bytesperline < 0)
1083 return bytesperline; 1115 return bytesperline;
1084 1116
1085 if (cpu_is_mx27()) { 1117 if (is_imx27_camera(pcdev)) {
1086 ret = mx27_camera_emma_prp_reset(pcdev); 1118 ret = mx27_camera_emma_prp_reset(pcdev);
1087 if (ret) 1119 if (ret)
1088 return ret; 1120 return ret;
1089 } else if (cpu_is_mx25()) { 1121 } else if (is_imx25_camera(pcdev)) {
1090 writel((bytesperline * icd->user_height) >> 2, 1122 writel((bytesperline * icd->user_height) >> 2,
1091 pcdev->base_csi + CSIRXCNT); 1123 pcdev->base_csi + CSIRXCNT);
1092 writel((bytesperline << 16) | icd->user_height, 1124 writel((bytesperline << 16) | icd->user_height,
@@ -1392,7 +1424,7 @@ static int mx2_camera_try_fmt(struct soc_camera_device *icd,
1392 /* FIXME: implement MX27 limits */ 1424 /* FIXME: implement MX27 limits */
1393 1425
1394 /* limit to MX25 hardware capabilities */ 1426 /* limit to MX25 hardware capabilities */
1395 if (cpu_is_mx25()) { 1427 if (is_imx25_camera(pcdev)) {
1396 if (xlate->host_fmt->bits_per_sample <= 8) 1428 if (xlate->host_fmt->bits_per_sample <= 8)
1397 width_limit = 0xffff * 4; 1429 width_limit = 0xffff * 4;
1398 else 1430 else
@@ -1726,6 +1758,20 @@ static int __devinit mx2_camera_probe(struct platform_device *pdev)
1726 goto exit; 1758 goto exit;
1727 } 1759 }
1728 1760
1761 pcdev->devtype = pdev->id_entry->driver_data;
1762 switch (pcdev->devtype) {
1763 case IMX25_CAMERA:
1764 pcdev->reg_csisr = CSISR_IMX25;
1765 pcdev->reg_csicr3 = CSICR3_IMX25;
1766 break;
1767 case IMX27_CAMERA:
1768 pcdev->reg_csisr = CSISR_IMX27;
1769 pcdev->reg_csicr3 = CSICR3_IMX27;
1770 break;
1771 default:
1772 break;
1773 }
1774
1729 pcdev->clk_csi = devm_clk_get(&pdev->dev, "ahb"); 1775 pcdev->clk_csi = devm_clk_get(&pdev->dev, "ahb");
1730 if (IS_ERR(pcdev->clk_csi)) { 1776 if (IS_ERR(pcdev->clk_csi)) {
1731 dev_err(&pdev->dev, "Could not get csi clock\n"); 1777 dev_err(&pdev->dev, "Could not get csi clock\n");
@@ -1763,7 +1809,7 @@ static int __devinit mx2_camera_probe(struct platform_device *pdev)
1763 pcdev->dev = &pdev->dev; 1809 pcdev->dev = &pdev->dev;
1764 platform_set_drvdata(pdev, pcdev); 1810 platform_set_drvdata(pdev, pcdev);
1765 1811
1766 if (cpu_is_mx25()) { 1812 if (is_imx25_camera(pcdev)) {
1767 err = devm_request_irq(&pdev->dev, irq_csi, mx25_camera_irq, 0, 1813 err = devm_request_irq(&pdev->dev, irq_csi, mx25_camera_irq, 0,
1768 MX2_CAM_DRV_NAME, pcdev); 1814 MX2_CAM_DRV_NAME, pcdev);
1769 if (err) { 1815 if (err) {
@@ -1772,7 +1818,7 @@ static int __devinit mx2_camera_probe(struct platform_device *pdev)
1772 } 1818 }
1773 } 1819 }
1774 1820
1775 if (cpu_is_mx27()) { 1821 if (is_imx27_camera(pcdev)) {
1776 err = mx27_camera_emma_init(pdev); 1822 err = mx27_camera_emma_init(pdev);
1777 if (err) 1823 if (err)
1778 goto exit; 1824 goto exit;
@@ -1789,7 +1835,7 @@ static int __devinit mx2_camera_probe(struct platform_device *pdev)
1789 pcdev->soc_host.priv = pcdev; 1835 pcdev->soc_host.priv = pcdev;
1790 pcdev->soc_host.v4l2_dev.dev = &pdev->dev; 1836 pcdev->soc_host.v4l2_dev.dev = &pdev->dev;
1791 pcdev->soc_host.nr = pdev->id; 1837 pcdev->soc_host.nr = pdev->id;
1792 if (cpu_is_mx25()) 1838 if (is_imx25_camera(pcdev))
1793 pcdev->soc_host.capabilities = SOCAM_HOST_CAP_STRIDE; 1839 pcdev->soc_host.capabilities = SOCAM_HOST_CAP_STRIDE;
1794 1840
1795 pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); 1841 pcdev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev);
@@ -1809,7 +1855,7 @@ static int __devinit mx2_camera_probe(struct platform_device *pdev)
1809exit_free_emma: 1855exit_free_emma:
1810 vb2_dma_contig_cleanup_ctx(pcdev->alloc_ctx); 1856 vb2_dma_contig_cleanup_ctx(pcdev->alloc_ctx);
1811eallocctx: 1857eallocctx:
1812 if (cpu_is_mx27()) { 1858 if (is_imx27_camera(pcdev)) {
1813 clk_disable_unprepare(pcdev->clk_emma_ipg); 1859 clk_disable_unprepare(pcdev->clk_emma_ipg);
1814 clk_disable_unprepare(pcdev->clk_emma_ahb); 1860 clk_disable_unprepare(pcdev->clk_emma_ahb);
1815 } 1861 }
@@ -1827,7 +1873,7 @@ static int __devexit mx2_camera_remove(struct platform_device *pdev)
1827 1873
1828 vb2_dma_contig_cleanup_ctx(pcdev->alloc_ctx); 1874 vb2_dma_contig_cleanup_ctx(pcdev->alloc_ctx);
1829 1875
1830 if (cpu_is_mx27()) { 1876 if (is_imx27_camera(pcdev)) {
1831 clk_disable_unprepare(pcdev->clk_emma_ipg); 1877 clk_disable_unprepare(pcdev->clk_emma_ipg);
1832 clk_disable_unprepare(pcdev->clk_emma_ahb); 1878 clk_disable_unprepare(pcdev->clk_emma_ahb);
1833 } 1879 }
@@ -1841,6 +1887,7 @@ static struct platform_driver mx2_camera_driver = {
1841 .driver = { 1887 .driver = {
1842 .name = MX2_CAM_DRV_NAME, 1888 .name = MX2_CAM_DRV_NAME,
1843 }, 1889 },
1890 .id_table = mx2_camera_devtype,
1844 .remove = __devexit_p(mx2_camera_remove), 1891 .remove = __devexit_p(mx2_camera_remove),
1845}; 1892};
1846 1893
diff --git a/drivers/media/platform/soc_camera/mx3_camera.c b/drivers/media/platform/soc_camera/mx3_camera.c
index 3557ac97e430..64d39b1b5582 100644
--- a/drivers/media/platform/soc_camera/mx3_camera.c
+++ b/drivers/media/platform/soc_camera/mx3_camera.c
@@ -17,6 +17,7 @@
17#include <linux/vmalloc.h> 17#include <linux/vmalloc.h>
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/sched.h> 19#include <linux/sched.h>
20#include <linux/dma/ipu-dma.h>
20 21
21#include <media/v4l2-common.h> 22#include <media/v4l2-common.h>
22#include <media/v4l2-dev.h> 23#include <media/v4l2-dev.h>
@@ -24,7 +25,6 @@
24#include <media/soc_camera.h> 25#include <media/soc_camera.h>
25#include <media/soc_mediabus.h> 26#include <media/soc_mediabus.h>
26 27
27#include <mach/ipu.h>
28#include <linux/platform_data/camera-mx3.h> 28#include <linux/platform_data/camera-mx3.h>
29#include <linux/platform_data/dma-imx.h> 29#include <linux/platform_data/dma-imx.h>
30 30