All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2 v2] sh_mobile_ceu: add soft reset function
@ 2009-08-06  0:49 Kuninori Morimoto
  2009-08-06  8:13 ` Guennadi Liakhovetski
  2009-08-07  5:24 ` Magnus Damm
  0 siblings, 2 replies; 3+ messages in thread
From: Kuninori Morimoto @ 2009-08-06  0:49 UTC (permalink / raw)
  To: Guennadi Liakhovetski; +Cc: V4L-Linux


Signed-off-by: Kuninori Morimoto <morimoto.kuninori@renesas.com>
---
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(-)

diff --git a/drivers/media/video/sh_mobile_ceu_camera.c b/drivers/media/video/sh_mobile_ceu_camera.c
index 0db88a5..3741ad6 100644
--- a/drivers/media/video/sh_mobile_ceu_camera.c
+++ b/drivers/media/video/sh_mobile_ceu_camera.c
@@ -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);
-- 
1.6.0.4

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2 v2] sh_mobile_ceu: add soft reset function
  2009-08-06  0:49 [PATCH 1/2 v2] sh_mobile_ceu: add soft reset function Kuninori Morimoto
@ 2009-08-06  8:13 ` Guennadi Liakhovetski
  2009-08-07  5:24 ` Magnus Damm
  1 sibling, 0 replies; 3+ messages in thread
From: Guennadi Liakhovetski @ 2009-08-06  8:13 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: V4L-Linux

On Thu, 6 Aug 2009, Kuninori Morimoto wrote:

> 
> Signed-off-by: Kuninori Morimoto <morimoto.kuninori@renesas.com>

Ok, I'm away for a week starting today, I'll have a look at your patches 
after I come back then.

Thanks
Guennadi

> ---
> 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(-)
> 
> diff --git a/drivers/media/video/sh_mobile_ceu_camera.c b/drivers/media/video/sh_mobile_ceu_camera.c
> index 0db88a5..3741ad6 100644
> --- a/drivers/media/video/sh_mobile_ceu_camera.c
> +++ b/drivers/media/video/sh_mobile_ceu_camera.c
> @@ -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);
> -- 
> 1.6.0.4
> 

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2 v2] sh_mobile_ceu: add soft reset function
  2009-08-06  0:49 [PATCH 1/2 v2] sh_mobile_ceu: add soft reset function Kuninori Morimoto
  2009-08-06  8:13 ` Guennadi Liakhovetski
@ 2009-08-07  5:24 ` Magnus Damm
  1 sibling, 0 replies; 3+ messages in thread
From: Magnus Damm @ 2009-08-07  5:24 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: V4L-Linux, Guennadi Liakhovetski

Hi Morimoto-san,

Thanks for your work on this.

On Thu, Aug 6, 2009 at 9:49 AM, Kuninori
Morimoto<morimoto.kuninori@renesas.com> wrote:
>
> Signed-off-by: Kuninori Morimoto <morimoto.kuninori@renesas.com>
> ---
> 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.

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:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-08-07  5:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-06  0:49 [PATCH 1/2 v2] sh_mobile_ceu: add soft reset function Kuninori Morimoto
2009-08-06  8:13 ` Guennadi Liakhovetski
2009-08-07  5:24 ` Magnus Damm

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.