Lines Matching +full:multi +full:- +full:phase
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Hardware monitoring driver for MPS Multi-phase Digital VR Controllers
85 return -ENODATA; in mp2975_read_byte_data()
90 mp2975_read_word_helper(struct i2c_client *client, int page, int phase, u8 reg, in mp2975_read_word_helper() argument
93 int ret = pmbus_read_word_data(client, page, phase, reg); in mp2975_read_word_helper()
104 return 250 + (val - 1) * 5; in mp2975_vid2direct()
108 return 500 + (val - 1) * 10; in mp2975_vid2direct()
112 return 200 + (val - 1) * 10; in mp2975_vid2direct()
115 return -EINVAL; in mp2975_vid2direct()
122 int page, int phase, u8 reg) in mp2975_read_phase() argument
126 ret = pmbus_read_word_data(client, page, phase, reg); in mp2975_read_phase()
130 if (!((phase + 1) % MP2975_PAGE_NUM)) in mp2975_read_phase()
137 * - Kcs is the DrMOS current sense gain of power stage, which is in mp2975_read_phase()
138 * obtained from the register MP2975_MFR_VR_CONFIG1, bits 13-12 with in mp2975_read_phase()
139 * the following selection of DrMOS (data->curr_sense_gain[page]): in mp2975_read_phase()
140 * 00b - 5µA/A, 01b - 8.5µA/A, 10b - 9.7µA/A, 11b - 10µA/A. in mp2975_read_phase()
141 * - Rcs is the internal phase current sense resistor which is constant in mp2975_read_phase()
144 ph_curr = ret * 100 - 9800; in mp2975_read_phase()
147 * Current phase sensing, providing by the device is not accurate in mp2975_read_phase()
150 * case phase current is represented as the maximum between the value in mp2975_read_phase()
153 ret = pmbus_read_word_data(client, page, phase, PMBUS_READ_IOUT); in mp2975_read_phase()
157 return max_t(int, DIV_ROUND_CLOSEST(ret, data->info.phases[page]), in mp2975_read_phase()
158 DIV_ROUND_CLOSEST(ph_curr, data->curr_sense_gain[page])); in mp2975_read_phase()
163 int page, int phase) in mp2975_read_phases() argument
168 switch (phase) { in mp2975_read_phases()
170 ret = mp2975_read_phase(client, data, page, phase, in mp2975_read_phases()
174 ret = mp2975_read_phase(client, data, page, phase, in mp2975_read_phases()
178 ret = mp2975_read_phase(client, data, page, phase, in mp2975_read_phases()
182 return -ENODATA; in mp2975_read_phases()
185 switch (phase) { in mp2975_read_phases()
187 ret = mp2975_read_phase(client, data, page, phase, in mp2975_read_phases()
191 ret = mp2975_read_phase(client, data, page, phase, in mp2975_read_phases()
195 ret = mp2975_read_phase(client, data, page, phase, in mp2975_read_phases()
199 ret = mp2975_read_phase(client, data, page, phase, in mp2975_read_phases()
203 ret = mp2975_read_phase(client, data, page, phase, in mp2975_read_phases()
207 ret = mp2975_read_phase(client, data, page, phase, in mp2975_read_phases()
211 return -ENODATA; in mp2975_read_phases()
218 int phase, int reg) in mp2975_read_word_data() argument
226 ret = mp2975_read_word_helper(client, page, phase, reg, in mp2975_read_word_data()
230 ret = mp2975_read_word_helper(client, page, phase, reg, in mp2975_read_word_data()
239 * Register provides two values for over-voltage protection in mp2975_read_word_data()
241 * minimum of these two values is provided as over-voltage in mp2975_read_word_data()
244 ret = mp2975_read_word_helper(client, page, phase, in mp2975_read_word_data()
250 ret = min_t(int, data->vout_max[page] + 50 * (ret + 1), in mp2975_read_word_data()
251 data->vout_ov_fixed[page]); in mp2975_read_word_data()
254 ret = mp2975_read_word_helper(client, page, phase, in mp2975_read_word_data()
260 ret = DIV_ROUND_CLOSEST(data->vref[page] * 10 - 50 * in mp2975_read_word_data()
261 (ret + 1) * data->vout_scale, 10); in mp2975_read_word_data()
264 ret = mp2975_read_word_helper(client, page, phase, reg, in mp2975_read_word_data()
275 * provided in a direct format. In case format is VID - convert in mp2975_read_word_data()
278 if (data->vout_format[page] == vid) in mp2975_read_word_data()
279 ret = mp2975_vid2direct(info->vrm_version[page], ret); in mp2975_read_word_data()
282 ret = mp2975_read_word_helper(client, page, phase, in mp2975_read_word_data()
291 ret = mp2975_read_word_helper(client, page, phase, in mp2975_read_word_data()
300 ret = mp2975_read_phases(client, data, page, phase); in mp2975_read_word_data()
321 return -ENXIO; in mp2975_read_word_data()
323 return -ENODATA; in mp2975_read_word_data()
334 * Identify multiphase for rail 2 - could be from 0 to 4. in mp2975_identify_multiphase_rail2()
335 * In case phase number is zero – only page zero is supported in mp2975_identify_multiphase_rail2()
341 /* Identify multiphase for rail 2 - could be from 0 to 4. */ in mp2975_identify_multiphase_rail2()
354 for (i = 0 ; i < info->phases[0]; i++) in mp2975_set_phase_rail1()
355 info->pfunc[i] = PMBUS_HAVE_IOUT; in mp2975_set_phase_rail1()
365 info->pfunc[MP2975_MAX_PHASE_RAIL1 - i] = PMBUS_HAVE_IOUT; in mp2975_set_phase_rail2()
378 /* Identify multiphase for rail 1 - could be from 1 to 8. */ in mp2975_identify_multiphase()
383 info->phases[0] = ret & GENMASK(3, 0); in mp2975_identify_multiphase()
387 * to different phase count applications for rail 1 and rail 2. in mp2975_identify_multiphase()
389 * phases at most. When rail 1’s phase count is configured as 0, rail in mp2975_identify_multiphase()
390 * 1 operates with 1-phase DCM. When rail 2 phase count is configured in mp2975_identify_multiphase()
393 if (info->phases[0] > MP2975_MAX_PHASE_RAIL1) in mp2975_identify_multiphase()
394 return -EINVAL; in mp2975_identify_multiphase()
397 num_phases2 = min(MP2975_MAX_PHASE_RAIL1 - info->phases[0], in mp2975_identify_multiphase()
399 if (info->phases[1] && info->phases[1] <= num_phases2) in mp2975_identify_multiphase()
418 info->vrm_version[page] = imvp9; in mp2975_identify_vid()
419 data->vid_step[page] = MP2975_PROT_DEV_OV_OFF; in mp2975_identify_vid()
421 info->vrm_version[page] = vr12; in mp2975_identify_vid()
422 data->vid_step[page] = MP2975_PROT_DEV_OV_ON; in mp2975_identify_vid()
424 info->vrm_version[page] = vr13; in mp2975_identify_vid()
425 data->vid_step[page] = MP2975_PROT_DEV_OV_OFF; in mp2975_identify_vid()
449 if (info->phases[1]) in mp2975_identify_rails_vid()
465 * MP2975_MFR_VR_CONFIG1, bits 13-12. The value is selected as below: in mp2975_current_sense_gain_get()
466 * 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()
469 for (i = 0 ; i < data->info.pages; i++) { in mp2975_current_sense_gain_get()
480 data->curr_sense_gain[i] = 50; in mp2975_current_sense_gain_get()
483 data->curr_sense_gain[i] = 85; in mp2975_current_sense_gain_get()
486 data->curr_sense_gain[i] = 97; in mp2975_current_sense_gain_get()
489 data->curr_sense_gain[i] = 100; in mp2975_current_sense_gain_get()
512 data->vref[0] = ret * data->vid_step[0]; in mp2975_vref_get()
515 if (data->info.pages == MP2975_PAGE_NUM) { in mp2975_vref_get()
520 data->vref[1] = ret * data->vid_step[1]; in mp2975_vref_get()
537 data->vref_off[page] = 140; in mp2975_vref_offset_get()
540 data->vref_off[page] = 220; in mp2975_vref_offset_get()
543 data->vref_off[page] = 400; in mp2975_vref_offset_get()
546 return -EINVAL; in mp2975_vref_offset_get()
557 /* Get maximum reference voltage of VID-DAC in VID format. */ in mp2975_vout_max_get()
562 data->vout_max[page] = mp2975_vid2direct(info->vrm_version[page], ret & in mp2975_vout_max_get()
578 data->vout_format[page] = vid; in mp2975_identify_vout_format()
580 data->vout_format[page] = direct; in mp2975_identify_vout_format()
595 * Get divider for over- and under-voltage protection thresholds in mp2975_vout_ov_scale_get()
596 * configuration from the Advanced Options of Auto Phase Shedding and in mp2975_vout_ov_scale_get()
612 data->vout_scale = sense_ampl * thres_dev; in mp2975_vout_ov_scale_get()
624 for (i = 0; i < data->info.pages; i++) { in mp2975_vout_per_rail_config_get()
649 * Set over-voltage fixed value. Thresholds are provided as in mp2975_vout_per_rail_config_get()
651 * exposed as over-voltage critical threshold. in mp2975_vout_per_rail_config_get()
653 data->vout_ov_fixed[i] = data->vref[i] + in mp2975_vout_per_rail_config_get()
654 DIV_ROUND_CLOSEST(data->vref_off[i] * in mp2975_vout_per_rail_config_get()
655 data->vout_scale, in mp2975_vout_per_rail_config_get()
689 data = devm_kzalloc(&client->dev, sizeof(struct mp2975_data), in mp2975_probe()
692 return -ENOMEM; in mp2975_probe()
694 memcpy(&data->info, &mp2975_info, sizeof(*info)); in mp2975_probe()
695 info = &data->info; in mp2975_probe()
704 data->info.pages = MP2975_PAGE_NUM; in mp2975_probe()
705 data->info.phases[1] = ret; in mp2975_probe()
706 data->info.func[1] = MP2975_RAIL2_FUNC; in mp2975_probe()
729 /* Obtain vout over-voltage scales. */ in mp2975_probe()