Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2315652rdb; Mon, 9 Oct 2023 23:12:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEeGCbpIoKP6qHDT5b4fwYUnaJMWH3+waS0FIrYKG2s9XMMKAEKhzSE2f15DRHwiEwF1lW+ X-Received: by 2002:a05:6a21:a5a7:b0:15d:721e:44d5 with SMTP id gd39-20020a056a21a5a700b0015d721e44d5mr19324887pzc.49.1696918353296; Mon, 09 Oct 2023 23:12:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1696918353; cv=pass; d=google.com; s=arc-20160816; b=x39lyDm94m2/gxdNvBHCghCBMzjL7EBgYLgCVSZlHvy38Z6LDBNPJur7R7lFt0tsb+ tBBFS4fg0lyIQfwqmK44jyaiZ9bRmZFRz1Thz8xxdWtVfc7wWvdKDjBrFndjZ8+HBypQ +pSYuOhz6eUhBq3ZNE7ZaF/G/EHrQge+dEl71V1HMrmHSqifQeWN9Hg8IleX0ipPeeoN aN02zpbtbaJJqB2Ed8g/DSljmvdDY7swNGIkz0UqdOUN/AnBcezTIIFOYC5zNRBfCPO6 avHaIQdy1DPMNsh46GF/JlirEGFP/Vex9/xuHghNhNuaQa2n7Pg7/CwNfgoN64xuWIw+ Z6AA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=XuMIcU8cZvU0jZEP/BNe7LPcBPMAKzlOUZkaZJUYjtI=; fh=Je028qsmlRvA/QUBLP3bIKF+0u8wNUkC41OVsVGh47Y=; b=t/npgw0yu9QeWTTiBmrO95IcXWP4lmDfYC4hKcyEUdB/dbahuhWceRO13Uw/SgvuJm cTR+9U2y/cIsuJ8V0HDKcetIw9nHbUut218ifWatHBkceIZuVo1uh9aPcUstkd4AWWDj K8v7YWeIjt6ZL8ALugC4xVR7ROopyWI+T4ksXZJ785LJu6Vt/KBo6WLXPKrELASxRLxV hIP0M6eLpyer6RkNJ8kSRor+wKFwWB8DZuYhRqPbBGO3p0Gydj2kcnCyUxFKO/77viwZ NzSZ3MbWTJaDJSACtTWOE7XgP7iDpuxhsS02xG9egq521KXjsk9Qtwy5xXeqUIp6PTN9 LUmQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@iki.fi header.s=meesny header.b=NJl5giuU; arc=pass (i=1); 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 Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id j3-20020a170903028300b001c1eed8a336si12015845plr.167.2023.10.09.23.12.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 23:12:33 -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 header.i=@iki.fi header.s=meesny header.b=NJl5giuU; arc=pass (i=1); 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 06AA4811F90C; Mon, 9 Oct 2023 23:12:32 -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 S1442205AbjJJGM2 (ORCPT + 99 others); Tue, 10 Oct 2023 02:12:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442156AbjJJGM1 (ORCPT ); Tue, 10 Oct 2023 02:12:27 -0400 X-Greylist: delayed 347 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 09 Oct 2023 23:12:22 PDT Received: from meesny.iki.fi (meesny.iki.fi [195.140.195.201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26041B0; Mon, 9 Oct 2023 23:12:22 -0700 (PDT) Received: from hillosipuli.retiisi.eu (2a00-1190-d1dd-0-c641-1eff-feae-163d.v6.cust.suomicom.net [IPv6:2a00:1190:d1dd:0:c641:1eff:feae:163d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sailus) by meesny.iki.fi (Postfix) with ESMTPSA id 4S4QXz3C4nzyWn; Tue, 10 Oct 2023 09:12:09 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1696918339; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XuMIcU8cZvU0jZEP/BNe7LPcBPMAKzlOUZkaZJUYjtI=; b=NJl5giuUzCG4Ku92wHfREsnir3US0FQ0HpE+6qjTjfsoW3tP8fuBpFZedO0+9jkxcOD89k htnlWd3aHs/6xBDFSESObrhER1KQ5laaq/hrHe8IrfFWnNs/RDi3J+7m51XDNDcYevhNxM Oay+fyJPJ65uyhE2Hyiv0gL+0byFDnw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1696918339; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XuMIcU8cZvU0jZEP/BNe7LPcBPMAKzlOUZkaZJUYjtI=; b=egiMaw3kzxckyRstS8g7T1uT5eABEm0ZHU5IJ2g4mwK6HAdnR4gnGkA1mMiQfs3Xto2cDO wIYKsxIDcCEBtppuPiN21Tlx6/HpjWu119w6dOoAJcRNI2A2uyWezzHOYdSBydXdoEHpfD 8HsqAlt7hefyQvPHxvzbrGczi+wBTqM= ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=sailus smtp.mailfrom=sakari.ailus@iki.fi ARC-Seal: i=1; s=meesny; d=iki.fi; t=1696918339; a=rsa-sha256; cv=none; b=XSefguaJ+zDIvDnCsD8PE9y8DwNenrZuxp+M04F1rd3jXV7aWhzzsGv9gj1sMxX5bPQCSH 8+GQ/Xf4k8ooDJ1ONGci26litC2xx/PcbTTwWg6r2JwrYdQ8dybt17SE8rrTPoQ9iEA7Hy qMxtwwcd/jLMP3YrVjPjLi1XxYlfoMA= Received: from valkosipuli.retiisi.eu (valkosipuli.localdomain [192.168.4.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by hillosipuli.retiisi.eu (Postfix) with ESMTPS id 0F723634CA9; Tue, 10 Oct 2023 09:12:09 +0300 (EEST) Date: Tue, 10 Oct 2023 06:12:08 +0000 From: Sakari Ailus To: Kieran Bingham Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org, Sakari Ailus , "Paul J. Murphy" , Daniele Alessandrelli , Mauro Carvalho Chehab , open list Subject: Re: [PATCH 2/5] media: i2c: imx335: Enable regulator supplies Message-ID: References: <20231010005126.3425444-1-kieran.bingham@ideasonboard.com> <20231010005126.3425444-3-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231010005126.3425444-3-kieran.bingham@ideasonboard.com> 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_NONE,SPF_PASS 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: 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 23:12:32 -0700 (PDT) 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 > --- > 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; > } -- Regards, Sakari Ailus