Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3285304pxf; Mon, 15 Mar 2021 06:17:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2cK5EZRnB+fSj+XLwKtm3kZ4yFB4NlKcAVi8PVq35+H3NEddIx4IMOqPjIszB47zVkGJe X-Received: by 2002:a17:906:5495:: with SMTP id r21mr7069451ejo.471.1615814241784; Mon, 15 Mar 2021 06:17:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615814241; cv=none; d=google.com; s=arc-20160816; b=oGVEL7n4Rp6km+lymgFjSmHsmFAHhiEYEa7kYKA0YKzvy85IcDLcf096buMxmbGLcM aavzqN34PUA62iJP9kihJWTi76N0dElV8GU1Q7XJer1Lexj7iNJOorfVncTnw6wxTS4J /lem4bDbOS09Hh01Ks9XSWhlTWWg7+De8Lw9FLApU7A3/LT9MuVuSYsyX1RIzL2Dh0E8 iqLDK2LHYiNzHjahOMB37G8kh89RJtRmdDUfRlMZrlkzX/HCfzjbjuHnnuPvTBzL5Sdp iw23vzEuHSozFHRXsC/Ai175+ZQnnu4y2+k2XrfRMWa8Zq0OmBItwI9pJ86IO5cZGWfG WXqQ== 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=qhb2fxcfXUA6d/Evz1l6jyXIMlFez+AzMSrnogAYKQ0=; b=D6jz6cdWils4XAuJx0sPbSOSMgU0sR4wR9y6GLhmFFmq6C0TsJ/CG1cyahmHutDa9w PLzx8zeaNxixTYc5sg7WwWlv0ROAuOn2UThO18hL/mWu72TpnpkqzywIhTe+4DxX1Rv5 5S9cpC3QDtBRqnEFSbQ+tsupqoKaB1A7l6CXSU2Ax0ZrR6vLdg5XVm28Hqs3OGddBdPx DZQO3SW21++Jgk5sKwBgNSPWeMCbCIVDPbDZGJjO1BqKw7e51kB7qQbCeObNWTG0gw/t RvRbrJkmxR9G91TsUM0T7VpXPWT4Ski8hua/ffSFN7+NIW1gCCgUPd3Z277c+wsg+gNX fGjw== 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 lr15si10579556ejb.275.2021.03.15.06.16.57; Mon, 15 Mar 2021 06:17:21 -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 S231127AbhCONPo (ORCPT + 99 others); Mon, 15 Mar 2021 09:15:44 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:42843 "EHLO relay9-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229830AbhCONPQ (ORCPT ); Mon, 15 Mar 2021 09:15:16 -0400 X-Originating-IP: 79.22.58.175 Received: from uno.homenet.telecomitalia.it (host-79-22-58-175.retail.telecomitalia.it [79.22.58.175]) (Authenticated sender: jacopo@jmondi.org) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 5AFB7FF812; Mon, 15 Mar 2021 13:15:12 +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 v2 08/18] media: i2c: rdacm20: Re-work ov10635 reset Date: Mon, 15 Mar 2021 14:15:02 +0100 Message-Id: <20210315131512.133720-9-jacopo+renesas@jmondi.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210315131512.133720-1-jacopo+renesas@jmondi.org> References: <20210315131512.133720-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 312450db958d..b9aaa0f7db42 100644 --- a/drivers/media/i2c/rdacm20.c +++ b/drivers/media/i2c/rdacm20.c @@ -477,6 +477,19 @@ static int rdacm20_initialize(struct rdacm20_device *dev) 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; @@ -491,22 +504,14 @@ static int rdacm20_initialize(struct rdacm20_device *dev) 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