sh_mobile_ceu: add soft reset function
PATCH v2 1/2 sh_mobile_ceu: add soft reset function
---
v1 -> v2
o it use msleep
o it judge in_atomic or not
it judge in_atomic because sh_mobile_ceu_soft_reset will also be called from atomic.
drivers/media/video/sh_mobile_ceu_camera.c | 36 ++++++++++++++++++++++++--- 1 files changed, 32 insertions(+), 4 deletions(-)
drivers/media/video/sh_mobile_ceu_camera.c +32 -4
@@ -135,6 +135,36 @@ static u32 ceu_read(struct sh_mobile_ceu_dev *priv, unsigned long reg_offs)return ioread32 (priv->base + reg_offs); } +static void sh_mobile_ceu_soft_reset (struct sh_mobile_ceu_dev *pcdev) +{ +int t; +int atomic =in_atomic (); + +ceu_write (pcdev,CAPSR ,1 <<16 );/* reset */ + + t =10000 ; +while (t--) { +if (!(ceu_read (pcdev,CAPSR ) & (1 <<16 ))) +break ; + +if (atomic) +cpu_relax (); +else +msleep (1 ); + } + + t =10000 ; +while (t--) { +if (!(ceu_read (pcdev,CSTSR ) &1 )) +break ; + +if (atomic) +cpu_relax (); +else +msleep (1 ); + } +} +/* * Videobuf operations */
@@ -366,9 +396,7 @@ 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 ); +sh_mobile_ceu_soft_reset (pcdev); pcdev->icd = icd; err:
@@ -386,7 +414,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
Quoted 2 lines · Kuninori Morimoto
Signed-off-by Kuninori Morimoto <[email protected]>
Ok, I'm away for a week starting today, I'll have a look at your patches after I come back then.
Thanks
Guennadi
Quoted 76 lines
---
v1 -> v2o it use msleep
o it judgein_atomicor notit judge
in_atomicbecausesh_mobile_ceu_soft_resetwill also be called from atomic.drivers/media/video/sh_mobile_ceu_camera.c | 36 ++++++++++++++++++++++++--- 1 files changed, 32 insertions(+), 4 deletions(-)drivers/media/video/sh_mobile_ceu_camera.c +32
-4@@ -135,6 +135,36 @@ static u32 ceu_read(struct sh_mobile_ceu_dev *priv, unsigned long reg_offs)return ioread32 (priv->base + reg_offs); } +static void sh_mobile_ceu_soft_reset (struct sh_mobile_ceu_dev *pcdev) +{ +int t; +int atomic =in_atomic (); + +ceu_write (pcdev,CAPSR ,1 <<16 );/* reset */ + + t =10000 ; +while (t--) { +if (!(ceu_read (pcdev,CAPSR ) & (1 <<16 ))) +break ; + +if (atomic) +cpu_relax (); +else +msleep (1 ); + } + + t =10000 ; +while (t--) { +if (!(ceu_read (pcdev,CSTSR ) &1 )) +break ; + +if (atomic) +cpu_relax (); +else +msleep (1 ); + } +} +/* * Videobuf operations */ @@ -366,9 +396,7 @@ 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 ); +sh_mobile_ceu_soft_reset (pcdev); pcdev->icd = icd; err:@@ -386,7 +414,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
---
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
Hi Morimoto-san,
Thanks for your work on this.
Quoted 10 lines · Kuninori Morimoto
Signed-off-by Kuninori Morimoto <[email protected]>---
v1 -> v2o it use msleep
o it judgein_atomicor notit judge
in_atomicbecausesh_mobile_ceu_soft_resetwill also be called from atomic.
If the time required for soft reset is short enough then you probably want to use udelay() instead. And if soft delay takes long time then you don't want to do it from interrupt context anyway. Please update the patch after summer vacation.
Cheers,
/ magnus
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list