2 * include/linux/i2c/twl6030-gpadc.h
4 * TWL6030 GPADC module driver header
6 * Copyright (C) 2009 Texas Instruments Inc.
7 * Nishant Kamat <nskamat@ti.com>
9 * Based on twl4030-madc.h
10 * Copyright (C) 2008 Nokia Corporation
11 * Mikko Ylinen <mikko.k.ylinen@nokia.com>
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * version 2 as published by the Free Software Foundation.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
29 #ifndef _TWL6030_GPADC_H
30 #define _TWL6030_GPADC_H
32 struct twl6030_gpadc_conversion_method {
40 #define TWL6030_GPADC_MAX_CHANNELS 17
41 #define TWL6032_GPADC_MAX_CHANNELS 19
42 /* Define this as the biggest of all chips using this driver */
43 #define GPADC_MAX_CHANNELS TWL6032_GPADC_MAX_CHANNELS
46 * raw_code - raw adc value
47 * raw_channel_value - adc * channel gain
48 * code - calibrated adc value
50 struct twl6030_value {
52 int raw_channel_value;
56 struct twl6030_gpadc_request {
63 int rbuf[TWL6032_GPADC_MAX_CHANNELS];
64 void (*func_cb)(struct twl6030_gpadc_request *req);
65 struct twl6030_value buf[TWL6032_GPADC_MAX_CHANNELS];
68 enum conversion_methods {
71 TWL6030_GPADC_NUM_METHODS
76 TWL6030_GPADC_IRQ_ONESHOT,
77 TWL6030_GPADC_IRQ_REARM
80 #define TWL6030_GPADC_CTRL 0x00 /* 0x2e */
81 #define TWL6030_GPADC_CTRL2 0x01 /* 0x2f */
83 #define TWL6030_GPADC_RTSELECT_LSB 0x02 /* 0x30 */
84 #define TWL6030_GPADC_RTSELECT_ISB 0x03
85 #define TWL6030_GPADC_RTSELECT_MSB 0x04
87 #define TWL6032_GPADC_RTSELECT_LSB 0x04 /* 0x32 */
88 #define TWL6032_GPADC_RTSELECT_ISB 0x05
89 #define TWL6032_GPADC_RTSELECT_MSB 0x06
91 #define TWL6030_GPADC_CTRL_P1 0x05
92 #define TWL6030_GPADC_CTRL_P2 0x06
94 #define TWL6032_GPADC_GPSELECT_ISB 0x07
95 #define TWL6032_GPADC_CTRL_P1 0x08
97 #define TWL6032_RTCH0_LSB 0x09
98 #define TWL6032_RTCH0_MSB 0x0a
99 #define TWL6032_RTCH1_LSB 0x0b
100 #define TWL6032_RTCH1_MSB 0x0c
101 #define TWL6032_GPCH0_LSB 0x0d
102 #define TWL6032_GPCH0_MSB 0x0e
104 #define TWL6030_GPADC_CTRL_P1_SP1 (1 << 3)
105 #define TWL6030_GPADC_CTRL_P1_EOCRT (1 << 2)
106 #define TWL6030_GPADC_CTRL_P1_EOCP1 (1 << 1)
107 #define TWL6030_GPADC_CTRL_P1_BUSY (1 << 0)
109 #define TWL6030_GPADC_CTRL_P2_SP2 (1 << 2)
110 #define TWL6030_GPADC_CTRL_P2_EOCP2 (1 << 1)
111 #define TWL6030_GPADC_CTRL_P1_BUSY (1 << 0)
113 #define TWL6030_GPADC_EOC_SW (1 << 1)
114 #define TWL6030_GPADC_BUSY (1 << 0)
116 #define TWL6030_GPADC_RTCH0_LSB (0x07)
117 #define TWL6030_GPADC_GPCH0_LSB (0x29)
120 #define TWL6030_GPADC_CTRL_TEMP1_EN (1 << 0) /* input ch 1 */
121 #define TWL6030_GPADC_CTRL_TEMP2_EN (1 << 1) /* input ch 4 */
122 #define TWL6030_GPADC_CTRL_SCALER_EN (1 << 2) /* input ch 2 */
123 #define TWL6030_GPADC_CTRL_SCALER_DIV4 (1 << 3)
124 #define TWL6030_GPADC_CTRL_SCALER_EN_CH11 (1 << 4) /* input ch 11 */
125 #define TWL6030_GPADC_CTRL_TEMP1_EN_MONITOR (1 << 5)
126 #define TWL6030_GPADC_CTRL_TEMP2_EN_MONITOR (1 << 6)
127 #define TWL6030_GPADC_CTRL_ISOURCE_EN (1 << 7)
129 #define TWL6030_GPADC_CTRL2_REMSENSE_0 (1 << 0)
130 #define TWL6030_GPADC_CTRL2_REMSENSE_1 (1 << 1)
131 #define TWL6030_GPADC_CTRL2_SCALER_EN_CH18 (1 << 2)
132 #define TWL6030_GPADC_CTRL2_VBAT_SCALER_DIV4 (1 << 3)
134 #define TWL6030_GPADC_RT_SW1_EOC_MASK (1 << 5)
135 #define TWL6030_GPADC_SW2_EOC_MASK (1 << 6)
137 #define TWL6032_GPADC_RT_EOC_MASK (1 << 4)
138 #define TWL6032_GPADC_SW_EOC_MASK (1 << 5)
140 #define TWL6030_GPADC_IOC_MAGIC '`'
141 #define TWL6030_GPADC_IOCX_ADC_RAW_READ _IO(TWL6030_GPADC_IOC_MAGIC, 0)
142 #define TWL6030_GPADC_IOCX_ADC_READ _IO(TWL6030_GPADC_IOC_MAGIC+1, 0)
144 struct twl6030_gpadc_user_parms {
150 int twl6030_gpadc_conversion(struct twl6030_gpadc_request *conv);