Lines Matching +full:4 +full:- +full:bits

1 // SPDX-License-Identifier: GPL-2.0
33 return ((st->pwr_down_mode >> (chan->channel * 2)) & 0x3) - 1; in ad5686_get_powerdown_mode()
42 st->pwr_down_mode &= ~(0x3 << (chan->channel * 2)); in ad5686_set_powerdown_mode()
43 st->pwr_down_mode |= ((mode + 1) << (chan->channel * 2)); in ad5686_set_powerdown_mode()
60 return sysfs_emit(buf, "%d\n", !!(st->pwr_down_mask & in ad5686_read_dac_powerdown()
61 (0x3 << (chan->channel * 2)))); in ad5686_read_dac_powerdown()
81 st->pwr_down_mask |= (0x3 << (chan->channel * 2)); in ad5686_write_dac_powerdown()
83 st->pwr_down_mask &= ~(0x3 << (chan->channel * 2)); in ad5686_write_dac_powerdown()
85 switch (st->chip_info->regmap_type) { in ad5686_write_dac_powerdown()
98 if (chan->channel > 0x7) in ad5686_write_dac_powerdown()
106 return -EINVAL; in ad5686_write_dac_powerdown()
109 val = ((st->pwr_down_mask & st->pwr_down_mode) << shift); in ad5686_write_dac_powerdown()
110 if (!st->use_internal_vref) in ad5686_write_dac_powerdown()
113 ret = st->write(st, AD5686_CMD_POWERDOWN_DAC, in ad5686_write_dac_powerdown()
130 mutex_lock(&st->lock); in ad5686_read_raw()
131 ret = st->read(st, chan->address); in ad5686_read_raw()
132 mutex_unlock(&st->lock); in ad5686_read_raw()
135 *val = (ret >> chan->scan_type.shift) & in ad5686_read_raw()
136 GENMASK(chan->scan_type.realbits - 1, 0); in ad5686_read_raw()
139 *val = st->vref_mv; in ad5686_read_raw()
140 *val2 = chan->scan_type.realbits; in ad5686_read_raw()
143 return -EINVAL; in ad5686_read_raw()
157 if (val > (1 << chan->scan_type.realbits) || val < 0) in ad5686_write_raw()
158 return -EINVAL; in ad5686_write_raw()
160 mutex_lock(&st->lock); in ad5686_write_raw()
161 ret = st->write(st, in ad5686_write_raw()
163 chan->address, in ad5686_write_raw()
164 val << chan->scan_type.shift); in ad5686_write_raw()
165 mutex_unlock(&st->lock); in ad5686_write_raw()
168 ret = -EINVAL; in ad5686_write_raw()
191 #define AD5868_CHANNEL(chan, addr, bits, _shift) { \ argument
201 .realbits = (bits), \
208 #define DECLARE_AD5693_CHANNELS(name, bits, _shift) \ argument
210 AD5868_CHANNEL(0, 0, bits, _shift), \
213 #define DECLARE_AD5338_CHANNELS(name, bits, _shift) \ argument
215 AD5868_CHANNEL(0, 1, bits, _shift), \
216 AD5868_CHANNEL(1, 8, bits, _shift), \
219 #define DECLARE_AD5686_CHANNELS(name, bits, _shift) \ argument
221 AD5868_CHANNEL(0, 1, bits, _shift), \
222 AD5868_CHANNEL(1, 2, bits, _shift), \
223 AD5868_CHANNEL(2, 4, bits, _shift), \
224 AD5868_CHANNEL(3, 8, bits, _shift), \
227 #define DECLARE_AD5676_CHANNELS(name, bits, _shift) \ argument
229 AD5868_CHANNEL(0, 0, bits, _shift), \
230 AD5868_CHANNEL(1, 1, bits, _shift), \
231 AD5868_CHANNEL(2, 2, bits, _shift), \
232 AD5868_CHANNEL(3, 3, bits, _shift), \
233 AD5868_CHANNEL(4, 4, bits, _shift), \
234 AD5868_CHANNEL(5, 5, bits, _shift), \
235 AD5868_CHANNEL(6, 6, bits, _shift), \
236 AD5868_CHANNEL(7, 7, bits, _shift), \
239 #define DECLARE_AD5679_CHANNELS(name, bits, _shift) \ argument
241 AD5868_CHANNEL(0, 0, bits, _shift), \
242 AD5868_CHANNEL(1, 1, bits, _shift), \
243 AD5868_CHANNEL(2, 2, bits, _shift), \
244 AD5868_CHANNEL(3, 3, bits, _shift), \
245 AD5868_CHANNEL(4, 4, bits, _shift), \
246 AD5868_CHANNEL(5, 5, bits, _shift), \
247 AD5868_CHANNEL(6, 6, bits, _shift), \
248 AD5868_CHANNEL(7, 7, bits, _shift), \
249 AD5868_CHANNEL(8, 8, bits, _shift), \
250 AD5868_CHANNEL(9, 9, bits, _shift), \
251 AD5868_CHANNEL(10, 10, bits, _shift), \
252 AD5868_CHANNEL(11, 11, bits, _shift), \
253 AD5868_CHANNEL(12, 12, bits, _shift), \
254 AD5868_CHANNEL(13, 13, bits, _shift), \
255 AD5868_CHANNEL(14, 14, bits, _shift), \
256 AD5868_CHANNEL(15, 15, bits, _shift), \
263 DECLARE_AD5676_CHANNELS(ad5672_channels, 12, 4);
264 DECLARE_AD5679_CHANNELS(ad5674r_channels, 12, 4);
267 DECLARE_AD5686_CHANNELS(ad5684_channels, 12, 4);
272 DECLARE_AD5693_CHANNELS(ad5691r_channels, 12, 4);
377 .num_channels = 4,
383 .num_channels = 4,
389 .num_channels = 4,
394 .num_channels = 4,
400 .num_channels = 4,
428 .num_channels = 4,
434 .num_channels = 4,
439 .num_channels = 4,
445 .num_channels = 4,
463 return -ENOMEM; in ad5686_probe()
468 st->dev = dev; in ad5686_probe()
469 st->write = write; in ad5686_probe()
470 st->read = read; in ad5686_probe()
472 st->reg = devm_regulator_get_optional(dev, "vcc"); in ad5686_probe()
473 if (!IS_ERR(st->reg)) { in ad5686_probe()
474 ret = regulator_enable(st->reg); in ad5686_probe()
478 ret = regulator_get_voltage(st->reg); in ad5686_probe()
485 st->chip_info = &ad5686_chip_info_tbl[chip_type]; in ad5686_probe()
488 st->vref_mv = voltage_uv / 1000; in ad5686_probe()
490 st->vref_mv = st->chip_info->int_vref_mv; in ad5686_probe()
493 for (i = 0; i < st->chip_info->num_channels; i++) in ad5686_probe()
494 st->pwr_down_mode |= (0x01 << (i * 2)); in ad5686_probe()
496 indio_dev->name = name; in ad5686_probe()
497 indio_dev->info = &ad5686_info; in ad5686_probe()
498 indio_dev->modes = INDIO_DIRECT_MODE; in ad5686_probe()
499 indio_dev->channels = st->chip_info->channels; in ad5686_probe()
500 indio_dev->num_channels = st->chip_info->num_channels; in ad5686_probe()
502 mutex_init(&st->lock); in ad5686_probe()
504 switch (st->chip_info->regmap_type) { in ad5686_probe()
508 st->use_internal_vref = !voltage_uv; in ad5686_probe()
513 st->use_internal_vref = !voltage_uv; in ad5686_probe()
522 st->use_internal_vref = !voltage_uv; in ad5686_probe()
525 ret = -EINVAL; in ad5686_probe()
531 ret = st->write(st, cmd, 0, !!val); in ad5686_probe()
542 if (!IS_ERR(st->reg)) in ad5686_probe()
543 regulator_disable(st->reg); in ad5686_probe()
554 if (!IS_ERR(st->reg)) in ad5686_remove()
555 regulator_disable(st->reg); in ad5686_remove()