sh_mobile_ceu: add soft reset function
PATCH v3 1/2 sh_mobile_ceu: add soft reset function
---
v2 -> v3
o use udelay instead
o return err value
o print warning if time out
drivers/media/video/sh_mobile_ceu_camera.c | 42 ++++++++++++++++++++++++--- 1 files changed, 37 insertions(+), 5 deletions(-)
drivers/media/video/sh_mobile_ceu_camera.c +37 -5
@@ -135,6 +135,40 @@ static u32 ceu_read(struct sh_mobile_ceu_dev *priv, unsigned long reg_offs)return ioread32 (priv->base + reg_offs); } +static int sh_mobile_ceu_soft_reset (struct sh_mobile_ceu_dev *pcdev) +{ +int i, success =0 ; +struct soc_camera_device *icd = pcdev->icd; + +ceu_write (pcdev,CAPSR ,1 <<16 );/* reset */ + +/* wait CSTSR.CPTON bit */ +for (i =0 ; i <1000 ; i++) { +if (!(ceu_read (pcdev,CSTSR ) &1 )) { + success++; +break ; + } +udelay (1 ); + } + +/* wait CAPSR.CPKIL bit */ +for (i =0 ; i <1000 ; i++) { +if (!(ceu_read (pcdev,CAPSR ) & (1 <<16 ))) { + success++; +break ; + } +udelay (1 ); + } + + +if (2 != success) { +dev_warn (&icd->dev,"soft reset time out\n" ); +return -EIO ; + } + +return 0 ; +} +/* * Videobuf operations */
@@ -366,11 +400,9 @@ static int sh_mobile_ceu_add_device(struct soc_camera_device *icd)clk_enable (pcdev->clk); -ceu_write (pcdev,CAPSR ,1 <<16 );/* reset */ -while (ceu_read (pcdev,CSTSR ) &1 ) -msleep (1 ); - pcdev->icd = icd; + + ret =sh_mobile_ceu_soft_reset (pcdev); err:return ret; }
@@ -386,7 +418,7 @@ static void sh_mobile_ceu_remove_device(struct soc_camera_device *icd)/* disable capture, disable interrupts */ ceu_write (pcdev,CEIER ,0 ); -ceu_write (pcdev,CAPSR ,1 <<16 );/* reset */ +sh_mobile_ceu_soft_reset (pcdev);/* make sure active buffer is canceled */ spin_lock_irqsave (&pcdev->lock, flags);
Signature · 6 lines
1.6.0.4 -- video4linux-list mailing list Unsubscribe mailto:[email protected]?subject=unsubscribe https://www.redhat.com/mailman/listinfo/video4linux-list
Hi Morimoto-san
Quoted 2 lines · Kuninori Morimoto
Signed-off-by Kuninori Morimoto <[email protected]>
I've updated both your patches on the top of my current tree and slightly cleaned them up - mainly multi-line comments. Also fixed one error in sh_mobile_ceu_add_device() (see below). Please, check if the stack at
http://download.open-technology.de/soc-camera/20090826/ looks ok and still works for you. As usual, you find instructions on which tree and branch to use in 0000-base.
Quoted 58 lines
---
v2 -> v3o use udelay instead
o return err value
o print warning if time outdrivers/media/video/sh_mobile_ceu_camera.c | 42 ++++++++++++++++++++++++--- 1 files changed, 37 insertions(+), 5 deletions(-)drivers/media/video/sh_mobile_ceu_camera.c +34
-0@@ -135,6 +135,40 @@ static u32 ceu_read(struct sh_mobile_ceu_dev *priv, unsigned long reg_offs)return ioread32 (priv->base + reg_offs); } +static int sh_mobile_ceu_soft_reset (struct sh_mobile_ceu_dev *pcdev) +{ +int i, success =0 ; +struct soc_camera_device *icd = pcdev->icd; + +ceu_write (pcdev,CAPSR ,1 <<16 );/* reset */ + +/* wait CSTSR.CPTON bit */ +for (i =0 ; i <1000 ; i++) { +if (!(ceu_read (pcdev,CSTSR ) &1 )) { + success++; +break ; + } +udelay (1 ); + } + +/* wait CAPSR.CPKIL bit */ +for (i =0 ; i <1000 ; i++) { +if (!(ceu_read (pcdev,CAPSR ) & (1 <<16 ))) { + success++; +break ; + } +udelay (1 ); + } + + +if (2 != success) { +dev_warn (&icd->dev,"soft reset time out\n" ); +return -EIO ; + } + +return 0 ; +} +/* * Videobuf operations */ @@ -366,11 +400,9 @@ static int sh_mobile_ceu_add_device(struct soc_camera_device *icd)clk_enable (pcdev->clk);
drivers/media/video/sh_mobile_ceu_camera.c static int sh_mobile_ceu_add_device(struct soc_camera_device *icd) · line 407
Quoted 10 lines
drivers/media/video/sh_mobile_ceu_camera.c +2
-4-ceu_write (pcdev,CAPSR ,1 <<16 );/* reset */ -while (ceu_read (pcdev,CSTSR ) &1 ) -msleep (1 ); - pcdev->icd = icd; + + ret =sh_mobile_ceu_soft_reset (pcdev); err:return ret;
This means, even in error case you'd have "pcdev->icd = icd" and a repeated call to sh_mobile_ceu_add_device() would return -EBUSY. I fixed this in my version.
Quoted 13 lines
drivers/media/video/sh_mobile_ceu_camera.c +1
-1}@@ -386,7 +418,7 @@ static void sh_mobile_ceu_remove_device(struct soc_camera_device *icd)/* disable capture, disable interrupts */ ceu_write (pcdev,CEIER ,0 ); -ceu_write (pcdev,CAPSR ,1 <<16 );/* reset */ +sh_mobile_ceu_soft_reset (pcdev);/* make sure active buffer is canceled */ spin_lock_irqsave (&pcdev->lock, flags);Signature · 1 line
1.6.0.4
Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Dear Guennadi
Quoted 6 lines
I've updated both your patches on the top of my current tree and slightly cleaned them up - mainly multi-line comments. Also fixed one error in
sh_mobile_ceu_add_device()(see below). Please, check if the stack at
http://download.open-technology.de/soc-camera/20090826/ looks ok and still works for you. As usual, you find instructions on which tree and branch to use in 0000-base.
Thank you for your hard work.
It looks OK for me.
But I wounder that does your and Paul's git can merge correctly ? I can find Magnus patch on sh_mobile_ceu_camera.c in latest Paul's git
--------------------------
commit 6d1386c6b8db54ac8d94c01194e0c27cd538532b
Author: Magnus Damm <[email protected]> Date: Fri Aug 14 10:49:17 2009 +0000
v4l2: Runtime PM for SuperH Mobile CEU
This patch modifies the SuperH Mobile CEU driver to support Runtime PM. Driver callbacks for Runtime PM are empty because the device registers are always re-initialized after pm_runtime_get_sync(). The Runtime PM functions replaces the clock framework module stop bit handling in this driver.
drivers/media/video/sh_mobile_ceu_camera.c +0 -0
--------------------------
Best regards
--
Kuninori Morimoto
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
Quoted 10 lines · Kuninori Morimoto
Dear Guennadi
Quoted 6 lines
I've updated both your patches on the top of my current tree and slightly cleaned them up - mainly multi-line comments. Also fixed one error in
sh_mobile_ceu_add_device()(see below). Please, check if the stack at
http://download.open-technology.de/soc-camera/20090826/ looks ok and still works for you. As usual, you find instructions on which tree and branch to use in 0000-base.
Quoted 4 lines
Thank you for your hard work.
It looks OK for me.
But I wounder that does your and Paul's git can merge correctly ? I can find Magnus patch onsh_mobile_ceu_camera.cin latest Paul's git
That will be handled when the time comes:-)
Thanks
Guennadi
---
Guennadi Liakhovetski
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list