Lines Matching +full:sdm845 +full:- +full:rpmhpd
1 // SPDX-License-Identifier: GPL-2.0
15 #include <soc/qcom/cmd-db.h>
17 #include <dt-bindings/power/qcom-rpmpd.h>
18 #include <dt-bindings/power/qcom,rpmhpd.h>
20 #define domain_to_rpmhpd(domain) container_of(domain, struct rpmhpd, pd)
25 * struct rpmhpd - top level RPMh power domain resource data structure
34 * @enable_corner: lowest non-zero corner
36 * derived from cmd-db
38 * being 16 (0 - 15)
40 * @res_name: Resource name used for cmd-db lookup
42 * cmd-db
43 * @state_synced: Indicator that sync_state has been invoked for the rpmhpd resource
46 struct rpmhpd { struct
50 struct rpmhpd *peer; argument
65 struct rpmhpd **rpmhpds; argument
73 static struct rpmhpd cx_ao;
74 static struct rpmhpd mx;
75 static struct rpmhpd mx_ao;
76 static struct rpmhpd cx = {
82 static struct rpmhpd cx_ao = {
89 static struct rpmhpd cx_ao_w_mx_parent;
90 static struct rpmhpd cx_w_mx_parent = {
97 static struct rpmhpd cx_ao_w_mx_parent = {
105 static struct rpmhpd ebi = {
110 static struct rpmhpd gfx = {
115 static struct rpmhpd lcx = {
120 static struct rpmhpd lmx = {
125 static struct rpmhpd mmcx_ao;
126 static struct rpmhpd mmcx = {
132 static struct rpmhpd mmcx_ao = {
139 static struct rpmhpd mmcx_ao_w_cx_parent;
140 static struct rpmhpd mmcx_w_cx_parent = {
147 static struct rpmhpd mmcx_ao_w_cx_parent = {
155 static struct rpmhpd mss = {
160 static struct rpmhpd mx_ao;
161 static struct rpmhpd mx = {
167 static struct rpmhpd mx_ao = {
174 static struct rpmhpd mxc_ao;
175 static struct rpmhpd mxc = {
182 static struct rpmhpd mxc_ao = {
190 static struct rpmhpd nsp = {
195 static struct rpmhpd nsp0 = {
200 static struct rpmhpd nsp1 = {
205 static struct rpmhpd nsp2 = {
210 static struct rpmhpd qphy = {
215 static struct rpmhpd gmxc = {
221 static struct rpmhpd *milos_rpmhpds[] = {
239 static struct rpmhpd *sa8540p_rpmhpds[] = {
258 static struct rpmhpd *sa8775p_rpmhpds[] = {
281 static struct rpmhpd *sar2130p_rpmhpds[] = {
305 static struct rpmhpd *sdm670_rpmhpds[] = {
321 /* SDM845 RPMH powerdomains */
322 static struct rpmhpd *sdm845_rpmhpds[] = {
340 static struct rpmhpd *sdx55_rpmhpds[] = {
352 static struct rpmhpd *sdx65_rpmhpds[] = {
367 static struct rpmhpd *sdx75_rpmhpds[] = {
382 static struct rpmhpd *sm4450_rpmhpds[] = {
397 static struct rpmhpd *sm6350_rpmhpds[] = {
412 static struct rpmhpd *sm7150_rpmhpds[] = {
429 static struct rpmhpd *sm8150_rpmhpds[] = {
448 static struct rpmhpd *sa8155p_rpmhpds[] = {
464 static struct rpmhpd *sm8250_rpmhpds[] = {
483 static struct rpmhpd *sm8350_rpmhpds[] = {
505 static struct rpmhpd *sm8450_rpmhpds[] = {
527 static struct rpmhpd *sm8550_rpmhpds[] = {
550 static struct rpmhpd *sm8650_rpmhpds[] = {
574 static struct rpmhpd *sm8750_rpmhpds[] = {
599 static struct rpmhpd *qdu1000_rpmhpds[] = {
612 static struct rpmhpd *sc7180_rpmhpds[] = {
629 static struct rpmhpd *sc7280_rpmhpds[] = {
647 static struct rpmhpd *sc8180x_rpmhpds[] = {
667 static struct rpmhpd *sc8280xp_rpmhpds[] = {
688 static struct rpmhpd *glymur_rpmhpds[] = {
713 static struct rpmhpd *x1e80100_rpmhpds[] = {
735 static struct rpmhpd *qcs8300_rpmhpds[] = {
758 static struct rpmhpd *qcs615_rpmhpds[] = {
769 { .compatible = "qcom,glymur-rpmhpd", .data = &glymur_desc },
770 { .compatible = "qcom,milos-rpmhpd", .data = &milos_desc },
771 { .compatible = "qcom,qcs615-rpmhpd", .data = &qcs615_desc },
772 { .compatible = "qcom,qcs8300-rpmhpd", .data = &qcs8300_desc },
773 { .compatible = "qcom,qdu1000-rpmhpd", .data = &qdu1000_desc },
774 { .compatible = "qcom,sa8155p-rpmhpd", .data = &sa8155p_desc },
775 { .compatible = "qcom,sa8540p-rpmhpd", .data = &sa8540p_desc },
776 { .compatible = "qcom,sa8775p-rpmhpd", .data = &sa8775p_desc },
777 { .compatible = "qcom,sar2130p-rpmhpd", .data = &sar2130p_desc},
778 { .compatible = "qcom,sc7180-rpmhpd", .data = &sc7180_desc },
779 { .compatible = "qcom,sc7280-rpmhpd", .data = &sc7280_desc },
780 { .compatible = "qcom,sc8180x-rpmhpd", .data = &sc8180x_desc },
781 { .compatible = "qcom,sc8280xp-rpmhpd", .data = &sc8280xp_desc },
782 { .compatible = "qcom,sdm670-rpmhpd", .data = &sdm670_desc },
783 { .compatible = "qcom,sdm845-rpmhpd", .data = &sdm845_desc },
784 { .compatible = "qcom,sdx55-rpmhpd", .data = &sdx55_desc},
785 { .compatible = "qcom,sdx65-rpmhpd", .data = &sdx65_desc},
786 { .compatible = "qcom,sdx75-rpmhpd", .data = &sdx75_desc},
787 { .compatible = "qcom,sm4450-rpmhpd", .data = &sm4450_desc },
788 { .compatible = "qcom,sm6350-rpmhpd", .data = &sm6350_desc },
789 { .compatible = "qcom,sm7150-rpmhpd", .data = &sm7150_desc },
790 { .compatible = "qcom,sm8150-rpmhpd", .data = &sm8150_desc },
791 { .compatible = "qcom,sm8250-rpmhpd", .data = &sm8250_desc },
792 { .compatible = "qcom,sm8350-rpmhpd", .data = &sm8350_desc },
793 { .compatible = "qcom,sm8450-rpmhpd", .data = &sm8450_desc },
794 { .compatible = "qcom,sm8550-rpmhpd", .data = &sm8550_desc },
795 { .compatible = "qcom,sm8650-rpmhpd", .data = &sm8650_desc },
796 { .compatible = "qcom,sm8750-rpmhpd", .data = &sm8750_desc },
797 { .compatible = "qcom,x1e80100-rpmhpd", .data = &x1e80100_desc },
802 static int rpmhpd_send_corner(struct rpmhpd *pd, int state, in rpmhpd_send_corner()
806 .addr = pd->addr, in rpmhpd_send_corner()
815 return rpmh_write(pd->dev, state, &cmd, 1); in rpmhpd_send_corner()
817 return rpmh_write_async(pd->dev, state, &cmd, 1); in rpmhpd_send_corner()
820 static void to_active_sleep(struct rpmhpd *pd, unsigned int corner, in to_active_sleep()
825 if (pd->active_only) in to_active_sleep()
840 static int rpmhpd_aggregate_corner(struct rpmhpd *pd, unsigned int corner) in rpmhpd_aggregate_corner()
843 struct rpmhpd *peer = pd->peer; in rpmhpd_aggregate_corner()
849 if (pd->state_synced) { in rpmhpd_aggregate_corner()
853 this_active_corner = pd->level_count - 1; in rpmhpd_aggregate_corner()
854 this_sleep_corner = pd->level_count - 1; in rpmhpd_aggregate_corner()
857 if (peer && peer->enabled) { in rpmhpd_aggregate_corner()
858 peer_enabled_corner = max(peer->corner, peer->enable_corner); in rpmhpd_aggregate_corner()
866 active_corner > pd->active_corner); in rpmhpd_aggregate_corner()
870 pd->active_corner = active_corner; in rpmhpd_aggregate_corner()
873 peer->active_corner = active_corner; in rpmhpd_aggregate_corner()
891 struct rpmhpd *pd = domain_to_rpmhpd(domain); in rpmhpd_power_on()
897 corner = max(pd->corner, pd->enable_corner); in rpmhpd_power_on()
900 pd->enabled = true; in rpmhpd_power_on()
909 struct rpmhpd *pd = domain_to_rpmhpd(domain); in rpmhpd_power_off()
916 pd->enabled = false; in rpmhpd_power_off()
926 struct rpmhpd *pd = domain_to_rpmhpd(domain); in rpmhpd_set_performance_state()
931 for (i = 0; i < pd->level_count; i++) in rpmhpd_set_performance_state()
932 if (level <= pd->level[i]) in rpmhpd_set_performance_state()
939 if (i == pd->level_count) in rpmhpd_set_performance_state()
940 i--; in rpmhpd_set_performance_state()
942 if (pd->enabled) { in rpmhpd_set_performance_state()
944 if (i < pd->enable_corner) in rpmhpd_set_performance_state()
945 i = pd->enable_corner; in rpmhpd_set_performance_state()
952 pd->corner = i; in rpmhpd_set_performance_state()
957 static int rpmhpd_update_level_mapping(struct rpmhpd *rpmhpd) in rpmhpd_update_level_mapping() argument
962 buf = cmd_db_read_aux_data(rpmhpd->res_name, &rpmhpd->level_count); in rpmhpd_update_level_mapping()
967 rpmhpd->level_count >>= 1; in rpmhpd_update_level_mapping()
969 if (rpmhpd->level_count > RPMH_ARC_MAX_LEVELS) in rpmhpd_update_level_mapping()
970 return -EINVAL; in rpmhpd_update_level_mapping()
972 for (i = 0; i < rpmhpd->level_count; i++) { in rpmhpd_update_level_mapping()
973 if (rpmhpd->skip_retention_level && buf[i] == RPMH_REGULATOR_LEVEL_RETENTION) in rpmhpd_update_level_mapping()
976 rpmhpd->level[i] = buf[i]; in rpmhpd_update_level_mapping()
978 /* Remember the first corner with non-zero level */ in rpmhpd_update_level_mapping()
979 if (!rpmhpd->level[rpmhpd->enable_corner] && rpmhpd->level[i]) in rpmhpd_update_level_mapping()
980 rpmhpd->enable_corner = i; in rpmhpd_update_level_mapping()
986 if (i > 0 && rpmhpd->level[i] == 0) { in rpmhpd_update_level_mapping()
987 rpmhpd->level_count = i; in rpmhpd_update_level_mapping()
990 pr_debug("%s: ARC hlvl=%2d --> vlvl=%4u\n", rpmhpd->res_name, i, in rpmhpd_update_level_mapping()
991 rpmhpd->level[i]); in rpmhpd_update_level_mapping()
1001 struct device *dev = &pdev->dev; in rpmhpd_probe()
1003 struct rpmhpd **rpmhpds; in rpmhpd_probe()
1008 return -EINVAL; in rpmhpd_probe()
1010 rpmhpds = desc->rpmhpds; in rpmhpd_probe()
1011 num_pds = desc->num_pds; in rpmhpd_probe()
1015 return -ENOMEM; in rpmhpd_probe()
1017 data->domains = devm_kcalloc(dev, num_pds, sizeof(*data->domains), in rpmhpd_probe()
1019 if (!data->domains) in rpmhpd_probe()
1020 return -ENOMEM; in rpmhpd_probe()
1022 data->num_domains = num_pds; in rpmhpd_probe()
1028 rpmhpds[i]->dev = dev; in rpmhpd_probe()
1029 rpmhpds[i]->addr = cmd_db_read_addr(rpmhpds[i]->res_name); in rpmhpd_probe()
1030 if (!rpmhpds[i]->addr) { in rpmhpd_probe()
1032 rpmhpds[i]->res_name); in rpmhpd_probe()
1033 return -ENODEV; in rpmhpd_probe()
1036 ret = cmd_db_read_slave_id(rpmhpds[i]->res_name); in rpmhpd_probe()
1039 return -EINVAL; in rpmhpd_probe()
1046 rpmhpds[i]->pd.power_off = rpmhpd_power_off; in rpmhpd_probe()
1047 rpmhpds[i]->pd.power_on = rpmhpd_power_on; in rpmhpd_probe()
1048 rpmhpds[i]->pd.set_performance_state = rpmhpd_set_performance_state; in rpmhpd_probe()
1049 pm_genpd_init(&rpmhpds[i]->pd, NULL, true); in rpmhpd_probe()
1051 data->domains[i] = &rpmhpds[i]->pd; in rpmhpd_probe()
1058 if (rpmhpds[i]->parent) in rpmhpd_probe()
1059 pm_genpd_add_subdomain(rpmhpds[i]->parent, in rpmhpd_probe()
1060 &rpmhpds[i]->pd); in rpmhpd_probe()
1063 return of_genpd_add_provider_onecell(pdev->dev.of_node, data); in rpmhpd_probe()
1069 struct rpmhpd **rpmhpds = desc->rpmhpds; in rpmhpd_sync_state()
1071 struct rpmhpd *pd; in rpmhpd_sync_state()
1075 of_genpd_sync_state(dev->of_node); in rpmhpd_sync_state()
1078 for (i = 0; i < desc->num_pds; i++) { in rpmhpd_sync_state()
1083 pd->state_synced = true; in rpmhpd_sync_state()
1084 if (pd->enabled) in rpmhpd_sync_state()
1085 corner = max(pd->corner, pd->enable_corner); in rpmhpd_sync_state()
1091 dev_err(dev, "failed to sync %s\n", pd->res_name); in rpmhpd_sync_state()
1098 .name = "qcom-rpmhpd",