ARM: clk-imx27: Add missing clock for mx2-camera
PATCH v4 1/2 ARM: clk-imx27: Add missing clock for mx2-camera
During the clock conversion for mx27 the "per4_gate" clock was missed to get registered as a dependency of mx2-camera driver.
In the old mx27 clock driver we used to have:
DEFINE_CLOCK1(csi_clk, 0, NULL, 0, parent, &csi_clk1, &per4_clk);
,so does the same in the new clock driver
---
Changes since v3:
- Use imx27-camera.0 instead of mx2-camera.0, due to recent changes in the
imx27 clock (commit 27b76486a3: media: mx2_camera: remove cpu_is_xxx by using platform_device_id)
arch/arm/mach-imx/clk-imx27.c | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-imx/clk-imx27.c +1 -0
@@ -224,6 +224,7 @@ int __init mx27_clocks_init(unsigned long fref)clk_register_clkdev (clk[lcdc_ipg_gate],"ipg" ,"imx21-fb.0" );clk_register_clkdev (clk[lcdc_ahb_gate],"ahb" ,"imx21-fb.0" );clk_register_clkdev (clk[csi_ahb_gate],"ahb" ,"imx27-camera.0" ); +clk_register_clkdev (clk[per4_gate],"per" ,"imx27-camera.0" );clk_register_clkdev (clk[usb_div],"per" ,"fsl-usb2-udc" );clk_register_clkdev (clk[usb_ipg_gate],"ipg" ,"fsl-usb2-udc" );clk_register_clkdev (clk[usb_ahb_gate],"ahb" ,"fsl-usb2-udc" );
Signature · 1 line
1.7.9.5
PATCH v4 2/2 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.
---
Changes since v3:
- Drop unneeded clk_unprepare calls as pointed out by Guennadi Changes since v2:
- Fix clock error handling code as pointed out by Russell King Changes since v1:
- Rebased against linux-next 20121008.
drivers/media/platform/soc_camera/mx2_camera.c | 39 ++++++++++++++++++------ 1 file changed, 29 insertions(+), 10 deletions(-)
drivers/media/platform/soc_camera/mx2_camera.c +29 -10
@@ -278,7 +278,8 @@ struct mx2_camera_dev {struct device *dev;struct soc_camera_host soc_host;struct soc_camera_device *icd; -struct clk *clk_csi, *clk_emma_ahb, *clk_emma_ipg; +struct clk *clk_emma_ahb, *clk_emma_ipg; +struct clk *clk_csi_ahb, *clk_csi_per;void __iomem *base_csi, *base_emma;
@@ -464,7 +465,8 @@ static void mx2_camera_deactivate(struct mx2_camera_dev *pcdev) {unsigned long flags; -clk_disable_unprepare (pcdev->clk_csi); +clk_disable_unprepare (pcdev->clk_csi_ahb); +clk_disable_unprepare (pcdev->clk_csi_per);writel (0 , pcdev->base_csi +CSICR1 );if (is_imx27_camera (pcdev)) {writel (0 , pcdev->base_emma +PRP_CNTL );
@@ -492,10 +494,14 @@ static int mx2_camera_add_device(struct soc_camera_device *icd)if (pcdev->icd)return -EBUSY ; - ret =clk_prepare_enable (pcdev->clk_csi); + ret =clk_prepare_enable (pcdev->clk_csi_ahb);if (ret <0 )return ret; + ret =clk_prepare_enable (pcdev->clk_csi_per); +if (ret <0 ) + goto exit_csi_ahb; + csicr1 =CSICR1_MCLKEN ;if (is_imx27_camera (pcdev))
@@ -512,6 +518,11 @@ static int mx2_camera_add_device(struct soc_camera_device *icd) icd->devnum);return 0 ; + +exit_csi_ahb: +clk_disable_unprepare (pcdev->clk_csi_ahb); + +return ret; }static void mx2_camera_remove_device (struct soc_camera_device *icd)
@@ -1772,10 +1783,17 @@ static int __devinit mx2_camera_probe(struct platform_device *pdev)break ; } - pcdev->clk_csi =devm_clk_get (&pdev->dev,"ahb" ); -if (IS_ERR (pcdev->clk_csi)) { -dev_err (&pdev->dev,"Could not get csi clock\n" ); - err =PTR_ERR (pcdev->clk_csi); + pcdev->clk_csi_ahb =devm_clk_get (&pdev->dev,"ahb" ); +if (IS_ERR (pcdev->clk_csi_ahb)) { +dev_err (&pdev->dev,"Could not get csi ahb clock\n" ); + err =PTR_ERR (pcdev->clk_csi_ahb); + goto exit; + } + + pcdev->clk_csi_per =devm_clk_get (&pdev->dev,"per" ); +if (IS_ERR (pcdev->clk_csi_per)) { +dev_err (&pdev->dev,"Could not get csi per clock\n" ); + err =PTR_ERR (pcdev->clk_csi_per); goto exit; }
@@ -1785,12 +1803,13 @@ static int __devinit mx2_camera_probe(struct platform_device *pdev) pcdev->platform_flags = pcdev->pdata->flags; - rate =clk_round_rate (pcdev->clk_csi, pcdev->pdata->clk *2 ); + rate =clk_round_rate (pcdev->clk_csi_per, + pcdev->pdata->clk *2 );if (rate <=0 ) { err = -ENODEV ; goto exit; } - err =clk_set_rate (pcdev->clk_csi, rate); + err =clk_set_rate (pcdev->clk_csi_per, rate);if (err <0 ) goto exit; }
@@ -1848,7 +1867,7 @@ static int __devinit mx2_camera_probe(struct platform_device *pdev) goto exit_free_emma;dev_info (&pdev->dev,"MX2 Camera (CSI) driver probed, clock frequency: %ld\n" , -clk_get_rate (pcdev->clk_csi)); +clk_get_rate (pcdev->clk_csi_per));return 0 ;
Signature · 1 line
1.7.9.5
PATCH v4 2/2 mx2_camera: Fix regression caused by clock conversion
Em Tue, 30 Oct 2012 10:03:26 -0200
Fabio Estevam <[email protected]> escreveu:
Quoted 11 lines
Since mx27 transitioned to the commmon clock framework in 3.5, the correct way to acquire the csi clock is to get
csi_ahbandcsi_perclocks 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
Quoted 6 lines
Adapt the
mx2_cameradriver to the new clock framework and make it functional again.Tested-by Ga?tan Carlier <[email protected]>Tested-by Javier Martin <[email protected]>Signed-off-by Fabio Estevam <[email protected]>
As it seems that those patches depend on some patches at the arm tree, the better is to merge them via -arm tree.
So,
Quoted 101 lines
---
Changes since v3:
- Drop unneededclk_unpreparecalls as pointed out by Guennadi Changes since v2:
- Fix clock error handling code as pointed out by Russell King Changes since v1:
- Rebased against linux-next 20121008.drivers/media/platform/soc_camera/mx2_camera.c | 39 ++++++++++++++++++------ 1 file changed, 29 insertions(+), 10 deletions(-)drivers/media/platform/soc_camera/mx2_camera.c +28
-9@@ -278,7 +278,8 @@ struct mx2_camera_dev {struct device *dev;struct soc_camera_host soc_host;struct soc_camera_device *icd; -struct clk *clk_csi, *clk_emma_ahb, *clk_emma_ipg; +struct clk *clk_emma_ahb, *clk_emma_ipg; +struct clk *clk_csi_ahb, *clk_csi_per;void __iomem *base_csi, *base_emma;@@ -464,7 +465,8 @@ static void mx2_camera_deactivate(struct mx2_camera_dev *pcdev) {unsigned long flags; -clk_disable_unprepare (pcdev->clk_csi); +clk_disable_unprepare (pcdev->clk_csi_ahb); +clk_disable_unprepare (pcdev->clk_csi_per);writel (0 , pcdev->base_csi +CSICR1 );if (is_imx27_camera (pcdev)) {writel (0 , pcdev->base_emma +PRP_CNTL );@@ -492,10 +494,14 @@ static int mx2_camera_add_device(struct soc_camera_device *icd)if (pcdev->icd)return -EBUSY ; - ret =clk_prepare_enable (pcdev->clk_csi); + ret =clk_prepare_enable (pcdev->clk_csi_ahb);if (ret <0 )return ret; + ret =clk_prepare_enable (pcdev->clk_csi_per); +if (ret <0 ) + goto exit_csi_ahb; + csicr1 =CSICR1_MCLKEN ;if (is_imx27_camera (pcdev))@@ -512,6 +518,11 @@ static int mx2_camera_add_device(struct soc_camera_device *icd) icd->devnum);return 0 ; + +exit_csi_ahb: +clk_disable_unprepare (pcdev->clk_csi_ahb); + +return ret; }static void mx2_camera_remove_device (struct soc_camera_device *icd)@@ -1772,10 +1783,17 @@ static int __devinit mx2_camera_probe(struct platform_device *pdev)break ; } - pcdev->clk_csi =devm_clk_get (&pdev->dev,"ahb" ); -if (IS_ERR (pcdev->clk_csi)) { -dev_err (&pdev->dev,"Could not get csi clock\n" ); - err =PTR_ERR (pcdev->clk_csi); + pcdev->clk_csi_ahb =devm_clk_get (&pdev->dev,"ahb" ); +if (IS_ERR (pcdev->clk_csi_ahb)) { +dev_err (&pdev->dev,"Could not get csi ahb clock\n" ); + err =PTR_ERR (pcdev->clk_csi_ahb); + goto exit; + } + + pcdev->clk_csi_per =devm_clk_get (&pdev->dev,"per" ); +if (IS_ERR (pcdev->clk_csi_per)) { +dev_err (&pdev->dev,"Could not get csi per clock\n" ); + err =PTR_ERR (pcdev->clk_csi_per); goto exit; }@@ -1785,12 +1803,13 @@ static int __devinit mx2_camera_probe(struct platform_device *pdev) pcdev->platform_flags = pcdev->pdata->flags; - rate =clk_round_rate (pcdev->clk_csi, pcdev->pdata->clk *2 ); + rate =clk_round_rate (pcdev->clk_csi_per, + pcdev->pdata->clk *2 );if (rate <=0 ) { err = -ENODEV ; goto exit; } - err =clk_set_rate (pcdev->clk_csi, rate); + err =clk_set_rate (pcdev->clk_csi_per, rate);if (err <0 ) goto exit; }
drivers/media/platform/soc_camera/mx2_camera.c static int __devinit mx2_camera_probe(struct platform_device *pdev) · line 1873
Quoted 8 lines
drivers/media/platform/soc_camera/mx2_camera.c +1
-1@@ -1848,7 +1867,7 @@ static int __devinit mx2_camera_probe(struct platform_device *pdev) goto exit_free_emma;dev_info (&pdev->dev,"MX2 Camera (CSI) driver probed, clock frequency: %ld\n" , -clk_get_rate (pcdev->clk_csi)); +clk_get_rate (pcdev->clk_csi_per));return 0 ;
Cheers,
Mauro
Fabio Estevam
reviewerPATCH v4 2/2 mx2_camera: Fix regression caused by clock conversion
Hi Sascha,
Quoted 6 lines · Mauro Carvalho Chehab
As it seems that those patches depend on some patches at the arm tree, the better is to merge them via -arm tree.
So,
Could you please apply this series via your tree?
Thanks,
Fabio Estevam
Sascha Hauer
maintainerPATCH v4 2/2 mx2_camera: Fix regression caused by clock conversion
Quoted 5 lines · Fabio Estevam
Hi Sascha,
On Wed, Oct 31, 2012 at 9:57 AM, Mauro Carvalho Chehab <[email protected]> wrote:
Quoted 8 lines
Quoted 6 lines
As it seems that those patches depend on some patches at the arm tree, the better is to merge them via -arm tree.
So,
Could you please apply this series via your tree?
Sure, I already have this in my queue.
Sascha
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
PATCH v4 1/2 ARM: clk-imx27: Add missing clock for mx2-camera
In reply to Fabio EstevamEm Tue, 30 Oct 2012 10:03:25 -0200
Fabio Estevam <[email protected]> escreveu:
Quoted 11 lines
During the clock conversion for mx27 the "
per4_gate" clock was missed to get registered as a dependency of mx2-camera driver.In the old mx27 clock driver we used to have:
DEFINE_CLOCK1(csi_clk, 0, NULL, 0, parent, &csi_clk1, &per4_clk);,so does the same in the new clock driver
Signed-off-by Fabio Estevam <[email protected]>Acked-by Sascha Hauer <[email protected]>
As it seems that those patches depend on some patches at the arm tree, the better is to merge them via -arm tree.
So,
Quoted 13 lines
---
Changes since v3:
- Use imx27-camera.0 instead of mx2-camera.0, due to recent changes in the
imx27 clock (commit27b76486a3: media:mx2_camera: removecpu_is_xxxby usingplatform_device_id)arch/arm/mach-imx/clk-imx27.c | 1 + 1 file changed, 1 insertion(+)arch/arm/mach-imx/clk-imx27.c +0
-0
arch/arm/mach-imx/clk-imx27.c int __init mx27_clocks_init(unsigned long fref) · line 230
Quoted 7 lines
arch/arm/mach-imx/clk-imx27.c +1
-0@@ -224,6 +224,7 @@ int __init mx27_clocks_init(unsigned long fref)clk_register_clkdev (clk[lcdc_ipg_gate],"ipg" ,"imx21-fb.0" );clk_register_clkdev (clk[lcdc_ahb_gate],"ahb" ,"imx21-fb.0" );clk_register_clkdev (clk[csi_ahb_gate],"ahb" ,"imx27-camera.0" ); +clk_register_clkdev (clk[per4_gate],"per" ,"imx27-camera.0" );clk_register_clkdev (clk[usb_div],"per" ,"fsl-usb2-udc" );clk_register_clkdev (clk[usb_ipg_gate],"ipg" ,"fsl-usb2-udc" );clk_register_clkdev (clk[usb_ahb_gate],"ahb" ,"fsl-usb2-udc" );
Cheers,
Mauro
Sascha Hauer
maintainerPATCH v4 1/2 ARM: clk-imx27: Add missing clock for mx2-camera
Hi Mauro,
Quoted 10 lines · Mauro Carvalho Chehab
Em Tue, 30 Oct 2012 10:03:25 -0200
Fabio Estevam <[email protected]> escreveu:Quoted 7 lines
During the clock conversion for mx27 the "
per4_gate" clock was missed to get registered as a dependency of mx2-camera driver.In the old mx27 clock driver we used to have:
DEFINE_CLOCK1(csi_clk, 0, NULL, 0, parent, &csi_clk1, &per4_clk);
Quoted 7 lines
Quoted 4 lines
,so does the same in the new clock driver
Signed-off-by Fabio Estevam <[email protected]>Acked-by Sascha Hauer <[email protected]>As it seems that those patches depend on some patches at the arm tree, the better is to merge them via -arm tree.
Quoting yourself:
Quoted 3 lines
Forgot to comment: as patch 2 relies on this change, the better, IMHO, is to send both via the same tree. If you decide to do so, please get arm maintainer's ack, instead, and we can merge both via my tree.
That's why Fabio resent these patches with my Ack. You are free to take these.
Sascha
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Fabio Estevam
reviewerPATCH v4 1/2 ARM: clk-imx27: Add missing clock for mx2-camera
Hi Sascha,
Quoted 8 lines · Sascha Hauer
Quoting yourself:
Quoted 3 lines
Forgot to comment: as patch 2 relies on this change, the better, IMHO, is to send both via the same tree. If you decide to do so, please get arm maintainer's ack, instead, and we can merge both via my tree.
That's why Fabio resent these patches with my Ack. You are free to take these.
I have just realized that this patch (1/2) will not apply against media tree because it does not have commit 27b76486a3 (media:mx2_camera: remove cpu_is_xxx by using platform_device_id), which changes from mx2_camera.0 to imx27-camera.0.
So it seems to be better to merge this via arm tree to avoid such conflict.
Regards,
Fabio Estevam
PATCH v4 1/2 ARM: clk-imx27: Add missing clock for mx2-camera
Quoted 10 lines · Fabio Estevam
Hi Sascha,
Quoted 6 lines · Sascha Hauer
Quoting yourself:
Quoted 3 lines
Forgot to comment: as patch 2 relies on this change, the better, IMHO, is to send both via the same tree. If you decide to do so, please get arm maintainer's ack, instead, and we can merge both via my tree.
Quoted 7 lines
Quoted 2 lines
That's why Fabio resent these patches with my Ack. You are free to take these.
I have just realized that this patch (1/2) will not apply against media tree because it does not have commit
27b76486a3(media:mx2_camera: removecpu_is_xxxby usingplatform_device_id), which changes from mx2_camera.0 to imx27-camera.0.
This is exactly the reason why I wasn't able to merge it. The problem was, that this "media: mx2_camera: remove cpu_is_xxx by using platform_device_id" patch non-trivially touched both arch/arm/ and drivers/media/ directories. And being patch 27/34 I didn't feel like asking the author to redo it again:-) This confirms, that it's better to avoid such overlapping patches whenever possible.
Quoted 1 line
So it seems to be better to merge this via arm tree to avoid such conflict.
Thanks
Guennadi
Quoted 3 lines
Regards,
Fabio Estevam
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
PATCH v4 1/2 ARM: clk-imx27: Add missing clock for mx2-camera
Em Wed, 31 Oct 2012 14:53:47 +0100 (CET) Guennadi Liakhovetski <[email protected]> escreveu:
Quoted 20 lines · Fabio Estevam
Quoted 11 lines
Hi Sascha,
Quoted 6 lines · Sascha Hauer
Quoting yourself:
Quoted 3 lines
Forgot to comment: as patch 2 relies on this change, the better, IMHO, is to send both via the same tree. If you decide to do so, please get arm maintainer's ack, instead, and we can merge both via my tree.
Quoted 7 lines
Quoted 2 lines
That's why Fabio resent these patches with my Ack. You are free to take these.
I have just realized that this patch (1/2) will not apply against media tree because it does not have commit
27b76486a3(media:mx2_camera: removecpu_is_xxxby usingplatform_device_id), which changes from mx2_camera.0 to imx27-camera.0.
Quoted 8 lines
This is exactly the reason why I wasn't able to merge it. The problem was, that this "media:
mx2_camera: removecpu_is_xxxby usingplatform_device_id" patch non-trivially touched botharch/arm/anddrivers/media/directories. And being patch 27/34 I didn't feel like asking the author to redo it again:-) This confirms, that it's better to avoid such overlapping patches whenever possible.Quoted 1 line
So it seems to be better to merge this via arm tree to avoid such conflict.
I agree with Fabio and Guennadi. There are so many changes happening at arm that merging those two patches there will likely be easier for everybody.
Otherwise, I'll need to pull from some arm tree that never rebase, with the needed patches, and coordinate with you during the merge window, to be sure that patches will arrive there at the right order, from the right tree.
Cheers,
Mauro
Sascha Hauer
maintainerPATCH v4 1/2 ARM: clk-imx27: Add missing clock for mx2-camera
Quoted 30 lines · Mauro Carvalho Chehab
Em Wed, 31 Oct 2012 14:53:47 +0100 (CET) Guennadi Liakhovetski <[email protected]> escreveu:
Quoted 27 lines · Fabio Estevam
Quoted 11 lines
Hi Sascha,
Quoted 6 lines · Sascha Hauer
Quoting yourself:
Quoted 3 lines
Forgot to comment: as patch 2 relies on this change, the better, IMHO, is to send both via the same tree. If you decide to do so, please get arm maintainer's ack, instead, and we can merge both via my tree.
Quoted 7 lines
Quoted 2 lines
That's why Fabio resent these patches with my Ack. You are free to take these.
I have just realized that this patch (1/2) will not apply against media tree because it does not have commit
27b76486a3(media:mx2_camera: removecpu_is_xxxby usingplatform_device_id), which changes from mx2_camera.0 to imx27-camera.0.This is exactly the reason why I wasn't able to merge it. The problem was, that this "media:
mx2_camera: removecpu_is_xxxby usingplatform_device_id" patch non-trivially touched botharch/arm/anddrivers/media/directories. And being patch 27/34 I didn't feel like asking the author to redo it again:-) This confirms, that it's better to avoid such overlapping patches whenever possible.
Quoted 4 lines
Quoted 1 line
Quoted 1 line
So it seems to be better to merge this via arm tree to avoid such conflict.
I agree with Fabio and Guennadi. There are so many changes happening at arm that merging those two patches there will likely be easier for everybody.
Ok, then I'll take them. I wasn't aware in arm-soc are sitting patches for this driver already.
Quoted 5 lines
Otherwise, I'll need to pull from some arm tree that never rebase, with the needed patches, and coordinate with you during the merge window, to be sure that patches will arrive there at the right order, from the right tree.
Hopefully these kind of cross dependencies become fewer over time. SoC code is getting smaller and gets better abstracted from the drivers, so chances are good.
Sascha
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
PATCH v4 1/2 ARM: clk-imx27: Add missing clock for mx2-camera
Em Wed, 31 Oct 2012 20:02:49 +0100
Sascha Hauer <[email protected]> escreveu:
Quoted 11 lines · Mauro Carvalho Chehab
Quoted 7 lines
Em Wed, 31 Oct 2012 14:53:47 +0100 (CET) Guennadi Liakhovetski <[email protected]> escreveu:
Quoted 1 line · Fabio Estevam
I agree with Fabio and Guennadi. There are so many changes happening at arm that merging those two patches there will likely be easier for everybody.
Ok, then I'll take them. I wasn't aware in arm-soc are sitting patches for this driver already.
Thank you!
Quoted 9 lines
Quoted 5 lines
Otherwise, I'll need to pull from some arm tree that never rebase, with the needed patches, and coordinate with you during the merge window, to be sure that patches will arrive there at the right order, from the right tree.
Hopefully these kind of cross dependencies become fewer over time. SoC code is getting smaller and gets better abstracted from the drivers, so chances are good.
Yes, I'm expecting so.
Regards,
Mauro