Lines Matching +full:shunt +full:- +full:resistor +full:- +full:micro +full:- +full:ohms
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Hardware monitoring driver for Analog Devices ADM1275 Hot-Swap Controller
110 [0] = { 27169, 0, -1 }, /* voltage */
111 [1] = { 806, 20475, -1 }, /* current, irange25 */
112 [2] = { 404, 20475, -1 }, /* current, irange50 */
113 [3] = { 8549, 0, -1 }, /* power, irange25 */
114 [4] = { 4279, 0, -1 }, /* power, irange50 */
118 [0] = { 6770, 0, -2 }, /* voltage, vrange 60V */
119 [1] = { 4062, 0, -2 }, /* voltage, vrange 100V */
120 [2] = { 1326, 20480, -1 }, /* current, vsense range 15mV */
121 [3] = { 663, 20480, -1 }, /* current, vsense range 30mV */
122 [4] = { 3512, 0, -2 }, /* power, vrange 60V, irange 15mV */
123 [5] = { 21071, 0, -3 }, /* power, vrange 100V, irange 15mV */
124 [6] = { 17561, 0, -3 }, /* power, vrange 60V, irange 30mV */
125 [7] = { 10535, 0, -3 }, /* power, vrange 100V, irange 30mV */
126 [8] = { 42, 31871, -1 }, /* temperature */
131 [0] = { 19199, 0, -2 }, /* voltage, vrange set */
132 [1] = { 6720, 0, -1 }, /* voltage, vrange not set */
133 [2] = { 807, 20475, -1 }, /* current */
137 [0] = { 19199, 0, -2 }, /* voltage, vrange set */
138 [1] = { 6720, 0, -1 }, /* voltage, vrange not set */
139 [2] = { 807, 20475, -1 }, /* current */
140 [3] = { 6043, 0, -2 }, /* power, vrange set */
141 [4] = { 2115, 0, -1 }, /* power, vrange not set */
145 [0] = { 19599, 0, -2 }, /* voltage */
146 [1] = { 800, 20475, -1 }, /* current */
147 [2] = { 6123, 0, -2 }, /* power */
148 [3] = { 42, 31880, -1 }, /* temperature */
152 [0] = { 3333, -1, 0 }, /* voltage, vrange 1.2V */
153 [1] = { 5552, -5, -1 }, /* voltage, vrange 7.4V */
154 [2] = { 19604, -50, -2 }, /* voltage, vrange 21V */
155 [3] = { 8000, -100, -2 }, /* current, irange25 */
156 [4] = { 4000, -100, -2 }, /* current, irange50 */
157 [5] = { 20000, -1000, -3 }, /* current, irange100 */
158 [6] = { 10000, -1000, -3 }, /* current, irange200 */
159 [7] = { 10417, 0, -1 }, /* power, 1.2V, irange25 */
160 [8] = { 5208, 0, -1 }, /* power, 1.2V, irange50 */
161 [9] = { 26042, 0, -2 }, /* power, 1.2V, irange100 */
162 [10] = { 13021, 0, -2 }, /* power, 1.2V, irange200 */
163 [11] = { 17351, 0, -2 }, /* power, 7.4V, irange25 */
164 [12] = { 8676, 0, -2 }, /* power, 7.4V, irange50 */
165 [13] = { 4338, 0, -2 }, /* power, 7.4V, irange100 */
166 [14] = { 21689, 0, -3 }, /* power, 7.4V, irange200 */
167 [15] = { 6126, 0, -2 }, /* power, 21V, irange25 */
168 [16] = { 30631, 0, -3 }, /* power, 21V, irange50 */
169 [17] = { 15316, 0, -3 }, /* power, 21V, irange100 */
170 [18] = { 7658, 0, -3 }, /* power, 21V, irange200 */
180 * The PMON configuration register is a 16-bit register only on chips in adm1275_read_pmon_config()
181 * supporting power average sampling. On other chips it is an 8-bit in adm1275_read_pmon_config()
184 if (data->have_power_sampling) { in adm1275_read_pmon_config()
206 if (data->have_power_sampling) { in adm1275_write_pmon_config()
219 if (data->have_power_sampling) in adm1275_write_pmon_config()
237 return -ENXIO; in adm1275_read_word_data()
241 if (!data->have_uc_fault) in adm1275_read_word_data()
242 return -ENXIO; in adm1275_read_word_data()
247 if (!data->have_oc_fault) in adm1275_read_word_data()
248 return -ENXIO; in adm1275_read_word_data()
253 if (data->have_vout) in adm1275_read_word_data()
254 return -ENODATA; in adm1275_read_word_data()
259 if (data->have_vout) in adm1275_read_word_data()
260 return -ENODATA; in adm1275_read_word_data()
265 if (data->have_vout) in adm1275_read_word_data()
266 return -ENODATA; in adm1275_read_word_data()
271 if (!data->have_iout_min) in adm1275_read_word_data()
272 return -ENXIO; in adm1275_read_word_data()
289 if (!data->have_pin_min) in adm1275_read_word_data()
290 return -ENXIO; in adm1275_read_word_data()
295 if (!data->have_pin_max) in adm1275_read_word_data()
296 return -ENXIO; in adm1275_read_word_data()
301 if (!data->have_temp_max) in adm1275_read_word_data()
302 return -ENXIO; in adm1275_read_word_data()
311 if (!data->have_pin_max) in adm1275_read_word_data()
312 return -ENXIO; in adm1275_read_word_data()
315 if (!data->have_temp_max) in adm1275_read_word_data()
316 return -ENXIO; in adm1275_read_word_data()
319 if (!data->have_power_sampling) in adm1275_read_word_data()
320 return -ENXIO; in adm1275_read_word_data()
334 ret = -ENODATA; in adm1275_read_word_data()
348 return -ENXIO; in adm1275_write_word_data()
358 if (!ret && data->have_iout_min) in adm1275_write_word_data()
370 if (!ret && data->have_pin_min) in adm1275_write_word_data()
378 if (!data->have_power_sampling) in adm1275_write_word_data()
379 return -ENXIO; in adm1275_write_word_data()
391 ret = -ENODATA; in adm1275_write_word_data()
404 return -ENXIO; in adm1275_read_byte_data()
411 if (!data->have_oc_fault && !data->have_uc_fault) in adm1275_read_byte_data()
418 ret |= data->have_oc_fault ? in adm1275_read_byte_data()
423 if (data->have_vout) in adm1275_read_byte_data()
424 return -ENODATA; in adm1275_read_byte_data()
426 if (data->have_vaux_status) { in adm1275_read_byte_data()
435 } else if (data->have_mfr_vaux_status) { in adm1275_read_byte_data()
447 ret = -ENODATA; in adm1275_read_byte_data()
475 int vindex = -1, voindex = -1, cindex = -1, pindex = -1; in adm1275_probe()
476 int tindex = -1; in adm1275_probe()
477 u32 shunt; in adm1275_probe() local
479 if (!i2c_check_functionality(client->adapter, in adm1275_probe()
482 return -ENODEV; in adm1275_probe()
486 dev_err(&client->dev, "Failed to read Manufacturer ID\n"); in adm1275_probe()
490 dev_err(&client->dev, "Unsupported Manufacturer ID\n"); in adm1275_probe()
491 return -ENODEV; in adm1275_probe()
496 dev_err(&client->dev, "Failed to read Manufacturer Model\n"); in adm1275_probe()
499 for (mid = adm1275_id; mid->name[0]; mid++) { in adm1275_probe()
500 if (!strncasecmp(mid->name, block_buffer, strlen(mid->name))) in adm1275_probe()
503 if (!mid->name[0]) { in adm1275_probe()
504 dev_err(&client->dev, "Unsupported device\n"); in adm1275_probe()
505 return -ENODEV; in adm1275_probe()
508 if (strcmp(client->name, mid->name) != 0) in adm1275_probe()
509 dev_notice(&client->dev, in adm1275_probe()
511 client->name, mid->name); in adm1275_probe()
513 if (mid->driver_data == adm1272 || mid->driver_data == adm1278 || in adm1275_probe()
514 mid->driver_data == adm1293 || mid->driver_data == adm1294) in adm1275_probe()
526 data = devm_kzalloc(&client->dev, sizeof(struct adm1275_data), in adm1275_probe()
529 return -ENOMEM; in adm1275_probe()
531 if (of_property_read_u32(client->dev.of_node, in adm1275_probe()
532 "shunt-resistor-micro-ohms", &shunt)) in adm1275_probe()
533 shunt = 1000; /* 1 mOhm if not set via DT */ in adm1275_probe()
535 if (shunt == 0) in adm1275_probe()
536 return -EINVAL; in adm1275_probe()
538 data->id = mid->driver_data; in adm1275_probe()
540 info = &data->info; in adm1275_probe()
542 info->pages = 1; in adm1275_probe()
543 info->format[PSC_VOLTAGE_IN] = direct; in adm1275_probe()
544 info->format[PSC_VOLTAGE_OUT] = direct; in adm1275_probe()
545 info->format[PSC_CURRENT_OUT] = direct; in adm1275_probe()
546 info->format[PSC_POWER] = direct; in adm1275_probe()
547 info->format[PSC_TEMPERATURE] = direct; in adm1275_probe()
548 info->func[0] = PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | in adm1275_probe()
551 info->read_word_data = adm1275_read_word_data; in adm1275_probe()
552 info->read_byte_data = adm1275_read_byte_data; in adm1275_probe()
553 info->write_word_data = adm1275_write_word_data; in adm1275_probe()
555 switch (data->id) { in adm1275_probe()
558 data->have_oc_fault = true; in adm1275_probe()
560 data->have_uc_fault = true; in adm1275_probe()
561 data->have_pin_max = true; in adm1275_probe()
562 data->have_vaux_status = true; in adm1275_probe()
576 dev_err(&client->dev, "Invalid input current range"); in adm1275_probe()
580 info->func[0] |= PMBUS_HAVE_VIN | PMBUS_HAVE_PIN in adm1275_probe()
583 info->func[0] |= in adm1275_probe()
587 data->have_vout = true; in adm1275_probe()
588 data->have_pin_max = true; in adm1275_probe()
589 data->have_temp_max = true; in adm1275_probe()
590 data->have_power_sampling = true; in adm1275_probe()
613 info->func[0] |= PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT | in adm1275_probe()
623 dev_err(&client->dev, in adm1275_probe()
625 return -ENODEV; in adm1275_probe()
630 info->func[0] |= in adm1275_probe()
633 info->func[0] |= PMBUS_HAVE_VIN; in adm1275_probe()
637 data->have_oc_fault = true; in adm1275_probe()
639 data->have_uc_fault = true; in adm1275_probe()
640 data->have_vout = true; in adm1275_probe()
647 info->func[0] |= in adm1275_probe()
650 info->func[0] |= in adm1275_probe()
655 data->have_oc_fault = true; in adm1275_probe()
657 data->have_uc_fault = true; in adm1275_probe()
658 data->have_vout = true; in adm1275_probe()
659 data->have_pin_max = true; in adm1275_probe()
666 info->func[0] |= PMBUS_HAVE_VIN | PMBUS_HAVE_PIN in adm1275_probe()
669 info->func[0] |= in adm1275_probe()
673 data->have_vout = true; in adm1275_probe()
674 data->have_pin_max = true; in adm1275_probe()
675 data->have_temp_max = true; in adm1275_probe()
676 data->have_power_sampling = true; in adm1275_probe()
684 info->func[0] |= PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT | in adm1275_probe()
696 dev_err(&client->dev, in adm1275_probe()
698 return -ENODEV; in adm1275_probe()
703 info->func[0] |= PMBUS_HAVE_VIN; in adm1275_probe()
707 data->have_iout_min = true; in adm1275_probe()
708 data->have_pin_min = true; in adm1275_probe()
709 data->have_pin_max = true; in adm1275_probe()
710 data->have_mfr_vaux_status = true; in adm1275_probe()
711 data->have_power_sampling = true; in adm1275_probe()
746 pindex = 7 + vindex * 4 + (cindex - 3); in adm1275_probe()
749 info->func[0] |= in adm1275_probe()
752 info->func[0] |= PMBUS_HAVE_PIN | in adm1275_probe()
757 dev_err(&client->dev, "Unsupported device\n"); in adm1275_probe()
758 return -ENODEV; in adm1275_probe()
764 info->m[PSC_VOLTAGE_IN] = coefficients[vindex].m; in adm1275_probe()
765 info->b[PSC_VOLTAGE_IN] = coefficients[vindex].b; in adm1275_probe()
766 info->R[PSC_VOLTAGE_IN] = coefficients[vindex].R; in adm1275_probe()
769 info->m[PSC_VOLTAGE_OUT] = coefficients[voindex].m; in adm1275_probe()
770 info->b[PSC_VOLTAGE_OUT] = coefficients[voindex].b; in adm1275_probe()
771 info->R[PSC_VOLTAGE_OUT] = coefficients[voindex].R; in adm1275_probe()
774 /* Scale current with sense resistor value */ in adm1275_probe()
775 info->m[PSC_CURRENT_OUT] = in adm1275_probe()
776 coefficients[cindex].m * shunt / 1000; in adm1275_probe()
777 info->b[PSC_CURRENT_OUT] = coefficients[cindex].b; in adm1275_probe()
778 info->R[PSC_CURRENT_OUT] = coefficients[cindex].R; in adm1275_probe()
781 info->m[PSC_POWER] = in adm1275_probe()
782 coefficients[pindex].m * shunt / 1000; in adm1275_probe()
783 info->b[PSC_POWER] = coefficients[pindex].b; in adm1275_probe()
784 info->R[PSC_POWER] = coefficients[pindex].R; in adm1275_probe()
787 info->m[PSC_TEMPERATURE] = coefficients[tindex].m; in adm1275_probe()
788 info->b[PSC_TEMPERATURE] = coefficients[tindex].b; in adm1275_probe()
789 info->R[PSC_TEMPERATURE] = coefficients[tindex].R; in adm1275_probe()