]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - include/linux/spi/tsc210x.h
Merge branch 'omap-fixes'
[linux-2.6-omap-h63xx.git] / include / linux / spi / tsc210x.h
1 /*
2  * include/linux/spi/tsc210x.h
3  *
4  * TI TSC2101/2102 control register definitions.
5  *
6  * Copyright (c) 2005-2007 Andrzej Zaborowski  <balrog@zabor.org>
7  *
8  * This package is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This package is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this package; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21  */
22
23 #ifndef __LINUX_SPI_TSC210X_H
24 #define __LINUX_SPI_TSC210X_H
25
26 struct apm_power_info;
27
28 struct tsc210x_config {
29         int use_internal;       /* Use internal reference voltage */
30         u32 monitor;            /* What inputs are wired on this board */
31         int temp_at25c[2];      /* Thermometer calibration data */
32         void (*apm_report)(struct apm_power_info *info, int battery[]);
33                                 /* Report status to APM based on battery[] */
34         void *alsa_config;      /* .platform_data for the ALSA device */
35         const char *mclk;       /* Optional: mclk name */
36         const char *bclk;       /* Optional: bclk name */
37 };
38
39 #define TSC_BAT1        (1 << 0)
40 #define TSC_BAT2        (1 << 1)
41 #define TSC_AUX1        (1 << 2)
42 #define TSC_AUX2        (1 << 3)
43 #define TSC_TEMP        (1 << 4)
44
45 #define TSC_AUX         TSC_AUX1
46 #define TSC_VBAT        TSC_BAT1
47
48 struct tsc210x_dev;
49
50 /* Drivers for tsc210x components like touchscreen, sensor, and audio
51  * are packaged as platform drivers which can issue synchronous register
52  * acceses, and may also register a callback to process their particular
53  * type of data when that data is automatically sampled.  The platform
54  * device is a child of the TSC spi device.
55  */
56
57 extern int tsc210x_read_sync(struct tsc210x_dev *dev, int page, u8 address);
58 extern int tsc210x_reads_sync(struct tsc210x_dev *dev, int page,
59                 u8 startaddress, u16 *data, int numregs);
60 extern int tsc210x_write_sync(struct tsc210x_dev *dev, int page,
61                 u8 address, u16 data);
62
63 typedef void (*tsc210x_touch_t)(void *context, int touching);
64 typedef void (*tsc210x_coords_t)(void *context, int x, int y, int z1, int z2);
65 typedef void (*tsc210x_ports_t)(void *context, int bat[], int aux[]);
66 typedef void (*tsc210x_temp_t)(void *context, int temp);
67
68 extern int tsc210x_touch_cb(struct device *dev,
69                 tsc210x_touch_t handler, void *context);
70 extern int tsc210x_coords_cb(struct device *dev,
71                 tsc210x_coords_t handler, void *context);
72 extern int tsc210x_ports_cb(struct device *dev,
73                 tsc210x_ports_t handler, void *context);
74 extern int tsc210x_temp1_cb(struct device *dev,
75                 tsc210x_temp_t handler, void *context);
76 extern int tsc210x_temp2_cb(struct device *dev,
77                 tsc210x_temp_t handler, void *context);
78
79 #if defined(CONFIG_SOUND) || defined(CONFIG_SOUND_MODULE)
80 extern void tsc210x_set_dac_volume(struct device *dev, u8 left, u8 right);
81 extern void tsc210x_set_dac_mute(struct device *dev, int left, int right);
82 extern void tsc210x_get_dac_mute(struct device *dev, int *left, int *right);
83 extern void tsc210x_dac_power(struct device *dev, int on);
84 extern int tsc210x_set_rate(struct device *dev, int rate);
85 extern void tsc210x_set_i2s_master(struct device *dev, int state);
86 extern void tsc210x_set_deemphasis(struct device *dev, int enable);
87 extern void tsc2102_set_bassboost(struct device *dev, int enable);
88 #endif
89
90 /*
91  * Emit a short keyclick typically in order to give feedback to
92  * user on specific events.
93  *
94  * amplitude must be between 0 (lowest) and 2 (highest).
95  * freq must be between 0 (corresponds to 62.5 Hz) and 7 (8 kHz).
96  * length should be between 2 and 32 periods.
97  *
98  * This function sleeps but for a period unrelated to the length of
99  * the sound, i.e. returning doesn't indicate that the sound has
100  * finished.
101  */
102 extern void tsc210x_keyclick(struct tsc210x_dev *dev,
103                 int amplitude, int freq, int length);
104
105 /* Page 0, Touch Screen & Keypad Data registers */
106 #define TSC210X_TS_X                    0, 0x00
107 #define TSC210X_TS_Y                    0, 0x01
108 #define TSC210X_TS_Z1                   0, 0x02
109 #define TSC210X_TS_Z2                   0, 0x03
110 #define TSC210X_TS_BAT1                 0, 0x05
111 #define TSC2102_TS_BAT2                 0, 0x06
112 #define TSC210X_TS_AUX1                 0, 0x07
113 #define TSC2101_TS_AUX2                 0, 0x08
114 #define TSC210X_TS_TEMP1                0, 0x09
115 #define TSC210X_TS_TEMP2                0, 0x0a
116
117 /* Page 1, Touch Screen & Keypad Control registers */
118 #define TSC210X_TS_ADC_CTRL             1, 0x00
119 #define TSC210X_TS_STATUS_CTRL          1, 0x01
120 #define TSC2101_TS_BUFFER_CTRL          1, 0x02
121 #define TSC210X_TS_REF_CTRL             1, 0x03
122 #define TSC210X_TS_RESET_CTRL           1, 0x04
123 #define TSC210X_TS_CONFIG_CTRL          1, 0x05
124 #define TSC2101_TS_TEMPMAX_CTRL         1, 0x06
125 #define TSC2101_TS_TEMPMIN_CTRL         1, 0x07
126 #define TSC2101_TS_AUX1MAX_CTRL         1, 0x08
127 #define TSC2101_TS_AUX1MIN_CTRL         1, 0x09
128 #define TSC2101_TS_AUX2MAX_CTRL         1, 0x0a
129 #define TSC2101_TS_AUX2MIN_CTRL         1, 0x0b
130 #define TSC2101_TS_MCONFIG_CTRL         1, 0x0c
131 #define TSC2101_TS_DELAY_CTRL           1, 0x0d
132
133 /* Page 2, Audio Control registers */
134 #define TSC210X_AUDIO1_CTRL             2, 0x00
135 #define TSC2101_HEADSET_GAIN_CTRL       2, 0x01
136 #define TSC210X_DAC_GAIN_CTRL           2, 0x02
137 #define TSC2101_MIXER_GAIN_CTRL         2, 0x03
138 #define TSC210X_AUDIO2_CTRL             2, 0x04
139 #define TSC210X_POWER_CTRL              2, 0x05
140 #define TSC210X_AUDIO3_CTRL             2, 0x06
141 #define TSC210X_LCH_BASS_BOOST_N0       2, 0x07
142 #define TSC210X_LCH_BASS_BOOST_N1       2, 0x08
143 #define TSC210X_LCH_BASS_BOOST_N2       2, 0x09
144 #define TSC210X_LCH_BASS_BOOST_N3       2, 0x0a
145 #define TSC210X_LCH_BASS_BOOST_N4       2, 0x0b
146 #define TSC210X_LCH_BASS_BOOST_N5       2, 0x0c
147 #define TSC210X_LCH_BASS_BOOST_D1       2, 0x0d
148 #define TSC210X_LCH_BASS_BOOST_D2       2, 0x0e
149 #define TSC210X_LCH_BASS_BOOST_D4       2, 0x0f
150 #define TSC210X_LCH_BASS_BOOST_D5       2, 0x10
151 #define TSC210X_RCH_BASS_BOOST_N0       2, 0x11
152 #define TSC210X_RCH_BASS_BOOST_N1       2, 0x12
153 #define TSC210X_RCH_BASS_BOOST_N2       2, 0x13
154 #define TSC210X_RCH_BASS_BOOST_N3       2, 0x14
155 #define TSC210X_RCH_BASS_BOOST_N4       2, 0x15
156 #define TSC210X_RCH_BASS_BOOST_N5       2, 0x16
157 #define TSC210X_RCH_BASS_BOOST_D1       2, 0x17
158 #define TSC210X_RCH_BASS_BOOST_D2       2, 0x18
159 #define TSC210X_RCH_BASS_BOOST_D4       2, 0x19
160 #define TSC210X_RCH_BASS_BOOST_D5       2, 0x1a
161 #define TSC210X_PLL1_CTRL               2, 0x1b
162 #define TSC210X_PLL2_CTRL               2, 0x1c
163 #define TSC210X_AUDIO4_CTRL             2, 0x1d
164 #define TSC2101_HANDSET_GAIN_CTRL       2, 0x1e
165 #define TSC2101_CELL_GAIN_CTRL          2, 0x1f
166 #define TSC2101_AUIDO5_CTRL             2, 0x20
167 #define TSC2101_AUDIO6_CTRL             2, 0x21
168 #define TSC2101_AUDIO7_CTRL             2, 0x22
169 #define TSC2101_GPIO_CTRL               2, 0x23
170 #define TSC2101_IN_AGC_CTRL             2, 0x24
171 #define TSC2101_POWER_STATUS            2, 0x25
172 #define TSC2101_MIX_AGC_CTRL            2, 0x26
173 #define TSC2101_CELL_AGC_CTRL           2, 0x27
174
175 /* Field masks for Audio Control 1 */
176 #define AC1_WLEN(ARG)                   (((ARG) & 0x03) << 10)
177 #define AC1_DATFM(ARG)                  (((ARG) & 0x03) << 8)
178 #define AC1_DACFS(ARG)                  ((ARG) & 0x3f)
179
180 /* Field masks for TSC2102_DAC_GAIN_CTRL */
181 #define DGC_DALMU                       (1 << 15)
182 #define DGC_DALVL(ARG)                  (((ARG) & 0x7f) << 8)
183 #define DGC_DARMU                       (1 << 7)
184 #define DGC_DARVL(ARG)                  (((ARG) & 0x7f))
185
186 /* Field formats for TSC210X_AUDIO2_CTRL */
187 #define AC2_KCLEN                       (1 << 15)
188 #define AC2_KCLAC(ARG)                  (((ARG) & 0x07) << 12)
189 #define AC2_KCLFRQ(ARG)                 (((ARG) & 0x07) << 8)
190 #define AC2_KCLLN(ARG)                  (((ARG) & 0x0f) << 4)
191 #define AC2_DLGAF                       (1 << 3)
192 #define AC2_DRGAF                       (1 << 2)
193 #define AC2_DASTC                       (1 << 1)
194
195 /* Field masks for TSC210X_DAC_POWER_CTRL */
196 #define CPC_PWDNC                       (1 << 15)
197 #define CPC_DAODRC                      (1 << 12)
198 #define CPC_DAPWDN                      (1 << 10)
199 #define CPC_VGPWDN                      (1 << 8)
200 #define CPC_DAPWDF                      (1 << 6)
201 #define CPC_BASSBC                      (1 << 1)
202 #define CPC_DEEMPF                      (0x01)
203
204 /* Field masks for TSC210X_AUDIO3_CTRL */
205 #define AC3_DMSVOL(ARG)                 (((ARG) & 0x03) << 14)
206 #define AC3_REFFS                       (1 << 13)
207 #define AC3_DAXFM                       (1 << 12)
208 #define AC3_SLVMS                       (1 << 11)
209 #define AC3_DALOVF                      (1 << 7)
210 #define AC3_DAROVF                      (1 << 6)
211 #define AC3_REVID(ARG)                  (((ARG) & 0x07))
212
213 /* Field masks for TSC210X_PLL1_CTRL */
214 #define PLL1_PLLEN                      (1 << 15)
215 #define PLL1_Q_VAL(ARG)                 (((ARG) & 0x0f) << 11)
216 #define PLL1_P_VAL(ARG)                 (((ARG) & 0x07) << 8)
217 #define PLL1_I_VAL(ARG)                 (((ARG) & 0x3f) << 2)
218
219 /* Field masks for TSC210X_PLL2_CTRL */
220 #define PLL2_D_VAL(ARG)                 (((ARG) & 0x3fff) << 2)
221
222 /* Field masks for TSC210X_AUDIO4_CTRL */
223 #define AC4_DASTPD                      (1 << 14)
224
225 struct tsc210x_rate_info_s {
226         u16 sample_rate;
227         u8 divisor;
228         u8 fs_44k;      /* 44.1 kHz Fsref if 1, 48 kHz if 0 */
229 };
230
231 #endif  /* __LINUX_SPI_TSC210X_H */