blob: 1577a2b8a6454a4c5f8a8c9167eaebec2451a11f [file] [log] [blame]
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -07001/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
2 *
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
Subbaraman Narayanamurthy3f93ab12012-08-17 19:39:47 -070020#define KS8851_IRQ_GPIO 94
Sathish Ambleye3154b42012-04-09 10:59:09 -070021
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -070022static struct gpiomux_setting gpio_uart_config = {
23 .func = GPIOMUX_FUNC_2,
24 .drv = GPIOMUX_DRV_16MA,
25 .pull = GPIOMUX_PULL_NONE,
26 .dir = GPIOMUX_OUT_HIGH,
27};
28
Sagar Dhariaa8e6b0a2012-08-10 20:52:30 -060029static struct gpiomux_setting slimbus = {
30 .func = GPIOMUX_FUNC_1,
31 .drv = GPIOMUX_DRV_8MA,
32 .pull = GPIOMUX_PULL_KEEPER,
33};
34
Sathish Ambleye3154b42012-04-09 10:59:09 -070035#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
36static struct gpiomux_setting gpio_eth_config = {
Subbaraman Narayanamurthy3f93ab12012-08-17 19:39:47 -070037 .pull = GPIOMUX_PULL_UP,
38 .drv = GPIOMUX_DRV_2MA,
Sathish Ambleye3154b42012-04-09 10:59:09 -070039 .func = GPIOMUX_FUNC_GPIO,
40};
41
Subbaraman Narayanamurthy3f93ab12012-08-17 19:39:47 -070042static struct gpiomux_setting gpio_spi_cs2_config = {
Sathish Ambleye3154b42012-04-09 10:59:09 -070043 .func = GPIOMUX_FUNC_4,
Subbaraman Narayanamurthy3f93ab12012-08-17 19:39:47 -070044 .drv = GPIOMUX_DRV_6MA,
45 .pull = GPIOMUX_PULL_DOWN,
Sathish Ambleye3154b42012-04-09 10:59:09 -070046};
47
48static struct gpiomux_setting gpio_spi_config = {
49 .func = GPIOMUX_FUNC_1,
50 .drv = GPIOMUX_DRV_12MA,
51 .pull = GPIOMUX_PULL_NONE,
52};
53
Subbaraman Narayanamurthy3f93ab12012-08-17 19:39:47 -070054static struct gpiomux_setting gpio_spi_cs1_config = {
55 .func = GPIOMUX_FUNC_GPIO,
56 .drv = GPIOMUX_DRV_6MA,
57 .pull = GPIOMUX_PULL_UP,
58};
59
Sathish Ambleye3154b42012-04-09 10:59:09 -070060static struct msm_gpiomux_config msm_eth_configs[] = {
61 {
62 .gpio = KS8851_IRQ_GPIO,
63 .settings = {
64 [GPIOMUX_SUSPENDED] = &gpio_eth_config,
65 }
66 },
67};
68#endif
Sameer Thalappil8d686d42012-08-24 10:07:31 -070069
70static struct gpiomux_setting wcnss_5wire_suspend_cfg = {
71 .func = GPIOMUX_FUNC_GPIO,
72 .drv = GPIOMUX_DRV_2MA,
73 .pull = GPIOMUX_PULL_UP,
74};
75
76static struct gpiomux_setting wcnss_5wire_active_cfg = {
77 .func = GPIOMUX_FUNC_1,
78 .drv = GPIOMUX_DRV_6MA,
79 .pull = GPIOMUX_PULL_DOWN,
80};
81
Jin Honga04caaa2012-05-23 10:28:27 -070082static struct gpiomux_setting gpio_i2c_config = {
83 .func = GPIOMUX_FUNC_3,
84 .drv = GPIOMUX_DRV_8MA,
85 .pull = GPIOMUX_PULL_NONE,
86};
87
Chandan Uddaraju88b26d72012-08-13 22:28:44 -070088static struct gpiomux_setting lcd_en_act_cfg = {
89 .func = GPIOMUX_FUNC_GPIO,
90 .drv = GPIOMUX_DRV_8MA,
91 .pull = GPIOMUX_PULL_NONE,
92};
93
94static struct gpiomux_setting lcd_en_sus_cfg = {
95 .func = GPIOMUX_FUNC_GPIO,
96 .drv = GPIOMUX_DRV_2MA,
97 .pull = GPIOMUX_PULL_DOWN,
98};
Sathish Ambleye3154b42012-04-09 10:59:09 -070099
Amy Maloche9e99a792012-08-15 23:27:51 -0700100static struct gpiomux_setting atmel_resout_sus_cfg = {
101 .func = GPIOMUX_FUNC_GPIO,
102 .drv = GPIOMUX_DRV_6MA,
103 .pull = GPIOMUX_PULL_DOWN,
104};
105
106static struct gpiomux_setting atmel_resout_act_cfg = {
107 .func = GPIOMUX_FUNC_GPIO,
108 .drv = GPIOMUX_DRV_6MA,
109 .pull = GPIOMUX_PULL_UP,
110};
111
112static struct gpiomux_setting atmel_int_act_cfg = {
113 .func = GPIOMUX_FUNC_GPIO,
114 .drv = GPIOMUX_DRV_8MA,
115 .pull = GPIOMUX_PULL_UP,
116};
117
118static struct gpiomux_setting atmel_int_sus_cfg = {
119 .func = GPIOMUX_FUNC_GPIO,
120 .drv = GPIOMUX_DRV_2MA,
121 .pull = GPIOMUX_PULL_DOWN,
122};
123
Joonwoo Park187e9cb2012-08-24 22:47:53 -0700124static struct gpiomux_setting taiko_reset = {
125 .func = GPIOMUX_FUNC_GPIO,
126 .drv = GPIOMUX_DRV_6MA,
127 .pull = GPIOMUX_PULL_NONE,
128 .dir = GPIOMUX_OUT_LOW,
129};
130
Amy Maloche9e99a792012-08-15 23:27:51 -0700131static struct msm_gpiomux_config msm_touch_configs[] __initdata = {
132 {
133 .gpio = 60, /* TOUCH RESET */
134 .settings = {
135 [GPIOMUX_ACTIVE] = &atmel_resout_act_cfg,
136 [GPIOMUX_SUSPENDED] = &atmel_resout_sus_cfg,
137 },
138 },
139 {
140 .gpio = 61, /* TOUCH IRQ */
141 .settings = {
142 [GPIOMUX_ACTIVE] = &atmel_int_act_cfg,
143 [GPIOMUX_SUSPENDED] = &atmel_int_sus_cfg,
144 },
145 },
146
147};
Ujwal Patel74b5df42012-08-13 22:50:13 -0700148
149static struct gpiomux_setting hdmi_suspend_cfg = {
150 .func = GPIOMUX_FUNC_GPIO,
151 .drv = GPIOMUX_DRV_2MA,
152 .pull = GPIOMUX_PULL_DOWN,
153};
154
155static struct gpiomux_setting hdmi_active_1_cfg = {
156 .func = GPIOMUX_FUNC_1,
157 .drv = GPIOMUX_DRV_2MA,
158 .pull = GPIOMUX_PULL_UP,
159};
160
161static struct gpiomux_setting hdmi_active_2_cfg = {
162 .func = GPIOMUX_FUNC_1,
163 .drv = GPIOMUX_DRV_16MA,
164 .pull = GPIOMUX_PULL_DOWN,
165};
166
167static struct msm_gpiomux_config msm_hdmi_configs[] __initdata = {
168 {
169 .gpio = 31,
170 .settings = {
171 [GPIOMUX_ACTIVE] = &hdmi_active_1_cfg,
172 [GPIOMUX_SUSPENDED] = &hdmi_suspend_cfg,
173 },
174 },
175 {
176 .gpio = 32,
177 .settings = {
178 [GPIOMUX_ACTIVE] = &hdmi_active_1_cfg,
179 [GPIOMUX_SUSPENDED] = &hdmi_suspend_cfg,
180 },
181 },
182 {
183 .gpio = 33,
184 .settings = {
185 [GPIOMUX_ACTIVE] = &hdmi_active_1_cfg,
186 [GPIOMUX_SUSPENDED] = &hdmi_suspend_cfg,
187 },
188 },
189 {
190 .gpio = 34,
191 .settings = {
192 [GPIOMUX_ACTIVE] = &hdmi_active_2_cfg,
193 [GPIOMUX_SUSPENDED] = &hdmi_suspend_cfg,
194 },
195 },
196};
197
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -0700198static struct msm_gpiomux_config msm_blsp_configs[] __initdata = {
Sathish Ambleye3154b42012-04-09 10:59:09 -0700199#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
200 {
201 .gpio = 0, /* BLSP1 QUP SPI_DATA_MOSI */
202 .settings = {
203 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
204 },
205 },
206 {
207 .gpio = 1, /* BLSP1 QUP SPI_DATA_MISO */
208 .settings = {
209 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
210 },
211 },
212 {
213 .gpio = 3, /* BLSP1 QUP SPI_CLK */
214 .settings = {
215 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
216 },
217 },
218 {
Subbaraman Narayanamurthy3f93ab12012-08-17 19:39:47 -0700219 .gpio = 9, /* BLSP1 QUP SPI_CS2A_N */
Sathish Ambleye3154b42012-04-09 10:59:09 -0700220 .settings = {
Subbaraman Narayanamurthy3f93ab12012-08-17 19:39:47 -0700221 [GPIOMUX_SUSPENDED] = &gpio_spi_cs2_config,
222 },
223 },
224 {
225 .gpio = 8, /* BLSP1 QUP SPI_CS1_N */
226 .settings = {
227 [GPIOMUX_SUSPENDED] = &gpio_spi_cs1_config,
Sathish Ambleye3154b42012-04-09 10:59:09 -0700228 },
229 },
230#endif
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -0700231 {
Chandan Uddaraju88b26d72012-08-13 22:28:44 -0700232 .gpio = 58,
233 .settings = {
234 [GPIOMUX_ACTIVE] = &lcd_en_act_cfg,
235 [GPIOMUX_SUSPENDED] = &lcd_en_sus_cfg,
236 },
237 },
238 {
Amy Malochebc7e9672012-08-15 10:30:40 -0700239 .gpio = 6, /* BLSP1 QUP2 I2C_DAT */
240 .settings = {
241 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
242 },
243 },
244 {
245 .gpio = 7, /* BLSP1 QUP2 I2C_CLK */
246 .settings = {
247 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
248 },
249 },
250 {
Jin Honga04caaa2012-05-23 10:28:27 -0700251 .gpio = 83, /* BLSP11 QUP I2C_DAT */
252 .settings = {
253 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
254 },
255 },
256 {
257 .gpio = 84, /* BLSP11 QUP I2C_CLK */
258 .settings = {
259 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
260 },
261 },
262 {
Stepan Moskovchenko5269b602012-08-08 17:57:09 -0700263 .gpio = 4, /* BLSP2 UART TX */
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -0700264 .settings = {
265 [GPIOMUX_SUSPENDED] = &gpio_uart_config,
266 },
267 },
268 {
Stepan Moskovchenko5269b602012-08-08 17:57:09 -0700269 .gpio = 5, /* BLSP2 UART RX */
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -0700270 .settings = {
271 [GPIOMUX_SUSPENDED] = &gpio_uart_config,
272 },
273 },
274};
275
Sagar Dhariaa8e6b0a2012-08-10 20:52:30 -0600276static struct msm_gpiomux_config msm8974_slimbus_config[] __initdata = {
277 {
278 .gpio = 70, /* slimbus clk */
279 .settings = {
280 [GPIOMUX_SUSPENDED] = &slimbus,
281 },
282 },
283 {
284 .gpio = 71, /* slimbus data */
285 .settings = {
286 [GPIOMUX_SUSPENDED] = &slimbus,
287 },
288 },
289};
290
Kevin Chanbdcf7ef2012-08-24 08:33:33 -0700291static struct gpiomux_setting cam_settings[] = {
292 {
Sreesudhan Ramakrish Ramkumar88c4a092012-09-07 23:43:46 -0700293 .func = GPIOMUX_FUNC_1, /*active 1*/ /* 0 */
Kevin Chanbdcf7ef2012-08-24 08:33:33 -0700294 .drv = GPIOMUX_DRV_2MA,
295 .pull = GPIOMUX_PULL_NONE,
296 },
297
298 {
Sreesudhan Ramakrish Ramkumar88c4a092012-09-07 23:43:46 -0700299 .func = GPIOMUX_FUNC_1, /*suspend*/ /* 1 */
Kevin Chanbdcf7ef2012-08-24 08:33:33 -0700300 .drv = GPIOMUX_DRV_2MA,
301 .pull = GPIOMUX_PULL_DOWN,
302 },
303
304 {
Sreesudhan Ramakrish Ramkumar88c4a092012-09-07 23:43:46 -0700305 .func = GPIOMUX_FUNC_1, /*i2c suspend*/ /* 2 */
Kevin Chanbdcf7ef2012-08-24 08:33:33 -0700306 .drv = GPIOMUX_DRV_2MA,
307 .pull = GPIOMUX_PULL_KEEPER,
308 },
Sreesudhan Ramakrish Ramkumar88c4a092012-09-07 23:43:46 -0700309
310 {
311 .func = GPIOMUX_FUNC_GPIO, /*active 0*/ /* 3 */
312 .drv = GPIOMUX_DRV_2MA,
313 .pull = GPIOMUX_PULL_NONE,
314 },
315
316 {
317 .func = GPIOMUX_FUNC_GPIO, /*suspend 0*/ /* 4 */
318 .drv = GPIOMUX_DRV_2MA,
319 .pull = GPIOMUX_PULL_DOWN,
320 },
Kevin Chanbdcf7ef2012-08-24 08:33:33 -0700321};
322
323static struct msm_gpiomux_config msm_sensor_configs[] __initdata = {
324 {
325 .gpio = 15, /* CAM_MCLK0 */
326 .settings = {
327 [GPIOMUX_ACTIVE] = &cam_settings[0],
328 [GPIOMUX_SUSPENDED] = &cam_settings[1],
329 },
330 },
331 {
332 .gpio = 16, /* CAM_MCLK1 */
333 .settings = {
334 [GPIOMUX_ACTIVE] = &cam_settings[0],
335 [GPIOMUX_SUSPENDED] = &cam_settings[1],
336 },
337 },
338 {
339 .gpio = 17, /* CAM_MCLK2 */
340 .settings = {
341 [GPIOMUX_ACTIVE] = &cam_settings[0],
342 [GPIOMUX_SUSPENDED] = &cam_settings[1],
343 },
344 },
345 {
346 .gpio = 18, /* WEBCAM1_RESET_N / CAM_MCLK3 */
347 .settings = {
Sreesudhan Ramakrish Ramkumar88c4a092012-09-07 23:43:46 -0700348 [GPIOMUX_ACTIVE] = &cam_settings[3],
349 [GPIOMUX_SUSPENDED] = &cam_settings[4],
Kevin Chanbdcf7ef2012-08-24 08:33:33 -0700350 },
351 },
352 {
353 .gpio = 19, /* CCI_I2C_SDA0 */
354 .settings = {
355 [GPIOMUX_ACTIVE] = &cam_settings[0],
356 [GPIOMUX_SUSPENDED] = &cam_settings[2],
357 },
358 },
359 {
360 .gpio = 20, /* CCI_I2C_SCL0 */
361 .settings = {
362 [GPIOMUX_ACTIVE] = &cam_settings[0],
363 [GPIOMUX_SUSPENDED] = &cam_settings[2],
364 },
365 },
366 {
367 .gpio = 21, /* CCI_I2C_SDA1 */
368 .settings = {
369 [GPIOMUX_ACTIVE] = &cam_settings[0],
370 [GPIOMUX_SUSPENDED] = &cam_settings[2],
371 },
372 },
373 {
374 .gpio = 22, /* CCI_I2C_SCL1 */
375 .settings = {
376 [GPIOMUX_ACTIVE] = &cam_settings[0],
377 [GPIOMUX_SUSPENDED] = &cam_settings[2],
378 },
379 },
380 {
381 .gpio = 23, /* FLASH_LED_EN */
382 .settings = {
383 [GPIOMUX_ACTIVE] = &cam_settings[0],
384 [GPIOMUX_SUSPENDED] = &cam_settings[1],
385 },
386 },
387 {
388 .gpio = 24, /* FLASH_LED_NOW */
389 .settings = {
390 [GPIOMUX_ACTIVE] = &cam_settings[0],
391 [GPIOMUX_SUSPENDED] = &cam_settings[1],
392 },
393 },
394 {
395 .gpio = 25, /* WEBCAM2_RESET_N */
396 .settings = {
397 [GPIOMUX_ACTIVE] = &cam_settings[0],
398 [GPIOMUX_SUSPENDED] = &cam_settings[1],
399 },
400 },
401 {
402 .gpio = 26, /* CAM_IRQ */
403 .settings = {
404 [GPIOMUX_ACTIVE] = &cam_settings[0],
405 [GPIOMUX_SUSPENDED] = &cam_settings[1],
406 },
407 },
408 {
409 .gpio = 27, /* OIS_SYNC */
410 .settings = {
411 [GPIOMUX_ACTIVE] = &cam_settings[0],
412 [GPIOMUX_SUSPENDED] = &cam_settings[1],
413 },
414 },
415 {
416 .gpio = 28, /* WEBCAM1_STANDBY */
417 .settings = {
418 [GPIOMUX_ACTIVE] = &cam_settings[0],
419 [GPIOMUX_SUSPENDED] = &cam_settings[1],
420 },
421 },
422 {
423 .gpio = 89, /* CAM1_STANDBY_N */
424 .settings = {
425 [GPIOMUX_ACTIVE] = &cam_settings[0],
426 [GPIOMUX_SUSPENDED] = &cam_settings[1],
427 },
428 },
429 {
430 .gpio = 90, /* CAM1_RST_N */
431 .settings = {
432 [GPIOMUX_ACTIVE] = &cam_settings[0],
433 [GPIOMUX_SUSPENDED] = &cam_settings[1],
434 },
435 },
436 {
437 .gpio = 91, /* CAM2_STANDBY_N */
438 .settings = {
439 [GPIOMUX_ACTIVE] = &cam_settings[0],
440 [GPIOMUX_SUSPENDED] = &cam_settings[1],
441 },
442 },
443 {
444 .gpio = 92, /* CAM2_RST_N */
445 .settings = {
446 [GPIOMUX_ACTIVE] = &cam_settings[0],
447 [GPIOMUX_SUSPENDED] = &cam_settings[1],
448 },
449 },
450};
Sameer Thalappil8d686d42012-08-24 10:07:31 -0700451static struct msm_gpiomux_config wcnss_5wire_interface[] = {
452 {
453 .gpio = 36,
454 .settings = {
455 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
456 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
457 },
458 },
459 {
460 .gpio = 37,
461 .settings = {
462 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
463 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
464 },
465 },
466 {
467 .gpio = 38,
468 .settings = {
469 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
470 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
471 },
472 },
473 {
474 .gpio = 39,
475 .settings = {
476 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
477 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
478 },
479 },
480 {
481 .gpio = 40,
482 .settings = {
483 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
484 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
485 },
486 },
487};
Kevin Chanbdcf7ef2012-08-24 08:33:33 -0700488
Joonwoo Park187e9cb2012-08-24 22:47:53 -0700489static struct msm_gpiomux_config msm_taiko_config[] __initdata = {
490 {
491 .gpio = 63, /* SYS_RST_N */
492 .settings = {
493 [GPIOMUX_SUSPENDED] = &taiko_reset,
494 },
495 }
496};
497
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700498void __init msm_8974_init_gpiomux(void)
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -0700499{
500 int rc;
501
502 rc = msm_gpiomux_init(NR_GPIO_IRQS);
503 if (rc) {
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700504 pr_err(KERN_ERR "msm_8974_init_gpiomux failed %d\n", rc);
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -0700505 return;
506 }
507
Sathish Ambleye3154b42012-04-09 10:59:09 -0700508#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
509 msm_gpiomux_install(msm_eth_configs, ARRAY_SIZE(msm_eth_configs));
510#endif
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -0700511 msm_gpiomux_install(msm_blsp_configs, ARRAY_SIZE(msm_blsp_configs));
Sameer Thalappil8d686d42012-08-24 10:07:31 -0700512 msm_gpiomux_install(wcnss_5wire_interface,
513 ARRAY_SIZE(wcnss_5wire_interface));
Sagar Dhariaa8e6b0a2012-08-10 20:52:30 -0600514
515 msm_gpiomux_install(msm8974_slimbus_config,
516 ARRAY_SIZE(msm8974_slimbus_config));
517
Amy Maloche9e99a792012-08-15 23:27:51 -0700518 msm_gpiomux_install(msm_touch_configs, ARRAY_SIZE(msm_touch_configs));
Kevin Chanbdcf7ef2012-08-24 08:33:33 -0700519
520 msm_gpiomux_install(msm_sensor_configs, ARRAY_SIZE(msm_sensor_configs));
Joonwoo Park187e9cb2012-08-24 22:47:53 -0700521
522 msm_gpiomux_install(msm_taiko_config, ARRAY_SIZE(msm_taiko_config));
Ujwal Patel74b5df42012-08-13 22:50:13 -0700523
524 msm_gpiomux_install(msm_hdmi_configs, ARRAY_SIZE(msm_hdmi_configs));
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -0700525}