blob: c91deb25c5e7aafa9f82b5438ae4a782c94a5888 [file] [log] [blame]
Bingzhe Cai43bed2b2014-01-02 14:07:31 +08001/* Copyright (c) 2012-2014, 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
Yue Ma10d88752014-02-20 17:12:05 -080014#include <linux/gpio.h>
Hanumant Singh55a1bb02012-11-06 10:01:15 -080015#include <linux/init.h>
16#include <linux/ioport.h>
17#include <mach/board.h>
18#include <mach/gpio.h>
19#include <mach/gpiomux.h>
Figo Wangb1510f82013-06-13 19:40:20 +080020#include <mach/socinfo.h>
Hanumant Singh55a1bb02012-11-06 10:01:15 -080021
Yue Ma10d88752014-02-20 17:12:05 -080022#define WLAN_CLK 27
23#define WLAN_SET 26
24#define WLAN_DATA0 25
25#define WLAN_DATA1 24
26#define WLAN_DATA2 23
27
Gilad Avidova460c472013-04-12 16:23:32 -060028static struct gpiomux_setting gpio_spi_config = {
29 .func = GPIOMUX_FUNC_1,
30 .drv = GPIOMUX_DRV_6MA,
31 .pull = GPIOMUX_PULL_NONE,
32};
Sana Venkat Rajue53161a2013-09-17 16:33:26 +053033static struct gpiomux_setting gpio_spi_susp_config = {
34 .func = GPIOMUX_FUNC_GPIO,
35 .drv = GPIOMUX_DRV_2MA,
36 .pull = GPIOMUX_PULL_DOWN,
37};
Gilad Avidova460c472013-04-12 16:23:32 -060038
Gilad Avidovf84f2792013-01-31 13:26:39 -070039static struct gpiomux_setting gpio_i2c_config = {
40 .func = GPIOMUX_FUNC_3,
41 .drv = GPIOMUX_DRV_2MA,
42 .pull = GPIOMUX_PULL_NONE,
43};
44
Kenneth Heitke0d4fbb12013-04-10 12:51:14 -060045static struct gpiomux_setting gpio_cam_i2c_config = {
46 .func = GPIOMUX_FUNC_1,
47 .drv = GPIOMUX_DRV_2MA,
48 .pull = GPIOMUX_PULL_NONE,
49};
50
Bansidhar Gopalacharie331f372013-09-25 19:50:43 +010051static struct gpiomux_setting gpio_nfc_config = {
52 .func = GPIOMUX_FUNC_2,
53 .drv = GPIOMUX_DRV_2MA,
54 .pull = GPIOMUX_PULL_NONE,
55};
56static struct gpiomux_setting gpio_nfc_sus_config = {
57 .func = GPIOMUX_FUNC_2,
58 .drv = GPIOMUX_DRV_2MA,
59 .pull = GPIOMUX_PULL_DOWN,
60};
61
Chun Zhangf39a0652013-05-01 15:57:54 -070062static struct gpiomux_setting atmel_int_act_cfg = {
63 .func = GPIOMUX_FUNC_GPIO,
64 .drv = GPIOMUX_DRV_8MA,
65 .pull = GPIOMUX_PULL_UP,
Gilad Avidovf58f1832013-01-09 17:31:28 -070066};
67
Chun Zhangf39a0652013-05-01 15:57:54 -070068static struct gpiomux_setting atmel_int_sus_cfg = {
69 .func = GPIOMUX_FUNC_GPIO,
70 .drv = GPIOMUX_DRV_2MA,
71 .pull = GPIOMUX_PULL_DOWN,
72};
73
74static struct gpiomux_setting atmel_reset_act_cfg = {
75 .func = GPIOMUX_FUNC_GPIO,
76 .drv = GPIOMUX_DRV_6MA,
77 .pull = GPIOMUX_PULL_UP,
78};
79
80static struct gpiomux_setting atmel_reset_sus_cfg = {
81 .func = GPIOMUX_FUNC_GPIO,
Gilad Avidovf58f1832013-01-09 17:31:28 -070082 .drv = GPIOMUX_DRV_6MA,
83 .pull = GPIOMUX_PULL_DOWN,
84};
85
Figo Wangb1510f82013-06-13 19:40:20 +080086static struct gpiomux_setting focaltech_int_act_cfg = {
87 .func = GPIOMUX_FUNC_GPIO,
88 .drv = GPIOMUX_DRV_8MA,
89 .pull = GPIOMUX_PULL_UP,
90};
91
92static struct gpiomux_setting focaltech_int_sus_cfg = {
93 .func = GPIOMUX_FUNC_GPIO,
94 .drv = GPIOMUX_DRV_2MA,
95 .pull = GPIOMUX_PULL_DOWN,
96};
97
98static struct gpiomux_setting focaltech_reset_act_cfg = {
99 .func = GPIOMUX_FUNC_GPIO,
100 .drv = GPIOMUX_DRV_6MA,
101 .pull = GPIOMUX_PULL_UP,
102};
103
104static struct gpiomux_setting focaltech_reset_sus_cfg = {
105 .func = GPIOMUX_FUNC_GPIO,
106 .drv = GPIOMUX_DRV_6MA,
107 .pull = GPIOMUX_PULL_UP,
108};
109
Sameer Thalappil1fafd672013-04-03 12:31:04 -0700110static struct gpiomux_setting wcnss_5wire_suspend_cfg = {
111 .func = GPIOMUX_FUNC_GPIO,
112 .drv = GPIOMUX_DRV_2MA,
113 .pull = GPIOMUX_PULL_UP,
114};
115
116static struct gpiomux_setting wcnss_5wire_active_cfg = {
117 .func = GPIOMUX_FUNC_1,
118 .drv = GPIOMUX_DRV_6MA,
119 .pull = GPIOMUX_PULL_DOWN,
120};
121
Yue Ma10d88752014-02-20 17:12:05 -0800122static struct gpiomux_setting wcnss_5gpio_suspend_cfg = {
123 .func = GPIOMUX_FUNC_GPIO,
124 .drv = GPIOMUX_DRV_2MA,
125 .pull = GPIOMUX_PULL_UP,
126};
127
128static struct gpiomux_setting wcnss_5gpio_active_cfg = {
129 .func = GPIOMUX_FUNC_GPIO,
130 .drv = GPIOMUX_DRV_6MA,
131 .pull = GPIOMUX_PULL_DOWN,
132};
133
Xiaoming Zhou17972262013-04-10 17:50:35 -0400134static struct gpiomux_setting lcd_en_act_cfg = {
135 .func = GPIOMUX_FUNC_GPIO,
136 .drv = GPIOMUX_DRV_8MA,
137 .pull = GPIOMUX_PULL_NONE,
138 .dir = GPIOMUX_OUT_HIGH,
139};
140
141static struct gpiomux_setting lcd_en_sus_cfg = {
142 .func = GPIOMUX_FUNC_GPIO,
143 .drv = GPIOMUX_DRV_2MA,
144 .pull = GPIOMUX_PULL_DOWN,
145};
146
Xiaoming Zhou8dca7e42013-05-31 19:44:57 -0400147static struct gpiomux_setting lcd_te_act_config = {
148 .func = GPIOMUX_FUNC_1,
149 .drv = GPIOMUX_DRV_2MA,
150 .pull = GPIOMUX_PULL_DOWN,
151 .dir = GPIOMUX_IN,
152};
153
154static struct gpiomux_setting lcd_te_sus_config = {
155 .func = GPIOMUX_FUNC_1,
156 .drv = GPIOMUX_DRV_2MA,
157 .pull = GPIOMUX_PULL_DOWN,
158 .dir = GPIOMUX_IN,
159};
160
Amy Maloche19c386b2013-04-15 14:06:01 -0700161static struct gpiomux_setting gpio_keys_active = {
162 .func = GPIOMUX_FUNC_GPIO,
163 .drv = GPIOMUX_DRV_2MA,
164 .pull = GPIOMUX_PULL_UP,
165};
166
167static struct gpiomux_setting gpio_keys_suspend = {
168 .func = GPIOMUX_FUNC_GPIO,
169 .drv = GPIOMUX_DRV_2MA,
170 .pull = GPIOMUX_PULL_NONE,
171};
172
Richard Liua1d406a2013-04-14 13:46:48 -0700173/* define gpio used as interrupt input */
174static struct gpiomux_setting gpio_int_act_cfg = {
175 .func = GPIOMUX_FUNC_GPIO,
176 .drv = GPIOMUX_DRV_2MA,
177 .pull = GPIOMUX_PULL_UP,
178 .dir = GPIOMUX_IN,
179};
180
181static struct gpiomux_setting gpio_int_sus_cfg = {
182 .func = GPIOMUX_FUNC_GPIO,
183 .drv = GPIOMUX_DRV_2MA,
184 .pull = GPIOMUX_PULL_UP,
185 .dir = GPIOMUX_IN,
186};
187
188static struct msm_gpiomux_config msm_gpio_int_configs[] __initdata = {
189 {
190 .gpio = 84,
191 .settings = {
192 [GPIOMUX_ACTIVE] = &gpio_int_act_cfg,
193 [GPIOMUX_SUSPENDED] = &gpio_int_sus_cfg,
194 },
195 },
196};
197
Xiaoming Zhou17972262013-04-10 17:50:35 -0400198static struct msm_gpiomux_config msm_lcd_configs[] __initdata = {
199 {
200 .gpio = 41,
201 .settings = {
202 [GPIOMUX_ACTIVE] = &lcd_en_act_cfg,
203 [GPIOMUX_SUSPENDED] = &lcd_en_sus_cfg,
204 },
205 },
206 {
207 .gpio = 7,
208 .settings = {
209 [GPIOMUX_ACTIVE] = &lcd_en_act_cfg,
210 [GPIOMUX_SUSPENDED] = &lcd_en_sus_cfg,
211 },
212 },
Xiaoming Zhou8dca7e42013-05-31 19:44:57 -0400213 {
214 .gpio = 12,
215 .settings = {
216 [GPIOMUX_ACTIVE] = &lcd_te_act_config,
217 [GPIOMUX_SUSPENDED] = &lcd_te_sus_config,
218 },
219 },
Xiaoming Zhou17972262013-04-10 17:50:35 -0400220};
221
Gilad Avidovf84f2792013-01-31 13:26:39 -0700222static struct msm_gpiomux_config msm_blsp_configs[] __initdata = {
223 {
Chun Zhangf39a0652013-05-01 15:57:54 -0700224 .gpio = 2, /* BLSP1 QUP1 I2C_SDA */
225 .settings = {
Bingzhe Cai12487222013-09-02 22:37:36 +0800226 [GPIOMUX_ACTIVE] = &gpio_i2c_config,
Chun Zhangf39a0652013-05-01 15:57:54 -0700227 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
228 },
229 },
230 {
231 .gpio = 3, /* BLSP1 QUP1 I2C_SCL */
232 .settings = {
Bingzhe Cai12487222013-09-02 22:37:36 +0800233 [GPIOMUX_ACTIVE] = &gpio_i2c_config,
Chun Zhangf39a0652013-05-01 15:57:54 -0700234 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
235 },
236 },
237 {
Gilad Avidovf58f1832013-01-09 17:31:28 -0700238 .gpio = 10, /* BLSP1 QUP3 I2C_SDA */
Gilad Avidovf84f2792013-01-31 13:26:39 -0700239 .settings = {
Bingzhe Cai12487222013-09-02 22:37:36 +0800240 [GPIOMUX_ACTIVE] = &gpio_i2c_config,
Gilad Avidovf84f2792013-01-31 13:26:39 -0700241 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
242 },
243 },
244 {
Gilad Avidovf58f1832013-01-09 17:31:28 -0700245 .gpio = 11, /* BLSP1 QUP3 I2C_SCL */
Gilad Avidovf84f2792013-01-31 13:26:39 -0700246 .settings = {
Bingzhe Cai12487222013-09-02 22:37:36 +0800247 [GPIOMUX_ACTIVE] = &gpio_i2c_config,
Gilad Avidovf84f2792013-01-31 13:26:39 -0700248 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
249 },
250 },
Gilad Avidovf58f1832013-01-09 17:31:28 -0700251 {
Kenneth Heitke0d4fbb12013-04-10 12:51:14 -0600252 .gpio = 16, /* BLSP1 QUP6 I2C_SDA */
253 .settings = {
Bingzhe Cai12487222013-09-02 22:37:36 +0800254 [GPIOMUX_ACTIVE] = &gpio_cam_i2c_config,
Kenneth Heitke0d4fbb12013-04-10 12:51:14 -0600255 [GPIOMUX_SUSPENDED] = &gpio_cam_i2c_config,
256 },
257 },
258 {
259 .gpio = 17, /* BLSP1 QUP6 I2C_SCL */
260 .settings = {
Bingzhe Cai12487222013-09-02 22:37:36 +0800261 [GPIOMUX_ACTIVE] = &gpio_cam_i2c_config,
Kenneth Heitke0d4fbb12013-04-10 12:51:14 -0600262 [GPIOMUX_SUSPENDED] = &gpio_cam_i2c_config,
263 },
264 },
Bansidhar Gopalacharie331f372013-09-25 19:50:43 +0100265 {
266 .gpio = 78, /* NFC CLK */
267 .settings = {
268 [GPIOMUX_ACTIVE] = &gpio_nfc_config,
269 [GPIOMUX_SUSPENDED] = &gpio_nfc_sus_config,
270 },
271 },
Chun Zhangf39a0652013-05-01 15:57:54 -0700272};
273
Houston Hoffman53421b42013-11-26 16:12:16 -0800274static struct gpiomux_setting gpio_i2c_nfc_pvt_config = {
275 .func = GPIOMUX_FUNC_5, /*active 1*/ /* 0 */
276 .drv = GPIOMUX_DRV_2MA,
277 .pull = GPIOMUX_PULL_NONE,
278 };
279
280static struct msm_gpiomux_config msm_nfc_configs[] __initdata = {
281 {
282 .gpio = 8, /* BLSP1 QUP2 I2C_SDA */
283 .settings = {
284 [GPIOMUX_ACTIVE] = &gpio_i2c_nfc_pvt_config,
285 [GPIOMUX_SUSPENDED] = &gpio_i2c_nfc_pvt_config,
286 },
287 },
288 {
289 .gpio = 9, /* BLSP1 QUP2 I2C_SCL */
290 .settings = {
291 [GPIOMUX_ACTIVE] = &gpio_i2c_nfc_pvt_config,
292 [GPIOMUX_SUSPENDED] = &gpio_i2c_nfc_pvt_config,
293 },
294 },
295};
296
Houston Hoffman1cd68b22013-11-26 17:27:38 -0800297
Chun Zhangf39a0652013-05-01 15:57:54 -0700298static struct msm_gpiomux_config msm_atmel_configs[] __initdata = {
Kenneth Heitke0d4fbb12013-04-10 12:51:14 -0600299 {
Chun Zhangf39a0652013-05-01 15:57:54 -0700300 .gpio = 0, /* TOUCH RESET */
Gilad Avidovf58f1832013-01-09 17:31:28 -0700301 .settings = {
Chun Zhangf39a0652013-05-01 15:57:54 -0700302 [GPIOMUX_ACTIVE] = &atmel_reset_act_cfg,
303 [GPIOMUX_SUSPENDED] = &atmel_reset_sus_cfg,
Gilad Avidovf58f1832013-01-09 17:31:28 -0700304 },
305 },
306 {
Chun Zhangf39a0652013-05-01 15:57:54 -0700307 .gpio = 1, /* TOUCH INT */
Gilad Avidovf58f1832013-01-09 17:31:28 -0700308 .settings = {
Chun Zhangf39a0652013-05-01 15:57:54 -0700309 [GPIOMUX_ACTIVE] = &atmel_int_act_cfg,
310 [GPIOMUX_SUSPENDED] = &atmel_int_sus_cfg,
Gilad Avidovf58f1832013-01-09 17:31:28 -0700311 },
312 },
Gilad Avidova460c472013-04-12 16:23:32 -0600313 {
314 .gpio = 86, /* BLSP1 QUP4 SPI_DATA_MOSI */
315 .settings = {
Sana Venkat Rajue53161a2013-09-17 16:33:26 +0530316 [GPIOMUX_ACTIVE] = &gpio_spi_config,
317 [GPIOMUX_SUSPENDED] = &gpio_spi_susp_config,
Gilad Avidova460c472013-04-12 16:23:32 -0600318 },
319 },
320 {
321 .gpio = 87, /* BLSP1 QUP4 SPI_DATA_MISO */
322 .settings = {
Sana Venkat Rajue53161a2013-09-17 16:33:26 +0530323 [GPIOMUX_ACTIVE] = &gpio_spi_config,
324 [GPIOMUX_SUSPENDED] = &gpio_spi_susp_config,
Gilad Avidova460c472013-04-12 16:23:32 -0600325 },
326 },
327 {
328 .gpio = 89, /* BLSP1 QUP4 SPI_CLK */
329 .settings = {
Sana Venkat Rajue53161a2013-09-17 16:33:26 +0530330 [GPIOMUX_ACTIVE] = &gpio_spi_config,
331 [GPIOMUX_SUSPENDED] = &gpio_spi_susp_config,
Gilad Avidova460c472013-04-12 16:23:32 -0600332 },
333 },
334 {
335 .gpio = 88, /* BLSP1 QUP4 SPI_CS */
336 .settings = {
Sana Venkat Rajue53161a2013-09-17 16:33:26 +0530337 [GPIOMUX_ACTIVE] = &gpio_spi_config,
338 [GPIOMUX_SUSPENDED] = &gpio_spi_susp_config,
Gilad Avidova460c472013-04-12 16:23:32 -0600339 },
340 },
Gilad Avidovf84f2792013-01-31 13:26:39 -0700341};
342
Figo Wangb1510f82013-06-13 19:40:20 +0800343static struct msm_gpiomux_config msm_focaltech_configs[] __initdata = {
344 {
345 .gpio = 0, /* TOUCH RESET */
346 .settings = {
347 [GPIOMUX_ACTIVE] = &focaltech_reset_act_cfg,
348 [GPIOMUX_SUSPENDED] = &focaltech_reset_sus_cfg,
349 },
350 },
351 {
352 .gpio = 1, /* TOUCH INT */
353 .settings = {
354 [GPIOMUX_ACTIVE] = &focaltech_int_act_cfg,
355 [GPIOMUX_SUSPENDED] = &focaltech_int_sus_cfg,
356 },
357 },
358 {
359 .gpio = 86, /* BLSP1 QUP4 SPI_DATA_MOSI */
360 .settings = {
Sana Venkat Rajue53161a2013-09-17 16:33:26 +0530361 [GPIOMUX_ACTIVE] = &gpio_spi_config,
362 [GPIOMUX_SUSPENDED] = &gpio_spi_susp_config,
Figo Wangb1510f82013-06-13 19:40:20 +0800363 },
364 },
365 {
366 .gpio = 87, /* BLSP1 QUP4 SPI_DATA_MISO */
367 .settings = {
Sana Venkat Rajue53161a2013-09-17 16:33:26 +0530368 [GPIOMUX_ACTIVE] = &gpio_spi_config,
369 [GPIOMUX_SUSPENDED] = &gpio_spi_susp_config,
Figo Wangb1510f82013-06-13 19:40:20 +0800370 },
371 },
372 {
373 .gpio = 89, /* BLSP1 QUP4 SPI_CLK */
374 .settings = {
Sana Venkat Rajue53161a2013-09-17 16:33:26 +0530375 [GPIOMUX_ACTIVE] = &gpio_spi_config,
376 [GPIOMUX_SUSPENDED] = &gpio_spi_susp_config,
Figo Wangb1510f82013-06-13 19:40:20 +0800377 },
378 },
379 {
380 .gpio = 88, /* BLSP1 QUP4 SPI_CS */
381 .settings = {
Sana Venkat Rajue53161a2013-09-17 16:33:26 +0530382 [GPIOMUX_ACTIVE] = &gpio_spi_config,
383 [GPIOMUX_SUSPENDED] = &gpio_spi_susp_config,
Figo Wangb1510f82013-06-13 19:40:20 +0800384 },
385 },
386};
387
388
Sameer Thalappil1fafd672013-04-03 12:31:04 -0700389static struct msm_gpiomux_config wcnss_5wire_interface[] = {
390 {
391 .gpio = 23,
392 .settings = {
393 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
394 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
395 },
396 },
397 {
398 .gpio = 24,
399 .settings = {
400 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
401 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
402 },
403 },
404 {
405 .gpio = 25,
406 .settings = {
407 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
408 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
409 },
410 },
411 {
412 .gpio = 26,
413 .settings = {
414 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
415 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
416 },
417 },
418 {
419 .gpio = 27,
420 .settings = {
421 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
422 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
423 },
424 },
425};
426
Yue Ma10d88752014-02-20 17:12:05 -0800427static struct msm_gpiomux_config wcnss_5gpio_interface[] = {
428 {
429 .gpio = 23,
430 .settings = {
431 [GPIOMUX_ACTIVE] = &wcnss_5gpio_active_cfg,
432 [GPIOMUX_SUSPENDED] = &wcnss_5gpio_suspend_cfg,
433 },
434 },
435 {
436 .gpio = 24,
437 .settings = {
438 [GPIOMUX_ACTIVE] = &wcnss_5gpio_active_cfg,
439 [GPIOMUX_SUSPENDED] = &wcnss_5gpio_suspend_cfg,
440 },
441 },
442 {
443 .gpio = 25,
444 .settings = {
445 [GPIOMUX_ACTIVE] = &wcnss_5gpio_active_cfg,
446 [GPIOMUX_SUSPENDED] = &wcnss_5gpio_suspend_cfg,
447 },
448 },
449 {
450 .gpio = 26,
451 .settings = {
452 [GPIOMUX_ACTIVE] = &wcnss_5gpio_active_cfg,
453 [GPIOMUX_SUSPENDED] = &wcnss_5gpio_suspend_cfg,
454 },
455 },
456 {
457 .gpio = 27,
458 .settings = {
459 [GPIOMUX_ACTIVE] = &wcnss_5gpio_active_cfg,
460 [GPIOMUX_SUSPENDED] = &wcnss_5gpio_suspend_cfg,
461 },
462 },
463};
464
Lokesh Kumar Aakulu329a3472013-06-03 06:08:17 -0700465static struct gpiomux_setting gpio_suspend_config[] = {
466 {
467 .func = GPIOMUX_FUNC_GPIO, /* IN-NP */
468 .drv = GPIOMUX_DRV_2MA,
469 .pull = GPIOMUX_PULL_NONE,
470 },
471 {
472 .func = GPIOMUX_FUNC_GPIO, /* O-LOW */
473 .drv = GPIOMUX_DRV_2MA,
474 .pull = GPIOMUX_PULL_NONE,
475 .dir = GPIOMUX_OUT_LOW,
476 },
477};
478
479static struct gpiomux_setting cam_settings[] = {
480 {
481 .func = GPIOMUX_FUNC_1, /*active 1*/ /* 0 */
482 .drv = GPIOMUX_DRV_2MA,
483 .pull = GPIOMUX_PULL_NONE,
484 },
485
486 {
487 .func = GPIOMUX_FUNC_1, /*suspend*/ /* 1 */
488 .drv = GPIOMUX_DRV_2MA,
489 .pull = GPIOMUX_PULL_DOWN,
490 },
491
492 {
493 .func = GPIOMUX_FUNC_1, /*i2c suspend*/ /* 2 */
494 .drv = GPIOMUX_DRV_2MA,
495 .pull = GPIOMUX_PULL_KEEPER,
496 },
497
498 {
499 .func = GPIOMUX_FUNC_GPIO, /*active 0*/ /* 3 */
500 .drv = GPIOMUX_DRV_2MA,
501 .pull = GPIOMUX_PULL_NONE,
502 },
503
504 {
505 .func = GPIOMUX_FUNC_GPIO, /*suspend 0*/ /* 4 */
506 .drv = GPIOMUX_DRV_2MA,
507 .pull = GPIOMUX_PULL_DOWN,
508 },
509};
510
Bingzhe Cai43bed2b2014-01-02 14:07:31 +0800511static struct gpiomux_setting accel_interrupt_config = {
512 .func = GPIOMUX_FUNC_GPIO,
513 .drv = GPIOMUX_DRV_6MA,
514 .pull = GPIOMUX_PULL_DOWN,
515};
516
Houston Hoffman1cd68b22013-11-26 17:27:38 -0800517static struct msm_gpiomux_config msm_non_qrd_configs[] __initdata = {
518 {
519 .gpio = 8, /* CAM1_STANDBY_N */
520 .settings = {
521 [GPIOMUX_ACTIVE] = &cam_settings[3],
522 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1],
523 },
524 },
Bingzhe Cai43bed2b2014-01-02 14:07:31 +0800525 {
526 .gpio = 81, /*ACCEL_INT1 */
527 .settings = {
528 [GPIOMUX_ACTIVE] = &accel_interrupt_config,
529 [GPIOMUX_SUSPENDED] = &accel_interrupt_config,
530 },
531 },
Houston Hoffman1cd68b22013-11-26 17:27:38 -0800532};
533
Lokesh Kumar Aakulu329a3472013-06-03 06:08:17 -0700534static struct msm_gpiomux_config msm_sensor_configs[] __initdata = {
535 {
536 .gpio = 13, /* CAM_MCLK0 */
537 .settings = {
538 [GPIOMUX_ACTIVE] = &cam_settings[0],
539 [GPIOMUX_SUSPENDED] = &cam_settings[1],
540 },
541 },
542 {
543 .gpio = 14, /* CAM_MCLK1 */
544 .settings = {
545 [GPIOMUX_ACTIVE] = &cam_settings[0],
546 [GPIOMUX_SUSPENDED] = &cam_settings[1],
547 },
548 },
549 {
550 .gpio = 16, /* CCI_I2C_SDA */
551 .settings = {
552 [GPIOMUX_ACTIVE] = &cam_settings[0],
553 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[0],
554 },
555 },
556 {
557 .gpio = 17, /* CCI_I2C_SCL */
558 .settings = {
559 [GPIOMUX_ACTIVE] = &cam_settings[0],
560 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[0],
561 },
562 },
563 {
564 .gpio = 18, /* FLASH_LED_EN */
565 .settings = {
Lokesh Kumar Aakulu034626d2013-05-10 20:30:07 -0700566 [GPIOMUX_ACTIVE] = &cam_settings[3],
Lokesh Kumar Aakulu329a3472013-06-03 06:08:17 -0700567 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1],
568 },
569 },
570 {
571 .gpio = 19, /* FLASH_LED_NOW */
572 .settings = {
Lokesh Kumar Aakulu034626d2013-05-10 20:30:07 -0700573 [GPIOMUX_ACTIVE] = &cam_settings[3],
Lokesh Kumar Aakulu329a3472013-06-03 06:08:17 -0700574 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1],
575 },
576 },
577 {
578 .gpio = 8, /* CAM1_STANDBY_N */
579 .settings = {
580 [GPIOMUX_ACTIVE] = &cam_settings[3],
581 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1],
582 },
583 },
584 {
585 .gpio = 15, /* CAM1_RST_N */
586 .settings = {
587 [GPIOMUX_ACTIVE] = &cam_settings[3],
588 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1],
589 },
590 },
591 {
592 .gpio = 20, /* WEBCAM1_STANDBY */
593 .settings = {
594 [GPIOMUX_ACTIVE] = &cam_settings[3],
595 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1],
596 },
597 },
598 {
599 .gpio = 21, /* WEBCAM2_RESET_N */
600 .settings = {
601 [GPIOMUX_ACTIVE] = &cam_settings[3],
602 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1],
603 },
604 },
605};
606
Amy Maloche19c386b2013-04-15 14:06:01 -0700607static struct msm_gpiomux_config msm_keypad_configs[] __initdata = {
608 {
609 .gpio = 72,
610 .settings = {
611 [GPIOMUX_ACTIVE] = &gpio_keys_active,
612 [GPIOMUX_SUSPENDED] = &gpio_keys_suspend,
613 },
614 },
615 {
616 .gpio = 73,
617 .settings = {
618 [GPIOMUX_ACTIVE] = &gpio_keys_active,
619 [GPIOMUX_SUSPENDED] = &gpio_keys_suspend,
620 },
621 },
622 {
623 .gpio = 74,
624 .settings = {
625 [GPIOMUX_ACTIVE] = &gpio_keys_active,
626 [GPIOMUX_SUSPENDED] = &gpio_keys_suspend,
627 },
628 },
629};
630
Venkat Gopalakrishnan8aaf15a2013-04-30 16:27:03 -0700631static struct gpiomux_setting sd_card_det_active_config = {
632 .func = GPIOMUX_FUNC_GPIO,
633 .drv = GPIOMUX_DRV_2MA,
634 .pull = GPIOMUX_PULL_NONE,
635 .dir = GPIOMUX_IN,
636};
637
638static struct gpiomux_setting sd_card_det_suspend_config = {
639 .func = GPIOMUX_FUNC_GPIO,
640 .drv = GPIOMUX_DRV_2MA,
641 .pull = GPIOMUX_PULL_UP,
642 .dir = GPIOMUX_IN,
643};
644
645static struct msm_gpiomux_config sd_card_det[] __initdata = {
646 {
647 .gpio = 42,
648 .settings = {
649 [GPIOMUX_ACTIVE] = &sd_card_det_active_config,
650 [GPIOMUX_SUSPENDED] = &sd_card_det_suspend_config,
651 },
652 },
653};
654
Bingzhe Caife20b712013-07-15 16:48:49 +0800655static struct gpiomux_setting interrupt_gpio_active = {
656 .func = GPIOMUX_FUNC_GPIO,
657 .drv = GPIOMUX_DRV_6MA,
658 .pull = GPIOMUX_PULL_UP,
659};
660
661static struct gpiomux_setting interrupt_gpio_suspend_pullup = {
662 .func = GPIOMUX_FUNC_GPIO,
663 .drv = GPIOMUX_DRV_6MA,
664 .pull = GPIOMUX_PULL_UP,
665};
666
667static struct gpiomux_setting interrupt_gpio_suspend_pulldown = {
668 .func = GPIOMUX_FUNC_GPIO,
669 .drv = GPIOMUX_DRV_6MA,
670 .pull = GPIOMUX_PULL_UP,
671};
672
673static struct msm_gpiomux_config msm_interrupt_configs[] __initdata = {
674 {
Houston Hoffman17f2dc52014-01-29 08:15:06 -0800675 .gpio = 75, /* NFC_CLK_REQ_IRQ*/
676 .settings = {
677 [GPIOMUX_ACTIVE] = &interrupt_gpio_active,
678 [GPIOMUX_SUSPENDED] = &interrupt_gpio_suspend_pullup,
679 },
680 },
681 {
Bingzhe Caife20b712013-07-15 16:48:49 +0800682 .gpio = 77, /* NFC_IRQ */
683 .settings = {
684 [GPIOMUX_ACTIVE] = &interrupt_gpio_active,
685 [GPIOMUX_SUSPENDED] = &interrupt_gpio_suspend_pullup,
686 },
687 },
688 {
Bingzhe Caife20b712013-07-15 16:48:49 +0800689 .gpio = 80, /*ALSP_INT */
690 .settings = {
691 [GPIOMUX_ACTIVE] = &interrupt_gpio_active,
692 [GPIOMUX_SUSPENDED] = &interrupt_gpio_suspend_pullup,
693 },
694 },
695 {
696 .gpio = 81, /*ACCEL_INT1 */
697 .settings = {
698 [GPIOMUX_ACTIVE] = &interrupt_gpio_active,
699 [GPIOMUX_SUSPENDED] = &interrupt_gpio_suspend_pulldown,
700 },
701 },
702 {
703 .gpio = 82, /*ACCEL_INT2 */
704 .settings = {
705 [GPIOMUX_ACTIVE] = &interrupt_gpio_active,
706 [GPIOMUX_SUSPENDED] = &interrupt_gpio_suspend_pulldown,
707 },
708 },
709};
710
Kuirong Wang3ef74f02013-08-02 14:46:45 -0700711static struct gpiomux_setting gpio_cdc_dmic_cfg = {
712 .func = GPIOMUX_FUNC_1,
713 .drv = GPIOMUX_DRV_4MA,
714 .pull = GPIOMUX_PULL_NONE,
715};
716
717
718static struct msm_gpiomux_config msm_cdc_dmic_configs[] __initdata = {
719 {
720 .gpio = 100, /* DMIC CLK */
721 .settings = {
722 [GPIOMUX_SUSPENDED] = &gpio_cdc_dmic_cfg,
723 },
724 },
725 {
726 .gpio = 101, /* DMIC DATA */
727 .settings = {
728 [GPIOMUX_SUSPENDED] = &gpio_cdc_dmic_cfg,
729 },
730 },
731};
732
Pavankumar Kondetied652082014-03-02 14:32:27 +0530733static struct gpiomux_setting ice40_spi_cs_act_config = {
734 .func = GPIOMUX_FUNC_1,
735 .drv = GPIOMUX_DRV_6MA,
736 .pull = GPIOMUX_PULL_NONE,
737};
738
739static struct gpiomux_setting ice40_spi_cs_susp_config = {
740 .func = GPIOMUX_FUNC_GPIO,
741 .drv = GPIOMUX_DRV_6MA,
742 .pull = GPIOMUX_PULL_UP,
743};
744
745static struct gpiomux_setting ice40_act_config = {
746 .func = GPIOMUX_FUNC_GPIO,
747 .drv = GPIOMUX_DRV_8MA,
748 .pull = GPIOMUX_PULL_NONE,
749};
750
751static struct gpiomux_setting ice40_susp_config = {
752 .func = GPIOMUX_FUNC_GPIO,
753 .drv = GPIOMUX_DRV_2MA,
754 .pull = GPIOMUX_PULL_NONE,
755};
756
757static struct msm_gpiomux_config ice40_spi_usb_configs[] __initdata = {
758 {
759 .gpio = 85,
760 .settings = {
761 [GPIOMUX_ACTIVE] = &ice40_spi_cs_act_config,
762 [GPIOMUX_SUSPENDED] = &ice40_spi_cs_susp_config,
763 },
764 },
765 {
766 .gpio = 94,
767 .settings = {
768 [GPIOMUX_ACTIVE] = &ice40_act_config,
769 [GPIOMUX_SUSPENDED] = &ice40_susp_config,
770 },
771 },
772 {
773 .gpio = 95,
774 .settings = {
775 [GPIOMUX_ACTIVE] = &ice40_act_config,
776 [GPIOMUX_SUSPENDED] = &ice40_susp_config,
777 },
778 },
779 {
780 .gpio = 96,
781 .settings = {
782 [GPIOMUX_ACTIVE] = &ice40_act_config,
783 [GPIOMUX_SUSPENDED] = &ice40_susp_config,
784 },
785 },
786};
787
Syed Rameez Mustafa3971c142013-01-09 19:04:53 -0800788void __init msm8610_init_gpiomux(void)
Hanumant Singh55a1bb02012-11-06 10:01:15 -0800789{
790 int rc;
791
Rohit Vaswani341c2032012-11-08 18:49:29 -0800792 rc = msm_gpiomux_init_dt();
Hanumant Singh55a1bb02012-11-06 10:01:15 -0800793 if (rc) {
Rohit Vaswani341c2032012-11-08 18:49:29 -0800794 pr_err("%s failed %d\n", __func__, rc);
Hanumant Singh55a1bb02012-11-06 10:01:15 -0800795 return;
796 }
Gilad Avidovf84f2792013-01-31 13:26:39 -0700797
798 msm_gpiomux_install(msm_blsp_configs, ARRAY_SIZE(msm_blsp_configs));
Figo Wangb1510f82013-06-13 19:40:20 +0800799 if (of_board_is_qrd()) {
800 msm_gpiomux_install(msm_focaltech_configs,
801 ARRAY_SIZE(msm_focaltech_configs));
802 } else {
803 msm_gpiomux_install(msm_atmel_configs,
Chun Zhangf39a0652013-05-01 15:57:54 -0700804 ARRAY_SIZE(msm_atmel_configs));
Figo Wangb1510f82013-06-13 19:40:20 +0800805 }
Sameer Thalappil1fafd672013-04-03 12:31:04 -0700806 msm_gpiomux_install(wcnss_5wire_interface,
807 ARRAY_SIZE(wcnss_5wire_interface));
Xiaoming Zhoua329c942013-07-10 10:32:20 -0400808 msm_gpiomux_install_nowrite(msm_lcd_configs,
809 ARRAY_SIZE(msm_lcd_configs));
Amy Maloche19c386b2013-04-15 14:06:01 -0700810 msm_gpiomux_install(msm_keypad_configs,
811 ARRAY_SIZE(msm_keypad_configs));
Venkat Gopalakrishnan8aaf15a2013-04-30 16:27:03 -0700812 msm_gpiomux_install(sd_card_det, ARRAY_SIZE(sd_card_det));
Lokesh Kumar Aakulu329a3472013-06-03 06:08:17 -0700813 msm_gpiomux_install(msm_sensor_configs, ARRAY_SIZE(msm_sensor_configs));
Richard Liua1d406a2013-04-14 13:46:48 -0700814 msm_gpiomux_install(msm_gpio_int_configs,
815 ARRAY_SIZE(msm_gpio_int_configs));
Houston Hoffman53421b42013-11-26 16:12:16 -0800816 if (of_board_is_qrd()) {
Bingzhe Caife20b712013-07-15 16:48:49 +0800817 msm_gpiomux_install(msm_interrupt_configs,
818 ARRAY_SIZE(msm_interrupt_configs));
Houston Hoffman53421b42013-11-26 16:12:16 -0800819 msm_gpiomux_install(msm_nfc_configs,
820 ARRAY_SIZE(msm_nfc_configs));
Houston Hoffman1cd68b22013-11-26 17:27:38 -0800821 } else {
822 msm_gpiomux_install(msm_non_qrd_configs,
823 ARRAY_SIZE(msm_non_qrd_configs));
Houston Hoffman53421b42013-11-26 16:12:16 -0800824 }
Kuirong Wang3ef74f02013-08-02 14:46:45 -0700825 if (of_board_is_cdp())
826 msm_gpiomux_install(msm_cdc_dmic_configs,
827 ARRAY_SIZE(msm_cdc_dmic_configs));
Pavankumar Kondetied652082014-03-02 14:32:27 +0530828
829 if (of_board_is_cdp())
830 msm_gpiomux_install(ice40_spi_usb_configs,
831 ARRAY_SIZE(ice40_spi_usb_configs));
Hanumant Singh55a1bb02012-11-06 10:01:15 -0800832}
Yue Ma10d88752014-02-20 17:12:05 -0800833
834static void wcnss_switch_to_gpio(void)
835{
836 /* Switch MUX to GPIO */
837 msm_gpiomux_install(wcnss_5gpio_interface,
838 ARRAY_SIZE(wcnss_5gpio_interface));
839
840 /* Ensure GPIO config */
841 gpio_direction_input(WLAN_DATA2);
842 gpio_direction_input(WLAN_DATA1);
843 gpio_direction_input(WLAN_DATA0);
844 gpio_direction_output(WLAN_SET, 0);
845 gpio_direction_output(WLAN_CLK, 0);
846}
847
848static void wcnss_switch_to_5wire(void)
849{
850 msm_gpiomux_install(wcnss_5wire_interface,
851 ARRAY_SIZE(wcnss_5wire_interface));
852}
853
854u32 wcnss_rf_read_reg(u32 rf_reg_addr)
855{
856 int count = 0;
857 u32 rf_cmd_and_addr = 0;
858 u32 rf_data_received = 0;
859 u32 rf_bit = 0;
860
861 wcnss_switch_to_gpio();
862
863 /* Reset the signal if it is already being used. */
864 gpio_set_value(WLAN_SET, 0);
865 gpio_set_value(WLAN_CLK, 0);
866
867 /* We start with cmd_set high WLAN_SET = 1. */
868 gpio_set_value(WLAN_SET, 1);
869
870 gpio_direction_output(WLAN_DATA0, 1);
871 gpio_direction_output(WLAN_DATA1, 1);
872 gpio_direction_output(WLAN_DATA2, 1);
873
874 gpio_set_value(WLAN_DATA0, 0);
875 gpio_set_value(WLAN_DATA1, 0);
876 gpio_set_value(WLAN_DATA2, 0);
877
878 /* Prepare command and RF register address that need to sent out.
879 * Make sure that we send only 14 bits from LSB.
880 */
881 rf_cmd_and_addr = (((WLAN_RF_READ_REG_CMD) |
882 (rf_reg_addr << WLAN_RF_REG_ADDR_START_OFFSET)) &
883 WLAN_RF_READ_CMD_MASK);
884
885 for (count = 0; count < 5; count++) {
886 gpio_set_value(WLAN_CLK, 0);
887
888 rf_bit = (rf_cmd_and_addr & 0x1);
889 gpio_set_value(WLAN_DATA0, rf_bit ? 1 : 0);
890 rf_cmd_and_addr = (rf_cmd_and_addr >> 1);
891
892 rf_bit = (rf_cmd_and_addr & 0x1);
893 gpio_set_value(WLAN_DATA1, rf_bit ? 1 : 0);
894 rf_cmd_and_addr = (rf_cmd_and_addr >> 1);
895
896 rf_bit = (rf_cmd_and_addr & 0x1);
897 gpio_set_value(WLAN_DATA2, rf_bit ? 1 : 0);
898 rf_cmd_and_addr = (rf_cmd_and_addr >> 1);
899
900 /* Send the data out WLAN_CLK = 1 */
901 gpio_set_value(WLAN_CLK, 1);
902 }
903
904 /* Pull down the clock signal */
905 gpio_set_value(WLAN_CLK, 0);
906
907 /* Configure data pins to input IO pins */
908 gpio_direction_input(WLAN_DATA0);
909 gpio_direction_input(WLAN_DATA1);
910 gpio_direction_input(WLAN_DATA2);
911
912 for (count = 0; count < 2; count++) {
913 gpio_set_value(WLAN_CLK, 1);
914 gpio_set_value(WLAN_CLK, 0);
915 }
916
917 rf_bit = 0;
918 for (count = 0; count < 6; count++) {
919 gpio_set_value(WLAN_CLK, 1);
920 gpio_set_value(WLAN_CLK, 0);
921
922 rf_bit = gpio_get_value(WLAN_DATA0);
923 rf_data_received |= (rf_bit << (count * 3 + 0));
924
925 if (count != 5) {
926 rf_bit = gpio_get_value(WLAN_DATA1);
927 rf_data_received |= (rf_bit << (count * 3 + 1));
928
929 rf_bit = gpio_get_value(WLAN_DATA2);
930 rf_data_received |= (rf_bit << (count * 3 + 2));
931 }
932 }
933
934 gpio_set_value(WLAN_SET, 0);
935 wcnss_switch_to_5wire();
936
937 return rf_data_received;
938}