Lines Matching refs:adc_dev

53 static u32 get_adc_step_mask(struct tiadc_device *adc_dev)  in get_adc_step_mask()  argument
57 step_en = ((1 << adc_dev->channels) - 1); in get_adc_step_mask()
58 step_en <<= TOTAL_STEPS - adc_dev->channels + 1; in get_adc_step_mask()
62 static u32 get_adc_chan_step_mask(struct tiadc_device *adc_dev, in get_adc_chan_step_mask() argument
67 for (i = 0; i < ARRAY_SIZE(adc_dev->channel_step); i++) { in get_adc_chan_step_mask()
68 if (chan->channel == adc_dev->channel_line[i]) { in get_adc_chan_step_mask()
71 step = adc_dev->channel_step[i]; in get_adc_chan_step_mask()
80 static u32 get_adc_step_bit(struct tiadc_device *adc_dev, int chan) in get_adc_step_bit() argument
82 return 1 << adc_dev->channel_step[chan]; in get_adc_step_bit()
87 struct tiadc_device *adc_dev = iio_priv(indio_dev); in tiadc_step_config() local
107 for (i = 0; i < adc_dev->channels; i++) { in tiadc_step_config()
110 chan = adc_dev->channel_line[i]; in tiadc_step_config()
111 tiadc_writel(adc_dev, REG_STEPCONFIG(steps), in tiadc_step_config()
113 tiadc_writel(adc_dev, REG_STEPDELAY(steps), in tiadc_step_config()
115 adc_dev->channel_step[i] = steps; in tiadc_step_config()
123 struct tiadc_device *adc_dev = iio_priv(indio_dev); in tiadc_irq_h() local
125 status = tiadc_readl(adc_dev, REG_IRQSTATUS); in tiadc_irq_h()
133 config = tiadc_readl(adc_dev, REG_CTRL); in tiadc_irq_h()
135 tiadc_writel(adc_dev, REG_CTRL, config); in tiadc_irq_h()
136 tiadc_writel(adc_dev, REG_IRQSTATUS, IRQENB_FIFO1OVRRUN in tiadc_irq_h()
138 tiadc_writel(adc_dev, REG_CTRL, (config | CNTRLREG_TSCSSENB)); in tiadc_irq_h()
142 tiadc_writel(adc_dev, REG_IRQCLR, IRQENB_FIFO1THRES); in tiadc_irq_h()
152 struct tiadc_device *adc_dev = iio_priv(indio_dev); in tiadc_worker_h() local
154 u16 *data = adc_dev->data; in tiadc_worker_h()
156 fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT); in tiadc_worker_h()
159 read = tiadc_readl(adc_dev, REG_FIFO1); in tiadc_worker_h()
165 tiadc_writel(adc_dev, REG_IRQSTATUS, IRQENB_FIFO1THRES); in tiadc_worker_h()
166 tiadc_writel(adc_dev, REG_IRQENABLE, IRQENB_FIFO1THRES); in tiadc_worker_h()
173 struct tiadc_device *adc_dev = iio_priv(indio_dev); in tiadc_buffer_preenable() local
176 tiadc_writel(adc_dev, REG_IRQCLR, (IRQENB_FIFO1THRES | in tiadc_buffer_preenable()
181 fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT); in tiadc_buffer_preenable()
183 read = tiadc_readl(adc_dev, REG_FIFO1); in tiadc_buffer_preenable()
190 struct tiadc_device *adc_dev = iio_priv(indio_dev); in tiadc_buffer_postenable() local
195 for_each_set_bit(bit, indio_dev->active_scan_mask, adc_dev->channels) in tiadc_buffer_postenable()
196 enb |= (get_adc_step_bit(adc_dev, bit) << 1); in tiadc_buffer_postenable()
197 adc_dev->buffer_en_ch_steps = enb; in tiadc_buffer_postenable()
199 am335x_tsc_se_set_cache(adc_dev->mfd_tscadc, enb); in tiadc_buffer_postenable()
201 tiadc_writel(adc_dev, REG_IRQSTATUS, IRQENB_FIFO1THRES in tiadc_buffer_postenable()
203 tiadc_writel(adc_dev, REG_IRQENABLE, IRQENB_FIFO1THRES in tiadc_buffer_postenable()
211 struct tiadc_device *adc_dev = iio_priv(indio_dev); in tiadc_buffer_predisable() local
214 tiadc_writel(adc_dev, REG_IRQCLR, (IRQENB_FIFO1THRES | in tiadc_buffer_predisable()
216 am335x_tsc_se_clr(adc_dev->mfd_tscadc, adc_dev->buffer_en_ch_steps); in tiadc_buffer_predisable()
217 adc_dev->buffer_en_ch_steps = 0; in tiadc_buffer_predisable()
220 fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT); in tiadc_buffer_predisable()
222 read = tiadc_readl(adc_dev, REG_FIFO1); in tiadc_buffer_predisable()
274 struct tiadc_device *adc_dev = iio_priv(indio_dev); in tiadc_iio_buffered_hardware_remove() local
276 free_irq(adc_dev->mfd_tscadc->irq, indio_dev); in tiadc_iio_buffered_hardware_remove()
294 struct tiadc_device *adc_dev = iio_priv(indio_dev); in tiadc_channel_init() local
310 chan->channel = adc_dev->channel_line[i]; in tiadc_channel_init()
333 struct tiadc_device *adc_dev = iio_priv(indio_dev); in tiadc_read_raw() local
343 step_en = get_adc_chan_step_mask(adc_dev, chan); in tiadc_read_raw()
347 fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT); in tiadc_read_raw()
349 tiadc_readl(adc_dev, REG_FIFO1); in tiadc_read_raw()
351 am335x_tsc_se_set_once(adc_dev->mfd_tscadc, step_en); in tiadc_read_raw()
354 (IDLE_TIMEOUT * adc_dev->channels); in tiadc_read_raw()
357 fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT); in tiadc_read_raw()
362 am335x_tsc_se_adc_done(adc_dev->mfd_tscadc); in tiadc_read_raw()
366 map_val = adc_dev->channel_step[chan->scan_index]; in tiadc_read_raw()
376 read = tiadc_readl(adc_dev, REG_FIFO1); in tiadc_read_raw()
386 am335x_tsc_se_adc_done(adc_dev->mfd_tscadc); in tiadc_read_raw()
401 struct tiadc_device *adc_dev; in tiadc_probe() local
420 adc_dev = iio_priv(indio_dev); in tiadc_probe()
422 adc_dev->mfd_tscadc = ti_tscadc_dev_get(pdev); in tiadc_probe()
425 adc_dev->channel_line[channels] = val; in tiadc_probe()
428 adc_dev->channels = channels; in tiadc_probe()
436 tiadc_writel(adc_dev, REG_FIFO1THR, FIFO1_THRESHOLD); in tiadc_probe()
438 err = tiadc_channel_init(indio_dev, adc_dev->channels); in tiadc_probe()
445 adc_dev->mfd_tscadc->irq, in tiadc_probe()
470 struct tiadc_device *adc_dev = iio_priv(indio_dev); in tiadc_remove() local
477 step_en = get_adc_step_mask(adc_dev); in tiadc_remove()
478 am335x_tsc_se_clr(adc_dev->mfd_tscadc, step_en); in tiadc_remove()
487 struct tiadc_device *adc_dev = iio_priv(indio_dev); in tiadc_suspend() local
493 idle = tiadc_readl(adc_dev, REG_CTRL); in tiadc_suspend()
495 tiadc_writel(adc_dev, REG_CTRL, (idle | in tiadc_suspend()
505 struct tiadc_device *adc_dev = iio_priv(indio_dev); in tiadc_resume() local
509 restore = tiadc_readl(adc_dev, REG_CTRL); in tiadc_resume()
511 tiadc_writel(adc_dev, REG_CTRL, restore); in tiadc_resume()
514 am335x_tsc_se_set_cache(adc_dev->mfd_tscadc, in tiadc_resume()
515 adc_dev->buffer_en_ch_steps); in tiadc_resume()