Lines Matching +full:vref +full:- +full:p

1 // SPDX-License-Identifier: GPL-2.0-only
3 * TI ADC081C/ADC101C/ADC121C 8/10/12-bit ADC driver
14 * bits handled. For the 8-bit and 10-bit models the least-significant 4 or 2
55 err = i2c_smbus_read_word_swapped(adc->i2c, REG_CONV_RES); in adc081c_read_raw()
59 *value = (err & 0xFFF) >> (12 - adc->bits); in adc081c_read_raw()
63 err = regulator_get_voltage(adc->ref); in adc081c_read_raw()
68 *shift = adc->bits; in adc081c_read_raw()
76 return -EINVAL; in adc081c_read_raw()
87 .shift = 12 - (_bits), \
132 static irqreturn_t adc081c_trigger_handler(int irq, void *p) in adc081c_trigger_handler() argument
134 struct iio_poll_func *pf = p; in adc081c_trigger_handler()
135 struct iio_dev *indio_dev = pf->indio_dev; in adc081c_trigger_handler()
139 ret = i2c_smbus_read_word_swapped(data->i2c, REG_CONV_RES); in adc081c_trigger_handler()
142 data->scan.channel = ret; in adc081c_trigger_handler()
143 iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, in adc081c_trigger_handler()
146 iio_trigger_notify_done(indio_dev->trig); in adc081c_trigger_handler()
163 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA)) in adc081c_probe()
164 return -EOPNOTSUPP; in adc081c_probe()
166 if (dev_fwnode(&client->dev)) in adc081c_probe()
167 model = device_get_match_data(&client->dev); in adc081c_probe()
169 model = &adcxx1c_models[id->driver_data]; in adc081c_probe()
171 iio = devm_iio_device_alloc(&client->dev, sizeof(*adc)); in adc081c_probe()
173 return -ENOMEM; in adc081c_probe()
176 adc->i2c = client; in adc081c_probe()
177 adc->bits = model->bits; in adc081c_probe()
179 adc->ref = devm_regulator_get(&client->dev, "vref"); in adc081c_probe()
180 if (IS_ERR(adc->ref)) in adc081c_probe()
181 return PTR_ERR(adc->ref); in adc081c_probe()
183 err = regulator_enable(adc->ref); in adc081c_probe()
187 err = devm_add_action_or_reset(&client->dev, adc081c_reg_disable, in adc081c_probe()
188 adc->ref); in adc081c_probe()
192 iio->name = dev_name(&client->dev); in adc081c_probe()
193 iio->modes = INDIO_DIRECT_MODE; in adc081c_probe()
194 iio->info = &adc081c_info; in adc081c_probe()
196 iio->channels = model->channels; in adc081c_probe()
197 iio->num_channels = ADC081C_NUM_CHANNELS; in adc081c_probe()
199 err = devm_iio_triggered_buffer_setup(&client->dev, iio, NULL, in adc081c_probe()
202 dev_err(&client->dev, "iio triggered buffer setup failed\n"); in adc081c_probe()
206 return devm_iio_device_register(&client->dev, iio); in adc081c_probe()
243 MODULE_AUTHOR("Thierry Reding <thierry.reding@avionic-design.de>");