Lines Matching +full:keep +full:- +full:vref +full:- +full:on
1 // SPDX-License-Identifier: GPL-2.0-only
3 * ltc2497-core.c - Common code for Analog Devices/Linear Technology
26 time_elapsed = ktime_ms_delta(ktime_get(), ddata->time_prev); in ltc2497core_wait_conv()
33 LTC2497_CONVERSION_TIME_MS - time_elapsed)) in ltc2497core_wait_conv()
34 return -ERESTARTSYS; in ltc2497core_wait_conv()
39 if (time_elapsed - LTC2497_CONVERSION_TIME_MS <= 0) { in ltc2497core_wait_conv()
40 /* We're in automatic mode - in ltc2497core_wait_conv()
57 if (ret || ddata->addr_prev != address) { in ltc2497core_read()
58 ret = ddata->result_and_measure(ddata, address, NULL); in ltc2497core_read()
61 ddata->addr_prev = address; in ltc2497core_read()
64 return -ERESTARTSYS; in ltc2497core_read()
67 ret = ddata->result_and_measure(ddata, address, val); in ltc2497core_read()
71 ddata->time_prev = ktime_get(); in ltc2497core_read()
85 mutex_lock(&ddata->lock); in ltc2497core_read_raw()
86 ret = ltc2497core_read(ddata, chan->address, val); in ltc2497core_read_raw()
87 mutex_unlock(&ddata->lock); in ltc2497core_read_raw()
94 ret = regulator_get_voltage(ddata->ref); in ltc2497core_read_raw()
99 *val2 = ddata->chip_info->resolution + 1; in ltc2497core_read_raw()
104 return -EINVAL; in ltc2497core_read_raw()
174 * Keep using dev_name() for the iio_dev's name on some of the parts, in ltc2497core_probe()
177 if (ddata->chip_info->name) in ltc2497core_probe()
178 indio_dev->name = ddata->chip_info->name; in ltc2497core_probe()
180 indio_dev->name = dev_name(dev); in ltc2497core_probe()
182 indio_dev->info = <c2497core_info; in ltc2497core_probe()
183 indio_dev->modes = INDIO_DIRECT_MODE; in ltc2497core_probe()
184 indio_dev->channels = ltc2497core_channel; in ltc2497core_probe()
185 indio_dev->num_channels = ARRAY_SIZE(ltc2497core_channel); in ltc2497core_probe()
187 ret = ddata->result_and_measure(ddata, LTC2497_CONFIG_DEFAULT, NULL); in ltc2497core_probe()
191 ddata->ref = devm_regulator_get(dev, "vref"); in ltc2497core_probe()
192 if (IS_ERR(ddata->ref)) in ltc2497core_probe()
193 return dev_err_probe(dev, PTR_ERR(ddata->ref), in ltc2497core_probe()
194 "Failed to get vref regulator\n"); in ltc2497core_probe()
196 ret = regulator_enable(ddata->ref); in ltc2497core_probe()
198 dev_err(dev, "Failed to enable vref regulator: %pe\n", in ltc2497core_probe()
203 if (dev->platform_data) { in ltc2497core_probe()
206 plat_data = (struct iio_map *)dev->platform_data; in ltc2497core_probe()
210 dev_err(&indio_dev->dev, "iio map err: %d\n", ret); in ltc2497core_probe()
215 ddata->addr_prev = LTC2497_CONFIG_DEFAULT; in ltc2497core_probe()
216 ddata->time_prev = ktime_get(); in ltc2497core_probe()
218 mutex_init(&ddata->lock); in ltc2497core_probe()
230 regulator_disable(ddata->ref); in ltc2497core_probe()
244 regulator_disable(ddata->ref); in ltc2497core_remove()