Lines Matching +full:sdm845 +full:- +full:rpmhpd
1 // SPDX-License-Identifier: GPL-2.0
14 #include <soc/qcom/cmd-db.h>
16 #include <dt-bindings/power/qcom-rpmpd.h>
17 #include <dt-bindings/power/qcom,rpmhpd.h>
19 #define domain_to_rpmhpd(domain) container_of(domain, struct rpmhpd, pd)
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
42 * @state_synced: Indicator that sync_state has been invoked for the rpmhpd resource
45 struct rpmhpd { struct
49 struct rpmhpd *peer; argument
64 struct rpmhpd **rpmhpds; argument
72 static struct rpmhpd cx_ao;
73 static struct rpmhpd mx;
74 static struct rpmhpd mx_ao;
75 static struct rpmhpd cx = {
81 static struct rpmhpd cx_ao = {
88 static struct rpmhpd cx_ao_w_mx_parent;
89 static struct rpmhpd cx_w_mx_parent = {
96 static struct rpmhpd cx_ao_w_mx_parent = {
104 static struct rpmhpd ebi = {
109 static struct rpmhpd gfx = {
114 static struct rpmhpd lcx = {
119 static struct rpmhpd lmx = {
124 static struct rpmhpd mmcx_ao;
125 static struct rpmhpd mmcx = {
131 static struct rpmhpd mmcx_ao = {
138 static struct rpmhpd mmcx_ao_w_cx_parent;
139 static struct rpmhpd mmcx_w_cx_parent = {
146 static struct rpmhpd mmcx_ao_w_cx_parent = {
154 static struct rpmhpd mss = {
159 static struct rpmhpd mx_ao;
160 static struct rpmhpd mx = {
166 static struct rpmhpd mx_ao = {
173 static struct rpmhpd mxc_ao;
174 static struct rpmhpd mxc = {
181 static struct rpmhpd mxc_ao = {
189 static struct rpmhpd nsp = {
194 static struct rpmhpd nsp0 = {
199 static struct rpmhpd nsp1 = {
204 static struct rpmhpd qphy = {
210 static struct rpmhpd *sa8540p_rpmhpds[] = {
229 static struct rpmhpd *sa8775p_rpmhpds[] = {
252 static struct rpmhpd *sdm670_rpmhpds[] = {
268 /* SDM845 RPMH powerdomains */
269 static struct rpmhpd *sdm845_rpmhpds[] = {
287 static struct rpmhpd *sdx55_rpmhpds[] = {
299 static struct rpmhpd *sdx65_rpmhpds[] = {
314 static struct rpmhpd *sdx75_rpmhpds[] = {
329 static struct rpmhpd *sm6350_rpmhpds[] = {
344 static struct rpmhpd *sm8150_rpmhpds[] = {
363 static struct rpmhpd *sa8155p_rpmhpds[] = {
379 static struct rpmhpd *sm8250_rpmhpds[] = {
398 static struct rpmhpd *sm8350_rpmhpds[] = {
420 static struct rpmhpd *sm8450_rpmhpds[] = {
442 static struct rpmhpd *sm8550_rpmhpds[] = {
465 static struct rpmhpd *qdu1000_rpmhpds[] = {
478 static struct rpmhpd *sc7180_rpmhpds[] = {
495 static struct rpmhpd *sc7280_rpmhpds[] = {
513 static struct rpmhpd *sc8180x_rpmhpds[] = {
533 static struct rpmhpd *sc8280xp_rpmhpds[] = {
554 { .compatible = "qcom,qdu1000-rpmhpd", .data = &qdu1000_desc },
555 { .compatible = "qcom,sa8155p-rpmhpd", .data = &sa8155p_desc },
556 { .compatible = "qcom,sa8540p-rpmhpd", .data = &sa8540p_desc },
557 { .compatible = "qcom,sa8775p-rpmhpd", .data = &sa8775p_desc },
558 { .compatible = "qcom,sc7180-rpmhpd", .data = &sc7180_desc },
559 { .compatible = "qcom,sc7280-rpmhpd", .data = &sc7280_desc },
560 { .compatible = "qcom,sc8180x-rpmhpd", .data = &sc8180x_desc },
561 { .compatible = "qcom,sc8280xp-rpmhpd", .data = &sc8280xp_desc },
562 { .compatible = "qcom,sdm670-rpmhpd", .data = &sdm670_desc },
563 { .compatible = "qcom,sdm845-rpmhpd", .data = &sdm845_desc },
564 { .compatible = "qcom,sdx55-rpmhpd", .data = &sdx55_desc},
565 { .compatible = "qcom,sdx65-rpmhpd", .data = &sdx65_desc},
566 { .compatible = "qcom,sdx75-rpmhpd", .data = &sdx75_desc},
567 { .compatible = "qcom,sm6350-rpmhpd", .data = &sm6350_desc },
568 { .compatible = "qcom,sm8150-rpmhpd", .data = &sm8150_desc },
569 { .compatible = "qcom,sm8250-rpmhpd", .data = &sm8250_desc },
570 { .compatible = "qcom,sm8350-rpmhpd", .data = &sm8350_desc },
571 { .compatible = "qcom,sm8450-rpmhpd", .data = &sm8450_desc },
572 { .compatible = "qcom,sm8550-rpmhpd", .data = &sm8550_desc },
577 static int rpmhpd_send_corner(struct rpmhpd *pd, int state, in rpmhpd_send_corner()
581 .addr = pd->addr, in rpmhpd_send_corner()
590 return rpmh_write(pd->dev, state, &cmd, 1); in rpmhpd_send_corner()
592 return rpmh_write_async(pd->dev, state, &cmd, 1); in rpmhpd_send_corner()
595 static void to_active_sleep(struct rpmhpd *pd, unsigned int corner, in to_active_sleep()
600 if (pd->active_only) in to_active_sleep()
615 static int rpmhpd_aggregate_corner(struct rpmhpd *pd, unsigned int corner) in rpmhpd_aggregate_corner()
618 struct rpmhpd *peer = pd->peer; in rpmhpd_aggregate_corner()
624 if (pd->state_synced) { in rpmhpd_aggregate_corner()
628 this_active_corner = pd->level_count - 1; in rpmhpd_aggregate_corner()
629 this_sleep_corner = pd->level_count - 1; in rpmhpd_aggregate_corner()
632 if (peer && peer->enabled) { in rpmhpd_aggregate_corner()
633 peer_enabled_corner = max(peer->corner, peer->enable_corner); in rpmhpd_aggregate_corner()
641 active_corner > pd->active_corner); in rpmhpd_aggregate_corner()
645 pd->active_corner = active_corner; in rpmhpd_aggregate_corner()
648 peer->active_corner = active_corner; in rpmhpd_aggregate_corner()
666 struct rpmhpd *pd = domain_to_rpmhpd(domain); in rpmhpd_power_on()
672 corner = max(pd->corner, pd->enable_corner); in rpmhpd_power_on()
675 pd->enabled = true; in rpmhpd_power_on()
684 struct rpmhpd *pd = domain_to_rpmhpd(domain); in rpmhpd_power_off()
691 pd->enabled = false; in rpmhpd_power_off()
701 struct rpmhpd *pd = domain_to_rpmhpd(domain); in rpmhpd_set_performance_state()
706 for (i = 0; i < pd->level_count; i++) in rpmhpd_set_performance_state()
707 if (level <= pd->level[i]) in rpmhpd_set_performance_state()
714 if (i == pd->level_count) in rpmhpd_set_performance_state()
715 i--; in rpmhpd_set_performance_state()
717 if (pd->enabled) { in rpmhpd_set_performance_state()
719 if (i < pd->enable_corner) in rpmhpd_set_performance_state()
720 i = pd->enable_corner; in rpmhpd_set_performance_state()
727 pd->corner = i; in rpmhpd_set_performance_state()
740 static int rpmhpd_update_level_mapping(struct rpmhpd *rpmhpd) in rpmhpd_update_level_mapping() argument
745 buf = cmd_db_read_aux_data(rpmhpd->res_name, &rpmhpd->level_count); in rpmhpd_update_level_mapping()
750 rpmhpd->level_count >>= 1; in rpmhpd_update_level_mapping()
752 if (rpmhpd->level_count > RPMH_ARC_MAX_LEVELS) in rpmhpd_update_level_mapping()
753 return -EINVAL; in rpmhpd_update_level_mapping()
755 for (i = 0; i < rpmhpd->level_count; i++) { in rpmhpd_update_level_mapping()
756 if (rpmhpd->skip_retention_level && buf[i] == RPMH_REGULATOR_LEVEL_RETENTION) in rpmhpd_update_level_mapping()
759 rpmhpd->level[i] = buf[i]; in rpmhpd_update_level_mapping()
761 /* Remember the first corner with non-zero level */ in rpmhpd_update_level_mapping()
762 if (!rpmhpd->level[rpmhpd->enable_corner] && rpmhpd->level[i]) in rpmhpd_update_level_mapping()
763 rpmhpd->enable_corner = i; in rpmhpd_update_level_mapping()
769 if (i > 0 && rpmhpd->level[i] == 0) { in rpmhpd_update_level_mapping()
770 rpmhpd->level_count = i; in rpmhpd_update_level_mapping()
773 pr_debug("%s: ARC hlvl=%2d --> vlvl=%4u\n", rpmhpd->res_name, i, in rpmhpd_update_level_mapping()
774 rpmhpd->level[i]); in rpmhpd_update_level_mapping()
784 struct device *dev = &pdev->dev; in rpmhpd_probe()
786 struct rpmhpd **rpmhpds; in rpmhpd_probe()
791 return -EINVAL; in rpmhpd_probe()
793 rpmhpds = desc->rpmhpds; in rpmhpd_probe()
794 num_pds = desc->num_pds; in rpmhpd_probe()
798 return -ENOMEM; in rpmhpd_probe()
800 data->domains = devm_kcalloc(dev, num_pds, sizeof(*data->domains), in rpmhpd_probe()
802 if (!data->domains) in rpmhpd_probe()
803 return -ENOMEM; in rpmhpd_probe()
805 data->num_domains = num_pds; in rpmhpd_probe()
811 rpmhpds[i]->dev = dev; in rpmhpd_probe()
812 rpmhpds[i]->addr = cmd_db_read_addr(rpmhpds[i]->res_name); in rpmhpd_probe()
813 if (!rpmhpds[i]->addr) { in rpmhpd_probe()
815 rpmhpds[i]->res_name); in rpmhpd_probe()
816 return -ENODEV; in rpmhpd_probe()
819 ret = cmd_db_read_slave_id(rpmhpds[i]->res_name); in rpmhpd_probe()
822 return -EINVAL; in rpmhpd_probe()
829 rpmhpds[i]->pd.power_off = rpmhpd_power_off; in rpmhpd_probe()
830 rpmhpds[i]->pd.power_on = rpmhpd_power_on; in rpmhpd_probe()
831 rpmhpds[i]->pd.set_performance_state = rpmhpd_set_performance_state; in rpmhpd_probe()
832 rpmhpds[i]->pd.opp_to_performance_state = rpmhpd_get_performance_state; in rpmhpd_probe()
833 pm_genpd_init(&rpmhpds[i]->pd, NULL, true); in rpmhpd_probe()
835 data->domains[i] = &rpmhpds[i]->pd; in rpmhpd_probe()
842 if (rpmhpds[i]->parent) in rpmhpd_probe()
843 pm_genpd_add_subdomain(rpmhpds[i]->parent, in rpmhpd_probe()
844 &rpmhpds[i]->pd); in rpmhpd_probe()
847 return of_genpd_add_provider_onecell(pdev->dev.of_node, data); in rpmhpd_probe()
853 struct rpmhpd **rpmhpds = desc->rpmhpds; in rpmhpd_sync_state()
855 struct rpmhpd *pd; in rpmhpd_sync_state()
860 for (i = 0; i < desc->num_pds; i++) { in rpmhpd_sync_state()
865 pd->state_synced = true; in rpmhpd_sync_state()
866 if (pd->enabled) in rpmhpd_sync_state()
867 corner = max(pd->corner, pd->enable_corner); in rpmhpd_sync_state()
873 dev_err(dev, "failed to sync %s\n", pd->res_name); in rpmhpd_sync_state()
880 .name = "qcom-rpmhpd",