blob: 5163b6503603d0d4b5746d0194d3e7419e58dbac [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * Qualcomm XOADC Driver header file
13 */
14
Rob Walker16e79b9f2011-12-02 18:08:23 -080015#ifndef _PMIC8058_XOADC_H_
16#define _PMIC8058_XOADC_H_
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070017
18#include <linux/kernel.h>
19#include <linux/list.h>
20#include <linux/workqueue.h>
21
22struct xoadc_conv_state {
23 struct adc_conv_slot *context;
24 struct list_head slots;
25 struct mutex list_lock;
26};
27
28#define CHANNEL_VCOIN 0
29#define CHANNEL_VBAT 1
30#define CHANNEL_VCHG 2
31#define CHANNEL_CHG_MONITOR 3
32#define CHANNEL_VPH_PWR 4
33#define CHANNEL_MPP5 5
34#define CHANNEL_MPP6 6
35#define CHANNEL_MPP7 7
36#define CHANNEL_MPP8 8
37#define CHANNEL_MPP9 9
38#define CHANNEL_USB_VBUS 0Xa
39#define CHANNEL_DIE_TEMP 0Xb
40#define CHANNEL_INTERNAL 0xc
41#define CHANNEL_125V 0xd
42#define CHANNEL_INTERNAL_2 0Xe
43#define CHANNEL_MUXOFF 0xf
44
45#define XOADC_MPP_3 0x2
46#define XOADC_MPP_4 0X3
47#define XOADC_MPP_5 0x4
48#define XOADC_MPP_7 0x6
49#define XOADC_MPP_8 0x7
50#define XOADC_MPP_10 0X9
51
52#define XOADC_PMIC_0 0x0
53
54#define CHANNEL_ADC_625_MV 625
55
56struct xoadc_platform_data {
57 struct adc_properties *xoadc_prop;
58 u32 (*xoadc_setup) (void);
59 void (*xoadc_shutdown) (void);
60 void (*xoadc_mpp_config) (void);
61 int (*xoadc_vreg_set) (int);
62 int (*xoadc_vreg_setup) (void);
63 void (*xoadc_vreg_shutdown) (void);
64 u32 xoadc_num;
65 u32 xoadc_wakeup;
66};
67
Vijayakumar Muthuvel Manickam2d2a2c52011-10-20 13:41:39 -070068#ifdef CONFIG_PMIC8058_XOADC
69int32_t pm8058_xoadc_read_adc_code(uint32_t adc_instance, int32_t *data);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070070
Vijayakumar Muthuvel Manickam2d2a2c52011-10-20 13:41:39 -070071int32_t pm8058_xoadc_select_chan_and_start_conv(uint32_t adc_instance,
72 struct adc_conv_slot *slot);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070073
Vijayakumar Muthuvel Manickam2d2a2c52011-10-20 13:41:39 -070074void pm8058_xoadc_slot_request(uint32_t adc_instance,
75 struct adc_conv_slot **slot);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070076
Vijayakumar Muthuvel Manickam2d2a2c52011-10-20 13:41:39 -070077void pm8058_xoadc_restore_slot(uint32_t adc_instance,
78 struct adc_conv_slot *slot);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070079
Vijayakumar Muthuvel Manickam2d2a2c52011-10-20 13:41:39 -070080struct adc_properties *pm8058_xoadc_get_properties(uint32_t dev_instance);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070081
Vijayakumar Muthuvel Manickam2d2a2c52011-10-20 13:41:39 -070082int32_t pm8058_xoadc_calibrate(uint32_t dev_instance,
83 struct adc_conv_slot *slot, int * calib_status);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070084
85int32_t pm8058_xoadc_registered(void);
86
87int32_t pm8058_xoadc_calib_device(uint32_t adc_instance);
Vijayakumar Muthuvel Manickam2d2a2c52011-10-20 13:41:39 -070088
89#else
90
91static inline int32_t pm8058_xoadc_read_adc_code(uint32_t adc_instance,
92 int32_t *data)
93{ return -ENXIO; }
94
95static inline int32_t pm8058_xoadc_select_chan_and_start_conv(
96 uint32_t adc_instance, struct adc_conv_slot *slot)
97{ return -ENXIO; }
98
99static inline void pm8058_xoadc_slot_request(uint32_t adc_instance,
100 struct adc_conv_slot **slot)
101{ return; }
102
103static inline void pm8058_xoadc_restore_slot(uint32_t adc_instance,
104 struct adc_conv_slot *slot)
105{ return; }
106
107static inline struct adc_properties *pm8058_xoadc_get_properties(
108 uint32_t dev_instance)
109{ return NULL; }
110
111static inline int32_t pm8058_xoadc_calibrate(uint32_t dev_instance,
112 struct adc_conv_slot *slot, int *calib_status)
113{ return -ENXIO; }
114
115static inline int32_t pm8058_xoadc_registered(void)
116{ return -ENXIO; }
117
118static inline int32_t pm8058_xoadc_calib_device(uint32_t adc_instance)
119{ return -ENXIO; }
120#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700121#endif