Return-path: Received: from mx3.redhat.com (mx3.redhat.com [172.16.48.32]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n760nRQK012797 for ; Wed, 5 Aug 2009 20:49:27 -0400 Received: from mail02.idc.renesas.com (mail.renesas.com [202.234.163.13]) by mx3.redhat.com (8.13.8/8.13.8) with ESMTP id n760nCEh021172 for ; Wed, 5 Aug 2009 20:49:13 -0400 Date: Thu, 06 Aug 2009 09:49:04 +0900 From: Kuninori Morimoto To: Guennadi Liakhovetski Message-id: MIME-version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-type: text/plain; charset=US-ASCII Cc: V4L-Linux Subject: [PATCH 1/2 v2] sh_mobile_ceu: add soft reset function List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: video4linux-list-bounces@redhat.com Errors-To: video4linux-list-bounces@redhat.com List-ID: Signed-off-by: Kuninori Morimoto --- 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