Skip to content

Commit 8b57988

Browse files
cazoustorulf
authored andcommitted
pmdomain: rockchip: Add gating support
Some rockchip SoC need to ungate power domains before their power status can be changed. Each power domain has a gate mask that is set to 1 to ungate it when manipulating power status, then set back to 0 to gate it again. Signed-off-by: Detlev Casanova <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent 4c621d6 commit 8b57988

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

drivers/pmdomain/rockchip/pm-domains.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct rockchip_domain_info {
4646
bool active_wakeup;
4747
int pwr_w_mask;
4848
int req_w_mask;
49+
int clk_ungate_mask;
4950
int mem_status_mask;
5051
int repair_status_mask;
5152
u32 pwr_offset;
@@ -63,6 +64,7 @@ struct rockchip_pmu_info {
6364
u32 chain_status_offset;
6465
u32 mem_status_offset;
6566
u32 repair_status_offset;
67+
u32 clk_ungate_offset;
6668

6769
u32 core_pwrcnt_offset;
6870
u32 gpu_pwrcnt_offset;
@@ -303,6 +305,26 @@ static unsigned int rockchip_pmu_read_ack(struct rockchip_pmu *pmu)
303305
return val;
304306
}
305307

308+
static int rockchip_pmu_ungate_clk(struct rockchip_pm_domain *pd, bool ungate)
309+
{
310+
const struct rockchip_domain_info *pd_info = pd->info;
311+
struct rockchip_pmu *pmu = pd->pmu;
312+
unsigned int val;
313+
int clk_ungate_w_mask = pd_info->clk_ungate_mask << 16;
314+
315+
if (!pd_info->clk_ungate_mask)
316+
return 0;
317+
318+
if (!pmu->info->clk_ungate_offset)
319+
return 0;
320+
321+
val = ungate ? (pd_info->clk_ungate_mask | clk_ungate_w_mask) :
322+
clk_ungate_w_mask;
323+
regmap_write(pmu->regmap, pmu->info->clk_ungate_offset, val);
324+
325+
return 0;
326+
}
327+
306328
static int rockchip_pmu_set_idle_request(struct rockchip_pm_domain *pd,
307329
bool idle)
308330
{
@@ -543,6 +565,8 @@ static int rockchip_pd_power(struct rockchip_pm_domain *pd, bool power_on)
543565
return ret;
544566
}
545567

568+
rockchip_pmu_ungate_clk(pd, true);
569+
546570
if (!power_on) {
547571
rockchip_pmu_save_qos(pd);
548572

@@ -559,6 +583,7 @@ static int rockchip_pd_power(struct rockchip_pm_domain *pd, bool power_on)
559583
rockchip_pmu_restore_qos(pd);
560584
}
561585

586+
rockchip_pmu_ungate_clk(pd, false);
562587
clk_bulk_disable(pd->num_clks, pd->clks);
563588
}
564589

0 commit comments

Comments
 (0)