From: "Heiko Stübner" <heiko@sntech.de>
To: Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Elaine Zhang <zhangqing@rock-chips.com>,
Ulf Hansson <ulfh@kernel.org>,
1579567540@qq.com
Cc: Cunhao Lu <1579567540@qq.com>,
devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-pm@vger.kernel.org,
Sebastian Reichel <sebastian.reichel@collabora.com>
Subject: Re: [PATCH v5 2/2] pmdomain: rockchip: Add RK3572 power domains
Date: Thu, 19 Nov 2026 19:08:19 +0100 [thread overview]
Message-ID: <z4ZFdDPMSaWK2zh19ZM7pA@sntech.de> (raw)
In-Reply-To: <20261118-add-board-ok3572-c-pmdomain-v5-2-f1af919dd434@qq.com>
Hi,
Am Mittwoch, 18. November 2026, 10:11:40 Mitteleuropäische Normalzeit schrieb Cunhao Lu via B4 Relay:
> From: Cunhao Lu <1579567540@qq.com>
>
> Add the RK3572 PMU register layout and all 14 power domains, including
> bus idle requests, memory power controls and firmware shift-ready checks.
> Control the NPU voltage domain around power transitions. Keep boot-enabled
> IMG, VOP, VOP_PRE and VO domains powered until genpd releases startup
> protection after their consumers have probed.
>
> Signed-off-by: Cunhao Lu <1579567540@qq.com>
There are a bunch of smaller issues below, but I guess my biggest question
is around the voltage-domain stuff.
I guess the first question is, why do you need that?
The TRMs of both RK3572 and RK3588 have the voltage-domain power-control
registers, but why do you need to control them now?
Side-question, how are voltage-domains handled on the other SoCs.
The RK3588 also has the PMU_VOL_GATE_CONx registers, so I guess
they could also be turned off?
But in general, if you need to enable the voltage-domain to enable the
power-domain inside it, this really sounds more like a power-domain of
a different type - because the wiggling inside the power-domain
handling below looks strange, and we already are handling domain
trees.
> @@ -377,15 +417,16 @@ static bool rockchip_pmu_domain_is_idle(struct rockchip_pm_domain *pd)
> const struct rockchip_domain_info *pd_info = pd->info;
> unsigned int val;
>
> - regmap_read(pmu->regmap, pmu->info->idle_offset, &val);
> + regmap_read(pmu->regmap, pmu->info->idle_offset + pd_info->status_offset, &val);
> return (val & pd_info->idle_mask) == pd_info->idle_mask;
> }
>
> -static unsigned int rockchip_pmu_read_ack(struct rockchip_pmu *pmu)
> +static unsigned int rockchip_pmu_read_ack(struct rockchip_pm_domain *pd)
> {
> + struct rockchip_pmu *pmu = pd->pmu;
> unsigned int val;
>
> - regmap_read(pmu->regmap, pmu->info->ack_offset, &val);
> + regmap_read(pmu->regmap, pmu->info->ack_offset + pd->info->status_offset, &val);
> return val;
> }
>
> @@ -394,7 +435,7 @@ static int rockchip_pmu_ungate_clk(struct rockchip_pm_domain *pd, bool ungate)
> const struct rockchip_domain_info *pd_info = pd->info;
> struct rockchip_pmu *pmu = pd->pmu;
> unsigned int val;
> - int clk_ungate_w_mask = pd_info->clk_ungate_mask << 16;
> + u32 clk_ungate_w_mask = (u32)pd_info->clk_ungate_mask << 16;
why does it need to be u32 now?
Yes, the mask should probably be u32, but why not change simply change
the global type then?
>
> if (!pd_info->clk_ungate_mask)
> return 0;
> @@ -404,7 +445,8 @@ static int rockchip_pmu_ungate_clk(struct rockchip_pm_domain *pd, bool ungate)
>
> val = ungate ? (pd_info->clk_ungate_mask | clk_ungate_w_mask) :
> clk_ungate_w_mask;
> - regmap_write(pmu->regmap, pmu->info->clk_ungate_offset, val);
> + regmap_write(pmu->regmap,
> + pmu->info->clk_ungate_offset + pd_info->clk_ungate_offset, val);
both the clk_ungate_offset + status_offset addition should probably be
separate patches, as they should get a descriptive commit message on
why they are needed.
As this then also includes the changes to rockchip_pmu_set_idle_request()
and rockchip_pmu_read_ack (pmu -> pd parameter change), this would also
bring this diff down a lot :-)
I assume the reason is that Rockchip engineers again sprinkled necessary
information bits in even more random places.
>
> return 0;
> }
> @@ -433,9 +475,8 @@ static int rockchip_pmu_set_idle_request(struct rockchip_pm_domain *pd,
>
> wmb();
>
> - /* Wait util idle_ack = 1 */
> target_ack = idle ? pd_info->ack_mask : 0;
> - ret = readx_poll_timeout_atomic(rockchip_pmu_read_ack, pmu, val,
> + ret = readx_poll_timeout_atomic(rockchip_pmu_read_ack, pd, val,
> (val & pd_info->ack_mask) == target_ack,
> 0, 10000);
> if (ret) {
> @@ -547,6 +588,9 @@ static bool rockchip_pmu_domain_is_chain_on(struct rockchip_pm_domain *pd)
> regmap_read(pmu->regmap,
> pmu->info->chain_status_offset + pd->info->mem_offset, &val);
>
> + if (pmu->info->chain_status_inverted)
> + return !(val & pd->info->mem_status_mask);
> +
again, introducing this new parameter should get its own commit and
descriptive message on what this does.
> /* 1'b1: power on, 1'b0: power off */
> return val & pd->info->mem_status_mask;
> }
> @@ -671,9 +715,37 @@ static void rockchip_pd_power_on_rollback(struct rockchip_pm_domain *pd)
> pd->genpd.name, ret);
> }
>
> +static void rockchip_pmu_vd_on(struct rockchip_pm_domain *pd, bool on)
> +{
> + const struct rockchip_domain_info *pd_info = pd->info;
> + struct rockchip_pmu *pmu = pd->pmu;
> + unsigned int val;
> +
> + if (!pd_info->vd_en)
> + return;
> +
> + val = on ? pd_info->pwr_w_mask : pd_info->pwr_mask | pd_info->pwr_w_mask;
> + regmap_write(pmu->regmap, pmu->info->vd_offset + pd_info->pwr_offset, val);
> +}
> +
> +static int rockchip_pmu_wait_fw_shift_ready(struct rockchip_pm_domain *pd)
> +{
> + struct rockchip_pmu *pmu = pd->pmu;
> + u32 mask = pd->info->fw_mask;
> + unsigned int val;
> +
> + if (!mask)
> + return 0;
> +
> + return regmap_read_poll_timeout(pmu->grf, pmu->info->fw_status_offset,
> + val, (val & mask) == mask, 0, 10000);
> +}
this definitly also needs way more explanation
prev parent reply other threads:[~2026-11-19 18:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 9:11 [PATCH v5 0/2] pmdomain: rockchip: Add RK3572 power domains Cunhao Lu via B4 Relay
2026-11-18 9:11 ` [PATCH v5 1/2] dt-bindings: power: " Cunhao Lu via B4 Relay
2026-11-19 12:26 ` Heiko Stübner
2026-11-18 9:11 ` [PATCH v5 2/2] pmdomain: " Cunhao Lu via B4 Relay
2026-11-19 18:08 ` Heiko Stübner [this message]
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=z4ZFdDPMSaWK2zh19ZM7pA@sntech.de \
--to=heiko@sntech.de \
--cc=1579567540@qq.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=robh@kernel.org \
--cc=sebastian.reichel@collabora.com \
--cc=ulfh@kernel.org \
--cc=zhangqing@rock-chips.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