Lines Matching +full:14 +full:- +full:channel

1 // SPDX-License-Identifier: GPL-2.0-or-later
32 * struct ad5446_state - driver instance specific data
55 * struct ad5446_chip_info - chip specific information
56 * @channel: channel spec for the DAC
62 struct iio_chan_spec channel; member
76 st->pwr_down_mode = mode + 1; in ad5446_set_powerdown_mode()
86 return st->pwr_down_mode - 1; in ad5446_get_powerdown_mode()
103 return sysfs_emit(buf, "%d\n", st->pwr_down); in ad5446_read_dac_powerdown()
121 mutex_lock(&st->lock); in ad5446_write_dac_powerdown()
122 st->pwr_down = powerdown; in ad5446_write_dac_powerdown()
124 if (st->pwr_down) { in ad5446_write_dac_powerdown()
125 shift = chan->scan_type.realbits + chan->scan_type.shift; in ad5446_write_dac_powerdown()
126 val = st->pwr_down_mode << shift; in ad5446_write_dac_powerdown()
128 val = st->cached_val; in ad5446_write_dac_powerdown()
131 ret = st->chip_info->write(st, val); in ad5446_write_dac_powerdown()
132 mutex_unlock(&st->lock); in ad5446_write_dac_powerdown()
153 .channel = 0, \
181 *val = st->cached_val >> chan->scan_type.shift; in ad5446_read_raw()
184 *val = st->vref_mv; in ad5446_read_raw()
185 *val2 = chan->scan_type.realbits; in ad5446_read_raw()
188 return -EINVAL; in ad5446_read_raw()
202 if (val >= (1 << chan->scan_type.realbits) || val < 0) in ad5446_write_raw()
203 return -EINVAL; in ad5446_write_raw()
205 val <<= chan->scan_type.shift; in ad5446_write_raw()
206 mutex_lock(&st->lock); in ad5446_write_raw()
207 st->cached_val = val; in ad5446_write_raw()
208 if (!st->pwr_down) in ad5446_write_raw()
209 ret = st->chip_info->write(st, val); in ad5446_write_raw()
210 mutex_unlock(&st->lock); in ad5446_write_raw()
213 ret = -EINVAL; in ad5446_write_raw()
247 ret = -ENOMEM; in ad5446_probe()
251 st->chip_info = chip_info; in ad5446_probe()
254 st->reg = reg; in ad5446_probe()
255 st->dev = dev; in ad5446_probe()
257 indio_dev->name = name; in ad5446_probe()
258 indio_dev->info = &ad5446_info; in ad5446_probe()
259 indio_dev->modes = INDIO_DIRECT_MODE; in ad5446_probe()
260 indio_dev->channels = &st->chip_info->channel; in ad5446_probe()
261 indio_dev->num_channels = 1; in ad5446_probe()
263 mutex_init(&st->lock); in ad5446_probe()
265 st->pwr_down_mode = MODE_PWRDWN_1k; in ad5446_probe()
267 if (st->chip_info->int_vref_mv) in ad5446_probe()
268 st->vref_mv = st->chip_info->int_vref_mv; in ad5446_probe()
270 st->vref_mv = voltage_uv / 1000; in ad5446_probe()
292 if (!IS_ERR(st->reg)) in ad5446_remove()
293 regulator_disable(st->reg); in ad5446_remove()
300 struct spi_device *spi = to_spi_device(st->dev); in ad5446_write()
308 struct spi_device *spi = to_spi_device(st->dev); in ad5660_write()
350 .channel = AD5446_CHANNEL_POWERDOWN(8, 16, 4),
354 .channel = AD5446_CHANNEL_POWERDOWN(10, 16, 2),
358 .channel = AD5446_CHANNEL_POWERDOWN(12, 16, 0),
362 .channel = AD5446_CHANNEL(12, 16, 2),
366 .channel = AD5446_CHANNEL(14, 16, 0),
370 .channel = AD5446_CHANNEL(8, 16, 6),
374 .channel = AD5446_CHANNEL(10, 16, 4),
378 .channel = AD5446_CHANNEL(16, 16, 0),
382 .channel = AD5446_CHANNEL(12, 16, 4),
386 .channel = AD5446_CHANNEL(14, 16, 0),
390 .channel = AD5446_CHANNEL(16, 16, 0),
394 .channel = AD5446_CHANNEL_POWERDOWN(8, 16, 6),
398 .channel = AD5446_CHANNEL_POWERDOWN(10, 16, 4),
402 .channel = AD5446_CHANNEL_POWERDOWN(12, 16, 2),
406 .channel = AD5446_CHANNEL_POWERDOWN(14, 16, 0),
410 .channel = AD5446_CHANNEL_POWERDOWN(12, 16, 2),
415 .channel = AD5446_CHANNEL_POWERDOWN(12, 16, 2),
420 .channel = AD5446_CHANNEL_POWERDOWN(14, 16, 0),
425 .channel = AD5446_CHANNEL_POWERDOWN(14, 16, 0),
430 .channel = AD5446_CHANNEL_POWERDOWN(16, 16, 0),
435 .channel = AD5446_CHANNEL_POWERDOWN(16, 16, 0),
440 .channel = AD5446_CHANNEL_POWERDOWN(16, 16, 0),
465 {"ad5620-2500", ID_AD5620_2500}, /* AD5620/40/60: */
466 {"ad5620-1250", ID_AD5620_1250}, /* part numbers may look differently */
467 {"ad5640-2500", ID_AD5640_2500},
468 {"ad5640-1250", ID_AD5640_1250},
469 {"ad5660-2500", ID_AD5660_2500},
470 {"ad5660-1250", ID_AD5660_1250},
490 return ad5446_probe(&spi->dev, id->name, in ad5446_spi_probe()
491 &ad5446_spi_chip_info[id->driver_data]); in ad5446_spi_probe()
496 ad5446_remove(&spi->dev); in ad5446_spi_remove()
530 struct i2c_client *client = to_i2c_client(st->dev); in ad5622_write()
538 return -EIO; in ad5622_write()
558 .channel = AD5446_CHANNEL_POWERDOWN(8, 16, 4),
562 .channel = AD5446_CHANNEL_POWERDOWN(10, 16, 2),
566 .channel = AD5446_CHANNEL_POWERDOWN(12, 16, 0),
574 return ad5446_probe(&i2c->dev, id->name, in ad5446_i2c_probe()
575 &ad5446_i2c_chip_info[id->driver_data]); in ad5446_i2c_probe()
580 ad5446_remove(&i2c->dev); in ad5446_i2c_remove()