Add pm domains support for RK3528 SoCs. Code based on BSP by Signed-off-by: Finley Xiao diff --speed-large-files --no-dereference --minimal -Naur linux-6.4.11/drivers/soc/rockchip/pm_domains.c linux-6.4.11/drivers/soc/rockchip/pm_domains.c --- linux-6.4.11/drivers/soc/rockchip/pm_domains.c 2023-08-18 11:48:09.863344579 +0200 +++ linux-6.4.11/drivers/soc/rockchip/pm_domains.c 2023-08-18 11:41:40.283343244 +0200 @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -46,6 +47,8 @@ int repair_status_mask; u32 pwr_offset; u32 req_offset; + bool keepon_startup; + bool always_on; }; struct rockchip_pmu_info { @@ -119,6 +122,20 @@ .active_wakeup = wakeup, \ } +#define DOMAIN_M_A(pwr, status, req, idle, ack, always, wakeup, keepon) \ +{ \ + .pwr_w_mask = (pwr) << 16, \ + .pwr_mask = (pwr), \ + .status_mask = (status), \ + .req_w_mask = (req) << 16, \ + .req_mask = (req), \ + .idle_mask = (idle), \ + .ack_mask = (ack), \ + .always_on = always, \ + .active_wakeup = wakeup, \ + .keepon_startup = keepon, \ +} + #define DOMAIN_M_O_R(_name, p_offset, pwr, status, r_status, r_offset, req, idle, ack, wakeup) \ { \ .name = _name, \ @@ -163,6 +180,9 @@ #define DOMAIN_RK3399(name, pwr, status, req, wakeup) \ DOMAIN(name, pwr, status, req, req, req, wakeup) +#define DOMAIN_RK3528(pwr, req, always, wakeup) \ + DOMAIN_M_A(pwr, pwr, req, req, req, always, wakeup, false) + #define DOMAIN_RK3568(name, pwr, req, wakeup) \ DOMAIN_M(name, pwr, pwr, req, req, req, wakeup) @@ -1034,6 +1054,18 @@ [RK3399_PD_SDIOAUDIO] = DOMAIN_RK3399("sdioaudio", BIT(31), BIT(31), BIT(29), true), }; +static const struct rockchip_domain_info rk3528_pm_domains[] = { + [RK3528_PD_PMU] = DOMAIN_RK3528(0, BIT(0), true, false), + [RK3528_PD_BUS] = DOMAIN_RK3528(0, BIT(1), true, false), + [RK3528_PD_DDR] = DOMAIN_RK3528(0, BIT(2), true, false), + [RK3528_PD_MSCH] = DOMAIN_RK3528(0, BIT(3), true, false), + [RK3528_PD_GPU] = DOMAIN_RK3528(BIT(0), BIT(4), true, false), + [RK3528_PD_RKVDEC] = DOMAIN_RK3528(0, BIT(5), true, false), + [RK3528_PD_RKVENC] = DOMAIN_RK3528(0, BIT(6), true, false), + [RK3528_PD_VO] = DOMAIN_RK3528(0, BIT(7), true, false), + [RK3528_PD_VPU] = DOMAIN_RK3528(0, BIT(8), true, false), +}; + static const struct rockchip_domain_info rk3568_pm_domains[] = { [RK3568_PD_NPU] = DOMAIN_RK3568("npu", BIT(1), BIT(2), false), [RK3568_PD_GPU] = DOMAIN_RK3568("gpu", BIT(0), BIT(1), false), @@ -1213,6 +1245,17 @@ .domain_info = rk3399_pm_domains, }; +static const struct rockchip_pmu_info rk3528_pmu = { + .pwr_offset = 0x1210, + .status_offset = 0x1230, + .req_offset = 0x1110, + .idle_offset = 0x1128, + .ack_offset = 0x1120, + + .num_domains = ARRAY_SIZE(rk3528_pm_domains), + .domain_info = rk3528_pm_domains, +}; + static const struct rockchip_pmu_info rk3568_pmu = { .pwr_offset = 0xa0, .status_offset = 0x98, @@ -1293,6 +1336,10 @@ .data = (void *)&rk3399_pmu, }, { + .compatible = "rockchip,rk3528-power-controller", + .data = (void *)&rk3528_pmu, + }, + { .compatible = "rockchip,rk3568-power-controller", .data = (void *)&rk3568_pmu, },