Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1629963pxb; Mon, 12 Apr 2021 02:53:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcH6W2IEgv57pxm+3i6kJtDXuPlN2eQTqkicB9ZHyGI6V4UHzcLV0VFlm50K9xAfnYKY0T X-Received: by 2002:a17:90a:d801:: with SMTP id a1mr11658486pjv.138.1618221218302; Mon, 12 Apr 2021 02:53:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618221218; cv=none; d=google.com; s=arc-20160816; b=yckJfL0gjv08mWsCGEA110uNVgl91pkJVfUH5+boELZ5Hf1ClLPp9PoA2vt6OG9bfD xoBqMpFxAqvyaEdBnzL9TS9N6tbDgMepaMTmEX9lmsoAq8xvIZ+KrP5DlWtBRXYGNwa5 gGO7lo3aFgmHxIRKSftjcntbPHMbjodz2GeomLtRzMnrWgXTXsQkmdomNmWBQrcgzCOu i4qVFV0/X9UBFAo6Ro8MVP0m5ELwGTbR/uTcrIAwStNzOtWeZIe5zZW/jDxYdqLWYJNi aJiE1nMnv7y0VuB2dCVnZlmG25Xm1ZrlkXfzzWnbEmzOd/eQxsvYuLb5BZRMFkoF6mkz wGAg== 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=o07pCcxN7/vNRyKzyDGu1VBfivgCIGtQCvYzChRLq/0=; b=pGiw16DyRMDsv8T20MnPbpr1CU+Ld5mixwvlTFO0A3tkYgDhzleGvsgmhFixQpO59W xL15Eab5JtGa9jBRUCDIkjZswRlNcCQ/Wb8+9wEOO+p9OJ+eHcZJXtYIFepYsjbifxUk /oMleV9+xFQxL0jeM2B8ynbHEQzwjCHoKNZPmbgfOKRvqPPIRCd93lMIF9LQ4wfF2rOr cdZbAhrksjWnL6xUkqrZ/rUpKAbtZqIewFNsIvBv/0Z30bJjHWN7cXWqJMFwEeOYPolQ Xbkb+Crsb4brYP3sax154PxTstOQHnKWBkS/o9Hgif3LycI1Hpk0W0KWRSBeWW128bTM 4QMg== 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 x72si13483853pfc.310.2021.04.12.02.53.23; Mon, 12 Apr 2021 02:53:38 -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 S241285AbhDLJsV (ORCPT + 99 others); Mon, 12 Apr 2021 05:48:21 -0400 Received: from relay12.mail.gandi.net ([217.70.178.232]:58373 "EHLO relay12.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240692AbhDLJfA (ORCPT ); Mon, 12 Apr 2021 05:35:00 -0400 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 20D4C20001A; Mon, 12 Apr 2021 09:34:36 +0000 (UTC) From: Jacopo Mondi To: 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 v4 09/17] media: i2c: rdacm21: Fix OV10640 powerup Date: Mon, 12 Apr 2021 11:34:43 +0200 Message-Id: <20210412093451.14198-10-jacopo+renesas@jmondi.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412093451.14198-1-jacopo+renesas@jmondi.org> References: <20210412093451.14198-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") Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart Signed-off-by: Jacopo Mondi --- 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