Lines Matching +full:vref +full:- +full:buffered

1 // SPDX-License-Identifier: GPL-2.0
3 * IIO driver for Texas Instruments ADS7924 ADC, 12-bit, 4-Channels, I2C
8 * based on iio/adc/ti-ads1015.c
98 * The power-up time is allowed to elapse whenever the device has been shutdown
99 * in idle mode. Power-up time can allow external circuits, such as an
103 * If a power-up time is not required, set the bits to '0' to effectively bypass.
137 /* GPIO descriptor for device hard-reset pin. */
141 * Protects ADC ops, e.g: concurrent sysfs/buffered
147 * Set to true when the ADC is switched to the continuous-conversion
148 * mode and exits from a power-down state. This flag is used to avoid
198 if (chan->channel < 0 || chan->channel >= ADS7924_CHANNELS) in ads7924_get_adc_result()
199 return -EINVAL; in ads7924_get_adc_result()
201 if (data->conv_invalid) { in ads7924_get_adc_result()
208 data->conv_invalid = false; in ads7924_get_adc_result()
211 ret = regmap_raw_read(data->regmap, ADS7924_AUTO_INCREMENT_BIT | in ads7924_get_adc_result()
212 chan->address, &be_val, sizeof(be_val)); in ads7924_get_adc_result()
230 mutex_lock(&data->lock); in ads7924_read_raw()
232 mutex_unlock(&data->lock); in ads7924_read_raw()
238 vref_uv = regulator_get_voltage(data->vref_reg); in ads7924_read_raw()
246 return -EINVAL; in ads7924_read_raw()
258 struct device *dev = priv->dev; in ads7924_get_channels_config()
282 return -EINVAL; in ads7924_get_channels_config()
291 struct device *dev = data->dev; in ads7924_set_conv_mode()
302 ret = regmap_update_bits(data->regmap, ADS7924_MODECNTRL_REG, in ads7924_set_conv_mode()
314 ret = regmap_update_bits(data->regmap, ADS7924_MODECNTRL_REG, in ads7924_set_conv_mode()
327 if (data->reset_gpio) { in ads7924_reset()
328 gpiod_set_value(data->reset_gpio, 1); /* Assert. */ in ads7924_reset()
331 gpiod_set_value(data->reset_gpio, 0); /* Deassert. */ in ads7924_reset()
339 return regmap_write(data->regmap, ADS7924_RESET_REG, 0b10101010); in ads7924_reset()
356 struct device *dev = &client->dev; in ads7924_probe()
359 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); in ads7924_probe()
361 return dev_err_probe(dev, -ENOMEM, in ads7924_probe()
366 data->dev = dev; in ads7924_probe()
369 data->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); in ads7924_probe()
370 if (IS_ERR(data->reset_gpio)) in ads7924_probe()
371 return dev_err_probe(dev, PTR_ERR(data->reset_gpio), in ads7924_probe()
374 mutex_init(&data->lock); in ads7924_probe()
376 indio_dev->name = "ads7924"; in ads7924_probe()
377 indio_dev->modes = INDIO_DIRECT_MODE; in ads7924_probe()
379 indio_dev->channels = ads7924_channels; in ads7924_probe()
380 indio_dev->num_channels = ARRAY_SIZE(ads7924_channels); in ads7924_probe()
381 indio_dev->info = &ads7924_info; in ads7924_probe()
388 data->regmap = devm_regmap_init_i2c(client, &ads7924_regmap_config); in ads7924_probe()
389 if (IS_ERR(data->regmap)) in ads7924_probe()
390 return dev_err_probe(dev, PTR_ERR(data->regmap), in ads7924_probe()
393 data->vref_reg = devm_regulator_get(dev, "vref"); in ads7924_probe()
394 if (IS_ERR(data->vref_reg)) in ads7924_probe()
395 return dev_err_probe(dev, PTR_ERR(data->vref_reg), in ads7924_probe()
396 "failed to get vref regulator\n"); in ads7924_probe()
398 ret = regulator_enable(data->vref_reg); in ads7924_probe()
403 ret = devm_add_action_or_reset(dev, ads7924_reg_disable, data->vref_reg); in ads7924_probe()
424 ret = regmap_update_bits(data->regmap, ADS7924_ACQCONFIG_REG, in ads7924_probe()
431 /* Disable power-up time. */ in ads7924_probe()
432 ret = regmap_update_bits(data->regmap, ADS7924_PWRCONFIG_REG, in ads7924_probe()
437 "failed to configure power-up time\n"); in ads7924_probe()
439 data->conv_invalid = true; in ads7924_probe()