blob: 1404debbd056cc3622ec68515a77c5d7dec143bb [file] [log] [blame]
Duy Truonge833aca2013-02-12 13:35:08 -08001/* Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
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
Flemmard48132802014-02-28 23:11:56 +010089#ifdef CONFIG_MACH_HTC
90int32_t pm8058_htc_config_mpp_and_adc_read(int32_t *result,
91 int32_t size, int32_t channels,
92 uint32_t mpp, uint32_t amux);
93#endif
Vijayakumar Muthuvel Manickam2d2a2c52011-10-20 13:41:39 -070094#else
95
96static inline int32_t pm8058_xoadc_read_adc_code(uint32_t adc_instance,
97 int32_t *data)
98{ return -ENXIO; }
99
100static inline int32_t pm8058_xoadc_select_chan_and_start_conv(
101 uint32_t adc_instance, struct adc_conv_slot *slot)
102{ return -ENXIO; }
103
104static inline void pm8058_xoadc_slot_request(uint32_t adc_instance,
105 struct adc_conv_slot **slot)
106{ return; }
107
108static inline void pm8058_xoadc_restore_slot(uint32_t adc_instance,
109 struct adc_conv_slot *slot)
110{ return; }
111
112static inline struct adc_properties *pm8058_xoadc_get_properties(
113 uint32_t dev_instance)
114{ return NULL; }
115
116static inline int32_t pm8058_xoadc_calibrate(uint32_t dev_instance,
117 struct adc_conv_slot *slot, int *calib_status)
118{ return -ENXIO; }
119
120static inline int32_t pm8058_xoadc_registered(void)
121{ return -ENXIO; }
122
123static inline int32_t pm8058_xoadc_calib_device(uint32_t adc_instance)
124{ return -ENXIO; }
Flemmard48132802014-02-28 23:11:56 +0100125#ifdef CONFIG_MACH_HTC
126static inline int32_t pm8058_htc_config_mpp_and_adc_read(int32_t *result,
127 int32_t size, int32_t channels,
128 uint32_t mpp, uint32_t amux)
129{ return -ENXIO; }
130#endif
Vijayakumar Muthuvel Manickam2d2a2c52011-10-20 13:41:39 -0700131#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700132#endif