From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
To: Kamal Wadhwa <kamal.wadhwa@oss.qualcomm.com>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Vinod Koul <vkoul@kernel.org>
Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 3/4] regulator: qcom-rpmh: readback voltage/bypass/mode/status set during bootup
Date: Wed, 22 Apr 2026 12:54:33 +0200 [thread overview]
Message-ID: <e2095ff8-5d90-4b09-ab09-287822f844d1@oss.qualcomm.com> (raw)
In-Reply-To: <20260420-read-rpmh-v3-v4-3-70c152e6c958@oss.qualcomm.com>
On 4/20/26 5:43 PM, Kamal Wadhwa wrote:
> Currently, during regulator registration, regulator framework sends an
> unnecessary `min-microvolts` request for the rpmh-regulator device. This
> happens because in current design, we do not have a way to readback the
> voltage settings that was set during the bootloader stage.
>
> Fix this by using the rpmh_read() API to read the regulator voltage
> settings done during boot and make it available to regulator framework
> from the very first read after the bootup.
>
> Also use this API to read the status/mode/bypass settings as well. This
> will provide the regulator framework a sense of the initial settings
> done by bootloader and thus preventing any redundents writes for any
> setting post bootup incase the same setting was already applied during
> bootup.
>
> Signed-off-by: Kamal Wadhwa <kamal.wadhwa@oss.qualcomm.com>
> ---
> drivers/regulator/qcom-rpmh-regulator.c | 179 ++++++++++++++++++++++++++++++++
> 1 file changed, 179 insertions(+)
>
> diff --git a/drivers/regulator/qcom-rpmh-regulator.c b/drivers/regulator/qcom-rpmh-regulator.c
> index 85fbf10f74bb3393071bc65681356312f27b7527..1add15d73cac67ad8c0b45aaad6fb2ae9b388180 100644
> --- a/drivers/regulator/qcom-rpmh-regulator.c
> +++ b/drivers/regulator/qcom-rpmh-regulator.c
> @@ -14,6 +14,7 @@
> #include <linux/regulator/driver.h>
> #include <linux/regulator/machine.h>
> #include <linux/regulator/of_regulator.h>
> +#include <linux/bits.h>
Please sort the includes
[...]
> +/**
> + * rpmh_regulator_read_data() - read data from RPMh
> + * @vreg: Pointer to the RPMh regulator
> + * @cmd: Pointer to the RPMh command struct to readback data
> + *
> + * Return: 0 on success, or a negative error number on failure
> + */
> +static int rpmh_regulator_read_data(struct rpmh_vreg *vreg, struct tcs_cmd *cmd)
> +{
> + return rpmh_read(vreg->dev, cmd);
> +}
Since this is a wrapper of a oneliner, perhaps let's just
ctrl-x + ctrl-v it into the usage
[...]
> +static int rpmh_regulator_determine_initial_status(struct rpmh_vreg *vreg)
> +{
> + struct tcs_cmd cmd = {
> + .addr = vreg->addr + RPMH_REGULATOR_REG_ENABLE,
> + };
> + int ret, pmic_mode, mode;
> + int sts = 0;
Drop the initialization, it's always initialized before usage
[...]
> + /*
> + * NOTE: Since BOB4 BYPASS_MODE value = 0 we cannot confirm if that BOB
> + * regulator has been sent into bypass mode by bootloader or if bootloader
> + * just has not requested for any mode voting. Due this limitation, we
> + * must check if the read pmic_mode value is non-zero before comparing it
> + * to bypass mode value. This also is needed to avoid setting BYPASS status
> + * for LDOs which dont support bypass mode, and have the pmic_bypass_mode
> + * uninitialized value as zero in the vreg hw data. For such cases assume
> + * lowest mode/status, if pmic_mode is zero, to allow for mode voting.
> + */
> + if (!pmic_mode) {
> + for (mode = REGULATOR_MODE_STANDBY; mode > REGULATOR_MODE_INVALID; mode >>= 1) {
> + if (vreg->hw_data->pmic_mode_map[mode] >= 0) {
> + vreg->mode = mode;
> + break;
> + }
> + }
> +
> + vreg->status = regulator_mode_to_status(vreg->mode);
> + return 0;
nit: since you did so above, please keep a \n above the return statements
Konrad
next prev parent reply other threads:[~2026-04-22 10:54 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-20 15:43 [PATCH v4 0/4] regulator: qcom-rpmh: Support RPMH address reads and use it for rpmh-regulators Kamal Wadhwa
2026-04-20 15:43 ` [PATCH v4 1/4] soc: qcom: rpmh: Add support to read back resource settings Kamal Wadhwa
2026-04-20 15:43 ` [PATCH v4 2/4] regulator: qcom-rpmh: Fix PMIC5 BOB bypass mode handling Kamal Wadhwa
2026-04-20 15:43 ` [PATCH v4 3/4] regulator: qcom-rpmh: readback voltage/bypass/mode/status set during bootup Kamal Wadhwa
2026-04-21 21:16 ` Mark Brown
2026-04-28 21:33 ` Kamal Wadhwa
2026-04-28 23:15 ` Mark Brown
2026-06-30 22:06 ` Kamal Wadhwa
2026-07-01 12:10 ` Mark Brown
2026-04-22 10:54 ` Konrad Dybcio [this message]
2026-04-23 9:28 ` Kamal Wadhwa
2026-04-20 15:43 ` [PATCH v4 4/4] regulator: qcom-rpmh: Fix coding style issues Kamal Wadhwa
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=e2095ff8-5d90-4b09-ab09-287822f844d1@oss.qualcomm.com \
--to=konrad.dybcio@oss.qualcomm.com \
--cc=andersson@kernel.org \
--cc=broonie@kernel.org \
--cc=kamal.wadhwa@oss.qualcomm.com \
--cc=konradybcio@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vkoul@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