Lines Matching +full:current +full:- +full:sense +full:- +full:shunt

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Hardware monitoring driver for Analog Devices ADM1275 Hot-Swap Controller
116 [0] = { 27169, 0, -1 }, /* voltage */
117 [1] = { 806, 20475, -1 }, /* current, irange25 */
118 [2] = { 404, 20475, -1 }, /* current, irange50 */
119 [3] = { 8549, 0, -1 }, /* power, irange25 */
120 [4] = { 4279, 0, -1 }, /* power, irange50 */
124 [0] = { 6770, 0, -2 }, /* voltage, vrange 60V */
125 [1] = { 4062, 0, -2 }, /* voltage, vrange 100V */
126 [2] = { 1326, 20480, -1 }, /* current, vsense range 15mV */
127 [3] = { 663, 20480, -1 }, /* current, vsense range 30mV */
128 [4] = { 3512, 0, -2 }, /* power, vrange 60V, irange 15mV */
129 [5] = { 21071, 0, -3 }, /* power, vrange 100V, irange 15mV */
130 [6] = { 17561, 0, -3 }, /* power, vrange 60V, irange 30mV */
131 [7] = { 10535, 0, -3 }, /* power, vrange 100V, irange 30mV */
132 [8] = { 42, 31871, -1 }, /* temperature */
137 [0] = { 19199, 0, -2 }, /* voltage, vrange set */
138 [1] = { 6720, 0, -1 }, /* voltage, vrange not set */
139 [2] = { 807, 20475, -1 }, /* current */
143 [0] = { 19199, 0, -2 }, /* voltage, vrange set */
144 [1] = { 6720, 0, -1 }, /* voltage, vrange not set */
145 [2] = { 807, 20475, -1 }, /* current */
146 [3] = { 6043, 0, -2 }, /* power, vrange set */
147 [4] = { 2115, 0, -1 }, /* power, vrange not set */
151 [0] = { 19599, 0, -2 }, /* voltage */
152 [1] = { 800, 20475, -1 }, /* current */
153 [2] = { 6123, 0, -2 }, /* power */
154 [3] = { 42, 31880, -1 }, /* temperature */
158 [0] = { 3333, -1, 0 }, /* voltage, vrange 1.2V */
159 [1] = { 5552, -5, -1 }, /* voltage, vrange 7.4V */
160 [2] = { 19604, -50, -2 }, /* voltage, vrange 21V */
161 [3] = { 8000, -100, -2 }, /* current, irange25 */
162 [4] = { 4000, -100, -2 }, /* current, irange50 */
163 [5] = { 20000, -1000, -3 }, /* current, irange100 */
164 [6] = { 10000, -1000, -3 }, /* current, irange200 */
165 [7] = { 10417, 0, -1 }, /* power, 1.2V, irange25 */
166 [8] = { 5208, 0, -1 }, /* power, 1.2V, irange50 */
167 [9] = { 26042, 0, -2 }, /* power, 1.2V, irange100 */
168 [10] = { 13021, 0, -2 }, /* power, 1.2V, irange200 */
169 [11] = { 17351, 0, -2 }, /* power, 7.4V, irange25 */
170 [12] = { 8676, 0, -2 }, /* power, 7.4V, irange50 */
171 [13] = { 4338, 0, -2 }, /* power, 7.4V, irange100 */
172 [14] = { 21689, 0, -3 }, /* power, 7.4V, irange200 */
173 [15] = { 6126, 0, -2 }, /* power, 21V, irange25 */
174 [16] = { 30631, 0, -3 }, /* power, 21V, irange50 */
175 [17] = { 15316, 0, -3 }, /* power, 21V, irange100 */
176 [18] = { 7658, 0, -3 }, /* power, 21V, irange200 */
186 * The PMON configuration register is a 16-bit register only on chips in adm1275_read_samples()
187 * supporting power average sampling. On other chips it is an 8-bit in adm1275_read_samples()
190 if (data->have_power_sampling) { in adm1275_read_samples()
214 if (data->have_power_sampling) in adm1275_write_pmon_config()
222 * We still want to re-enable conversions if writing into in adm1275_write_pmon_config()
240 if (data->have_power_sampling) { in adm1275_write_samples()
265 return -ENXIO; in adm1275_read_word_data()
269 if (!data->have_uc_fault) in adm1275_read_word_data()
270 return -ENXIO; in adm1275_read_word_data()
275 if (!data->have_oc_fault) in adm1275_read_word_data()
276 return -ENXIO; in adm1275_read_word_data()
281 if (data->have_vout) in adm1275_read_word_data()
282 return -ENODATA; in adm1275_read_word_data()
287 if (data->have_vout) in adm1275_read_word_data()
288 return -ENODATA; in adm1275_read_word_data()
293 if (data->have_vout) in adm1275_read_word_data()
294 return -ENODATA; in adm1275_read_word_data()
299 if (!data->have_iout_min) in adm1275_read_word_data()
300 return -ENXIO; in adm1275_read_word_data()
317 if (!data->have_pin_min) in adm1275_read_word_data()
318 return -ENXIO; in adm1275_read_word_data()
323 if (!data->have_pin_max) in adm1275_read_word_data()
324 return -ENXIO; in adm1275_read_word_data()
329 if (!data->have_temp_max) in adm1275_read_word_data()
330 return -ENXIO; in adm1275_read_word_data()
339 if (!data->have_pin_max) in adm1275_read_word_data()
340 return -ENXIO; in adm1275_read_word_data()
343 if (!data->have_temp_max) in adm1275_read_word_data()
344 return -ENXIO; in adm1275_read_word_data()
347 if (!data->have_power_sampling) in adm1275_read_word_data()
348 return -ENXIO; in adm1275_read_word_data()
362 ret = -ENODATA; in adm1275_read_word_data()
376 return -ENXIO; in adm1275_write_word_data()
386 if (!ret && data->have_iout_min) in adm1275_write_word_data()
398 if (!ret && data->have_pin_min) in adm1275_write_word_data()
406 if (!data->have_power_sampling) in adm1275_write_word_data()
407 return -ENXIO; in adm1275_write_word_data()
417 ret = -ENODATA; in adm1275_write_word_data()
430 return -ENXIO; in adm1275_read_byte_data()
437 if (!data->have_oc_fault && !data->have_uc_fault) in adm1275_read_byte_data()
444 ret |= data->have_oc_fault ? in adm1275_read_byte_data()
449 if (data->have_vout) in adm1275_read_byte_data()
450 return -ENODATA; in adm1275_read_byte_data()
452 if (data->have_vaux_status) { in adm1275_read_byte_data()
461 } else if (data->have_mfr_vaux_status) { in adm1275_read_byte_data()
473 ret = -ENODATA; in adm1275_read_byte_data()
501 dev_err(&client->dev, "Failed to enable VOUT/TEMP1 monitoring\n"); in adm1275_enable_vout_temp()
518 int vindex = -1, voindex = -1, cindex = -1, pindex = -1; in adm1275_probe()
519 int tindex = -1; in adm1275_probe()
520 u32 shunt; in adm1275_probe() local
523 if (!i2c_check_functionality(client->adapter, in adm1275_probe()
526 return -ENODEV; in adm1275_probe()
530 dev_err(&client->dev, "Failed to read Manufacturer ID\n"); in adm1275_probe()
534 dev_err(&client->dev, "Unsupported Manufacturer ID\n"); in adm1275_probe()
535 return -ENODEV; in adm1275_probe()
540 dev_err(&client->dev, "Failed to read Manufacturer Model\n"); in adm1275_probe()
543 for (mid = adm1275_id; mid->name[0]; mid++) { in adm1275_probe()
544 if (!strncasecmp(mid->name, block_buffer, strlen(mid->name))) in adm1275_probe()
547 if (!mid->name[0]) { in adm1275_probe()
548 dev_err(&client->dev, "Unsupported device\n"); in adm1275_probe()
549 return -ENODEV; in adm1275_probe()
552 if (strcmp(client->name, mid->name) != 0) in adm1275_probe()
553 dev_notice(&client->dev, in adm1275_probe()
555 client->name, mid->name); in adm1275_probe()
557 if (mid->driver_data == adm1272 || mid->driver_data == adm1278 || in adm1275_probe()
558 mid->driver_data == adm1293 || mid->driver_data == adm1294) in adm1275_probe()
570 data = devm_kzalloc(&client->dev, sizeof(struct adm1275_data), in adm1275_probe()
573 return -ENOMEM; in adm1275_probe()
575 if (of_property_read_u32(client->dev.of_node, in adm1275_probe()
576 "shunt-resistor-micro-ohms", &shunt)) in adm1275_probe()
577 shunt = 1000; /* 1 mOhm if not set via DT */ in adm1275_probe()
579 if (shunt == 0) in adm1275_probe()
580 return -EINVAL; in adm1275_probe()
582 data->id = mid->driver_data; in adm1275_probe()
584 info = &data->info; in adm1275_probe()
586 info->pages = 1; in adm1275_probe()
587 info->format[PSC_VOLTAGE_IN] = direct; in adm1275_probe()
588 info->format[PSC_VOLTAGE_OUT] = direct; in adm1275_probe()
589 info->format[PSC_CURRENT_OUT] = direct; in adm1275_probe()
590 info->format[PSC_POWER] = direct; in adm1275_probe()
591 info->format[PSC_TEMPERATURE] = direct; in adm1275_probe()
592 info->func[0] = PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | in adm1275_probe()
595 info->read_word_data = adm1275_read_word_data; in adm1275_probe()
596 info->read_byte_data = adm1275_read_byte_data; in adm1275_probe()
597 info->write_word_data = adm1275_write_word_data; in adm1275_probe()
599 switch (data->id) { in adm1275_probe()
602 data->have_oc_fault = true; in adm1275_probe()
604 data->have_uc_fault = true; in adm1275_probe()
605 data->have_pin_max = true; in adm1275_probe()
606 data->have_vaux_status = true; in adm1275_probe()
620 dev_err(&client->dev, "Invalid input current range"); in adm1275_probe()
624 info->func[0] |= PMBUS_HAVE_VIN | PMBUS_HAVE_PIN in adm1275_probe()
627 info->func[0] |= in adm1275_probe()
631 data->have_vout = true; in adm1275_probe()
632 data->have_pin_max = true; in adm1275_probe()
633 data->have_temp_max = true; in adm1275_probe()
634 data->have_power_sampling = true; in adm1275_probe()
657 info->func[0] |= PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT | in adm1275_probe()
666 info->func[0] |= PMBUS_HAVE_VIN; in adm1275_probe()
670 data->have_oc_fault = true; in adm1275_probe()
672 data->have_uc_fault = true; in adm1275_probe()
673 data->have_vout = true; in adm1275_probe()
680 info->func[0] |= in adm1275_probe()
683 info->func[0] |= in adm1275_probe()
688 data->have_oc_fault = true; in adm1275_probe()
690 data->have_uc_fault = true; in adm1275_probe()
691 data->have_vout = true; in adm1275_probe()
692 data->have_pin_max = true; in adm1275_probe()
699 info->func[0] |= PMBUS_HAVE_VIN | PMBUS_HAVE_PIN in adm1275_probe()
702 info->func[0] |= in adm1275_probe()
706 data->have_vout = true; in adm1275_probe()
707 data->have_pin_max = true; in adm1275_probe()
708 data->have_temp_max = true; in adm1275_probe()
709 data->have_power_sampling = true; in adm1275_probe()
717 info->func[0] |= PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT | in adm1275_probe()
726 info->func[0] |= PMBUS_HAVE_VIN; in adm1275_probe()
730 data->have_iout_min = true; in adm1275_probe()
731 data->have_pin_min = true; in adm1275_probe()
732 data->have_pin_max = true; in adm1275_probe()
733 data->have_mfr_vaux_status = true; in adm1275_probe()
734 data->have_power_sampling = true; in adm1275_probe()
769 pindex = 7 + vindex * 4 + (cindex - 3); in adm1275_probe()
772 info->func[0] |= in adm1275_probe()
775 info->func[0] |= PMBUS_HAVE_PIN | in adm1275_probe()
780 dev_err(&client->dev, "Unsupported device\n"); in adm1275_probe()
781 return -ENODEV; in adm1275_probe()
784 if (data->have_power_sampling && in adm1275_probe()
785 of_property_read_u32(client->dev.of_node, in adm1275_probe()
786 "adi,power-sample-average", &avg) == 0) { in adm1275_probe()
789 dev_err(&client->dev, in adm1275_probe()
791 return -EINVAL; in adm1275_probe()
795 dev_err(&client->dev, in adm1275_probe()
802 if (of_property_read_u32(client->dev.of_node, in adm1275_probe()
803 "adi,volt-curr-sample-average", &avg) == 0) { in adm1275_probe()
806 dev_err(&client->dev, in adm1275_probe()
807 "Invalid number of voltage/current samples"); in adm1275_probe()
808 return -EINVAL; in adm1275_probe()
812 dev_err(&client->dev, in adm1275_probe()
813 "Setting voltage and current sample averaging failed with error %d", in adm1275_probe()
822 info->m[PSC_VOLTAGE_IN] = coefficients[vindex].m; in adm1275_probe()
823 info->b[PSC_VOLTAGE_IN] = coefficients[vindex].b; in adm1275_probe()
824 info->R[PSC_VOLTAGE_IN] = coefficients[vindex].R; in adm1275_probe()
827 info->m[PSC_VOLTAGE_OUT] = coefficients[voindex].m; in adm1275_probe()
828 info->b[PSC_VOLTAGE_OUT] = coefficients[voindex].b; in adm1275_probe()
829 info->R[PSC_VOLTAGE_OUT] = coefficients[voindex].R; in adm1275_probe()
832 /* Scale current with sense resistor value */ in adm1275_probe()
833 info->m[PSC_CURRENT_OUT] = in adm1275_probe()
834 coefficients[cindex].m * shunt / 1000; in adm1275_probe()
835 info->b[PSC_CURRENT_OUT] = coefficients[cindex].b; in adm1275_probe()
836 info->R[PSC_CURRENT_OUT] = coefficients[cindex].R; in adm1275_probe()
839 info->m[PSC_POWER] = in adm1275_probe()
840 coefficients[pindex].m * shunt / 1000; in adm1275_probe()
841 info->b[PSC_POWER] = coefficients[pindex].b; in adm1275_probe()
842 info->R[PSC_POWER] = coefficients[pindex].R; in adm1275_probe()
845 info->m[PSC_TEMPERATURE] = coefficients[tindex].m; in adm1275_probe()
846 info->b[PSC_TEMPERATURE] = coefficients[tindex].b; in adm1275_probe()
847 info->R[PSC_TEMPERATURE] = coefficients[tindex].R; in adm1275_probe()