Lines Matching +full:1 +full:st

52 static int ad7266_wakeup(struct ad7266_state *st)  in ad7266_wakeup()  argument
55 return spi_read(st->spi, &st->data.sample[0], 2); in ad7266_wakeup()
58 static int ad7266_powerdown(struct ad7266_state *st) in ad7266_powerdown() argument
61 return spi_read(st->spi, &st->data.sample[0], 1); in ad7266_powerdown()
66 struct ad7266_state *st = iio_priv(indio_dev); in ad7266_preenable() local
67 return ad7266_wakeup(st); in ad7266_preenable()
72 struct ad7266_state *st = iio_priv(indio_dev); in ad7266_postdisable() local
73 return ad7266_powerdown(st); in ad7266_postdisable()
85 struct ad7266_state *st = iio_priv(indio_dev); in ad7266_trigger_handler() local
88 ret = spi_read(st->spi, st->data.sample, 4); in ad7266_trigger_handler()
90 iio_push_to_buffers_with_timestamp(indio_dev, &st->data, in ad7266_trigger_handler()
99 static void ad7266_select_input(struct ad7266_state *st, unsigned int nr) in ad7266_select_input() argument
103 if (st->fixed_addr) in ad7266_select_input()
106 switch (st->mode) { in ad7266_select_input()
108 nr >>= 1; in ad7266_select_input()
111 nr |= 1; in ad7266_select_input()
114 nr &= ~1; in ad7266_select_input()
119 gpiod_set_value(st->gpios[i], (bool)(nr & BIT(i))); in ad7266_select_input()
125 struct ad7266_state *st = iio_priv(indio_dev); in ad7266_update_scan_mode() local
129 ad7266_select_input(st, nr); in ad7266_update_scan_mode()
134 static int ad7266_read_single(struct ad7266_state *st, int *val, in ad7266_read_single() argument
139 ad7266_select_input(st, address); in ad7266_read_single()
141 ret = spi_sync(st->spi, &st->single_msg); in ad7266_read_single()
142 *val = be16_to_cpu(st->data.sample[address % 2]); in ad7266_read_single()
150 struct ad7266_state *st = iio_priv(indio_dev); in ad7266_read_raw() local
159 ret = ad7266_read_single(st, val, chan->address); in ad7266_read_raw()
167 chan->scan_type.realbits - 1); in ad7266_read_raw()
171 scale_mv = st->vref_mv; in ad7266_read_raw()
172 if (st->mode == AD7266_MODE_DIFF) in ad7266_read_raw()
174 if (st->range == AD7266_RANGE_2VREF) in ad7266_read_raw()
181 if (st->range == AD7266_RANGE_2VREF && in ad7266_read_raw()
182 st->mode != AD7266_MODE_DIFF) in ad7266_read_raw()
193 .indexed = 1, \
212 AD7266_CHAN(1, (_sign)), \
229 AD7266_CHAN(1, (_sign)), \
240 .indexed = 1, \
242 .channel2 = (_chan) * 2 + 1, \
255 .differential = 1, \
261 AD7266_CHAN_DIFF(1, (_sign)), \
275 AD7266_CHAN_DIFF(1, (_sign)), \
316 (((_differential) << 2) | ((_signed) << 1) | ((_fixed) << 0))
324 [AD7266_CHAN_INFO_INDEX(0, 0, 1)] = {
329 [AD7266_CHAN_INFO_INDEX(0, 1, 0)] = {
334 [AD7266_CHAN_INFO_INDEX(0, 1, 1)] = {
339 [AD7266_CHAN_INFO_INDEX(1, 0, 0)] = {
344 [AD7266_CHAN_INFO_INDEX(1, 0, 1)] = {
349 [AD7266_CHAN_INFO_INDEX(1, 1, 0)] = {
354 [AD7266_CHAN_INFO_INDEX(1, 1, 1)] = {
363 struct ad7266_state *st = iio_priv(indio_dev); in ad7266_init_channels() local
368 is_differential = st->mode != AD7266_MODE_SINGLE_ENDED; in ad7266_init_channels()
369 is_signed = (st->range == AD7266_RANGE_2VREF) | in ad7266_init_channels()
370 (st->mode == AD7266_MODE_DIFF); in ad7266_init_channels()
372 i = AD7266_CHAN_INFO_INDEX(is_differential, is_signed, st->fixed_addr); in ad7266_init_channels()
388 struct ad7266_state *st; in ad7266_probe() local
392 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); in ad7266_probe()
396 st = iio_priv(indio_dev); in ad7266_probe()
402 st->vref_mv = ret == -ENODEV ? AD7266_INTERNAL_REF_MV : ret / 1000; in ad7266_probe()
405 st->fixed_addr = pdata->fixed_addr; in ad7266_probe()
406 st->mode = pdata->mode; in ad7266_probe()
407 st->range = pdata->range; in ad7266_probe()
409 if (!st->fixed_addr) { in ad7266_probe()
410 for (i = 0; i < ARRAY_SIZE(st->gpios); ++i) { in ad7266_probe()
411 st->gpios[i] = devm_gpiod_get(&spi->dev, in ad7266_probe()
414 if (IS_ERR(st->gpios[i])) { in ad7266_probe()
415 ret = PTR_ERR(st->gpios[i]); in ad7266_probe()
421 st->fixed_addr = true; in ad7266_probe()
422 st->range = AD7266_RANGE_VREF; in ad7266_probe()
423 st->mode = AD7266_MODE_DIFF; in ad7266_probe()
426 st->spi = spi; in ad7266_probe()
435 st->single_xfer[0].rx_buf = &st->data.sample[0]; in ad7266_probe()
436 st->single_xfer[0].len = 2; in ad7266_probe()
437 st->single_xfer[0].cs_change = 1; in ad7266_probe()
439 st->single_xfer[1].rx_buf = st->data.sample; in ad7266_probe()
440 st->single_xfer[1].len = 4; in ad7266_probe()
441 st->single_xfer[1].cs_change = 1; in ad7266_probe()
443 st->single_xfer[2].tx_buf = &st->data.sample[0]; in ad7266_probe()
444 st->single_xfer[2].len = 1; in ad7266_probe()
446 spi_message_init(&st->single_msg); in ad7266_probe()
447 spi_message_add_tail(&st->single_xfer[0], &st->single_msg); in ad7266_probe()
448 spi_message_add_tail(&st->single_xfer[1], &st->single_msg); in ad7266_probe()
449 spi_message_add_tail(&st->single_xfer[2], &st->single_msg); in ad7266_probe()