Lines Matching +full:negative +full:- +full:phase

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Hardware monitoring driver for MPS Multi-phase Digital VR Controllers
130 mp2975_read_word_helper(struct i2c_client *client, int page, int phase, u8 reg, in mp2975_read_word_helper() argument
133 int ret = pmbus_read_word_data(client, page, phase, reg); in mp2975_read_word_helper()
144 return 250 + (val - 1) * 5; in mp2975_vid2direct()
148 return 500 + (val - 1) * 10; in mp2975_vid2direct()
152 return 200 + (val - 1) * 10; in mp2975_vid2direct()
155 return -EINVAL; in mp2975_vid2direct()
163 /* Converts a milli-unit DIRECT value to LINEAR11 format */
167 bool negative = false; in mp2975_data2reg_linear11() local
179 while (val < MIN_LIN_MANTISSA && exponent > -15) { in mp2975_data2reg_linear11()
180 exponent--; in mp2975_data2reg_linear11()
184 /* Convert mantissa from milli-units to units */ in mp2975_data2reg_linear11()
188 if (negative) in mp2975_data2reg_linear11()
189 mantissa = -mantissa; in mp2975_data2reg_linear11()
197 int page, int phase, u8 reg) in mp2975_read_phase() argument
201 ret = pmbus_read_word_data(client, page, phase, reg); in mp2975_read_phase()
205 if (!((phase + 1) % MP2975_PAGE_NUM)) in mp2975_read_phase()
212 * - Kcs is the DrMOS current sense gain of power stage, which is in mp2975_read_phase()
213 * obtained from the register MP2975_MFR_VR_CONFIG1, bits 13-12 with in mp2975_read_phase()
214 * the following selection of DrMOS (data->curr_sense_gain[page]): in mp2975_read_phase()
215 * 00b - 5µA/A, 01b - 8.5µA/A, 10b - 9.7µA/A, 11b - 10µA/A. in mp2975_read_phase()
216 * - Rcs is the internal phase current sense resistor which is constant in mp2975_read_phase()
219 ph_curr = ret * 100 - 9800; in mp2975_read_phase()
222 * Current phase sensing, providing by the device is not accurate in mp2975_read_phase()
225 * case phase current is represented as the maximum between the value in mp2975_read_phase()
228 ret = pmbus_read_word_data(client, page, phase, PMBUS_READ_IOUT); in mp2975_read_phase()
232 return max_t(int, DIV_ROUND_CLOSEST(ret, data->info.phases[page]), in mp2975_read_phase()
233 DIV_ROUND_CLOSEST(ph_curr, data->curr_sense_gain[page])); in mp2975_read_phase()
238 int page, int phase) in mp2975_read_phases() argument
243 switch (phase) { in mp2975_read_phases()
245 ret = mp2975_read_phase(client, data, page, phase, in mp2975_read_phases()
249 ret = mp2975_read_phase(client, data, page, phase, in mp2975_read_phases()
253 ret = mp2975_read_phase(client, data, page, phase, in mp2975_read_phases()
257 return -ENODATA; in mp2975_read_phases()
260 switch (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()
270 ret = mp2975_read_phase(client, data, page, phase, in mp2975_read_phases()
274 ret = mp2975_read_phase(client, data, page, phase, in mp2975_read_phases()
278 ret = mp2975_read_phase(client, data, page, phase, in mp2975_read_phases()
282 ret = mp2975_read_phase(client, data, page, phase, in mp2975_read_phases()
286 return -ENODATA; in mp2975_read_phases()
293 int phase, int reg) in mp2973_read_word_data() argument
302 ret = pmbus_read_word_data(client, page, phase, reg); in mp2973_read_word_data()
306 ret = mp2975_read_word_helper(client, page, phase, reg, in mp2973_read_word_data()
310 ret = mp2975_read_word_helper(client, page, phase, reg, in mp2973_read_word_data()
321 ret = mp2975_read_word_helper(client, page, phase, in mp2973_read_word_data()
327 ret = data->vout_max[page] + 50 * (ret + 1); in mp2973_read_word_data()
330 ret = mp2975_read_word_helper(client, page, phase, reg, in mp2973_read_word_data()
334 ret = mp2975_vid2direct(info->vrm_version[page], ret); in mp2973_read_word_data()
337 ret = pmbus_read_word_data(client, page, phase, in mp2973_read_word_data()
341 ret = pmbus_read_word_data(client, page, phase, in mp2973_read_word_data()
345 ret = mp2975_read_word_helper(client, page, phase, in mp2973_read_word_data()
356 ret = mp2975_data2reg_linear11(ret * info->phases[page] * 1000); in mp2973_read_word_data()
372 return -ENXIO; in mp2973_read_word_data()
374 return -ENODATA; in mp2973_read_word_data()
381 int phase, int reg) in mp2975_read_word_data() argument
389 ret = mp2975_read_word_helper(client, page, phase, reg, in mp2975_read_word_data()
393 ret = mp2975_read_word_helper(client, page, phase, reg, in mp2975_read_word_data()
402 * Register provides two values for over-voltage protection in mp2975_read_word_data()
404 * minimum of these two values is provided as over-voltage in mp2975_read_word_data()
407 ret = mp2975_read_word_helper(client, page, phase, in mp2975_read_word_data()
413 ret = min_t(int, data->vout_max[page] + 50 * (ret + 1), in mp2975_read_word_data()
414 data->vout_ov_fixed[page]); in mp2975_read_word_data()
417 ret = mp2975_read_word_helper(client, page, phase, in mp2975_read_word_data()
423 ret = DIV_ROUND_CLOSEST(data->vref[page] * 10 - 50 * in mp2975_read_word_data()
424 (ret + 1) * data->vout_scale, 10); in mp2975_read_word_data()
427 ret = mp2975_read_word_helper(client, page, phase, in mp2975_read_word_data()
436 ret = mp2975_read_word_helper(client, page, phase, in mp2975_read_word_data()
445 ret = mp2975_read_phases(client, data, page, phase); in mp2975_read_word_data()
466 return -ENXIO; in mp2975_read_word_data()
468 return -ENODATA; in mp2975_read_word_data()
480 * Identify multiphase for rail 2 - could be from 0 to data->max_phases[1]. in mp2975_identify_multiphase_rail2()
481 * In case phase number is zero – only page zero is supported in mp2975_identify_multiphase_rail2()
492 return (ret >= data->max_phases[1]) ? data->max_phases[1] : ret; in mp2975_identify_multiphase_rail2()
499 for (i = 0 ; i < info->phases[0]; i++) in mp2975_set_phase_rail1()
500 info->pfunc[i] = PMBUS_HAVE_IOUT; in mp2975_set_phase_rail1()
510 info->pfunc[MP2975_MAX_PHASE_RAIL1 - i] = PMBUS_HAVE_IOUT; in mp2975_set_phase_rail2()
523 /* Identify multiphase for rail 1 - could be from 1 to data->max_phases[0]. */ in mp2975_identify_multiphase()
528 info->phases[0] = ret & GENMASK(3, 0); in mp2975_identify_multiphase()
532 * to different phase count applications for rail 1 and rail 2. in mp2975_identify_multiphase()
534 * that. When rail 1’s phase count is configured as 0, rail in mp2975_identify_multiphase()
535 * 1 operates with 1-phase DCM. When rail 2 phase count is configured in mp2975_identify_multiphase()
538 if (info->phases[0] > data->max_phases[0]) in mp2975_identify_multiphase()
539 return -EINVAL; in mp2975_identify_multiphase()
541 if (data->chip_id == mp2975) { in mp2975_identify_multiphase()
543 num_phases2 = min(data->max_phases[0] - info->phases[0], in mp2975_identify_multiphase()
544 data->max_phases[1]); in mp2975_identify_multiphase()
545 if (info->phases[1] && info->phases[1] <= num_phases2) in mp2975_identify_multiphase()
565 info->vrm_version[page] = imvp9; in mp2975_identify_vid()
566 data->vid_step[page] = MP2975_PROT_DEV_OV_OFF; in mp2975_identify_vid()
568 info->vrm_version[page] = vr12; in mp2975_identify_vid()
569 data->vid_step[page] = MP2975_PROT_DEV_OV_ON; in mp2975_identify_vid()
571 info->vrm_version[page] = vr13; in mp2975_identify_vid()
572 data->vid_step[page] = MP2975_PROT_DEV_OV_OFF; in mp2975_identify_vid()
596 if (info->phases[1]) in mp2975_identify_rails_vid()
624 if (info->phases[1]) in mp2973_identify_rails_vid()
641 * MP2975_MFR_VR_CONFIG1, bits 13-12. The value is selected as below: in mp2975_current_sense_gain_get()
642 * 00b - 5µA/A, 01b - 8.5µA/A, 10b - 9.7µA/A, 11b - 10µA/A. Other in mp2975_current_sense_gain_get()
645 for (i = 0 ; i < data->info.pages; i++) { in mp2975_current_sense_gain_get()
656 data->curr_sense_gain[i] = 50; in mp2975_current_sense_gain_get()
659 data->curr_sense_gain[i] = 85; in mp2975_current_sense_gain_get()
662 data->curr_sense_gain[i] = 97; in mp2975_current_sense_gain_get()
665 data->curr_sense_gain[i] = 100; in mp2975_current_sense_gain_get()
688 data->vref[0] = ret * data->vid_step[0]; in mp2975_vref_get()
691 if (data->info.pages == MP2975_PAGE_NUM) { in mp2975_vref_get()
696 data->vref[1] = ret * data->vid_step[1]; in mp2975_vref_get()
713 data->vref_off[page] = 140; in mp2975_vref_offset_get()
716 data->vref_off[page] = 220; in mp2975_vref_offset_get()
719 data->vref_off[page] = 400; in mp2975_vref_offset_get()
722 return -EINVAL; in mp2975_vref_offset_get()
733 /* Get maximum reference voltage of VID-DAC in VID format. */ in mp2975_vout_max_get()
738 data->vout_max[page] = mp2975_vid2direct(info->vrm_version[page], ret & in mp2975_vout_max_get()
750 if (data->chip_id == mp2975) { in mp2975_set_vout_format()
788 * Get divider for over- and under-voltage protection thresholds in mp2975_vout_ov_scale_get()
789 * configuration from the Advanced Options of Auto Phase Shedding and in mp2975_vout_ov_scale_get()
805 data->vout_scale = sense_ampl * thres_dev; in mp2975_vout_ov_scale_get()
817 for (i = 0; i < data->info.pages; i++) { in mp2975_vout_per_rail_config_get()
833 if (data->chip_id != mp2975) in mp2975_vout_per_rail_config_get()
842 * Set over-voltage fixed value. Thresholds are provided as in mp2975_vout_per_rail_config_get()
844 * exposed as over-voltage critical threshold. in mp2975_vout_per_rail_config_get()
846 data->vout_ov_fixed[i] = data->vref[i] + in mp2975_vout_per_rail_config_get()
847 DIV_ROUND_CLOSEST(data->vref_off[i] * in mp2975_vout_per_rail_config_get()
848 data->vout_scale, in mp2975_vout_per_rail_config_get()
906 data = devm_kzalloc(&client->dev, sizeof(struct mp2975_data), in mp2975_probe()
909 return -ENOMEM; in mp2975_probe()
911 if (client->dev.of_node) in mp2975_probe()
912 data->chip_id = (enum chips)(unsigned long)of_device_get_match_data(&client->dev); in mp2975_probe()
914 data->chip_id = i2c_match_id(mp2975_id, client)->driver_data; in mp2975_probe()
916 memcpy(data->max_phases, mp2975_max_phases[data->chip_id], in mp2975_probe()
917 sizeof(data->max_phases)); in mp2975_probe()
919 if (data->chip_id == mp2975) in mp2975_probe()
920 memcpy(&data->info, &mp2975_info, sizeof(*info)); in mp2975_probe()
922 memcpy(&data->info, &mp2973_info, sizeof(*info)); in mp2975_probe()
924 info = &data->info; in mp2975_probe()
933 data->info.pages = MP2975_PAGE_NUM; in mp2975_probe()
934 data->info.phases[1] = ret; in mp2975_probe()
935 data->info.func[1] = MP2975_RAIL2_FUNC; in mp2975_probe()
937 data->info.num_regulators = MP2975_PAGE_NUM; in mp2975_probe()
945 if (data->chip_id == mp2975) { in mp2975_probe()
961 /* Obtain vout over-voltage scales. */ in mp2975_probe()