Web lists-archives.com

[PATCH 1/2] sh_mobile_ceu: add soft reset function




Signed-off-by: Kuninori Morimoto <morimoto.kuninori@xxxxxxxxxxx>
---
 drivers/media/video/sh_mobile_ceu_camera.c |   26 ++++++++++++++++++++++----
 1 files changed, 22 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..896bbf1 100644
--- a/drivers/media/video/sh_mobile_ceu_camera.c
+++ b/drivers/media/video/sh_mobile_ceu_camera.c
@@ -135,6 +135,26 @@ 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;
+
+	ceu_write(pcdev, CAPSR, 1 << 16); /* reset */
+	t = 10000;
+	while (t--) {
+		if (!(ceu_read(pcdev, CAPSR) & (1 << 16)))
+			break;
+		cpu_relax();
+	}
+
+	t = 10000;
+	while (t--) {
+		if (!(ceu_read(pcdev, CSTSR) & 1))
+			break;
+		cpu_relax();
+	}
+}
+
 /*
  *  Videobuf operations
  */
@@ -366,9 +386,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 +404,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@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list