update adc driver: interrupt add spin_lock
[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 #define ASYNC_READ 0\r
35 #define SYNC_READ 1\r
36         int status;\r
37 };\r
38 struct adc_host;\r
39 struct adc_ops {\r
40         void (*start)(struct adc_host *);\r
41         void (*stop)(struct adc_host *);\r
42         int (*read)(struct adc_host *);\r
43 };\r
44         \r
45         \r
46 struct adc_host {\r
47         struct device *dev;\r
48         int is_suspended;\r
49         struct adc_request *queue[MAX_ADC_FIFO_DEPTH];\r
50         int queue_head;\r
51         int queue_tail;\r
52         spinlock_t                      lock;\r
53         struct adc_client *cur;\r
54         const struct adc_ops *ops;\r
55         unsigned long           private[0];\r
56 };\r
57 static inline void *adc_priv(struct adc_host *adc)\r
58 {\r
59         return (void *)adc->private;\r
60 }\r
61         \r
62 extern struct adc_host *adc_alloc_host(int extra, struct device *dev);\r
63 extern void adc_free_host(struct adc_host *adc);\r
64 extern void adc_core_irq_handle(struct adc_host *adc);\r
65 \r
66 \r
67 #ifdef CONFIG_ADC\r
68 extern struct adc_client *adc_register(int chn,\r
69                                 void (*callback)(struct adc_client *, void *, int), \r
70                                 void *callback_param);\r
71 extern void adc_unregister(struct adc_client *client);\r
72 \r
73 extern int adc_sync_read(struct adc_client *client);\r
74 extern int adc_async_read(struct adc_client *client);\r
75 #else\r
76 static inline struct adc_client *adc_register(int chn,\r
77                                 void (*callback)(struct adc_client *, void *, int),\r
78                                 void *callback_param)\r
79 {\r
80         return NULL;\r
81 }\r
82 static inline void adc_unregister(struct adc_client *client) {}\r
83 static inline int adc_sync_read(struct adc_client *client) { return -EINVAL; }\r
84 static inline int adc_async_read(struct adc_client *client) { return -EINVAL; }\r
85 #endif\r
86 \r
87 #endif\r
88 \r