blob: 819ca5634b0b057bb158cc9aaa66299fa78f9c96 [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>
19
aiquny76b46082013-03-13 15:58:08 -070020#define KS8851_IRQ_GPIO 115
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -080021
22#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
23static struct gpiomux_setting gpio_eth_config = {
24 .pull = GPIOMUX_PULL_UP,
25 .drv = GPIOMUX_DRV_2MA,
26 .func = GPIOMUX_FUNC_GPIO,
27};
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -080028
29static struct msm_gpiomux_config msm_eth_configs[] = {
30 {
31 .gpio = KS8851_IRQ_GPIO,
32 .settings = {
33 [GPIOMUX_SUSPENDED] = &gpio_eth_config,
34 }
35 },
36};
Gilad Avidov28e18eb2012-11-21 18:13:25 -070037#endif
38
Amy Maloche41708ba2013-03-03 15:19:27 -080039static struct gpiomux_setting synaptics_int_act_cfg = {
40 .func = GPIOMUX_FUNC_GPIO,
41 .drv = GPIOMUX_DRV_8MA,
42 .pull = GPIOMUX_PULL_UP,
43};
44
45static struct gpiomux_setting synaptics_int_sus_cfg = {
46 .func = GPIOMUX_FUNC_GPIO,
47 .drv = GPIOMUX_DRV_2MA,
48 .pull = GPIOMUX_PULL_DOWN,
49};
50
51static struct gpiomux_setting synaptics_reset_act_cfg = {
52 .func = GPIOMUX_FUNC_GPIO,
53 .drv = GPIOMUX_DRV_6MA,
54 .pull = GPIOMUX_PULL_DOWN,
55};
56
57static struct gpiomux_setting synaptics_reset_sus_cfg = {
58 .func = GPIOMUX_FUNC_GPIO,
59 .drv = GPIOMUX_DRV_6MA,
60 .pull = GPIOMUX_PULL_DOWN,
61};
62
Amy Maloche24c59dd2013-03-05 11:43:55 -080063static struct gpiomux_setting gpio_keys_active = {
64 .func = GPIOMUX_FUNC_GPIO,
65 .drv = GPIOMUX_DRV_2MA,
66 .pull = GPIOMUX_PULL_UP,
67};
68
69static struct gpiomux_setting gpio_keys_suspend = {
70 .func = GPIOMUX_FUNC_GPIO,
71 .drv = GPIOMUX_DRV_2MA,
72 .pull = GPIOMUX_PULL_NONE,
73};
74
Gilad Avidov28e18eb2012-11-21 18:13:25 -070075static struct gpiomux_setting gpio_spi_config = {
76 .func = GPIOMUX_FUNC_1,
77 .drv = GPIOMUX_DRV_8MA,
78 .pull = GPIOMUX_PULL_NONE,
79};
80
Gilad Avidovd59217c2013-02-01 13:45:59 -070081static struct gpiomux_setting gpio_spi_cs_config = {
82 .func = GPIOMUX_FUNC_1,
83 .drv = GPIOMUX_DRV_6MA,
84 .pull = GPIOMUX_PULL_DOWN,
85};
86
aiquny76b46082013-03-13 15:58:08 -070087static struct gpiomux_setting gpio_spi_cs_eth_config = {
88 .func = GPIOMUX_FUNC_4,
89 .drv = GPIOMUX_DRV_6MA,
90 .pull = GPIOMUX_PULL_DOWN,
91};
92
Sheng Fang6746c3f2013-03-19 08:37:13 +080093static struct gpiomux_setting wcnss_5wire_suspend_cfg = {
94 .func = GPIOMUX_FUNC_GPIO,
95 .drv = GPIOMUX_DRV_2MA,
96 .pull = GPIOMUX_PULL_UP,
97};
98
99static struct gpiomux_setting wcnss_5wire_active_cfg = {
100 .func = GPIOMUX_FUNC_1,
101 .drv = GPIOMUX_DRV_6MA,
102 .pull = GPIOMUX_PULL_DOWN,
103};
104
Gilad Avidov28e18eb2012-11-21 18:13:25 -0700105static struct gpiomux_setting gpio_i2c_config = {
106 .func = GPIOMUX_FUNC_3,
107 .drv = GPIOMUX_DRV_2MA,
108 .pull = GPIOMUX_PULL_NONE,
109};
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800110
Amy Maloche24c59dd2013-03-05 11:43:55 -0800111static struct msm_gpiomux_config msm_keypad_configs[] __initdata = {
112 {
113 .gpio = 106,
114 .settings = {
115 [GPIOMUX_ACTIVE] = &gpio_keys_active,
116 [GPIOMUX_SUSPENDED] = &gpio_keys_suspend,
117 },
118 },
119 {
120 .gpio = 107,
121 .settings = {
122 [GPIOMUX_ACTIVE] = &gpio_keys_active,
123 [GPIOMUX_SUSPENDED] = &gpio_keys_suspend,
124 },
125 },
126 {
127 .gpio = 108,
128 .settings = {
129 [GPIOMUX_ACTIVE] = &gpio_keys_active,
130 [GPIOMUX_SUSPENDED] = &gpio_keys_suspend,
131 },
132 },
133};
134
Aravind Venkateswaranf60fb212013-03-08 13:57:06 -0800135static struct gpiomux_setting lcd_rst_act_cfg = {
136 .func = GPIOMUX_FUNC_GPIO,
137 .drv = GPIOMUX_DRV_8MA,
138 .pull = GPIOMUX_PULL_NONE,
139 .dir = GPIOMUX_OUT_LOW,
140};
141
142static struct gpiomux_setting lcd_rst_sus_cfg = {
143 .func = GPIOMUX_FUNC_GPIO,
144 .drv = GPIOMUX_DRV_2MA,
145 .pull = GPIOMUX_PULL_DOWN,
146};
147
148static struct msm_gpiomux_config msm_lcd_configs[] __initdata = {
149 {
150 .gpio = 25,
151 .settings = {
152 [GPIOMUX_ACTIVE] = &lcd_rst_act_cfg,
153 [GPIOMUX_SUSPENDED] = &lcd_rst_sus_cfg,
154 },
155 }
156};
157
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800158static struct msm_gpiomux_config msm_blsp_configs[] __initdata = {
159 {
Gilad Avidovd59217c2013-02-01 13:45:59 -0700160 .gpio = 0, /* BLSP1 QUP1 SPI_DATA_MOSI */
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800161 .settings = {
162 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
163 },
164 },
165 {
Gilad Avidovd59217c2013-02-01 13:45:59 -0700166 .gpio = 1, /* BLSP1 QUP1 SPI_DATA_MISO */
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800167 .settings = {
168 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
169 },
170 },
171 {
Gilad Avidovd59217c2013-02-01 13:45:59 -0700172 .gpio = 2, /* BLSP1 QUP1 SPI_CS1 */
173 .settings = {
174 [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config,
175 },
176 },
177 {
178 .gpio = 3, /* BLSP1 QUP1 SPI_CLK */
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800179 .settings = {
180 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
181 },
182 },
183 {
Gilad Avidovd59217c2013-02-01 13:45:59 -0700184 .gpio = 14, /* BLSP1 QUP4 I2C_SDA */
Gilad Avidov28e18eb2012-11-21 18:13:25 -0700185 .settings = {
186 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
187 },
188 },
189 {
Gilad Avidovd59217c2013-02-01 13:45:59 -0700190 .gpio = 15, /* BLSP1 QUP4 I2C_SCL */
Gilad Avidov28e18eb2012-11-21 18:13:25 -0700191 .settings = {
192 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
193 },
194 },
Amy Maloche41708ba2013-03-03 15:19:27 -0800195 {
196 .gpio = 18, /* BLSP1 QUP5 I2C_SDA */
197 .settings = {
198 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
199 },
200 },
201 {
202 .gpio = 19, /* BLSP1 QUP5 I2C_SCL */
203 .settings = {
204 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
205 },
206 },
aiquny76b46082013-03-13 15:58:08 -0700207 {
208 .gpio = 22, /* BLSP1 QUP1 SPI_CS_ETH */
209 .settings = {
210 [GPIOMUX_SUSPENDED] = &gpio_spi_cs_eth_config,
211 },
212 },
Amy Maloche41708ba2013-03-03 15:19:27 -0800213};
214
215static struct msm_gpiomux_config msm_synaptics_configs[] __initdata = {
216 {
217 .gpio = 16,
218 .settings = {
219 [GPIOMUX_ACTIVE] = &synaptics_reset_act_cfg,
220 [GPIOMUX_SUSPENDED] = &synaptics_reset_sus_cfg,
221 },
222 },
223 {
224 .gpio = 17,
225 .settings = {
226 [GPIOMUX_ACTIVE] = &synaptics_int_act_cfg,
227 [GPIOMUX_SUSPENDED] = &synaptics_int_sus_cfg,
228 },
229 },
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800230};
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800231
Krishna Konda7af5df92013-03-06 20:35:30 -0800232static struct gpiomux_setting sd_card_det_active_config = {
233 .func = GPIOMUX_FUNC_GPIO,
234 .drv = GPIOMUX_DRV_2MA,
235 .pull = GPIOMUX_PULL_NONE,
236 .dir = GPIOMUX_IN,
237};
238
239static struct gpiomux_setting sd_card_det_sleep_config = {
240 .func = GPIOMUX_FUNC_GPIO,
241 .drv = GPIOMUX_DRV_2MA,
242 .pull = GPIOMUX_PULL_UP,
243 .dir = GPIOMUX_IN,
244};
245
246static struct msm_gpiomux_config sd_card_det __initdata = {
247 .gpio = 38,
248 .settings = {
249 [GPIOMUX_ACTIVE] = &sd_card_det_active_config,
250 [GPIOMUX_SUSPENDED] = &sd_card_det_sleep_config,
251 },
252};
253
Sheng Fang6746c3f2013-03-19 08:37:13 +0800254static struct msm_gpiomux_config wcnss_5wire_interface[] = {
255 {
256 .gpio = 40,
257 .settings = {
258 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
259 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
260 },
261 },
262 {
263 .gpio = 41,
264 .settings = {
265 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
266 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
267 },
268 },
269 {
270 .gpio = 42,
271 .settings = {
272 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
273 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
274 },
275 },
276 {
277 .gpio = 43,
278 .settings = {
279 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
280 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
281 },
282 },
283 {
284 .gpio = 44,
285 .settings = {
286 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
287 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
288 },
289 },
290};
Su Liud1c66ee2013-03-22 15:29:48 -0700291
292static struct gpiomux_setting gpio_suspend_config[] = {
293 {
294 .func = GPIOMUX_FUNC_GPIO, /* IN-NP */
295 .drv = GPIOMUX_DRV_2MA,
296 .pull = GPIOMUX_PULL_NONE,
297 },
298 {
299 .func = GPIOMUX_FUNC_GPIO, /* O-LOW */
300 .drv = GPIOMUX_DRV_2MA,
301 .pull = GPIOMUX_PULL_NONE,
302 .dir = GPIOMUX_OUT_LOW,
303 },
304};
305
306static struct gpiomux_setting cam_settings[] = {
307 {
308 .func = GPIOMUX_FUNC_1, /*active 1*/ /* 0 */
309 .drv = GPIOMUX_DRV_2MA,
310 .pull = GPIOMUX_PULL_NONE,
311 },
312
313 {
314 .func = GPIOMUX_FUNC_1, /*suspend*/ /* 1 */
315 .drv = GPIOMUX_DRV_2MA,
316 .pull = GPIOMUX_PULL_DOWN,
317 },
318
319 {
320 .func = GPIOMUX_FUNC_1, /*i2c suspend*/ /* 2 */
321 .drv = GPIOMUX_DRV_2MA,
322 .pull = GPIOMUX_PULL_KEEPER,
323 },
324
325 {
326 .func = GPIOMUX_FUNC_GPIO, /*active 0*/ /* 3 */
327 .drv = GPIOMUX_DRV_2MA,
328 .pull = GPIOMUX_PULL_NONE,
329 },
330
331 {
332 .func = GPIOMUX_FUNC_GPIO, /*suspend 0*/ /* 4 */
333 .drv = GPIOMUX_DRV_2MA,
334 .pull = GPIOMUX_PULL_DOWN,
335 },
336};
337
338
339static struct msm_gpiomux_config msm_sensor_configs[] __initdata = {
340 {
341 .gpio = 26, /* CAM_MCLK0 */
342 .settings = {
343 [GPIOMUX_ACTIVE] = &cam_settings[0],
344 [GPIOMUX_SUSPENDED] = &cam_settings[1],
345 },
346 },
347 {
348 .gpio = 27, /* CAM_MCLK1 */
349 .settings = {
350 [GPIOMUX_ACTIVE] = &cam_settings[0],
351 [GPIOMUX_SUSPENDED] = &cam_settings[1],
352 },
353
354 },
355 {
356 .gpio = 29, /* CCI_I2C_SDA0 */
357 .settings = {
358 [GPIOMUX_ACTIVE] = &cam_settings[0],
359 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[0],
360 },
361 },
362 {
363 .gpio = 30, /* CCI_I2C_SCL0 */
364 .settings = {
365 [GPIOMUX_ACTIVE] = &cam_settings[0],
366 [GPIOMUX_SUSPENDED] = &gpio_suspend_config[0],
367 },
368 },
369 {
370 .gpio = 36, /* CAM1_STANDBY_N */
371 .settings = {
372 [GPIOMUX_ACTIVE] = &cam_settings[3],
373 [GPIOMUX_SUSPENDED] = &cam_settings[4],
374 },
375 },
376 {
377 .gpio = 37, /* CAM1_RST_N */
378 .settings = {
379 [GPIOMUX_ACTIVE] = &cam_settings[3],
380 [GPIOMUX_SUSPENDED] = &cam_settings[4],
381 },
382 },
383 {
384 .gpio = 35, /* CAM2_STANDBY_N */
385 .settings = {
386 [GPIOMUX_ACTIVE] = &cam_settings[3],
387 [GPIOMUX_SUSPENDED] = &cam_settings[4],
388 },
389 },
390 {
391 .gpio = 28, /* CAM2_RST_N */
392 .settings = {
393 [GPIOMUX_ACTIVE] = &cam_settings[3],
394 [GPIOMUX_SUSPENDED] = &cam_settings[4],
395 },
396 },
397
398};
399
Syed Rameez Mustafa9d16c4f2012-09-10 14:16:55 -0700400void __init msm8226_init_gpiomux(void)
401{
402 int rc;
403
Rohit Vaswani341c2032012-11-08 18:49:29 -0800404 rc = msm_gpiomux_init_dt();
Syed Rameez Mustafa9d16c4f2012-09-10 14:16:55 -0700405 if (rc) {
Rohit Vaswani341c2032012-11-08 18:49:29 -0800406 pr_err("%s failed %d\n", __func__, rc);
Syed Rameez Mustafa9d16c4f2012-09-10 14:16:55 -0700407 return;
408 }
Gilad Avidov28e18eb2012-11-21 18:13:25 -0700409
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800410#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
411 msm_gpiomux_install(msm_eth_configs, ARRAY_SIZE(msm_eth_configs));
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800412#endif
Amy Maloche24c59dd2013-03-05 11:43:55 -0800413 msm_gpiomux_install(msm_keypad_configs,
414 ARRAY_SIZE(msm_keypad_configs));
Gilad Avidov28e18eb2012-11-21 18:13:25 -0700415
416 msm_gpiomux_install(msm_blsp_configs, ARRAY_SIZE(msm_blsp_configs));
Sheng Fang6746c3f2013-03-19 08:37:13 +0800417 msm_gpiomux_install(wcnss_5wire_interface,
418 ARRAY_SIZE(wcnss_5wire_interface));
Krishna Konda7af5df92013-03-06 20:35:30 -0800419
420 msm_gpiomux_install(&sd_card_det, 1);
Amy Maloche41708ba2013-03-03 15:19:27 -0800421 msm_gpiomux_install(msm_synaptics_configs,
422 ARRAY_SIZE(msm_synaptics_configs));
Aravind Venkateswaranf60fb212013-03-08 13:57:06 -0800423 msm_gpiomux_install_nowrite(msm_lcd_configs,
424 ARRAY_SIZE(msm_lcd_configs));
Su Liud1c66ee2013-03-22 15:29:48 -0700425 msm_gpiomux_install(msm_sensor_configs, ARRAY_SIZE(msm_sensor_configs));
Syed Rameez Mustafa9d16c4f2012-09-10 14:16:55 -0700426}