Lines Matching +full:cmd +full:- +full:db

1 // SPDX-License-Identifier: GPL-2.0
15 #include <soc/qcom/cmd-db.h>
17 #include <dt-bindings/power/qcom-rpmpd.h>
24 * struct rpmhpd - top level RPMh power domain resource data structure
33 * @enable_corner: lowest non-zero corner
35 * derived from cmd-db
37 * being 16 (0 - 15)
39 * @res_name: Resource name used for cmd-db lookup
41 * cmd-db
433 { .compatible = "qcom,sa8540p-rpmhpd", .data = &sa8540p_desc },
434 { .compatible = "qcom,sc7180-rpmhpd", .data = &sc7180_desc },
435 { .compatible = "qcom,sc7280-rpmhpd", .data = &sc7280_desc },
436 { .compatible = "qcom,sc8180x-rpmhpd", .data = &sc8180x_desc },
437 { .compatible = "qcom,sc8280xp-rpmhpd", .data = &sc8280xp_desc },
438 { .compatible = "qcom,sdm845-rpmhpd", .data = &sdm845_desc },
439 { .compatible = "qcom,sdx55-rpmhpd", .data = &sdx55_desc},
440 { .compatible = "qcom,sdx65-rpmhpd", .data = &sdx65_desc},
441 { .compatible = "qcom,sm6350-rpmhpd", .data = &sm6350_desc },
442 { .compatible = "qcom,sm8150-rpmhpd", .data = &sm8150_desc },
443 { .compatible = "qcom,sm8250-rpmhpd", .data = &sm8250_desc },
444 { .compatible = "qcom,sm8350-rpmhpd", .data = &sm8350_desc },
445 { .compatible = "qcom,sm8450-rpmhpd", .data = &sm8450_desc },
453 struct tcs_cmd cmd = { in rpmhpd_send_corner() local
454 .addr = pd->addr, in rpmhpd_send_corner()
463 return rpmh_write(pd->dev, state, &cmd, 1); in rpmhpd_send_corner()
465 return rpmh_write_async(pd->dev, state, &cmd, 1); in rpmhpd_send_corner()
473 if (pd->active_only) in to_active_sleep()
491 struct rpmhpd *peer = pd->peer; in rpmhpd_aggregate_corner()
498 if (peer && peer->enabled) in rpmhpd_aggregate_corner()
499 to_active_sleep(peer, peer->corner, &peer_active_corner, in rpmhpd_aggregate_corner()
505 active_corner > pd->active_corner); in rpmhpd_aggregate_corner()
509 pd->active_corner = active_corner; in rpmhpd_aggregate_corner()
512 peer->active_corner = active_corner; in rpmhpd_aggregate_corner()
536 corner = max(pd->corner, pd->enable_corner); in rpmhpd_power_on()
539 pd->enabled = true; in rpmhpd_power_on()
555 pd->enabled = false; in rpmhpd_power_off()
570 for (i = 0; i < pd->level_count; i++) in rpmhpd_set_performance_state()
571 if (level <= pd->level[i]) in rpmhpd_set_performance_state()
578 if (i == pd->level_count) in rpmhpd_set_performance_state()
579 i--; in rpmhpd_set_performance_state()
581 if (pd->enabled) { in rpmhpd_set_performance_state()
583 if (i < pd->enable_corner) in rpmhpd_set_performance_state()
584 i = pd->enable_corner; in rpmhpd_set_performance_state()
591 pd->corner = i; in rpmhpd_set_performance_state()
609 buf = cmd_db_read_aux_data(rpmhpd->res_name, &rpmhpd->level_count); in rpmhpd_update_level_mapping()
613 /* 2 bytes used for each command DB aux data entry */ in rpmhpd_update_level_mapping()
614 rpmhpd->level_count >>= 1; in rpmhpd_update_level_mapping()
616 if (rpmhpd->level_count > RPMH_ARC_MAX_LEVELS) in rpmhpd_update_level_mapping()
617 return -EINVAL; in rpmhpd_update_level_mapping()
619 for (i = 0; i < rpmhpd->level_count; i++) { in rpmhpd_update_level_mapping()
620 rpmhpd->level[i] = buf[i]; in rpmhpd_update_level_mapping()
622 /* Remember the first corner with non-zero level */ in rpmhpd_update_level_mapping()
623 if (!rpmhpd->level[rpmhpd->enable_corner] && rpmhpd->level[i]) in rpmhpd_update_level_mapping()
624 rpmhpd->enable_corner = i; in rpmhpd_update_level_mapping()
630 if (i > 0 && rpmhpd->level[i] == 0) { in rpmhpd_update_level_mapping()
631 rpmhpd->level_count = i; in rpmhpd_update_level_mapping()
634 pr_debug("%s: ARC hlvl=%2d --> vlvl=%4u\n", rpmhpd->res_name, i, in rpmhpd_update_level_mapping()
635 rpmhpd->level[i]); in rpmhpd_update_level_mapping()
645 struct device *dev = &pdev->dev; in rpmhpd_probe()
652 return -EINVAL; in rpmhpd_probe()
654 rpmhpds = desc->rpmhpds; in rpmhpd_probe()
655 num_pds = desc->num_pds; in rpmhpd_probe()
659 return -ENOMEM; in rpmhpd_probe()
661 data->domains = devm_kcalloc(dev, num_pds, sizeof(*data->domains), in rpmhpd_probe()
663 if (!data->domains) in rpmhpd_probe()
664 return -ENOMEM; in rpmhpd_probe()
666 data->num_domains = num_pds; in rpmhpd_probe()
672 rpmhpds[i]->dev = dev; in rpmhpd_probe()
673 rpmhpds[i]->addr = cmd_db_read_addr(rpmhpds[i]->res_name); in rpmhpd_probe()
674 if (!rpmhpds[i]->addr) { in rpmhpd_probe()
676 rpmhpds[i]->res_name); in rpmhpd_probe()
677 return -ENODEV; in rpmhpd_probe()
680 ret = cmd_db_read_slave_id(rpmhpds[i]->res_name); in rpmhpd_probe()
683 return -EINVAL; in rpmhpd_probe()
690 rpmhpds[i]->pd.power_off = rpmhpd_power_off; in rpmhpd_probe()
691 rpmhpds[i]->pd.power_on = rpmhpd_power_on; in rpmhpd_probe()
692 rpmhpds[i]->pd.set_performance_state = rpmhpd_set_performance_state; in rpmhpd_probe()
693 rpmhpds[i]->pd.opp_to_performance_state = rpmhpd_get_performance_state; in rpmhpd_probe()
694 pm_genpd_init(&rpmhpds[i]->pd, NULL, true); in rpmhpd_probe()
696 data->domains[i] = &rpmhpds[i]->pd; in rpmhpd_probe()
703 if (rpmhpds[i]->parent) in rpmhpd_probe()
704 pm_genpd_add_subdomain(rpmhpds[i]->parent, in rpmhpd_probe()
705 &rpmhpds[i]->pd); in rpmhpd_probe()
708 return of_genpd_add_provider_onecell(pdev->dev.of_node, data); in rpmhpd_probe()
713 .name = "qcom-rpmhpd",