• Home
  • Raw
  • Download

Lines Matching refs:sigma_delta

39 void ad_sd_set_comm(struct ad_sigma_delta *sigma_delta, uint8_t comm)  in ad_sd_set_comm()  argument
43 sigma_delta->comm = comm & AD_SD_COMM_CHAN_MASK; in ad_sd_set_comm()
57 int ad_sd_write_reg(struct ad_sigma_delta *sigma_delta, unsigned int reg, in ad_sd_write_reg() argument
60 uint8_t *data = sigma_delta->tx_buf; in ad_sd_write_reg()
64 .cs_change = sigma_delta->keep_cs_asserted, in ad_sd_write_reg()
69 data[0] = (reg << sigma_delta->info->addr_shift) | sigma_delta->comm; in ad_sd_write_reg()
90 if (sigma_delta->bus_locked) in ad_sd_write_reg()
91 ret = spi_sync_locked(sigma_delta->spi, &m); in ad_sd_write_reg()
93 ret = spi_sync(sigma_delta->spi, &m); in ad_sd_write_reg()
99 static int ad_sd_read_reg_raw(struct ad_sigma_delta *sigma_delta, in ad_sd_read_reg_raw() argument
102 uint8_t *data = sigma_delta->tx_buf; in ad_sd_read_reg_raw()
111 .cs_change = sigma_delta->bus_locked, in ad_sd_read_reg_raw()
118 if (sigma_delta->info->has_registers) { in ad_sd_read_reg_raw()
119 data[0] = reg << sigma_delta->info->addr_shift; in ad_sd_read_reg_raw()
120 data[0] |= sigma_delta->info->read_mask; in ad_sd_read_reg_raw()
121 data[0] |= sigma_delta->comm; in ad_sd_read_reg_raw()
126 if (sigma_delta->bus_locked) in ad_sd_read_reg_raw()
127 ret = spi_sync_locked(sigma_delta->spi, &m); in ad_sd_read_reg_raw()
129 ret = spi_sync(sigma_delta->spi, &m); in ad_sd_read_reg_raw()
144 int ad_sd_read_reg(struct ad_sigma_delta *sigma_delta, in ad_sd_read_reg() argument
149 ret = ad_sd_read_reg_raw(sigma_delta, reg, size, sigma_delta->rx_buf); in ad_sd_read_reg()
155 *val = get_unaligned_be32(sigma_delta->rx_buf); in ad_sd_read_reg()
158 *val = get_unaligned_be24(sigma_delta->rx_buf); in ad_sd_read_reg()
161 *val = get_unaligned_be16(sigma_delta->rx_buf); in ad_sd_read_reg()
164 *val = sigma_delta->rx_buf[0]; in ad_sd_read_reg()
184 int ad_sd_reset(struct ad_sigma_delta *sigma_delta, in ad_sd_reset() argument
197 ret = spi_write(sigma_delta->spi, buf, size); in ad_sd_reset()
204 int ad_sd_calibrate(struct ad_sigma_delta *sigma_delta, in ad_sd_calibrate() argument
210 ret = ad_sigma_delta_set_channel(sigma_delta, channel); in ad_sd_calibrate()
214 spi_bus_lock(sigma_delta->spi->master); in ad_sd_calibrate()
215 sigma_delta->bus_locked = true; in ad_sd_calibrate()
216 sigma_delta->keep_cs_asserted = true; in ad_sd_calibrate()
217 reinit_completion(&sigma_delta->completion); in ad_sd_calibrate()
219 ret = ad_sigma_delta_set_mode(sigma_delta, mode); in ad_sd_calibrate()
223 sigma_delta->irq_dis = false; in ad_sd_calibrate()
224 enable_irq(sigma_delta->spi->irq); in ad_sd_calibrate()
225 timeout = wait_for_completion_timeout(&sigma_delta->completion, 2 * HZ); in ad_sd_calibrate()
227 sigma_delta->irq_dis = true; in ad_sd_calibrate()
228 disable_irq_nosync(sigma_delta->spi->irq); in ad_sd_calibrate()
234 sigma_delta->keep_cs_asserted = false; in ad_sd_calibrate()
235 ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_IDLE); in ad_sd_calibrate()
236 sigma_delta->bus_locked = false; in ad_sd_calibrate()
237 spi_bus_unlock(sigma_delta->spi->master); in ad_sd_calibrate()
251 int ad_sd_calibrate_all(struct ad_sigma_delta *sigma_delta, in ad_sd_calibrate_all() argument
258 ret = ad_sd_calibrate(sigma_delta, cb[i].mode, cb[i].channel); in ad_sd_calibrate_all()
278 struct ad_sigma_delta *sigma_delta = iio_device_get_drvdata(indio_dev); in ad_sigma_delta_single_conversion() local
287 ad_sigma_delta_set_channel(sigma_delta, chan->address); in ad_sigma_delta_single_conversion()
289 spi_bus_lock(sigma_delta->spi->master); in ad_sigma_delta_single_conversion()
290 sigma_delta->bus_locked = true; in ad_sigma_delta_single_conversion()
291 sigma_delta->keep_cs_asserted = true; in ad_sigma_delta_single_conversion()
292 reinit_completion(&sigma_delta->completion); in ad_sigma_delta_single_conversion()
294 ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_SINGLE); in ad_sigma_delta_single_conversion()
296 sigma_delta->irq_dis = false; in ad_sigma_delta_single_conversion()
297 enable_irq(sigma_delta->spi->irq); in ad_sigma_delta_single_conversion()
299 &sigma_delta->completion, HZ); in ad_sigma_delta_single_conversion()
306 if (sigma_delta->info->data_reg != 0) in ad_sigma_delta_single_conversion()
307 data_reg = sigma_delta->info->data_reg; in ad_sigma_delta_single_conversion()
311 ret = ad_sd_read_reg(sigma_delta, data_reg, in ad_sigma_delta_single_conversion()
316 if (!sigma_delta->irq_dis) { in ad_sigma_delta_single_conversion()
317 disable_irq_nosync(sigma_delta->spi->irq); in ad_sigma_delta_single_conversion()
318 sigma_delta->irq_dis = true; in ad_sigma_delta_single_conversion()
321 sigma_delta->keep_cs_asserted = false; in ad_sigma_delta_single_conversion()
322 ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_IDLE); in ad_sigma_delta_single_conversion()
323 sigma_delta->bus_locked = false; in ad_sigma_delta_single_conversion()
324 spi_bus_unlock(sigma_delta->spi->master); in ad_sigma_delta_single_conversion()
334 ret = ad_sigma_delta_postprocess_sample(sigma_delta, raw_sample); in ad_sigma_delta_single_conversion()
344 struct ad_sigma_delta *sigma_delta = iio_device_get_drvdata(indio_dev); in ad_sd_buffer_postenable() local
350 ret = ad_sigma_delta_set_channel(sigma_delta, in ad_sd_buffer_postenable()
355 spi_bus_lock(sigma_delta->spi->master); in ad_sd_buffer_postenable()
356 sigma_delta->bus_locked = true; in ad_sd_buffer_postenable()
357 sigma_delta->keep_cs_asserted = true; in ad_sd_buffer_postenable()
359 ret = ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_CONTINUOUS); in ad_sd_buffer_postenable()
363 sigma_delta->irq_dis = false; in ad_sd_buffer_postenable()
364 enable_irq(sigma_delta->spi->irq); in ad_sd_buffer_postenable()
369 spi_bus_unlock(sigma_delta->spi->master); in ad_sd_buffer_postenable()
376 struct ad_sigma_delta *sigma_delta = iio_device_get_drvdata(indio_dev); in ad_sd_buffer_postdisable() local
378 reinit_completion(&sigma_delta->completion); in ad_sd_buffer_postdisable()
379 wait_for_completion_timeout(&sigma_delta->completion, HZ); in ad_sd_buffer_postdisable()
381 if (!sigma_delta->irq_dis) { in ad_sd_buffer_postdisable()
382 disable_irq_nosync(sigma_delta->spi->irq); in ad_sd_buffer_postdisable()
383 sigma_delta->irq_dis = true; in ad_sd_buffer_postdisable()
386 sigma_delta->keep_cs_asserted = false; in ad_sd_buffer_postdisable()
387 ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_IDLE); in ad_sd_buffer_postdisable()
389 sigma_delta->bus_locked = false; in ad_sd_buffer_postdisable()
390 return spi_bus_unlock(sigma_delta->spi->master); in ad_sd_buffer_postdisable()
397 struct ad_sigma_delta *sigma_delta = iio_device_get_drvdata(indio_dev); in ad_sd_trigger_handler() local
398 uint8_t *data = sigma_delta->rx_buf; in ad_sd_trigger_handler()
406 if (sigma_delta->info->data_reg != 0) in ad_sd_trigger_handler()
407 data_reg = sigma_delta->info->data_reg; in ad_sd_trigger_handler()
415 ad_sd_read_reg_raw(sigma_delta, data_reg, reg_size, &data[0]); in ad_sd_trigger_handler()
420 ad_sd_read_reg_raw(sigma_delta, data_reg, reg_size, &data[1]); in ad_sd_trigger_handler()
427 sigma_delta->irq_dis = false; in ad_sd_trigger_handler()
428 enable_irq(sigma_delta->spi->irq); in ad_sd_trigger_handler()
441 struct ad_sigma_delta *sigma_delta = private; in ad_sd_data_rdy_trig_poll() local
443 complete(&sigma_delta->completion); in ad_sd_data_rdy_trig_poll()
445 sigma_delta->irq_dis = true; in ad_sd_data_rdy_trig_poll()
446 iio_trigger_poll(sigma_delta->trig); in ad_sd_data_rdy_trig_poll()
461 struct ad_sigma_delta *sigma_delta = iio_device_get_drvdata(indio_dev); in ad_sd_validate_trigger() local
463 if (sigma_delta->trig != trig) in ad_sd_validate_trigger()
475 struct ad_sigma_delta *sigma_delta = iio_device_get_drvdata(indio_dev); in ad_sd_probe_trigger() local
478 sigma_delta->trig = iio_trigger_alloc("%s-dev%d", indio_dev->name, in ad_sd_probe_trigger()
480 if (sigma_delta->trig == NULL) { in ad_sd_probe_trigger()
484 sigma_delta->trig->ops = &ad_sd_trigger_ops; in ad_sd_probe_trigger()
485 init_completion(&sigma_delta->completion); in ad_sd_probe_trigger()
487 ret = request_irq(sigma_delta->spi->irq, in ad_sd_probe_trigger()
489 sigma_delta->info->irq_flags, in ad_sd_probe_trigger()
491 sigma_delta); in ad_sd_probe_trigger()
495 if (!sigma_delta->irq_dis) { in ad_sd_probe_trigger()
496 sigma_delta->irq_dis = true; in ad_sd_probe_trigger()
497 disable_irq_nosync(sigma_delta->spi->irq); in ad_sd_probe_trigger()
499 sigma_delta->trig->dev.parent = &sigma_delta->spi->dev; in ad_sd_probe_trigger()
500 iio_trigger_set_drvdata(sigma_delta->trig, sigma_delta); in ad_sd_probe_trigger()
502 ret = iio_trigger_register(sigma_delta->trig); in ad_sd_probe_trigger()
507 indio_dev->trig = iio_trigger_get(sigma_delta->trig); in ad_sd_probe_trigger()
512 free_irq(sigma_delta->spi->irq, sigma_delta); in ad_sd_probe_trigger()
514 iio_trigger_free(sigma_delta->trig); in ad_sd_probe_trigger()
521 struct ad_sigma_delta *sigma_delta = iio_device_get_drvdata(indio_dev); in ad_sd_remove_trigger() local
523 iio_trigger_unregister(sigma_delta->trig); in ad_sd_remove_trigger()
524 free_irq(sigma_delta->spi->irq, sigma_delta); in ad_sd_remove_trigger()
525 iio_trigger_free(sigma_delta->trig); in ad_sd_remove_trigger()
572 int ad_sd_init(struct ad_sigma_delta *sigma_delta, struct iio_dev *indio_dev, in ad_sd_init() argument
575 sigma_delta->spi = spi; in ad_sd_init()
576 sigma_delta->info = info; in ad_sd_init()
577 iio_device_set_drvdata(indio_dev, sigma_delta); in ad_sd_init()