2 * include/linux/i2c/twl4030-madc.h
4 * TWL4030 MADC module driver header
6 * Copyright (C) 2008 Nokia Corporation
7 * Mikko Ylinen <mikko.k.ylinen@nokia.com>
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.
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.
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
25 #ifndef _TWL4030_MADC_H
26 #define _TWL4030_MADC_H
28 struct twl4030_madc_conversion_method {
35 #define TWL4030_MADC_MAX_CHANNELS 16
37 struct twl4030_madc_request {
44 int rbuf[TWL4030_MADC_MAX_CHANNELS];
45 void (*func_cb)(int len, int channels, int *buf);
48 enum conversion_methods {
52 TWL4030_MADC_NUM_METHODS
57 TWL4030_MADC_IRQ_ONESHOT,
58 TWL4030_MADC_IRQ_REARM
61 #define TWL4030_MADC_CTRL1 0x00
62 #define TWL4030_MADC_CTRL2 0x01
64 #define TWL4030_MADC_RTSELECT_LSB 0x02
65 #define TWL4030_MADC_SW1SELECT_LSB 0x06
66 #define TWL4030_MADC_SW2SELECT_LSB 0x0A
68 #define TWL4030_MADC_RTAVERAGE_LSB 0x04
69 #define TWL4030_MADC_SW1AVERAGE_LSB 0x08
70 #define TWL4030_MADC_SW2AVERAGE_LSB 0x0C
72 #define TWL4030_MADC_CTRL_SW1 0x12
73 #define TWL4030_MADC_CTRL_SW2 0x13
75 #define TWL4030_MADC_RTCH0_LSB 0x17
76 #define TWL4030_MADC_GPCH0_LSB 0x37
78 #define TWL4030_MADC_ISR1 0x61
79 #define TWL4030_MADC_IMR1 0x62
80 #define TWL4030_MADC_ISR2 0x63
81 #define TWL4030_MADC_IMR2 0x64
82 #define TWL4030_MADC_SIR 0x65
83 #define TWL4030_MADC_EDR 0x66
84 #define TWL4030_MADC_SIH_CTRL 0x67
86 #define TWL4030_MADC_MADCON (1<<0) /* MADC power on */
87 #define TWL4030_MADC_BUSY (1<<0) /* MADC busy */
88 #define TWL4030_MADC_EOC_SW (1<<1) /* MADC conversion completion */
89 #define TWL4030_MADC_SW_START (1<<5) /* MADC SWx start conversion */
91 #define TWL4030_MADC_ADCIN0 (1<<0)
92 #define TWL4030_MADC_ADCIN1 (1<<1)
93 #define TWL4030_MADC_ADCIN2 (1<<2)
94 #define TWL4030_MADC_ADCIN3 (1<<3)
95 #define TWL4030_MADC_ADCIN4 (1<<4)
96 #define TWL4030_MADC_ADCIN5 (1<<5)
97 #define TWL4030_MADC_ADCIN6 (1<<6)
98 #define TWL4030_MADC_ADCIN7 (1<<7)
99 #define TWL4030_MADC_ADCIN8 (1<<8)
100 #define TWL4030_MADC_ADCIN9 (1<<9)
101 #define TWL4030_MADC_ADCIN10 (1<<10)
102 #define TWL4030_MADC_ADCIN11 (1<<11)
103 #define TWL4030_MADC_ADCIN12 (1<<12)
104 #define TWL4030_MADC_ADCIN13 (1<<13)
105 #define TWL4030_MADC_ADCIN14 (1<<14)
106 #define TWL4030_MADC_ADCIN15 (1<<15)
109 #define TWL4030_MADC_BTEMP TWL4030_MADC_ADCIN1
110 #define TWL4030_MADC_VBUS TWL4030_MADC_ADCIN8
111 #define TWL4030_MADC_VBKB TWL4030_MADC_ADCIN9
112 #define TWL4030_MADC_ICHG TWL4030_MADC_ADCIN10
113 #define TWL4030_MADC_VCHG TWL4030_MADC_ADCIN11
114 #define TWL4030_MADC_VBAT TWL4030_MADC_ADCIN12
116 /* BCI related - XXX To be moved elsewhere */
117 #define TWL4030_BCI_BCICTL1 0x23
118 #define TWL4030_BCI_MESBAT (1<<1)
119 #define TWL4030_BCI_TYPEN (1<<4)
120 #define TWL4030_BCI_ITHEN (1<<3)
122 #define TWL4030_MADC_IOC_MAGIC '`'
123 #define TWL4030_MADC_IOCX_ADC_RAW_READ _IO(TWL4030_MADC_IOC_MAGIC, 0)
125 struct twl4030_madc_user_parms {
132 int twl4030_madc_conversion(struct twl4030_madc_request *conv);