Lines Matching refs:st
106 struct ad7298_state *st = iio_priv(indio_dev); in ad7298_update_scan_mode() local
114 command = AD7298_WRITE | st->ext_ref; in ad7298_update_scan_mode()
120 st->tx_buf[0] = cpu_to_be16(command); in ad7298_update_scan_mode()
123 st->ring_xfer[0].tx_buf = &st->tx_buf[0]; in ad7298_update_scan_mode()
124 st->ring_xfer[0].len = 2; in ad7298_update_scan_mode()
125 st->ring_xfer[0].cs_change = 1; in ad7298_update_scan_mode()
126 st->ring_xfer[1].tx_buf = &st->tx_buf[1]; in ad7298_update_scan_mode()
127 st->ring_xfer[1].len = 2; in ad7298_update_scan_mode()
128 st->ring_xfer[1].cs_change = 1; in ad7298_update_scan_mode()
130 spi_message_init(&st->ring_msg); in ad7298_update_scan_mode()
131 spi_message_add_tail(&st->ring_xfer[0], &st->ring_msg); in ad7298_update_scan_mode()
132 spi_message_add_tail(&st->ring_xfer[1], &st->ring_msg); in ad7298_update_scan_mode()
135 st->ring_xfer[i + 2].rx_buf = &st->rx_buf[i]; in ad7298_update_scan_mode()
136 st->ring_xfer[i + 2].len = 2; in ad7298_update_scan_mode()
137 st->ring_xfer[i + 2].cs_change = 1; in ad7298_update_scan_mode()
138 spi_message_add_tail(&st->ring_xfer[i + 2], &st->ring_msg); in ad7298_update_scan_mode()
141 st->ring_xfer[i + 1].cs_change = 0; in ad7298_update_scan_mode()
150 struct ad7298_state *st = iio_priv(indio_dev); in ad7298_trigger_handler() local
153 b_sent = spi_sync(st->spi, &st->ring_msg); in ad7298_trigger_handler()
157 iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf, in ad7298_trigger_handler()
166 static int ad7298_scan_direct(struct ad7298_state *st, unsigned ch) in ad7298_scan_direct() argument
169 st->tx_buf[0] = cpu_to_be16(AD7298_WRITE | st->ext_ref | in ad7298_scan_direct()
172 ret = spi_sync(st->spi, &st->scan_single_msg); in ad7298_scan_direct()
176 return be16_to_cpu(st->rx_buf[0]); in ad7298_scan_direct()
179 static int ad7298_scan_temp(struct ad7298_state *st, int *val) in ad7298_scan_temp() argument
185 AD7298_TAVG | st->ext_ref); in ad7298_scan_temp()
187 ret = spi_write(st->spi, (u8 *)&buf, 2); in ad7298_scan_temp()
193 ret = spi_write(st->spi, (u8 *)&buf, 2); in ad7298_scan_temp()
199 ret = spi_read(st->spi, (u8 *)&buf, 2); in ad7298_scan_temp()
208 static int ad7298_get_ref_voltage(struct ad7298_state *st) in ad7298_get_ref_voltage() argument
212 if (st->reg) { in ad7298_get_ref_voltage()
213 vref = regulator_get_voltage(st->reg); in ad7298_get_ref_voltage()
230 struct ad7298_state *st = iio_priv(indio_dev); in ad7298_read_raw() local
239 ret = ad7298_scan_temp(st, val); in ad7298_read_raw()
241 ret = ad7298_scan_direct(st, chan->address); in ad7298_read_raw()
255 *val = ad7298_get_ref_voltage(st); in ad7298_read_raw()
259 *val = ad7298_get_ref_voltage(st); in ad7298_read_raw()
266 *val = 1093 - 2732500 / ad7298_get_ref_voltage(st); in ad7298_read_raw()
286 struct ad7298_state *st; in ad7298_probe() local
290 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); in ad7298_probe()
294 st = iio_priv(indio_dev); in ad7298_probe()
296 st->reg = devm_regulator_get_optional(&spi->dev, "vref"); in ad7298_probe()
297 if (!IS_ERR(st->reg)) { in ad7298_probe()
298 st->ext_ref = AD7298_EXTREF; in ad7298_probe()
300 ret = PTR_ERR(st->reg); in ad7298_probe()
304 st->reg = NULL; in ad7298_probe()
307 if (st->reg) { in ad7298_probe()
308 ret = regulator_enable(st->reg); in ad7298_probe()
313 st->reg); in ad7298_probe()
318 st->spi = spi; in ad7298_probe()
328 st->scan_single_xfer[0].tx_buf = &st->tx_buf[0]; in ad7298_probe()
329 st->scan_single_xfer[0].len = 2; in ad7298_probe()
330 st->scan_single_xfer[0].cs_change = 1; in ad7298_probe()
331 st->scan_single_xfer[1].tx_buf = &st->tx_buf[1]; in ad7298_probe()
332 st->scan_single_xfer[1].len = 2; in ad7298_probe()
333 st->scan_single_xfer[1].cs_change = 1; in ad7298_probe()
334 st->scan_single_xfer[2].rx_buf = &st->rx_buf[0]; in ad7298_probe()
335 st->scan_single_xfer[2].len = 2; in ad7298_probe()
337 spi_message_init(&st->scan_single_msg); in ad7298_probe()
338 spi_message_add_tail(&st->scan_single_xfer[0], &st->scan_single_msg); in ad7298_probe()
339 spi_message_add_tail(&st->scan_single_xfer[1], &st->scan_single_msg); in ad7298_probe()
340 spi_message_add_tail(&st->scan_single_xfer[2], &st->scan_single_msg); in ad7298_probe()