19 #include <linux/kernel.h>
20 #include <linux/slab.h>
21 #include <linux/module.h>
23 #include <linux/device.h>
42 #define PCF50633_MAX_ADC_FIFO_DEPTH 8
56 return platform_get_drvdata(pcf->
adc_pdev);
72 static void trigger_next_adc_job_if_any(
struct pcf50633 *
pcf)
79 if (!adc->
queue[head])
82 adc_setup(pcf, adc->
queue[head]->mux, adc->
queue[head]->avg);
96 if (adc->
queue[tail]) {
98 dev_err(pcf->
dev,
"ADC queue is full, dropping request\n");
104 trigger_next_adc_job_if_any(pcf);
112 static void pcf50633_adc_sync_read_callback(
struct pcf50633 *pcf,
void *
param,
129 pcf50633_adc_sync_read_callback, &req);
141 void *callback_param)
155 return adc_enqueue_request(pcf, req);
159 static int adc_result(
struct pcf50633 *pcf)
168 dev_dbg(pcf->
dev,
"adc result = %d\n", result);
173 static void pcf50633_adc_irq(
int irq,
void *
data)
185 dev_err(pcf->
dev,
"pcf50633-adc irq: ADC queue empty!\n");
193 res = adc_result(pcf);
194 trigger_next_adc_job_if_any(pcf);
210 adc->
pcf = dev_to_pcf50633(pdev->
dev.parent);
211 platform_set_drvdata(pdev, adc);
214 pcf50633_adc_irq, adc);
233 "adc driver removed with request pending\n");
246 .name =
"pcf50633-adc",
248 .probe = pcf50633_adc_probe,