• Home
  • Raw
  • Download

Lines Matching +full:vref +full:- +full:p

4  * Copyright (c) 2013-2015 Intel Corporation.
36 * In case of ACPI, we use the hard-wired 5000 mV of the Galileo and IOT2000
38 * via the vref-supply regulator.
45 * chips. The ADC108S102 effectively returns a 12-bit result with the 2
46 * least-significant bits unset.
52 * 16-bit SPI command format:
54 * [13:11] 3-bit channel address
60 * 16-bit SPI response format:
62 * [11:0] 12-bit ADC sample (for ADC108S102, [1:0] will always be 0).
85 * rx_buf: 1 dummy response, 8 channel responses, plus 64-bit timestamp
132 st->tx_buf[cmds++] = cpu_to_be16(ADC108S102_CMD(bit)); in adc108s102_update_scan_mode()
135 st->tx_buf[cmds++] = 0x00; in adc108s102_update_scan_mode()
138 st->ring_xfer.tx_buf = &st->tx_buf[0]; in adc108s102_update_scan_mode()
139 st->ring_xfer.rx_buf = &st->rx_buf[0]; in adc108s102_update_scan_mode()
140 st->ring_xfer.len = cmds * sizeof(st->tx_buf[0]); in adc108s102_update_scan_mode()
142 spi_message_init_with_transfers(&st->ring_msg, &st->ring_xfer, 1); in adc108s102_update_scan_mode()
147 static irqreturn_t adc108s102_trigger_handler(int irq, void *p) in adc108s102_trigger_handler() argument
149 struct iio_poll_func *pf = p; in adc108s102_trigger_handler()
150 struct iio_dev *indio_dev = pf->indio_dev; in adc108s102_trigger_handler()
154 ret = spi_sync(st->spi, &st->ring_msg); in adc108s102_trigger_handler()
160 (u8 *)&st->rx_buf[1], in adc108s102_trigger_handler()
164 iio_trigger_notify_done(indio_dev->trig); in adc108s102_trigger_handler()
173 st->tx_buf[0] = cpu_to_be16(ADC108S102_CMD(ch)); in adc108s102_scan_direct()
174 ret = spi_sync(st->spi, &st->scan_single_msg); in adc108s102_scan_direct()
179 return be16_to_cpu(st->rx_buf[1]); in adc108s102_scan_direct()
195 ret = adc108s102_scan_direct(st, chan->address); in adc108s102_read_raw()
206 if (chan->type != IIO_VOLTAGE) in adc108s102_read_raw()
209 *val = st->va_millivolt; in adc108s102_read_raw()
210 *val2 = chan->scan_type.realbits; in adc108s102_read_raw()
217 return -EINVAL; in adc108s102_read_raw()
231 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); in adc108s102_probe()
233 return -ENOMEM; in adc108s102_probe()
237 if (ACPI_COMPANION(&spi->dev)) { in adc108s102_probe()
238 st->va_millivolt = ADC108S102_VA_MV_ACPI_DEFAULT; in adc108s102_probe()
240 st->reg = devm_regulator_get(&spi->dev, "vref"); in adc108s102_probe()
241 if (IS_ERR(st->reg)) in adc108s102_probe()
242 return PTR_ERR(st->reg); in adc108s102_probe()
244 ret = regulator_enable(st->reg); in adc108s102_probe()
246 dev_err(&spi->dev, "Cannot enable vref regulator\n"); in adc108s102_probe()
250 ret = regulator_get_voltage(st->reg); in adc108s102_probe()
252 dev_err(&spi->dev, "vref get voltage failed\n"); in adc108s102_probe()
256 st->va_millivolt = ret / 1000; in adc108s102_probe()
260 st->spi = spi; in adc108s102_probe()
262 indio_dev->name = spi->modalias; in adc108s102_probe()
263 indio_dev->dev.parent = &spi->dev; in adc108s102_probe()
264 indio_dev->modes = INDIO_DIRECT_MODE; in adc108s102_probe()
265 indio_dev->channels = adc108s102_channels; in adc108s102_probe()
266 indio_dev->num_channels = ARRAY_SIZE(adc108s102_channels); in adc108s102_probe()
267 indio_dev->info = &adc108s102_info; in adc108s102_probe()
270 st->scan_single_xfer.tx_buf = st->tx_buf; in adc108s102_probe()
271 st->scan_single_xfer.rx_buf = st->rx_buf; in adc108s102_probe()
272 st->scan_single_xfer.len = 2 * sizeof(st->tx_buf[0]); in adc108s102_probe()
274 spi_message_init_with_transfers(&st->scan_single_msg, in adc108s102_probe()
275 &st->scan_single_xfer, 1); in adc108s102_probe()
284 dev_err(&spi->dev, "Failed to register IIO device\n"); in adc108s102_probe()
293 regulator_disable(st->reg); in adc108s102_probe()
306 regulator_disable(st->reg); in adc108s102_remove()