Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp915554rdb; Wed, 1 Nov 2023 06:34:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFhvkGJhAK0o/CGI7//1UD/qlmWg4F16VSQYoP2k8bXznmfwkF+I9If4Y1alCDGmiqxgdGq X-Received: by 2002:a05:6a20:1590:b0:15e:a653:fed5 with SMTP id h16-20020a056a20159000b0015ea653fed5mr19371943pzj.16.1698845680394; Wed, 01 Nov 2023 06:34:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698845680; cv=none; d=google.com; s=arc-20160816; b=EBAyndUmr4W7netspCPD90OQAWvj6yDISmmG1eLy6Cr0Fa474lwdvXpmev3f79brB3 W7IqJ/Nx617BwG4br60hFP8FgZm+0nVocmYT5ykwSIT6NYFznuFDwy2SdnvwtGuURs3C Fgfb50UcyBaLRA80gep2sE7LKpURzv0k1gkDDbjBbNOrw3e9igiO4AaKFNb012BYyEwX 9tict0nBPTZGQOIeuWM/fxO9ZS/8fQTyk/wVyLTJYA0ZYWTVrnyLhYde045KXuG58YLY ruex7TDxp0g7vPcxs5DY5Qp9Ngnv7stY8gnJ91XOH2v/Uu4l6m4F0ubbAVxVQWypa6zn CLpg== ARC-Message-Signature: i=1; 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=Z8R2ImfFLu0BbF3mZq+PzEU3tNq7tJWn6nuG3ikbDMo=; fh=OXuy776hihhZL4pMI8il+lOnYR/uAghWp68HeOEVdE4=; b=s6sKljXnqVrM5g8xO5ZpqZdhyXW+3Rh0gjIjv8/guf/VVkDPzR5/9HyPgDdZwOJKd/ wgniyp6E26rWXXITzb8smifNDOoMBSkss+CkTEQX3QdHATMJL/GCzvbxSeQZRLmjVvVL wtYEsunIxv/EXnBYD6J/sAt5ukxUcQpzALlkbM020XKi6JKKoVA3w/9/mYkODIikUTLR EtXNXebgBK3WNeCwk9xslMdcEjJ5Qn/iN6uNCDo1u9RdxlOVHEFxKe3j2KUKVV07yKYO ArzGWB5FGHbeIBzc20Z8mBgRASg3uowP9ls0V4H2UCsN/SFF7fjYy17nltZanoFV8e4j Hskg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ma+noyr4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id c12-20020a170902724c00b001ca24970584si2938790pll.572.2023.11.01.06.34.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 06:34:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ma+noyr4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id DCFD480A4AE8; Wed, 1 Nov 2023 06:34:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344290AbjKANdg (ORCPT + 99 others); Wed, 1 Nov 2023 09:33:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344162AbjKANdf (ORCPT ); Wed, 1 Nov 2023 09:33:35 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DC96F7; Wed, 1 Nov 2023 06:33:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698845607; x=1730381607; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=TLfikYcSzIKUF7Psef+fS9e6czzFkIgyby047PInD7c=; b=Ma+noyr4+ky2IkD6gSL/5CIjCqbwfCyflzPvmKn/Be9H5MjoYWPagBio HI201hb5Vpm/Mrf4r9EaIm5WysbE8pbA8Y7RgiEPtGJUAprDPlIL/X0R0 MijUrogG1x1BD5beNEd+vIswKlCdwOaS/xX7XV6ECTTf9EritBMGLOb1K 2+LS9iKZ6fPweLlyiW2Ue5tvhKobwMmz0dbbsSfUDKCpvvUGijD7iINAs UhY5l2Chv7y41d/+n/WfjRTLl54RUWaJUDfcgviFmDIu+NMEhiZG64mgc CZKkU5swfOIAl8N64CnHtG2VlD13C8ah1oBpTtvYuYOGiECGTSEchihmO Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10880"; a="391359976" X-IronPort-AV: E=Sophos;i="6.03,268,1694761200"; d="scan'208";a="391359976" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 06:33:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10880"; a="790114629" X-IronPort-AV: E=Sophos;i="6.03,268,1694761200"; d="scan'208";a="790114629" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 06:33:23 -0700 Received: from kekkonen.localdomain (localhost [127.0.0.1]) by kekkonen.fi.intel.com (Postfix) with SMTP id 48DB41207A3; Wed, 1 Nov 2023 15:33:22 +0200 (EET) Date: Wed, 1 Nov 2023 13:33:22 +0000 From: Sakari Ailus To: Kieran Bingham Cc: devicetree@vger.kernel.org, linux-media@vger.kernel.org, "Paul J. Murphy" , Daniele Alessandrelli , Mauro Carvalho Chehab , open list Subject: Re: [PATCH v2 4/6] media: i2c: imx335: Enable regulator supplies Message-ID: References: <20231101131354.2333498-1-kieran.bingham@ideasonboard.com> <20231101131354.2333498-5-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231101131354.2333498-5-kieran.bingham@ideasonboard.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email 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 (fry.vger.email [0.0.0.0]); Wed, 01 Nov 2023 06:34:35 -0700 (PDT) Hi Kieran, Thanks for the set. On Wed, Nov 01, 2023 at 01:13:52PM +0000, Kieran Bingham wrote: > Provide support for enabling and disabling regulator supplies to control > power to the camera sensor. > > While updating the power on function, document that a sleep is > represented as 'T4' in the datasheet power on sequence. > > Signed-off-by: Kieran Bingham > > --- > > v2: > - document 'supplies' member variable > - disable regulators in error path > - Remove 'unhelpful' comments > Signed-off-by: Kieran Bingham > --- > drivers/media/i2c/imx335.c | 38 ++++++++++++++++++++++++++++++++++++-- > 1 file changed, 36 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c > index 31c612c6bdd8..f17ce40b9c77 100644 > --- a/drivers/media/i2c/imx335.c > +++ b/drivers/media/i2c/imx335.c > @@ -75,6 +75,14 @@ struct imx335_reg_list { > const struct imx335_reg *regs; > }; > > +static const char * const imx335_supply_name[] = { > + "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) Please use plain ARRAY_SIZE() where you needed this. > + > /** > * struct imx335_mode - imx335 sensor mode structure > * @width: Frame width > @@ -108,6 +116,7 @@ struct imx335_mode { > * @sd: V4L2 sub-device > * @pad: Media pad. Only one pad supported > * @reset_gpio: Sensor reset gpio > + * @supplies: Regulator supplies to handle power control > * @inclk: Sensor input clock > * @ctrl_handler: V4L2 control handler > * @link_freq_ctrl: Pointer to link frequency control > @@ -126,6 +135,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 +792,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)) { > @@ -863,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); > @@ -871,12 +904,13 @@ static int imx335_power_on(struct device *dev) > goto error_reset; > } > > - usleep_range(20, 22); > + usleep_range(20, 22); /* T4 */ > > return 0; > > error_reset: > gpiod_set_value_cansleep(imx335->reset_gpio, 0); > + regulator_bulk_disable(IMX335_NUM_SUPPLIES, imx335->supplies); > > return ret; > } > @@ -893,8 +927,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