diff options
Diffstat (limited to 'arch/arm/mach-tegra/board-touch-raydium_spi.c')
-rw-r--r-- | arch/arm/mach-tegra/board-touch-raydium_spi.c | 243 |
1 files changed, 243 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/board-touch-raydium_spi.c b/arch/arm/mach-tegra/board-touch-raydium_spi.c new file mode 100644 index 00000000000..9f5843a0e62 --- /dev/null +++ b/arch/arm/mach-tegra/board-touch-raydium_spi.c | |||
@@ -0,0 +1,243 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-tegra/board-touch-raydium_spi.c | ||
3 | * | ||
4 | * Copyright (c) 2011, NVIDIA Corporation. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
14 | * more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
19 | */ | ||
20 | |||
21 | #include <linux/errno.h> | ||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/spi/spi.h> | ||
24 | #include <linux/delay.h> | ||
25 | #include <linux/gpio.h> | ||
26 | #include <linux/spi/rm31080a_ts.h> | ||
27 | |||
28 | /* Raydium touchscreen Driver data */ | ||
29 | /*-----------------------------------------------------*/ | ||
30 | static const u8 rm31080_config_cardhu[] = { | ||
31 | 0x00, 0x00, 0x00, 0x00, 0x30, 0x1e, 0x20, 0x0f, | ||
32 | 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x08, | ||
33 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
34 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
35 | 0x10, 0x10, 0x06, 0x06, 0x04, 0x01, 0x02, 0x00, | ||
36 | 0x00, 0x0a, 0x00, 0xd5, 0x2b, 0x00, 0x00, 0x09, | ||
37 | 0x2c, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
38 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
39 | 0x28, 0xf8, 0x50, 0xce, 0x0a, 0x0c, 0x00, 0x00, | ||
40 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
41 | 0x16, 0x1b, 0x14, 0x16, 0x16, 0x18, 0x32, 0x19, | ||
42 | 0x1d, 0x08, 0x30, 0x19, 0x10, 0xf6, 0xe2, 0x08, | ||
43 | 0x28, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, | ||
44 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
45 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
46 | 0x00, 0x21, 0x00, 0x00, 0x21, 0x00, 0x00, 0x21, | ||
47 | 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
48 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x80, | ||
49 | 0x00, 0xc0, 0x00, 0xc2, 0x00, 0xf0, 0xed, 0x02, | ||
50 | 0xed, 0x02, 0x00, 0x90, 0x0a, 0x06, 0x80, 0x02, | ||
51 | 0x00, 0x04, 0x00, 0x20, 0x03, 0x02, 0x08, 0x03, | ||
52 | 0x10, 0x20, 0x20, 0x40, 0x10, 0x00, 0x00, 0x00, | ||
53 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
54 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
55 | 0x10, 0x10, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, | ||
56 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
57 | 0x50, 0x80, 0x02, 0x02, 0x02, 0x00, 0x00, 0x33, | ||
58 | 0x32, 0x00, 0x01, 0x4c, 0xfa, 0x00, 0x00, 0x43, | ||
59 | 0x3c, 0x00, 0x01, 0x38, 0xe6, 0x00, 0x00, 0x26, | ||
60 | 0x19, 0x00, 0x02, 0x66, 0x19, 0x00, 0x02, 0x50, | ||
61 | 0x64, 0x00, 0x00, 0x36, 0x4a, 0x00, 0x00, 0x0c, | ||
62 | 0x19, 0x00, 0x02, 0x64, 0x96, 0xab, 0x88, 0x78, | ||
63 | 0x88, 0x78, 0x04, 0x0f, 0x38, 0xff, 0x02, 0x04, | ||
64 | 0x80, 0xe0, 0x13, 0x01, 0x00, 0x44, 0x61, 0x12, | ||
65 | 0x41, 0x00, 0x00, 0x00, 0x00, 0x97, 0x01, 0x0c, | ||
66 | 0x44, 0x61, 0x12, 0x29, 0x29, 0x41, 0x00, 0x00, | ||
67 | 0x97, 0x06, 0x0c, 0x12, 0x41, 0x44, 0x52, 0x52, | ||
68 | 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
69 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
70 | 0x00, 0x00, 0x80, 0x80, 0x01, 0x80, 0x01, 0x80, | ||
71 | 0x22, 0x33, 0x22, 0x33, 0x66, 0x20, 0xff, 0xc9, | ||
72 | 0x19, 0xd0, 0xd0, 0x44, 0x00, 0x10, 0x00, 0x80, | ||
73 | 0x05, 0x44, 0xff, 0x00, 0x00, 0x10, 0x50, 0x00, | ||
74 | 0x00, 0x00, 0x30, 0x00, 0x00, 0x18, 0x18, 0x0f, | ||
75 | 0x0f, 0xf0, 0xf0, 0x00, 0x00, 0x10, 0x10, 0x00, | ||
76 | 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, | ||
77 | 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
78 | 0x00, 0x00, 0x00, 0x10, 0x01, 0x10, 0x01, 0x02, | ||
79 | }; | ||
80 | |||
81 | /* Wintek 7" MB (01.18.10.01.10) */ | ||
82 | static const u8 rm31080_config_kai_mainboard[] = { | ||
83 | 0x00, 0x00, 0x00, 0x00, 0x1e, 0x12, 0x20, 0x0f, | ||
84 | 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x07, | ||
85 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
86 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
87 | 0x19, 0x19, 0x06, 0x06, 0x04, 0x10, 0x02, 0x00, | ||
88 | 0x00, 0x0a, 0x00, 0xd5, 0x2b, 0x00, 0x00, 0x09, | ||
89 | 0x2c, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
90 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
91 | 0x28, 0xec, 0x5f, 0xce, 0x14, 0x0a, 0x00, 0x00, | ||
92 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
93 | 0x14, 0x19, 0x14, 0x19, 0x10, 0x10, 0x32, 0x12, | ||
94 | 0x1d, 0x08, 0x20, 0x19, 0x10, 0xf6, 0xe2, 0x08, | ||
95 | 0x1c, 0x04, 0x04, 0x20, 0x0f, 0x1c, 0x00, 0x00, | ||
96 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
97 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
98 | 0x00, 0x28, 0x00, 0x10, 0x22, 0x00, 0x00, 0x21, | ||
99 | 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
100 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x60, | ||
101 | 0x00, 0xa8, 0x00, 0xa8, 0x00, 0xd0, 0xed, 0x02, | ||
102 | 0xed, 0x02, 0x00, 0x90, 0x0a, 0x06, 0x20, 0x02, | ||
103 | 0x70, 0x03, 0x20, 0x1b, 0x03, 0x02, 0x08, 0x03, | ||
104 | 0x10, 0x20, 0x20, 0x40, 0x10, 0x00, 0x00, 0x00, | ||
105 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
106 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
107 | 0x20, 0x20, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, | ||
108 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
109 | 0x50, 0x80, 0x02, 0x02, 0x02, 0x00, 0x00, 0x33, | ||
110 | 0x32, 0x00, 0x01, 0x60, 0xfa, 0x00, 0x00, 0x43, | ||
111 | 0x3c, 0x00, 0x01, 0x4c, 0xe6, 0x00, 0x00, 0x26, | ||
112 | 0x19, 0x00, 0x02, 0x7a, 0x19, 0x00, 0x02, 0x50, | ||
113 | 0x64, 0x00, 0x00, 0x36, 0x4a, 0x00, 0x00, 0x0c, | ||
114 | 0x19, 0x00, 0x02, 0x64, 0x96, 0xab, 0x88, 0x78, | ||
115 | 0x88, 0x78, 0x04, 0x0f, 0x38, 0xff, 0x02, 0x04, | ||
116 | 0x80, 0xe0, 0x13, 0x02, 0x00, 0x2c, 0x1b, 0x4b, | ||
117 | 0x2e, 0x00, 0x00, 0x00, 0x00, 0x97, 0x06, 0x0c, | ||
118 | 0x2c, 0x1b, 0x2e, 0x3c, 0x3c, 0x4b, 0x00, 0x00, | ||
119 | 0x97, 0x06, 0x0c, 0x12, 0x41, 0x44, 0x52, 0x52, | ||
120 | 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
121 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
122 | 0x00, 0x00, 0x80, 0x80, 0x01, 0x80, 0x01, 0x80, | ||
123 | 0x21, 0x33, 0x21, 0x33, 0x66, 0x20, 0xff, 0xc9, | ||
124 | 0x19, 0xd0, 0xd0, 0x44, 0x00, 0x10, 0x00, 0x80, | ||
125 | 0x05, 0x44, 0xff, 0x00, 0x00, 0x10, 0x50, 0x00, | ||
126 | 0x00, 0x00, 0x30, 0x00, 0x00, 0x18, 0x18, 0x0f, | ||
127 | 0x0f, 0xf0, 0xf0, 0x00, 0x00, 0x10, 0x10, 0x00, | ||
128 | 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, | ||
129 | 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
130 | 0x00, 0x00, 0x00, 0x10, 0x01, 0x10, 0x01, 0x02, | ||
131 | }; | ||
132 | |||
133 | /* Wintek 7" PCB (01.18.10.01.10), TS IC is on the mainboard */ | ||
134 | static const u8 rm31080_config_kai_pcb[] = { | ||
135 | 0x00, 0x00, 0x00, 0x00, 0x1e, 0x12, 0x20, 0x0f, | ||
136 | 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x07, | ||
137 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
138 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
139 | 0x19, 0x19, 0x06, 0x06, 0x04, 0x10, 0x02, 0x00, | ||
140 | 0x00, 0x0a, 0x00, 0xd5, 0x2b, 0x00, 0x00, 0x09, | ||
141 | 0x2c, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
142 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
143 | 0x28, 0xec, 0x5f, 0xce, 0x14, 0x0a, 0x00, 0x00, | ||
144 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
145 | 0x14, 0x19, 0x14, 0x19, 0x10, 0x10, 0x32, 0x12, | ||
146 | 0x1d, 0x08, 0x20, 0x19, 0x10, 0xf6, 0xe2, 0x08, | ||
147 | 0x1c, 0x04, 0x04, 0x20, 0x0f, 0x1c, 0x00, 0x00, | ||
148 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
149 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
150 | 0x00, 0x28, 0x00, 0x10, 0x22, 0x00, 0x00, 0x21, | ||
151 | 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
152 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x60, | ||
153 | 0x00, 0xa8, 0x00, 0xa8, 0x00, 0xd0, 0xed, 0x02, | ||
154 | 0xed, 0x02, 0x00, 0x90, 0x0a, 0x06, 0x20, 0x02, | ||
155 | 0x70, 0x03, 0x20, 0x1b, 0x03, 0x02, 0x08, 0x03, | ||
156 | 0x10, 0x20, 0x20, 0x40, 0x10, 0x00, 0x00, 0x00, | ||
157 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
158 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
159 | 0x20, 0x20, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, | ||
160 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
161 | 0x50, 0x80, 0x02, 0x02, 0x02, 0x00, 0x00, 0x33, | ||
162 | 0x32, 0x00, 0x01, 0x60, 0xfa, 0x00, 0x00, 0x43, | ||
163 | 0x3c, 0x00, 0x01, 0x4c, 0xe6, 0x00, 0x00, 0x26, | ||
164 | 0x19, 0x00, 0x02, 0x7a, 0x19, 0x00, 0x02, 0x50, | ||
165 | 0x64, 0x00, 0x00, 0x36, 0x4a, 0x00, 0x00, 0x0c, | ||
166 | 0x19, 0x00, 0x02, 0x64, 0x96, 0xab, 0x88, 0x78, | ||
167 | 0x88, 0x78, 0x04, 0x0f, 0x38, 0xff, 0x02, 0x04, | ||
168 | 0x80, 0xe0, 0x13, 0x02, 0x00, 0x28, 0x17, 0x4b, | ||
169 | 0x2e, 0x00, 0x00, 0x00, 0x00, 0x97, 0x06, 0x0c, | ||
170 | 0x28, 0x17, 0x2e, 0x3c, 0x3c, 0x4b, 0x00, 0x00, | ||
171 | 0x97, 0x06, 0x0c, 0x12, 0x41, 0x44, 0x52, 0x52, | ||
172 | 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
173 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
174 | 0x00, 0x00, 0x80, 0x80, 0x01, 0x80, 0x01, 0x80, | ||
175 | 0x21, 0x33, 0x21, 0x33, 0x66, 0x20, 0xff, 0xc9, | ||
176 | 0x19, 0xd0, 0xd0, 0x44, 0x00, 0x10, 0x00, 0x80, | ||
177 | 0x05, 0x44, 0xff, 0x00, 0x00, 0x10, 0x50, 0x00, | ||
178 | 0x00, 0x00, 0x30, 0x00, 0x00, 0x18, 0x18, 0x0f, | ||
179 | 0x0f, 0xf0, 0xf0, 0x00, 0x00, 0x10, 0x10, 0x00, | ||
180 | 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, | ||
181 | 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
182 | 0x00, 0x00, 0x00, 0x10, 0x01, 0x10, 0x01, 0x02, | ||
183 | }; | ||
184 | |||
185 | struct rm_spi_ts_platform_data rm31080ts_data = { | ||
186 | .gpio_reset = 0, | ||
187 | .config = 0, | ||
188 | }; | ||
189 | |||
190 | struct spi_board_info rm31080a_spi_board[1] = { | ||
191 | { | ||
192 | .modalias = "rm_ts_spidev", | ||
193 | .bus_num = 0, | ||
194 | .chip_select = 0, | ||
195 | .max_speed_hz = 13 * 1000 * 1000, | ||
196 | .mode = SPI_MODE_0, | ||
197 | .platform_data = &rm31080ts_data, | ||
198 | }, | ||
199 | }; | ||
200 | |||
201 | int __init touch_init_raydium(int irq_gpio, int reset_gpio, int platform) | ||
202 | { | ||
203 | int err = 0; | ||
204 | tegra_gpio_enable(irq_gpio); | ||
205 | gpio_request(irq_gpio, "raydium-irq"); | ||
206 | gpio_direction_input(irq_gpio); | ||
207 | |||
208 | tegra_gpio_enable(reset_gpio); | ||
209 | gpio_request(reset_gpio, "raydium-reset"); | ||
210 | gpio_direction_output(reset_gpio, 0); | ||
211 | |||
212 | rm31080ts_data.gpio_reset = reset_gpio; | ||
213 | |||
214 | msleep(1); | ||
215 | gpio_set_value(reset_gpio, 1); | ||
216 | msleep(100); | ||
217 | |||
218 | rm31080a_spi_board[0].irq = TEGRA_GPIO_TO_IRQ(irq_gpio); | ||
219 | |||
220 | switch (platform) { | ||
221 | case 0: | ||
222 | pr_info("Raydium Kai PCB based touch init\n"); | ||
223 | rm31080ts_data.config = rm31080_config_kai_pcb; | ||
224 | break; | ||
225 | case 1: | ||
226 | pr_info("Raydium Kai On-Board touch init\n"); | ||
227 | rm31080ts_data.config = rm31080_config_kai_mainboard; | ||
228 | break; | ||
229 | case 2: | ||
230 | pr_info("Raydium cardhu touch init\n"); | ||
231 | rm31080ts_data.config = rm31080_config_cardhu; | ||
232 | break; | ||
233 | default: | ||
234 | pr_err("touch_id error, no touch\n"); | ||
235 | err = -ENODEV; | ||
236 | } | ||
237 | |||
238 | if(!err) | ||
239 | spi_register_board_info(rm31080a_spi_board, | ||
240 | ARRAY_SIZE(rm31080a_spi_board)); | ||
241 | |||
242 | return err; | ||
243 | } | ||