Lines Matching refs:ret
146 int ret = pmbus_read_word_data(client, page, phase, reg); in mp2975_read_word_helper() local
148 return (ret > 0) ? ret & mask : ret; in mp2975_read_word_helper()
212 int ph_curr, ret; in mp2975_read_phase() local
214 ret = pmbus_read_word_data(client, page, phase, reg); in mp2975_read_phase()
215 if (ret < 0) in mp2975_read_phase()
216 return ret; in mp2975_read_phase()
219 ret >>= 8; in mp2975_read_phase()
220 ret &= 0xff; in mp2975_read_phase()
232 ph_curr = ret * 100 - 9800; in mp2975_read_phase()
241 ret = pmbus_read_word_data(client, page, phase, PMBUS_READ_IOUT); in mp2975_read_phase()
242 if (ret < 0) in mp2975_read_phase()
243 return ret; in mp2975_read_phase()
245 return max_t(int, DIV_ROUND_CLOSEST(ret, data->info.phases[page]), in mp2975_read_phase()
253 int ret; in mp2975_read_phases() local
258 ret = mp2975_read_phase(client, data, page, phase, in mp2975_read_phases()
262 ret = mp2975_read_phase(client, data, page, phase, in mp2975_read_phases()
266 ret = mp2975_read_phase(client, data, page, phase, in mp2975_read_phases()
275 ret = mp2975_read_phase(client, data, page, phase, in mp2975_read_phases()
279 ret = mp2975_read_phase(client, data, page, phase, in mp2975_read_phases()
283 ret = mp2975_read_phase(client, data, page, phase, in mp2975_read_phases()
287 ret = mp2975_read_phase(client, data, page, phase, in mp2975_read_phases()
291 ret = mp2975_read_phase(client, data, page, phase, in mp2975_read_phases()
295 ret = mp2975_read_phase(client, data, page, phase, in mp2975_read_phases()
302 return ret; in mp2975_read_phases()
310 int ret; in mp2973_read_word_data() local
315 ret = pmbus_read_word_data(client, page, phase, reg); in mp2973_read_word_data()
316 ret ^= PB_STATUS_POWER_GOOD_N; in mp2973_read_word_data()
319 ret = mp2975_read_word_helper(client, page, phase, reg, in mp2973_read_word_data()
323 ret = mp2975_read_word_helper(client, page, phase, reg, in mp2973_read_word_data()
325 if (ret < 0) in mp2973_read_word_data()
326 return ret; in mp2973_read_word_data()
328 ret = DIV_ROUND_CLOSEST(ret, MP2975_VIN_UV_LIMIT_UNIT); in mp2973_read_word_data()
334 ret = mp2975_read_word_helper(client, page, phase, in mp2973_read_word_data()
337 if (ret < 0) in mp2973_read_word_data()
338 return ret; in mp2973_read_word_data()
340 ret = data->vout_max[page] + 50 * (ret + 1); in mp2973_read_word_data()
343 ret = mp2975_read_word_helper(client, page, phase, reg, in mp2973_read_word_data()
345 if (ret < 0) in mp2973_read_word_data()
346 return ret; in mp2973_read_word_data()
347 ret = mp2975_vid2direct(info->vrm_version[page], ret); in mp2973_read_word_data()
350 ret = pmbus_read_word_data(client, page, phase, in mp2973_read_word_data()
354 ret = pmbus_read_word_data(client, page, phase, in mp2973_read_word_data()
358 ret = mp2975_read_word_helper(client, page, phase, in mp2973_read_word_data()
361 if (ret < 0) in mp2973_read_word_data()
362 return ret; in mp2973_read_word_data()
364 if (ret & MP2973_MFR_OCP_LEVEL_RES) in mp2973_read_word_data()
365 ret = 2 * (ret & MP2973_OCP_TOTAL_CUR_MASK); in mp2973_read_word_data()
367 ret = ret & MP2973_OCP_TOTAL_CUR_MASK; in mp2973_read_word_data()
369 ret = mp2975_data2reg_linear11(ret * info->phases[page] * 1000); in mp2973_read_word_data()
390 return ret; in mp2973_read_word_data()
397 long ret; in mp2973_write_word_data() local
405 ret = pmbus_read_word_data(client, 0, 0, PMBUS_SMBALERT_MASK); in mp2973_write_word_data()
406 if (ret < 0) in mp2973_write_word_data()
407 return ret; in mp2973_write_word_data()
434 __assign_bit(MP2973_INVALID_DATA, &ret, !(mask & PB_CML_FAULT_INVALID_DATA)); in mp2973_write_word_data()
435 __assign_bit(MP2973_INVALID_COMMAND, &ret, !(mask & PB_CML_FAULT_INVALID_COMMAND)); in mp2973_write_word_data()
436 __assign_bit(MP2973_OTHER_COMM, &ret, !(mask & PB_CML_FAULT_OTHER_COMM)); in mp2973_write_word_data()
437 __assign_bit(MP2973_PACKET_ERROR, &ret, !(mask & PB_CML_FAULT_PACKET_ERROR)); in mp2973_write_word_data()
440 __assign_bit(MP2973_VOLTAGE_UV, &ret, !(mask & PB_VOLTAGE_UV_FAULT)); in mp2973_write_word_data()
441 __assign_bit(MP2973_VOLTAGE_OV, &ret, !(mask & PB_VOLTAGE_OV_FAULT)); in mp2973_write_word_data()
444 __assign_bit(MP2973_IOUT_OC, &ret, !(mask & PB_IOUT_OC_FAULT)); in mp2973_write_word_data()
445 __assign_bit(MP2973_IOUT_OC_LV, &ret, !(mask & PB_IOUT_OC_LV_FAULT)); in mp2973_write_word_data()
448 __assign_bit(MP2973_TEMP_OT, &ret, !(mask & PB_TEMP_OT_FAULT)); in mp2973_write_word_data()
455 __assign_bit(MP2973_VIN_UVLO, &ret, !(mask & BIT(1))); in mp2973_write_word_data()
456 __assign_bit(MP2973_VIN_OVP, &ret, !(mask & BIT(3))); in mp2973_write_word_data()
457 __assign_bit(MP2973_MTP_FAULT, &ret, !(mask & BIT(4))); in mp2973_write_word_data()
458 __assign_bit(MP2973_MTP_BLK_TRIG, &ret, !(mask & BIT(6))); in mp2973_write_word_data()
464 return pmbus_write_word_data(client, 0, PMBUS_SMBALERT_MASK, ret); in mp2973_write_word_data()
472 int ret; in mp2975_read_word_data() local
476 ret = mp2975_read_word_helper(client, page, phase, reg, in mp2975_read_word_data()
480 ret = mp2975_read_word_helper(client, page, phase, reg, in mp2975_read_word_data()
482 if (ret < 0) in mp2975_read_word_data()
483 return ret; in mp2975_read_word_data()
485 ret = DIV_ROUND_CLOSEST(ret, MP2975_VIN_UV_LIMIT_UNIT); in mp2975_read_word_data()
494 ret = mp2975_read_word_helper(client, page, phase, in mp2975_read_word_data()
497 if (ret < 0) in mp2975_read_word_data()
498 return ret; in mp2975_read_word_data()
500 ret = min_t(int, data->vout_max[page] + 50 * (ret + 1), in mp2975_read_word_data()
504 ret = mp2975_read_word_helper(client, page, phase, in mp2975_read_word_data()
507 if (ret < 0) in mp2975_read_word_data()
508 return ret; in mp2975_read_word_data()
510 ret = DIV_ROUND_CLOSEST(data->vref[page] * 10 - 50 * in mp2975_read_word_data()
511 (ret + 1) * data->vout_scale, 10); in mp2975_read_word_data()
514 ret = mp2975_read_word_helper(client, page, phase, in mp2975_read_word_data()
517 if (ret < 0) in mp2975_read_word_data()
518 return ret; in mp2975_read_word_data()
520 ret = DIV_ROUND_CLOSEST(ret, 4); in mp2975_read_word_data()
523 ret = mp2975_read_word_helper(client, page, phase, in mp2975_read_word_data()
526 if (ret < 0) in mp2975_read_word_data()
527 return ret; in mp2975_read_word_data()
529 ret = DIV_ROUND_CLOSEST(ret, 4); in mp2975_read_word_data()
532 ret = mp2975_read_phases(client, data, page, phase); in mp2975_read_word_data()
533 if (ret < 0) in mp2975_read_word_data()
534 return ret; in mp2975_read_word_data()
558 return ret; in mp2975_read_word_data()
564 int ret; in mp2975_identify_multiphase_rail2() local
570 ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, 2); in mp2975_identify_multiphase_rail2()
571 if (ret < 0) in mp2975_identify_multiphase_rail2()
572 return ret; in mp2975_identify_multiphase_rail2()
574 ret = i2c_smbus_read_word_data(client, MP2975_MFR_VR_MULTI_CONFIG_R2); in mp2975_identify_multiphase_rail2()
575 if (ret < 0) in mp2975_identify_multiphase_rail2()
576 return ret; in mp2975_identify_multiphase_rail2()
578 ret &= GENMASK(2, 0); in mp2975_identify_multiphase_rail2()
579 return (ret >= data->max_phases[1]) ? data->max_phases[1] : ret; in mp2975_identify_multiphase_rail2()
604 int num_phases2, ret; in mp2975_identify_multiphase() local
606 ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, 2); in mp2975_identify_multiphase()
607 if (ret < 0) in mp2975_identify_multiphase()
608 return ret; in mp2975_identify_multiphase()
611 ret = i2c_smbus_read_word_data(client, MP2975_MFR_VR_MULTI_CONFIG_R1); in mp2975_identify_multiphase()
612 if (ret <= 0) in mp2975_identify_multiphase()
613 return ret; in mp2975_identify_multiphase()
615 info->phases[0] = ret & GENMASK(3, 0); in mp2975_identify_multiphase()
644 int ret; in mp2975_identify_vid() local
647 ret = i2c_smbus_read_word_data(client, reg); in mp2975_identify_vid()
648 if (ret < 0) in mp2975_identify_vid()
649 return ret; in mp2975_identify_vid()
651 if (ret & imvp_bit) { in mp2975_identify_vid()
654 } else if (ret & vr_bit) { in mp2975_identify_vid()
669 int ret; in mp2975_identify_rails_vid() local
671 ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, 2); in mp2975_identify_rails_vid()
672 if (ret < 0) in mp2975_identify_rails_vid()
673 return ret; in mp2975_identify_rails_vid()
676 ret = mp2975_identify_vid(client, data, info, in mp2975_identify_rails_vid()
679 if (ret < 0) in mp2975_identify_rails_vid()
680 return ret; in mp2975_identify_rails_vid()
684 ret = mp2975_identify_vid(client, data, info, in mp2975_identify_rails_vid()
689 return ret; in mp2975_identify_rails_vid()
696 int ret; in mp2973_identify_rails_vid() local
698 ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, 2); in mp2973_identify_rails_vid()
699 if (ret < 0) in mp2973_identify_rails_vid()
700 return ret; in mp2973_identify_rails_vid()
703 ret = mp2975_identify_vid(client, data, info, in mp2973_identify_rails_vid()
707 if (ret < 0) in mp2973_identify_rails_vid()
708 return ret; in mp2973_identify_rails_vid()
712 ret = mp2975_identify_vid(client, data, info, in mp2973_identify_rails_vid()
717 return ret; in mp2973_identify_rails_vid()
724 int i, ret; in mp2975_current_sense_gain_get() local
733 ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, i); in mp2975_current_sense_gain_get()
734 if (ret < 0) in mp2975_current_sense_gain_get()
735 return ret; in mp2975_current_sense_gain_get()
736 ret = i2c_smbus_read_word_data(client, in mp2975_current_sense_gain_get()
738 if (ret < 0) in mp2975_current_sense_gain_get()
739 return ret; in mp2975_current_sense_gain_get()
741 switch ((ret & MP2975_DRMOS_KCS) >> 12) { in mp2975_current_sense_gain_get()
764 int ret; in mp2975_vref_get() local
766 ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, 3); in mp2975_vref_get()
767 if (ret < 0) in mp2975_vref_get()
768 return ret; in mp2975_vref_get()
771 ret = i2c_smbus_read_word_data(client, MP2975_MFR_READ_VREF_R1); in mp2975_vref_get()
772 if (ret < 0) in mp2975_vref_get()
773 return ret; in mp2975_vref_get()
775 data->vref[0] = ret * data->vid_step[0]; in mp2975_vref_get()
779 ret = i2c_smbus_read_word_data(client, MP2975_MFR_READ_VREF_R2); in mp2975_vref_get()
780 if (ret < 0) in mp2975_vref_get()
781 return ret; in mp2975_vref_get()
783 data->vref[1] = ret * data->vid_step[1]; in mp2975_vref_get()
792 int ret; in mp2975_vref_offset_get() local
794 ret = i2c_smbus_read_word_data(client, MP2975_MFR_OVP_TH_SET); in mp2975_vref_offset_get()
795 if (ret < 0) in mp2975_vref_offset_get()
796 return ret; in mp2975_vref_offset_get()
798 switch ((ret & GENMASK(5, 3)) >> 3) { in mp2975_vref_offset_get()
818 int ret; in mp2975_vout_max_get() local
821 ret = i2c_smbus_read_word_data(client, PMBUS_VOUT_MAX); in mp2975_vout_max_get()
822 if (ret < 0) in mp2975_vout_max_get()
823 return ret; in mp2975_vout_max_get()
825 data->vout_max[page] = mp2975_vid2direct(info->vrm_version[page], ret & in mp2975_vout_max_get()
834 int ret, i; in mp2975_set_vout_format() local
838 ret = i2c_smbus_read_word_data(client, MP2975_MFR_DC_LOOP_CTRL); in mp2975_set_vout_format()
839 if (ret < 0) in mp2975_set_vout_format()
840 return ret; in mp2975_set_vout_format()
841 if (ret & MP2975_VOUT_FORMAT) { in mp2975_set_vout_format()
842 ret &= ~MP2975_VOUT_FORMAT; in mp2975_set_vout_format()
843 ret = i2c_smbus_write_word_data(client, MP2975_MFR_DC_LOOP_CTRL, ret); in mp2975_set_vout_format()
846 ret = i2c_smbus_read_word_data(client, MP2973_MFR_RESO_SET); in mp2975_set_vout_format()
847 if (ret < 0) in mp2975_set_vout_format()
848 return ret; in mp2975_set_vout_format()
849 i = ret; in mp2975_set_vout_format()
858 if (i != ret) in mp2975_set_vout_format()
859 ret = i2c_smbus_write_word_data(client, MP2973_MFR_RESO_SET, i); in mp2975_set_vout_format()
861 return ret; in mp2975_set_vout_format()
868 int thres_dev, sense_ampl, ret; in mp2975_vout_ov_scale_get() local
870 ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, 0); in mp2975_vout_ov_scale_get()
871 if (ret < 0) in mp2975_vout_ov_scale_get()
872 return ret; in mp2975_vout_ov_scale_get()
879 ret = i2c_smbus_read_word_data(client, MP2975_MFR_APS_DECAY_ADV); in mp2975_vout_ov_scale_get()
880 if (ret < 0) in mp2975_vout_ov_scale_get()
881 return ret; in mp2975_vout_ov_scale_get()
882 thres_dev = ret & MP2975_PRT_THRES_DIV_OV_EN ? MP2975_PROT_DEV_OV_ON : in mp2975_vout_ov_scale_get()
886 ret = i2c_smbus_read_word_data(client, PMBUS_VOUT_SCALE_LOOP); in mp2975_vout_ov_scale_get()
887 if (ret < 0) in mp2975_vout_ov_scale_get()
888 return ret; in mp2975_vout_ov_scale_get()
889 sense_ampl = ret & MP2975_SENSE_AMPL ? MP2975_SENSE_AMPL_HALF : in mp2975_vout_ov_scale_get()
902 int i, ret; in mp2975_vout_per_rail_config_get() local
905 ret = i2c_smbus_write_byte_data(client, PMBUS_PAGE, i); in mp2975_vout_per_rail_config_get()
906 if (ret < 0) in mp2975_vout_per_rail_config_get()
910 ret = mp2975_set_vout_format(client, data, i); in mp2975_vout_per_rail_config_get()
911 if (ret < 0) in mp2975_vout_per_rail_config_get()
912 return ret; in mp2975_vout_per_rail_config_get()
915 ret = mp2975_vout_max_get(client, data, info, i); in mp2975_vout_per_rail_config_get()
916 if (ret < 0) in mp2975_vout_per_rail_config_get()
917 return ret; in mp2975_vout_per_rail_config_get()
924 ret = mp2975_vref_offset_get(client, data, i); in mp2975_vout_per_rail_config_get()
925 if (ret < 0) in mp2975_vout_per_rail_config_get()
926 return ret; in mp2975_vout_per_rail_config_get()
1000 int ret; in mp2975_probe() local
1021 ret = mp2975_identify_multiphase_rail2(client, data); in mp2975_probe()
1022 if (ret < 0) in mp2975_probe()
1023 return ret; in mp2975_probe()
1025 if (ret) { in mp2975_probe()
1028 data->info.phases[1] = ret; in mp2975_probe()
1035 ret = mp2975_identify_multiphase(client, data, info); in mp2975_probe()
1036 if (ret) in mp2975_probe()
1037 return ret; in mp2975_probe()
1041 ret = mp2975_identify_rails_vid(client, data, info); in mp2975_probe()
1042 if (ret < 0) in mp2975_probe()
1043 return ret; in mp2975_probe()
1046 ret = mp2975_current_sense_gain_get(client, data); in mp2975_probe()
1047 if (ret) in mp2975_probe()
1048 return ret; in mp2975_probe()
1051 ret = mp2975_vref_get(client, data, info); in mp2975_probe()
1052 if (ret) in mp2975_probe()
1053 return ret; in mp2975_probe()
1056 ret = mp2975_vout_ov_scale_get(client, data, info); in mp2975_probe()
1057 if (ret < 0) in mp2975_probe()
1058 return ret; in mp2975_probe()
1061 ret = mp2973_identify_rails_vid(client, data, info); in mp2975_probe()
1062 if (ret < 0) in mp2975_probe()
1063 return ret; in mp2975_probe()
1067 ret = mp2975_vout_per_rail_config_get(client, data, info); in mp2975_probe()
1068 if (ret) in mp2975_probe()
1069 return ret; in mp2975_probe()