Lines Matching refs:st
107 struct ad7298_state *st = iio_priv(indio_dev);
115 command = AD7298_WRITE | st->ext_ref;
121 st->tx_buf[0] = cpu_to_be16(command);
124 st->ring_xfer[0].tx_buf = &st->tx_buf[0];
125 st->ring_xfer[0].len = 2;
126 st->ring_xfer[0].cs_change = 1;
127 st->ring_xfer[1].tx_buf = &st->tx_buf[1];
128 st->ring_xfer[1].len = 2;
129 st->ring_xfer[1].cs_change = 1;
131 spi_message_init(&st->ring_msg);
132 spi_message_add_tail(&st->ring_xfer[0], &st->ring_msg);
133 spi_message_add_tail(&st->ring_xfer[1], &st->ring_msg);
136 st->ring_xfer[i + 2].rx_buf = &st->rx_buf[i];
137 st->ring_xfer[i + 2].len = 2;
138 st->ring_xfer[i + 2].cs_change = 1;
139 spi_message_add_tail(&st->ring_xfer[i + 2], &st->ring_msg);
142 st->ring_xfer[i + 1].cs_change = 0;
157 struct ad7298_state *st = iio_priv(indio_dev);
160 b_sent = spi_sync(st->spi, &st->ring_msg);
164 iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf,
173 static int ad7298_scan_direct(struct ad7298_state *st, unsigned ch)
176 st->tx_buf[0] = cpu_to_be16(AD7298_WRITE | st->ext_ref |
179 ret = spi_sync(st->spi, &st->scan_single_msg);
183 return be16_to_cpu(st->rx_buf[0]);
186 static int ad7298_scan_temp(struct ad7298_state *st, int *val)
192 AD7298_TAVG | st->ext_ref);
194 ret = spi_write(st->spi, (u8 *)&buf, 2);
200 ret = spi_write(st->spi, (u8 *)&buf, 2);
206 ret = spi_read(st->spi, (u8 *)&buf, 2);
215 static int ad7298_get_ref_voltage(struct ad7298_state *st)
219 if (st->ext_ref) {
220 vref = regulator_get_voltage(st->reg);
237 struct ad7298_state *st = iio_priv(indio_dev);
246 ret = ad7298_scan_temp(st, val);
248 ret = ad7298_scan_direct(st, chan->address);
262 *val = ad7298_get_ref_voltage(st);
266 *val = ad7298_get_ref_voltage(st);
273 *val = 1093 - 2732500 / ad7298_get_ref_voltage(st);
287 struct ad7298_state *st;
291 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
295 st = iio_priv(indio_dev);
298 st->ext_ref = AD7298_EXTREF;
300 if (st->ext_ref) {
301 st->reg = devm_regulator_get(&spi->dev, "vref");
302 if (IS_ERR(st->reg))
303 return PTR_ERR(st->reg);
305 ret = regulator_enable(st->reg);
312 st->spi = spi;
322 st->scan_single_xfer[0].tx_buf = &st->tx_buf[0];
323 st->scan_single_xfer[0].len = 2;
324 st->scan_single_xfer[0].cs_change = 1;
325 st->scan_single_xfer[1].tx_buf = &st->tx_buf[1];
326 st->scan_single_xfer[1].len = 2;
327 st->scan_single_xfer[1].cs_change = 1;
328 st->scan_single_xfer[2].rx_buf = &st->rx_buf[0];
329 st->scan_single_xfer[2].len = 2;
331 spi_message_init(&st->scan_single_msg);
332 spi_message_add_tail(&st->scan_single_xfer[0], &st->scan_single_msg);
333 spi_message_add_tail(&st->scan_single_xfer[1], &st->scan_single_msg);
334 spi_message_add_tail(&st->scan_single_xfer[2], &st->scan_single_msg);
350 if (st->ext_ref)
351 regulator_disable(st->reg);
359 struct ad7298_state *st = iio_priv(indio_dev);
363 if (st->ext_ref)
364 regulator_disable(st->reg);