Lines Matching +full:analog +full:- +full:amplifier

1 // SPDX-License-Identifier: GPL-2.0
5 * AD8366 Dual-Digital Variable Gain Amplifier (VGA)
6 * ADA4961 BiCMOS RF Digital Gain Amplifier (DGA)
7 * ADL5240 Digitally controlled variable gain amplifier (VGA)
8 * HMC1119 0.25 dB LSB, 7-Bit, Silicon Digital Attenuator
10 * Copyright 2012-2019 Analog Devices Inc.
60 .gain_min = -6000,
64 .gain_min = -11500,
68 .gain_min = -31750,
79 switch (st->type) { in ad8366_write()
84 st->data[0] = ch_b >> 4; in ad8366_write()
85 st->data[1] = (ch_b << 4) | (ch_a >> 2); in ad8366_write()
88 st->data[0] = ch_a & 0x1F; in ad8366_write()
91 st->data[0] = (ch_a & 0x3F); in ad8366_write()
94 st->data[0] = ch_a; in ad8366_write()
98 ret = spi_write(st->spi, st->data, indio_dev->num_channels); in ad8366_write()
100 dev_err(&indio_dev->dev, "write failed (%d)", ret); in ad8366_write()
115 mutex_lock(&st->lock); in ad8366_read_raw()
118 code = st->ch[chan->channel]; in ad8366_read_raw()
120 switch (st->type) { in ad8366_read_raw()
125 gain = 15000 - code * 1000; in ad8366_read_raw()
128 gain = 20000 - 31500 + code * 500; in ad8366_read_raw()
131 gain = -1 * code * 250; in ad8366_read_raw()
142 ret = -EINVAL; in ad8366_read_raw()
144 mutex_unlock(&st->lock); in ad8366_read_raw()
156 struct ad8366_info *inf = st->info; in ad8366_write_raw()
162 gain = (val * 1000) - (val2 / 1000); in ad8366_write_raw()
166 if (gain > inf->gain_max || gain < inf->gain_min) in ad8366_write_raw()
167 return -EINVAL; in ad8366_write_raw()
169 switch (st->type) { in ad8366_write_raw()
171 code = (gain - 4500) / 253; in ad8366_write_raw()
174 code = (15000 - gain) / 1000; in ad8366_write_raw()
177 code = ((gain - 500 - 20000) / 500) & 0x3F; in ad8366_write_raw()
184 mutex_lock(&st->lock); in ad8366_write_raw()
187 st->ch[chan->channel] = code; in ad8366_write_raw()
188 ret = ad8366_write(indio_dev, st->ch[0], st->ch[1]); in ad8366_write_raw()
191 ret = -EINVAL; in ad8366_write_raw()
193 mutex_unlock(&st->lock); in ad8366_write_raw()
206 return -EINVAL; in ad8366_write_raw_get_fmt()
239 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); in ad8366_probe()
241 return -ENOMEM; in ad8366_probe()
245 st->reg = devm_regulator_get(&spi->dev, "vcc"); in ad8366_probe()
246 if (!IS_ERR(st->reg)) { in ad8366_probe()
247 ret = regulator_enable(st->reg); in ad8366_probe()
253 mutex_init(&st->lock); in ad8366_probe()
254 st->spi = spi; in ad8366_probe()
255 st->type = spi_get_device_id(spi)->driver_data; in ad8366_probe()
257 switch (st->type) { in ad8366_probe()
259 indio_dev->channels = ad8366_channels; in ad8366_probe()
260 indio_dev->num_channels = ARRAY_SIZE(ad8366_channels); in ad8366_probe()
265 st->reset_gpio = devm_gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_HIGH); in ad8366_probe()
266 if (IS_ERR(st->reset_gpio)) { in ad8366_probe()
267 ret = PTR_ERR(st->reset_gpio); in ad8366_probe()
270 indio_dev->channels = ada4961_channels; in ad8366_probe()
271 indio_dev->num_channels = ARRAY_SIZE(ada4961_channels); in ad8366_probe()
274 dev_err(&spi->dev, "Invalid device ID\n"); in ad8366_probe()
275 ret = -EINVAL; in ad8366_probe()
279 st->info = &ad8366_infos[st->type]; in ad8366_probe()
280 indio_dev->name = spi_get_device_id(spi)->name; in ad8366_probe()
281 indio_dev->info = &ad8366_info; in ad8366_probe()
282 indio_dev->modes = INDIO_DIRECT_MODE; in ad8366_probe()
295 if (!IS_ERR(st->reg)) in ad8366_probe()
296 regulator_disable(st->reg); in ad8366_probe()
305 struct regulator *reg = st->reg; in ad8366_remove()
333 MODULE_AUTHOR("Michael Hennerich <michael.hennerich@analog.com>");
334 MODULE_DESCRIPTION("Analog Devices AD8366 and similar Gain Amplifiers");