Lines Matching refs:adc_dev

54 static u32 get_adc_step_mask(struct tiadc_device *adc_dev)  in get_adc_step_mask()  argument
58 step_en = ((1 << adc_dev->channels) - 1); in get_adc_step_mask()
59 step_en <<= TOTAL_STEPS - adc_dev->channels + 1; in get_adc_step_mask()
63 static u32 get_adc_chan_step_mask(struct tiadc_device *adc_dev, in get_adc_chan_step_mask() argument
68 for (i = 0; i < ARRAY_SIZE(adc_dev->channel_step); i++) { in get_adc_chan_step_mask()
69 if (chan->channel == adc_dev->channel_line[i]) { in get_adc_chan_step_mask()
72 step = adc_dev->channel_step[i]; in get_adc_chan_step_mask()
81 static u32 get_adc_step_bit(struct tiadc_device *adc_dev, int chan) in get_adc_step_bit() argument
83 return 1 << adc_dev->channel_step[chan]; in get_adc_step_bit()
88 struct tiadc_device *adc_dev = iio_priv(indio_dev); in tiadc_step_config() local
89 struct device *dev = adc_dev->mfd_tscadc->dev; in tiadc_step_config()
104 for (i = 0; i < adc_dev->channels; i++) { in tiadc_step_config()
107 chan = adc_dev->channel_line[i]; in tiadc_step_config()
109 if (adc_dev->step_avg[i] > STEPCONFIG_AVG_16) { in tiadc_step_config()
112 adc_dev->step_avg[i] = STEPCONFIG_AVG_16; in tiadc_step_config()
115 if (adc_dev->step_avg[i]) in tiadc_step_config()
117 STEPCONFIG_AVG(ffs(adc_dev->step_avg[i]) - 1) | in tiadc_step_config()
125 tiadc_writel(adc_dev, REG_STEPCONFIG(steps), in tiadc_step_config()
128 if (adc_dev->open_delay[i] > STEPDELAY_OPEN_MASK) { in tiadc_step_config()
131 adc_dev->open_delay[i] = STEPDELAY_OPEN_MASK; in tiadc_step_config()
134 if (adc_dev->sample_delay[i] > 0xFF) { in tiadc_step_config()
137 adc_dev->sample_delay[i] = 0xFF; in tiadc_step_config()
140 tiadc_writel(adc_dev, REG_STEPDELAY(steps), in tiadc_step_config()
141 STEPDELAY_OPEN(adc_dev->open_delay[i]) | in tiadc_step_config()
142 STEPDELAY_SAMPLE(adc_dev->sample_delay[i])); in tiadc_step_config()
144 adc_dev->channel_step[i] = steps; in tiadc_step_config()
152 struct tiadc_device *adc_dev = iio_priv(indio_dev); in tiadc_irq_h() local
154 status = tiadc_readl(adc_dev, REG_IRQSTATUS); in tiadc_irq_h()
162 config = tiadc_readl(adc_dev, REG_CTRL); in tiadc_irq_h()
164 tiadc_writel(adc_dev, REG_CTRL, config); in tiadc_irq_h()
165 tiadc_writel(adc_dev, REG_IRQSTATUS, IRQENB_FIFO1OVRRUN in tiadc_irq_h()
167 tiadc_writel(adc_dev, REG_CTRL, (config | CNTRLREG_TSCSSENB)); in tiadc_irq_h()
171 tiadc_writel(adc_dev, REG_IRQCLR, IRQENB_FIFO1THRES); in tiadc_irq_h()
181 struct tiadc_device *adc_dev = iio_priv(indio_dev); in tiadc_worker_h() local
183 u16 *data = adc_dev->data; in tiadc_worker_h()
185 fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT); in tiadc_worker_h()
188 read = tiadc_readl(adc_dev, REG_FIFO1); in tiadc_worker_h()
194 tiadc_writel(adc_dev, REG_IRQSTATUS, IRQENB_FIFO1THRES); in tiadc_worker_h()
195 tiadc_writel(adc_dev, REG_IRQENABLE, IRQENB_FIFO1THRES); in tiadc_worker_h()
202 struct tiadc_device *adc_dev = iio_priv(indio_dev); in tiadc_buffer_preenable() local
205 tiadc_writel(adc_dev, REG_IRQCLR, (IRQENB_FIFO1THRES | in tiadc_buffer_preenable()
210 fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT); in tiadc_buffer_preenable()
212 read = tiadc_readl(adc_dev, REG_FIFO1); in tiadc_buffer_preenable()
219 struct tiadc_device *adc_dev = iio_priv(indio_dev); in tiadc_buffer_postenable() local
224 for_each_set_bit(bit, indio_dev->active_scan_mask, adc_dev->channels) in tiadc_buffer_postenable()
225 enb |= (get_adc_step_bit(adc_dev, bit) << 1); in tiadc_buffer_postenable()
226 adc_dev->buffer_en_ch_steps = enb; in tiadc_buffer_postenable()
228 am335x_tsc_se_set_cache(adc_dev->mfd_tscadc, enb); in tiadc_buffer_postenable()
230 tiadc_writel(adc_dev, REG_IRQSTATUS, IRQENB_FIFO1THRES in tiadc_buffer_postenable()
232 tiadc_writel(adc_dev, REG_IRQENABLE, IRQENB_FIFO1THRES in tiadc_buffer_postenable()
240 struct tiadc_device *adc_dev = iio_priv(indio_dev); in tiadc_buffer_predisable() local
243 tiadc_writel(adc_dev, REG_IRQCLR, (IRQENB_FIFO1THRES | in tiadc_buffer_predisable()
245 am335x_tsc_se_clr(adc_dev->mfd_tscadc, adc_dev->buffer_en_ch_steps); in tiadc_buffer_predisable()
246 adc_dev->buffer_en_ch_steps = 0; in tiadc_buffer_predisable()
249 fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT); in tiadc_buffer_predisable()
251 read = tiadc_readl(adc_dev, REG_FIFO1); in tiadc_buffer_predisable()
303 struct tiadc_device *adc_dev = iio_priv(indio_dev); in tiadc_iio_buffered_hardware_remove() local
305 free_irq(adc_dev->mfd_tscadc->irq, indio_dev); in tiadc_iio_buffered_hardware_remove()
323 struct tiadc_device *adc_dev = iio_priv(indio_dev); in tiadc_channel_init() local
339 chan->channel = adc_dev->channel_line[i]; in tiadc_channel_init()
362 struct tiadc_device *adc_dev = iio_priv(indio_dev); in tiadc_read_raw() local
372 step_en = get_adc_chan_step_mask(adc_dev, chan); in tiadc_read_raw()
376 fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT); in tiadc_read_raw()
378 tiadc_readl(adc_dev, REG_FIFO1); in tiadc_read_raw()
380 am335x_tsc_se_set_once(adc_dev->mfd_tscadc, step_en); in tiadc_read_raw()
383 (IDLE_TIMEOUT * adc_dev->channels); in tiadc_read_raw()
386 fifo1count = tiadc_readl(adc_dev, REG_FIFO1CNT); in tiadc_read_raw()
391 am335x_tsc_se_adc_done(adc_dev->mfd_tscadc); in tiadc_read_raw()
395 map_val = adc_dev->channel_step[chan->scan_index]; in tiadc_read_raw()
405 read = tiadc_readl(adc_dev, REG_FIFO1); in tiadc_read_raw()
415 am335x_tsc_se_adc_done(adc_dev->mfd_tscadc); in tiadc_read_raw()
428 struct tiadc_device *adc_dev) in tiadc_parse_dt() argument
437 adc_dev->channel_line[channels] = val; in tiadc_parse_dt()
440 adc_dev->open_delay[channels] = STEPCONFIG_OPENDLY; in tiadc_parse_dt()
441 adc_dev->sample_delay[channels] = STEPCONFIG_SAMPLEDLY; in tiadc_parse_dt()
442 adc_dev->step_avg[channels] = 16; in tiadc_parse_dt()
448 adc_dev->step_avg, channels); in tiadc_parse_dt()
450 adc_dev->open_delay, channels); in tiadc_parse_dt()
452 adc_dev->sample_delay, channels); in tiadc_parse_dt()
454 adc_dev->channels = channels; in tiadc_parse_dt()
461 struct tiadc_device *adc_dev; in tiadc_probe() local
476 adc_dev = iio_priv(indio_dev); in tiadc_probe()
478 adc_dev->mfd_tscadc = ti_tscadc_dev_get(pdev); in tiadc_probe()
479 tiadc_parse_dt(pdev, adc_dev); in tiadc_probe()
487 tiadc_writel(adc_dev, REG_FIFO1THR, FIFO1_THRESHOLD); in tiadc_probe()
489 err = tiadc_channel_init(indio_dev, adc_dev->channels); in tiadc_probe()
496 adc_dev->mfd_tscadc->irq, in tiadc_probe()
521 struct tiadc_device *adc_dev = iio_priv(indio_dev); in tiadc_remove() local
528 step_en = get_adc_step_mask(adc_dev); in tiadc_remove()
529 am335x_tsc_se_clr(adc_dev->mfd_tscadc, step_en); in tiadc_remove()
538 struct tiadc_device *adc_dev = iio_priv(indio_dev); in tiadc_suspend() local
544 idle = tiadc_readl(adc_dev, REG_CTRL); in tiadc_suspend()
546 tiadc_writel(adc_dev, REG_CTRL, (idle | in tiadc_suspend()
556 struct tiadc_device *adc_dev = iio_priv(indio_dev); in tiadc_resume() local
560 restore = tiadc_readl(adc_dev, REG_CTRL); in tiadc_resume()
562 tiadc_writel(adc_dev, REG_CTRL, restore); in tiadc_resume()
565 am335x_tsc_se_set_cache(adc_dev->mfd_tscadc, in tiadc_resume()
566 adc_dev->buffer_en_ch_steps); in tiadc_resume()