Lines Matching +full:vrefa +full:- +full:supply

1 // SPDX-License-Identifier: GPL-2.0-only
7 * Author: Lars-Peter Clausen <lars@metafoo.de>
38 * struct ad5449_chip_info - chip specific information
50 * struct ad5449 - driver instance specific data
53 * @vref_reg: vref supply regulators
90 mutex_lock(&st->lock); in ad5449_write()
91 st->data[0] = cpu_to_be16((addr << 12) | val); in ad5449_write()
92 ret = spi_write(st->spi, st->data, 2); in ad5449_write()
93 mutex_unlock(&st->lock); in ad5449_write()
105 .tx_buf = &st->data[0], in ad5449_read()
109 .tx_buf = &st->data[1], in ad5449_read()
110 .rx_buf = &st->data[1], in ad5449_read()
115 mutex_lock(&st->lock); in ad5449_read()
116 st->data[0] = cpu_to_be16(addr << 12); in ad5449_read()
117 st->data[1] = cpu_to_be16(AD5449_CMD_NOOP); in ad5449_read()
119 ret = spi_sync_transfer(st->spi, t, ARRAY_SIZE(t)); in ad5449_read()
123 *val = be16_to_cpu(st->data[1]); in ad5449_read()
126 mutex_unlock(&st->lock); in ad5449_read()
140 if (st->has_sdo) { in ad5449_read_raw()
142 AD5449_CMD_READ(chan->address), val); in ad5449_read_raw()
147 *val = st->dac_cache[chan->address]; in ad5449_read_raw()
152 reg = &st->vref_reg[chan->channel]; in ad5449_read_raw()
153 scale_uv = regulator_get_voltage(reg->consumer); in ad5449_read_raw()
158 *val2 = chan->scan_type.realbits; in ad5449_read_raw()
165 return -EINVAL; in ad5449_read_raw()
176 if (val < 0 || val >= (1 << chan->scan_type.realbits)) in ad5449_write_raw()
177 return -EINVAL; in ad5449_write_raw()
180 AD5449_CMD_LOAD_AND_UPDATE(chan->address), in ad5449_write_raw()
181 val << chan->scan_type.shift); in ad5449_write_raw()
183 st->dac_cache[chan->address] = val; in ad5449_write_raw()
186 ret = -EINVAL; in ad5449_write_raw()
209 .shift = 12 - (bits), \
258 if (st->chip_info->num_channels == 1) in ad5449_vref_name()
262 return "VREFA"; in ad5449_vref_name()
275 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); in ad5449_spi_probe()
277 return -ENOMEM; in ad5449_spi_probe()
282 st->chip_info = &ad5449_chip_info[id->driver_data]; in ad5449_spi_probe()
283 st->spi = spi; in ad5449_spi_probe()
285 for (i = 0; i < st->chip_info->num_channels; ++i) in ad5449_spi_probe()
286 st->vref_reg[i].supply = ad5449_vref_name(st, i); in ad5449_spi_probe()
288 ret = devm_regulator_bulk_get(&spi->dev, st->chip_info->num_channels, in ad5449_spi_probe()
289 st->vref_reg); in ad5449_spi_probe()
293 ret = regulator_bulk_enable(st->chip_info->num_channels, st->vref_reg); in ad5449_spi_probe()
297 indio_dev->name = id->name; in ad5449_spi_probe()
298 indio_dev->info = &ad5449_info; in ad5449_spi_probe()
299 indio_dev->modes = INDIO_DIRECT_MODE; in ad5449_spi_probe()
300 indio_dev->channels = st->chip_info->channels; in ad5449_spi_probe()
301 indio_dev->num_channels = st->chip_info->num_channels; in ad5449_spi_probe()
303 mutex_init(&st->lock); in ad5449_spi_probe()
305 if (st->chip_info->has_ctrl) { in ad5449_spi_probe()
306 st->has_sdo = true; in ad5449_spi_probe()
317 regulator_bulk_disable(st->chip_info->num_channels, st->vref_reg); in ad5449_spi_probe()
329 regulator_bulk_disable(st->chip_info->num_channels, st->vref_reg); in ad5449_spi_remove()
354 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");