blob: 0b456e2d00e8c7f20e75aeb8935f38525c6bb46f [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
Amy Maloche19c386b2013-04-15 14:06:01 -070087static struct gpiomux_setting gpio_keys_active = {
88 .func = GPIOMUX_FUNC_GPIO,
89 .drv = GPIOMUX_DRV_2MA,
90 .pull = GPIOMUX_PULL_UP,
91};
92
93static struct gpiomux_setting gpio_keys_suspend = {
94 .func = GPIOMUX_FUNC_GPIO,
95 .drv = GPIOMUX_DRV_2MA,
96 .pull = GPIOMUX_PULL_NONE,
97};
98
Xiaoming Zhou17972262013-04-10 17:50:35 -040099static struct msm_gpiomux_config msm_lcd_configs[] __initdata = {
100 {
101 .gpio = 41,
102 .settings = {
103 [GPIOMUX_ACTIVE] = &lcd_en_act_cfg,
104 [GPIOMUX_SUSPENDED] = &lcd_en_sus_cfg,
105 },
106 },
107 {
108 .gpio = 7,
109 .settings = {
110 [GPIOMUX_ACTIVE] = &lcd_en_act_cfg,
111 [GPIOMUX_SUSPENDED] = &lcd_en_sus_cfg,
112 },
113 },
114};
115
Gilad Avidovf84f2792013-01-31 13:26:39 -0700116static struct msm_gpiomux_config msm_blsp_configs[] __initdata = {
117 {
Chun Zhangf39a0652013-05-01 15:57:54 -0700118 .gpio = 2, /* BLSP1 QUP1 I2C_SDA */
119 .settings = {
120 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
121 },
122 },
123 {
124 .gpio = 3, /* BLSP1 QUP1 I2C_SCL */
125 .settings = {
126 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
127 },
128 },
129 {
Gilad Avidovf58f1832013-01-09 17:31:28 -0700130 .gpio = 10, /* BLSP1 QUP3 I2C_SDA */
Gilad Avidovf84f2792013-01-31 13:26:39 -0700131 .settings = {
132 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
133 },
134 },
135 {
Gilad Avidovf58f1832013-01-09 17:31:28 -0700136 .gpio = 11, /* BLSP1 QUP3 I2C_SCL */
Gilad Avidovf84f2792013-01-31 13:26:39 -0700137 .settings = {
138 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
139 },
140 },
Gilad Avidovf58f1832013-01-09 17:31:28 -0700141 {
Kenneth Heitke0d4fbb12013-04-10 12:51:14 -0600142 .gpio = 16, /* BLSP1 QUP6 I2C_SDA */
143 .settings = {
144 [GPIOMUX_SUSPENDED] = &gpio_cam_i2c_config,
145 },
146 },
147 {
148 .gpio = 17, /* BLSP1 QUP6 I2C_SCL */
149 .settings = {
150 [GPIOMUX_SUSPENDED] = &gpio_cam_i2c_config,
151 },
152 },
Chun Zhangf39a0652013-05-01 15:57:54 -0700153};
154
155static struct msm_gpiomux_config msm_atmel_configs[] __initdata = {
Kenneth Heitke0d4fbb12013-04-10 12:51:14 -0600156 {
Chun Zhangf39a0652013-05-01 15:57:54 -0700157 .gpio = 0, /* TOUCH RESET */
Gilad Avidovf58f1832013-01-09 17:31:28 -0700158 .settings = {
Chun Zhangf39a0652013-05-01 15:57:54 -0700159 [GPIOMUX_ACTIVE] = &atmel_reset_act_cfg,
160 [GPIOMUX_SUSPENDED] = &atmel_reset_sus_cfg,
Gilad Avidovf58f1832013-01-09 17:31:28 -0700161 },
162 },
163 {
Chun Zhangf39a0652013-05-01 15:57:54 -0700164 .gpio = 1, /* TOUCH INT */
Gilad Avidovf58f1832013-01-09 17:31:28 -0700165 .settings = {
Chun Zhangf39a0652013-05-01 15:57:54 -0700166 [GPIOMUX_ACTIVE] = &atmel_int_act_cfg,
167 [GPIOMUX_SUSPENDED] = &atmel_int_sus_cfg,
Gilad Avidovf58f1832013-01-09 17:31:28 -0700168 },
169 },
Gilad Avidova460c472013-04-12 16:23:32 -0600170 {
171 .gpio = 86, /* BLSP1 QUP4 SPI_DATA_MOSI */
172 .settings = {
173 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
174 },
175 },
176 {
177 .gpio = 87, /* BLSP1 QUP4 SPI_DATA_MISO */
178 .settings = {
179 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
180 },
181 },
182 {
183 .gpio = 89, /* BLSP1 QUP4 SPI_CLK */
184 .settings = {
185 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
186 },
187 },
188 {
189 .gpio = 88, /* BLSP1 QUP4 SPI_CS */
190 .settings = {
191 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
192 },
193 },
Gilad Avidovf84f2792013-01-31 13:26:39 -0700194};
195
Sameer Thalappil1fafd672013-04-03 12:31:04 -0700196static struct msm_gpiomux_config wcnss_5wire_interface[] = {
197 {
198 .gpio = 23,
199 .settings = {
200 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
201 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
202 },
203 },
204 {
205 .gpio = 24,
206 .settings = {
207 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
208 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
209 },
210 },
211 {
212 .gpio = 25,
213 .settings = {
214 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
215 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
216 },
217 },
218 {
219 .gpio = 26,
220 .settings = {
221 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
222 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
223 },
224 },
225 {
226 .gpio = 27,
227 .settings = {
228 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
229 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
230 },
231 },
232};
233
Lokesh Kumar Aakulu329a3472013-06-03 06:08:17 -0700234static struct gpiomux_setting gpio_suspend_config[] = {
235 {
236 .func = GPIOMUX_FUNC_GPIO, /* IN-NP */
237 .drv = GPIOMUX_DRV_2MA,
238 .pull = GPIOMUX_PULL_NONE,
239 },
240 {
241 .func = GPIOMUX_FUNC_GPIO, /* O-LOW */
242 .drv = GPIOMUX_DRV_2MA,
243 .pull = GPIOMUX_PULL_NONE,
244 .dir = GPIOMUX_OUT_LOW,
245 },
246};
247
248static struct gpiomux_setting cam_settings[] = {
249 {
250 .func = GPIOMUX_FUNC_1, /*active 1*/ /* 0 */
251 .drv = GPIOMUX_DRV_2MA,
252 .pull = GPIOMUX_PULL_NONE,
253 },
254
255 {
256 .func = GPIOMUX_FUNC_1, /*suspend*/ /* 1 */
257 .drv = GPIOMUX_DRV_2MA,
258 .pull = GPIOMUX_PULL_DOWN,
259 },
260
261 {
262 .func = GPIOMUX_FUNC_1, /*i2c suspend*/ /* 2 */
263 .drv = GPIOMUX_DRV_2MA,
264 .pull = GPIOMUX_PULL_KEEPER,
265 },
266
267 {
268 .func = GPIOMUX_FUNC_GPIO, /*active 0*/ /* 3 */
269 .drv = GPIOMUX_DRV_2MA,
270 .pull = GPIOMUX_PULL_NONE,
271 },
272
273 {
274 .func = GPIOMUX_FUNC_GPIO, /*suspend 0*/ /* 4 */
275 .drv = GPIOMUX_DRV_2MA,
276 .pull = GPIOMUX_PULL_DOWN,
277 },
278};
279
280static struct msm_gpiomux_config msm_sensor_configs[] __initdata = {
281 {
282 .gpio = 13, /* CAM_MCLK0 */
283 .settings = {
284 [GPIOMUX_ACTIVE] = &cam_settings[0],
285 [GPIOMUX_SUSPENDED] = &cam_settings[1],
286 },
287 },
288 {
289 .gpio = 14, /* CAM_MCLK1 */
290 .settings = {
291 [GPIOMUX_ACTIVE] = &cam_settings[0],
292 [GPIOMUX_SUSPENDED] = &cam_settings[1],
293 },
294 },
295 {
296 .gpio = 16, /* CCI_I2C_SDA */
297 .settings = {
298 [GPIOMUX_ACTIVE] = &cam_settings[0],
299 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[0],
300 },
301 },
302 {
303 .gpio = 17, /* CCI_I2C_SCL */
304 .settings = {
305 [GPIOMUX_ACTIVE] = &cam_settings[0],
306 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[0],
307 },
308 },
309 {
310 .gpio = 18, /* FLASH_LED_EN */
311 .settings = {
312 [GPIOMUX_ACTIVE] = &cam_settings[0],
313 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1],
314 },
315 },
316 {
317 .gpio = 19, /* FLASH_LED_NOW */
318 .settings = {
319 [GPIOMUX_ACTIVE] = &cam_settings[0],
320 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1],
321 },
322 },
323 {
324 .gpio = 8, /* CAM1_STANDBY_N */
325 .settings = {
326 [GPIOMUX_ACTIVE] = &cam_settings[3],
327 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1],
328 },
329 },
330 {
331 .gpio = 15, /* CAM1_RST_N */
332 .settings = {
333 [GPIOMUX_ACTIVE] = &cam_settings[3],
334 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1],
335 },
336 },
337 {
338 .gpio = 20, /* WEBCAM1_STANDBY */
339 .settings = {
340 [GPIOMUX_ACTIVE] = &cam_settings[3],
341 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1],
342 },
343 },
344 {
345 .gpio = 21, /* WEBCAM2_RESET_N */
346 .settings = {
347 [GPIOMUX_ACTIVE] = &cam_settings[3],
348 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1],
349 },
350 },
351};
352
Amy Maloche19c386b2013-04-15 14:06:01 -0700353static struct msm_gpiomux_config msm_keypad_configs[] __initdata = {
354 {
355 .gpio = 72,
356 .settings = {
357 [GPIOMUX_ACTIVE] = &gpio_keys_active,
358 [GPIOMUX_SUSPENDED] = &gpio_keys_suspend,
359 },
360 },
361 {
362 .gpio = 73,
363 .settings = {
364 [GPIOMUX_ACTIVE] = &gpio_keys_active,
365 [GPIOMUX_SUSPENDED] = &gpio_keys_suspend,
366 },
367 },
368 {
369 .gpio = 74,
370 .settings = {
371 [GPIOMUX_ACTIVE] = &gpio_keys_active,
372 [GPIOMUX_SUSPENDED] = &gpio_keys_suspend,
373 },
374 },
375};
376
Venkat Gopalakrishnan8aaf15a2013-04-30 16:27:03 -0700377static struct gpiomux_setting sd_card_det_active_config = {
378 .func = GPIOMUX_FUNC_GPIO,
379 .drv = GPIOMUX_DRV_2MA,
380 .pull = GPIOMUX_PULL_NONE,
381 .dir = GPIOMUX_IN,
382};
383
384static struct gpiomux_setting sd_card_det_suspend_config = {
385 .func = GPIOMUX_FUNC_GPIO,
386 .drv = GPIOMUX_DRV_2MA,
387 .pull = GPIOMUX_PULL_UP,
388 .dir = GPIOMUX_IN,
389};
390
391static struct msm_gpiomux_config sd_card_det[] __initdata = {
392 {
393 .gpio = 42,
394 .settings = {
395 [GPIOMUX_ACTIVE] = &sd_card_det_active_config,
396 [GPIOMUX_SUSPENDED] = &sd_card_det_suspend_config,
397 },
398 },
399};
400
Syed Rameez Mustafa3971c142013-01-09 19:04:53 -0800401void __init msm8610_init_gpiomux(void)
Hanumant Singh55a1bb02012-11-06 10:01:15 -0800402{
403 int rc;
404
Rohit Vaswani341c2032012-11-08 18:49:29 -0800405 rc = msm_gpiomux_init_dt();
Hanumant Singh55a1bb02012-11-06 10:01:15 -0800406 if (rc) {
Rohit Vaswani341c2032012-11-08 18:49:29 -0800407 pr_err("%s failed %d\n", __func__, rc);
Hanumant Singh55a1bb02012-11-06 10:01:15 -0800408 return;
409 }
Gilad Avidovf84f2792013-01-31 13:26:39 -0700410
411 msm_gpiomux_install(msm_blsp_configs, ARRAY_SIZE(msm_blsp_configs));
Chun Zhangf39a0652013-05-01 15:57:54 -0700412 msm_gpiomux_install(msm_atmel_configs,
413 ARRAY_SIZE(msm_atmel_configs));
Sameer Thalappil1fafd672013-04-03 12:31:04 -0700414 msm_gpiomux_install(wcnss_5wire_interface,
415 ARRAY_SIZE(wcnss_5wire_interface));
Xiaoming Zhou17972262013-04-10 17:50:35 -0400416 msm_gpiomux_install(msm_lcd_configs, ARRAY_SIZE(msm_lcd_configs));
Amy Maloche19c386b2013-04-15 14:06:01 -0700417 msm_gpiomux_install(msm_keypad_configs,
418 ARRAY_SIZE(msm_keypad_configs));
Venkat Gopalakrishnan8aaf15a2013-04-30 16:27:03 -0700419 msm_gpiomux_install(sd_card_det, ARRAY_SIZE(sd_card_det));
Lokesh Kumar Aakulu329a3472013-06-03 06:08:17 -0700420 msm_gpiomux_install(msm_sensor_configs, ARRAY_SIZE(msm_sensor_configs));
Hanumant Singh55a1bb02012-11-06 10:01:15 -0800421}