| Duy Truong | e833aca | 2013-02-12 13:35:08 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2010-2011, The Linux Foundation. All rights reserved. | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 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 Walker | 16e79b9f | 2011-12-02 18:08:23 -0800 | [diff] [blame] | 15 | #ifndef _PMIC8058_XOADC_H_ | 
|  | 16 | #define _PMIC8058_XOADC_H_ | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 17 |  | 
|  | 18 | #include <linux/kernel.h> | 
|  | 19 | #include <linux/list.h> | 
|  | 20 | #include <linux/workqueue.h> | 
|  | 21 |  | 
|  | 22 | struct 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 |  | 
|  | 56 | struct 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 Manickam | 2d2a2c5 | 2011-10-20 13:41:39 -0700 | [diff] [blame] | 68 | #ifdef CONFIG_PMIC8058_XOADC | 
|  | 69 | int32_t pm8058_xoadc_read_adc_code(uint32_t adc_instance, int32_t *data); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 70 |  | 
| Vijayakumar Muthuvel Manickam | 2d2a2c5 | 2011-10-20 13:41:39 -0700 | [diff] [blame] | 71 | int32_t pm8058_xoadc_select_chan_and_start_conv(uint32_t adc_instance, | 
|  | 72 | struct adc_conv_slot *slot); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 73 |  | 
| Vijayakumar Muthuvel Manickam | 2d2a2c5 | 2011-10-20 13:41:39 -0700 | [diff] [blame] | 74 | void pm8058_xoadc_slot_request(uint32_t adc_instance, | 
|  | 75 | struct adc_conv_slot **slot); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 76 |  | 
| Vijayakumar Muthuvel Manickam | 2d2a2c5 | 2011-10-20 13:41:39 -0700 | [diff] [blame] | 77 | void pm8058_xoadc_restore_slot(uint32_t adc_instance, | 
|  | 78 | struct adc_conv_slot *slot); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 79 |  | 
| Vijayakumar Muthuvel Manickam | 2d2a2c5 | 2011-10-20 13:41:39 -0700 | [diff] [blame] | 80 | struct adc_properties *pm8058_xoadc_get_properties(uint32_t dev_instance); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 81 |  | 
| Vijayakumar Muthuvel Manickam | 2d2a2c5 | 2011-10-20 13:41:39 -0700 | [diff] [blame] | 82 | int32_t pm8058_xoadc_calibrate(uint32_t dev_instance, | 
|  | 83 | struct adc_conv_slot *slot, int * calib_status); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 84 |  | 
|  | 85 | int32_t pm8058_xoadc_registered(void); | 
|  | 86 |  | 
|  | 87 | int32_t pm8058_xoadc_calib_device(uint32_t adc_instance); | 
| Vijayakumar Muthuvel Manickam | 2d2a2c5 | 2011-10-20 13:41:39 -0700 | [diff] [blame] | 88 |  | 
| Flemmard | 4813280 | 2014-02-28 23:11:56 +0100 | [diff] [blame] | 89 | #ifdef CONFIG_MACH_HTC | 
|  | 90 | int32_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 Manickam | 2d2a2c5 | 2011-10-20 13:41:39 -0700 | [diff] [blame] | 94 | #else | 
|  | 95 |  | 
|  | 96 | static inline int32_t pm8058_xoadc_read_adc_code(uint32_t adc_instance, | 
|  | 97 | int32_t *data) | 
|  | 98 | { return -ENXIO; } | 
|  | 99 |  | 
|  | 100 | static inline int32_t pm8058_xoadc_select_chan_and_start_conv( | 
|  | 101 | uint32_t adc_instance, struct adc_conv_slot *slot) | 
|  | 102 | { return -ENXIO; } | 
|  | 103 |  | 
|  | 104 | static inline void pm8058_xoadc_slot_request(uint32_t adc_instance, | 
|  | 105 | struct adc_conv_slot **slot) | 
|  | 106 | { return; } | 
|  | 107 |  | 
|  | 108 | static inline void pm8058_xoadc_restore_slot(uint32_t adc_instance, | 
|  | 109 | struct adc_conv_slot *slot) | 
|  | 110 | { return; } | 
|  | 111 |  | 
|  | 112 | static inline struct adc_properties *pm8058_xoadc_get_properties( | 
|  | 113 | uint32_t dev_instance) | 
|  | 114 | { return NULL; } | 
|  | 115 |  | 
|  | 116 | static inline int32_t pm8058_xoadc_calibrate(uint32_t dev_instance, | 
|  | 117 | struct adc_conv_slot *slot, int *calib_status) | 
|  | 118 | { return -ENXIO; } | 
|  | 119 |  | 
|  | 120 | static inline int32_t pm8058_xoadc_registered(void) | 
|  | 121 | { return -ENXIO; } | 
|  | 122 |  | 
|  | 123 | static inline int32_t pm8058_xoadc_calib_device(uint32_t adc_instance) | 
|  | 124 | { return -ENXIO; } | 
| Flemmard | 4813280 | 2014-02-28 23:11:56 +0100 | [diff] [blame] | 125 | #ifdef CONFIG_MACH_HTC | 
|  | 126 | static 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 Manickam | 2d2a2c5 | 2011-10-20 13:41:39 -0700 | [diff] [blame] | 131 | #endif | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 132 | #endif |