Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1629831pxb; Mon, 12 Apr 2021 02:53:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDk1kRryGGBqBc821nwhYoXPedAzYeor/P8MlkClFAxQHDYGrDZAJ0kimuBUEL3UgcZZtP X-Received: by 2002:a17:902:a5c1:b029:e7:3ee0:a1e9 with SMTP id t1-20020a170902a5c1b02900e73ee0a1e9mr25897326plq.82.1618221201399; Mon, 12 Apr 2021 02:53:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618221201; cv=none; d=google.com; s=arc-20160816; b=hJst0bJn8IEy2TtVn9c3BHH8MLATXqpTymxPD37hFS1rju6uaFSMcDf8WyOqU6DCzr DIHfTFIjXuaMRgbJjkgyqnnp6GU33Oi1x96Mc8jg9hMCov8KmYIZoqxiFlVj2vY/ciYq JequeRlHgHyKlsHiRd9Mkh5QBrWWVvvvX7D1Yvnwc+DiEFYuRkI0wjYjtv5NjEqhox7O T8mMRMYs75bA2lXvc/0pMq3XTN22u+QRhKvs/lJ1teVKYfxnSXE9uq3H4/lX0QkqbO0f CDR6jLHXeob3Ab1+LINoeqRDg07U3u4+TBwoVNCcZVzlurVD0F0IPegxRtNGVikcCiqw 5oBw== 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=MmsfdrWFWn1HS4kB9Uf+cHmz1joe2zMnioE5JQFpGWg=; b=hvYt+jtU8AudlL+WVoJASyDH3Nf99ahltQPfQD00OiUxhKxaMftEgM7Wrk3529ntQD CtC/X8xLo3ciHDkW8eVP+MHE9Zvg73TCoYHIsRGiIjgSiUkmF0VizSazu+49YP+rEP/q ZelrTeancw5gGqH7DUIn73gwRvs0UUQzxGKSr2nDaxrBS+9fWQ6ThIBmd3jL/2rNRIgW fvx2PSHEPoVGlWj9dp49plcQaAKt55qZ6s7UfU5sEbFKsSI22BU68JBQRZscskNVDBKT bJTkWJ9RWu57rxPvjgNhx5q5TEgSh+vUMU/B2sMfBu0CnneIajKaqNEsJBQGBJcCtUpF Nl3Q== 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 p185si11998725pgp.320.2021.04.12.02.53.08; Mon, 12 Apr 2021 02:53: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 S242527AbhDLJuY (ORCPT + 99 others); Mon, 12 Apr 2021 05:50:24 -0400 Received: from relay12.mail.gandi.net ([217.70.178.232]:41649 "EHLO relay12.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239055AbhDLJgq (ORCPT ); Mon, 12 Apr 2021 05:36:46 -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 20BBF200018; Mon, 12 Apr 2021 09:34:49 +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 15/17] media: i2c: rdacm20: Re-work ov10635 reset Date: Mon, 12 Apr 2021 11:34:49 +0200 Message-Id: <20210412093451.14198-16-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 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 e6fed86a3281..cb725c2778c0 100644 --- a/drivers/media/i2c/rdacm20.c +++ b/drivers/media/i2c/rdacm20.c @@ -473,6 +473,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; @@ -487,22 +500,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); again: ret = ov10635_read16(dev, OV10635_PID); -- 2.31.1