aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Estevam <fabio.estevam@freescale.com>2012-10-30 08:03:26 -0400
committerSascha Hauer <s.hauer@pengutronix.de>2012-11-16 10:21:49 -0500
commit376aaac1837af8ed6c1014958396322c44306cbf (patch)
tree7fc0ac19856b0d0750462277f141a685c5730924
parent6efc782362b4e869bfd71d801020c8641abdbd1f (diff)
mx2_camera: Fix regression caused by clock conversion
Since mx27 transitioned to the commmon clock framework in 3.5, the correct way to acquire the csi clock is to get csi_ahb and csi_per clocks separately. By not doing so the camera sensor does not probe correctly: soc-camera-pdrv soc-camera-pdrv.0: Probing soc-camera-pdrv.0 mx2-camera mx2-camera.0: Camera driver attached to camera 0 ov2640 0-0030: Product ID error fb:fb mx2-camera mx2-camera.0: Camera driver detached from camera 0 mx2-camera mx2-camera.0: MX2 Camera (CSI) driver probed, clock frequency: 66500000 Adapt the mx2_camera driver to the new clock framework and make it functional again. Tested-by: Gaƫtan Carlier <gcembed@gmail.com> Tested-by: Javier Martin <javier.martin@vista-silicon.com> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/platform/soc_camera/mx2_camera.c39
1 files changed, 29 insertions, 10 deletions
diff --git a/drivers/media/platform/soc_camera/mx2_camera.c b/drivers/media/platform/soc_camera/mx2_camera.c
index e575ae82771d..558f6a3e510d 100644
--- a/drivers/media/platform/soc_camera/mx2_camera.c
+++ b/drivers/media/platform/soc_camera/mx2_camera.c
@@ -278,7 +278,8 @@ struct mx2_camera_dev {
278 struct device *dev; 278 struct device *dev;
279 struct soc_camera_host soc_host; 279 struct soc_camera_host soc_host;
280 struct soc_camera_device *icd; 280 struct soc_camera_device *icd;
281 struct clk *clk_csi, *clk_emma_ahb, *clk_emma_ipg; 281 struct clk *clk_emma_ahb, *clk_emma_ipg;
282 struct clk *clk_csi_ahb, *clk_csi_per;
282 283
283 void __iomem *base_csi, *base_emma; 284 void __iomem *base_csi, *base_emma;
284 285
@@ -464,7 +465,8 @@ static void mx2_camera_deactivate(struct mx2_camera_dev *pcdev)
464{ 465{
465 unsigned long flags; 466 unsigned long flags;
466 467
467 clk_disable_unprepare(pcdev->clk_csi); 468 clk_disable_unprepare(pcdev->clk_csi_ahb);
469 clk_disable_unprepare(pcdev->clk_csi_per);
468 writel(0, pcdev->base_csi + CSICR1); 470 writel(0, pcdev->base_csi + CSICR1);
469 if (is_imx27_camera(pcdev)) { 471 if (is_imx27_camera(pcdev)) {
470 writel(0, pcdev->base_emma + PRP_CNTL); 472 writel(0, pcdev->base_emma + PRP_CNTL);
@@ -492,10 +494,14 @@ static int mx2_camera_add_device(struct soc_camera_device *icd)
492 if (pcdev->icd) 494 if (pcdev->icd)
493 return -EBUSY; 495 return -EBUSY;
494 496
495 ret = clk_prepare_enable(pcdev->clk_csi); 497 ret = clk_prepare_enable(pcdev->clk_csi_ahb);
496 if (ret < 0) 498 if (ret < 0)
497 return ret; 499 return ret;
498 500
501 ret = clk_prepare_enable(pcdev->clk_csi_per);
502 if (ret < 0)
503 goto exit_csi_ahb;
504
499 csicr1 = CSICR1_MCLKEN; 505 csicr1 = CSICR1_MCLKEN;
500 506
501 if (is_imx27_camera(pcdev)) 507 if (is_imx27_camera(pcdev))
@@ -512,6 +518,11 @@ static int mx2_camera_add_device(struct soc_camera_device *icd)
512 icd->devnum); 518 icd->devnum);
513 519
514 return 0; 520 return 0;
521
522exit_csi_ahb:
523 clk_disable_unprepare(pcdev->clk_csi_ahb);
524
525 return ret;
515} 526}
516 527
517static void mx2_camera_remove_device(struct soc_camera_device *icd) 528static void mx2_camera_remove_device(struct soc_camera_device *icd)
@@ -1772,10 +1783,17 @@ static int __devinit mx2_camera_probe(struct platform_device *pdev)
1772 break; 1783 break;
1773 } 1784 }
1774 1785
1775 pcdev->clk_csi = devm_clk_get(&pdev->dev, "ahb"); 1786 pcdev->clk_csi_ahb = devm_clk_get(&pdev->dev, "ahb");
1776 if (IS_ERR(pcdev->clk_csi)) { 1787 if (IS_ERR(pcdev->clk_csi_ahb)) {
1777 dev_err(&pdev->dev, "Could not get csi clock\n"); 1788 dev_err(&pdev->dev, "Could not get csi ahb clock\n");
1778 err = PTR_ERR(pcdev->clk_csi); 1789 err = PTR_ERR(pcdev->clk_csi_ahb);
1790 goto exit;
1791 }
1792
1793 pcdev->clk_csi_per = devm_clk_get(&pdev->dev, "per");
1794 if (IS_ERR(pcdev->clk_csi_per)) {
1795 dev_err(&pdev->dev, "Could not get csi per clock\n");
1796 err = PTR_ERR(pcdev->clk_csi_per);
1779 goto exit; 1797 goto exit;
1780 } 1798 }
1781 1799
@@ -1785,12 +1803,13 @@ static int __devinit mx2_camera_probe(struct platform_device *pdev)
1785 1803
1786 pcdev->platform_flags = pcdev->pdata->flags; 1804 pcdev->platform_flags = pcdev->pdata->flags;
1787 1805
1788 rate = clk_round_rate(pcdev->clk_csi, pcdev->pdata->clk * 2); 1806 rate = clk_round_rate(pcdev->clk_csi_per,
1807 pcdev->pdata->clk * 2);
1789 if (rate <= 0) { 1808 if (rate <= 0) {
1790 err = -ENODEV; 1809 err = -ENODEV;
1791 goto exit; 1810 goto exit;
1792 } 1811 }
1793 err = clk_set_rate(pcdev->clk_csi, rate); 1812 err = clk_set_rate(pcdev->clk_csi_per, rate);
1794 if (err < 0) 1813 if (err < 0)
1795 goto exit; 1814 goto exit;
1796 } 1815 }
@@ -1848,7 +1867,7 @@ static int __devinit mx2_camera_probe(struct platform_device *pdev)
1848 goto exit_free_emma; 1867 goto exit_free_emma;
1849 1868
1850 dev_info(&pdev->dev, "MX2 Camera (CSI) driver probed, clock frequency: %ld\n", 1869 dev_info(&pdev->dev, "MX2 Camera (CSI) driver probed, clock frequency: %ld\n",
1851 clk_get_rate(pcdev->clk_csi)); 1870 clk_get_rate(pcdev->clk_csi_per));
1852 1871
1853 return 0; 1872 return 0;
1854 1873