#include <linux/adc.h>
#include "adc_priv.h"
-struct list_head adc_host_head;
+struct adc_host *g_adc = NULL;
+static LIST_HEAD(adc_host_head);
struct adc_host *adc_alloc_host(struct device *dev, int extra, enum host_chn_mask mask)
{
{
client->result = result;
}
+
static void adc_callback(struct adc_host *adc)
{
struct adc_request *req = NULL, *n = NULL;
kfree(req);
}
}
+
void adc_finished(struct adc_host *adc, int result)
{
unsigned long flags;
adc_callback(adc);
}
+
void adc_core_irq_handle(struct adc_host *adc)
{
int result = 0;
EXPORT_SYMBOL(adc_async_read);
-static int __init adc_core_init(void)
+int adc_get_def_ref_volt(void)
{
- INIT_LIST_HEAD(&adc_host_head);
- return 0;
+ return g_adc->pdata->ref_volt;
}
-subsys_initcall(adc_core_init);
+EXPORT_SYMBOL(adc_get_def_ref_volt);
-static void __exit adc_core_exit(void)
+int adc_get_curr_ref_volt(void)
{
- return;
+ int v = 0, volt = 0;
+
+ if(!g_adc)
+ return -EINVAL;
+ if(!g_adc->base_client)
+ return g_adc->pdata->ref_volt;
+
+ volt = g_adc->pdata->get_base_volt();
+ if(volt < 0)
+ return g_adc->pdata->ref_volt;
+
+ v = adc_sync_read(g_adc->base_client);
+ if(v < 0)
+ return v;
+
+ return volt * 1024 / v;
}
-module_exit(adc_core_exit);
-
-
+EXPORT_SYMBOL(adc_get_curr_ref_volt);