Lines Matching refs:pmu
69 struct rockchip_pmu *pmu; member
136 struct rockchip_pmu *pmu = pd->pmu; in rockchip_pmu_domain_is_idle() local
140 regmap_read(pmu->regmap, pmu->info->idle_offset, &val); in rockchip_pmu_domain_is_idle()
144 static unsigned int rockchip_pmu_read_ack(struct rockchip_pmu *pmu) in rockchip_pmu_read_ack() argument
148 regmap_read(pmu->regmap, pmu->info->ack_offset, &val); in rockchip_pmu_read_ack()
157 struct rockchip_pmu *pmu = pd->pmu; in rockchip_pmu_set_idle_request() local
166 regmap_write(pmu->regmap, pmu->info->req_offset, in rockchip_pmu_set_idle_request()
170 regmap_update_bits(pmu->regmap, pmu->info->req_offset, in rockchip_pmu_set_idle_request()
177 ret = readx_poll_timeout_atomic(rockchip_pmu_read_ack, pmu, val, in rockchip_pmu_set_idle_request()
181 dev_err(pmu->dev, in rockchip_pmu_set_idle_request()
190 dev_err(pmu->dev, in rockchip_pmu_set_idle_request()
250 struct rockchip_pmu *pmu = pd->pmu; in rockchip_pmu_domain_is_on() local
257 regmap_read(pmu->regmap, pmu->info->status_offset, &val); in rockchip_pmu_domain_is_on()
266 struct rockchip_pmu *pmu = pd->pmu; in rockchip_do_pmu_set_power_domain() local
273 regmap_write(pmu->regmap, pmu->info->pwr_offset, in rockchip_do_pmu_set_power_domain()
277 regmap_update_bits(pmu->regmap, pmu->info->pwr_offset, in rockchip_do_pmu_set_power_domain()
284 dev_err(pmu->dev, in rockchip_do_pmu_set_power_domain()
293 struct rockchip_pmu *pmu = pd->pmu; in rockchip_pd_power() local
296 mutex_lock(&pmu->mutex); in rockchip_pd_power()
301 dev_err(pmu->dev, "failed to enable clocks\n"); in rockchip_pd_power()
302 mutex_unlock(&pmu->mutex); in rockchip_pd_power()
325 mutex_unlock(&pmu->mutex); in rockchip_pd_power()
381 static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu, in rockchip_pm_add_one_domain() argument
393 dev_err(pmu->dev, in rockchip_pm_add_one_domain()
399 if (id >= pmu->info->num_domains) { in rockchip_pm_add_one_domain()
400 dev_err(pmu->dev, "%pOFn: invalid domain id %d\n", in rockchip_pm_add_one_domain()
405 pd_info = &pmu->info->domain_info[id]; in rockchip_pm_add_one_domain()
407 dev_err(pmu->dev, "%pOFn: undefined domain id %d\n", in rockchip_pm_add_one_domain()
412 pd = devm_kzalloc(pmu->dev, sizeof(*pd), GFP_KERNEL); in rockchip_pm_add_one_domain()
417 pd->pmu = pmu; in rockchip_pm_add_one_domain()
421 pd->clks = devm_kcalloc(pmu->dev, pd->num_clks, in rockchip_pm_add_one_domain()
426 dev_dbg(pmu->dev, "%pOFn: doesn't have clocks: %d\n", in rockchip_pm_add_one_domain()
435 dev_err(pmu->dev, in rockchip_pm_add_one_domain()
450 pd->qos_regmap = devm_kcalloc(pmu->dev, pd->num_qos, in rockchip_pm_add_one_domain()
459 pd->qos_save_regs[j] = devm_kcalloc(pmu->dev, in rockchip_pm_add_one_domain()
487 dev_err(pmu->dev, in rockchip_pm_add_one_domain()
503 pmu->genpd_data.domains[id] = &pd->genpd; in rockchip_pm_add_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()
530 mutex_lock(&pd->pmu->mutex); in rockchip_pm_remove_one_domain()
532 mutex_unlock(&pd->pmu->mutex); in rockchip_pm_remove_one_domain()
537 static void rockchip_pm_domain_cleanup(struct rockchip_pmu *pmu) in rockchip_pm_domain_cleanup() argument
543 for (i = 0; i < pmu->genpd_data.num_domains; i++) { in rockchip_pm_domain_cleanup()
544 genpd = pmu->genpd_data.domains[i]; in rockchip_pm_domain_cleanup()
554 static void rockchip_configure_pd_cnt(struct rockchip_pmu *pmu, in rockchip_configure_pd_cnt() argument
559 regmap_write(pmu->regmap, domain_reg_offset, count); in rockchip_configure_pd_cnt()
561 regmap_write(pmu->regmap, domain_reg_offset + 4, count); in rockchip_configure_pd_cnt()
564 static int rockchip_pm_add_subdomain(struct rockchip_pmu *pmu, in rockchip_pm_add_subdomain() argument
576 dev_err(pmu->dev, in rockchip_pm_add_subdomain()
581 parent_domain = pmu->genpd_data.domains[idx]; in rockchip_pm_add_subdomain()
583 error = rockchip_pm_add_one_domain(pmu, np); in rockchip_pm_add_subdomain()
585 dev_err(pmu->dev, "failed to handle node %pOFn: %d\n", in rockchip_pm_add_subdomain()
592 dev_err(pmu->dev, in rockchip_pm_add_subdomain()
597 child_domain = pmu->genpd_data.domains[idx]; in rockchip_pm_add_subdomain()
601 dev_err(pmu->dev, "%s failed to add subdomain %s: %d\n", in rockchip_pm_add_subdomain()
605 dev_dbg(pmu->dev, "%s add subdomain: %s\n", in rockchip_pm_add_subdomain()
609 rockchip_pm_add_subdomain(pmu, np); in rockchip_pm_add_subdomain()
625 struct rockchip_pmu *pmu; in rockchip_pm_domain_probe() local
643 pmu = devm_kzalloc(dev, in rockchip_pm_domain_probe()
644 struct_size(pmu, domains, pmu_info->num_domains), in rockchip_pm_domain_probe()
646 if (!pmu) in rockchip_pm_domain_probe()
649 pmu->dev = &pdev->dev; in rockchip_pm_domain_probe()
650 mutex_init(&pmu->mutex); in rockchip_pm_domain_probe()
652 pmu->info = pmu_info; in rockchip_pm_domain_probe()
654 pmu->genpd_data.domains = pmu->domains; in rockchip_pm_domain_probe()
655 pmu->genpd_data.num_domains = pmu_info->num_domains; in rockchip_pm_domain_probe()
663 pmu->regmap = syscon_node_to_regmap(parent->of_node); in rockchip_pm_domain_probe()
664 if (IS_ERR(pmu->regmap)) { in rockchip_pm_domain_probe()
666 return PTR_ERR(pmu->regmap); in rockchip_pm_domain_probe()
674 rockchip_configure_pd_cnt(pmu, pmu_info->core_pwrcnt_offset, in rockchip_pm_domain_probe()
677 rockchip_configure_pd_cnt(pmu, pmu_info->gpu_pwrcnt_offset, in rockchip_pm_domain_probe()
683 error = rockchip_pm_add_one_domain(pmu, node); in rockchip_pm_domain_probe()
691 error = rockchip_pm_add_subdomain(pmu, node); in rockchip_pm_domain_probe()
705 error = of_genpd_add_provider_onecell(np, &pmu->genpd_data); in rockchip_pm_domain_probe()
714 rockchip_pm_domain_cleanup(pmu); in rockchip_pm_domain_probe()