Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp468455pxj; Wed, 16 Jun 2021 06:39:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJo04R8d/p1BqCGF25mTDethFxTzAb/Sj9qdJ66gYMwBUw2k9x+psTpzcnkFadvEN54/AP X-Received: by 2002:a5e:8d02:: with SMTP id m2mr40774ioj.9.1623850780459; Wed, 16 Jun 2021 06:39:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623850780; cv=none; d=google.com; s=arc-20160816; b=gd0qe+elQCbDhNoK88uyw14j+zm78lXD371jiQyP+ALQmZeyUUPKjabhkZTxQlytJy F0pNnpgVqKOSzbkG3MWzMxvbTnD1D2SBmzn1Ht4YFfY4r3/RE+WBxfyj8d4xvERovxCS USsakR07J102unGEVlIuYdq+sQck82siiagvw6kSL/U7wxh3CHEd2JbrhU6UPitaQPcA 5yfeFAtGZf2L/0mJgOMnoT7W44zw00PboU58hX/lWY+1jmkreDLcrmhuKuwwj5A4jBQV 0s4TXDlmQQbT5d4wA1X9NDcMmbXM5p+z6xlnuBFNUkuiF7Xr4GoI901Sw2zc20CyJ+h5 aI0g== 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=GI+WFB8j5mCZersdQjCyrwRYibniR1Hb4jvyeGfeopo=; b=l8o5bfwS+2m9JOvAieWdz6zvvk6o92udEAOV/hj6Cm3HWe8cVljLofAvTvkgI89hGs /PsoduJDwOW4ipot6hv/LUkwC/xl26cYDtJxRwTTfyhACy6B8Q9QSfzBxRYgY1n8Dhfb w+VsaVrQBOqOmIdwpM5N4V1eIa/Lebfq6kBaE1LEhumksiDLethu4+DMf4bDltrVxRTF uvyb2IwAOePp7ly8hS2lcD127hBdoOAzGfsyzH9D0dvDFg5eJtuwKI6MJl8FYfAd62iJ kIDr0FrECASSdrnrPODQ52RH4lD1bScXUjq1unpkw3sarchfyHi83W5WCZeG6g2jmz7p WjNg== 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 b14si2432148ioj.18.2021.06.16.06.39.27; Wed, 16 Jun 2021 06:39:40 -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 S233028AbhFPMsq (ORCPT + 99 others); Wed, 16 Jun 2021 08:48:46 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:43029 "EHLO relay5-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233029AbhFPMsT (ORCPT ); Wed, 16 Jun 2021 08:48:19 -0400 Received: (Authenticated sender: jacopo@jmondi.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id B98CB1C0017; Wed, 16 Jun 2021 12:46:10 +0000 (UTC) From: Jacopo Mondi To: Hans Verkuil , 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 v5 15/15] media: i2c: rdacm20: Re-work ov10635 reset Date: Wed, 16 Jun 2021 14:46:16 +0200 Message-Id: <20210616124616.49249-16-jacopo+renesas@jmondi.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210616124616.49249-1-jacopo+renesas@jmondi.org> References: <20210616124616.49249-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. Signed-off-by: Jacopo Mondi Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- 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