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_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 */
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)
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
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)
114 #define TWL4030_MADC_IOC_MAGIC '`'
115 #define TWL4030_MADC_IOCX_ADC_RAW_READ _IO(TWL4030_MADC_IOC_MAGIC, 0)
117 struct twl4030_madc_user_parms {
124 int twl4030_madc_conversion(struct twl4030_madc_request *conv);