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()
643 static int at91_adc_trigger_init(struct iio_dev *idev) in at91_adc_trigger_init() argument
645 struct at91_adc_state *st = iio_priv(idev); in at91_adc_trigger_init()
648 st->trig = devm_kcalloc(&idev->dev, in at91_adc_trigger_init()
661 st->trig[i] = at91_adc_allocate_trigger(idev, in at91_adc_trigger_init()
664 dev_err(&idev->dev, in at91_adc_trigger_init()
682 static void at91_adc_trigger_remove(struct iio_dev *idev) in at91_adc_trigger_remove() argument
684 struct at91_adc_state *st = iio_priv(idev); in at91_adc_trigger_remove()
693 static int at91_adc_buffer_init(struct iio_dev *idev) in at91_adc_buffer_init() argument
695 return iio_triggered_buffer_setup(idev, &iio_pollfunc_store_time, in at91_adc_buffer_init()
699 static void at91_adc_buffer_remove(struct iio_dev *idev) in at91_adc_buffer_remove() argument
701 iio_triggered_buffer_cleanup(idev); in at91_adc_buffer_remove()
704 static int at91_adc_read_raw(struct iio_dev *idev, in at91_adc_read_raw() argument
708 struct at91_adc_state *st = iio_priv(idev); in at91_adc_read_raw()
740 dev_err(&idev->dev, "ADC Channel %d timeout.\n", in at91_adc_read_raw()
859 static int at91_ts_hw_init(struct iio_dev *idev, u32 adc_clk_khz) in at91_ts_hw_init() argument
861 struct at91_adc_state *st = iio_priv(idev); in at91_ts_hw_init()
901 dev_dbg(&idev->dev, "adc_clk at: %d KHz, tssctim at: %d\n", in at91_ts_hw_init()
934 static int at91_ts_register(struct iio_dev *idev, in at91_ts_register() argument
937 struct at91_adc_state *st = iio_priv(idev); in at91_ts_register()
943 dev_err(&idev->dev, "Failed to allocate TS device!\n"); in at91_ts_register()
1000 struct iio_dev *idev; in at91_adc_probe() local
1005 idev = devm_iio_device_alloc(&pdev->dev, sizeof(struct at91_adc_state)); in at91_adc_probe()
1006 if (!idev) in at91_adc_probe()
1009 st = iio_priv(idev); in at91_adc_probe()
1016 dev_err(&idev->dev, "Missing adc-channels-used property in the DT.\n"); in at91_adc_probe()
1024 dev_err(&idev->dev, "Missing adc-startup-time property in the DT.\n"); in at91_adc_probe()
1034 dev_err(&idev->dev, "Missing adc-vref property in the DT.\n"); in at91_adc_probe()
1045 dev_info(&idev->dev, "Resolution used: %u bits\n", st->res); in at91_adc_probe()
1052 ret = at91_adc_probe_dt_ts(node, st, &idev->dev); in at91_adc_probe()
1057 platform_set_drvdata(pdev, idev); in at91_adc_probe()
1059 idev->name = dev_name(&pdev->dev); in at91_adc_probe()
1060 idev->modes = INDIO_DIRECT_MODE; in at91_adc_probe()
1061 idev->info = &at91_adc_info; in at91_adc_probe()
1080 pdev->dev.driver->name, idev); in at91_adc_probe()
1083 pdev->dev.driver->name, idev); in at91_adc_probe()
1159 ret = at91_adc_channel_init(idev); in at91_adc_probe()
1174 ret = at91_adc_buffer_init(idev); in at91_adc_probe()
1180 ret = at91_adc_trigger_init(idev); in at91_adc_probe()
1183 at91_adc_buffer_remove(idev); in at91_adc_probe()
1187 ret = at91_ts_register(idev, pdev); in at91_adc_probe()
1191 at91_ts_hw_init(idev, adc_clk_khz); in at91_adc_probe()
1194 ret = iio_device_register(idev); in at91_adc_probe()
1204 at91_adc_trigger_remove(idev); in at91_adc_probe()
1205 at91_adc_buffer_remove(idev); in at91_adc_probe()
1214 free_irq(st->irq, idev); in at91_adc_probe()
1220 struct iio_dev *idev = platform_get_drvdata(pdev); in at91_adc_remove() local
1221 struct at91_adc_state *st = iio_priv(idev); in at91_adc_remove()
1223 iio_device_unregister(idev); in at91_adc_remove()
1225 at91_adc_trigger_remove(idev); in at91_adc_remove()
1226 at91_adc_buffer_remove(idev); in at91_adc_remove()
1232 free_irq(st->irq, idev); in at91_adc_remove()
1240 struct iio_dev *idev = dev_get_drvdata(dev); in at91_adc_suspend() local
1241 struct at91_adc_state *st = iio_priv(idev); in at91_adc_suspend()
1251 struct iio_dev *idev = dev_get_drvdata(dev); in at91_adc_resume() local
1252 struct at91_adc_state *st = iio_priv(idev); in at91_adc_resume()