Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp6612394ybn; Mon, 30 Sep 2019 00:29:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqy23OyiUtn1yMHO5w0mw2xfqFwOzva5/FcAuQtO6s6WihBVIBn40U/gOaFLD0OrqVJVxOmK X-Received: by 2002:a17:906:d0d2:: with SMTP id bq18mr18134316ejb.233.1569828575775; Mon, 30 Sep 2019 00:29:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569828575; cv=none; d=google.com; s=arc-20160816; b=te6VMOZfNyP2FqBNjIoqgCkuRccsxE1pbkqlhlLjJ9/mxSCY7Y6L30ZNJe+OyiAvUI DWEZMzAFVKDNpyvhWBLDVnGDDh2Y7wT5qRZ0BacqCsig3dhDkIS3SVUPfDOtBUQKTEif rJgibQZWQr++Zynl2KxQ9ZFOO06GaQdsZHWw/6wLjndUus7tp6TVJj9uCGRlXh2hLpsO eP94XUh/tWBIfMFLO4C9xLHsv5/OdExGxPewa4IkEVKDR/v3X4WDGFwPcN/bqaX68YWF 9b2feZBxRkbU/iHIMOBIXZYC7jx6ezJiYXskfqejioZ9Jrf/OdZz4h+hym6L3PsGAWI0 LsMQ== 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=4TBhZK5Rff54DyA/d4mZAjc02j47kCDVaue332S0qhU=; b=jTq+KdIrO07bACc0OGOL0fZ3w34vVmnsyJmWDB9KU0eAzlH/FEldlil3Sfm1dsmfe5 ojPjsuLjB8LjFRBObBdEVhqS0bn3LMzjQJvTRAJx2y3vLTNE8lh2j1UxNZEUS2cH1k0/ nRvZ6OVZsttgZ1vSDYbSa72Pi7CveimbLuN2PMkT/7+3qkC2E3zGxGc8VSxNBWgC6QaN Nq/eZJdbWk9dTRo7Cw+BxlfqbmLDzH/lGSyb9+bYQdm58lABHfVh7USzv4CQXfYgVRZc p8GVjMs7GdAGN6HGRGKEBSQZX6WPe5c++dGoKn1WDZdP+ijA7WsUGZ51CObWqeEHrPiQ vr2Q== 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 t26si6045364eju.238.2019.09.30.00.29.10; Mon, 30 Sep 2019 00:29:35 -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 S1729357AbfI3H3D (ORCPT + 99 others); Mon, 30 Sep 2019 03:29:03 -0400 Received: from mga01.intel.com ([192.55.52.88]:57004 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725767AbfI3H3D (ORCPT ); Mon, 30 Sep 2019 03:29:03 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Sep 2019 00:29:02 -0700 X-IronPort-AV: E=Sophos;i="5.64,565,1559545200"; d="scan'208";a="220563276" Received: from paasikivi.fi.intel.com ([10.237.72.42]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Sep 2019 00:29:00 -0700 Received: by paasikivi.fi.intel.com (Postfix, from userid 1000) id E351220343; Mon, 30 Sep 2019 10:28:57 +0300 (EEST) Date: Mon, 30 Sep 2019 10:28:57 +0300 From: Sakari Ailus To: Benoit Parrot Cc: Hans Verkuil , linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [Patch v4 6/8] media: i2c: ov2659: Add powerdown/reset gpio handling Message-ID: <20190930072857.GA19037@paasikivi.fi.intel.com> References: <20190927184722.31989-1-bparrot@ti.com> <20190927184722.31989-7-bparrot@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190927184722.31989-7-bparrot@ti.com> 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 Benoit, On Fri, Sep 27, 2019 at 01:47:20PM -0500, Benoit Parrot wrote: > On some board it is possible that the sensor 'powerdown' and or 'reset' > pin might be controlled by gpio instead of being tied. > > To implement we add pm_runtime support which will handle the power > up/down sequence when it is available otherwise the sensor will be > powered on at module insertion/probe and powered off at module removal. > > Now originally the driver assumed that the sensor would always stay > powered and keep its register setting. We cannot assume this anymore, so > every time we "power up" we need to re-program the initial registers > configuration first. This was previously done only at probe time. > > Signed-off-by: Benoit Parrot > --- > drivers/media/i2c/Kconfig | 2 +- > drivers/media/i2c/ov2659.c | 88 +++++++++++++++++++++++++++++++++++++- > 2 files changed, 87 insertions(+), 3 deletions(-) > > diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig > index 7eee1812bba3..315c1d8bdb7b 100644 > --- a/drivers/media/i2c/Kconfig > +++ b/drivers/media/i2c/Kconfig > @@ -634,7 +634,7 @@ config VIDEO_OV2640 > config VIDEO_OV2659 > tristate "OmniVision OV2659 sensor support" > depends on VIDEO_V4L2 && I2C > - depends on MEDIA_CAMERA_SUPPORT > + depends on MEDIA_CAMERA_SUPPORT && GPIOLIB > select V4L2_FWNODE > help > This is a Video4Linux2 sensor driver for the OmniVision > diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c > index cd4625432264..7d0baa386644 100644 > --- a/drivers/media/i2c/ov2659.c > +++ b/drivers/media/i2c/ov2659.c > @@ -22,9 +22,11 @@ > > #include > #include > +#include > #include > #include > #include > +#include > > #include > #include > @@ -218,6 +220,11 @@ struct ov2659 { > struct sensor_register *format_ctrl_regs; > struct ov2659_pll_ctrl pll; > int streaming; > + /* used to control the sensor PWDN pin */ > + struct gpio_desc *pwdn_gpio; > + /* used to control the sensor RESETB pin */ > + struct gpio_desc *resetb_gpio; > + int on; Please use runtime PM for this instead. It's hard to get this right otherwise. Access to "on" is not serialised with the power state changes. In this case e.g. drivers/media/i2c/ov5670.c is a good example. I think I'll see how I could improve smiapp as well. -- Sakari Ailus sakari.ailus@linux.intel.com