Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp468299pxj; Wed, 16 Jun 2021 06:39:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysLZr2r+vJSxsFYsAPD99kUwfvv8RgBK4h1pGoqiakL6KmyGa0UdPVk1GNtP/z/PhV+0Gn X-Received: by 2002:a05:6e02:1a08:: with SMTP id s8mr3834277ild.5.1623850769179; Wed, 16 Jun 2021 06:39:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623850769; cv=none; d=google.com; s=arc-20160816; b=tdTZb5ojw8weLaIGUTIQ3jVVGnN32L40oYOSmLLmkJvYUrhm8P2Hmx0OdOaNcSrQ5M KQb56N0fmZdG9FqR3PgyHyCivdbtwTfzPwZN4rxPL8fp1yWjrGMXj+Vs3JiRJJv/qKxm elwirZK9JsBruNpe8C+dBFL6zZrmsafQOKJsbwbT8sxeaVWMIbZD0iurZlpFsu6ZTgAD qKpX+/3BI2pAiQOFJTB0ELP3JkgNfNP5vyQjbSc82ckHyCNxCQgT6CwflQzh05857xT5 HM+oWfh3cCOsjVwRFc2Nz9bNwdbwIKZm2CVUR+v4L4pZo+3Y08IcS6tf/UbOavmx+hNd Gi2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=CIv0kLEwGmObqXbwu+WlWfzPL5BRNuMW1nFnxCCZsas=; b=gZKUbcDEmWfMeny+PvFKA33DtPc6WGpB49UbbTb+DfAUedKsMm6ZiTjyrlkDdHsl9h BuhOoPU0STYDT+TF9YZHmot0rqSQ/I2guQmYz6iItIc2YZiqMIhxkZulWrqG+hOtC27A 1/k8iirw5rPdfH5JUoI7//O2QuTvsPGGM/s8DGod1jjbV6BfLqhzeqF9Yq5DwIKOYqfv ZDJJAUYYHAb7o/UvSO9F8TKjAlDviPbSjs7gWJ6tJ5hypsOdgEpEI6wceLhh1Wioc++s NJUhHqJ0U8As4gsWtm7gCmTR3mz/D8gC1DgRuCEy/eSQcbR/LwqD0hkV5VovgsRxY+bc Frgw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k7si3061578jad.43.2021.06.16.06.39.14; Wed, 16 Jun 2021 06:39:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232997AbhFPMsW (ORCPT + 99 others); Wed, 16 Jun 2021 08:48:22 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:57113 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232950AbhFPMsF (ORCPT ); Wed, 16 Jun 2021 08:48:05 -0400 Received: (Authenticated sender: jacopo@jmondi.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 9625A1C0010; Wed, 16 Jun 2021 12:45:56 +0000 (UTC) From: Jacopo Mondi To: Hans Verkuil , kieran.bingham+renesas@ideasonboard.com, laurent.pinchart+renesas@ideasonboard.com, niklas.soderlund+renesas@ragnatech.se, geert@linux-m68k.org Cc: Jacopo Mondi , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Laurent Pinchart Subject: [PATCH v5 09/15] media: i2c: rdacm21: Fix OV10640 powerup Date: Wed, 16 Jun 2021 14:46:10 +0200 Message-Id: <20210616124616.49249-10-jacopo+renesas@jmondi.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210616124616.49249-1-jacopo+renesas@jmondi.org> References: <20210616124616.49249-1-jacopo+renesas@jmondi.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The OV10640 image sensor powerdown signal is controlled by the first line of the OV490 GPIO pad #1, but the pad #0 identifier OV490_GPIO_OUTPUT_VALUE0 was erroneously used. As a result the image sensor powerdown signal was never asserted but was left floating and kept high by an internal pull-up resistor, causing sporadic failures during the image sensor startup phase. Fix this by using the correct GPIO pad identifier and wait the mandatory 1.5 millisecond delay after the powerup lane is asserted. The reset delay is not characterized in the chip manual if not as "255 XVCLK + initialization". Wait for at least 3 milliseconds to guarantee the SCCB bus is available. While at it also fix the reset sequence, as the reset line was released before the powerdown one, and the line was not cycled. This commit fixes a sporadic start-up error triggered by a failure to read the OV10640 chip ID: rdacm21 8-0054: OV10640 ID mismatch: (0x01) Fixes: a59f853b3b4b ("media: i2c: Add driver for RDACM21 camera module") Signed-off-by: Jacopo Mondi Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- drivers/media/i2c/rdacm21.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/rdacm21.c b/drivers/media/i2c/rdacm21.c index 6be8ce130e78..7c0a4a84340a 100644 --- a/drivers/media/i2c/rdacm21.c +++ b/drivers/media/i2c/rdacm21.c @@ -333,13 +333,19 @@ static int ov10640_initialize(struct rdacm21_device *dev) { u8 val; - /* Power-up OV10640 by setting RESETB and PWDNB pins high. */ + /* Enable GPIO0#0 (reset) and GPIO1#0 (pwdn) as output lines. */ ov490_write_reg(dev, OV490_GPIO_SEL0, OV490_GPIO0); ov490_write_reg(dev, OV490_GPIO_SEL1, OV490_SPWDN0); ov490_write_reg(dev, OV490_GPIO_DIRECTION0, OV490_GPIO0); ov490_write_reg(dev, OV490_GPIO_DIRECTION1, OV490_SPWDN0); + + /* Power up OV10640 and then reset it. */ + ov490_write_reg(dev, OV490_GPIO_OUTPUT_VALUE1, OV490_SPWDN0); + usleep_range(1500, 3000); + + ov490_write_reg(dev, OV490_GPIO_OUTPUT_VALUE0, 0x00); + usleep_range(1500, 3000); ov490_write_reg(dev, OV490_GPIO_OUTPUT_VALUE0, OV490_GPIO0); - ov490_write_reg(dev, OV490_GPIO_OUTPUT_VALUE0, OV490_SPWDN0); usleep_range(3000, 5000); /* Read OV10640 ID to test communications. */ -- 2.31.1