mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Christian Kohlschütter" <christian@kohlschutter.com>
To: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Cc: "Robin Murphy" <robin.murphy@arm.com>,
	wens@kernel.org, "Heiko Stübner" <heiko@sntech.de>,
	"Markus Reichl" <m.reichl@fivetechno.de>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	"open list:ARM/Rockchip SoC..."
	<linux-rockchip@lists.infradead.org>,
	"Linux MMC List" <linux-mmc@vger.kernel.org>
Subject: Re: [PATCH] regulator: core: Fix off-on-delay-us for always-on/boot-on regulators
Date: Sun, 17 Jul 2022 13:49:23 +0200	[thread overview]
Message-ID: <96D772F2-16D8-49BD-A438-A827B69DB670@kohlschutter.com> (raw)
In-Reply-To: <2B145293-BAAE-40AE-B408-FCFC4A80E46D@kohlschutter.com>

+CC mmc/rockchip folks

> Am 17.07.2022 um 13:39 schrieb Christian Kohlschütter <christian@kohlschutter.com>:
> 
> This is _somewhat_ related to "[PATCH] regulator: core: Fix off-on-delay-us for always-on/boot-on regulators"
> That other patch is the right solution for my specific problem, and no further fixes are necessary.
> 
> This change fixes an attempted "bandage" solution (adding an "off-on-delay-us") that we had initially tried to no avail.
> While the cleanup not only reduces complexity, it may also prevent future code changes reintroducing the non-delayed cycling after registration.
> 
> from arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi:
> vcc3v0_sd: vcc3v0-sd {
>        compatible = "regulator-fixed";
>        enable-active-high;
>        gpio = <&gpio0 RK_PA1 GPIO_ACTIVE_HIGH>;
>        pinctrl-names = "default";
>        pinctrl-0 = <&sdmmc0_pwr_h>;
>        regulator-always-on; // prevents setting last_off upon registration
>        off-on-delay-us = <500000>; // would not be honored upon regulator_register
>        regulator-min-microvolt = <3000000>;
>        regulator-max-microvolt = <3000000>;
>        regulator-name = "vcc3v0_sd";
>        vin-supply = <&vcc3v3_sys>;
> };
> 
>> Am 17.07.2022 um 13:30 schrieb Christian Kohlschuetter <christian@kohlschuetter.com>:
>> 
>> Regulators marked with "regulator-always-on" or "regulator-boot-on"
>> as well as an "off-on-delay-us", may run into cycling issues that are
>> hard to detect.
>> 
>> This is caused by the "last_off" state not being initialized in this
>> case.
>> 
>> Fix the "last_off" initialization by setting it to the current kernel
>> time upon initialization, regardless of always_on/boot_on state.
>> 
>> Signed-off-by: Christian Kohlschütter <christian@kohlschutter.com>
>> ---
>> drivers/regulator/core.c | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>> 
>> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
>> index c4d844ffad7a..48ed33ad48c8 100644
>> --- a/drivers/regulator/core.c
>> +++ b/drivers/regulator/core.c
>> @@ -1522,6 +1522,9 @@ static int set_machine_constraints(struct regulator_dev *rdev)
>> 		}
>> 	}
>> 
>> +	if (rdev->desc->off_on_delay)
>> +		rdev->last_off = ktime_get();
>> +
>> 	/* If the constraints say the regulator should be on at this point
>> 	 * and we have control then make sure it is enabled.
>> 	 */
>> @@ -1549,8 +1552,6 @@ static int set_machine_constraints(struct regulator_dev *rdev)
>> 
>> 		if (rdev->constraints->always_on)
>> 			rdev->use_count++;
>> -	} else if (rdev->desc->off_on_delay) {
>> -		rdev->last_off = ktime_get();
>> 	}
>> 
>> 	print_constraints(rdev);
>> -- 
>> 2.36.1
>> 
>> 
> 
> 
> 
> -- 
> Dr. Christian Kohlschütter
> 
> 
> 


  reply	other threads:[~2022-07-17 11:49 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-17 11:30 Christian Kohlschuetter
2022-07-17 11:39 ` Christian Kohlschütter
2022-07-17 11:49   ` Christian Kohlschütter [this message]
2022-07-18 12:36 ` Mark Brown
2022-07-18 17:24   ` [PATCH REBASE] " Christian Kohlschuetter
2022-07-19 13:57     ` [PATCH] " Mark Brown
2022-07-19 14:02       ` Christian Kohlschuetter
2022-07-19 14:02     ` [PATCH REBASE] " Christian Kohlschütter
2022-07-19 14:27       ` Mark Brown
2022-07-19 14:29       ` Mark Brown
2022-07-19 18:49         ` Christian Kohlschütter
2022-07-19 19:38           ` Mark Brown
2022-07-19 19:39             ` Christian Kohlschütter
2022-07-19 18:48       ` Mark Brown
2022-07-19 18:54         ` Christian Kohlschütter
2022-07-19 18:48     ` Mark Brown
2022-07-19 18:48 ` [PATCH] " Mark Brown

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=96D772F2-16D8-49BD-A438-A827B69DB670@kohlschutter.com \
    --to=christian@kohlschutter.com \
    --cc=broonie@kernel.org \
    --cc=heiko@sntech.de \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=m.reichl@fivetechno.de \
    --cc=robin.murphy@arm.com \
    --cc=wens@kernel.org \
    /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®