Lines Matching +full:shunt +full:- +full:resistor +full:- +full:micro +full:- +full:ohms
1 // SPDX-License-Identifier: GPL-2.0
6 * 12-bit ADC interface.
12 * This driver supports input common-mode voltage, current-sense
16 * Op-amp, analog comparator, and watchdog functionalities are not
58 * (((adc_read >> 4) - offset) / ((1 / LSB) * 10^-3)
72 * (((adc_read >> 4) * 1000) - offset) / (1 / 14 * 1000)
114 * max9611_mux_conf - associate ADC mux configuration with register address
137 * max9611_csa_gain_conf - associate gain multiplier with LSB and
195 * max9611_read_single() - read a single value from ADC interface
202 * Data are transmitted with big-endian ordering: MSB arrives first.
218 * Keep mutex lock held during read-write to avoid mux register in max9611_read_single()
219 * (CTRL1) re-configuration. in max9611_read_single()
221 mutex_lock(&max9611->lock); in max9611_read_single()
222 ret = i2c_smbus_write_byte_data(max9611->i2c_client, in max9611_read_single()
225 dev_err(max9611->dev, "i2c write byte failed: 0x%2x - 0x%2x\n", in max9611_read_single()
227 mutex_unlock(&max9611->lock); in max9611_read_single()
235 ret = i2c_smbus_read_word_swapped(max9611->i2c_client, reg_addr); in max9611_read_single()
237 dev_err(max9611->dev, "i2c read word from 0x%2x failed\n", in max9611_read_single()
239 mutex_unlock(&max9611->lock); in max9611_read_single()
244 mutex_unlock(&max9611->lock); in max9611_read_single()
250 * max9611_read_csa_voltage() - read current sense amplifier output voltage
284 return -EIO; in max9611_read_csa_voltage()
300 switch (chan->address) { in max9611_read_raw()
305 return -EINVAL; in max9611_read_raw()
314 return -EINVAL; in max9611_read_raw()
330 switch (chan->address) { in max9611_read_raw()
347 switch (chan->address) { in max9611_read_raw()
350 * processed (mV): (raw - offset) * LSB (nV) / 10^6 in max9611_read_raw()
358 return -EINVAL; in max9611_read_raw()
362 adc_data -= csa_gain[CSA_GAIN_OFFS_RAW]; in max9611_read_raw()
374 return -EINVAL; in max9611_read_raw()
378 adc_data -= csa_gain[CSA_GAIN_OFFS_RAW]; in max9611_read_raw()
381 *val2 = dev->shunt_resistor_uohm; in max9611_read_raw()
393 return -EINVAL; in max9611_read_raw()
395 adc_data -= MAX9611_CIM_OFFSET_RAW; in max9611_read_raw()
402 return -EINVAL; in max9611_read_raw()
407 adc_data -= csa_gain[CSA_GAIN_OFFS_RAW]; in max9611_read_raw()
410 *val2 = dev->shunt_resistor_uohm; in max9611_read_raw()
418 return -EINVAL; in max9611_read_raw()
428 i = max9611->shunt_resistor_uohm / 1000000; in max9611_shunt_resistor_show()
429 r = max9611->shunt_resistor_uohm % 1000000; in max9611_shunt_resistor_show()
456 struct i2c_client *client = max9611->i2c_client; in max9611_init()
460 if (!i2c_check_functionality(client->adapter, in max9611_init()
463 dev_err(max9611->dev, in max9611_init()
465 return -EINVAL; in max9611_init()
478 dev_err(max9611->dev, in max9611_init()
481 return -EIO; in max9611_init()
485 ret = i2c_smbus_write_byte_data(max9611->i2c_client, in max9611_init()
488 dev_err(max9611->dev, "i2c write byte failed: 0x%2x - 0x%2x\n", in max9611_init()
493 ret = i2c_smbus_write_byte_data(max9611->i2c_client, in max9611_init()
496 dev_err(max9611->dev, "i2c write byte failed: 0x%2x - 0x%2x\n", in max9611_init()
515 const char * const shunt_res_prop = "shunt-resistor-micro-ohms"; in max9611_probe()
516 const struct device_node *of_node = client->dev.of_node; in max9611_probe()
518 of_match_device(max9611_of_table, &client->dev); in max9611_probe()
524 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*max9611)); in max9611_probe()
526 return -ENOMEM; in max9611_probe()
531 max9611->dev = &client->dev; in max9611_probe()
532 max9611->i2c_client = client; in max9611_probe()
533 mutex_init(&max9611->lock); in max9611_probe()
537 dev_err(&client->dev, in max9611_probe()
542 max9611->shunt_resistor_uohm = of_shunt; in max9611_probe()
548 indio_dev->name = of_id->data; in max9611_probe()
549 indio_dev->modes = INDIO_DIRECT_MODE; in max9611_probe()
550 indio_dev->info = &indio_info; in max9611_probe()
551 indio_dev->channels = max9611_channels; in max9611_probe()
552 indio_dev->num_channels = ARRAY_SIZE(max9611_channels); in max9611_probe()
554 return devm_iio_device_register(&client->dev, indio_dev); in max9611_probe()