Lines Matching +full:1 +full:st

32 #define AD7298_TAVG	BIT(1) /* temperature sensor averaging enable */
59 .indexed = 1, \
76 .indexed = 1,
82 .scan_index = -1,
90 AD7298_V_CHAN(1),
106 struct ad7298_state *st = iio_priv(indio_dev); in ad7298_update_scan_mode() local
115 command = AD7298_WRITE | st->ext_ref; in ad7298_update_scan_mode()
117 for (i = 0, m = AD7298_CH(0); i < AD7298_MAX_CHAN; i++, m >>= 1) in ad7298_update_scan_mode()
121 st->tx_buf[0] = cpu_to_be16(command); in ad7298_update_scan_mode()
124 st->ring_xfer[0].tx_buf = &st->tx_buf[0]; in ad7298_update_scan_mode()
125 st->ring_xfer[0].len = 2; in ad7298_update_scan_mode()
126 st->ring_xfer[0].cs_change = 1; in ad7298_update_scan_mode()
127 st->ring_xfer[1].tx_buf = &st->tx_buf[1]; in ad7298_update_scan_mode()
128 st->ring_xfer[1].len = 2; in ad7298_update_scan_mode()
129 st->ring_xfer[1].cs_change = 1; in ad7298_update_scan_mode()
131 spi_message_init(&st->ring_msg); in ad7298_update_scan_mode()
132 spi_message_add_tail(&st->ring_xfer[0], &st->ring_msg); in ad7298_update_scan_mode()
133 spi_message_add_tail(&st->ring_xfer[1], &st->ring_msg); in ad7298_update_scan_mode()
136 st->ring_xfer[i + 2].rx_buf = &st->rx_buf[i]; in ad7298_update_scan_mode()
137 st->ring_xfer[i + 2].len = 2; in ad7298_update_scan_mode()
138 st->ring_xfer[i + 2].cs_change = 1; in ad7298_update_scan_mode()
139 spi_message_add_tail(&st->ring_xfer[i + 2], &st->ring_msg); in ad7298_update_scan_mode()
142 st->ring_xfer[i + 1].cs_change = 0; in ad7298_update_scan_mode()
151 struct ad7298_state *st = iio_priv(indio_dev); in ad7298_trigger_handler() local
154 b_sent = spi_sync(st->spi, &st->ring_msg); in ad7298_trigger_handler()
158 iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf, in ad7298_trigger_handler()
167 static int ad7298_scan_direct(struct ad7298_state *st, unsigned ch) in ad7298_scan_direct() argument
170 st->tx_buf[0] = cpu_to_be16(AD7298_WRITE | st->ext_ref | in ad7298_scan_direct()
173 ret = spi_sync(st->spi, &st->scan_single_msg); in ad7298_scan_direct()
177 return be16_to_cpu(st->rx_buf[0]); in ad7298_scan_direct()
180 static int ad7298_scan_temp(struct ad7298_state *st, int *val) in ad7298_scan_temp() argument
186 AD7298_TAVG | st->ext_ref); in ad7298_scan_temp()
188 ret = spi_write(st->spi, (u8 *)&buf, 2); in ad7298_scan_temp()
194 ret = spi_write(st->spi, (u8 *)&buf, 2); in ad7298_scan_temp()
200 ret = spi_read(st->spi, (u8 *)&buf, 2); in ad7298_scan_temp()
209 static int ad7298_get_ref_voltage(struct ad7298_state *st) in ad7298_get_ref_voltage() argument
213 if (st->reg) { in ad7298_get_ref_voltage()
214 vref = regulator_get_voltage(st->reg); in ad7298_get_ref_voltage()
231 struct ad7298_state *st = iio_priv(indio_dev); in ad7298_read_raw() local
240 ret = ad7298_scan_temp(st, val); in ad7298_read_raw()
242 ret = ad7298_scan_direct(st, chan->address); in ad7298_read_raw()
250 *val = ret & GENMASK(chan->scan_type.realbits - 1, 0); in ad7298_read_raw()
256 *val = ad7298_get_ref_voltage(st); in ad7298_read_raw()
260 *val = ad7298_get_ref_voltage(st); in ad7298_read_raw()
267 *val = 1093 - 2732500 / ad7298_get_ref_voltage(st); in ad7298_read_raw()
287 struct ad7298_state *st; in ad7298_probe() local
291 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); in ad7298_probe()
295 st = iio_priv(indio_dev); in ad7298_probe()
297 st->reg = devm_regulator_get_optional(&spi->dev, "vref"); in ad7298_probe()
298 if (!IS_ERR(st->reg)) { in ad7298_probe()
299 st->ext_ref = AD7298_EXTREF; in ad7298_probe()
301 ret = PTR_ERR(st->reg); in ad7298_probe()
305 st->reg = NULL; in ad7298_probe()
308 if (st->reg) { in ad7298_probe()
309 ret = regulator_enable(st->reg); in ad7298_probe()
314 st->reg); in ad7298_probe()
319 st->spi = spi; in ad7298_probe()
329 st->scan_single_xfer[0].tx_buf = &st->tx_buf[0]; in ad7298_probe()
330 st->scan_single_xfer[0].len = 2; in ad7298_probe()
331 st->scan_single_xfer[0].cs_change = 1; in ad7298_probe()
332 st->scan_single_xfer[1].tx_buf = &st->tx_buf[1]; in ad7298_probe()
333 st->scan_single_xfer[1].len = 2; in ad7298_probe()
334 st->scan_single_xfer[1].cs_change = 1; in ad7298_probe()
335 st->scan_single_xfer[2].rx_buf = &st->rx_buf[0]; in ad7298_probe()
336 st->scan_single_xfer[2].len = 2; in ad7298_probe()
338 spi_message_init(&st->scan_single_msg); in ad7298_probe()
339 spi_message_add_tail(&st->scan_single_xfer[0], &st->scan_single_msg); in ad7298_probe()
340 spi_message_add_tail(&st->scan_single_xfer[1], &st->scan_single_msg); in ad7298_probe()
341 spi_message_add_tail(&st->scan_single_xfer[2], &st->scan_single_msg); in ad7298_probe()