[PATCH v5 2/2] pmdomain: rockchip: Add RK3572 power domains

Heiko Stübner heiko at sntech.de
Thu Nov 19 10:08:19 PST 2026


Hi,

Am Mittwoch, 18. November 2026, 10:11:40 Mitteleuropäische Normalzeit schrieb Cunhao Lu via B4 Relay:
> From: Cunhao Lu <1579567540 at 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 at 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






More information about the Linux-rockchip mailing list