Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1 | /* 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 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 | |
| 89 | #else |
| 90 | |
| 91 | static inline int32_t pm8058_xoadc_read_adc_code(uint32_t adc_instance, |
| 92 | int32_t *data) |
| 93 | { return -ENXIO; } |
| 94 | |
| 95 | static inline int32_t pm8058_xoadc_select_chan_and_start_conv( |
| 96 | uint32_t adc_instance, struct adc_conv_slot *slot) |
| 97 | { return -ENXIO; } |
| 98 | |
| 99 | static inline void pm8058_xoadc_slot_request(uint32_t adc_instance, |
| 100 | struct adc_conv_slot **slot) |
| 101 | { return; } |
| 102 | |
| 103 | static inline void pm8058_xoadc_restore_slot(uint32_t adc_instance, |
| 104 | struct adc_conv_slot *slot) |
| 105 | { return; } |
| 106 | |
| 107 | static inline struct adc_properties *pm8058_xoadc_get_properties( |
| 108 | uint32_t dev_instance) |
| 109 | { return NULL; } |
| 110 | |
| 111 | static inline int32_t pm8058_xoadc_calibrate(uint32_t dev_instance, |
| 112 | struct adc_conv_slot *slot, int *calib_status) |
| 113 | { return -ENXIO; } |
| 114 | |
| 115 | static inline int32_t pm8058_xoadc_registered(void) |
| 116 | { return -ENXIO; } |
| 117 | |
| 118 | static inline int32_t pm8058_xoadc_calib_device(uint32_t adc_instance) |
| 119 | { return -ENXIO; } |
| 120 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 121 | #endif |