Lines Matching +full:ad7091r +full:- +full:4
1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright 2014-2019 Analog Devices Inc.
17 #include "ad7091r-base.h"
46 ret = regmap_write(st->map, AD7091R_REG_CHANNEL, in ad7091r_set_channel()
55 return regmap_read(st->map, AD7091R_REG_RESULT, &dummy); in ad7091r_set_channel()
69 ret = regmap_read(st->map, AD7091R_REG_RESULT, &val); in ad7091r_read_one()
73 if (st->chip_info->reg_result_chan_id(val) != channel) in ad7091r_read_one()
74 return -EIO; in ad7091r_read_one()
89 guard(mutex)(&st->lock); in ad7091r_read_raw()
93 if (st->mode != AD7091R_MODE_COMMAND) in ad7091r_read_raw()
94 return -EBUSY; in ad7091r_read_raw()
96 ret = ad7091r_read_one(iio_dev, chan->channel, &read_val); in ad7091r_read_raw()
104 if (st->vref) { in ad7091r_read_raw()
105 ret = regulator_get_voltage(st->vref); in ad7091r_read_raw()
111 *val = st->chip_info->vref_mV; in ad7091r_read_raw()
114 *val2 = chan->scan_type.realbits; in ad7091r_read_raw()
118 return -EINVAL; in ad7091r_read_raw()
132 ret = regmap_read(st->map, in ad7091r_read_event_config()
133 AD7091R_REG_CH_HIGH_LIMIT(chan->channel), in ad7091r_read_event_config()
139 ret = regmap_read(st->map, in ad7091r_read_event_config()
140 AD7091R_REG_CH_LOW_LIMIT(chan->channel), in ad7091r_read_event_config()
146 return -EINVAL; in ad7091r_read_event_config()
158 return regmap_set_bits(st->map, AD7091R_REG_CONF, in ad7091r_write_event_config()
162 * Set thresholds either to 0 or to 2^12 - 1 as appropriate to in ad7091r_write_event_config()
167 return regmap_write(st->map, in ad7091r_write_event_config()
168 AD7091R_REG_CH_HIGH_LIMIT(chan->channel), in ad7091r_write_event_config()
171 return regmap_write(st->map, in ad7091r_write_event_config()
172 AD7091R_REG_CH_LOW_LIMIT(chan->channel), in ad7091r_write_event_config()
175 return -EINVAL; in ad7091r_write_event_config()
193 ret = regmap_read(st->map, in ad7091r_read_event_value()
194 AD7091R_REG_CH_HIGH_LIMIT(chan->channel), in ad7091r_read_event_value()
200 ret = regmap_read(st->map, in ad7091r_read_event_value()
201 AD7091R_REG_CH_LOW_LIMIT(chan->channel), in ad7091r_read_event_value()
207 return -EINVAL; in ad7091r_read_event_value()
210 ret = regmap_read(st->map, in ad7091r_read_event_value()
211 AD7091R_REG_CH_HYSTERESIS(chan->channel), in ad7091r_read_event_value()
217 return -EINVAL; in ad7091r_read_event_value()
233 return regmap_write(st->map, in ad7091r_write_event_value()
234 AD7091R_REG_CH_HIGH_LIMIT(chan->channel), in ad7091r_write_event_value()
237 return regmap_write(st->map, in ad7091r_write_event_value()
238 AD7091R_REG_CH_LOW_LIMIT(chan->channel), in ad7091r_write_event_value()
241 return -EINVAL; in ad7091r_write_event_value()
244 return regmap_write(st->map, in ad7091r_write_event_value()
245 AD7091R_REG_CH_HYSTERESIS(chan->channel), in ad7091r_write_event_value()
248 return -EINVAL; in ad7091r_write_event_value()
268 ret = regmap_read(st->map, AD7091R_REG_ALERT, &read_val); in ad7091r_event_handler()
272 for (i = 0; i < st->chip_info->num_channels; i++) { in ad7091r_event_handler()
292 regulator_disable(st->vref); in ad7091r_remove()
304 return -ENOMEM; in ad7091r_probe()
307 st->dev = dev; in ad7091r_probe()
308 init_info->init_adc_regmap(st, init_info->regmap_config); in ad7091r_probe()
309 if (IS_ERR(st->map)) in ad7091r_probe()
310 return dev_err_probe(st->dev, PTR_ERR(st->map), in ad7091r_probe()
313 iio_dev->info = &ad7091r_info; in ad7091r_probe()
314 iio_dev->modes = INDIO_DIRECT_MODE; in ad7091r_probe()
316 if (init_info->setup) { in ad7091r_probe()
317 ret = init_info->setup(st); in ad7091r_probe()
323 st->chip_info = init_info->info_irq; in ad7091r_probe()
324 ret = regmap_update_bits(st->map, AD7091R_REG_CONF, in ad7091r_probe()
325 AD7091R_REG_CONF_ALERT_EN, BIT(4)); in ad7091r_probe()
333 st->chip_info->name, iio_dev); in ad7091r_probe()
337 st->chip_info = init_info->info_no_irq; in ad7091r_probe()
340 iio_dev->name = st->chip_info->name; in ad7091r_probe()
341 iio_dev->num_channels = st->chip_info->num_channels; in ad7091r_probe()
342 iio_dev->channels = st->chip_info->channels; in ad7091r_probe()
344 st->vref = devm_regulator_get_optional(dev, "vref"); in ad7091r_probe()
345 if (IS_ERR(st->vref)) { in ad7091r_probe()
346 if (PTR_ERR(st->vref) == -EPROBE_DEFER) in ad7091r_probe()
347 return -EPROBE_DEFER; in ad7091r_probe()
349 st->vref = NULL; in ad7091r_probe()
351 ret = regmap_set_bits(st->map, AD7091R_REG_CONF, in ad7091r_probe()
354 return dev_err_probe(st->dev, ret, in ad7091r_probe()
357 ret = regulator_enable(st->vref); in ad7091r_probe()
366 ret = st->chip_info->set_mode(st, AD7091R_MODE_COMMAND); in ad7091r_probe()
399 MODULE_DESCRIPTION("Analog Devices AD7091Rx multi-channel converters");