devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Benjamin Bara <bbara93@gmail.com>,
	Support Opensource <support.opensource@diasemi.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Lee Jones <lee@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Steve Twiss <stwiss.opensource@diasemi.com>
Cc: DLG-Adam.Thomson.Opensource@dm.renesas.com,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	Benjamin Bara <benjamin.bara@skidata.com>
Subject: Re: [PATCH v2 2/3] regulator: da9063: implement basic XVP setter
Date: Wed, 5 Apr 2023 10:42:30 +0300	[thread overview]
Message-ID: <2ee54bc0-65ee-1aa7-c045-72d92594683e@gmail.com> (raw)
In-Reply-To: <20230403-da9063-disable-unused-v2-2-2f1bd2a2434a@skidata.com>

On 4/5/23 08:29, Benjamin Bara wrote:
> From: Benjamin Bara <benjamin.bara@skidata.com>
> 
> Allow to en- and disable voltage monitoring from the device tree.
> Consider that the da9063 only monitors UV *and* OV together, so both
> must be en- or disabled.
> 
> Signed-off-by: Benjamin Bara <benjamin.bara@skidata.com>
> ---
>   drivers/regulator/da9063-regulator.c | 100 +++++++++++++++++++++++++----------
>   1 file changed, 72 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/regulator/da9063-regulator.c b/drivers/regulator/da9063-regulator.c
> index 1c720fc595b3..000fa0daef18 100644
> --- a/drivers/regulator/da9063-regulator.c
> +++ b/drivers/regulator/da9063-regulator.c
> @@ -207,6 +207,24 @@ static const unsigned int da9063_bmem_bio_merged_limits[] = {
>   	4600000, 4800000, 5000000, 5200000, 5400000, 5600000, 5800000, 6000000
>   };
>   
> +static int da9063_set_xvp(struct regulator_dev *rdev, int lim_uV, int severity, bool enable)
> +{
> +	struct da9063_regulator *regl = rdev_get_drvdata(rdev);
> +	struct device *dev = regl->hw->dev;
> +
> +	dev_dbg(dev, "%s: lim: %d, sev: %d, en: %d\n", regl->desc.name, lim_uV, severity, enable);
> +
> +	/*
> +	 * only support enable and disable.
> +	 * the da9063 offers a GPIO (GP_FB2) which is unasserted if an XV happens.
> +	 * therefore ignore severity here, as there might be handlers in hardware.
> +	 */
> +	if (lim_uV)
> +		return -EINVAL;
> +
> +	return regmap_field_write(regl->vmon, enable ? 1 : 0);
> +}
> +
>   static int da9063_buck_set_mode(struct regulator_dev *rdev, unsigned int mode)
>   {
>   	struct da9063_regulator *regl = rdev_get_drvdata(rdev);
> @@ -545,37 +563,41 @@ static int da9063_buck_get_current_limit(struct regulator_dev *rdev)
>   }
>   
>   static const struct regulator_ops da9063_buck_ops = {
> -	.enable			= regulator_enable_regmap,
> -	.disable		= regulator_disable_regmap,
> -	.is_enabled		= regulator_is_enabled_regmap,
> -	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
> -	.set_voltage_sel	= regulator_set_voltage_sel_regmap,
> -	.list_voltage		= regulator_list_voltage_linear,
> -	.set_current_limit	= da9063_buck_set_current_limit,
> -	.get_current_limit	= da9063_buck_get_current_limit,
> -	.set_mode		= da9063_buck_set_mode,
> -	.get_mode		= da9063_buck_get_mode,
> -	.get_status		= da9063_buck_get_status,
> -	.set_suspend_voltage	= da9063_set_suspend_voltage,
> -	.set_suspend_enable	= da9063_suspend_enable,
> -	.set_suspend_disable	= da9063_suspend_disable,
> -	.set_suspend_mode	= da9063_buck_set_suspend_mode,
> +	.enable				= regulator_enable_regmap,
> +	.disable			= regulator_disable_regmap,
> +	.is_enabled			= regulator_is_enabled_regmap,
> +	.get_voltage_sel		= regulator_get_voltage_sel_regmap,
> +	.set_voltage_sel		= regulator_set_voltage_sel_regmap,
> +	.list_voltage			= regulator_list_voltage_linear,
> +	.set_current_limit		= da9063_buck_set_current_limit,
> +	.get_current_limit		= da9063_buck_get_current_limit,
> +	.set_mode			= da9063_buck_set_mode,
> +	.get_mode			= da9063_buck_get_mode,
> +	.get_status			= da9063_buck_get_status,
> +	.set_suspend_voltage		= da9063_set_suspend_voltage,
> +	.set_suspend_enable		= da9063_suspend_enable,
> +	.set_suspend_disable		= da9063_suspend_disable,
> +	.set_suspend_mode		= da9063_buck_set_suspend_mode,
> +	.set_over_voltage_protection	= da9063_set_xvp,
> +	.set_under_voltage_protection	= da9063_set_xvp,
>   };
>   
>   static const struct regulator_ops da9063_ldo_ops = {
> -	.enable			= regulator_enable_regmap,
> -	.disable		= regulator_disable_regmap,
> -	.is_enabled		= regulator_is_enabled_regmap,
> -	.get_voltage_sel	= regulator_get_voltage_sel_regmap,
> -	.set_voltage_sel	= regulator_set_voltage_sel_regmap,
> -	.list_voltage		= regulator_list_voltage_linear,
> -	.set_mode		= da9063_ldo_set_mode,
> -	.get_mode		= da9063_ldo_get_mode,
> -	.get_status		= da9063_ldo_get_status,
> -	.set_suspend_voltage	= da9063_set_suspend_voltage,
> -	.set_suspend_enable	= da9063_suspend_enable,
> -	.set_suspend_disable	= da9063_suspend_disable,
> -	.set_suspend_mode	= da9063_ldo_set_suspend_mode,
> +	.enable				= regulator_enable_regmap,
> +	.disable			= regulator_disable_regmap,
> +	.is_enabled			= regulator_is_enabled_regmap,
> +	.get_voltage_sel		= regulator_get_voltage_sel_regmap,
> +	.set_voltage_sel		= regulator_set_voltage_sel_regmap,
> +	.list_voltage			= regulator_list_voltage_linear,
> +	.set_mode			= da9063_ldo_set_mode,
> +	.get_mode			= da9063_ldo_get_mode,
> +	.get_status			= da9063_ldo_get_status,
> +	.set_suspend_voltage		= da9063_set_suspend_voltage,
> +	.set_suspend_enable		= da9063_suspend_enable,
> +	.set_suspend_disable		= da9063_suspend_disable,
> +	.set_suspend_mode		= da9063_ldo_set_suspend_mode,
> +	.set_over_voltage_protection	= da9063_set_xvp,
> +	.set_under_voltage_protection	= da9063_set_xvp,
>   };

During my recent visit in the IIO territory I was told to by Jonathan to 
drop the 'pretty indenting' of structs like this. I think this shows 
well why - when longer members are added, it's hard to see from the diff 
what actually changed. So, if you re-spin and unless Mark has another 
opinion, maybe drop the tabs - in my eyes this does not do much for the 
readability.

Well, IMO this is definitely not something that would require a re-spin 
- and it may be others disagree with me on this. So, FWIW:

Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>

Yours,
	-- Matti

-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~


  reply	other threads:[~2023-04-05  7:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-05  5:29 [PATCH v2 0/3] regulator: da9063: disable unused voltage monitors Benjamin Bara
2023-04-05  5:29 ` [PATCH v2 1/3] regulator: da9063: add voltage monitoring registers Benjamin Bara
2023-04-05  7:29   ` Matti Vaittinen
2023-04-05  8:04     ` Benjamin Bara
2023-04-05  5:29 ` [PATCH v2 2/3] regulator: da9063: implement basic XVP setter Benjamin Bara
2023-04-05  7:42   ` Matti Vaittinen [this message]
2023-04-05 10:52   ` Mark Brown
2023-04-05 14:08     ` Benjamin Bara
2023-04-05  5:29 ` [PATCH v2 3/3] dt-bindings: mfd: dlg,da9063: document XVP Benjamin Bara
2023-04-05  5:33   ` Krzysztof Kozlowski
2023-04-05  7:43   ` Matti Vaittinen
2023-04-05 15:30 ` [PATCH v2 0/3] regulator: da9063: disable unused voltage monitors Lee Jones

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=2ee54bc0-65ee-1aa7-c045-72d92594683e@gmail.com \
    --to=mazziesaccount@gmail.com \
    --cc=DLG-Adam.Thomson.Opensource@dm.renesas.com \
    --cc=bbara93@gmail.com \
    --cc=benjamin.bara@skidata.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lee@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=stwiss.opensource@diasemi.com \
    --cc=support.opensource@diasemi.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;
as well as URLs for NNTP newsgroup(s).