Merge remote-tracking branch 'origin/upstream/linux-linaro-lsk-v3.10-android+android...
[firefly-linux-kernel-4.4.55.git] / include / linux / adc.h
1 /* include/linux/adc.h\r
2  *\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
6  *\r
7 */\r
8 \r
9 #ifndef __ASM_ADC_CORE_H\r
10 #define __ASM_ADC_CORE_H\r
11 \r
12 #include <linux/list.h>\r
13 #include <linux/wait.h>\r
14 \r
15 enum host_chn_shift{\r
16         SARADC_CHN_SHIFT = 0,\r
17         CUSTOM_CHN_SHIFT = 28\r
18 };\r
19 \r
20 enum host_chn_mask{\r
21         SARADC_CHN_MASK = 0x0000000f,  // saradc: 0 -- 15\r
22         CUSTOM_CHN_MASK = 0xf0000000,\r
23 };\r
24 \r
25 struct adc_host;\r
26 struct adc_client {\r
27         unsigned int index;\r
28         unsigned int chn;\r
29         unsigned int is_finished;\r
30         unsigned int flags;\r
31         int result;\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
37 };\r
38 \r
39 #ifdef CONFIG_ADC\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
44 /*\r
45  * function: adc_sync_read\r
46  * 1)return value:\r
47  *     if correct, return adc sample value;\r
48  *     if error, return negative;\r
49  */\r
50 int adc_sync_read(struct adc_client *client);\r
51 /*\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
56  */\r
57 int adc_async_read(struct adc_client *client);\r
58 /*\r
59  * function: return current reference voltage, unit: mV\r
60  */\r
61 int adc_get_curr_ref_volt(void);\r
62 /*\r
63  * function: return default reference voltage, unit: mV\r
64  */\r
65 int adc_get_def_ref_volt(void);\r
66 #else\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
70 {\r
71         return NULL;\r
72 }\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
78 #endif\r
79 \r
80 #endif\r
81 \r