Lines Matching +full:tia +full:- +full:gain +full:- +full:ohm

1 // SPDX-License-Identifier: GPL-2.0+
3 * lmp91000.c - Support for Texas Instruments digital potentiostats
42 #define LMP91000_TEMP_BASE -40
74 /* 64-bit data + 64-bit naturally aligned timestamp */
99 .scan_index = -1,
107 ret = regmap_read(data->regmap, LMP91000_REG_MODECN, &state); in lmp91000_read()
109 return -EINVAL; in lmp91000_read()
111 ret = regmap_write(data->regmap, LMP91000_REG_MODECN, channel); in lmp91000_read()
113 return -EINVAL; in lmp91000_read()
119 data->chan_select = channel != LMP91000_REG_MODECN_3LEAD; in lmp91000_read()
121 iio_trigger_poll_nested(data->trig); in lmp91000_read()
123 ret = wait_for_completion_timeout(&data->completion, HZ); in lmp91000_read()
124 reinit_completion(&data->completion); in lmp91000_read()
127 return -ETIMEDOUT; in lmp91000_read()
129 *val = data->buffer[data->chan_select]; in lmp91000_read()
137 struct iio_dev *indio_dev = pf->indio_dev; in lmp91000_buffer_handler()
141 memset(data->buffer, 0, sizeof(data->buffer)); in lmp91000_buffer_handler()
145 data->buffer[0] = val; in lmp91000_buffer_handler()
146 iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, in lmp91000_buffer_handler()
150 iio_trigger_notify_done(indio_dev->trig); in lmp91000_buffer_handler()
164 int ret = iio_channel_start_all_cb(data->cb_buffer); in lmp91000_read_raw()
169 ret = lmp91000_read(data, chan->address, val); in lmp91000_read_raw()
171 iio_channel_stop_all_cb(data->cb_buffer); in lmp91000_read_raw()
179 ret = iio_convert_raw_to_processed(data->adc_chan, in lmp91000_read_raw()
193 return iio_read_channel_offset(data->adc_chan, val, val2); in lmp91000_read_raw()
195 return iio_read_channel_scale(data->adc_chan, val, val2); in lmp91000_read_raw()
198 return -EINVAL; in lmp91000_read_raw()
207 struct device *dev = data->dev; in lmp91000_read_config()
211 ret = device_property_read_u32(dev, "ti,tia-gain-ohm", &val); in lmp91000_read_config()
213 if (!device_property_read_bool(dev, "ti,external-tia-resistor")) { in lmp91000_read_config()
214 dev_err(dev, "no ti,tia-gain-ohm defined and external resistor not specified\n"); in lmp91000_read_config()
220 ret = -EINVAL; in lmp91000_read_config()
230 dev_err(dev, "invalid ti,tia-gain-ohm %d\n", val); in lmp91000_read_config()
234 ret = device_property_read_u32(dev, "ti,rload-ohm", &val); in lmp91000_read_config()
237 dev_info(dev, "no ti,rload-ohm defined, default to %d\n", val); in lmp91000_read_config()
240 ret = -EINVAL; in lmp91000_read_config()
250 dev_err(dev, "invalid ti,rload-ohm %d\n", val); in lmp91000_read_config()
254 regmap_write(data->regmap, LMP91000_REG_LOCK, 0); in lmp91000_read_config()
255 regmap_write(data->regmap, LMP91000_REG_TIACN, reg); in lmp91000_read_config()
256 regmap_write(data->regmap, LMP91000_REG_REFCN, in lmp91000_read_config()
258 regmap_write(data->regmap, LMP91000_REG_LOCK, 1); in lmp91000_read_config()
268 data->buffer[data->chan_select] = *((int *)val); in lmp91000_buffer_cb()
269 complete_all(&data->completion); in lmp91000_buffer_cb()
278 return iio_channel_start_all_cb(data->cb_buffer); in lmp91000_buffer_postenable()
285 iio_channel_stop_all_cb(data->cb_buffer); in lmp91000_buffer_predisable()
297 struct device *dev = &client->dev; in lmp91000_probe()
304 return -ENOMEM; in lmp91000_probe()
306 indio_dev->info = &lmp91000_info; in lmp91000_probe()
307 indio_dev->channels = lmp91000_channels; in lmp91000_probe()
308 indio_dev->num_channels = ARRAY_SIZE(lmp91000_channels); in lmp91000_probe()
309 indio_dev->name = LMP91000_DRV_NAME; in lmp91000_probe()
310 indio_dev->modes = INDIO_DIRECT_MODE; in lmp91000_probe()
314 data->dev = dev; in lmp91000_probe()
315 data->regmap = devm_regmap_init_i2c(client, &lmp91000_regmap_config); in lmp91000_probe()
316 if (IS_ERR(data->regmap)) { in lmp91000_probe()
318 return PTR_ERR(data->regmap); in lmp91000_probe()
321 data->trig = devm_iio_trigger_alloc(dev, "%s-mux%d", in lmp91000_probe()
322 indio_dev->name, in lmp91000_probe()
324 if (!data->trig) { in lmp91000_probe()
326 return -ENOMEM; in lmp91000_probe()
329 init_completion(&data->completion); in lmp91000_probe()
335 ret = iio_trigger_set_immutable(iio_channel_cb_get_iio_dev(data->cb_buffer), in lmp91000_probe()
336 data->trig); in lmp91000_probe()
342 ret = iio_trigger_register(data->trig); in lmp91000_probe()
354 data->cb_buffer = iio_channel_get_all_cb(dev, &lmp91000_buffer_cb, in lmp91000_probe()
357 if (IS_ERR(data->cb_buffer)) { in lmp91000_probe()
358 if (PTR_ERR(data->cb_buffer) == -ENODEV) in lmp91000_probe()
359 ret = -EPROBE_DEFER; in lmp91000_probe()
361 ret = PTR_ERR(data->cb_buffer); in lmp91000_probe()
366 data->adc_chan = iio_channel_cb_get_channels(data->cb_buffer); in lmp91000_probe()
375 iio_channel_release_all_cb(data->cb_buffer); in lmp91000_probe()
381 iio_trigger_unregister(data->trig); in lmp91000_probe()
393 iio_channel_stop_all_cb(data->cb_buffer); in lmp91000_remove()
394 iio_channel_release_all_cb(data->cb_buffer); in lmp91000_remove()
397 iio_trigger_unregister(data->trig); in lmp91000_remove()