1 /* include/linux/adc.h
\r
3 * This program is free software; you can redistribute it and/or modify
\r
4 * it under the terms of the GNU General Public License version 2 as
\r
5 * published by the Free Software Foundation.
\r
9 #ifndef __ASM_ADC_CORE_H
\r
10 #define __ASM_ADC_CORE_H
\r
12 #include <linux/list.h>
\r
13 #include <linux/wait.h>
\r
15 enum host_chn_shift{
\r
16 SARADC_CHN_SHIFT = 0,
\r
17 CUSTOM_CHN_SHIFT = 28
\r
21 SARADC_CHN_MASK = 0x0000000f, // saradc: 0 -- 15
\r
22 CUSTOM_CHN_MASK = 0xf0000000,
\r
29 unsigned int is_finished;
\r
32 struct adc_host *adc;
\r
33 struct list_head list;
\r
34 wait_queue_head_t wait;
\r
35 void (*callback)(struct adc_client *, void *, int);
\r
36 void *callback_param;
\r
40 struct adc_client *adc_register(int chn,
\r
41 void (*callback)(struct adc_client *, void *, int),
\r
42 void *callback_param);
\r
43 void adc_unregister(struct adc_client *client);
\r
45 * function: adc_sync_read
\r
47 * if correct, return adc sample value;
\r
48 * if error, return negative;
\r
50 int adc_sync_read(struct adc_client *client);
\r
52 * function: adc_async_read
\r
53 * 1)return value: if error, return negative; else return 0;
\r
54 * 2)adc sample value: the third parameter of callback.
\r
55 * if timeout, sample value is -1; else sample value is non-negative
\r
57 int adc_async_read(struct adc_client *client);
\r
59 * function: return current reference voltage, unit: mV
\r
61 int adc_get_curr_ref_volt(void);
\r
63 * function: return default reference voltage, unit: mV
\r
65 int adc_get_def_ref_volt(void);
\r
67 static inline struct adc_client *adc_register(int chn,
\r
68 void (*callback)(struct adc_client *, void *, int),
\r
69 void *callback_param)
\r
73 static inline void adc_unregister(struct adc_client *client) {}
\r
74 static inline int adc_sync_read(struct adc_client *client) { return -1; }
\r
75 static inline int adc_async_read(struct adc_client *client) { return -1; }
\r
76 static inline int adc_get_curr_ref_volt(void) { return -1; }
\r
77 static inline int adc_get_def_ref_volt(void) { return -1; }
\r