Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1558005pxf; Fri, 19 Mar 2021 09:43:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIdhZAjSTMCS1HJmCXr9Lp0d5wCxh/Aaam73M1jVxM7ysGdGl/qiOIXtD6rWCRKEM8KWse X-Received: by 2002:aa7:c447:: with SMTP id n7mr10487648edr.171.1616172221770; Fri, 19 Mar 2021 09:43:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616172221; cv=none; d=google.com; s=arc-20160816; b=BLJMkkjKTi8SsXDuYzi7TZpB6TzxneGlJ3HaHZLcqQk8OYKpyLGIi3zquT9DZ5zFPF JvTteXTUuBg7abGCkNjTgq2/dgB5kKoeWTId6WsSKmAVaOT2K8N93rRGjHU+dwMwZcw+ mtq+OZvzc0j+PUMV7N17ybdq4rmzF27rzIKwZ3TybA+6Uknhbd68k3Vpzu3B/nsa2L8u 3u6U0mdsLOjlMQgCgk/SUBaieyu7u4tjVOE3pLShWOMVhF3uTeRSOFgNpNtc1Q2FfCxi AfvWvwiU636xJiI2mnOSpJ5xjFgi40wLJAHhjABi4Yqx+CN/Hli0PbclLHhUzsu+k9rr cUFw== 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=01epPKwPSR5HSS2Eio0s4DiyAkThjEEcPj3cKUuK78c=; b=ker/XtLRAywJwHs5FcWw2tM2SVOC5TfRmo2jRCIKzLLdL//zI1amvXBlR/Lu9AorKC +g3Sg7JrrCxIlS6g3+li+ZwJwfm6Er0Hq/LHHSeISEKO+LsW97Nv+14rmJhErLXDXygp 4wchPpFBTQzxsQ6baMgAgcm7LRh6bGC1+JeZKhxgb24olJ2qbZH+fKC4kZaTTEOtbysW qwVQ+KEaEVpMGvj3JQql4zChdY9rz9wPrbOF14XM3HxkRfhVgDqDGMY9YWwOU8Uqm0qC Me+M09JvA/gneioa2oBuQBvZBFjqb4q9rGyn1RuSOLTRdwON24NsKyRIdxIAgBzQ3n2e VTKw== 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 g19si4763196eds.96.2021.03.19.09.43.18; Fri, 19 Mar 2021 09:43:41 -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 S230507AbhCSQmg (ORCPT + 99 others); Fri, 19 Mar 2021 12:42:36 -0400 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:32797 "EHLO relay6-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230239AbhCSQmL (ORCPT ); Fri, 19 Mar 2021 12:42:11 -0400 X-Originating-IP: 5.92.35.220 Received: from uno.localdomain (mob-5-92-35-220.net.vodafone.it [5.92.35.220]) (Authenticated sender: jacopo@jmondi.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 58E4AC0008; Fri, 19 Mar 2021 16:42:07 +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 v3 12/19] media: i2c: rdacm21: Fix OV10640 powerup Date: Fri, 19 Mar 2021 17:41:41 +0100 Message-Id: <20210319164148.199192-13-jacopo+renesas@jmondi.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210319164148.199192-1-jacopo+renesas@jmondi.org> References: <20210319164148.199192-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 875bec9f7904..3f38c465b348 100644 --- a/drivers/media/i2c/rdacm21.c +++ b/drivers/media/i2c/rdacm21.c @@ -318,13 +318,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.30.0