Message ID | 20231010005126.3425444-3-kieran.bingham@ideasonboard.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp2204833vqo; Mon, 9 Oct 2023 17:51:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHF7QghhdNs45e5xEoDttH1cEB2q730cyZhnE1UJJH7nMupWKi3etvrvd5q7qdj87oDz9Ij X-Received: by 2002:a17:90a:bc8:b0:273:f087:1c8f with SMTP id x8-20020a17090a0bc800b00273f0871c8fmr15155258pjd.11.1696899112088; Mon, 09 Oct 2023 17:51:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696899112; cv=none; d=google.com; s=arc-20160816; b=jd+24K82/GV07vUNKN1DIek2/5JUYv3Jso/7biuh/A3K+rNQEHOjbHVZ5umQLc4hbN +/xgienQkL1zYjIS4Ek0W+3qgP34ZFgZymsMwiHe0sXTMalHSTxsjOvJpv0rFwiFxu33 jdVK+8m+oxboBgrrwPUg0THJJtiRpIe/j3G1ImreCzPid1UqUhrEwcwhvVhFq2o1i6LP I3jHgpogyHPAXZRecfuTYZIA8fajXDj6Kujp43qdbnyErIgyjZ7bLD/lMmShLzrXyfh3 4LHtD4QTHXZKP3UgLvJ97UW10Nc0X7E1WPPnl9HLUH/nTCH+O5UdD6jdYcV0P7IsGF/g NF0A== 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 :dkim-signature; bh=FyH8uF3fcVfzpmptcNVc6ab7yZiCdq+V6fWYLFfyJRQ=; fh=K9XhkRf1fOoeiq1BBKobuN71OI6n2VgIwDJrdPRXaRg=; b=wBvxO3udIlTJmmtfF+OThs9m/XjFHhY4C0lWUj22n2VZWMTJfInhj2Xo2Z+z/rj24L KiFgYx8tPdZSsl83rfyWQxj0va1KQMuMIYQFI6O2oU1oP28eipCRTFthJpkA3JaaWmIa g432my4XxP8i4nIu54AUz9UkHCw2USQPN8usSfucheYCAabi0sM24VG+AXYGOSa31MWD Xhvay4O2q7jqeEZyHwt8RQpzFBJLbxgeOIFND2uUJkEGGX0enWZyJjd4sSfF4yEeVzE0 1EDDHg8ErNm4KMncvbv7Sl58O+mt3ZkGK4UrBc4lNnzKbjmJjvf5WdxSU9I5kyXIlSfV Q26w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=CK46n6zV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id gm16-20020a17090b101000b0027924ff5de3si12852076pjb.68.2023.10.09.17.51.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 17:51:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=CK46n6zV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 4B4238104390; Mon, 9 Oct 2023 17:51:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379295AbjJJAvo (ORCPT <rfc822;makky5685@gmail.com> + 18 others); Mon, 9 Oct 2023 20:51:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379274AbjJJAvk (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 9 Oct 2023 20:51:40 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22973EB; Mon, 9 Oct 2023 17:51:38 -0700 (PDT) Received: from Monstersaurus.local (aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net [82.37.23.78]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1BBB3EF2; Tue, 10 Oct 2023 02:51:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1696899093; bh=rnMJgKFBWGCjiyhcMU2IuGY2WEmrwzEZzGWN5THJvAA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CK46n6zV6Xh9jK/5YUIjEJ4q7bl6SZiYuDbASL3wtLglk7WEJc01WpilsbssmYsII 1cEdcpA/7IYdbIkV9HKVgCI4cjg3KyG35dvO/gKOfp/HIMrb+MLOflsJ2u4RU/9uCS yZNijO2DAel4XvrixE/Cds6c13aiAi6j114HS0N4= From: Kieran Bingham <kieran.bingham@ideasonboard.com> To: linux-media@vger.kernel.org, devicetree@vger.kernel.org Cc: Kieran Bingham <kieran.bingham@ideasonboard.com>, Sakari Ailus <sakari.ailus@linux.intel.com>, "Paul J. Murphy" <paul.j.murphy@intel.com>, Daniele Alessandrelli <daniele.alessandrelli@intel.com>, Mauro Carvalho Chehab <mchehab@kernel.org>, linux-kernel@vger.kernel.org (open list) Subject: [PATCH 2/5] media: i2c: imx335: Enable regulator supplies Date: Tue, 10 Oct 2023 01:51:23 +0100 Message-Id: <20231010005126.3425444-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231010005126.3425444-1-kieran.bingham@ideasonboard.com> References: <20231010005126.3425444-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 09 Oct 2023 17:51:51 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779327683559882555 X-GMAIL-MSGID: 1779327683559882555 |
Series | [1/5] media: dt-bindings: media: imx335: Add supply bindings | |
Commit Message
Kieran Bingham
Oct. 10, 2023, 12:51 a.m. UTC
Provide support for enabling and disabling regulator supplies to control
power to the camera sensor.
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
drivers/media/i2c/imx335.c | 41 ++++++++++++++++++++++++++++++++++++--
1 file changed, 39 insertions(+), 2 deletions(-)
Comments
Hi Kieran, Thank you for the patch. On 10/10/23 6:21 AM, Kieran Bingham wrote: > Provide support for enabling and disabling regulator supplies to control > power to the camera sensor. > > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > --- > drivers/media/i2c/imx335.c | 41 ++++++++++++++++++++++++++++++++++++-- > 1 file changed, 39 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c > index ec729126274b..bf12b9b69fce 100644 > --- a/drivers/media/i2c/imx335.c > +++ b/drivers/media/i2c/imx335.c > @@ -75,6 +75,19 @@ struct imx335_reg_list { > const struct imx335_reg *regs; > }; > > +static const char * const imx335_supply_name[] = { > + /* > + * Turn on the power supplies so that they rise in order of > + * 1.2v,-> 1.8 -> 2.9v > + * All power supplies should finish rising within 200ms. > + */ > + "avdd", /* Analog (2.9V) supply */ > + "ovdd", /* Digital I/O (1.8V) supply */ > + "dvdd", /* Digital Core (1.2V) supply */ > +}; > + > +#define IMX335_NUM_SUPPLIES ARRAY_SIZE(imx335_supply_name) > + > /** > * struct imx335_mode - imx335 sensor mode structure > * @width: Frame width > @@ -126,6 +139,8 @@ struct imx335 { > struct v4l2_subdev sd; > struct media_pad pad; > struct gpio_desc *reset_gpio; > + struct regulator_bulk_data supplies[IMX335_NUM_SUPPLIES]; > + > struct clk *inclk; > struct v4l2_ctrl_handler ctrl_handler; > struct v4l2_ctrl *link_freq_ctrl; > @@ -781,6 +796,17 @@ static int imx335_parse_hw_config(struct imx335 *imx335) > return PTR_ERR(imx335->reset_gpio); > } > > + for (i = 0; i < IMX335_NUM_SUPPLIES; i++) > + imx335->supplies[i].supply = imx335_supply_name[i]; > + > + ret = devm_regulator_bulk_get(imx335->dev, > + IMX335_NUM_SUPPLIES, > + imx335->supplies); Shouldn't this go directly in probe() function ? (Taking IMX219 driver as a reference..) > + if (ret) { > + dev_err(imx335->dev, "Failed to get regulators\n"); > + return ret; > + } > + > /* Get sensor input clock */ > imx335->inclk = devm_clk_get(imx335->dev, NULL); > if (IS_ERR(imx335->inclk)) { > @@ -859,6 +885,17 @@ static int imx335_power_on(struct device *dev) > struct imx335 *imx335 = to_imx335(sd); > int ret; > > + ret = regulator_bulk_enable(IMX335_NUM_SUPPLIES, > + imx335->supplies); > + if (ret) { > + dev_err(dev, "%s: failed to enable regulators\n", > + __func__); > + return ret; > + } > + > + usleep_range(500, 550); /* Tlow */ > + > + /* Set XCLR */ > gpiod_set_value_cansleep(imx335->reset_gpio, 1); > > ret = clk_prepare_enable(imx335->inclk); > @@ -867,7 +904,7 @@ static int imx335_power_on(struct device *dev) > goto error_reset; > } > > - usleep_range(20, 22); > + usleep_range(20, 22); /* T4 */ It would be help to document this addition of comment in the commit message as well. > > return 0; > > @@ -889,8 +926,8 @@ static int imx335_power_off(struct device *dev) > struct imx335 *imx335 = to_imx335(sd); > > gpiod_set_value_cansleep(imx335->reset_gpio, 0); > - > clk_disable_unprepare(imx335->inclk); > + regulator_bulk_disable(IMX335_NUM_SUPPLIES, imx335->supplies); > > return 0; > }
Hi Kieran,
kernel test robot noticed the following build warnings:
[auto build test WARNING on media-tree/master]
[also build test WARNING on sailus-media-tree/streams linus/master v6.6-rc5 next-20231009]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Kieran-Bingham/media-dt-bindings-media-imx335-Add-supply-bindings/20231010-085313
base: git://linuxtv.org/media_tree.git master
patch link: https://lore.kernel.org/r/20231010005126.3425444-3-kieran.bingham%40ideasonboard.com
patch subject: [PATCH 2/5] media: i2c: imx335: Enable regulator supplies
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20231010/202310101224.43dpo3Ng-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231010/202310101224.43dpo3Ng-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202310101224.43dpo3Ng-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/media/i2c/imx335.c:159: warning: Function parameter or member 'supplies' not described in 'imx335'
vim +159 drivers/media/i2c/imx335.c
45d19b5fb9aeab Martina Krasteva 2021-05-27 116
45d19b5fb9aeab Martina Krasteva 2021-05-27 117 /**
45d19b5fb9aeab Martina Krasteva 2021-05-27 118 * struct imx335 - imx335 sensor device structure
45d19b5fb9aeab Martina Krasteva 2021-05-27 119 * @dev: Pointer to generic device
45d19b5fb9aeab Martina Krasteva 2021-05-27 120 * @client: Pointer to i2c client
45d19b5fb9aeab Martina Krasteva 2021-05-27 121 * @sd: V4L2 sub-device
45d19b5fb9aeab Martina Krasteva 2021-05-27 122 * @pad: Media pad. Only one pad supported
45d19b5fb9aeab Martina Krasteva 2021-05-27 123 * @reset_gpio: Sensor reset gpio
45d19b5fb9aeab Martina Krasteva 2021-05-27 124 * @inclk: Sensor input clock
45d19b5fb9aeab Martina Krasteva 2021-05-27 125 * @ctrl_handler: V4L2 control handler
45d19b5fb9aeab Martina Krasteva 2021-05-27 126 * @link_freq_ctrl: Pointer to link frequency control
45d19b5fb9aeab Martina Krasteva 2021-05-27 127 * @pclk_ctrl: Pointer to pixel clock control
45d19b5fb9aeab Martina Krasteva 2021-05-27 128 * @hblank_ctrl: Pointer to horizontal blanking control
45d19b5fb9aeab Martina Krasteva 2021-05-27 129 * @vblank_ctrl: Pointer to vertical blanking control
45d19b5fb9aeab Martina Krasteva 2021-05-27 130 * @exp_ctrl: Pointer to exposure control
45d19b5fb9aeab Martina Krasteva 2021-05-27 131 * @again_ctrl: Pointer to analog gain control
45d19b5fb9aeab Martina Krasteva 2021-05-27 132 * @vblank: Vertical blanking in lines
45d19b5fb9aeab Martina Krasteva 2021-05-27 133 * @cur_mode: Pointer to current selected sensor mode
45d19b5fb9aeab Martina Krasteva 2021-05-27 134 * @mutex: Mutex for serializing sensor controls
45d19b5fb9aeab Martina Krasteva 2021-05-27 135 * @streaming: Flag indicating streaming state
45d19b5fb9aeab Martina Krasteva 2021-05-27 136 */
45d19b5fb9aeab Martina Krasteva 2021-05-27 137 struct imx335 {
45d19b5fb9aeab Martina Krasteva 2021-05-27 138 struct device *dev;
45d19b5fb9aeab Martina Krasteva 2021-05-27 139 struct i2c_client *client;
45d19b5fb9aeab Martina Krasteva 2021-05-27 140 struct v4l2_subdev sd;
45d19b5fb9aeab Martina Krasteva 2021-05-27 141 struct media_pad pad;
45d19b5fb9aeab Martina Krasteva 2021-05-27 142 struct gpio_desc *reset_gpio;
15931cfe0b52d1 Kieran Bingham 2023-10-10 143 struct regulator_bulk_data supplies[IMX335_NUM_SUPPLIES];
15931cfe0b52d1 Kieran Bingham 2023-10-10 144
45d19b5fb9aeab Martina Krasteva 2021-05-27 145 struct clk *inclk;
45d19b5fb9aeab Martina Krasteva 2021-05-27 146 struct v4l2_ctrl_handler ctrl_handler;
45d19b5fb9aeab Martina Krasteva 2021-05-27 147 struct v4l2_ctrl *link_freq_ctrl;
45d19b5fb9aeab Martina Krasteva 2021-05-27 148 struct v4l2_ctrl *pclk_ctrl;
45d19b5fb9aeab Martina Krasteva 2021-05-27 149 struct v4l2_ctrl *hblank_ctrl;
45d19b5fb9aeab Martina Krasteva 2021-05-27 150 struct v4l2_ctrl *vblank_ctrl;
45d19b5fb9aeab Martina Krasteva 2021-05-27 151 struct {
45d19b5fb9aeab Martina Krasteva 2021-05-27 152 struct v4l2_ctrl *exp_ctrl;
45d19b5fb9aeab Martina Krasteva 2021-05-27 153 struct v4l2_ctrl *again_ctrl;
45d19b5fb9aeab Martina Krasteva 2021-05-27 154 };
45d19b5fb9aeab Martina Krasteva 2021-05-27 155 u32 vblank;
45d19b5fb9aeab Martina Krasteva 2021-05-27 156 const struct imx335_mode *cur_mode;
45d19b5fb9aeab Martina Krasteva 2021-05-27 157 struct mutex mutex;
45d19b5fb9aeab Martina Krasteva 2021-05-27 158 bool streaming;
45d19b5fb9aeab Martina Krasteva 2021-05-27 @159 };
45d19b5fb9aeab Martina Krasteva 2021-05-27 160
Hi Kieran, On Tue, Oct 10, 2023 at 01:51:23AM +0100, Kieran Bingham wrote: > Provide support for enabling and disabling regulator supplies to control > power to the camera sensor. > > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > --- > drivers/media/i2c/imx335.c | 41 ++++++++++++++++++++++++++++++++++++-- > 1 file changed, 39 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c > index ec729126274b..bf12b9b69fce 100644 > --- a/drivers/media/i2c/imx335.c > +++ b/drivers/media/i2c/imx335.c > @@ -75,6 +75,19 @@ struct imx335_reg_list { > const struct imx335_reg *regs; > }; > > +static const char * const imx335_supply_name[] = { > + /* > + * Turn on the power supplies so that they rise in order of > + * 1.2v,-> 1.8 -> 2.9v This won't happen with regulator_bulk_enable(). Does the spec require this? > + * All power supplies should finish rising within 200ms. > + */ > + "avdd", /* Analog (2.9V) supply */ > + "ovdd", /* Digital I/O (1.8V) supply */ > + "dvdd", /* Digital Core (1.2V) supply */ > +}; > + > +#define IMX335_NUM_SUPPLIES ARRAY_SIZE(imx335_supply_name) > + > /** > * struct imx335_mode - imx335 sensor mode structure > * @width: Frame width > @@ -126,6 +139,8 @@ struct imx335 { > struct v4l2_subdev sd; > struct media_pad pad; > struct gpio_desc *reset_gpio; > + struct regulator_bulk_data supplies[IMX335_NUM_SUPPLIES]; > + > struct clk *inclk; > struct v4l2_ctrl_handler ctrl_handler; > struct v4l2_ctrl *link_freq_ctrl; > @@ -781,6 +796,17 @@ static int imx335_parse_hw_config(struct imx335 *imx335) > return PTR_ERR(imx335->reset_gpio); > } > > + for (i = 0; i < IMX335_NUM_SUPPLIES; i++) > + imx335->supplies[i].supply = imx335_supply_name[i]; > + > + ret = devm_regulator_bulk_get(imx335->dev, > + IMX335_NUM_SUPPLIES, > + imx335->supplies); > + if (ret) { > + dev_err(imx335->dev, "Failed to get regulators\n"); > + return ret; > + } > + > /* Get sensor input clock */ > imx335->inclk = devm_clk_get(imx335->dev, NULL); > if (IS_ERR(imx335->inclk)) { > @@ -859,6 +885,17 @@ static int imx335_power_on(struct device *dev) > struct imx335 *imx335 = to_imx335(sd); > int ret; > > + ret = regulator_bulk_enable(IMX335_NUM_SUPPLIES, > + imx335->supplies); > + if (ret) { > + dev_err(dev, "%s: failed to enable regulators\n", > + __func__); > + return ret; > + } > + > + usleep_range(500, 550); /* Tlow */ You're not handling the error case later on in the function. > + > + /* Set XCLR */ > gpiod_set_value_cansleep(imx335->reset_gpio, 1); > > ret = clk_prepare_enable(imx335->inclk); > @@ -867,7 +904,7 @@ static int imx335_power_on(struct device *dev) > goto error_reset; > } > > - usleep_range(20, 22); > + usleep_range(20, 22); /* T4 */ > > return 0; > > @@ -889,8 +926,8 @@ static int imx335_power_off(struct device *dev) > struct imx335 *imx335 = to_imx335(sd); > > gpiod_set_value_cansleep(imx335->reset_gpio, 0); > - > clk_disable_unprepare(imx335->inclk); > + regulator_bulk_disable(IMX335_NUM_SUPPLIES, imx335->supplies); > > return 0; > }
Hi Kieran, On Wed, Oct 11, 2023 at 10:41:59AM +0100, Kieran Bingham wrote: > Quoting Sakari Ailus (2023-10-10 07:12:08) > > Hi Kieran, > > > > On Tue, Oct 10, 2023 at 01:51:23AM +0100, Kieran Bingham wrote: > > > Provide support for enabling and disabling regulator supplies to control > > > power to the camera sensor. > > > > > > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > > > --- > > > drivers/media/i2c/imx335.c | 41 ++++++++++++++++++++++++++++++++++++-- > > > 1 file changed, 39 insertions(+), 2 deletions(-) > > > > > > diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c > > > index ec729126274b..bf12b9b69fce 100644 > > > --- a/drivers/media/i2c/imx335.c > > > +++ b/drivers/media/i2c/imx335.c > > > @@ -75,6 +75,19 @@ struct imx335_reg_list { > > > const struct imx335_reg *regs; > > > }; > > > > > > +static const char * const imx335_supply_name[] = { > > > + /* > > > + * Turn on the power supplies so that they rise in order of > > > + * 1.2v,-> 1.8 -> 2.9v > > > > This won't happen with regulator_bulk_enable(). Does the spec require this? > > Every camera I've ever seen handles this in hardware. (I know that's not > an excuse as somewhere there could be a device that routes each of these > separately). > > Perhaps I shouldn't have added the comment ;-) But I thought it was > useful while I was working through anyway, and could be important for > other devices indeed. > > The datasheet states: > > ``` > 1. Turn On the power supplies so that the power supplies rise in order > of 1.2 V power supply (DVDD1, DVDD2) → 1.8 V power supply (OVDD) → 2.9 V > power supply (AVDD1, AVDD2). In addition, all power supplies should > finish rising within 200 ms. That's an annoying requirement but I'd presume this to work just fine in practice. The device is reset in any case (as you describe below). Some boards might not wire the reset GPIO though, and then it's when it gets interesting. To literally implement the documented sequence, you should separately enable the regulators one by one. Although I don't object just removing the comment either.
diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c index ec729126274b..bf12b9b69fce 100644 --- a/drivers/media/i2c/imx335.c +++ b/drivers/media/i2c/imx335.c @@ -75,6 +75,19 @@ struct imx335_reg_list { const struct imx335_reg *regs; }; +static const char * const imx335_supply_name[] = { + /* + * Turn on the power supplies so that they rise in order of + * 1.2v,-> 1.8 -> 2.9v + * All power supplies should finish rising within 200ms. + */ + "avdd", /* Analog (2.9V) supply */ + "ovdd", /* Digital I/O (1.8V) supply */ + "dvdd", /* Digital Core (1.2V) supply */ +}; + +#define IMX335_NUM_SUPPLIES ARRAY_SIZE(imx335_supply_name) + /** * struct imx335_mode - imx335 sensor mode structure * @width: Frame width @@ -126,6 +139,8 @@ struct imx335 { struct v4l2_subdev sd; struct media_pad pad; struct gpio_desc *reset_gpio; + struct regulator_bulk_data supplies[IMX335_NUM_SUPPLIES]; + struct clk *inclk; struct v4l2_ctrl_handler ctrl_handler; struct v4l2_ctrl *link_freq_ctrl; @@ -781,6 +796,17 @@ static int imx335_parse_hw_config(struct imx335 *imx335) return PTR_ERR(imx335->reset_gpio); } + for (i = 0; i < IMX335_NUM_SUPPLIES; i++) + imx335->supplies[i].supply = imx335_supply_name[i]; + + ret = devm_regulator_bulk_get(imx335->dev, + IMX335_NUM_SUPPLIES, + imx335->supplies); + if (ret) { + dev_err(imx335->dev, "Failed to get regulators\n"); + return ret; + } + /* Get sensor input clock */ imx335->inclk = devm_clk_get(imx335->dev, NULL); if (IS_ERR(imx335->inclk)) { @@ -859,6 +885,17 @@ static int imx335_power_on(struct device *dev) struct imx335 *imx335 = to_imx335(sd); int ret; + ret = regulator_bulk_enable(IMX335_NUM_SUPPLIES, + imx335->supplies); + if (ret) { + dev_err(dev, "%s: failed to enable regulators\n", + __func__); + return ret; + } + + usleep_range(500, 550); /* Tlow */ + + /* Set XCLR */ gpiod_set_value_cansleep(imx335->reset_gpio, 1); ret = clk_prepare_enable(imx335->inclk); @@ -867,7 +904,7 @@ static int imx335_power_on(struct device *dev) goto error_reset; } - usleep_range(20, 22); + usleep_range(20, 22); /* T4 */ return 0; @@ -889,8 +926,8 @@ static int imx335_power_off(struct device *dev) struct imx335 *imx335 = to_imx335(sd); gpiod_set_value_cansleep(imx335->reset_gpio, 0); - clk_disable_unprepare(imx335->inclk); + regulator_bulk_disable(IMX335_NUM_SUPPLIES, imx335->supplies); return 0; }