• Home
  • Raw
  • Download

Lines Matching refs:st

107 	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()
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()
157 struct ad7298_state *st = iio_priv(indio_dev); in ad7298_trigger_handler() local
160 b_sent = spi_sync(st->spi, &st->ring_msg); in ad7298_trigger_handler()
164 iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf, in ad7298_trigger_handler()
173 static int ad7298_scan_direct(struct ad7298_state *st, unsigned ch) in ad7298_scan_direct() argument
176 st->tx_buf[0] = cpu_to_be16(AD7298_WRITE | st->ext_ref | in ad7298_scan_direct()
179 ret = spi_sync(st->spi, &st->scan_single_msg); in ad7298_scan_direct()
183 return be16_to_cpu(st->rx_buf[0]); in ad7298_scan_direct()
186 static int ad7298_scan_temp(struct ad7298_state *st, int *val) in ad7298_scan_temp() argument
192 AD7298_TAVG | st->ext_ref); in ad7298_scan_temp()
194 ret = spi_write(st->spi, (u8 *)&buf, 2); in ad7298_scan_temp()
200 ret = spi_write(st->spi, (u8 *)&buf, 2); in ad7298_scan_temp()
206 ret = spi_read(st->spi, (u8 *)&buf, 2); in ad7298_scan_temp()
215 static int ad7298_get_ref_voltage(struct ad7298_state *st) in ad7298_get_ref_voltage() argument
219 if (st->ext_ref) { in ad7298_get_ref_voltage()
220 vref = regulator_get_voltage(st->reg); in ad7298_get_ref_voltage()
237 struct ad7298_state *st = iio_priv(indio_dev); in ad7298_read_raw() local
246 ret = ad7298_scan_temp(st, val); in ad7298_read_raw()
248 ret = ad7298_scan_direct(st, chan->address); in ad7298_read_raw()
262 *val = ad7298_get_ref_voltage(st); in ad7298_read_raw()
266 *val = ad7298_get_ref_voltage(st); in ad7298_read_raw()
273 *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()
298 st->ext_ref = AD7298_EXTREF; in ad7298_probe()
300 if (st->ext_ref) { in ad7298_probe()
301 st->reg = devm_regulator_get(&spi->dev, "vref"); in ad7298_probe()
302 if (IS_ERR(st->reg)) in ad7298_probe()
303 return PTR_ERR(st->reg); in ad7298_probe()
305 ret = regulator_enable(st->reg); in ad7298_probe()
312 st->spi = spi; in ad7298_probe()
322 st->scan_single_xfer[0].tx_buf = &st->tx_buf[0]; in ad7298_probe()
323 st->scan_single_xfer[0].len = 2; in ad7298_probe()
324 st->scan_single_xfer[0].cs_change = 1; in ad7298_probe()
325 st->scan_single_xfer[1].tx_buf = &st->tx_buf[1]; in ad7298_probe()
326 st->scan_single_xfer[1].len = 2; in ad7298_probe()
327 st->scan_single_xfer[1].cs_change = 1; in ad7298_probe()
328 st->scan_single_xfer[2].rx_buf = &st->rx_buf[0]; in ad7298_probe()
329 st->scan_single_xfer[2].len = 2; in ad7298_probe()
331 spi_message_init(&st->scan_single_msg); in ad7298_probe()
332 spi_message_add_tail(&st->scan_single_xfer[0], &st->scan_single_msg); in ad7298_probe()
333 spi_message_add_tail(&st->scan_single_xfer[1], &st->scan_single_msg); in ad7298_probe()
334 spi_message_add_tail(&st->scan_single_xfer[2], &st->scan_single_msg); in ad7298_probe()
350 if (st->ext_ref) in ad7298_probe()
351 regulator_disable(st->reg); in ad7298_probe()
359 struct ad7298_state *st = iio_priv(indio_dev); in ad7298_remove() local
363 if (st->ext_ref) in ad7298_remove()
364 regulator_disable(st->reg); in ad7298_remove()