mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Umang Jain <umang.jain@ideasonboard.com>
To: Kieran Bingham <kieran.bingham@ideasonboard.com>,
	linux-media@vger.kernel.org, devicetree@vger.kernel.org
Cc: 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>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/5] media: i2c: imx335: Enable regulator supplies
Date: Tue, 10 Oct 2023 09:36:45 +0530	[thread overview]
Message-ID: <b9eb03cd-41b3-7d1c-d8c0-fb4fc98af8e1@ideasonboard.com> (raw)
In-Reply-To: <20231010005126.3425444-3-kieran.bingham@ideasonboard.com>

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;
>   }


  reply	other threads:[~2023-10-10  4:07 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20231010005126.3425444-1-kieran.bingham@ideasonboard.com>
2023-10-10  0:51 ` [PATCH 1/5] media: dt-bindings: media: imx335: Add supply bindings Kieran Bingham
2023-10-10  3:53   ` Umang Jain
2023-10-10  5:03   ` Marco Felsch
2023-10-10  6:06   ` Sakari Ailus
     [not found]     ` <169694430967.3973464.6599459439831458834@ping.linuxembedded.co.uk>
2023-10-11 11:01       ` Sakari Ailus
2023-10-10 17:09   ` Rob Herring
2023-10-10  0:51 ` [PATCH 2/5] media: i2c: imx335: Enable regulator supplies Kieran Bingham
2023-10-10  4:06   ` Umang Jain [this message]
2023-10-10  4:10   ` kernel test robot
2023-10-10  6:12   ` Sakari Ailus
     [not found]     ` <169701731909.277971.10840095252716847805@ping.linuxembedded.co.uk>
2023-10-11 11:06       ` Sakari Ailus
2023-10-10  0:51 ` [PATCH 3/5] media: i2c: imx335: Implement get selection API Kieran Bingham
2023-10-10  4:16   ` Umang Jain
2023-10-10  6:14   ` Sakari Ailus
     [not found]     ` <169701831889.277971.6656559808677876108@ping.linuxembedded.co.uk>
2023-10-11 11:12       ` Sakari Ailus
2023-10-10  0:51 ` [PATCH 4/5] media: i2c: imx335: Fix hblank min/max values Kieran Bingham
2023-10-10  4:15   ` Umang Jain
2023-10-10  0:51 ` [PATCH 5/5] media: i2c: imx335: Improve configuration error reporting Kieran Bingham
2023-10-10  3:36   ` Umang Jain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b9eb03cd-41b3-7d1c-d8c0-fb4fc98af8e1@ideasonboard.com \
    --to=umang.jain@ideasonboard.com \
    --cc=daniele.alessandrelli@intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=paul.j.murphy@intel.com \
    --cc=sakari.ailus@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®