#ifndef __ASM_ADC_CORE_H\r
#define __ASM_ADC_CORE_H\r
\r
-#define MAX_ADC_CHN 4\r
-#define MAX_ADC_FIFO_DEPTH 8\r
+#include <linux/list.h>\r
+#include <linux/wait.h>\r
\r
+enum host_chn_shift{\r
+ SARADC_CHN_SHIFT = 0,\r
+ CUSTOM_CHN_SHIFT = 28\r
+};\r
\r
-struct adc_client {\r
- int chn;\r
- int time;\r
- int result;\r
- void (*callback)(struct adc_client *, void *, int);\r
- void *callback_param;\r
-\r
- struct adc_host *adc;\r
+enum host_chn_mask{\r
+ SARADC_CHN_MASK = 0x0000000f, // saradc: 0 -- 15\r
+ CUSTOM_CHN_MASK = 0xf0000000,\r
};\r
\r
-struct adc_request {\r
- int result;\r
- int chn;\r
+struct adc_host;\r
+struct adc_client {\r
+ unsigned int index;\r
+ unsigned int chn;\r
+ unsigned int is_finished;\r
+ unsigned int flags;\r
+ int result;\r
+ struct adc_host *adc;\r
+ struct list_head list;\r
+ wait_queue_head_t wait;\r
void (*callback)(struct adc_client *, void *, int);\r
void *callback_param;\r
- struct adc_client *client;\r
- /* Used in case of sync requests */\r
- struct completion completion;\r
-#define ASYNC_READ 0\r
-#define SYNC_READ 1\r
- int status;\r
-};\r
-struct adc_host;\r
-struct adc_ops {\r
- void (*start)(struct adc_host *);\r
- void (*stop)(struct adc_host *);\r
- int (*read)(struct adc_host *);\r
-};\r
- \r
- \r
-struct adc_host {\r
- struct device *dev;\r
- int is_suspended;\r
- struct adc_request *queue[MAX_ADC_FIFO_DEPTH];\r
- int queue_head;\r
- int queue_tail;\r
- struct mutex queue_mutex;\r
- struct adc_client *cur;\r
- const struct adc_ops *ops;\r
- unsigned long private[0];\r
};\r
-static inline void *adc_priv(struct adc_host *adc)\r
-{\r
- return (void *)adc->private;\r
-}\r
- \r
-extern struct adc_host *adc_alloc_host(int extra, struct device *dev);\r
-extern void adc_free_host(struct adc_host *adc);\r
-extern void adc_core_irq_handle(struct adc_host *adc);\r
-\r
\r
#ifdef CONFIG_ADC\r
-extern struct adc_client *adc_register(int chn,\r
+struct adc_client *adc_register(int chn,\r
void (*callback)(struct adc_client *, void *, int), \r
void *callback_param);\r
-extern void adc_unregister(struct adc_client *client);\r
-\r
-extern int adc_sync_read(struct adc_client *client);\r
-extern int adc_async_read(struct adc_client *client);\r
+void adc_unregister(struct adc_client *client);\r
+/*\r
+ * function: adc_sync_read\r
+ * 1)return value:\r
+ * if correct, return adc sample value;\r
+ * if error, return negative;\r
+ */\r
+int adc_sync_read(struct adc_client *client);\r
+/*\r
+ * function: adc_async_read\r
+ * 1)return value: if error, return negative; else return 0;\r
+ * 2)adc sample value: the third parameter of callback.\r
+ * if timeout, sample value is -1; else sample value is non-negative\r
+ */\r
+int adc_async_read(struct adc_client *client);\r
+/*\r
+ * function: return current reference voltage, unit: mV\r
+ */\r
+int adc_get_curr_ref_volt(void);\r
+/*\r
+ * function: return default reference voltage, unit: mV\r
+ */\r
+int adc_get_def_ref_volt(void);\r
#else\r
static inline struct adc_client *adc_register(int chn,\r
void (*callback)(struct adc_client *, void *, int),\r
return NULL;\r
}\r
static inline void adc_unregister(struct adc_client *client) {}\r
-static inline int adc_sync_read(struct adc_client *client) { return -EINVAL; }\r
-static inline int adc_async_read(struct adc_client *client) { return -EINVAL; }\r
+static inline int adc_sync_read(struct adc_client *client) { return -1; }\r
+static inline int adc_async_read(struct adc_client *client) { return -1; }\r
+static inline int adc_get_curr_ref_volt(void) { return -1; }\r
+static inline int adc_get_def_ref_volt(void) { return -1; }\r
#endif\r
\r
#endif\r