blob: 62b7f1711d1879718b92955773af3c717f72f37a [file] [log] [blame]
Stepan Moskovchenko5ea3c312012-01-31 18:19:40 -08001/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
Stepan Moskovchenko2327a952011-12-14 16:31:28 -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 <linux/platform_device.h>
17#include <linux/bootmem.h>
18#include <asm/mach-types.h>
19#include <asm/mach/mmc.h>
20#include <mach/msm_bus_board.h>
21#include <mach/board.h>
22#include <mach/gpio.h>
23#include <mach/gpiomux.h>
Joel Kingdacbc822012-01-25 13:30:57 -080024#include <mach/socinfo.h>
Stepan Moskovchenko2327a952011-12-14 16:31:28 -080025#include "devices.h"
26#include "board-8064.h"
27
28#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
29static struct gpiomux_setting gpio_eth_config = {
30 .pull = GPIOMUX_PULL_NONE,
31 .drv = GPIOMUX_DRV_8MA,
32 .func = GPIOMUX_FUNC_GPIO,
33};
34
35/* The SPI configurations apply to GSBI 5*/
36static struct gpiomux_setting gpio_spi_config = {
37 .func = GPIOMUX_FUNC_2,
Stepan Moskovchenkoc71c9792012-01-31 18:12:44 -080038 .drv = GPIOMUX_DRV_12MA,
Stepan Moskovchenko2327a952011-12-14 16:31:28 -080039 .pull = GPIOMUX_PULL_NONE,
40};
41
42/* The SPI configurations apply to GSBI 5 chip select 2*/
43static struct gpiomux_setting gpio_spi_cs2_config = {
44 .func = GPIOMUX_FUNC_3,
Stepan Moskovchenkoc71c9792012-01-31 18:12:44 -080045 .drv = GPIOMUX_DRV_12MA,
Stepan Moskovchenko2327a952011-12-14 16:31:28 -080046 .pull = GPIOMUX_PULL_NONE,
47};
48
Stepan Moskovchenkoc71c9792012-01-31 18:12:44 -080049/* Chip selects for SPI clients */
50static struct gpiomux_setting gpio_spi_cs_config = {
51 .func = GPIOMUX_FUNC_GPIO,
52 .drv = GPIOMUX_DRV_12MA,
53 .pull = GPIOMUX_PULL_UP,
54};
55
Stepan Moskovchenko2327a952011-12-14 16:31:28 -080056struct msm_gpiomux_config apq8064_ethernet_configs[] = {
57 {
58 .gpio = 43,
59 .settings = {
60 [GPIOMUX_SUSPENDED] = &gpio_eth_config,
61 [GPIOMUX_ACTIVE] = &gpio_eth_config,
62 }
63 },
64};
65#endif
66
Swaminathan Sathappancef966d2011-12-15 17:27:04 -080067static struct gpiomux_setting cdc_mclk = {
68 .func = GPIOMUX_FUNC_1,
69 .drv = GPIOMUX_DRV_8MA,
70 .pull = GPIOMUX_PULL_NONE,
71};
72
Stepan Moskovchenko2327a952011-12-14 16:31:28 -080073static struct gpiomux_setting audio_auxpcm[] = {
74 /* Suspended state */
75 {
76 .func = GPIOMUX_FUNC_GPIO,
77 .drv = GPIOMUX_DRV_2MA,
78 .pull = GPIOMUX_PULL_NONE,
79 },
80 /* Active state */
81 {
82 .func = GPIOMUX_FUNC_1,
83 .drv = GPIOMUX_DRV_2MA,
84 .pull = GPIOMUX_PULL_NONE,
85 },
86};
87
Swaminathan Sathappancef966d2011-12-15 17:27:04 -080088static struct gpiomux_setting slimbus = {
89 .func = GPIOMUX_FUNC_1,
90 .drv = GPIOMUX_DRV_8MA,
91 .pull = GPIOMUX_PULL_KEEPER,
92};
93
Stepan Moskovchenko5ea3c312012-01-31 18:19:40 -080094static struct gpiomux_setting gsbi1_uart_config = {
95 .func = GPIOMUX_FUNC_1,
96 .drv = GPIOMUX_DRV_16MA,
97 .pull = GPIOMUX_PULL_NONE,
98};
99
David Collinsf0d00732012-01-25 15:46:50 -0800100static struct gpiomux_setting ext_regulator_config = {
101 .func = GPIOMUX_FUNC_GPIO,
102 .drv = GPIOMUX_DRV_8MA,
103 .pull = GPIOMUX_PULL_NONE,
104 .dir = GPIOMUX_OUT_LOW,
105};
106
Jin Hong4bbbfba2012-02-02 21:48:07 -0800107static struct gpiomux_setting gsbi7_func1_cfg = {
108 .func = GPIOMUX_FUNC_1,
109 .drv = GPIOMUX_DRV_8MA,
110 .pull = GPIOMUX_PULL_NONE,
111};
112
113static struct gpiomux_setting gsbi7_func2_cfg = {
114 .func = GPIOMUX_FUNC_2,
115 .drv = GPIOMUX_DRV_8MA,
116 .pull = GPIOMUX_PULL_NONE,
117};
118
Jing Lin04601f92012-02-05 15:36:07 -0800119static struct gpiomux_setting gsbi3_suspended_cfg = {
120 .func = GPIOMUX_FUNC_1,
121 .drv = GPIOMUX_DRV_2MA,
122 .pull = GPIOMUX_PULL_KEEPER,
123};
124
125static struct gpiomux_setting gsbi3_active_cfg = {
126 .func = GPIOMUX_FUNC_1,
127 .drv = GPIOMUX_DRV_8MA,
128 .pull = GPIOMUX_PULL_NONE,
129};
130
Hemant Kumara945b472012-01-25 15:08:06 -0800131#ifdef CONFIG_USB_EHCI_MSM_HSIC
132static struct gpiomux_setting hsic_act_cfg = {
133 .func = GPIOMUX_FUNC_1,
134 .drv = GPIOMUX_DRV_8MA,
135 .pull = GPIOMUX_PULL_NONE,
136};
137
138static struct gpiomux_setting hsic_sus_cfg = {
139 .func = GPIOMUX_FUNC_GPIO,
140 .drv = GPIOMUX_DRV_2MA,
141 .pull = GPIOMUX_PULL_DOWN,
142 .dir = GPIOMUX_OUT_LOW,
143};
144
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -0800145static struct gpiomux_setting cyts_resout_sus_cfg = {
146 .func = GPIOMUX_FUNC_GPIO,
147 .drv = GPIOMUX_DRV_6MA,
148 .pull = GPIOMUX_PULL_UP,
149};
150
151static struct gpiomux_setting cyts_resout_act_cfg = {
152 .func = GPIOMUX_FUNC_GPIO,
153 .drv = GPIOMUX_DRV_6MA,
154 .pull = GPIOMUX_PULL_UP,
155};
156
157static struct gpiomux_setting cyts_sleep_sus_cfg = {
158 .func = GPIOMUX_FUNC_GPIO,
159 .drv = GPIOMUX_DRV_6MA,
160 .pull = GPIOMUX_PULL_DOWN,
161};
162
163static struct gpiomux_setting cyts_sleep_act_cfg = {
164 .func = GPIOMUX_FUNC_GPIO,
165 .drv = GPIOMUX_DRV_6MA,
166 .pull = GPIOMUX_PULL_DOWN,
167};
168
169static struct gpiomux_setting cyts_int_act_cfg = {
170 .func = GPIOMUX_FUNC_GPIO,
171 .drv = GPIOMUX_DRV_8MA,
172 .pull = GPIOMUX_PULL_UP,
173};
174
175static struct gpiomux_setting cyts_int_sus_cfg = {
176 .func = GPIOMUX_FUNC_GPIO,
177 .drv = GPIOMUX_DRV_2MA,
178 .pull = GPIOMUX_PULL_DOWN,
179};
180
181static struct msm_gpiomux_config cyts_gpio_configs[] __initdata = {
182 { /* TS INTERRUPT */
183 .gpio = 6,
184 .settings = {
185 [GPIOMUX_ACTIVE] = &cyts_int_act_cfg,
186 [GPIOMUX_SUSPENDED] = &cyts_int_sus_cfg,
187 },
188 },
189 { /* TS SLEEP */
190 .gpio = 33,
191 .settings = {
192 [GPIOMUX_ACTIVE] = &cyts_sleep_act_cfg,
193 [GPIOMUX_SUSPENDED] = &cyts_sleep_sus_cfg,
194 },
195 },
196 { /* TS RESOUT */
197 .gpio = 7,
198 .settings = {
199 [GPIOMUX_ACTIVE] = &cyts_resout_act_cfg,
200 [GPIOMUX_SUSPENDED] = &cyts_resout_sus_cfg,
201 },
202 },
203};
204
Hemant Kumara945b472012-01-25 15:08:06 -0800205static struct msm_gpiomux_config apq8064_hsic_configs[] = {
206 {
207 .gpio = 88, /*HSIC_STROBE */
208 .settings = {
209 [GPIOMUX_ACTIVE] = &hsic_act_cfg,
210 [GPIOMUX_SUSPENDED] = &hsic_sus_cfg,
211 },
212 },
213 {
214 .gpio = 89, /* HSIC_DATA */
215 .settings = {
216 [GPIOMUX_ACTIVE] = &hsic_act_cfg,
217 [GPIOMUX_SUSPENDED] = &hsic_sus_cfg,
218 },
219 },
220};
221#endif
222
Jing Lin21ed4de2012-02-05 15:53:28 -0800223static struct gpiomux_setting mxt_reset_sus_cfg = {
224 .func = GPIOMUX_FUNC_GPIO,
225 .drv = GPIOMUX_DRV_6MA,
226 .pull = GPIOMUX_PULL_DOWN,
227};
228
229static struct gpiomux_setting mxt_reset_act_cfg = {
230 .func = GPIOMUX_FUNC_GPIO,
231 .drv = GPIOMUX_DRV_6MA,
232 .pull = GPIOMUX_PULL_UP,
233};
234
235static struct gpiomux_setting mxt_int_sus_cfg = {
236 .func = GPIOMUX_FUNC_GPIO,
237 .drv = GPIOMUX_DRV_2MA,
238 .pull = GPIOMUX_PULL_DOWN,
239};
240
241static struct gpiomux_setting mxt_int_act_cfg = {
242 .func = GPIOMUX_FUNC_GPIO,
243 .drv = GPIOMUX_DRV_8MA,
244 .pull = GPIOMUX_PULL_UP,
245};
246
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800247static struct msm_gpiomux_config apq8064_gsbi_configs[] __initdata = {
Stepan Moskovchenko5ea3c312012-01-31 18:19:40 -0800248 {
Jing Lin04601f92012-02-05 15:36:07 -0800249 .gpio = 8, /* GSBI3 I2C QUP SDA */
250 .settings = {
251 [GPIOMUX_SUSPENDED] = &gsbi3_suspended_cfg,
252 [GPIOMUX_ACTIVE] = &gsbi3_active_cfg,
253 },
254 },
255 {
256 .gpio = 9, /* GSBI3 I2C QUP SCL */
257 .settings = {
258 [GPIOMUX_SUSPENDED] = &gsbi3_suspended_cfg,
259 [GPIOMUX_ACTIVE] = &gsbi3_active_cfg,
260 },
261 },
262 {
Stepan Moskovchenko5ea3c312012-01-31 18:19:40 -0800263 .gpio = 18, /* GSBI1 UART TX */
264 .settings = {
265 [GPIOMUX_SUSPENDED] = &gsbi1_uart_config,
266 },
267 },
268 {
269 .gpio = 19, /* GSBI1 UART RX */
270 .settings = {
271 [GPIOMUX_SUSPENDED] = &gsbi1_uart_config,
272 },
273 },
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800274#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
275 {
276 .gpio = 51, /* GSBI5 QUP SPI_DATA_MOSI */
277 .settings = {
278 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
279 },
280 },
281 {
282 .gpio = 52, /* GSBI5 QUP SPI_DATA_MISO */
283 .settings = {
284 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
285 },
286 },
287 {
Stepan Moskovchenkoc71c9792012-01-31 18:12:44 -0800288 .gpio = 53, /* Funny CS0 */
289 .settings = {
290 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
291 },
292 },
293 {
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800294 .gpio = 31, /* GSBI5 QUP SPI_CS2_N */
295 .settings = {
296 [GPIOMUX_SUSPENDED] = &gpio_spi_cs2_config,
297 },
298 },
299 {
300 .gpio = 54, /* GSBI5 QUP SPI_CLK */
301 .settings = {
302 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
303 },
304 },
305#endif
Stepan Moskovchenkoc71c9792012-01-31 18:12:44 -0800306 {
307 .gpio = 30, /* FP CS */
308 .settings = {
309 [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config,
310 },
311 },
312 {
313 .gpio = 32, /* EPM CS */
314 .settings = {
315 [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config,
316 },
317 },
318 {
319 .gpio = 53, /* NOR CS */
320 .settings = {
321 [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config,
322 },
323 },
Jin Hong4bbbfba2012-02-02 21:48:07 -0800324 {
325 .gpio = 82, /* GSBI7 UART2 TX */
326 .settings = {
327 [GPIOMUX_SUSPENDED] = &gsbi7_func2_cfg,
328 },
329 },
330 {
331 .gpio = 83, /* GSBI7 UART2 RX */
332 .settings = {
333 [GPIOMUX_SUSPENDED] = &gsbi7_func1_cfg,
334 },
335 },
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800336};
337
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800338static struct msm_gpiomux_config apq8064_slimbus_config[] __initdata = {
339 {
340 .gpio = 40, /* slimbus clk */
341 .settings = {
342 [GPIOMUX_SUSPENDED] = &slimbus,
343 },
344 },
345 {
346 .gpio = 41, /* slimbus data */
347 .settings = {
348 [GPIOMUX_SUSPENDED] = &slimbus,
349 },
350 },
351};
352
353static struct msm_gpiomux_config apq8064_audio_codec_configs[] __initdata = {
354 {
355 .gpio = 39,
356 .settings = {
357 [GPIOMUX_SUSPENDED] = &cdc_mclk,
358 },
359 },
360};
361
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800362static struct msm_gpiomux_config apq8064_audio_auxpcm_configs[] __initdata = {
363 {
364 .gpio = 43,
365 .settings = {
366 [GPIOMUX_SUSPENDED] = &audio_auxpcm[0],
367 [GPIOMUX_ACTIVE] = &audio_auxpcm[1],
368 },
369 },
370 {
371 .gpio = 44,
372 .settings = {
373 [GPIOMUX_SUSPENDED] = &audio_auxpcm[0],
374 [GPIOMUX_ACTIVE] = &audio_auxpcm[1],
375 },
376 },
377 {
378 .gpio = 45,
379 .settings = {
380 [GPIOMUX_SUSPENDED] = &audio_auxpcm[0],
381 [GPIOMUX_ACTIVE] = &audio_auxpcm[1],
382 },
383 },
384 {
385 .gpio = 46,
386 .settings = {
387 [GPIOMUX_SUSPENDED] = &audio_auxpcm[0],
388 [GPIOMUX_ACTIVE] = &audio_auxpcm[1],
389 },
390 },
391};
392
David Collinsf0d00732012-01-25 15:46:50 -0800393/* External 3.3 V regulator enable */
394static struct msm_gpiomux_config apq8064_ext_regulator_configs[] __initdata = {
395 {
396 .gpio = APQ8064_EXT_3P3V_REG_EN_GPIO,
397 .settings = {
398 [GPIOMUX_SUSPENDED] = &ext_regulator_config,
399 },
400 },
401};
402
Joel Kingdacbc822012-01-25 13:30:57 -0800403static struct gpiomux_setting ap2mdm_cfg = {
404 .func = GPIOMUX_FUNC_GPIO,
405 .drv = GPIOMUX_DRV_8MA,
406 .pull = GPIOMUX_PULL_DOWN,
407};
408
409static struct gpiomux_setting mdm2ap_status_cfg = {
410 .func = GPIOMUX_FUNC_GPIO,
411 .drv = GPIOMUX_DRV_8MA,
412 .pull = GPIOMUX_PULL_NONE,
413};
414
415static struct gpiomux_setting mdm2ap_errfatal_cfg = {
416 .func = GPIOMUX_FUNC_GPIO,
417 .drv = GPIOMUX_DRV_16MA,
418 .pull = GPIOMUX_PULL_DOWN,
419};
420
421static struct gpiomux_setting ap2mdm_pon_reset_n_cfg = {
422 .func = GPIOMUX_FUNC_GPIO,
423 .drv = GPIOMUX_DRV_8MA,
424 .pull = GPIOMUX_PULL_DOWN,
425};
426
427static struct msm_gpiomux_config mdm_configs[] __initdata = {
428 /* AP2MDM_STATUS */
429 {
430 .gpio = 48,
431 .settings = {
432 [GPIOMUX_SUSPENDED] = &ap2mdm_cfg,
433 }
434 },
435 /* MDM2AP_STATUS */
436 {
437 .gpio = 49,
438 .settings = {
439 [GPIOMUX_SUSPENDED] = &mdm2ap_status_cfg,
440 }
441 },
442 /* MDM2AP_ERRFATAL */
443 {
444 .gpio = 19,
445 .settings = {
446 [GPIOMUX_SUSPENDED] = &mdm2ap_errfatal_cfg,
447 }
448 },
449 /* AP2MDM_ERRFATAL */
450 {
451 .gpio = 18,
452 .settings = {
453 [GPIOMUX_SUSPENDED] = &ap2mdm_cfg,
454 }
455 },
456 /* AP2MDM_PON_RESET_N */
457 {
458 .gpio = 27,
459 .settings = {
460 [GPIOMUX_SUSPENDED] = &ap2mdm_pon_reset_n_cfg,
461 }
462 }
463};
464
Jing Lin21ed4de2012-02-05 15:53:28 -0800465static struct msm_gpiomux_config apq8064_mxt_configs[] __initdata = {
466 { /* TS INTERRUPT */
467 .gpio = 6,
468 .settings = {
469 [GPIOMUX_ACTIVE] = &mxt_int_act_cfg,
470 [GPIOMUX_SUSPENDED] = &mxt_int_sus_cfg,
471 },
472 },
473 { /* TS RESET */
474 .gpio = 33,
475 .settings = {
476 [GPIOMUX_ACTIVE] = &mxt_reset_act_cfg,
477 [GPIOMUX_SUSPENDED] = &mxt_reset_sus_cfg,
478 },
479 },
480};
481
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800482void __init apq8064_init_gpiomux(void)
483{
484 int rc;
485
486 rc = msm_gpiomux_init(NR_GPIO_IRQS);
487 if (rc) {
488 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
489 return;
490 }
491
492#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
493 msm_gpiomux_install(apq8064_ethernet_configs,
494 ARRAY_SIZE(apq8064_ethernet_configs));
495#endif
496
497 msm_gpiomux_install(apq8064_gsbi_configs,
498 ARRAY_SIZE(apq8064_gsbi_configs));
499
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800500 msm_gpiomux_install(apq8064_slimbus_config,
501 ARRAY_SIZE(apq8064_slimbus_config));
502
503 msm_gpiomux_install(apq8064_audio_codec_configs,
504 ARRAY_SIZE(apq8064_audio_codec_configs));
505
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800506 msm_gpiomux_install(apq8064_audio_auxpcm_configs,
507 ARRAY_SIZE(apq8064_audio_auxpcm_configs));
David Collinsf0d00732012-01-25 15:46:50 -0800508
509 msm_gpiomux_install(apq8064_ext_regulator_configs,
510 ARRAY_SIZE(apq8064_ext_regulator_configs));
Joel Kingdacbc822012-01-25 13:30:57 -0800511
512 if (machine_is_apq8064_mtp())
513 msm_gpiomux_install(mdm_configs,
514 ARRAY_SIZE(mdm_configs));
Hemant Kumara945b472012-01-25 15:08:06 -0800515
Anirudh Ghayal2917a5a2012-02-05 19:51:07 -0800516 if (machine_is_apq8064_mtp())
517 msm_gpiomux_install(cyts_gpio_configs,
518 ARRAY_SIZE(cyts_gpio_configs));
519
Hemant Kumara945b472012-01-25 15:08:06 -0800520#ifdef CONFIG_USB_EHCI_MSM_HSIC
521 msm_gpiomux_install(apq8064_hsic_configs,
522 ARRAY_SIZE(apq8064_hsic_configs));
523#endif
Jing Lin21ed4de2012-02-05 15:53:28 -0800524
525 if (machine_is_apq8064_cdp() || machine_is_apq8064_liquid())
526 msm_gpiomux_install(apq8064_mxt_configs,
527 ARRAY_SIZE(apq8064_mxt_configs));
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800528}