Lines Matching refs:svsb

497 	struct svs_bank *svsb = svsp->pbank;  in svs_switch_bank()  local
499 svs_writel_relaxed(svsp, svsb->core_sel, CORESEL); in svs_switch_bank()
514 static int svs_sync_bank_volts_from_opp(struct svs_bank *svsb) in svs_sync_bank_volts_from_opp() argument
519 for (i = 0; i < svsb->opp_count; i++) { in svs_sync_bank_volts_from_opp()
520 opp = dev_pm_opp_find_freq_exact(svsb->opp_dev, in svs_sync_bank_volts_from_opp()
521 svsb->opp_dfreq[i], in svs_sync_bank_volts_from_opp()
524 dev_err(svsb->dev, "cannot find freq = %u (%ld)\n", in svs_sync_bank_volts_from_opp()
525 svsb->opp_dfreq[i], PTR_ERR(opp)); in svs_sync_bank_volts_from_opp()
530 svsb->volt[i] = svs_opp_volt_to_bank_volt(opp_u_volt, in svs_sync_bank_volts_from_opp()
531 svsb->volt_step, in svs_sync_bank_volts_from_opp()
532 svsb->volt_base); in svs_sync_bank_volts_from_opp()
539 static int svs_adjust_pm_opp_volts(struct svs_bank *svsb) in svs_adjust_pm_opp_volts() argument
544 mutex_lock(&svsb->lock); in svs_adjust_pm_opp_volts()
550 if (svsb->type == SVSB_HIGH) { in svs_adjust_pm_opp_volts()
552 opp_stop = svsb->turn_pt; in svs_adjust_pm_opp_volts()
553 } else if (svsb->type == SVSB_LOW) { in svs_adjust_pm_opp_volts()
554 opp_start = svsb->turn_pt; in svs_adjust_pm_opp_volts()
555 opp_stop = svsb->opp_count; in svs_adjust_pm_opp_volts()
558 opp_stop = svsb->opp_count; in svs_adjust_pm_opp_volts()
562 if (!IS_ERR_OR_NULL(svsb->tzd)) { in svs_adjust_pm_opp_volts()
563 ret = thermal_zone_get_temp(svsb->tzd, &tzone_temp); in svs_adjust_pm_opp_volts()
564 if (ret || (svsb->temp > SVSB_TEMP_UPPER_BOUND && in svs_adjust_pm_opp_volts()
565 svsb->temp < SVSB_TEMP_LOWER_BOUND)) { in svs_adjust_pm_opp_volts()
566 dev_err(svsb->dev, "%s: %d (0x%x), run default volts\n", in svs_adjust_pm_opp_volts()
567 svsb->tzone_name, ret, svsb->temp); in svs_adjust_pm_opp_volts()
568 svsb->phase = SVSB_PHASE_ERROR; in svs_adjust_pm_opp_volts()
571 if (tzone_temp >= svsb->tzone_htemp) in svs_adjust_pm_opp_volts()
572 temp_voffset += svsb->tzone_htemp_voffset; in svs_adjust_pm_opp_volts()
573 else if (tzone_temp <= svsb->tzone_ltemp) in svs_adjust_pm_opp_volts()
574 temp_voffset += svsb->tzone_ltemp_voffset; in svs_adjust_pm_opp_volts()
577 if (svsb->phase == SVSB_PHASE_MON && (svsb->type == SVSB_HIGH || in svs_adjust_pm_opp_volts()
578 svsb->type == SVSB_LOW)) { in svs_adjust_pm_opp_volts()
580 opp_stop = svsb->opp_count; in svs_adjust_pm_opp_volts()
586 switch (svsb->phase) { in svs_adjust_pm_opp_volts()
588 opp_volt = svsb->opp_dvolt[i]; in svs_adjust_pm_opp_volts()
595 svsb_volt = max(svsb->volt[i] + temp_voffset, svsb->vmin); in svs_adjust_pm_opp_volts()
597 svsb->volt_step, in svs_adjust_pm_opp_volts()
598 svsb->volt_base); in svs_adjust_pm_opp_volts()
601 dev_err(svsb->dev, "unknown phase: %u\n", svsb->phase); in svs_adjust_pm_opp_volts()
606 opp_volt = min(opp_volt, svsb->opp_dvolt[i]); in svs_adjust_pm_opp_volts()
607 ret = dev_pm_opp_adjust_voltage(svsb->opp_dev, in svs_adjust_pm_opp_volts()
608 svsb->opp_dfreq[i], in svs_adjust_pm_opp_volts()
610 svsb->opp_dvolt[i]); in svs_adjust_pm_opp_volts()
612 dev_err(svsb->dev, "set %uuV fail: %d\n", in svs_adjust_pm_opp_volts()
619 mutex_unlock(&svsb->lock); in svs_adjust_pm_opp_volts()
625 struct svs_bank *svsb) in svs_bank_disable_and_restore_default_volts() argument
629 if (svsb->mode_support == SVSB_MODE_ALL_DISABLE) in svs_bank_disable_and_restore_default_volts()
633 svsp->pbank = svsb; in svs_bank_disable_and_restore_default_volts()
639 svsb->phase = SVSB_PHASE_ERROR; in svs_bank_disable_and_restore_default_volts()
640 svs_adjust_pm_opp_volts(svsb); in svs_bank_disable_and_restore_default_volts()
647 struct svs_bank *svsb; in svs_dump_debug_show() local
662 svsb = &svsp->banks[idx]; in svs_dump_debug_show()
678 svs_reg_addr, svsb->reg_data[i][j]); in svs_dump_debug_show()
690 struct svs_bank *svsb = (struct svs_bank *)m->private; in svs_enable_debug_show() local
692 switch (svsb->phase) { in svs_enable_debug_show()
717 struct svs_bank *svsb = file_inode(filp)->i_private; in svs_enable_debug_write() local
718 struct svs_platform *svsp = dev_get_drvdata(svsb->dev); in svs_enable_debug_write()
734 svs_bank_disable_and_restore_default_volts(svsp, svsb); in svs_enable_debug_write()
735 svsb->mode_support = SVSB_MODE_ALL_DISABLE; in svs_enable_debug_write()
747 struct svs_bank *svsb = (struct svs_bank *)m->private; in svs_status_debug_show() local
752 ret = thermal_zone_get_temp(svsb->tzd, &tzone_temp); in svs_status_debug_show()
755 svsb->name, svsb->turn_pt); in svs_status_debug_show()
758 svsb->name, tzone_temp, svsb->turn_pt); in svs_status_debug_show()
760 for (i = 0; i < svsb->opp_count; i++) { in svs_status_debug_show()
761 opp = dev_pm_opp_find_freq_exact(svsb->opp_dev, in svs_status_debug_show()
762 svsb->opp_dfreq[i], true); in svs_status_debug_show()
765 svsb->name, svsb->opp_dfreq[i], in svs_status_debug_show()
771 i, svsb->opp_dfreq[i], i, in svs_status_debug_show()
774 i, svsb->volt[i], i, svsb->freq_pct[i]); in svs_status_debug_show()
785 struct svs_bank *svsb; in svs_create_debug_cmds() local
823 svsb = &svsp->banks[idx]; in svs_create_debug_cmds()
825 if (svsb->mode_support == SVSB_MODE_ALL_DISABLE) in svs_create_debug_cmds()
828 svsb_dir = debugfs_create_dir(svsb->name, svs_dir); in svs_create_debug_cmds()
831 d, svsb->name, PTR_ERR(svsb_dir)); in svs_create_debug_cmds()
837 0664, svsb_dir, svsb, in svs_create_debug_cmds()
841 d, svsb->name, svsb_entries[i].name, in svs_create_debug_cmds()
867 struct svs_bank *svsb = svsp->pbank; in svs_get_bank_volts_v3() local
868 u32 i, j, *vop, vop74, vop30, turn_pt = svsb->turn_pt; in svs_get_bank_volts_v3()
870 u32 middle_index = (svsb->opp_count / 2); in svs_get_bank_volts_v3()
872 if (svsb->phase == SVSB_PHASE_MON && in svs_get_bank_volts_v3()
873 svsb->volt_flags & SVSB_MON_VOLT_IGNORE) in svs_get_bank_volts_v3()
881 if (svsb->type == SVSB_HIGH) { in svs_get_bank_volts_v3()
887 svsb->volt[i] = (*vop >> b_sft) & GENMASK(7, 0); in svs_get_bank_volts_v3()
890 } else if (svsb->type == SVSB_LOW) { in svs_get_bank_volts_v3()
892 j = svsb->opp_count - 7; in svs_get_bank_volts_v3()
893 svsb->volt[turn_pt] = FIELD_GET(SVSB_VOPS_FLD_VOP0_4, vop30); in svs_get_bank_volts_v3()
895 for (i = j; i < svsb->opp_count; i++) { in svs_get_bank_volts_v3()
899 svsb->volt[i] = (*vop >> b_sft) & GENMASK(7, 0); in svs_get_bank_volts_v3()
905 svsb->volt[i] = interpolate(svsb->freq_pct[turn_pt], in svs_get_bank_volts_v3()
906 svsb->freq_pct[j], in svs_get_bank_volts_v3()
907 svsb->volt[turn_pt], in svs_get_bank_volts_v3()
908 svsb->volt[j], in svs_get_bank_volts_v3()
909 svsb->freq_pct[i]); in svs_get_bank_volts_v3()
912 if (svsb->type == SVSB_HIGH) { in svs_get_bank_volts_v3()
915 svsb->volt[0] = FIELD_GET(SVSB_VOPS_FLD_VOP0_4, vop30); in svs_get_bank_volts_v3()
921 svsb->volt[i] = (*vop >> b_sft) & GENMASK(7, 0); in svs_get_bank_volts_v3()
927 svsb->volt[i] = interpolate(svsb->freq_pct[0], in svs_get_bank_volts_v3()
928 svsb->freq_pct[j], in svs_get_bank_volts_v3()
929 svsb->volt[0], in svs_get_bank_volts_v3()
930 svsb->volt[j], in svs_get_bank_volts_v3()
931 svsb->freq_pct[i]); in svs_get_bank_volts_v3()
932 } else if (svsb->type == SVSB_LOW) { in svs_get_bank_volts_v3()
934 for (i = turn_pt; i < svsb->opp_count; i++) { in svs_get_bank_volts_v3()
938 svsb->volt[i] = (*vop >> b_sft) & GENMASK(7, 0); in svs_get_bank_volts_v3()
944 if (svsb->type == SVSB_HIGH) { in svs_get_bank_volts_v3()
946 opp_stop = svsb->turn_pt; in svs_get_bank_volts_v3()
947 } else if (svsb->type == SVSB_LOW) { in svs_get_bank_volts_v3()
948 opp_start = svsb->turn_pt; in svs_get_bank_volts_v3()
949 opp_stop = svsb->opp_count; in svs_get_bank_volts_v3()
953 if (svsb->volt_flags & SVSB_REMOVE_DVTFIXED_VOLT) in svs_get_bank_volts_v3()
954 svsb->volt[i] -= svsb->dvt_fixed; in svs_get_bank_volts_v3()
959 struct svs_bank *svsb = svsp->pbank; in svs_set_bank_freq_pct_v3() local
962 u32 middle_index = (svsb->opp_count / 2); in svs_set_bank_freq_pct_v3()
964 for (i = 0; i < svsb->opp_count; i++) { in svs_set_bank_freq_pct_v3()
965 if (svsb->opp_dfreq[i] <= svsb->turn_freq_base) { in svs_set_bank_freq_pct_v3()
966 svsb->turn_pt = i; in svs_set_bank_freq_pct_v3()
971 turn_pt = svsb->turn_pt; in svs_set_bank_freq_pct_v3()
975 if (svsb->type == SVSB_HIGH) { in svs_set_bank_freq_pct_v3()
982 freq_pct30 = svsb->freq_pct[0]; in svs_set_bank_freq_pct_v3()
989 *freq_pct |= (svsb->freq_pct[i] << b_sft); in svs_set_bank_freq_pct_v3()
992 } else if (svsb->type == SVSB_LOW) { in svs_set_bank_freq_pct_v3()
997 freq_pct30 = svsb->freq_pct[turn_pt]; in svs_set_bank_freq_pct_v3()
999 j = svsb->opp_count - 7; in svs_set_bank_freq_pct_v3()
1000 for (i = j; i < svsb->opp_count; i++) { in svs_set_bank_freq_pct_v3()
1004 *freq_pct |= (svsb->freq_pct[i] << b_sft); in svs_set_bank_freq_pct_v3()
1009 if (svsb->type == SVSB_HIGH) { in svs_set_bank_freq_pct_v3()
1014 freq_pct30 = svsb->freq_pct[0]; in svs_set_bank_freq_pct_v3()
1021 *freq_pct |= (svsb->freq_pct[i] << b_sft); in svs_set_bank_freq_pct_v3()
1024 } else if (svsb->type == SVSB_LOW) { in svs_set_bank_freq_pct_v3()
1026 for (i = turn_pt; i < svsb->opp_count; i++) { in svs_set_bank_freq_pct_v3()
1030 *freq_pct |= (svsb->freq_pct[i] << b_sft); in svs_set_bank_freq_pct_v3()
1042 struct svs_bank *svsb = svsp->pbank; in svs_get_bank_volts_v2() local
1046 svsb->volt[14] = FIELD_GET(SVSB_VOPS_FLD_VOP3_7, temp); in svs_get_bank_volts_v2()
1047 svsb->volt[12] = FIELD_GET(SVSB_VOPS_FLD_VOP2_6, temp); in svs_get_bank_volts_v2()
1048 svsb->volt[10] = FIELD_GET(SVSB_VOPS_FLD_VOP1_5, temp); in svs_get_bank_volts_v2()
1049 svsb->volt[8] = FIELD_GET(SVSB_VOPS_FLD_VOP0_4, temp); in svs_get_bank_volts_v2()
1052 svsb->volt[6] = FIELD_GET(SVSB_VOPS_FLD_VOP3_7, temp); in svs_get_bank_volts_v2()
1053 svsb->volt[4] = FIELD_GET(SVSB_VOPS_FLD_VOP2_6, temp); in svs_get_bank_volts_v2()
1054 svsb->volt[2] = FIELD_GET(SVSB_VOPS_FLD_VOP1_5, temp); in svs_get_bank_volts_v2()
1055 svsb->volt[0] = FIELD_GET(SVSB_VOPS_FLD_VOP0_4, temp); in svs_get_bank_volts_v2()
1058 svsb->volt[i + 1] = interpolate(svsb->freq_pct[i], in svs_get_bank_volts_v2()
1059 svsb->freq_pct[i + 2], in svs_get_bank_volts_v2()
1060 svsb->volt[i], in svs_get_bank_volts_v2()
1061 svsb->volt[i + 2], in svs_get_bank_volts_v2()
1062 svsb->freq_pct[i + 1]); in svs_get_bank_volts_v2()
1064 svsb->volt[15] = interpolate(svsb->freq_pct[12], in svs_get_bank_volts_v2()
1065 svsb->freq_pct[14], in svs_get_bank_volts_v2()
1066 svsb->volt[12], in svs_get_bank_volts_v2()
1067 svsb->volt[14], in svs_get_bank_volts_v2()
1068 svsb->freq_pct[15]); in svs_get_bank_volts_v2()
1070 for (i = 0; i < svsb->opp_count; i++) in svs_get_bank_volts_v2()
1071 svsb->volt[i] += svsb->volt_od; in svs_get_bank_volts_v2()
1076 struct svs_bank *svsb = svsp->pbank; in svs_set_bank_freq_pct_v2() local
1079 freqpct74_val = FIELD_PREP(SVSB_FREQPCTS_FLD_PCT0_4, svsb->freq_pct[8]) | in svs_set_bank_freq_pct_v2()
1080 FIELD_PREP(SVSB_FREQPCTS_FLD_PCT1_5, svsb->freq_pct[10]) | in svs_set_bank_freq_pct_v2()
1081 FIELD_PREP(SVSB_FREQPCTS_FLD_PCT2_6, svsb->freq_pct[12]) | in svs_set_bank_freq_pct_v2()
1082 FIELD_PREP(SVSB_FREQPCTS_FLD_PCT3_7, svsb->freq_pct[14]); in svs_set_bank_freq_pct_v2()
1084 freqpct30_val = FIELD_PREP(SVSB_FREQPCTS_FLD_PCT0_4, svsb->freq_pct[0]) | in svs_set_bank_freq_pct_v2()
1085 FIELD_PREP(SVSB_FREQPCTS_FLD_PCT1_5, svsb->freq_pct[2]) | in svs_set_bank_freq_pct_v2()
1086 FIELD_PREP(SVSB_FREQPCTS_FLD_PCT2_6, svsb->freq_pct[4]) | in svs_set_bank_freq_pct_v2()
1087 FIELD_PREP(SVSB_FREQPCTS_FLD_PCT3_7, svsb->freq_pct[6]); in svs_set_bank_freq_pct_v2()
1096 struct svs_bank *svsb = svsp->pbank; in svs_set_bank_phase() local
1101 des_char = FIELD_PREP(SVSB_DESCHAR_FLD_BDES, svsb->bdes) | in svs_set_bank_phase()
1102 FIELD_PREP(SVSB_DESCHAR_FLD_MDES, svsb->mdes); in svs_set_bank_phase()
1105 temp_char = FIELD_PREP(SVSB_TEMPCHAR_FLD_VCO, svsb->vco) | in svs_set_bank_phase()
1106 FIELD_PREP(SVSB_TEMPCHAR_FLD_MTDES, svsb->mtdes) | in svs_set_bank_phase()
1107 FIELD_PREP(SVSB_TEMPCHAR_FLD_DVT_FIXED, svsb->dvt_fixed); in svs_set_bank_phase()
1110 det_char = FIELD_PREP(SVSB_DETCHAR_FLD_DCBDET, svsb->dcbdet) | in svs_set_bank_phase()
1111 FIELD_PREP(SVSB_DETCHAR_FLD_DCMDET, svsb->dcmdet); in svs_set_bank_phase()
1114 svs_writel_relaxed(svsp, svsb->dc_config, DCCONFIG); in svs_set_bank_phase()
1115 svs_writel_relaxed(svsp, svsb->age_config, AGECONFIG); in svs_set_bank_phase()
1118 svsb->set_freq_pct(svsp); in svs_set_bank_phase()
1122 FIELD_PREP(SVSB_LIMITVALS_FLD_VMIN, svsb->vmin) | in svs_set_bank_phase()
1123 FIELD_PREP(SVSB_LIMITVALS_FLD_VMAX, svsb->vmax); in svs_set_bank_phase()
1128 svs_writel_relaxed(svsp, svsb->chk_shift, CHKSHIFT); in svs_set_bank_phase()
1129 svs_writel_relaxed(svsp, svsb->ctl0, CTL0); in svs_set_bank_phase()
1134 svs_writel_relaxed(svsp, svsb->vboot, VBOOT); in svs_set_bank_phase()
1139 init2vals = FIELD_PREP(SVSB_INIT2VALS_FLD_AGEVOFFSETIN, svsb->age_voffset_in) | in svs_set_bank_phase()
1140 FIELD_PREP(SVSB_INIT2VALS_FLD_DCVOFFSETIN, svsb->dc_voffset_in); in svs_set_bank_phase()
1146 ts_calcs = FIELD_PREP(SVSB_TSCALCS_FLD_BTS, svsb->bts) | in svs_set_bank_phase()
1147 FIELD_PREP(SVSB_TSCALCS_FLD_MTS, svsb->mts); in svs_set_bank_phase()
1153 dev_err(svsb->dev, "requested unknown target phase: %u\n", in svs_set_bank_phase()
1162 struct svs_bank *svsb = svsp->pbank; in svs_save_bank_register_data() local
1166 svsb->reg_data[phase][rg_i] = svs_readl_relaxed(svsp, rg_i); in svs_save_bank_register_data()
1171 struct svs_bank *svsb = svsp->pbank; in svs_error_isr_handler() local
1173 dev_err(svsb->dev, "%s: CORESEL = 0x%08x\n", in svs_error_isr_handler()
1175 dev_err(svsb->dev, "SVSEN = 0x%08x, INTSTS = 0x%08x\n", in svs_error_isr_handler()
1178 dev_err(svsb->dev, "SMSTATE0 = 0x%08x, SMSTATE1 = 0x%08x\n", in svs_error_isr_handler()
1181 dev_err(svsb->dev, "TEMP = 0x%08x\n", svs_readl_relaxed(svsp, TEMP)); in svs_error_isr_handler()
1185 svsb->phase = SVSB_PHASE_ERROR; in svs_error_isr_handler()
1192 struct svs_bank *svsb = svsp->pbank; in svs_init01_isr_handler() local
1194 dev_info(svsb->dev, "%s: VDN74~30:0x%08x~0x%08x, DC:0x%08x\n", in svs_init01_isr_handler()
1201 svsb->phase = SVSB_PHASE_INIT01; in svs_init01_isr_handler()
1202 svsb->dc_voffset_in = ~(svs_readl_relaxed(svsp, DCVALUES) & in svs_init01_isr_handler()
1204 if (svsb->volt_flags & SVSB_INIT01_VOLT_IGNORE || in svs_init01_isr_handler()
1205 (svsb->dc_voffset_in & SVSB_DC_SIGNED_BIT && in svs_init01_isr_handler()
1206 svsb->volt_flags & SVSB_INIT01_VOLT_INC_ONLY)) in svs_init01_isr_handler()
1207 svsb->dc_voffset_in = 0; in svs_init01_isr_handler()
1209 svsb->age_voffset_in = svs_readl_relaxed(svsp, AGEVALUES) & in svs_init01_isr_handler()
1214 svsb->core_sel &= ~SVSB_DET_CLK_EN; in svs_init01_isr_handler()
1219 struct svs_bank *svsb = svsp->pbank; in svs_init02_isr_handler() local
1221 dev_info(svsb->dev, "%s: VOP74~30:0x%08x~0x%08x, DC:0x%08x\n", in svs_init02_isr_handler()
1228 svsb->phase = SVSB_PHASE_INIT02; in svs_init02_isr_handler()
1229 svsb->get_volts(svsp); in svs_init02_isr_handler()
1237 struct svs_bank *svsb = svsp->pbank; in svs_mon_mode_isr_handler() local
1241 svsb->phase = SVSB_PHASE_MON; in svs_mon_mode_isr_handler()
1242 svsb->get_volts(svsp); in svs_mon_mode_isr_handler()
1244 svsb->temp = svs_readl_relaxed(svsp, TEMP) & GENMASK(7, 0); in svs_mon_mode_isr_handler()
1251 struct svs_bank *svsb = NULL; in svs_isr() local
1256 svsb = &svsp->banks[idx]; in svs_isr()
1257 WARN(!svsb, "%s: svsb(%s) is null", __func__, svsb->name); in svs_isr()
1260 svsp->pbank = svsb; in svs_isr()
1263 if (svsb->int_st & svs_readl_relaxed(svsp, INTST)) { in svs_isr()
1287 svs_adjust_pm_opp_volts(svsb); in svs_isr()
1289 if (svsb->phase == SVSB_PHASE_INIT01 || in svs_isr()
1290 svsb->phase == SVSB_PHASE_INIT02) in svs_isr()
1291 complete(&svsb->init_completion); in svs_isr()
1298 struct svs_bank *svsb; in svs_init01() local
1309 svsb = &svsp->banks[idx]; in svs_init01()
1311 if (!(svsb->mode_support & SVSB_MODE_INIT01)) in svs_init01()
1314 ret = regulator_enable(svsb->buck); in svs_init01()
1316 dev_err(svsb->dev, "%s enable fail: %d\n", in svs_init01()
1317 svsb->buck_name, ret); in svs_init01()
1322 ret = regulator_set_mode(svsb->buck, REGULATOR_MODE_FAST); in svs_init01()
1324 dev_notice(svsb->dev, "set fast mode fail: %d\n", ret); in svs_init01()
1326 if (svsb->volt_flags & SVSB_INIT01_PD_REQ) { in svs_init01()
1327 if (!pm_runtime_enabled(svsb->opp_dev)) { in svs_init01()
1328 pm_runtime_enable(svsb->opp_dev); in svs_init01()
1329 svsb->pm_runtime_enabled_count++; in svs_init01()
1332 ret = pm_runtime_resume_and_get(svsb->opp_dev); in svs_init01()
1334 dev_err(svsb->dev, "mtcmos on fail: %d\n", ret); in svs_init01()
1346 svsb = &svsp->banks[idx]; in svs_init01()
1348 if (!(svsb->mode_support & SVSB_MODE_INIT01)) in svs_init01()
1356 opp_vboot = svs_bank_volt_to_opp_volt(svsb->vboot, in svs_init01()
1357 svsb->volt_step, in svs_init01()
1358 svsb->volt_base); in svs_init01()
1360 for (i = 0; i < svsb->opp_count; i++) { in svs_init01()
1361 opp_freq = svsb->opp_dfreq[i]; in svs_init01()
1362 if (!search_done && svsb->opp_dvolt[i] <= opp_vboot) { in svs_init01()
1363 ret = dev_pm_opp_adjust_voltage(svsb->opp_dev, in svs_init01()
1369 dev_err(svsb->dev, in svs_init01()
1377 ret = dev_pm_opp_disable(svsb->opp_dev, in svs_init01()
1378 svsb->opp_dfreq[i]); in svs_init01()
1380 dev_err(svsb->dev, in svs_init01()
1382 svsb->opp_dfreq[i], ret); in svs_init01()
1391 svsb = &svsp->banks[idx]; in svs_init01()
1393 if (!(svsb->mode_support & SVSB_MODE_INIT01)) in svs_init01()
1396 opp_vboot = svs_bank_volt_to_opp_volt(svsb->vboot, in svs_init01()
1397 svsb->volt_step, in svs_init01()
1398 svsb->volt_base); in svs_init01()
1400 buck_volt = regulator_get_voltage(svsb->buck); in svs_init01()
1402 dev_err(svsb->dev, in svs_init01()
1410 svsp->pbank = svsb; in svs_init01()
1414 time_left = wait_for_completion_timeout(&svsb->init_completion, in svs_init01()
1417 dev_err(svsb->dev, "init01 completion timeout\n"); in svs_init01()
1425 svsb = &svsp->banks[idx]; in svs_init01()
1427 if (!(svsb->mode_support & SVSB_MODE_INIT01)) in svs_init01()
1430 for (i = 0; i < svsb->opp_count; i++) { in svs_init01()
1431 r = dev_pm_opp_enable(svsb->opp_dev, in svs_init01()
1432 svsb->opp_dfreq[i]); in svs_init01()
1434 dev_err(svsb->dev, "opp %uHz enable fail: %d\n", in svs_init01()
1435 svsb->opp_dfreq[i], r); in svs_init01()
1438 if (svsb->volt_flags & SVSB_INIT01_PD_REQ) { in svs_init01()
1439 r = pm_runtime_put_sync(svsb->opp_dev); in svs_init01()
1441 dev_err(svsb->dev, "mtcmos off fail: %d\n", r); in svs_init01()
1443 if (svsb->pm_runtime_enabled_count > 0) { in svs_init01()
1444 pm_runtime_disable(svsb->opp_dev); in svs_init01()
1445 svsb->pm_runtime_enabled_count--; in svs_init01()
1449 r = regulator_set_mode(svsb->buck, REGULATOR_MODE_NORMAL); in svs_init01()
1451 dev_notice(svsb->dev, "set normal mode fail: %d\n", r); in svs_init01()
1453 r = regulator_disable(svsb->buck); in svs_init01()
1455 dev_err(svsb->dev, "%s disable fail: %d\n", in svs_init01()
1456 svsb->buck_name, r); in svs_init01()
1467 struct svs_bank *svsb; in svs_init02() local
1473 svsb = &svsp->banks[idx]; in svs_init02()
1475 if (!(svsb->mode_support & SVSB_MODE_INIT02)) in svs_init02()
1478 reinit_completion(&svsb->init_completion); in svs_init02()
1480 svsp->pbank = svsb; in svs_init02()
1484 time_left = wait_for_completion_timeout(&svsb->init_completion, in svs_init02()
1487 dev_err(svsb->dev, "init02 completion timeout\n"); in svs_init02()
1499 svsb = &svsp->banks[idx]; in svs_init02()
1501 if (!(svsb->mode_support & SVSB_MODE_INIT02)) in svs_init02()
1504 if (svsb->type == SVSB_HIGH || svsb->type == SVSB_LOW) { in svs_init02()
1505 if (svs_sync_bank_volts_from_opp(svsb)) { in svs_init02()
1506 dev_err(svsb->dev, "sync volt fail\n"); in svs_init02()
1517 svsb = &svsp->banks[idx]; in svs_init02()
1518 svs_bank_disable_and_restore_default_volts(svsp, svsb); in svs_init02()
1526 struct svs_bank *svsb; in svs_mon_mode() local
1531 svsb = &svsp->banks[idx]; in svs_mon_mode()
1533 if (!(svsb->mode_support & SVSB_MODE_MON)) in svs_mon_mode()
1537 svsp->pbank = svsb; in svs_mon_mode()
1563 struct svs_bank *svsb; in svs_suspend() local
1568 svsb = &svsp->banks[idx]; in svs_suspend()
1569 svs_bank_disable_and_restore_default_volts(svsp, svsb); in svs_suspend()
1619 struct svs_bank *svsb; in svs_bank_resource_setup() local
1628 svsb = &svsp->banks[idx]; in svs_bank_resource_setup()
1630 switch (svsb->sw_id) { in svs_bank_resource_setup()
1632 svsb->name = "SVSB_CPU_LITTLE"; in svs_bank_resource_setup()
1635 svsb->name = "SVSB_CPU_BIG"; in svs_bank_resource_setup()
1638 svsb->name = "SVSB_CCI"; in svs_bank_resource_setup()
1641 if (svsb->type == SVSB_HIGH) in svs_bank_resource_setup()
1642 svsb->name = "SVSB_GPU_HIGH"; in svs_bank_resource_setup()
1643 else if (svsb->type == SVSB_LOW) in svs_bank_resource_setup()
1644 svsb->name = "SVSB_GPU_LOW"; in svs_bank_resource_setup()
1646 svsb->name = "SVSB_GPU"; in svs_bank_resource_setup()
1649 dev_err(svsb->dev, "unknown sw_id: %u\n", svsb->sw_id); in svs_bank_resource_setup()
1653 svsb->dev = devm_kzalloc(svsp->dev, sizeof(*svsb->dev), in svs_bank_resource_setup()
1655 if (!svsb->dev) in svs_bank_resource_setup()
1658 ret = dev_set_name(svsb->dev, "%s", svsb->name); in svs_bank_resource_setup()
1662 dev_set_drvdata(svsb->dev, svsp); in svs_bank_resource_setup()
1664 ret = devm_pm_opp_of_add_table(svsb->opp_dev); in svs_bank_resource_setup()
1666 dev_err(svsb->dev, "add opp table fail: %d\n", ret); in svs_bank_resource_setup()
1670 mutex_init(&svsb->lock); in svs_bank_resource_setup()
1671 init_completion(&svsb->init_completion); in svs_bank_resource_setup()
1673 if (svsb->mode_support & SVSB_MODE_INIT01) { in svs_bank_resource_setup()
1674 svsb->buck = devm_regulator_get_optional(svsb->opp_dev, in svs_bank_resource_setup()
1675 svsb->buck_name); in svs_bank_resource_setup()
1676 if (IS_ERR(svsb->buck)) { in svs_bank_resource_setup()
1677 dev_err(svsb->dev, "cannot get \"%s-supply\"\n", in svs_bank_resource_setup()
1678 svsb->buck_name); in svs_bank_resource_setup()
1679 return PTR_ERR(svsb->buck); in svs_bank_resource_setup()
1683 if (!IS_ERR_OR_NULL(svsb->tzone_name)) { in svs_bank_resource_setup()
1684 svsb->tzd = thermal_zone_get_zone_by_name(svsb->tzone_name); in svs_bank_resource_setup()
1685 if (IS_ERR(svsb->tzd)) { in svs_bank_resource_setup()
1686 dev_err(svsb->dev, "cannot get \"%s\" thermal zone\n", in svs_bank_resource_setup()
1687 svsb->tzone_name); in svs_bank_resource_setup()
1688 return PTR_ERR(svsb->tzd); in svs_bank_resource_setup()
1692 count = dev_pm_opp_get_opp_count(svsb->opp_dev); in svs_bank_resource_setup()
1693 if (svsb->opp_count != count) { in svs_bank_resource_setup()
1694 dev_err(svsb->dev, in svs_bank_resource_setup()
1696 svsb->opp_count, count); in svs_bank_resource_setup()
1700 for (i = 0, freq = U32_MAX; i < svsb->opp_count; i++, freq--) { in svs_bank_resource_setup()
1701 opp = dev_pm_opp_find_freq_floor(svsb->opp_dev, &freq); in svs_bank_resource_setup()
1703 dev_err(svsb->dev, "cannot find freq = %ld\n", in svs_bank_resource_setup()
1708 svsb->opp_dfreq[i] = freq; in svs_bank_resource_setup()
1709 svsb->opp_dvolt[i] = dev_pm_opp_get_voltage(opp); in svs_bank_resource_setup()
1710 svsb->freq_pct[i] = percent(svsb->opp_dfreq[i], in svs_bank_resource_setup()
1711 svsb->freq_base); in svs_bank_resource_setup()
1748 struct svs_bank *svsb; in svs_mt8192_efuse_parsing() local
1766 svsb = &svsp->banks[idx]; in svs_mt8192_efuse_parsing()
1769 svsb->vmin = 0x1e; in svs_mt8192_efuse_parsing()
1771 if (svsb->type == SVSB_LOW) { in svs_mt8192_efuse_parsing()
1772 svsb->mtdes = svsp->efuse[10] & GENMASK(7, 0); in svs_mt8192_efuse_parsing()
1773 svsb->bdes = (svsp->efuse[10] >> 16) & GENMASK(7, 0); in svs_mt8192_efuse_parsing()
1774 svsb->mdes = (svsp->efuse[10] >> 24) & GENMASK(7, 0); in svs_mt8192_efuse_parsing()
1775 svsb->dcbdet = (svsp->efuse[17]) & GENMASK(7, 0); in svs_mt8192_efuse_parsing()
1776 svsb->dcmdet = (svsp->efuse[17] >> 8) & GENMASK(7, 0); in svs_mt8192_efuse_parsing()
1777 } else if (svsb->type == SVSB_HIGH) { in svs_mt8192_efuse_parsing()
1778 svsb->mtdes = svsp->efuse[9] & GENMASK(7, 0); in svs_mt8192_efuse_parsing()
1779 svsb->bdes = (svsp->efuse[9] >> 16) & GENMASK(7, 0); in svs_mt8192_efuse_parsing()
1780 svsb->mdes = (svsp->efuse[9] >> 24) & GENMASK(7, 0); in svs_mt8192_efuse_parsing()
1781 svsb->dcbdet = (svsp->efuse[17] >> 16) & GENMASK(7, 0); in svs_mt8192_efuse_parsing()
1782 svsb->dcmdet = (svsp->efuse[17] >> 24) & GENMASK(7, 0); in svs_mt8192_efuse_parsing()
1785 svsb->vmax += svsb->dvt_fixed; in svs_mt8192_efuse_parsing()
1803 svsb = &svsp->banks[idx]; in svs_mt8192_efuse_parsing()
1804 svsb->mts = 500; in svs_mt8192_efuse_parsing()
1805 svsb->bts = (((500 * golden_temp + 250460) / 1000) - 25) * 4; in svs_mt8192_efuse_parsing()
1813 struct svs_bank *svsb; in svs_mt8183_efuse_parsing() local
1834 svsb = &svsp->banks[idx]; in svs_mt8183_efuse_parsing()
1837 svsb->volt_flags |= SVSB_INIT01_VOLT_IGNORE; in svs_mt8183_efuse_parsing()
1839 switch (svsb->sw_id) { in svs_mt8183_efuse_parsing()
1841 svsb->bdes = svsp->efuse[16] & GENMASK(7, 0); in svs_mt8183_efuse_parsing()
1842 svsb->mdes = (svsp->efuse[16] >> 8) & GENMASK(7, 0); in svs_mt8183_efuse_parsing()
1843 svsb->dcbdet = (svsp->efuse[16] >> 16) & GENMASK(7, 0); in svs_mt8183_efuse_parsing()
1844 svsb->dcmdet = (svsp->efuse[16] >> 24) & GENMASK(7, 0); in svs_mt8183_efuse_parsing()
1845 svsb->mtdes = (svsp->efuse[17] >> 16) & GENMASK(7, 0); in svs_mt8183_efuse_parsing()
1848 svsb->volt_od += 10; in svs_mt8183_efuse_parsing()
1850 svsb->volt_od += 2; in svs_mt8183_efuse_parsing()
1853 svsb->bdes = svsp->efuse[18] & GENMASK(7, 0); in svs_mt8183_efuse_parsing()
1854 svsb->mdes = (svsp->efuse[18] >> 8) & GENMASK(7, 0); in svs_mt8183_efuse_parsing()
1855 svsb->dcbdet = (svsp->efuse[18] >> 16) & GENMASK(7, 0); in svs_mt8183_efuse_parsing()
1856 svsb->dcmdet = (svsp->efuse[18] >> 24) & GENMASK(7, 0); in svs_mt8183_efuse_parsing()
1857 svsb->mtdes = svsp->efuse[17] & GENMASK(7, 0); in svs_mt8183_efuse_parsing()
1860 svsb->volt_od += 15; in svs_mt8183_efuse_parsing()
1862 svsb->volt_od += 12; in svs_mt8183_efuse_parsing()
1865 svsb->bdes = svsp->efuse[4] & GENMASK(7, 0); in svs_mt8183_efuse_parsing()
1866 svsb->mdes = (svsp->efuse[4] >> 8) & GENMASK(7, 0); in svs_mt8183_efuse_parsing()
1867 svsb->dcbdet = (svsp->efuse[4] >> 16) & GENMASK(7, 0); in svs_mt8183_efuse_parsing()
1868 svsb->dcmdet = (svsp->efuse[4] >> 24) & GENMASK(7, 0); in svs_mt8183_efuse_parsing()
1869 svsb->mtdes = (svsp->efuse[5] >> 16) & GENMASK(7, 0); in svs_mt8183_efuse_parsing()
1872 svsb->volt_od += 10; in svs_mt8183_efuse_parsing()
1874 svsb->volt_od += 2; in svs_mt8183_efuse_parsing()
1877 svsb->bdes = svsp->efuse[6] & GENMASK(7, 0); in svs_mt8183_efuse_parsing()
1878 svsb->mdes = (svsp->efuse[6] >> 8) & GENMASK(7, 0); in svs_mt8183_efuse_parsing()
1879 svsb->dcbdet = (svsp->efuse[6] >> 16) & GENMASK(7, 0); in svs_mt8183_efuse_parsing()
1880 svsb->dcmdet = (svsp->efuse[6] >> 24) & GENMASK(7, 0); in svs_mt8183_efuse_parsing()
1881 svsb->mtdes = svsp->efuse[5] & GENMASK(7, 0); in svs_mt8183_efuse_parsing()
1884 svsb->freq_base = 800000000; /* 800MHz */ in svs_mt8183_efuse_parsing()
1885 svsb->dvt_fixed = 2; in svs_mt8183_efuse_parsing()
1889 dev_err(svsb->dev, "unknown sw_id: %u\n", svsb->sw_id); in svs_mt8183_efuse_parsing()
1957 svsb = &svsp->banks[idx]; in svs_mt8183_efuse_parsing()
1958 svsb->mts = mts; in svs_mt8183_efuse_parsing()
1960 switch (svsb->sw_id) { in svs_mt8183_efuse_parsing()
1974 dev_err(svsb->dev, "unknown sw_id: %u\n", svsb->sw_id); in svs_mt8183_efuse_parsing()
1983 svsb->bts = (temp0 + temp2 - 250) * 4 / 10; in svs_mt8183_efuse_parsing()
1990 svsb = &svsp->banks[idx]; in svs_mt8183_efuse_parsing()
1991 svsb->mode_support &= ~SVSB_MODE_MON; in svs_mt8183_efuse_parsing()
2047 struct svs_bank *svsb; in svs_mt8192_platform_probe() local
2061 svsb = &svsp->banks[idx]; in svs_mt8192_platform_probe()
2063 if (svsb->type == SVSB_HIGH) in svs_mt8192_platform_probe()
2064 svsb->opp_dev = svs_add_device_link(svsp, "gpu"); in svs_mt8192_platform_probe()
2065 else if (svsb->type == SVSB_LOW) in svs_mt8192_platform_probe()
2066 svsb->opp_dev = svs_get_subsys_device(svsp, "gpu"); in svs_mt8192_platform_probe()
2068 if (IS_ERR(svsb->opp_dev)) in svs_mt8192_platform_probe()
2069 return dev_err_probe(svsp->dev, PTR_ERR(svsb->opp_dev), in svs_mt8192_platform_probe()
2080 struct svs_bank *svsb; in svs_mt8183_platform_probe() local
2089 svsb = &svsp->banks[idx]; in svs_mt8183_platform_probe()
2091 switch (svsb->sw_id) { in svs_mt8183_platform_probe()
2094 svsb->opp_dev = get_cpu_device(svsb->cpu_id); in svs_mt8183_platform_probe()
2097 svsb->opp_dev = svs_add_device_link(svsp, "cci"); in svs_mt8183_platform_probe()
2100 svsb->opp_dev = svs_add_device_link(svsp, "gpu"); in svs_mt8183_platform_probe()
2103 dev_err(svsb->dev, "unknown sw_id: %u\n", svsb->sw_id); in svs_mt8183_platform_probe()
2107 if (IS_ERR(svsb->opp_dev)) in svs_mt8183_platform_probe()
2108 return dev_err_probe(svsp->dev, PTR_ERR(svsb->opp_dev), in svs_mt8183_platform_probe()