Lines Matching +full:exca +full:- +full:output +full:- +full:en

1 // SPDX-License-Identifier: GPL-2.0
255 int ret = i2c_smbus_write_byte_data(chip->client, in ad7746_set_capdac()
257 chip->capdac[channel][0]); in ad7746_set_capdac()
261 return i2c_smbus_write_byte_data(chip->client, in ad7746_set_capdac()
263 chip->capdac[channel][1]); in ad7746_set_capdac()
273 switch (chan->type) { in ad7746_select_channel()
276 ad7746_chan_info[chan->address].cin2) | in ad7746_select_channel()
278 ad7746_chan_info[chan->address].capdiff) | in ad7746_select_channel()
280 vt_setup = chip->vt_setup & ~AD7746_VTSETUP_VTEN; in ad7746_select_channel()
281 idx = FIELD_GET(AD7746_CONF_CAPFS_MASK, chip->config); in ad7746_select_channel()
284 ret = ad7746_set_capdac(chip, chan->channel); in ad7746_select_channel()
288 chip->capdac_set = chan->channel; in ad7746_select_channel()
293 ad7746_chan_info[chan->address].vtmd) | in ad7746_select_channel()
295 cap_setup = chip->cap_setup & ~AD7746_CAPSETUP_CAPEN; in ad7746_select_channel()
296 idx = FIELD_GET(AD7746_CONF_VTFS_MASK, chip->config); in ad7746_select_channel()
300 return -EINVAL; in ad7746_select_channel()
303 if (chip->cap_setup != cap_setup) { in ad7746_select_channel()
304 ret = i2c_smbus_write_byte_data(chip->client, in ad7746_select_channel()
310 chip->cap_setup = cap_setup; in ad7746_select_channel()
313 if (chip->vt_setup != vt_setup) { in ad7746_select_channel()
314 ret = i2c_smbus_write_byte_data(chip->client, in ad7746_select_channel()
320 chip->vt_setup = vt_setup; in ad7746_select_channel()
344 mutex_lock(&chip->lock); in ad7746_start_calib()
345 regval |= chip->config; in ad7746_start_calib()
346 ret = i2c_smbus_write_byte_data(chip->client, AD7746_REG_CFG, regval); in ad7746_start_calib()
352 ret = i2c_smbus_read_byte_data(chip->client, AD7746_REG_CFG); in ad7746_start_calib()
356 } while ((ret == regval) && timeout--); in ad7746_start_calib()
358 mutex_unlock(&chip->lock); in ad7746_start_calib()
363 mutex_unlock(&chip->lock); in ad7746_start_calib()
374 &ad7746_channels[to_iio_dev_attr(attr)->address]); in ad7746_start_offset_calib()
390 &ad7746_channels[to_iio_dev_attr(attr)->address]); in ad7746_start_gain_calib()
420 i = ARRAY_SIZE(ad7746_cap_filter_rate_table) - 1; in ad7746_store_cap_filter_rate_setup()
422 chip->config &= ~AD7746_CONF_CAPFS_MASK; in ad7746_store_cap_filter_rate_setup()
423 chip->config |= FIELD_PREP(AD7746_CONF_CAPFS_MASK, i); in ad7746_store_cap_filter_rate_setup()
438 i = ARRAY_SIZE(ad7746_vt_filter_rate_table) - 1; in ad7746_store_vt_filter_rate_setup()
440 chip->config &= ~AD7746_CONF_VTFS_MASK; in ad7746_store_vt_filter_rate_setup()
441 chip->config |= FIELD_PREP(AD7746_CONF_VTFS_MASK, i); in ad7746_store_vt_filter_rate_setup()
471 return -EINVAL; in ad7746_write_raw()
475 switch (chan->type) { in ad7746_write_raw()
483 return -EINVAL; in ad7746_write_raw()
486 mutex_lock(&chip->lock); in ad7746_write_raw()
487 ret = i2c_smbus_write_word_swapped(chip->client, reg, val); in ad7746_write_raw()
488 mutex_unlock(&chip->lock); in ad7746_write_raw()
495 return -EINVAL; in ad7746_write_raw()
497 mutex_lock(&chip->lock); in ad7746_write_raw()
498 ret = i2c_smbus_write_word_swapped(chip->client, in ad7746_write_raw()
500 mutex_unlock(&chip->lock); in ad7746_write_raw()
508 return -EINVAL; in ad7746_write_raw()
517 mutex_lock(&chip->lock); in ad7746_write_raw()
518 chip->capdac[chan->channel][chan->differential] = val > 0 ? in ad7746_write_raw()
521 ret = ad7746_set_capdac(chip, chan->channel); in ad7746_write_raw()
523 mutex_unlock(&chip->lock); in ad7746_write_raw()
527 chip->capdac_set = chan->channel; in ad7746_write_raw()
528 mutex_unlock(&chip->lock); in ad7746_write_raw()
533 return -EINVAL; in ad7746_write_raw()
535 switch (chan->type) { in ad7746_write_raw()
537 mutex_lock(&chip->lock); in ad7746_write_raw()
539 mutex_unlock(&chip->lock); in ad7746_write_raw()
542 mutex_lock(&chip->lock); in ad7746_write_raw()
544 mutex_unlock(&chip->lock); in ad7746_write_raw()
547 return -EINVAL; in ad7746_write_raw()
550 return -EINVAL; in ad7746_write_raw()
562 return -EINVAL; in ad7746_read_avail()
564 switch (chan->type) { in ad7746_read_avail()
574 return -EINVAL; in ad7746_read_avail()
594 regval = chip->config | FIELD_PREP(AD7746_CONF_MODE_MASK, in ad7746_read_channel()
596 ret = i2c_smbus_write_byte_data(chip->client, AD7746_REG_CFG, regval); in ad7746_read_channel()
602 ret = i2c_smbus_read_i2c_block_data(chip->client, in ad7746_read_channel()
603 ad7746_chan_info[chan->address].addr, in ad7746_read_channel()
612 *val = get_unaligned_be24(data) - 0x800000; in ad7746_read_channel()
628 mutex_lock(&chip->lock); in ad7746_read_raw()
630 mutex_unlock(&chip->lock); in ad7746_read_raw()
636 switch (chan->type) { in ad7746_read_raw()
644 return -EINVAL; in ad7746_read_raw()
647 mutex_lock(&chip->lock); in ad7746_read_raw()
648 ret = i2c_smbus_read_word_swapped(chip->client, reg); in ad7746_read_raw()
649 mutex_unlock(&chip->lock); in ad7746_read_raw()
658 mutex_lock(&chip->lock); in ad7746_read_raw()
659 ret = i2c_smbus_read_word_swapped(chip->client, in ad7746_read_raw()
661 mutex_unlock(&chip->lock); in ad7746_read_raw()
670 chip->capdac[chan->channel][chan->differential]) * 338646; in ad7746_read_raw()
674 switch (chan->type) { in ad7746_read_raw()
683 if (chan->channel == 1) in ad7746_read_raw()
692 return -EINVAL; in ad7746_read_raw()
695 switch (chan->type) { in ad7746_read_raw()
697 idx = FIELD_GET(AD7746_CONF_CAPFS_MASK, chip->config); in ad7746_read_raw()
701 idx = FIELD_GET(AD7746_CONF_VTFS_MASK, chip->config); in ad7746_read_raw()
705 return -EINVAL; in ad7746_read_raw()
708 return -EINVAL; in ad7746_read_raw()
722 struct device *dev = &client->dev; in ad7746_probe()
729 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip)); in ad7746_probe()
731 return -ENOMEM; in ad7746_probe()
734 mutex_init(&chip->lock); in ad7746_probe()
736 chip->client = client; in ad7746_probe()
737 chip->capdac_set = -1; in ad7746_probe()
739 indio_dev->name = id->name; in ad7746_probe()
740 indio_dev->info = &ad7746_info; in ad7746_probe()
741 indio_dev->channels = ad7746_channels; in ad7746_probe()
742 if (id->driver_data == 7746) in ad7746_probe()
743 indio_dev->num_channels = ARRAY_SIZE(ad7746_channels); in ad7746_probe()
745 indio_dev->num_channels = ARRAY_SIZE(ad7746_channels) - 2; in ad7746_probe()
746 indio_dev->modes = INDIO_DIRECT_MODE; in ad7746_probe()
748 if (device_property_read_bool(dev, "adi,exca-output-en")) { in ad7746_probe()
749 if (device_property_read_bool(dev, "adi,exca-output-invert")) in ad7746_probe()
755 if (device_property_read_bool(dev, "adi,excb-output-en")) { in ad7746_probe()
756 if (device_property_read_bool(dev, "adi,excb-output-invert")) in ad7746_probe()
762 ret = device_property_read_u32(dev, "adi,excitation-vdd-permille", in ad7746_probe()
783 ret = i2c_smbus_write_byte_data(chip->client, AD7746_REG_EXC_SETUP, in ad7746_probe()
788 return devm_iio_device_register(indio_dev->dev.parent, indio_dev); in ad7746_probe()