]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - include/linux/i2c/twl4030-madc.h
24523b507e5b7040071de8707df3f26161ea3216
[linux-2.6-omap-h63xx.git] / include / linux / i2c / twl4030-madc.h
1 /*
2  * include/linux/i2c/twl4030-madc.h
3  *
4  * TWL4030 MADC module driver header
5  *
6  * Copyright (C) 2008 Nokia Corporation
7  * Mikko Ylinen <mikko.k.ylinen@nokia.com>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * version 2 as published by the Free Software Foundation.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  */
24
25 #ifndef _TWL4030_MADC_H
26 #define _TWL4030_MADC_H
27
28 struct twl4030_madc_conversion_method {
29         u8 sel;
30         u8 avg;
31         u8 rbase;
32         u8 ctrl;
33 };
34
35 #define TWL4030_MADC_MAX_CHANNELS 16
36
37 struct twl4030_madc_request {
38         u16 channels;
39         u16 do_avg;
40         u16 method;
41         u16 type;
42         int active;
43         int result_pending;
44         int rbuf[TWL4030_MADC_MAX_CHANNELS];
45         void (*func_cb)(int len, int channels, int *buf);
46 };
47
48 enum conversion_methods {
49         TWL4030_MADC_RT,
50         TWL4030_MADC_SW1,
51         TWL4030_MADC_SW2,
52         TWL4030_MADC_NUM_METHODS
53 };
54
55 enum sample_type {
56         TWL4030_MADC_WAIT,
57         TWL4030_MADC_IRQ_ONESHOT,
58         TWL4030_MADC_IRQ_REARM
59 };
60
61 #define TWL4030_MADC_CTRL1              0x00
62 #define TWL4030_MADC_CTRL2              0x01
63
64 #define TWL4030_MADC_RTSELECT_LSB       0x02
65 #define TWL4030_MADC_SW1SELECT_LSB      0x06
66 #define TWL4030_MADC_SW2SELECT_LSB      0x0A
67
68 #define TWL4030_MADC_RTAVERAGE_LSB      0x04
69 #define TWL4030_MADC_SW1AVERAGE_LSB     0x08
70 #define TWL4030_MADC_SW2AVERAGE_LSB     0x0C
71
72 #define TWL4030_MADC_CTRL_SW1           0x12
73 #define TWL4030_MADC_CTRL_SW2           0x13
74
75 #define TWL4030_MADC_RTCH0_LSB          0x17
76 #define TWL4030_MADC_GPCH0_LSB          0x37
77
78 #define TWL4030_MADC_MADCON             (1<<0)  /* MADC power on */
79 #define TWL4030_MADC_BUSY               (1<<0)  /* MADC busy */
80 #define TWL4030_MADC_EOC_SW             (1<<1)  /* MADC conversion completion */
81 #define TWL4030_MADC_SW_START           (1<<5)  /* MADC SWx start conversion */
82
83 #define TWL4030_MADC_ADCIN0             (1<<0)
84 #define TWL4030_MADC_ADCIN1             (1<<1)
85 #define TWL4030_MADC_ADCIN2             (1<<2)
86 #define TWL4030_MADC_ADCIN3             (1<<3)
87 #define TWL4030_MADC_ADCIN4             (1<<4)
88 #define TWL4030_MADC_ADCIN5             (1<<5)
89 #define TWL4030_MADC_ADCIN6             (1<<6)
90 #define TWL4030_MADC_ADCIN7             (1<<7)
91 #define TWL4030_MADC_ADCIN8             (1<<8)
92 #define TWL4030_MADC_ADCIN9             (1<<9)
93 #define TWL4030_MADC_ADCIN10            (1<<10)
94 #define TWL4030_MADC_ADCIN11            (1<<11)
95 #define TWL4030_MADC_ADCIN12            (1<<12)
96 #define TWL4030_MADC_ADCIN13            (1<<13)
97 #define TWL4030_MADC_ADCIN14            (1<<14)
98 #define TWL4030_MADC_ADCIN15            (1<<15)
99
100 /* Fixed channels */
101 #define TWL4030_MADC_BTEMP              TWL4030_MADC_ADCIN1
102 #define TWL4030_MADC_VBUS               TWL4030_MADC_ADCIN8
103 #define TWL4030_MADC_VBKB               TWL4030_MADC_ADCIN9
104 #define TWL4030_MADC_ICHG               TWL4030_MADC_ADCIN10
105 #define TWL4030_MADC_VCHG               TWL4030_MADC_ADCIN11
106 #define TWL4030_MADC_VBAT               TWL4030_MADC_ADCIN12
107
108 /* BCI related - XXX To be moved elsewhere */
109 #define TWL4030_BCI_BCICTL1             0x23
110 #define TWL4030_BCI_MESBAT              (1<<1)
111 #define TWL4030_BCI_TYPEN               (1<<4)
112 #define TWL4030_BCI_ITHEN               (1<<3)
113
114 #define TWL4030_MADC_IOC_MAGIC '`'
115 #define TWL4030_MADC_IOCX_ADC_RAW_READ          _IO(TWL4030_MADC_IOC_MAGIC, 0)
116
117 struct twl4030_madc_user_parms {
118         int channel;
119         int average;
120         int status;
121         u16 result;
122 };
123
124 int twl4030_madc_conversion(struct twl4030_madc_request *conv);
125
126 #endif