blob: 894960920ee1ab61e1c15975234bfe9ce95c9689 [file] [log] [blame]
Syed Rameez Mustafa3971c142013-01-09 19:04:53 -08001/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
Hanumant Singh55a1bb02012-11-06 10:01:15 -08002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13
14#include <linux/init.h>
15#include <linux/ioport.h>
16#include <mach/board.h>
17#include <mach/gpio.h>
18#include <mach/gpiomux.h>
19
Gilad Avidova460c472013-04-12 16:23:32 -060020static struct gpiomux_setting gpio_spi_config = {
21 .func = GPIOMUX_FUNC_1,
22 .drv = GPIOMUX_DRV_6MA,
23 .pull = GPIOMUX_PULL_NONE,
24};
25
Gilad Avidovf84f2792013-01-31 13:26:39 -070026static struct gpiomux_setting gpio_i2c_config = {
27 .func = GPIOMUX_FUNC_3,
28 .drv = GPIOMUX_DRV_2MA,
29 .pull = GPIOMUX_PULL_NONE,
30};
31
Kenneth Heitke0d4fbb12013-04-10 12:51:14 -060032static struct gpiomux_setting gpio_cam_i2c_config = {
33 .func = GPIOMUX_FUNC_1,
34 .drv = GPIOMUX_DRV_2MA,
35 .pull = GPIOMUX_PULL_NONE,
36};
37
Chun Zhangf39a0652013-05-01 15:57:54 -070038static struct gpiomux_setting atmel_int_act_cfg = {
39 .func = GPIOMUX_FUNC_GPIO,
40 .drv = GPIOMUX_DRV_8MA,
41 .pull = GPIOMUX_PULL_UP,
Gilad Avidovf58f1832013-01-09 17:31:28 -070042};
43
Chun Zhangf39a0652013-05-01 15:57:54 -070044static struct gpiomux_setting atmel_int_sus_cfg = {
45 .func = GPIOMUX_FUNC_GPIO,
46 .drv = GPIOMUX_DRV_2MA,
47 .pull = GPIOMUX_PULL_DOWN,
48};
49
50static struct gpiomux_setting atmel_reset_act_cfg = {
51 .func = GPIOMUX_FUNC_GPIO,
52 .drv = GPIOMUX_DRV_6MA,
53 .pull = GPIOMUX_PULL_UP,
54};
55
56static struct gpiomux_setting atmel_reset_sus_cfg = {
57 .func = GPIOMUX_FUNC_GPIO,
Gilad Avidovf58f1832013-01-09 17:31:28 -070058 .drv = GPIOMUX_DRV_6MA,
59 .pull = GPIOMUX_PULL_DOWN,
60};
61
Sameer Thalappil1fafd672013-04-03 12:31:04 -070062static struct gpiomux_setting wcnss_5wire_suspend_cfg = {
63 .func = GPIOMUX_FUNC_GPIO,
64 .drv = GPIOMUX_DRV_2MA,
65 .pull = GPIOMUX_PULL_UP,
66};
67
68static struct gpiomux_setting wcnss_5wire_active_cfg = {
69 .func = GPIOMUX_FUNC_1,
70 .drv = GPIOMUX_DRV_6MA,
71 .pull = GPIOMUX_PULL_DOWN,
72};
73
Xiaoming Zhou17972262013-04-10 17:50:35 -040074static struct gpiomux_setting lcd_en_act_cfg = {
75 .func = GPIOMUX_FUNC_GPIO,
76 .drv = GPIOMUX_DRV_8MA,
77 .pull = GPIOMUX_PULL_NONE,
78 .dir = GPIOMUX_OUT_HIGH,
79};
80
81static struct gpiomux_setting lcd_en_sus_cfg = {
82 .func = GPIOMUX_FUNC_GPIO,
83 .drv = GPIOMUX_DRV_2MA,
84 .pull = GPIOMUX_PULL_DOWN,
85};
86
Xiaoming Zhou8dca7e42013-05-31 19:44:57 -040087static struct gpiomux_setting lcd_te_act_config = {
88 .func = GPIOMUX_FUNC_1,
89 .drv = GPIOMUX_DRV_2MA,
90 .pull = GPIOMUX_PULL_DOWN,
91 .dir = GPIOMUX_IN,
92};
93
94static struct gpiomux_setting lcd_te_sus_config = {
95 .func = GPIOMUX_FUNC_1,
96 .drv = GPIOMUX_DRV_2MA,
97 .pull = GPIOMUX_PULL_DOWN,
98 .dir = GPIOMUX_IN,
99};
100
Amy Maloche19c386b2013-04-15 14:06:01 -0700101static struct gpiomux_setting gpio_keys_active = {
102 .func = GPIOMUX_FUNC_GPIO,
103 .drv = GPIOMUX_DRV_2MA,
104 .pull = GPIOMUX_PULL_UP,
105};
106
107static struct gpiomux_setting gpio_keys_suspend = {
108 .func = GPIOMUX_FUNC_GPIO,
109 .drv = GPIOMUX_DRV_2MA,
110 .pull = GPIOMUX_PULL_NONE,
111};
112
Richard Liua1d406a2013-04-14 13:46:48 -0700113/* define gpio used as interrupt input */
114static struct gpiomux_setting gpio_int_act_cfg = {
115 .func = GPIOMUX_FUNC_GPIO,
116 .drv = GPIOMUX_DRV_2MA,
117 .pull = GPIOMUX_PULL_UP,
118 .dir = GPIOMUX_IN,
119};
120
121static struct gpiomux_setting gpio_int_sus_cfg = {
122 .func = GPIOMUX_FUNC_GPIO,
123 .drv = GPIOMUX_DRV_2MA,
124 .pull = GPIOMUX_PULL_UP,
125 .dir = GPIOMUX_IN,
126};
127
128static struct msm_gpiomux_config msm_gpio_int_configs[] __initdata = {
129 {
130 .gpio = 84,
131 .settings = {
132 [GPIOMUX_ACTIVE] = &gpio_int_act_cfg,
133 [GPIOMUX_SUSPENDED] = &gpio_int_sus_cfg,
134 },
135 },
136};
137
Xiaoming Zhou17972262013-04-10 17:50:35 -0400138static struct msm_gpiomux_config msm_lcd_configs[] __initdata = {
139 {
140 .gpio = 41,
141 .settings = {
142 [GPIOMUX_ACTIVE] = &lcd_en_act_cfg,
143 [GPIOMUX_SUSPENDED] = &lcd_en_sus_cfg,
144 },
145 },
146 {
147 .gpio = 7,
148 .settings = {
149 [GPIOMUX_ACTIVE] = &lcd_en_act_cfg,
150 [GPIOMUX_SUSPENDED] = &lcd_en_sus_cfg,
151 },
152 },
Xiaoming Zhou8dca7e42013-05-31 19:44:57 -0400153 {
154 .gpio = 12,
155 .settings = {
156 [GPIOMUX_ACTIVE] = &lcd_te_act_config,
157 [GPIOMUX_SUSPENDED] = &lcd_te_sus_config,
158 },
159 },
Xiaoming Zhou17972262013-04-10 17:50:35 -0400160};
161
Gilad Avidovf84f2792013-01-31 13:26:39 -0700162static struct msm_gpiomux_config msm_blsp_configs[] __initdata = {
163 {
Chun Zhangf39a0652013-05-01 15:57:54 -0700164 .gpio = 2, /* BLSP1 QUP1 I2C_SDA */
165 .settings = {
166 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
167 },
168 },
169 {
170 .gpio = 3, /* BLSP1 QUP1 I2C_SCL */
171 .settings = {
172 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
173 },
174 },
175 {
Gilad Avidovf58f1832013-01-09 17:31:28 -0700176 .gpio = 10, /* BLSP1 QUP3 I2C_SDA */
Gilad Avidovf84f2792013-01-31 13:26:39 -0700177 .settings = {
178 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
179 },
180 },
181 {
Gilad Avidovf58f1832013-01-09 17:31:28 -0700182 .gpio = 11, /* BLSP1 QUP3 I2C_SCL */
Gilad Avidovf84f2792013-01-31 13:26:39 -0700183 .settings = {
184 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
185 },
186 },
Gilad Avidovf58f1832013-01-09 17:31:28 -0700187 {
Kenneth Heitke0d4fbb12013-04-10 12:51:14 -0600188 .gpio = 16, /* BLSP1 QUP6 I2C_SDA */
189 .settings = {
190 [GPIOMUX_SUSPENDED] = &gpio_cam_i2c_config,
191 },
192 },
193 {
194 .gpio = 17, /* BLSP1 QUP6 I2C_SCL */
195 .settings = {
196 [GPIOMUX_SUSPENDED] = &gpio_cam_i2c_config,
197 },
198 },
Chun Zhangf39a0652013-05-01 15:57:54 -0700199};
200
201static struct msm_gpiomux_config msm_atmel_configs[] __initdata = {
Kenneth Heitke0d4fbb12013-04-10 12:51:14 -0600202 {
Chun Zhangf39a0652013-05-01 15:57:54 -0700203 .gpio = 0, /* TOUCH RESET */
Gilad Avidovf58f1832013-01-09 17:31:28 -0700204 .settings = {
Chun Zhangf39a0652013-05-01 15:57:54 -0700205 [GPIOMUX_ACTIVE] = &atmel_reset_act_cfg,
206 [GPIOMUX_SUSPENDED] = &atmel_reset_sus_cfg,
Gilad Avidovf58f1832013-01-09 17:31:28 -0700207 },
208 },
209 {
Chun Zhangf39a0652013-05-01 15:57:54 -0700210 .gpio = 1, /* TOUCH INT */
Gilad Avidovf58f1832013-01-09 17:31:28 -0700211 .settings = {
Chun Zhangf39a0652013-05-01 15:57:54 -0700212 [GPIOMUX_ACTIVE] = &atmel_int_act_cfg,
213 [GPIOMUX_SUSPENDED] = &atmel_int_sus_cfg,
Gilad Avidovf58f1832013-01-09 17:31:28 -0700214 },
215 },
Gilad Avidova460c472013-04-12 16:23:32 -0600216 {
217 .gpio = 86, /* BLSP1 QUP4 SPI_DATA_MOSI */
218 .settings = {
219 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
220 },
221 },
222 {
223 .gpio = 87, /* BLSP1 QUP4 SPI_DATA_MISO */
224 .settings = {
225 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
226 },
227 },
228 {
229 .gpio = 89, /* BLSP1 QUP4 SPI_CLK */
230 .settings = {
231 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
232 },
233 },
234 {
235 .gpio = 88, /* BLSP1 QUP4 SPI_CS */
236 .settings = {
237 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
238 },
239 },
Gilad Avidovf84f2792013-01-31 13:26:39 -0700240};
241
Sameer Thalappil1fafd672013-04-03 12:31:04 -0700242static struct msm_gpiomux_config wcnss_5wire_interface[] = {
243 {
244 .gpio = 23,
245 .settings = {
246 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
247 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
248 },
249 },
250 {
251 .gpio = 24,
252 .settings = {
253 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
254 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
255 },
256 },
257 {
258 .gpio = 25,
259 .settings = {
260 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
261 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
262 },
263 },
264 {
265 .gpio = 26,
266 .settings = {
267 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
268 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
269 },
270 },
271 {
272 .gpio = 27,
273 .settings = {
274 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
275 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
276 },
277 },
278};
279
Lokesh Kumar Aakulu329a3472013-06-03 06:08:17 -0700280static struct gpiomux_setting gpio_suspend_config[] = {
281 {
282 .func = GPIOMUX_FUNC_GPIO, /* IN-NP */
283 .drv = GPIOMUX_DRV_2MA,
284 .pull = GPIOMUX_PULL_NONE,
285 },
286 {
287 .func = GPIOMUX_FUNC_GPIO, /* O-LOW */
288 .drv = GPIOMUX_DRV_2MA,
289 .pull = GPIOMUX_PULL_NONE,
290 .dir = GPIOMUX_OUT_LOW,
291 },
292};
293
294static struct gpiomux_setting cam_settings[] = {
295 {
296 .func = GPIOMUX_FUNC_1, /*active 1*/ /* 0 */
297 .drv = GPIOMUX_DRV_2MA,
298 .pull = GPIOMUX_PULL_NONE,
299 },
300
301 {
302 .func = GPIOMUX_FUNC_1, /*suspend*/ /* 1 */
303 .drv = GPIOMUX_DRV_2MA,
304 .pull = GPIOMUX_PULL_DOWN,
305 },
306
307 {
308 .func = GPIOMUX_FUNC_1, /*i2c suspend*/ /* 2 */
309 .drv = GPIOMUX_DRV_2MA,
310 .pull = GPIOMUX_PULL_KEEPER,
311 },
312
313 {
314 .func = GPIOMUX_FUNC_GPIO, /*active 0*/ /* 3 */
315 .drv = GPIOMUX_DRV_2MA,
316 .pull = GPIOMUX_PULL_NONE,
317 },
318
319 {
320 .func = GPIOMUX_FUNC_GPIO, /*suspend 0*/ /* 4 */
321 .drv = GPIOMUX_DRV_2MA,
322 .pull = GPIOMUX_PULL_DOWN,
323 },
324};
325
326static struct msm_gpiomux_config msm_sensor_configs[] __initdata = {
327 {
328 .gpio = 13, /* CAM_MCLK0 */
329 .settings = {
330 [GPIOMUX_ACTIVE] = &cam_settings[0],
331 [GPIOMUX_SUSPENDED] = &cam_settings[1],
332 },
333 },
334 {
335 .gpio = 14, /* CAM_MCLK1 */
336 .settings = {
337 [GPIOMUX_ACTIVE] = &cam_settings[0],
338 [GPIOMUX_SUSPENDED] = &cam_settings[1],
339 },
340 },
341 {
342 .gpio = 16, /* CCI_I2C_SDA */
343 .settings = {
344 [GPIOMUX_ACTIVE] = &cam_settings[0],
345 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[0],
346 },
347 },
348 {
349 .gpio = 17, /* CCI_I2C_SCL */
350 .settings = {
351 [GPIOMUX_ACTIVE] = &cam_settings[0],
352 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[0],
353 },
354 },
355 {
356 .gpio = 18, /* FLASH_LED_EN */
357 .settings = {
358 [GPIOMUX_ACTIVE] = &cam_settings[0],
359 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1],
360 },
361 },
362 {
363 .gpio = 19, /* FLASH_LED_NOW */
364 .settings = {
365 [GPIOMUX_ACTIVE] = &cam_settings[0],
366 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1],
367 },
368 },
369 {
370 .gpio = 8, /* CAM1_STANDBY_N */
371 .settings = {
372 [GPIOMUX_ACTIVE] = &cam_settings[3],
373 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1],
374 },
375 },
376 {
377 .gpio = 15, /* CAM1_RST_N */
378 .settings = {
379 [GPIOMUX_ACTIVE] = &cam_settings[3],
380 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1],
381 },
382 },
383 {
384 .gpio = 20, /* WEBCAM1_STANDBY */
385 .settings = {
386 [GPIOMUX_ACTIVE] = &cam_settings[3],
387 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1],
388 },
389 },
390 {
391 .gpio = 21, /* WEBCAM2_RESET_N */
392 .settings = {
393 [GPIOMUX_ACTIVE] = &cam_settings[3],
394 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1],
395 },
396 },
397};
398
Amy Maloche19c386b2013-04-15 14:06:01 -0700399static struct msm_gpiomux_config msm_keypad_configs[] __initdata = {
400 {
401 .gpio = 72,
402 .settings = {
403 [GPIOMUX_ACTIVE] = &gpio_keys_active,
404 [GPIOMUX_SUSPENDED] = &gpio_keys_suspend,
405 },
406 },
407 {
408 .gpio = 73,
409 .settings = {
410 [GPIOMUX_ACTIVE] = &gpio_keys_active,
411 [GPIOMUX_SUSPENDED] = &gpio_keys_suspend,
412 },
413 },
414 {
415 .gpio = 74,
416 .settings = {
417 [GPIOMUX_ACTIVE] = &gpio_keys_active,
418 [GPIOMUX_SUSPENDED] = &gpio_keys_suspend,
419 },
420 },
421};
422
Venkat Gopalakrishnan8aaf15a2013-04-30 16:27:03 -0700423static struct gpiomux_setting sd_card_det_active_config = {
424 .func = GPIOMUX_FUNC_GPIO,
425 .drv = GPIOMUX_DRV_2MA,
426 .pull = GPIOMUX_PULL_NONE,
427 .dir = GPIOMUX_IN,
428};
429
430static struct gpiomux_setting sd_card_det_suspend_config = {
431 .func = GPIOMUX_FUNC_GPIO,
432 .drv = GPIOMUX_DRV_2MA,
433 .pull = GPIOMUX_PULL_UP,
434 .dir = GPIOMUX_IN,
435};
436
437static struct msm_gpiomux_config sd_card_det[] __initdata = {
438 {
439 .gpio = 42,
440 .settings = {
441 [GPIOMUX_ACTIVE] = &sd_card_det_active_config,
442 [GPIOMUX_SUSPENDED] = &sd_card_det_suspend_config,
443 },
444 },
445};
446
Syed Rameez Mustafa3971c142013-01-09 19:04:53 -0800447void __init msm8610_init_gpiomux(void)
Hanumant Singh55a1bb02012-11-06 10:01:15 -0800448{
449 int rc;
450
Rohit Vaswani341c2032012-11-08 18:49:29 -0800451 rc = msm_gpiomux_init_dt();
Hanumant Singh55a1bb02012-11-06 10:01:15 -0800452 if (rc) {
Rohit Vaswani341c2032012-11-08 18:49:29 -0800453 pr_err("%s failed %d\n", __func__, rc);
Hanumant Singh55a1bb02012-11-06 10:01:15 -0800454 return;
455 }
Gilad Avidovf84f2792013-01-31 13:26:39 -0700456
457 msm_gpiomux_install(msm_blsp_configs, ARRAY_SIZE(msm_blsp_configs));
Chun Zhangf39a0652013-05-01 15:57:54 -0700458 msm_gpiomux_install(msm_atmel_configs,
459 ARRAY_SIZE(msm_atmel_configs));
Sameer Thalappil1fafd672013-04-03 12:31:04 -0700460 msm_gpiomux_install(wcnss_5wire_interface,
461 ARRAY_SIZE(wcnss_5wire_interface));
Xiaoming Zhou17972262013-04-10 17:50:35 -0400462 msm_gpiomux_install(msm_lcd_configs, ARRAY_SIZE(msm_lcd_configs));
Amy Maloche19c386b2013-04-15 14:06:01 -0700463 msm_gpiomux_install(msm_keypad_configs,
464 ARRAY_SIZE(msm_keypad_configs));
Venkat Gopalakrishnan8aaf15a2013-04-30 16:27:03 -0700465 msm_gpiomux_install(sd_card_det, ARRAY_SIZE(sd_card_det));
Lokesh Kumar Aakulu329a3472013-06-03 06:08:17 -0700466 msm_gpiomux_install(msm_sensor_configs, ARRAY_SIZE(msm_sensor_configs));
Richard Liua1d406a2013-04-14 13:46:48 -0700467 msm_gpiomux_install(msm_gpio_int_configs,
468 ARRAY_SIZE(msm_gpio_int_configs));
Hanumant Singh55a1bb02012-11-06 10:01:15 -0800469}