Lines Matching refs:pd
98 static bool rockchip_pmu_domain_is_idle(struct rockchip_pm_domain *pd) in rockchip_pmu_domain_is_idle() argument
100 struct rockchip_pmu *pmu = pd->pmu; in rockchip_pmu_domain_is_idle()
101 const struct rockchip_domain_info *pd_info = pd->info; in rockchip_pmu_domain_is_idle()
108 static int rockchip_pmu_set_idle_request(struct rockchip_pm_domain *pd, in rockchip_pmu_set_idle_request() argument
111 const struct rockchip_domain_info *pd_info = pd->info; in rockchip_pmu_set_idle_request()
112 struct rockchip_pmu *pmu = pd->pmu; in rockchip_pmu_set_idle_request()
127 while (rockchip_pmu_domain_is_idle(pd) != idle) in rockchip_pmu_set_idle_request()
133 static int rockchip_pmu_save_qos(struct rockchip_pm_domain *pd) in rockchip_pmu_save_qos() argument
137 for (i = 0; i < pd->num_qos; i++) { in rockchip_pmu_save_qos()
138 regmap_read(pd->qos_regmap[i], in rockchip_pmu_save_qos()
140 &pd->qos_save_regs[0][i]); in rockchip_pmu_save_qos()
141 regmap_read(pd->qos_regmap[i], in rockchip_pmu_save_qos()
143 &pd->qos_save_regs[1][i]); in rockchip_pmu_save_qos()
144 regmap_read(pd->qos_regmap[i], in rockchip_pmu_save_qos()
146 &pd->qos_save_regs[2][i]); in rockchip_pmu_save_qos()
147 regmap_read(pd->qos_regmap[i], in rockchip_pmu_save_qos()
149 &pd->qos_save_regs[3][i]); in rockchip_pmu_save_qos()
150 regmap_read(pd->qos_regmap[i], in rockchip_pmu_save_qos()
152 &pd->qos_save_regs[4][i]); in rockchip_pmu_save_qos()
157 static int rockchip_pmu_restore_qos(struct rockchip_pm_domain *pd) in rockchip_pmu_restore_qos() argument
161 for (i = 0; i < pd->num_qos; i++) { in rockchip_pmu_restore_qos()
162 regmap_write(pd->qos_regmap[i], in rockchip_pmu_restore_qos()
164 pd->qos_save_regs[0][i]); in rockchip_pmu_restore_qos()
165 regmap_write(pd->qos_regmap[i], in rockchip_pmu_restore_qos()
167 pd->qos_save_regs[1][i]); in rockchip_pmu_restore_qos()
168 regmap_write(pd->qos_regmap[i], in rockchip_pmu_restore_qos()
170 pd->qos_save_regs[2][i]); in rockchip_pmu_restore_qos()
171 regmap_write(pd->qos_regmap[i], in rockchip_pmu_restore_qos()
173 pd->qos_save_regs[3][i]); in rockchip_pmu_restore_qos()
174 regmap_write(pd->qos_regmap[i], in rockchip_pmu_restore_qos()
176 pd->qos_save_regs[4][i]); in rockchip_pmu_restore_qos()
182 static bool rockchip_pmu_domain_is_on(struct rockchip_pm_domain *pd) in rockchip_pmu_domain_is_on() argument
184 struct rockchip_pmu *pmu = pd->pmu; in rockchip_pmu_domain_is_on()
188 if (pd->info->status_mask == 0) in rockchip_pmu_domain_is_on()
189 return !rockchip_pmu_domain_is_idle(pd); in rockchip_pmu_domain_is_on()
194 return !(val & pd->info->status_mask); in rockchip_pmu_domain_is_on()
197 static void rockchip_do_pmu_set_power_domain(struct rockchip_pm_domain *pd, in rockchip_do_pmu_set_power_domain() argument
200 struct rockchip_pmu *pmu = pd->pmu; in rockchip_do_pmu_set_power_domain()
202 if (pd->info->pwr_mask == 0) in rockchip_do_pmu_set_power_domain()
206 pd->info->pwr_mask, on ? 0 : -1U); in rockchip_do_pmu_set_power_domain()
210 while (rockchip_pmu_domain_is_on(pd) != on) in rockchip_do_pmu_set_power_domain()
214 static int rockchip_pd_power(struct rockchip_pm_domain *pd, bool power_on) in rockchip_pd_power() argument
218 mutex_lock(&pd->pmu->mutex); in rockchip_pd_power()
220 if (rockchip_pmu_domain_is_on(pd) != power_on) { in rockchip_pd_power()
221 for (i = 0; i < pd->num_clks; i++) in rockchip_pd_power()
222 clk_enable(pd->clks[i]); in rockchip_pd_power()
225 rockchip_pmu_save_qos(pd); in rockchip_pd_power()
228 rockchip_pmu_set_idle_request(pd, true); in rockchip_pd_power()
231 rockchip_do_pmu_set_power_domain(pd, power_on); in rockchip_pd_power()
235 rockchip_pmu_set_idle_request(pd, false); in rockchip_pd_power()
237 rockchip_pmu_restore_qos(pd); in rockchip_pd_power()
240 for (i = pd->num_clks - 1; i >= 0; i--) in rockchip_pd_power()
241 clk_disable(pd->clks[i]); in rockchip_pd_power()
244 mutex_unlock(&pd->pmu->mutex); in rockchip_pd_power()
250 struct rockchip_pm_domain *pd = to_rockchip_pd(domain); in rockchip_pd_power_on() local
252 return rockchip_pd_power(pd, true); in rockchip_pd_power_on()
257 struct rockchip_pm_domain *pd = to_rockchip_pd(domain); in rockchip_pd_power_off() local
259 return rockchip_pd_power(pd, false); in rockchip_pd_power_off()
303 struct rockchip_pm_domain *pd; in rockchip_active_wakeup() local
306 pd = container_of(genpd, struct rockchip_pm_domain, genpd); in rockchip_active_wakeup()
308 return pd->info->active_wakeup; in rockchip_active_wakeup()
315 struct rockchip_pm_domain *pd; in rockchip_pm_add_one_domain() local
345 pd = devm_kzalloc(pmu->dev, in rockchip_pm_add_one_domain()
346 sizeof(*pd) + clk_cnt * sizeof(pd->clks[0]), in rockchip_pm_add_one_domain()
348 if (!pd) in rockchip_pm_add_one_domain()
351 pd->info = pd_info; in rockchip_pm_add_one_domain()
352 pd->pmu = pmu; in rockchip_pm_add_one_domain()
373 pd->clks[pd->num_clks++] = clk; in rockchip_pm_add_one_domain()
379 pd->num_qos = of_count_phandle_with_args(node, "pm_qos", in rockchip_pm_add_one_domain()
382 if (pd->num_qos > 0) { in rockchip_pm_add_one_domain()
383 pd->qos_regmap = devm_kcalloc(pmu->dev, pd->num_qos, in rockchip_pm_add_one_domain()
384 sizeof(*pd->qos_regmap), in rockchip_pm_add_one_domain()
386 if (!pd->qos_regmap) { in rockchip_pm_add_one_domain()
392 pd->qos_save_regs[j] = devm_kcalloc(pmu->dev, in rockchip_pm_add_one_domain()
393 pd->num_qos, in rockchip_pm_add_one_domain()
396 if (!pd->qos_save_regs[j]) { in rockchip_pm_add_one_domain()
402 for (j = 0; j < pd->num_qos; j++) { in rockchip_pm_add_one_domain()
408 pd->qos_regmap[j] = syscon_node_to_regmap(qos_node); in rockchip_pm_add_one_domain()
409 if (IS_ERR(pd->qos_regmap[j])) { in rockchip_pm_add_one_domain()
418 error = rockchip_pd_power(pd, true); in rockchip_pm_add_one_domain()
426 pd->genpd.name = node->name; in rockchip_pm_add_one_domain()
427 pd->genpd.power_off = rockchip_pd_power_off; in rockchip_pm_add_one_domain()
428 pd->genpd.power_on = rockchip_pd_power_on; in rockchip_pm_add_one_domain()
429 pd->genpd.attach_dev = rockchip_pd_attach_dev; in rockchip_pm_add_one_domain()
430 pd->genpd.detach_dev = rockchip_pd_detach_dev; in rockchip_pm_add_one_domain()
431 pd->genpd.dev_ops.active_wakeup = rockchip_active_wakeup; in rockchip_pm_add_one_domain()
432 pd->genpd.flags = GENPD_FLAG_PM_CLK; in rockchip_pm_add_one_domain()
433 pm_genpd_init(&pd->genpd, NULL, false); in rockchip_pm_add_one_domain()
435 pmu->genpd_data.domains[id] = &pd->genpd; in rockchip_pm_add_one_domain()
440 clk_unprepare(pd->clks[i]); in rockchip_pm_add_one_domain()
441 clk_put(pd->clks[i]); in rockchip_pm_add_one_domain()
446 static void rockchip_pm_remove_one_domain(struct rockchip_pm_domain *pd) in rockchip_pm_remove_one_domain() argument
450 for (i = 0; i < pd->num_clks; i++) { in rockchip_pm_remove_one_domain()
451 clk_unprepare(pd->clks[i]); in rockchip_pm_remove_one_domain()
452 clk_put(pd->clks[i]); in rockchip_pm_remove_one_domain()
456 mutex_lock(&pd->pmu->mutex); in rockchip_pm_remove_one_domain()
457 pd->num_clks = 0; in rockchip_pm_remove_one_domain()
458 mutex_unlock(&pd->pmu->mutex); in rockchip_pm_remove_one_domain()
466 struct rockchip_pm_domain *pd; in rockchip_pm_domain_cleanup() local
472 pd = to_rockchip_pd(genpd); in rockchip_pm_domain_cleanup()
473 rockchip_pm_remove_one_domain(pd); in rockchip_pm_domain_cleanup()