mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Benjamin Bara <bbara93@gmail.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	support.opensource@diasemi.com
Cc: DLG-Adam.Ward.opensource@dm.renesas.com,
	linux-kernel@vger.kernel.org,
	Benjamin Bara <benjamin.bara@skidata.com>
Subject: Re: [PATCH RFC v2 1/2] regulator: add properties to disable monitoring on actions
Date: Mon, 24 Apr 2023 16:30:35 +0300	[thread overview]
Message-ID: <244225d6-5391-9f31-5065-c44318d7e235@gmail.com> (raw)
In-Reply-To: <20230419-dynamic-vmon-v2-1-c303bcc75ebc@skidata.com>

On 4/21/23 12:13, Benjamin Bara wrote:
> From: Benjamin Bara <benjamin.bara@skidata.com>
> 
> These are useful when the state of the regulator might change during
> runtime, but the monitors state (in hardware) are not implicitly changed
> with the change of the regulator state or mode (in hardware). Also, when
> the monitors should be disabled while ramping after a set_value().
> 
> Signed-off-by: Benjamin Bara <benjamin.bara@skidata.com>
> ---
>   drivers/regulator/core.c         | 64 ++++++++++++++++++++++++++++++++++++----
>   include/linux/regulator/driver.h | 10 +++++++
>   2 files changed, 68 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> index 4fcd36055b02..5052e1da85a7 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
> @@ -1360,7 +1360,7 @@ static int notif_set_limit(struct regulator_dev *rdev,
>   
>   static int handle_notify_limits(struct regulator_dev *rdev,
>   			int (*set)(struct regulator_dev *, int, int, bool),
> -			struct notification_limit *limits)
> +			const struct notification_limit *limits)
>   {
>   	int ret = 0;
>   
> @@ -1385,6 +1385,29 @@ static int handle_notify_limits(struct regulator_dev *rdev,
>   
>   	return ret;
>   }
> +
> +static const struct notification_limit disable_limits = {
> +	.prot = REGULATOR_NOTIF_LIMIT_DISABLE,
> +	.err = REGULATOR_NOTIF_LIMIT_DISABLE,
> +	.warn = REGULATOR_NOTIF_LIMIT_DISABLE,
> +};
> +
> +static int monitors_set_state(struct regulator_dev *rdev, bool enable)
> +{
> +	const struct regulation_constraints *reg_c = rdev->constraints;
> +	const struct regulator_ops *ops = rdev->desc->ops;
> +	int ret = 0;
> +
> +	/* only set the state if monitoring is activated in the device-tree. */
> +	if (reg_c->over_voltage_detection)
> +		ret = handle_notify_limits(rdev, ops->set_over_voltage_protection,
> +					   enable ? &reg_c->over_voltage_limits : &disable_limits);
> +	if (!ret && reg_c->under_voltage_detection)
> +		ret = handle_notify_limits(rdev, ops->set_under_voltage_protection,
> +					   enable ? &reg_c->under_voltage_limits : &disable_limits);

I still think forcing the use of the set_over_voltage_protection() / 
set_under_voltage_protection() (and omitting over-current protection) 
instead of allowing the driver to populate potentially more suitable 
callbacks is somewhat limiting.

For example, the only _in-tree_ regulator driver that I know is 
disabling monitors at voltage change is the bd718x7. There we have extra 
conditions for disabling - the power must be enabled (which could 
probably be a generic condition for disabling monitoring at voltage 
change), and also the new voltage must be greater than the old voltage. 
This logic is naturally implemented in set_under_voltage_protection - 
which should unconditionally disable the monitoring if it is requested 
via device-tree.

After that being said - I am leaving weighing pros and cons to You and 
Mark - I don't feel I am in a position where I should dictate the design 
here. I'll just say that if the new generic disabling unconditionally 
uses set_under_voltage_protection - then at least the bd718x7 can not 
benefit from it w/o relaxing the monitoring.

Finally, thanks Benjamin for improving things here!

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-24 13:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-21  9:13 [PATCH RFC v2 0/2] regulator: dynamic voltage monitoring support Benjamin Bara
2023-04-21  9:13 ` [PATCH RFC v2 1/2] regulator: add properties to disable monitoring on actions Benjamin Bara
2023-04-24 13:30   ` Matti Vaittinen [this message]
2023-04-21  9:13 ` [PATCH RFC v2 2/2] regulator: da9063: disable monitoring while regulator is off Benjamin Bara

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=244225d6-5391-9f31-5065-c44318d7e235@gmail.com \
    --to=mazziesaccount@gmail.com \
    --cc=DLG-Adam.Ward.opensource@dm.renesas.com \
    --cc=bbara93@gmail.com \
    --cc=benjamin.bara@skidata.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®