• Home
  • Raw
  • Download

Lines Matching full:pd

134 static bool rockchip_pmu_domain_is_idle(struct rockchip_pm_domain *pd)  in rockchip_pmu_domain_is_idle()  argument
136 struct rockchip_pmu *pmu = pd->pmu; in rockchip_pmu_domain_is_idle()
137 const struct rockchip_domain_info *pd_info = pd->info; in rockchip_pmu_domain_is_idle()
152 static int rockchip_pmu_set_idle_request(struct rockchip_pm_domain *pd, in rockchip_pmu_set_idle_request() argument
155 const struct rockchip_domain_info *pd_info = pd->info; in rockchip_pmu_set_idle_request()
156 struct generic_pm_domain *genpd = &pd->genpd; in rockchip_pmu_set_idle_request()
157 struct rockchip_pmu *pmu = pd->pmu; in rockchip_pmu_set_idle_request()
187 ret = readx_poll_timeout_atomic(rockchip_pmu_domain_is_idle, pd, in rockchip_pmu_set_idle_request()
199 static int rockchip_pmu_save_qos(struct rockchip_pm_domain *pd) in rockchip_pmu_save_qos() argument
203 for (i = 0; i < pd->num_qos; i++) { in rockchip_pmu_save_qos()
204 regmap_read(pd->qos_regmap[i], in rockchip_pmu_save_qos()
206 &pd->qos_save_regs[0][i]); in rockchip_pmu_save_qos()
207 regmap_read(pd->qos_regmap[i], in rockchip_pmu_save_qos()
209 &pd->qos_save_regs[1][i]); in rockchip_pmu_save_qos()
210 regmap_read(pd->qos_regmap[i], in rockchip_pmu_save_qos()
212 &pd->qos_save_regs[2][i]); in rockchip_pmu_save_qos()
213 regmap_read(pd->qos_regmap[i], in rockchip_pmu_save_qos()
215 &pd->qos_save_regs[3][i]); in rockchip_pmu_save_qos()
216 regmap_read(pd->qos_regmap[i], in rockchip_pmu_save_qos()
218 &pd->qos_save_regs[4][i]); in rockchip_pmu_save_qos()
223 static int rockchip_pmu_restore_qos(struct rockchip_pm_domain *pd) in rockchip_pmu_restore_qos() argument
227 for (i = 0; i < pd->num_qos; i++) { in rockchip_pmu_restore_qos()
228 regmap_write(pd->qos_regmap[i], in rockchip_pmu_restore_qos()
230 pd->qos_save_regs[0][i]); in rockchip_pmu_restore_qos()
231 regmap_write(pd->qos_regmap[i], in rockchip_pmu_restore_qos()
233 pd->qos_save_regs[1][i]); in rockchip_pmu_restore_qos()
234 regmap_write(pd->qos_regmap[i], in rockchip_pmu_restore_qos()
236 pd->qos_save_regs[2][i]); in rockchip_pmu_restore_qos()
237 regmap_write(pd->qos_regmap[i], in rockchip_pmu_restore_qos()
239 pd->qos_save_regs[3][i]); in rockchip_pmu_restore_qos()
240 regmap_write(pd->qos_regmap[i], in rockchip_pmu_restore_qos()
242 pd->qos_save_regs[4][i]); in rockchip_pmu_restore_qos()
248 static bool rockchip_pmu_domain_is_on(struct rockchip_pm_domain *pd) in rockchip_pmu_domain_is_on() argument
250 struct rockchip_pmu *pmu = pd->pmu; in rockchip_pmu_domain_is_on()
254 if (pd->info->status_mask == 0) in rockchip_pmu_domain_is_on()
255 return !rockchip_pmu_domain_is_idle(pd); in rockchip_pmu_domain_is_on()
260 return !(val & pd->info->status_mask); in rockchip_pmu_domain_is_on()
263 static void rockchip_do_pmu_set_power_domain(struct rockchip_pm_domain *pd, in rockchip_do_pmu_set_power_domain() argument
266 struct rockchip_pmu *pmu = pd->pmu; in rockchip_do_pmu_set_power_domain()
267 struct generic_pm_domain *genpd = &pd->genpd; in rockchip_do_pmu_set_power_domain()
270 if (pd->info->pwr_mask == 0) in rockchip_do_pmu_set_power_domain()
272 else if (pd->info->pwr_w_mask) in rockchip_do_pmu_set_power_domain()
274 on ? pd->info->pwr_w_mask : in rockchip_do_pmu_set_power_domain()
275 (pd->info->pwr_mask | pd->info->pwr_w_mask)); in rockchip_do_pmu_set_power_domain()
278 pd->info->pwr_mask, on ? 0 : -1U); in rockchip_do_pmu_set_power_domain()
282 if (readx_poll_timeout_atomic(rockchip_pmu_domain_is_on, pd, is_on, in rockchip_do_pmu_set_power_domain()
291 static int rockchip_pd_power(struct rockchip_pm_domain *pd, bool power_on) in rockchip_pd_power() argument
293 struct rockchip_pmu *pmu = pd->pmu; in rockchip_pd_power()
298 if (rockchip_pmu_domain_is_on(pd) != power_on) { in rockchip_pd_power()
299 ret = clk_bulk_enable(pd->num_clks, pd->clks); in rockchip_pd_power()
307 rockchip_pmu_save_qos(pd); in rockchip_pd_power()
310 rockchip_pmu_set_idle_request(pd, true); in rockchip_pd_power()
313 rockchip_do_pmu_set_power_domain(pd, power_on); in rockchip_pd_power()
317 rockchip_pmu_set_idle_request(pd, false); in rockchip_pd_power()
319 rockchip_pmu_restore_qos(pd); in rockchip_pd_power()
322 clk_bulk_disable(pd->num_clks, pd->clks); in rockchip_pd_power()
331 struct rockchip_pm_domain *pd = to_rockchip_pd(domain); in rockchip_pd_power_on() local
333 return rockchip_pd_power(pd, true); in rockchip_pd_power_on()
338 struct rockchip_pm_domain *pd = to_rockchip_pd(domain); in rockchip_pd_power_off() local
340 return rockchip_pd_power(pd, false); in rockchip_pd_power_off()
385 struct rockchip_pm_domain *pd; in rockchip_pm_add_one_domain() local
412 pd = devm_kzalloc(pmu->dev, sizeof(*pd), GFP_KERNEL); in rockchip_pm_add_one_domain()
413 if (!pd) in rockchip_pm_add_one_domain()
416 pd->info = pd_info; in rockchip_pm_add_one_domain()
417 pd->pmu = pmu; in rockchip_pm_add_one_domain()
419 pd->num_clks = of_clk_get_parent_count(node); in rockchip_pm_add_one_domain()
420 if (pd->num_clks > 0) { in rockchip_pm_add_one_domain()
421 pd->clks = devm_kcalloc(pmu->dev, pd->num_clks, in rockchip_pm_add_one_domain()
422 sizeof(*pd->clks), GFP_KERNEL); in rockchip_pm_add_one_domain()
423 if (!pd->clks) in rockchip_pm_add_one_domain()
427 node, pd->num_clks); in rockchip_pm_add_one_domain()
428 pd->num_clks = 0; in rockchip_pm_add_one_domain()
431 for (i = 0; i < pd->num_clks; i++) { in rockchip_pm_add_one_domain()
432 pd->clks[i].clk = of_clk_get(node, i); in rockchip_pm_add_one_domain()
433 if (IS_ERR(pd->clks[i].clk)) { in rockchip_pm_add_one_domain()
434 error = PTR_ERR(pd->clks[i].clk); in rockchip_pm_add_one_domain()
442 error = clk_bulk_prepare(pd->num_clks, pd->clks); in rockchip_pm_add_one_domain()
446 pd->num_qos = of_count_phandle_with_args(node, "pm_qos", in rockchip_pm_add_one_domain()
449 if (pd->num_qos > 0) { in rockchip_pm_add_one_domain()
450 pd->qos_regmap = devm_kcalloc(pmu->dev, pd->num_qos, in rockchip_pm_add_one_domain()
451 sizeof(*pd->qos_regmap), in rockchip_pm_add_one_domain()
453 if (!pd->qos_regmap) { in rockchip_pm_add_one_domain()
459 pd->qos_save_regs[j] = devm_kcalloc(pmu->dev, in rockchip_pm_add_one_domain()
460 pd->num_qos, in rockchip_pm_add_one_domain()
463 if (!pd->qos_save_regs[j]) { in rockchip_pm_add_one_domain()
469 for (j = 0; j < pd->num_qos; j++) { in rockchip_pm_add_one_domain()
475 pd->qos_regmap[j] = syscon_node_to_regmap(qos_node); in rockchip_pm_add_one_domain()
476 if (IS_ERR(pd->qos_regmap[j])) { in rockchip_pm_add_one_domain()
485 error = rockchip_pd_power(pd, true); in rockchip_pm_add_one_domain()
493 pd->genpd.name = node->name; in rockchip_pm_add_one_domain()
494 pd->genpd.power_off = rockchip_pd_power_off; in rockchip_pm_add_one_domain()
495 pd->genpd.power_on = rockchip_pd_power_on; in rockchip_pm_add_one_domain()
496 pd->genpd.attach_dev = rockchip_pd_attach_dev; in rockchip_pm_add_one_domain()
497 pd->genpd.detach_dev = rockchip_pd_detach_dev; in rockchip_pm_add_one_domain()
498 pd->genpd.flags = GENPD_FLAG_PM_CLK; in rockchip_pm_add_one_domain()
500 pd->genpd.flags |= GENPD_FLAG_ACTIVE_WAKEUP; in rockchip_pm_add_one_domain()
501 pm_genpd_init(&pd->genpd, NULL, false); in rockchip_pm_add_one_domain()
503 pmu->genpd_data.domains[id] = &pd->genpd; in rockchip_pm_add_one_domain()
507 clk_bulk_unprepare(pd->num_clks, pd->clks); in rockchip_pm_add_one_domain()
509 clk_bulk_put(pd->num_clks, pd->clks); in rockchip_pm_add_one_domain()
513 static void rockchip_pm_remove_one_domain(struct rockchip_pm_domain *pd) in rockchip_pm_remove_one_domain() argument
521 ret = pm_genpd_remove(&pd->genpd); in rockchip_pm_remove_one_domain()
523 dev_err(pd->pmu->dev, "failed to remove domain '%s' : %d - state may be inconsistent\n", in rockchip_pm_remove_one_domain()
524 pd->genpd.name, ret); in rockchip_pm_remove_one_domain()
526 clk_bulk_unprepare(pd->num_clks, pd->clks); in rockchip_pm_remove_one_domain()
527 clk_bulk_put(pd->num_clks, pd->clks); in rockchip_pm_remove_one_domain()
530 mutex_lock(&pd->pmu->mutex); in rockchip_pm_remove_one_domain()
531 pd->num_clks = 0; in rockchip_pm_remove_one_domain()
532 mutex_unlock(&pd->pmu->mutex); in rockchip_pm_remove_one_domain()
540 struct rockchip_pm_domain *pd; in rockchip_pm_domain_cleanup() local
546 pd = to_rockchip_pd(genpd); in rockchip_pm_domain_cleanup()
547 rockchip_pm_remove_one_domain(pd); in rockchip_pm_domain_cleanup()