Merge current mainline tree into linux-omap tree
[pandora-kernel.git] / include / linux / spi / tsc2102.h
1 /*
2  * include/linux/spi/tsc2102.h
3  *
4  * TI TSC2102 Touchscreen, Audio and Battery control register definitions 
5  *
6  * Copyright (c) 2005 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_TSC2102_H
24 #define __LINUX_SPI_TSC2102_H
25
26 struct apm_power_info;
27 struct tsc2102_config {
28         int use_internal;       /* Use internal reference voltage */
29         uint32_t monitor;       /* What inputs are relevant */
30         int temp_at25c[2];      /* Thermometer calibration data */
31         void (*apm_report)(struct apm_power_info *info, int *battery);
32                                 /* Report status to APM based on battery[] */
33         void *alsa_config;      /* .platform_data for the ALSA device */
34 };
35
36 #define TSC_BAT1        (1 << 0)
37 #define TSC_BAT2        (1 << 1)
38 #define TSC_AUX         (1 << 2)
39 #define TSC_TEMP        (1 << 4)
40
41 extern u16 tsc2102_read_sync(int page, u8 address);
42 extern void tsc2102_reads_sync(int page, u8 startaddress, u16 *data,
43                 int numregs);
44 extern void tsc2102_write_sync(int page, u8 address, u16 data);
45
46 typedef void (*tsc2102_touch_t)(int touching);
47 typedef void (*tsc2102_coords_t)(int x, int y, int z1, int z2);
48 typedef void (*tsc2102_ports_t)(int bat1, int bat2, int aux);
49 typedef void (*tsc2102_temp_t)(int temp);
50 extern int tsc2102_touch_cb(tsc2102_touch_t handler);
51 extern int tsc2102_coords_cb(tsc2102_coords_t handler);
52 extern int tsc2102_ports_cb(tsc2102_ports_t handler);
53 extern int tsc2102_temp1_cb(tsc2102_temp_t handler);
54 extern int tsc2102_temp2_cb(tsc2102_temp_t handler);
55
56 #if defined(CONFIG_SND_OMAP_TSC2102) || defined(CONFIG_SND_OMAP_TSC2102_MODULE)
57 extern void tsc2102_set_volume(uint8_t left_ch, uint8_t right_ch);
58 extern void tsc2102_set_mute(int left_ch, int right_ch);
59 extern void tsc2102_get_mute(int *left_ch, int *right_ch);
60 extern void tsc2102_dac_power(int state);
61 extern int tsc2102_set_rate(int rate);
62 extern void tsc2102_set_i2s_master(int state);
63 extern void tsc2102_set_deemphasis(int enable);
64 extern void tsc2102_set_bassboost(int enable);
65 #endif
66
67 extern void tsc2102_keyclick(int amplitude, int freq, int length);
68
69 #define TSC2102_REG(pg, addr)           pg, addr
70
71 /* Page 0, Touch Screen & Keypad Data registers */
72 #define TSC2102_TS_X                    TSC2102_REG(0, 0x00)
73 #define TSC2102_TS_Y                    TSC2102_REG(0, 0x01)
74 #define TSC2102_TS_Z1                   TSC2102_REG(0, 0x02)
75 #define TSC2102_TS_Z2                   TSC2102_REG(0, 0x03)
76 #define TSC2102_TS_BAT1                 TSC2102_REG(0, 0x05)
77 #define TSC2102_TS_BAT2                 TSC2102_REG(0, 0x06)
78 #define TSC2102_TS_AUX                  TSC2102_REG(0, 0x07)
79 #define TSC2102_TS_TEMP1                TSC2102_REG(0, 0x09)
80 #define TSC2102_TS_TEMP2                TSC2102_REG(0, 0x0a)
81
82 /* Page 1, Touch Screen & Keypad Control registers */
83 #define TSC2102_TS_ADC_CTRL             TSC2102_REG(1, 0x00)
84 #define TSC2102_TS_STATUS_CTRL          TSC2102_REG(1, 0x01)
85 #define TSC2102_TS_REF_CTRL             TSC2102_REG(1, 0x03)
86 #define TSC2102_TS_RESET_CTRL           TSC2102_REG(1, 0x04)
87 #define TSC2102_TS_CONFIG_CTRL          TSC2102_REG(1, 0x05)
88
89 /* Page 2, Audio Control registers */
90 #define TSC2102_AUDIO1_CTRL             TSC2102_REG(2, 0x00)
91 #define TSC2102_DAC_GAIN_CTRL           TSC2102_REG(2, 0x02)
92 #define TSC2102_AUDIO2_CTRL             TSC2102_REG(2, 0x04)
93 #define TSC2102_DAC_POWER_CTRL          TSC2102_REG(2, 0x05)
94 #define TSC2102_AUDIO3_CTRL             TSC2102_REG(2, 0x06)
95 #define TSC2102_LCH_BASS_BOOST_N0       TSC2102_REG(2, 0x07)
96 #define TSC2102_LCH_BASS_BOOST_N1       TSC2102_REG(2, 0x08)
97 #define TSC2102_LCH_BASS_BOOST_N2       TSC2102_REG(2, 0x09)
98 #define TSC2102_LCH_BASS_BOOST_N3       TSC2102_REG(2, 0x0a)
99 #define TSC2102_LCH_BASS_BOOST_N4       TSC2102_REG(2, 0x0b)
100 #define TSC2102_LCH_BASS_BOOST_N5       TSC2102_REG(2, 0x0c)
101 #define TSC2102_LCH_BASS_BOOST_D1       TSC2102_REG(2, 0x0d)
102 #define TSC2102_LCH_BASS_BOOST_D2       TSC2102_REG(2, 0x0e)
103 #define TSC2102_LCH_BASS_BOOST_D4       TSC2102_REG(2, 0x0f)
104 #define TSC2102_LCH_BASS_BOOST_D5       TSC2102_REG(2, 0x10)
105 #define TSC2102_RCH_BASS_BOOST_N0       TSC2102_REG(2, 0x11)
106 #define TSC2102_RCH_BASS_BOOST_N1       TSC2102_REG(2, 0x12)
107 #define TSC2102_RCH_BASS_BOOST_N2       TSC2102_REG(2, 0x13)
108 #define TSC2102_RCH_BASS_BOOST_N3       TSC2102_REG(2, 0x14)
109 #define TSC2102_RCH_BASS_BOOST_N4       TSC2102_REG(2, 0x15)
110 #define TSC2102_RCH_BASS_BOOST_N5       TSC2102_REG(2, 0x16)
111 #define TSC2102_RCH_BASS_BOOST_D1       TSC2102_REG(2, 0x17)
112 #define TSC2102_RCH_BASS_BOOST_D2       TSC2102_REG(2, 0x18)
113 #define TSC2102_RCH_BASS_BOOST_D4       TSC2102_REG(2, 0x19)
114 #define TSC2102_RCH_BASS_BOOST_D5       TSC2102_REG(2, 0x1a)
115 #define TSC2102_PLL1_CTRL               TSC2102_REG(2, 0x1b)
116 #define TSC2102_PLL2_CTRL               TSC2102_REG(2, 0x1c)
117 #define TSC2102_AUDIO4_CTRL             TSC2102_REG(2, 0x1d)
118
119 /* Field masks for Audio Control 1 */
120 #define AC1_WLEN(ARG)                   (((ARG) & 0x03) << 10)
121 #define AC1_DATFM(ARG)                  (((ARG) & 0x03) << 8)
122 #define AC1_DACFS(ARG)                  ((ARG) & 0x3f)
123
124 /* Field masks for TSC2102_DAC_GAIN_CTRL */
125 #define DGC_DALMU                       (1 << 15)
126 #define DGC_DALVL(ARG)                  (((ARG) & 0x7f) << 8)
127 #define DGC_DARMU                       (1 << 7)
128 #define DGC_DARVL(ARG)                  (((ARG) & 0x7f))
129
130 /* Field formats for TSC2102_AUDIO2_CTRL */
131 #define AC2_KCLEN                       (1 << 15)
132 #define AC2_KCLAC(ARG)                  (((ARG) & 0x07) << 12)
133 #define AC2_KCLFRQ(ARG)                 (((ARG) & 0x07) << 8)
134 #define AC2_KCLLN(ARG)                  (((ARG) & 0x0f) << 4)
135 #define AC2_DLGAF                       (1 << 3)
136 #define AC2_DRGAF                       (1 << 2)
137 #define AC2_DASTC                       (1 << 1)
138
139 /* Field masks for TSC2102_DAC_POWER_CTRL */
140 #define CPC_PWDNC                       (1 << 15)
141 #define CPC_DAODRC                      (1 << 12)
142 #define CPC_DAPWDN                      (1 << 10)
143 #define CPC_VGPWDN                      (1 << 8)
144 #define CPC_DAPWDF                      (1 << 6)
145 #define CPC_BASSBC                      (1 << 1)
146 #define CPC_DEEMPF                      (0x01)
147
148 /* Field masks for TSC2101_AUDIO_CTRL_3 */
149 #define AC3_DMSVOL(ARG)                 (((ARG) & 0x03) << 14)
150 #define AC3_REFFS                       (1 << 13)
151 #define AC3_DAXFM                       (1 << 12)
152 #define AC3_SLVMS                       (1 << 11)
153 #define AC3_DALOVF                      (1 << 7)
154 #define AC3_DAROVF                      (1 << 6)
155 #define AC3_REVID(ARG)                  (((ARG) & 0x07))
156
157 /* Field masks for TSC2102_PLL1_CTRL */
158 #define PLL1_PLLEN                      (1 << 15)
159 #define PLL1_Q_VAL(ARG)                 (((ARG) & 0x0f) << 11)
160 #define PLL1_P_VAL(ARG)                 (((ARG) & 0x07) << 8)
161 #define PLL1_I_VAL(ARG)                 (((ARG) & 0x3f) << 2)
162
163 /* Field masks for TSC2102_PLL2_CTRL */
164 #define PLL2_D_VAL(ARG)                 (((ARG) & 0x3fff) << 2)
165
166 /* Field masks for TSC2101_AUDIO_CTRL_4 */
167 #define AC4_DASTPD                      (1 << 14)
168
169 struct tsc2102_rate_info_s {
170         u16 sample_rate;
171         u8 divisor;
172         u8 fs_44k;      /* 44.1 kHz Fsref if 1, 48 kHz if 0 */
173 };
174
175 #endif  /* __LINUX_SPI_TSC2102_H */