Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1558672pxf; Fri, 19 Mar 2021 09:44:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUMYc7WALJLN3itw/jkvBpB3lnUN23Cw48n8QDQGm+Gwn+66knBnXiuXmCkSu6gF2Almnh X-Received: by 2002:a50:8524:: with SMTP id 33mr10753073edr.110.1616172289438; Fri, 19 Mar 2021 09:44:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616172289; cv=none; d=google.com; s=arc-20160816; b=K3vQwx8UP8SUwuRsCfB3bWI5B4GgHsfhUaxw+87ZnLzLMHRgRpZVwMQvXmvHK97zNK q5cwG8YV5CYYW2x0S8WfE0WI3lNRditraUYnAlX7OsGxije8V55Az8ehI5+uXbgBr+fs sQA4xY6pt2r7Lwd2Tdo0aYOJJwjZgdg7K1QHow6nrVLFBt1aWyyMSGT7lLtXKg/khKe2 SaYM36YZ4OF+brcarkButYD25IoiunlmDfdaTRS9fDLnfCp82/lh0pcegTiKSuR2ZNHz 7Ws8ClZnArBom7F2/ZNHUCXXlGbfYEDhIWY5N7ZnbUr6msgGzDhGriWKqrva3kSnZiVV mruw== 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=cAAS1s2xzP6bcPiYo0JCIlqWz5w2M7ukRNKJmRUSBRI=; b=cxel2TWjZ1bWNhrRlzuTWV3Z+tL/vi7wyGw3NjiMPGH3fGwYMXFknNjDSBgk4kKam8 Ljova/LhjKJ2Q1aXafozLURNa1AQ6kuF97mjiG9ews5OfsVKj9xfGytEPHqmByoIjWj9 CcH4ZUQWlEeDBBwkMiAemjAm11/11XZrs/Pa4CNR887S7gZu72wVAJOhKdKG3v9ue5O+ iQXNXCcc/I6eKgZ3kYrtngnYS0kIcFK8yadmxc7sLTM7C9n8EsDOc9Wo/tUnD8akjLzI j3xUc1VEYKCYVUjmVrMbIM3/XAnwBDlK2tNKHAFIRJx9dX4ep3bQ1xzzada6NZPF4pE5 OuRQ== 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 o21si4538796ejc.724.2021.03.19.09.44.26; Fri, 19 Mar 2021 09:44:49 -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 S231214AbhCSQnC (ORCPT + 99 others); Fri, 19 Mar 2021 12:43:02 -0400 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:50443 "EHLO relay6-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230478AbhCSQme (ORCPT ); Fri, 19 Mar 2021 12:42:34 -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 91D97C000B; Fri, 19 Mar 2021 16:42:29 +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 19/19] media: i2c: rdacm20: Re-work ov10635 reset Date: Fri, 19 Mar 2021 17:41:48 +0100 Message-Id: <20210319164148.199192-20-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 OV10635 image sensor embedded in the camera module is currently reset after the MAX9271 initialization with two long delays that were most probably not correctly characterized. Re-work the image sensor reset procedure by holding the chip in reset during the MAX9271 configuration, removing the long sleep delays and only wait after the chip exits from reset for 350-500 microseconds interval, which is larger than the minimum (2048 * (1 / XVCLK)) timeout characterized in the chip manual. Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart Signed-off-by: Jacopo Mondi --- drivers/media/i2c/rdacm20.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/media/i2c/rdacm20.c b/drivers/media/i2c/rdacm20.c index 7ed3866b5335..7ba2d0249da8 100644 --- a/drivers/media/i2c/rdacm20.c +++ b/drivers/media/i2c/rdacm20.c @@ -454,6 +454,19 @@ static int rdacm20_init(struct v4l2_subdev *sd, unsigned int val) if (ret) return ret; + /* + * Hold OV10635 in reset during max9271 configuration. The reset signal + * has to be asserted for at least 200 microseconds. + */ + ret = max9271_enable_gpios(&dev->serializer, MAX9271_GPIO1OUT); + if (ret) + return ret; + + ret = max9271_clear_gpios(&dev->serializer, MAX9271_GPIO1OUT); + if (ret) + return ret; + usleep_range(200, 500); + ret = max9271_configure_gmsl_link(&dev->serializer); if (ret) return ret; @@ -468,22 +481,14 @@ static int rdacm20_init(struct v4l2_subdev *sd, unsigned int val) dev->serializer.client->addr = dev->addrs[0]; /* - * Reset the sensor by cycling the OV10635 reset signal connected to the - * MAX9271 GPIO1 and verify communication with the OV10635. + * Release ov10635 from reset and initialize it. The image sensor + * requires at least 2048 XVCLK cycles (85 micro-seconds at 24MHz) + * before being available. Stay safe and wait up to 500 micro-seconds. */ - ret = max9271_enable_gpios(&dev->serializer, MAX9271_GPIO1OUT); - if (ret) - return ret; - - ret = max9271_clear_gpios(&dev->serializer, MAX9271_GPIO1OUT); - if (ret) - return ret; - usleep_range(10000, 15000); - ret = max9271_set_gpios(&dev->serializer, MAX9271_GPIO1OUT); if (ret) return ret; - usleep_range(10000, 15000); + usleep_range(100, 500); for (i = 0; i < OV10635_PID_TIMEOUT; ++i) { ret = ov10635_read16(dev, OV10635_PID); -- 2.30.0