Merge branch 'develop' of xjh@10.10.10.29:/home/rockchip/kernel into develop_29server
[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 #define MAX_ADC_CHN 4\r
13 #define MAX_ADC_FIFO_DEPTH 8\r
14 \r
15 \r
16 struct adc_client {\r
17         int chn;\r
18         int time;\r
19         int result;\r
20         void (*callback)(struct adc_client *, void *, int);\r
21         void *callback_param;\r
22 \r
23         struct adc_host *adc;\r
24 };\r
25 \r
26 struct adc_request {\r
27         int result;\r
28         int chn;\r
29         void (*callback)(struct adc_client *, void *, int);\r
30         void *callback_param;\r
31         struct adc_client *client;\r
32         /* Used in case of sync requests */\r
33         struct completion completion;\r
34 };\r
35 struct adc_host;\r
36 struct adc_ops {\r
37         void (*start)(struct adc_host *);\r
38         void (*stop)(struct adc_host *);\r
39         int (*read)(struct adc_host *);\r
40 };\r
41         \r
42         \r
43 struct adc_host {\r
44         struct device *dev;\r
45         int is_suspended;\r
46         struct adc_request *queue[MAX_ADC_FIFO_DEPTH];\r
47         int queue_head;\r
48         int queue_tail;\r
49         struct mutex queue_mutex;\r
50         struct adc_client *cur;\r
51         const struct adc_ops *ops;\r
52         unsigned long           private[0];\r
53 };\r
54 static inline void *adc_priv(struct adc_host *adc)\r
55 {\r
56         return (void *)adc->private;\r
57 }\r
58         \r
59 extern struct adc_host *adc_alloc_host(int extra, struct device *dev);\r
60 extern void adc_free_host(struct adc_host *adc);\r
61 extern void adc_core_irq_handle(struct adc_host *adc);\r
62 \r
63 \r
64 #ifdef CONFIG_ADC\r
65 extern struct adc_client *adc_register(int chn,\r
66                                 void (*callback)(struct adc_client *, void *, int), \r
67                                 void *callback_param);\r
68 extern void adc_unregister(struct adc_client *client);\r
69 \r
70 extern int adc_sync_read(struct adc_client *client);\r
71 extern int adc_async_read(struct adc_client *client);\r
72 #else\r
73 static inline struct adc_client *adc_register(int chn,\r
74                                 void (*callback)(struct adc_client *, void *, int),\r
75                                 void *callback_param)\r
76 {\r
77         return NULL;\r
78 }\r
79 static inline void adc_unregister(struct adc_client *client) {}\r
80 static inline int adc_sync_read(struct adc_client *client) { return -EINVAL; }\r
81 static inline int adc_async_read(struct adc_client *client) { return -EINVAL; }\r
82 #endif\r
83 \r
84 #endif\r
85 \r