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
113 [0] = { 27169, 0, -1 }, /* voltage */
114 [1] = { 806, 20475, -1 }, /* current, irange25 */
115 [2] = { 404, 20475, -1 }, /* current, irange50 */
116 [3] = { 8549, 0, -1 }, /* power, irange25 */
117 [4] = { 4279, 0, -1 }, /* power, irange50 */
121 [0] = { 6770, 0, -2 }, /* voltage, vrange 60V */
122 [1] = { 4062, 0, -2 }, /* voltage, vrange 100V */
123 [2] = { 1326, 20480, -1 }, /* current, vsense range 15mV */
124 [3] = { 663, 20480, -1 }, /* current, vsense range 30mV */
125 [4] = { 3512, 0, -2 }, /* power, vrange 60V, irange 15mV */
126 [5] = { 21071, 0, -3 }, /* power, vrange 100V, irange 15mV */
127 [6] = { 17561, 0, -3 }, /* power, vrange 60V, irange 30mV */
128 [7] = { 10535, 0, -3 }, /* power, vrange 100V, irange 30mV */
129 [8] = { 42, 31871, -1 }, /* temperature */
134 [0] = { 19199, 0, -2 }, /* voltage, vrange set */
135 [1] = { 6720, 0, -1 }, /* voltage, vrange not set */
136 [2] = { 807, 20475, -1 }, /* current */
140 [0] = { 19199, 0, -2 }, /* voltage, vrange set */
141 [1] = { 6720, 0, -1 }, /* voltage, vrange not set */
142 [2] = { 807, 20475, -1 }, /* current */
143 [3] = { 6043, 0, -2 }, /* power, vrange set */
144 [4] = { 2115, 0, -1 }, /* power, vrange not set */
148 [0] = { 19599, 0, -2 }, /* voltage */
149 [1] = { 800, 20475, -1 }, /* current */
150 [2] = { 6123, 0, -2 }, /* power */
151 [3] = { 42, 31880, -1 }, /* temperature */
155 [0] = { 3333, -1, 0 }, /* voltage, vrange 1.2V */
156 [1] = { 5552, -5, -1 }, /* voltage, vrange 7.4V */
157 [2] = { 19604, -50, -2 }, /* voltage, vrange 21V */
158 [3] = { 8000, -100, -2 }, /* current, irange25 */
159 [4] = { 4000, -100, -2 }, /* current, irange50 */
160 [5] = { 20000, -1000, -3 }, /* current, irange100 */
161 [6] = { 10000, -1000, -3 }, /* current, irange200 */
162 [7] = { 10417, 0, -1 }, /* power, 1.2V, irange25 */
163 [8] = { 5208, 0, -1 }, /* power, 1.2V, irange50 */
164 [9] = { 26042, 0, -2 }, /* power, 1.2V, irange100 */
165 [10] = { 13021, 0, -2 }, /* power, 1.2V, irange200 */
166 [11] = { 17351, 0, -2 }, /* power, 7.4V, irange25 */
167 [12] = { 8676, 0, -2 }, /* power, 7.4V, irange50 */
168 [13] = { 4338, 0, -2 }, /* power, 7.4V, irange100 */
169 [14] = { 21689, 0, -3 }, /* power, 7.4V, irange200 */
170 [15] = { 6126, 0, -2 }, /* power, 21V, irange25 */
171 [16] = { 30631, 0, -3 }, /* power, 21V, irange50 */
172 [17] = { 15316, 0, -3 }, /* power, 21V, irange100 */
173 [18] = { 7658, 0, -3 }, /* power, 21V, irange200 */
183 * The PMON configuration register is a 16-bit register only on chips in adm1275_read_pmon_config()
184 * supporting power average sampling. On other chips it is an 8-bit in adm1275_read_pmon_config()
187 if (data->have_power_sampling) { in adm1275_read_pmon_config()
209 if (data->have_power_sampling) { in adm1275_write_pmon_config()
222 if (data->have_power_sampling) in adm1275_write_pmon_config()
240 return -ENXIO; in adm1275_read_word_data()
244 if (!data->have_uc_fault) in adm1275_read_word_data()
245 return -ENXIO; in adm1275_read_word_data()
250 if (!data->have_oc_fault) in adm1275_read_word_data()
251 return -ENXIO; in adm1275_read_word_data()
256 if (data->have_vout) in adm1275_read_word_data()
257 return -ENODATA; in adm1275_read_word_data()
262 if (data->have_vout) in adm1275_read_word_data()
263 return -ENODATA; in adm1275_read_word_data()
268 if (data->have_vout) in adm1275_read_word_data()
269 return -ENODATA; in adm1275_read_word_data()
274 if (!data->have_iout_min) in adm1275_read_word_data()
275 return -ENXIO; in adm1275_read_word_data()
292 if (!data->have_pin_min) in adm1275_read_word_data()
293 return -ENXIO; in adm1275_read_word_data()
298 if (!data->have_pin_max) in adm1275_read_word_data()
299 return -ENXIO; in adm1275_read_word_data()
304 if (!data->have_temp_max) in adm1275_read_word_data()
305 return -ENXIO; in adm1275_read_word_data()
314 if (!data->have_pin_max) in adm1275_read_word_data()
315 return -ENXIO; in adm1275_read_word_data()
318 if (!data->have_temp_max) in adm1275_read_word_data()
319 return -ENXIO; in adm1275_read_word_data()
322 if (!data->have_power_sampling) in adm1275_read_word_data()
323 return -ENXIO; in adm1275_read_word_data()
337 ret = -ENODATA; in adm1275_read_word_data()
351 return -ENXIO; in adm1275_write_word_data()
361 if (!ret && data->have_iout_min) in adm1275_write_word_data()
373 if (!ret && data->have_pin_min) in adm1275_write_word_data()
381 if (!data->have_power_sampling) in adm1275_write_word_data()
382 return -ENXIO; in adm1275_write_word_data()
394 ret = -ENODATA; in adm1275_write_word_data()
407 return -ENXIO; in adm1275_read_byte_data()
414 if (!data->have_oc_fault && !data->have_uc_fault) in adm1275_read_byte_data()
421 ret |= data->have_oc_fault ? in adm1275_read_byte_data()
426 if (data->have_vout) in adm1275_read_byte_data()
427 return -ENODATA; in adm1275_read_byte_data()
429 if (data->have_vaux_status) { in adm1275_read_byte_data()
438 } else if (data->have_mfr_vaux_status) { in adm1275_read_byte_data()
450 ret = -ENODATA; in adm1275_read_byte_data()
477 dev_err(&client->dev, "Failed to enable VOUT/TEMP1 monitoring\n"); in adm1275_enable_vout_temp()
494 int vindex = -1, voindex = -1, cindex = -1, pindex = -1; in adm1275_probe()
495 int tindex = -1; in adm1275_probe()
496 u32 shunt; in adm1275_probe() local
499 if (!i2c_check_functionality(client->adapter, in adm1275_probe()
502 return -ENODEV; in adm1275_probe()
506 dev_err(&client->dev, "Failed to read Manufacturer ID\n"); in adm1275_probe()
510 dev_err(&client->dev, "Unsupported Manufacturer ID\n"); in adm1275_probe()
511 return -ENODEV; in adm1275_probe()
516 dev_err(&client->dev, "Failed to read Manufacturer Model\n"); in adm1275_probe()
519 for (mid = adm1275_id; mid->name[0]; mid++) { in adm1275_probe()
520 if (!strncasecmp(mid->name, block_buffer, strlen(mid->name))) in adm1275_probe()
523 if (!mid->name[0]) { in adm1275_probe()
524 dev_err(&client->dev, "Unsupported device\n"); in adm1275_probe()
525 return -ENODEV; in adm1275_probe()
528 if (strcmp(client->name, mid->name) != 0) in adm1275_probe()
529 dev_notice(&client->dev, in adm1275_probe()
531 client->name, mid->name); in adm1275_probe()
533 if (mid->driver_data == adm1272 || mid->driver_data == adm1278 || in adm1275_probe()
534 mid->driver_data == adm1293 || mid->driver_data == adm1294) in adm1275_probe()
546 data = devm_kzalloc(&client->dev, sizeof(struct adm1275_data), in adm1275_probe()
549 return -ENOMEM; in adm1275_probe()
551 if (of_property_read_u32(client->dev.of_node, in adm1275_probe()
552 "shunt-resistor-micro-ohms", &shunt)) in adm1275_probe()
553 shunt = 1000; /* 1 mOhm if not set via DT */ in adm1275_probe()
555 if (shunt == 0) in adm1275_probe()
556 return -EINVAL; in adm1275_probe()
558 data->id = mid->driver_data; in adm1275_probe()
560 info = &data->info; in adm1275_probe()
562 info->pages = 1; in adm1275_probe()
563 info->format[PSC_VOLTAGE_IN] = direct; in adm1275_probe()
564 info->format[PSC_VOLTAGE_OUT] = direct; in adm1275_probe()
565 info->format[PSC_CURRENT_OUT] = direct; in adm1275_probe()
566 info->format[PSC_POWER] = direct; in adm1275_probe()
567 info->format[PSC_TEMPERATURE] = direct; in adm1275_probe()
568 info->func[0] = PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | in adm1275_probe()
571 info->read_word_data = adm1275_read_word_data; in adm1275_probe()
572 info->read_byte_data = adm1275_read_byte_data; in adm1275_probe()
573 info->write_word_data = adm1275_write_word_data; in adm1275_probe()
575 switch (data->id) { in adm1275_probe()
578 data->have_oc_fault = true; in adm1275_probe()
580 data->have_uc_fault = true; in adm1275_probe()
581 data->have_pin_max = true; in adm1275_probe()
582 data->have_vaux_status = true; in adm1275_probe()
596 dev_err(&client->dev, "Invalid input current range"); in adm1275_probe()
600 info->func[0] |= PMBUS_HAVE_VIN | PMBUS_HAVE_PIN in adm1275_probe()
603 info->func[0] |= in adm1275_probe()
607 data->have_vout = true; in adm1275_probe()
608 data->have_pin_max = true; in adm1275_probe()
609 data->have_temp_max = true; in adm1275_probe()
610 data->have_power_sampling = true; in adm1275_probe()
633 info->func[0] |= PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT | in adm1275_probe()
642 info->func[0] |= PMBUS_HAVE_VIN; in adm1275_probe()
646 data->have_oc_fault = true; in adm1275_probe()
648 data->have_uc_fault = true; in adm1275_probe()
649 data->have_vout = true; in adm1275_probe()
656 info->func[0] |= in adm1275_probe()
659 info->func[0] |= in adm1275_probe()
664 data->have_oc_fault = true; in adm1275_probe()
666 data->have_uc_fault = true; in adm1275_probe()
667 data->have_vout = true; in adm1275_probe()
668 data->have_pin_max = true; in adm1275_probe()
675 info->func[0] |= PMBUS_HAVE_VIN | PMBUS_HAVE_PIN in adm1275_probe()
678 info->func[0] |= in adm1275_probe()
682 data->have_vout = true; in adm1275_probe()
683 data->have_pin_max = true; in adm1275_probe()
684 data->have_temp_max = true; in adm1275_probe()
685 data->have_power_sampling = true; in adm1275_probe()
693 info->func[0] |= PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT | in adm1275_probe()
702 info->func[0] |= PMBUS_HAVE_VIN; in adm1275_probe()
706 data->have_iout_min = true; in adm1275_probe()
707 data->have_pin_min = true; in adm1275_probe()
708 data->have_pin_max = true; in adm1275_probe()
709 data->have_mfr_vaux_status = true; in adm1275_probe()
710 data->have_power_sampling = true; in adm1275_probe()
745 pindex = 7 + vindex * 4 + (cindex - 3); in adm1275_probe()
748 info->func[0] |= in adm1275_probe()
751 info->func[0] |= PMBUS_HAVE_PIN | in adm1275_probe()
756 dev_err(&client->dev, "Unsupported device\n"); in adm1275_probe()
757 return -ENODEV; in adm1275_probe()
760 if (data->have_power_sampling && in adm1275_probe()
761 of_property_read_u32(client->dev.of_node, in adm1275_probe()
762 "adi,power-sample-average", &avg) == 0) { in adm1275_probe()
765 dev_err(&client->dev, in adm1275_probe()
767 return -EINVAL; in adm1275_probe()
772 dev_err(&client->dev, in adm1275_probe()
779 if (of_property_read_u32(client->dev.of_node, in adm1275_probe()
780 "adi,volt-curr-sample-average", &avg) == 0) { in adm1275_probe()
783 dev_err(&client->dev, in adm1275_probe()
784 "Invalid number of voltage/current samples"); in adm1275_probe()
785 return -EINVAL; in adm1275_probe()
790 dev_err(&client->dev, in adm1275_probe()
791 "Setting voltage and current sample averaging failed with error %d", in adm1275_probe()
800 info->m[PSC_VOLTAGE_IN] = coefficients[vindex].m; in adm1275_probe()
801 info->b[PSC_VOLTAGE_IN] = coefficients[vindex].b; in adm1275_probe()
802 info->R[PSC_VOLTAGE_IN] = coefficients[vindex].R; in adm1275_probe()
805 info->m[PSC_VOLTAGE_OUT] = coefficients[voindex].m; in adm1275_probe()
806 info->b[PSC_VOLTAGE_OUT] = coefficients[voindex].b; in adm1275_probe()
807 info->R[PSC_VOLTAGE_OUT] = coefficients[voindex].R; in adm1275_probe()
810 /* Scale current with sense resistor value */ in adm1275_probe()
811 info->m[PSC_CURRENT_OUT] = in adm1275_probe()
812 coefficients[cindex].m * shunt / 1000; in adm1275_probe()
813 info->b[PSC_CURRENT_OUT] = coefficients[cindex].b; in adm1275_probe()
814 info->R[PSC_CURRENT_OUT] = coefficients[cindex].R; in adm1275_probe()
817 info->m[PSC_POWER] = in adm1275_probe()
818 coefficients[pindex].m * shunt / 1000; in adm1275_probe()
819 info->b[PSC_POWER] = coefficients[pindex].b; in adm1275_probe()
820 info->R[PSC_POWER] = coefficients[pindex].R; in adm1275_probe()
823 info->m[PSC_TEMPERATURE] = coefficients[tindex].m; in adm1275_probe()
824 info->b[PSC_TEMPERATURE] = coefficients[tindex].b; in adm1275_probe()
825 info->R[PSC_TEMPERATURE] = coefficients[tindex].R; in adm1275_probe()