Lines Matching full:pd
196 struct rockchip_pm_domain *pd; in rockchip_pmu_block() local
226 pd = to_rockchip_pd(genpd); in rockchip_pmu_block()
227 ret = clk_bulk_enable(pd->num_clks, pd->clks); in rockchip_pmu_block()
243 pd = to_rockchip_pd(genpd); in rockchip_pmu_block()
244 clk_bulk_disable(pd->num_clks, pd->clks); in rockchip_pmu_block()
259 struct rockchip_pm_domain *pd; in rockchip_pmu_unblock() local
267 pd = to_rockchip_pd(genpd); in rockchip_pmu_unblock()
268 clk_bulk_disable(pd->num_clks, pd->clks); in rockchip_pmu_unblock()
282 static bool rockchip_pmu_domain_is_idle(struct rockchip_pm_domain *pd) in rockchip_pmu_domain_is_idle() argument
284 struct rockchip_pmu *pmu = pd->pmu; in rockchip_pmu_domain_is_idle()
285 const struct rockchip_domain_info *pd_info = pd->info; in rockchip_pmu_domain_is_idle()
300 static int rockchip_pmu_set_idle_request(struct rockchip_pm_domain *pd, in rockchip_pmu_set_idle_request() argument
303 const struct rockchip_domain_info *pd_info = pd->info; in rockchip_pmu_set_idle_request()
304 struct generic_pm_domain *genpd = &pd->genpd; in rockchip_pmu_set_idle_request()
305 struct rockchip_pmu *pmu = pd->pmu; in rockchip_pmu_set_idle_request()
336 ret = readx_poll_timeout_atomic(rockchip_pmu_domain_is_idle, pd, in rockchip_pmu_set_idle_request()
348 static int rockchip_pmu_save_qos(struct rockchip_pm_domain *pd) in rockchip_pmu_save_qos() argument
352 for (i = 0; i < pd->num_qos; i++) { in rockchip_pmu_save_qos()
353 regmap_read(pd->qos_regmap[i], in rockchip_pmu_save_qos()
355 &pd->qos_save_regs[0][i]); in rockchip_pmu_save_qos()
356 regmap_read(pd->qos_regmap[i], in rockchip_pmu_save_qos()
358 &pd->qos_save_regs[1][i]); in rockchip_pmu_save_qos()
359 regmap_read(pd->qos_regmap[i], in rockchip_pmu_save_qos()
361 &pd->qos_save_regs[2][i]); in rockchip_pmu_save_qos()
362 regmap_read(pd->qos_regmap[i], in rockchip_pmu_save_qos()
364 &pd->qos_save_regs[3][i]); in rockchip_pmu_save_qos()
365 regmap_read(pd->qos_regmap[i], in rockchip_pmu_save_qos()
367 &pd->qos_save_regs[4][i]); in rockchip_pmu_save_qos()
372 static int rockchip_pmu_restore_qos(struct rockchip_pm_domain *pd) in rockchip_pmu_restore_qos() argument
376 for (i = 0; i < pd->num_qos; i++) { in rockchip_pmu_restore_qos()
377 regmap_write(pd->qos_regmap[i], in rockchip_pmu_restore_qos()
379 pd->qos_save_regs[0][i]); in rockchip_pmu_restore_qos()
380 regmap_write(pd->qos_regmap[i], in rockchip_pmu_restore_qos()
382 pd->qos_save_regs[1][i]); in rockchip_pmu_restore_qos()
383 regmap_write(pd->qos_regmap[i], in rockchip_pmu_restore_qos()
385 pd->qos_save_regs[2][i]); in rockchip_pmu_restore_qos()
386 regmap_write(pd->qos_regmap[i], in rockchip_pmu_restore_qos()
388 pd->qos_save_regs[3][i]); in rockchip_pmu_restore_qos()
389 regmap_write(pd->qos_regmap[i], in rockchip_pmu_restore_qos()
391 pd->qos_save_regs[4][i]); in rockchip_pmu_restore_qos()
397 static bool rockchip_pmu_domain_is_on(struct rockchip_pm_domain *pd) in rockchip_pmu_domain_is_on() argument
399 struct rockchip_pmu *pmu = pd->pmu; in rockchip_pmu_domain_is_on()
402 if (pd->info->repair_status_mask) { in rockchip_pmu_domain_is_on()
405 return val & pd->info->repair_status_mask; in rockchip_pmu_domain_is_on()
409 if (pd->info->status_mask == 0) in rockchip_pmu_domain_is_on()
410 return !rockchip_pmu_domain_is_idle(pd); in rockchip_pmu_domain_is_on()
415 return !(val & pd->info->status_mask); in rockchip_pmu_domain_is_on()
418 static bool rockchip_pmu_domain_is_mem_on(struct rockchip_pm_domain *pd) in rockchip_pmu_domain_is_mem_on() argument
420 struct rockchip_pmu *pmu = pd->pmu; in rockchip_pmu_domain_is_mem_on()
424 pmu->info->mem_status_offset + pd->info->mem_offset, &val); in rockchip_pmu_domain_is_mem_on()
427 return !(val & pd->info->mem_status_mask); in rockchip_pmu_domain_is_mem_on()
430 static bool rockchip_pmu_domain_is_chain_on(struct rockchip_pm_domain *pd) in rockchip_pmu_domain_is_chain_on() argument
432 struct rockchip_pmu *pmu = pd->pmu; in rockchip_pmu_domain_is_chain_on()
436 pmu->info->chain_status_offset + pd->info->mem_offset, &val); in rockchip_pmu_domain_is_chain_on()
439 return val & pd->info->mem_status_mask; in rockchip_pmu_domain_is_chain_on()
442 static int rockchip_pmu_domain_mem_reset(struct rockchip_pm_domain *pd) in rockchip_pmu_domain_mem_reset() argument
444 struct rockchip_pmu *pmu = pd->pmu; in rockchip_pmu_domain_mem_reset()
445 struct generic_pm_domain *genpd = &pd->genpd; in rockchip_pmu_domain_mem_reset()
449 ret = readx_poll_timeout_atomic(rockchip_pmu_domain_is_chain_on, pd, is_on, in rockchip_pmu_domain_mem_reset()
460 regmap_write(pmu->regmap, pmu->info->mem_pwr_offset + pd->info->pwr_offset, in rockchip_pmu_domain_mem_reset()
461 (pd->info->pwr_mask | pd->info->pwr_w_mask)); in rockchip_pmu_domain_mem_reset()
464 ret = readx_poll_timeout_atomic(rockchip_pmu_domain_is_mem_on, pd, is_on, in rockchip_pmu_domain_mem_reset()
473 regmap_write(pmu->regmap, pmu->info->mem_pwr_offset + pd->info->pwr_offset, in rockchip_pmu_domain_mem_reset()
474 pd->info->pwr_w_mask); in rockchip_pmu_domain_mem_reset()
477 ret = readx_poll_timeout_atomic(rockchip_pmu_domain_is_mem_on, pd, is_on, in rockchip_pmu_domain_mem_reset()
489 static void rockchip_do_pmu_set_power_domain(struct rockchip_pm_domain *pd, in rockchip_do_pmu_set_power_domain() argument
492 struct rockchip_pmu *pmu = pd->pmu; in rockchip_do_pmu_set_power_domain()
493 struct generic_pm_domain *genpd = &pd->genpd; in rockchip_do_pmu_set_power_domain()
494 u32 pd_pwr_offset = pd->info->pwr_offset; in rockchip_do_pmu_set_power_domain()
497 if (pd->info->pwr_mask == 0) in rockchip_do_pmu_set_power_domain()
500 if (on && pd->info->mem_status_mask) in rockchip_do_pmu_set_power_domain()
501 is_mem_on = rockchip_pmu_domain_is_mem_on(pd); in rockchip_do_pmu_set_power_domain()
503 if (pd->info->pwr_w_mask) in rockchip_do_pmu_set_power_domain()
505 on ? pd->info->pwr_w_mask : in rockchip_do_pmu_set_power_domain()
506 (pd->info->pwr_mask | pd->info->pwr_w_mask)); in rockchip_do_pmu_set_power_domain()
509 pd->info->pwr_mask, on ? 0 : -1U); in rockchip_do_pmu_set_power_domain()
513 if (is_mem_on && rockchip_pmu_domain_mem_reset(pd)) in rockchip_do_pmu_set_power_domain()
516 if (readx_poll_timeout_atomic(rockchip_pmu_domain_is_on, pd, is_on, in rockchip_do_pmu_set_power_domain()
525 static int rockchip_pd_power(struct rockchip_pm_domain *pd, bool power_on) in rockchip_pd_power() argument
527 struct rockchip_pmu *pmu = pd->pmu; in rockchip_pd_power()
532 if (rockchip_pmu_domain_is_on(pd) != power_on) { in rockchip_pd_power()
533 ret = clk_bulk_enable(pd->num_clks, pd->clks); in rockchip_pd_power()
541 rockchip_pmu_save_qos(pd); in rockchip_pd_power()
544 rockchip_pmu_set_idle_request(pd, true); in rockchip_pd_power()
547 rockchip_do_pmu_set_power_domain(pd, power_on); in rockchip_pd_power()
551 rockchip_pmu_set_idle_request(pd, false); in rockchip_pd_power()
553 rockchip_pmu_restore_qos(pd); in rockchip_pd_power()
556 clk_bulk_disable(pd->num_clks, pd->clks); in rockchip_pd_power()
565 struct rockchip_pm_domain *pd = to_rockchip_pd(domain); in rockchip_pd_power_on() local
567 return rockchip_pd_power(pd, true); in rockchip_pd_power_on()
572 struct rockchip_pm_domain *pd = to_rockchip_pd(domain); in rockchip_pd_power_off() local
574 return rockchip_pd_power(pd, false); in rockchip_pd_power_off()
619 struct rockchip_pm_domain *pd; in rockchip_pm_add_one_domain() local
649 pd = devm_kzalloc(pmu->dev, sizeof(*pd), GFP_KERNEL); in rockchip_pm_add_one_domain()
650 if (!pd) in rockchip_pm_add_one_domain()
653 pd->info = pd_info; in rockchip_pm_add_one_domain()
654 pd->pmu = pmu; in rockchip_pm_add_one_domain()
656 pd->num_clks = of_clk_get_parent_count(node); in rockchip_pm_add_one_domain()
657 if (pd->num_clks > 0) { in rockchip_pm_add_one_domain()
658 pd->clks = devm_kcalloc(pmu->dev, pd->num_clks, in rockchip_pm_add_one_domain()
659 sizeof(*pd->clks), GFP_KERNEL); in rockchip_pm_add_one_domain()
660 if (!pd->clks) in rockchip_pm_add_one_domain()
664 node, pd->num_clks); in rockchip_pm_add_one_domain()
665 pd->num_clks = 0; in rockchip_pm_add_one_domain()
668 for (i = 0; i < pd->num_clks; i++) { in rockchip_pm_add_one_domain()
669 pd->clks[i].clk = of_clk_get(node, i); in rockchip_pm_add_one_domain()
670 if (IS_ERR(pd->clks[i].clk)) { in rockchip_pm_add_one_domain()
671 error = PTR_ERR(pd->clks[i].clk); in rockchip_pm_add_one_domain()
679 error = clk_bulk_prepare(pd->num_clks, pd->clks); in rockchip_pm_add_one_domain()
683 pd->num_qos = of_count_phandle_with_args(node, "pm_qos", in rockchip_pm_add_one_domain()
686 if (pd->num_qos > 0) { in rockchip_pm_add_one_domain()
687 pd->qos_regmap = devm_kcalloc(pmu->dev, pd->num_qos, in rockchip_pm_add_one_domain()
688 sizeof(*pd->qos_regmap), in rockchip_pm_add_one_domain()
690 if (!pd->qos_regmap) { in rockchip_pm_add_one_domain()
696 pd->qos_save_regs[j] = devm_kcalloc(pmu->dev, in rockchip_pm_add_one_domain()
697 pd->num_qos, in rockchip_pm_add_one_domain()
700 if (!pd->qos_save_regs[j]) { in rockchip_pm_add_one_domain()
706 for (j = 0; j < pd->num_qos; j++) { in rockchip_pm_add_one_domain()
712 pd->qos_regmap[j] = syscon_node_to_regmap(qos_node); in rockchip_pm_add_one_domain()
713 if (IS_ERR(pd->qos_regmap[j])) { in rockchip_pm_add_one_domain()
722 if (pd->info->name) in rockchip_pm_add_one_domain()
723 pd->genpd.name = pd->info->name; in rockchip_pm_add_one_domain()
725 pd->genpd.name = kbasename(node->full_name); in rockchip_pm_add_one_domain()
726 pd->genpd.power_off = rockchip_pd_power_off; in rockchip_pm_add_one_domain()
727 pd->genpd.power_on = rockchip_pd_power_on; in rockchip_pm_add_one_domain()
728 pd->genpd.attach_dev = rockchip_pd_attach_dev; in rockchip_pm_add_one_domain()
729 pd->genpd.detach_dev = rockchip_pd_detach_dev; in rockchip_pm_add_one_domain()
730 pd->genpd.flags = GENPD_FLAG_PM_CLK; in rockchip_pm_add_one_domain()
732 pd->genpd.flags |= GENPD_FLAG_ACTIVE_WAKEUP; in rockchip_pm_add_one_domain()
733 pm_genpd_init(&pd->genpd, NULL, in rockchip_pm_add_one_domain()
734 !rockchip_pmu_domain_is_on(pd) || in rockchip_pm_add_one_domain()
735 (pd->info->mem_status_mask && !rockchip_pmu_domain_is_mem_on(pd))); in rockchip_pm_add_one_domain()
737 pmu->genpd_data.domains[id] = &pd->genpd; in rockchip_pm_add_one_domain()
741 clk_bulk_unprepare(pd->num_clks, pd->clks); in rockchip_pm_add_one_domain()
743 clk_bulk_put(pd->num_clks, pd->clks); in rockchip_pm_add_one_domain()
747 static void rockchip_pm_remove_one_domain(struct rockchip_pm_domain *pd) in rockchip_pm_remove_one_domain() argument
755 ret = pm_genpd_remove(&pd->genpd); in rockchip_pm_remove_one_domain()
757 dev_err(pd->pmu->dev, "failed to remove domain '%s' : %d - state may be inconsistent\n", in rockchip_pm_remove_one_domain()
758 pd->genpd.name, ret); in rockchip_pm_remove_one_domain()
760 clk_bulk_unprepare(pd->num_clks, pd->clks); in rockchip_pm_remove_one_domain()
761 clk_bulk_put(pd->num_clks, pd->clks); in rockchip_pm_remove_one_domain()
764 mutex_lock(&pd->pmu->mutex); in rockchip_pm_remove_one_domain()
765 pd->num_clks = 0; in rockchip_pm_remove_one_domain()
766 mutex_unlock(&pd->pmu->mutex); in rockchip_pm_remove_one_domain()
774 struct rockchip_pm_domain *pd; in rockchip_pm_domain_cleanup() local
780 pd = to_rockchip_pd(genpd); in rockchip_pm_domain_cleanup()
781 rockchip_pm_remove_one_domain(pd); in rockchip_pm_domain_cleanup()