Lines Matching refs:idev
267 struct iio_dev *idev = pf->indio_dev; in at91_adc_trigger_handler() local
268 struct at91_adc_state *st = iio_priv(idev); in at91_adc_trigger_handler()
272 for (i = 0; i < idev->masklength; i++) { in at91_adc_trigger_handler()
273 if (!test_bit(i, idev->active_scan_mask)) in at91_adc_trigger_handler()
275 chan = idev->channels + i; in at91_adc_trigger_handler()
280 iio_push_to_buffers_with_timestamp(idev, st->buffer, pf->timestamp); in at91_adc_trigger_handler()
282 iio_trigger_notify_done(idev->trig); in at91_adc_trigger_handler()
293 static void handle_adc_eoc_trigger(int irq, struct iio_dev *idev) in handle_adc_eoc_trigger() argument
295 struct at91_adc_state *st = iio_priv(idev); in handle_adc_eoc_trigger()
297 if (iio_buffer_enabled(idev)) { in handle_adc_eoc_trigger()
299 iio_trigger_poll(idev->trig); in handle_adc_eoc_trigger()
309 static int at91_ts_sample(struct iio_dev *idev) in at91_ts_sample() argument
311 struct at91_adc_state *st = iio_priv(idev); in at91_ts_sample()
327 dev_err(&idev->dev, "Error: xscale == 0!\n"); in at91_ts_sample()
338 dev_err(&idev->dev, "Error: yscale == 0!\n"); in at91_ts_sample()
354 …dev_dbg(&idev->dev, "xpos = %d, xscale = %d, ypos = %d, yscale = %d, z1 = %d, z2 = %d, press = %d\… in at91_ts_sample()
358 dev_dbg(&idev->dev, "x = %d, y = %d, pressure = %d\n", in at91_ts_sample()
366 dev_dbg(&idev->dev, "pressure too low: not reporting\n"); in at91_ts_sample()
374 struct iio_dev *idev = private; in at91_adc_rl_interrupt() local
375 struct at91_adc_state *st = iio_priv(idev); in at91_adc_rl_interrupt()
381 handle_adc_eoc_trigger(irq, idev); in at91_adc_rl_interrupt()
439 struct iio_dev *idev = private; in at91_adc_9x5_interrupt() local
440 struct at91_adc_state *st = iio_priv(idev); in at91_adc_9x5_interrupt()
448 handle_adc_eoc_trigger(irq, idev); in at91_adc_9x5_interrupt()
471 at91_ts_sample(idev); in at91_adc_9x5_interrupt()
485 static int at91_adc_channel_init(struct iio_dev *idev) in at91_adc_channel_init() argument
487 struct at91_adc_state *st = iio_priv(idev); in at91_adc_channel_init()
501 idev->num_channels = bitmap_weight(&st->channels_mask, in at91_adc_channel_init()
504 chan_array = devm_kzalloc(&idev->dev, in at91_adc_channel_init()
505 ((idev->num_channels + 1) * in at91_adc_channel_init()
535 idev->channels = chan_array; in at91_adc_channel_init()
536 return idev->num_channels; in at91_adc_channel_init()
539 static int at91_adc_get_trigger_value_by_name(struct iio_dev *idev, in at91_adc_get_trigger_value_by_name() argument
543 struct at91_adc_state *st = iio_priv(idev); in at91_adc_get_trigger_value_by_name()
549 idev->name, in at91_adc_get_trigger_value_by_name()
550 iio_device_id(idev), in at91_adc_get_trigger_value_by_name()
570 struct iio_dev *idev = iio_trigger_get_drvdata(trig); in at91_adc_configure_trigger() local
571 struct at91_adc_state *st = iio_priv(idev); in at91_adc_configure_trigger()
577 value = at91_adc_get_trigger_value_by_name(idev, in at91_adc_configure_trigger()
579 idev->trig->name); in at91_adc_configure_trigger()
584 st->buffer = kmalloc(idev->scan_bytes, GFP_KERNEL); in at91_adc_configure_trigger()
591 for_each_set_bit(bit, idev->active_scan_mask, in at91_adc_configure_trigger()
593 struct iio_chan_spec const *chan = idev->channels + bit; in at91_adc_configure_trigger()
606 for_each_set_bit(bit, idev->active_scan_mask, in at91_adc_configure_trigger()
608 struct iio_chan_spec const *chan = idev->channels + bit; in at91_adc_configure_trigger()
622 static struct iio_trigger *at91_adc_allocate_trigger(struct iio_dev *idev, in at91_adc_allocate_trigger() argument
628 trig = iio_trigger_alloc(idev->dev.parent, "%s-dev%d-%s", idev->name, in at91_adc_allocate_trigger()
629 iio_device_id(idev), trigger->name); in at91_adc_allocate_trigger()
633 iio_trigger_set_drvdata(trig, idev); in at91_adc_allocate_trigger()
645 static int at91_adc_trigger_init(struct iio_dev *idev) in at91_adc_trigger_init() argument
647 struct at91_adc_state *st = iio_priv(idev); in at91_adc_trigger_init()
650 st->trig = devm_kcalloc(&idev->dev, in at91_adc_trigger_init()
663 st->trig[i] = at91_adc_allocate_trigger(idev, in at91_adc_trigger_init()
666 dev_err(&idev->dev, in at91_adc_trigger_init()
684 static void at91_adc_trigger_remove(struct iio_dev *idev) in at91_adc_trigger_remove() argument
686 struct at91_adc_state *st = iio_priv(idev); in at91_adc_trigger_remove()
695 static int at91_adc_buffer_init(struct iio_dev *idev) in at91_adc_buffer_init() argument
697 return iio_triggered_buffer_setup(idev, &iio_pollfunc_store_time, in at91_adc_buffer_init()
701 static void at91_adc_buffer_remove(struct iio_dev *idev) in at91_adc_buffer_remove() argument
703 iio_triggered_buffer_cleanup(idev); in at91_adc_buffer_remove()
706 static int at91_adc_read_raw(struct iio_dev *idev, in at91_adc_read_raw() argument
710 struct at91_adc_state *st = iio_priv(idev); in at91_adc_read_raw()
742 dev_err(&idev->dev, "ADC Channel %d timeout.\n", in at91_adc_read_raw()
861 static int at91_ts_hw_init(struct iio_dev *idev, u32 adc_clk_khz) in at91_ts_hw_init() argument
863 struct at91_adc_state *st = iio_priv(idev); in at91_ts_hw_init()
903 dev_dbg(&idev->dev, "adc_clk at: %d KHz, tssctim at: %d\n", in at91_ts_hw_init()
936 static int at91_ts_register(struct iio_dev *idev, in at91_ts_register() argument
939 struct at91_adc_state *st = iio_priv(idev); in at91_ts_register()
945 dev_err(&idev->dev, "Failed to allocate TS device!\n"); in at91_ts_register()
1002 struct iio_dev *idev; in at91_adc_probe() local
1007 idev = devm_iio_device_alloc(&pdev->dev, sizeof(struct at91_adc_state)); in at91_adc_probe()
1008 if (!idev) in at91_adc_probe()
1011 st = iio_priv(idev); in at91_adc_probe()
1018 dev_err(&idev->dev, "Missing adc-channels-used property in the DT.\n"); in at91_adc_probe()
1026 dev_err(&idev->dev, "Missing adc-startup-time property in the DT.\n"); in at91_adc_probe()
1036 dev_err(&idev->dev, "Missing adc-vref property in the DT.\n"); in at91_adc_probe()
1047 dev_info(&idev->dev, "Resolution used: %u bits\n", st->res); in at91_adc_probe()
1054 ret = at91_adc_probe_dt_ts(node, st, &idev->dev); in at91_adc_probe()
1059 platform_set_drvdata(pdev, idev); in at91_adc_probe()
1061 idev->name = dev_name(&pdev->dev); in at91_adc_probe()
1062 idev->modes = INDIO_DIRECT_MODE; in at91_adc_probe()
1063 idev->info = &at91_adc_info; in at91_adc_probe()
1082 pdev->dev.driver->name, idev); in at91_adc_probe()
1085 pdev->dev.driver->name, idev); in at91_adc_probe()
1161 ret = at91_adc_channel_init(idev); in at91_adc_probe()
1176 ret = at91_adc_buffer_init(idev); in at91_adc_probe()
1182 ret = at91_adc_trigger_init(idev); in at91_adc_probe()
1185 at91_adc_buffer_remove(idev); in at91_adc_probe()
1189 ret = at91_ts_register(idev, pdev); in at91_adc_probe()
1193 at91_ts_hw_init(idev, adc_clk_khz); in at91_adc_probe()
1196 ret = iio_device_register(idev); in at91_adc_probe()
1206 at91_adc_trigger_remove(idev); in at91_adc_probe()
1207 at91_adc_buffer_remove(idev); in at91_adc_probe()
1216 free_irq(st->irq, idev); in at91_adc_probe()
1222 struct iio_dev *idev = platform_get_drvdata(pdev); in at91_adc_remove() local
1223 struct at91_adc_state *st = iio_priv(idev); in at91_adc_remove()
1225 iio_device_unregister(idev); in at91_adc_remove()
1227 at91_adc_trigger_remove(idev); in at91_adc_remove()
1228 at91_adc_buffer_remove(idev); in at91_adc_remove()
1234 free_irq(st->irq, idev); in at91_adc_remove()
1241 struct iio_dev *idev = dev_get_drvdata(dev); in at91_adc_suspend() local
1242 struct at91_adc_state *st = iio_priv(idev); in at91_adc_suspend()
1252 struct iio_dev *idev = dev_get_drvdata(dev); in at91_adc_resume() local
1253 struct at91_adc_state *st = iio_priv(idev); in at91_adc_resume()