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

1 // SPDX-License-Identifier: GPL-2.0-only
7 * Author: Lars-Peter Clausen <lars@metafoo.de>
40 * struct ad5449_chip_info - chip specific information
52 * struct ad5449 - driver instance specific data
55 * @vref_reg: vref supply regulators
92 mutex_lock(&st->lock); in ad5449_write()
93 st->data[0] = cpu_to_be16((addr << 12) | val); in ad5449_write()
94 ret = spi_write(st->spi, st->data, 2); in ad5449_write()
95 mutex_unlock(&st->lock); in ad5449_write()
107 .tx_buf = &st->data[0], in ad5449_read()
111 .tx_buf = &st->data[1], in ad5449_read()
112 .rx_buf = &st->data[1], in ad5449_read()
117 mutex_lock(&st->lock); in ad5449_read()
118 st->data[0] = cpu_to_be16(addr << 12); in ad5449_read()
119 st->data[1] = cpu_to_be16(AD5449_CMD_NOOP); in ad5449_read()
121 ret = spi_sync_transfer(st->spi, t, ARRAY_SIZE(t)); in ad5449_read()
125 *val = be16_to_cpu(st->data[1]); in ad5449_read()
128 mutex_unlock(&st->lock); in ad5449_read()
142 if (st->has_sdo) { in ad5449_read_raw()
144 AD5449_CMD_READ(chan->address), val); in ad5449_read_raw()
149 *val = st->dac_cache[chan->address]; in ad5449_read_raw()
154 reg = &st->vref_reg[chan->channel]; in ad5449_read_raw()
155 scale_uv = regulator_get_voltage(reg->consumer); in ad5449_read_raw()
160 *val2 = chan->scan_type.realbits; in ad5449_read_raw()
167 return -EINVAL; in ad5449_read_raw()
178 if (val < 0 || val >= (1 << chan->scan_type.realbits)) in ad5449_write_raw()
179 return -EINVAL; in ad5449_write_raw()
182 AD5449_CMD_LOAD_AND_UPDATE(chan->address), in ad5449_write_raw()
183 val << chan->scan_type.shift); in ad5449_write_raw()
185 st->dac_cache[chan->address] = val; in ad5449_write_raw()
188 ret = -EINVAL; in ad5449_write_raw()
211 .shift = 12 - (bits), \
260 if (st->chip_info->num_channels == 1) in ad5449_vref_name()
264 return "VREFA"; in ad5449_vref_name()
271 struct ad5449_platform_data *pdata = spi->dev.platform_data; in ad5449_spi_probe()
278 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); in ad5449_spi_probe()
280 return -ENOMEM; in ad5449_spi_probe()
285 st->chip_info = &ad5449_chip_info[id->driver_data]; in ad5449_spi_probe()
286 st->spi = spi; in ad5449_spi_probe()
288 for (i = 0; i < st->chip_info->num_channels; ++i) in ad5449_spi_probe()
289 st->vref_reg[i].supply = ad5449_vref_name(st, i); in ad5449_spi_probe()
291 ret = devm_regulator_bulk_get(&spi->dev, st->chip_info->num_channels, in ad5449_spi_probe()
292 st->vref_reg); in ad5449_spi_probe()
296 ret = regulator_bulk_enable(st->chip_info->num_channels, st->vref_reg); in ad5449_spi_probe()
300 indio_dev->name = id->name; in ad5449_spi_probe()
301 indio_dev->info = &ad5449_info; in ad5449_spi_probe()
302 indio_dev->modes = INDIO_DIRECT_MODE; in ad5449_spi_probe()
303 indio_dev->channels = st->chip_info->channels; in ad5449_spi_probe()
304 indio_dev->num_channels = st->chip_info->num_channels; in ad5449_spi_probe()
306 mutex_init(&st->lock); in ad5449_spi_probe()
308 if (st->chip_info->has_ctrl) { in ad5449_spi_probe()
311 if (pdata->hardware_clear_to_midscale) in ad5449_spi_probe()
313 ctrl |= pdata->sdo_mode << AD5449_CTRL_SDO_OFFSET; in ad5449_spi_probe()
314 st->has_sdo = pdata->sdo_mode != AD5449_SDO_DISABLED; in ad5449_spi_probe()
316 st->has_sdo = true; in ad5449_spi_probe()
328 regulator_bulk_disable(st->chip_info->num_channels, st->vref_reg); in ad5449_spi_probe()
340 regulator_bulk_disable(st->chip_info->num_channels, st->vref_reg); in ad5449_spi_remove()
365 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");