blob: 378edc8e0943a63cc56032bb8346ef9d1a770889 [file] [log] [blame]
Gilad Avidov28e18eb2012-11-21 18:13:25 -07001/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
Syed Rameez Mustafa9d16c4f2012-09-10 14:16:55 -07002 *
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>
David Collins091bb242013-05-23 11:08:24 -070019#include <mach/socinfo.h>
Syed Rameez Mustafa9d16c4f2012-09-10 14:16:55 -070020
aiquny76b46082013-03-13 15:58:08 -070021#define KS8851_IRQ_GPIO 115
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -080022
23#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
24static struct gpiomux_setting gpio_eth_config = {
25 .pull = GPIOMUX_PULL_UP,
26 .drv = GPIOMUX_DRV_2MA,
27 .func = GPIOMUX_FUNC_GPIO,
28};
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -080029
30static struct msm_gpiomux_config msm_eth_configs[] = {
31 {
32 .gpio = KS8851_IRQ_GPIO,
33 .settings = {
34 [GPIOMUX_SUSPENDED] = &gpio_eth_config,
35 }
36 },
37};
Gilad Avidov28e18eb2012-11-21 18:13:25 -070038#endif
39
Amy Maloche41708ba2013-03-03 15:19:27 -080040static struct gpiomux_setting synaptics_int_act_cfg = {
41 .func = GPIOMUX_FUNC_GPIO,
42 .drv = GPIOMUX_DRV_8MA,
43 .pull = GPIOMUX_PULL_UP,
44};
45
46static struct gpiomux_setting synaptics_int_sus_cfg = {
47 .func = GPIOMUX_FUNC_GPIO,
48 .drv = GPIOMUX_DRV_2MA,
49 .pull = GPIOMUX_PULL_DOWN,
50};
51
52static struct gpiomux_setting synaptics_reset_act_cfg = {
53 .func = GPIOMUX_FUNC_GPIO,
54 .drv = GPIOMUX_DRV_6MA,
55 .pull = GPIOMUX_PULL_DOWN,
56};
57
58static struct gpiomux_setting synaptics_reset_sus_cfg = {
59 .func = GPIOMUX_FUNC_GPIO,
60 .drv = GPIOMUX_DRV_6MA,
61 .pull = GPIOMUX_PULL_DOWN,
62};
63
Amy Maloche24c59dd2013-03-05 11:43:55 -080064static struct gpiomux_setting gpio_keys_active = {
65 .func = GPIOMUX_FUNC_GPIO,
66 .drv = GPIOMUX_DRV_2MA,
67 .pull = GPIOMUX_PULL_UP,
68};
69
70static struct gpiomux_setting gpio_keys_suspend = {
71 .func = GPIOMUX_FUNC_GPIO,
72 .drv = GPIOMUX_DRV_2MA,
73 .pull = GPIOMUX_PULL_NONE,
74};
75
Gilad Avidov28e18eb2012-11-21 18:13:25 -070076static struct gpiomux_setting gpio_spi_config = {
77 .func = GPIOMUX_FUNC_1,
78 .drv = GPIOMUX_DRV_8MA,
79 .pull = GPIOMUX_PULL_NONE,
80};
81
Gilad Avidovd59217c2013-02-01 13:45:59 -070082static struct gpiomux_setting gpio_spi_cs_config = {
83 .func = GPIOMUX_FUNC_1,
84 .drv = GPIOMUX_DRV_6MA,
85 .pull = GPIOMUX_PULL_DOWN,
86};
87
aiquny76b46082013-03-13 15:58:08 -070088static struct gpiomux_setting gpio_spi_cs_eth_config = {
89 .func = GPIOMUX_FUNC_4,
90 .drv = GPIOMUX_DRV_6MA,
91 .pull = GPIOMUX_PULL_DOWN,
92};
93
Sheng Fang6746c3f2013-03-19 08:37:13 +080094static struct gpiomux_setting wcnss_5wire_suspend_cfg = {
95 .func = GPIOMUX_FUNC_GPIO,
96 .drv = GPIOMUX_DRV_2MA,
97 .pull = GPIOMUX_PULL_UP,
98};
99
100static struct gpiomux_setting wcnss_5wire_active_cfg = {
101 .func = GPIOMUX_FUNC_1,
102 .drv = GPIOMUX_DRV_6MA,
103 .pull = GPIOMUX_PULL_DOWN,
104};
105
Gilad Avidov28e18eb2012-11-21 18:13:25 -0700106static struct gpiomux_setting gpio_i2c_config = {
107 .func = GPIOMUX_FUNC_3,
108 .drv = GPIOMUX_DRV_2MA,
109 .pull = GPIOMUX_PULL_NONE,
110};
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800111
Amy Maloche24c59dd2013-03-05 11:43:55 -0800112static struct msm_gpiomux_config msm_keypad_configs[] __initdata = {
113 {
114 .gpio = 106,
115 .settings = {
116 [GPIOMUX_ACTIVE] = &gpio_keys_active,
117 [GPIOMUX_SUSPENDED] = &gpio_keys_suspend,
118 },
119 },
120 {
121 .gpio = 107,
122 .settings = {
123 [GPIOMUX_ACTIVE] = &gpio_keys_active,
124 [GPIOMUX_SUSPENDED] = &gpio_keys_suspend,
125 },
126 },
127 {
128 .gpio = 108,
129 .settings = {
130 [GPIOMUX_ACTIVE] = &gpio_keys_active,
131 [GPIOMUX_SUSPENDED] = &gpio_keys_suspend,
132 },
133 },
134};
135
Aravind Venkateswaranf60fb212013-03-08 13:57:06 -0800136static struct gpiomux_setting lcd_rst_act_cfg = {
137 .func = GPIOMUX_FUNC_GPIO,
138 .drv = GPIOMUX_DRV_8MA,
139 .pull = GPIOMUX_PULL_NONE,
140 .dir = GPIOMUX_OUT_LOW,
141};
142
143static struct gpiomux_setting lcd_rst_sus_cfg = {
144 .func = GPIOMUX_FUNC_GPIO,
145 .drv = GPIOMUX_DRV_2MA,
146 .pull = GPIOMUX_PULL_DOWN,
147};
148
149static struct msm_gpiomux_config msm_lcd_configs[] __initdata = {
150 {
151 .gpio = 25,
152 .settings = {
153 [GPIOMUX_ACTIVE] = &lcd_rst_act_cfg,
154 [GPIOMUX_SUSPENDED] = &lcd_rst_sus_cfg,
155 },
156 }
157};
158
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800159static struct msm_gpiomux_config msm_blsp_configs[] __initdata = {
160 {
Gilad Avidovd59217c2013-02-01 13:45:59 -0700161 .gpio = 0, /* BLSP1 QUP1 SPI_DATA_MOSI */
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800162 .settings = {
163 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
164 },
165 },
166 {
Gilad Avidovd59217c2013-02-01 13:45:59 -0700167 .gpio = 1, /* BLSP1 QUP1 SPI_DATA_MISO */
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800168 .settings = {
169 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
170 },
171 },
172 {
Gilad Avidovd59217c2013-02-01 13:45:59 -0700173 .gpio = 2, /* BLSP1 QUP1 SPI_CS1 */
174 .settings = {
175 [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config,
176 },
177 },
178 {
179 .gpio = 3, /* BLSP1 QUP1 SPI_CLK */
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800180 .settings = {
181 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
182 },
183 },
184 {
Gilad Avidovd59217c2013-02-01 13:45:59 -0700185 .gpio = 14, /* BLSP1 QUP4 I2C_SDA */
Gilad Avidov28e18eb2012-11-21 18:13:25 -0700186 .settings = {
187 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
188 },
189 },
190 {
Gilad Avidovd59217c2013-02-01 13:45:59 -0700191 .gpio = 15, /* BLSP1 QUP4 I2C_SCL */
Gilad Avidov28e18eb2012-11-21 18:13:25 -0700192 .settings = {
193 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
194 },
195 },
Amy Maloche41708ba2013-03-03 15:19:27 -0800196 {
197 .gpio = 18, /* BLSP1 QUP5 I2C_SDA */
198 .settings = {
199 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
200 },
201 },
202 {
203 .gpio = 19, /* BLSP1 QUP5 I2C_SCL */
204 .settings = {
205 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
206 },
207 },
aiquny76b46082013-03-13 15:58:08 -0700208 {
209 .gpio = 22, /* BLSP1 QUP1 SPI_CS_ETH */
210 .settings = {
211 [GPIOMUX_SUSPENDED] = &gpio_spi_cs_eth_config,
212 },
213 },
Amy Maloche41708ba2013-03-03 15:19:27 -0800214};
215
216static struct msm_gpiomux_config msm_synaptics_configs[] __initdata = {
217 {
218 .gpio = 16,
219 .settings = {
220 [GPIOMUX_ACTIVE] = &synaptics_reset_act_cfg,
221 [GPIOMUX_SUSPENDED] = &synaptics_reset_sus_cfg,
222 },
223 },
224 {
225 .gpio = 17,
226 .settings = {
227 [GPIOMUX_ACTIVE] = &synaptics_int_act_cfg,
228 [GPIOMUX_SUSPENDED] = &synaptics_int_sus_cfg,
229 },
230 },
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800231};
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800232
Krishna Konda7af5df92013-03-06 20:35:30 -0800233static struct gpiomux_setting sd_card_det_active_config = {
234 .func = GPIOMUX_FUNC_GPIO,
235 .drv = GPIOMUX_DRV_2MA,
236 .pull = GPIOMUX_PULL_NONE,
237 .dir = GPIOMUX_IN,
238};
239
240static struct gpiomux_setting sd_card_det_sleep_config = {
241 .func = GPIOMUX_FUNC_GPIO,
242 .drv = GPIOMUX_DRV_2MA,
243 .pull = GPIOMUX_PULL_UP,
244 .dir = GPIOMUX_IN,
245};
246
247static struct msm_gpiomux_config sd_card_det __initdata = {
248 .gpio = 38,
249 .settings = {
250 [GPIOMUX_ACTIVE] = &sd_card_det_active_config,
251 [GPIOMUX_SUSPENDED] = &sd_card_det_sleep_config,
252 },
253};
254
Sheng Fang6746c3f2013-03-19 08:37:13 +0800255static struct msm_gpiomux_config wcnss_5wire_interface[] = {
256 {
257 .gpio = 40,
258 .settings = {
259 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
260 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
261 },
262 },
263 {
264 .gpio = 41,
265 .settings = {
266 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
267 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
268 },
269 },
270 {
271 .gpio = 42,
272 .settings = {
273 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
274 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
275 },
276 },
277 {
278 .gpio = 43,
279 .settings = {
280 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
281 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
282 },
283 },
284 {
285 .gpio = 44,
286 .settings = {
287 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
288 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
289 },
290 },
291};
Su Liud1c66ee2013-03-22 15:29:48 -0700292
293static struct gpiomux_setting gpio_suspend_config[] = {
294 {
295 .func = GPIOMUX_FUNC_GPIO, /* IN-NP */
296 .drv = GPIOMUX_DRV_2MA,
297 .pull = GPIOMUX_PULL_NONE,
298 },
299 {
300 .func = GPIOMUX_FUNC_GPIO, /* O-LOW */
301 .drv = GPIOMUX_DRV_2MA,
302 .pull = GPIOMUX_PULL_NONE,
303 .dir = GPIOMUX_OUT_LOW,
304 },
305};
306
307static struct gpiomux_setting cam_settings[] = {
308 {
309 .func = GPIOMUX_FUNC_1, /*active 1*/ /* 0 */
310 .drv = GPIOMUX_DRV_2MA,
311 .pull = GPIOMUX_PULL_NONE,
312 },
313
314 {
315 .func = GPIOMUX_FUNC_1, /*suspend*/ /* 1 */
316 .drv = GPIOMUX_DRV_2MA,
317 .pull = GPIOMUX_PULL_DOWN,
318 },
319
320 {
321 .func = GPIOMUX_FUNC_1, /*i2c suspend*/ /* 2 */
322 .drv = GPIOMUX_DRV_2MA,
323 .pull = GPIOMUX_PULL_KEEPER,
324 },
325
326 {
327 .func = GPIOMUX_FUNC_GPIO, /*active 0*/ /* 3 */
328 .drv = GPIOMUX_DRV_2MA,
329 .pull = GPIOMUX_PULL_NONE,
330 },
331
332 {
333 .func = GPIOMUX_FUNC_GPIO, /*suspend 0*/ /* 4 */
334 .drv = GPIOMUX_DRV_2MA,
335 .pull = GPIOMUX_PULL_DOWN,
336 },
337};
338
339
340static struct msm_gpiomux_config msm_sensor_configs[] __initdata = {
341 {
342 .gpio = 26, /* CAM_MCLK0 */
343 .settings = {
344 [GPIOMUX_ACTIVE] = &cam_settings[0],
345 [GPIOMUX_SUSPENDED] = &cam_settings[1],
346 },
347 },
348 {
349 .gpio = 27, /* CAM_MCLK1 */
350 .settings = {
351 [GPIOMUX_ACTIVE] = &cam_settings[0],
352 [GPIOMUX_SUSPENDED] = &cam_settings[1],
353 },
354
355 },
356 {
357 .gpio = 29, /* CCI_I2C_SDA0 */
358 .settings = {
359 [GPIOMUX_ACTIVE] = &cam_settings[0],
360 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[0],
361 },
362 },
363 {
364 .gpio = 30, /* CCI_I2C_SCL0 */
365 .settings = {
366 [GPIOMUX_ACTIVE] = &cam_settings[0],
367 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[0],
368 },
369 },
370 {
371 .gpio = 36, /* CAM1_STANDBY_N */
372 .settings = {
373 [GPIOMUX_ACTIVE] = &cam_settings[3],
374 [GPIOMUX_SUSPENDED] = &cam_settings[4],
375 },
376 },
377 {
378 .gpio = 37, /* CAM1_RST_N */
379 .settings = {
380 [GPIOMUX_ACTIVE] = &cam_settings[3],
381 [GPIOMUX_SUSPENDED] = &cam_settings[4],
382 },
383 },
384 {
385 .gpio = 35, /* CAM2_STANDBY_N */
386 .settings = {
387 [GPIOMUX_ACTIVE] = &cam_settings[3],
388 [GPIOMUX_SUSPENDED] = &cam_settings[4],
389 },
390 },
391 {
392 .gpio = 28, /* CAM2_RST_N */
393 .settings = {
394 [GPIOMUX_ACTIVE] = &cam_settings[3],
395 [GPIOMUX_SUSPENDED] = &cam_settings[4],
396 },
397 },
398
399};
400
Banajit Goswami25715c52013-05-10 11:45:47 -0700401static struct gpiomux_setting auxpcm_act_cfg = {
402 .func = GPIOMUX_FUNC_1,
403 .drv = GPIOMUX_DRV_8MA,
404 .pull = GPIOMUX_PULL_NONE,
405};
406
407static struct gpiomux_setting auxpcm_sus_cfg = {
408 .func = GPIOMUX_FUNC_1,
409 .drv = GPIOMUX_DRV_2MA,
410 .pull = GPIOMUX_PULL_DOWN,
411};
412
413static struct msm_gpiomux_config msm_auxpcm_configs[] __initdata = {
414 {
415 .gpio = 63,
416 .settings = {
417 [GPIOMUX_SUSPENDED] = &auxpcm_sus_cfg,
418 [GPIOMUX_ACTIVE] = &auxpcm_act_cfg,
419 },
420 },
421 {
422 .gpio = 64,
423 .settings = {
424 [GPIOMUX_SUSPENDED] = &auxpcm_sus_cfg,
425 [GPIOMUX_ACTIVE] = &auxpcm_act_cfg,
426 },
427 },
428 {
429 .gpio = 65,
430 .settings = {
431 [GPIOMUX_SUSPENDED] = &auxpcm_sus_cfg,
432 [GPIOMUX_ACTIVE] = &auxpcm_act_cfg,
433 },
434 },
435 {
436 .gpio = 66,
437 .settings = {
438 [GPIOMUX_SUSPENDED] = &auxpcm_sus_cfg,
439 [GPIOMUX_ACTIVE] = &auxpcm_act_cfg,
440 },
441 },
442};
443
David Collins091bb242013-05-23 11:08:24 -0700444static struct gpiomux_setting usb_otg_sw_cfg = {
445 .func = GPIOMUX_FUNC_GPIO,
446 .drv = GPIOMUX_DRV_2MA,
447 .dir = GPIOMUX_OUT_LOW,
448};
449
450static struct msm_gpiomux_config usb_otg_sw_configs[] __initdata = {
451 {
452 .gpio = 67,
453 .settings = {
454 [GPIOMUX_SUSPENDED] = &usb_otg_sw_cfg,
455 },
456 },
457};
458
Syed Rameez Mustafa9d16c4f2012-09-10 14:16:55 -0700459void __init msm8226_init_gpiomux(void)
460{
461 int rc;
462
Rohit Vaswani341c2032012-11-08 18:49:29 -0800463 rc = msm_gpiomux_init_dt();
Syed Rameez Mustafa9d16c4f2012-09-10 14:16:55 -0700464 if (rc) {
Rohit Vaswani341c2032012-11-08 18:49:29 -0800465 pr_err("%s failed %d\n", __func__, rc);
Syed Rameez Mustafa9d16c4f2012-09-10 14:16:55 -0700466 return;
467 }
Gilad Avidov28e18eb2012-11-21 18:13:25 -0700468
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800469#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
470 msm_gpiomux_install(msm_eth_configs, ARRAY_SIZE(msm_eth_configs));
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800471#endif
Amy Maloche24c59dd2013-03-05 11:43:55 -0800472 msm_gpiomux_install(msm_keypad_configs,
473 ARRAY_SIZE(msm_keypad_configs));
Gilad Avidov28e18eb2012-11-21 18:13:25 -0700474
475 msm_gpiomux_install(msm_blsp_configs, ARRAY_SIZE(msm_blsp_configs));
Sheng Fang6746c3f2013-03-19 08:37:13 +0800476 msm_gpiomux_install(wcnss_5wire_interface,
477 ARRAY_SIZE(wcnss_5wire_interface));
Krishna Konda7af5df92013-03-06 20:35:30 -0800478
479 msm_gpiomux_install(&sd_card_det, 1);
Amy Maloche41708ba2013-03-03 15:19:27 -0800480 msm_gpiomux_install(msm_synaptics_configs,
481 ARRAY_SIZE(msm_synaptics_configs));
Aravind Venkateswaranf60fb212013-03-08 13:57:06 -0800482 msm_gpiomux_install_nowrite(msm_lcd_configs,
483 ARRAY_SIZE(msm_lcd_configs));
Su Liud1c66ee2013-03-22 15:29:48 -0700484 msm_gpiomux_install(msm_sensor_configs, ARRAY_SIZE(msm_sensor_configs));
Banajit Goswami25715c52013-05-10 11:45:47 -0700485 msm_gpiomux_install(msm_auxpcm_configs,
486 ARRAY_SIZE(msm_auxpcm_configs));
David Collins091bb242013-05-23 11:08:24 -0700487
Syed Rameez Mustafa7ef61582013-06-07 16:14:58 -0700488 if (of_board_is_cdp() || of_board_is_mtp() || of_board_is_xpm())
David Collins091bb242013-05-23 11:08:24 -0700489 msm_gpiomux_install(usb_otg_sw_configs,
490 ARRAY_SIZE(usb_otg_sw_configs));
Syed Rameez Mustafa9d16c4f2012-09-10 14:16:55 -0700491}