Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp419286ybh; Wed, 11 Mar 2020 03:46:41 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuNHjQ2SfN10igkiplMxyQf+0B5eokf/P2uqfPzeF/oAhxQFvW+wrAqXq3MFn7rAnRweEV9 X-Received: by 2002:a05:6830:1645:: with SMTP id h5mr1833254otr.317.1583923601443; Wed, 11 Mar 2020 03:46:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583923601; cv=none; d=google.com; s=arc-20160816; b=Yjf4bmrAtLxZuGOIndwuXdsMRMsfZzMhXFq00/pA6YLFvNMWHF+bOToyxv93ubUc7p wZb2kw7m0eZLLSwAwiHQsVpSAr3mCoqmEQL1RCWzpzfO8sURn7VwS8GNGR+1lFd/WaBI eNY0uaHzsMzefdzlkLPOM/eM5TH7itOo/EeREoCMVSii+qyvwE4nUa44F75ydA1S6frk xxT4AqEpbeKTA9K0yX/qOZf/z65UJjeWMqJw490J+27YT+VVq853Nem1UUwanhLp8WBq gJjiZeaCtw9KZ8zi6MHtwHdUSJxHdKxec48j9jAcD7nu4EG5SXfDOmhiEUyWX9eyuycD Ty4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=1wIUylyQXwGKnD/G35BnBTwFCRhVOp8Z4jlUIwBI7h0=; b=QPmAe8rfXlXve0OcmU92xTr6Jzc3kPtqZqN8SKk4f9W+vPQGALTj9pGul7F0aBMZ01 0i0waEWHxjukk2uw/o3ggTnNN/D4kTNg2Z5EYeIk1+/GXpEX29Gn9/MX53XKM1cY7VNR mWmlD5Bc63wYSkEQ8Z6r1S5UUx2AvV7asIp5DOE6ZOv0EC/26+8yByvfzA/eO2J4z58T LjLOY9s9PDz2WnovMDGpn/SxhdS+RrD/l1QtRNmFo4GyktENuroNEFaaVtFyC3OCnPNf lajpZiTJjH5Cz6ZvNbF4jou4s3OxWWyQHO7I9/QnogR3//hc9EkwYZjkC/EW2h2jprQR zqAA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o20si99996oos.59.2020.03.11.03.46.29; Wed, 11 Mar 2020 03:46:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728933AbgCKKp6 (ORCPT + 99 others); Wed, 11 Mar 2020 06:45:58 -0400 Received: from mga06.intel.com ([134.134.136.31]:3022 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726044AbgCKKp6 (ORCPT ); Wed, 11 Mar 2020 06:45:58 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Mar 2020 03:45:56 -0700 X-IronPort-AV: E=Sophos;i="5.70,540,1574150400"; d="scan'208";a="289344053" Received: from paasikivi.fi.intel.com ([10.237.72.42]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Mar 2020 03:45:54 -0700 Received: by paasikivi.fi.intel.com (Postfix, from userid 1000) id A1EA82096B; Wed, 11 Mar 2020 12:45:52 +0200 (EET) Date: Wed, 11 Mar 2020 12:45:52 +0200 From: Sakari Ailus To: Tomasz Figa Cc: Linux Media Mailing List , Shunqian Zheng , Mauro Carvalho Chehab , Linux Kernel Mailing List , Dongchun Zhu Subject: Re: [PATCH] media: i2c: ov5695: Fix power on and off sequences Message-ID: <20200311104552.GK5379@paasikivi.fi.intel.com> References: <20191220130800.61589-1-tfiga@chromium.org> <20191220151939.GA19828@paasikivi.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Tomasz, On Wed, Mar 11, 2020 at 07:39:15PM +0900, Tomasz Figa wrote: > Hi Sakari, > > On Sat, Dec 21, 2019 at 12:19 AM Sakari Ailus > wrote: > > > > Hi Tomasz, > > > > On Fri, Dec 20, 2019 at 10:08:00PM +0900, Tomasz Figa wrote: > > > From: Dongchun Zhu > > > > > > From the measured hardware signal, OV5695 reset pin goes high for a > > > short period of time during boot-up. From the sensor specification, the > > > reset pin is active low and the DT binding defines the pin as active > > > low, which means that the values set by the driver are inverted and thus > > > the value requested in probe ends up high. > > > > > > Fix it by changing probe to request the reset GPIO initialized to high, > > > which makes the initial state of the physical signal low. > > > > > > In addition, DOVDD rising must occur before DVDD rising from spec., but > > > regulator_bulk_enable() API enables all the regulators asynchronously. > > > Use an explicit loops of regulator_enable() instead. > > > > > > For power off sequence, it is required that DVDD falls first. Given the > > > bulk API does not give any guarantee about the order of regulators, > > > change the driver to use regulator_disable() instead. > > > > > > The sensor also requires a delay between reset high and first I2C > > > transaction, which was assumed to be 8192 XVCLK cycles, but 1ms is > > > recommended by the vendor. Fix this as well. > > > > > > Signed-off-by: Dongchun Zhu > > > Signed-off-by: Tomasz Figa > > > --- > > > drivers/media/i2c/ov5695.c | 41 +++++++++++++++++++++----------------- > > > 1 file changed, 23 insertions(+), 18 deletions(-) > > > > > > diff --git a/drivers/media/i2c/ov5695.c b/drivers/media/i2c/ov5695.c > > > index d6cd15bb699ac..8d0cc3893fcfc 100644 > > > --- a/drivers/media/i2c/ov5695.c > > > +++ b/drivers/media/i2c/ov5695.c > > > @@ -971,16 +971,9 @@ static int ov5695_s_stream(struct v4l2_subdev *sd, int on) > > > return ret; > > > } > > > > > > -/* Calculate the delay in us by clock rate and clock cycles */ > > > -static inline u32 ov5695_cal_delay(u32 cycles) > > > -{ > > > - return DIV_ROUND_UP(cycles, OV5695_XVCLK_FREQ / 1000 / 1000); > > > -} > > > - > > > static int __ov5695_power_on(struct ov5695 *ov5695) > > > { > > > - int ret; > > > - u32 delay_us; > > > + int i, ret; > > > struct device *dev = &ov5695->client->dev; > > > > > > ret = clk_prepare_enable(ov5695->xvclk); > > > @@ -991,21 +984,24 @@ static int __ov5695_power_on(struct ov5695 *ov5695) > > > > > > gpiod_set_value_cansleep(ov5695->reset_gpio, 1); > > > > > > - ret = regulator_bulk_enable(OV5695_NUM_SUPPLIES, ov5695->supplies); > > > - if (ret < 0) { > > > - dev_err(dev, "Failed to enable regulators\n"); > > > - goto disable_clk; > > > + for (i = 0; i < OV5695_NUM_SUPPLIES; i++) { > > > + ret = regulator_enable(ov5695->supplies[i].consumer); > > > > The regulator voltage takes some time before it settles. If the hardware > > requires a particular order, then presumably there should be a small delay > > to ensure that. 1 ms should be plenty. > > The regulator API guarantees that when regulator_enable() returns, the > voltage is stable. Regulator ramp up delays can be also configured via > DT to take care for per-platform variability. Ack. In practice not many drivers do that still. But that should probably be seen as a driver bug indeed. -- Regards, Sakari Ailus