blob: 402e7f4a44d36cbc85e218c86ae0dd788f8815b3 [file] [log] [blame]
Duy Truong790f06d2013-02-13 16:38:12 -08001/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
Rohit Vaswania6815892011-12-15 20:20:39 -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>
Steve Mucklef132c6c2012-06-06 18:30:57 -070015#include <linux/gpio.h>
Rohit Vaswania6815892011-12-15 20:20:39 -080016#include <mach/gpiomux.h>
17#include <mach/board.h>
Rohit Vaswania6815892011-12-15 20:20:39 -080018#include "board-9615.h"
19
20static struct gpiomux_setting ps_hold = {
21 .func = GPIOMUX_FUNC_1,
22 .drv = GPIOMUX_DRV_8MA,
23 .pull = GPIOMUX_PULL_NONE,
24};
25
Sagar Dharia2a5378d2011-12-01 20:00:11 -070026static struct gpiomux_setting slimbus = {
27 .func = GPIOMUX_FUNC_2,
28 .drv = GPIOMUX_DRV_8MA,
29 .pull = GPIOMUX_PULL_KEEPER,
30};
31
Rohit Vaswania6815892011-12-15 20:20:39 -080032static struct gpiomux_setting gsbi4 = {
33 .func = GPIOMUX_FUNC_1,
34 .drv = GPIOMUX_DRV_8MA,
35 .pull = GPIOMUX_PULL_NONE,
36};
37
38static struct gpiomux_setting gsbi5 = {
39 .func = GPIOMUX_FUNC_1,
Damir Didjusto6b3e1b52012-11-08 23:16:36 -080040 .drv = GPIOMUX_DRV_2MA,
Rohit Vaswania6815892011-12-15 20:20:39 -080041 .pull = GPIOMUX_PULL_NONE,
42};
43
44static struct gpiomux_setting gsbi3 = {
45 .func = GPIOMUX_FUNC_1,
46 .drv = GPIOMUX_DRV_8MA,
47 .pull = GPIOMUX_PULL_NONE,
48};
49
50static struct gpiomux_setting gsbi3_cs1_config = {
51 .func = GPIOMUX_FUNC_4,
52 .drv = GPIOMUX_DRV_8MA,
53 .pull = GPIOMUX_PULL_NONE,
54};
55
56#ifdef CONFIG_LTC4088_CHARGER
57static struct gpiomux_setting ltc4088_chg_cfg = {
58 .func = GPIOMUX_FUNC_GPIO,
59 .drv = GPIOMUX_DRV_8MA,
60 .pull = GPIOMUX_PULL_NONE,
61};
62#endif
63
64static struct gpiomux_setting sdcc2_clk_actv_cfg = {
65 .func = GPIOMUX_FUNC_1,
66 .drv = GPIOMUX_DRV_16MA,
67 .pull = GPIOMUX_PULL_NONE,
68};
69
70static struct gpiomux_setting sdcc2_cmd_data_0_3_actv_cfg = {
71 .func = GPIOMUX_FUNC_1,
72 .drv = GPIOMUX_DRV_8MA,
73 .pull = GPIOMUX_PULL_UP,
74};
75
76static struct gpiomux_setting sdcc2_suspend_cfg = {
77 .func = GPIOMUX_FUNC_1,
78 .drv = GPIOMUX_DRV_2MA,
79 .pull = GPIOMUX_PULL_DOWN,
80};
81
Shiv Maliyappanahalli9ec55e92012-01-09 14:44:59 -080082static struct gpiomux_setting cdc_mclk = {
83 .func = GPIOMUX_FUNC_1,
84 .drv = GPIOMUX_DRV_8MA,
85 .pull = GPIOMUX_PULL_NONE,
86};
87
Zhang Chang Kena48794b2012-03-31 17:45:21 -040088#ifdef CONFIG_FB_MSM_EBI2
89static struct gpiomux_setting ebi2_lcdc_a_d = {
90 .func = GPIOMUX_FUNC_2,
91 .drv = GPIOMUX_DRV_12MA,
92 .pull = GPIOMUX_PULL_DOWN,
93};
94
95static struct gpiomux_setting ebi2_lcdc_cs = {
96 .func = GPIOMUX_FUNC_2,
97 .drv = GPIOMUX_DRV_12MA,
98 .pull = GPIOMUX_PULL_UP,
99};
100
101static struct gpiomux_setting ebi2_lcdc_rs = {
102 .func = GPIOMUX_FUNC_3,
103 .drv = GPIOMUX_DRV_12MA,
104 .pull = GPIOMUX_PULL_DOWN,
105};
106#endif
107
Pavan Kumar27556502012-05-21 18:38:01 -0700108static struct gpiomux_setting wlan_active_config = {
109 .func = GPIOMUX_FUNC_GPIO,
110 .drv = GPIOMUX_DRV_2MA,
111 .pull = GPIOMUX_PULL_NONE,
112 .dir = GPIOMUX_OUT_LOW,
113};
114
115static struct gpiomux_setting wlan_suspend_config = {
116 .func = GPIOMUX_FUNC_GPIO,
117 .drv = GPIOMUX_DRV_2MA,
118 .pull = GPIOMUX_PULL_NONE,
119 .dir = GPIOMUX_IN,
120};
121
Joonwoo Park187e9cb2012-08-24 22:47:53 -0700122static struct gpiomux_setting tabla_reset = {
123 .func = GPIOMUX_FUNC_GPIO,
124 .drv = GPIOMUX_DRV_6MA,
125 .pull = GPIOMUX_PULL_NONE,
126 .dir = GPIOMUX_OUT_LOW,
127};
128
Shiv Maliyappanahalli9ec55e92012-01-09 14:44:59 -0800129static struct msm_gpiomux_config msm9615_audio_codec_configs[] __initdata = {
130 {
131 .gpio = 24,
132 .settings = {
133 [GPIOMUX_SUSPENDED] = &cdc_mclk,
134 },
135 },
Joonwoo Park187e9cb2012-08-24 22:47:53 -0700136 {
137 .gpio = 84, /* SYS_RST_N */
138 .settings = {
139 [GPIOMUX_SUSPENDED] = &tabla_reset,
140 },
141 }
Shiv Maliyappanahalli9ec55e92012-01-09 14:44:59 -0800142};
143
Rohit Vaswania6815892011-12-15 20:20:39 -0800144static struct msm_gpiomux_config msm9615_sdcc2_configs[] __initdata = {
145 {
146 /* SDC2_DATA_0 */
147 .gpio = 25,
148 .settings = {
149 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
150 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
151 },
152 },
153 {
154 /* SDC2_DATA_1 */
155 .gpio = 26,
156 .settings = {
157 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
158 [GPIOMUX_SUSPENDED] = &sdcc2_cmd_data_0_3_actv_cfg,
159 },
160 },
161 {
162 /* SDC2_DATA_2 */
163 .gpio = 27,
164 .settings = {
165 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
166 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
167 },
168 },
169 {
170 /* SDC2_DATA_3 */
171 .gpio = 28,
172 .settings = {
173 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
174 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
175 },
176 },
177 {
178 /* SDC2_CMD */
179 .gpio = 29,
180 .settings = {
181 [GPIOMUX_ACTIVE] = &sdcc2_cmd_data_0_3_actv_cfg,
182 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
183 },
184 },
185 {
186 /* SDC2_CLK */
187 .gpio = 30,
188 .settings = {
189 [GPIOMUX_ACTIVE] = &sdcc2_clk_actv_cfg,
190 [GPIOMUX_SUSPENDED] = &sdcc2_suspend_cfg,
191 },
192 },
193};
194
195struct msm_gpiomux_config msm9615_ps_hold_config[] __initdata = {
196 {
197 .gpio = 83,
198 .settings = {
199 [GPIOMUX_SUSPENDED] = &ps_hold,
200 },
201 },
202};
203
Subhash Jadavani737ce552012-11-02 22:09:13 +0530204static struct gpiomux_setting sd_card_det = {
205 .func = GPIOMUX_FUNC_GPIO,
206 .drv = GPIOMUX_DRV_2MA,
207 .pull = GPIOMUX_PULL_NONE,
208 .dir = GPIOMUX_IN,
209};
210
211struct msm_gpiomux_config sd_card_det_config[] __initdata = {
212 {
213 .gpio = 80,
214 .settings = {
215 [GPIOMUX_ACTIVE] = &sd_card_det,
216 [GPIOMUX_SUSPENDED] = &sd_card_det,
217 },
218 },
219};
220
Rohit Vaswania6815892011-12-15 20:20:39 -0800221#ifdef CONFIG_LTC4088_CHARGER
222static struct msm_gpiomux_config
223 msm9615_ltc4088_charger_config[] __initdata = {
224 {
225 .gpio = 4,
226 .settings = {
227 [GPIOMUX_SUSPENDED] = &ltc4088_chg_cfg,
228 },
229 },
230 {
231 .gpio = 6,
232 .settings = {
233 [GPIOMUX_SUSPENDED] = &ltc4088_chg_cfg,
234 },
235 },
236 {
237 .gpio = 7,
238 .settings = {
239 [GPIOMUX_SUSPENDED] = &ltc4088_chg_cfg,
240 },
241 },
242};
243#endif
244
245struct msm_gpiomux_config msm9615_gsbi_configs[] __initdata = {
246 {
247 .gpio = 8, /* GSBI3 QUP SPI_CLK */
248 .settings = {
249 [GPIOMUX_SUSPENDED] = &gsbi3,
250 },
251 },
252 {
253 .gpio = 9, /* GSBI3 QUP SPI_CS_N */
254 .settings = {
255 [GPIOMUX_SUSPENDED] = &gsbi3,
256 },
257 },
258 {
259 .gpio = 10, /* GSBI3 QUP SPI_DATA_MISO */
260 .settings = {
261 [GPIOMUX_SUSPENDED] = &gsbi3,
262 },
263 },
264 {
265 .gpio = 11, /* GSBI3 QUP SPI_DATA_MOSI */
266 .settings = {
267 [GPIOMUX_SUSPENDED] = &gsbi3,
268 },
269 },
270 {
271 .gpio = 12, /* GSBI4 UART */
272 .settings = {
273 [GPIOMUX_SUSPENDED] = &gsbi4,
274 },
275 },
276 {
277 .gpio = 13, /* GSBI4 UART */
278 .settings = {
279 [GPIOMUX_SUSPENDED] = &gsbi4,
280 },
281 },
282 {
283 .gpio = 14, /* GSBI4 UART */
284 .settings = {
285 [GPIOMUX_SUSPENDED] = &gsbi4,
286 },
287 },
288 {
289 .gpio = 15, /* GSBI4 UART */
290 .settings = {
291 [GPIOMUX_SUSPENDED] = &gsbi4,
292 },
293 },
294 {
295 .gpio = 16, /* GSBI5 I2C QUP SCL */
296 .settings = {
297 [GPIOMUX_SUSPENDED] = &gsbi5,
Venkat Sudhir5efc4912012-05-15 17:10:35 -0700298 [GPIOMUX_ACTIVE] = &gsbi5,
Rohit Vaswania6815892011-12-15 20:20:39 -0800299 },
300 },
301 {
302 .gpio = 17, /* GSBI5 I2C QUP SDA */
303 .settings = {
304 [GPIOMUX_SUSPENDED] = &gsbi5,
305 },
306 },
307 {
308 /* GPIO 19 can be used for I2C/UART on GSBI5 */
309 .gpio = 19, /* GSBI3 QUP SPI_CS_1 */
310 .settings = {
311 [GPIOMUX_SUSPENDED] = &gsbi3_cs1_config,
312 },
313 },
314};
315
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700316static struct msm_gpiomux_config msm9615_slimbus_configs[] __initdata = {
317 {
318 .gpio = 20, /* Slimbus data */
319 .settings = {
320 [GPIOMUX_SUSPENDED] = &slimbus,
321 },
322 },
323 {
324 .gpio = 23, /* Slimbus clk */
325 .settings = {
326 [GPIOMUX_SUSPENDED] = &slimbus,
327 },
328 },
329};
330
Zhang Chang Kena48794b2012-03-31 17:45:21 -0400331#ifdef CONFIG_FB_MSM_EBI2
332static struct msm_gpiomux_config msm9615_ebi2_lcdc_configs[] __initdata = {
333 {
334 .gpio = 21, /* a_d */
335 .settings = {
336 [GPIOMUX_SUSPENDED] = &ebi2_lcdc_a_d,
337 },
338 },
339 {
340 .gpio = 22, /* cs */
341 .settings = {
342 [GPIOMUX_SUSPENDED] = &ebi2_lcdc_cs,
343 },
344 },
345 {
346 .gpio = 24, /* rs */
347 .settings = {
348 [GPIOMUX_SUSPENDED] = &ebi2_lcdc_rs,
349 },
350 },
351};
352#endif
353
Pavan Kumar27556502012-05-21 18:38:01 -0700354static struct msm_gpiomux_config msm9615_wlan_configs[] __initdata = {
355 {
356 .gpio = 21,/* WLAN_RESET_N */
357 .settings = {
358 [GPIOMUX_ACTIVE] = &wlan_active_config,
359 [GPIOMUX_SUSPENDED] = &wlan_suspend_config,
360 },
361 },
362};
363
364
Rohit Vaswania6815892011-12-15 20:20:39 -0800365int __init msm9615_init_gpiomux(void)
366{
367 int rc;
368
369 rc = msm_gpiomux_init(NR_GPIO_IRQS);
370 if (rc) {
371 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
372 return rc;
373 }
374 msm_gpiomux_install(msm9615_gsbi_configs,
375 ARRAY_SIZE(msm9615_gsbi_configs));
376
Sagar Dharia2a5378d2011-12-01 20:00:11 -0700377 msm_gpiomux_install(msm9615_slimbus_configs,
378 ARRAY_SIZE(msm9615_slimbus_configs));
379
Rohit Vaswania6815892011-12-15 20:20:39 -0800380 msm_gpiomux_install(msm9615_ps_hold_config,
381 ARRAY_SIZE(msm9615_ps_hold_config));
Subhash Jadavani737ce552012-11-02 22:09:13 +0530382 msm_gpiomux_install(sd_card_det_config,
383 ARRAY_SIZE(sd_card_det_config));
Rohit Vaswania6815892011-12-15 20:20:39 -0800384 msm_gpiomux_install(msm9615_sdcc2_configs,
385 ARRAY_SIZE(msm9615_sdcc2_configs));
386#ifdef CONFIG_LTC4088_CHARGER
387 msm_gpiomux_install(msm9615_ltc4088_charger_config,
388 ARRAY_SIZE(msm9615_ltc4088_charger_config));
389#endif
Shiv Maliyappanahalli9ec55e92012-01-09 14:44:59 -0800390 msm_gpiomux_install(msm9615_audio_codec_configs,
391 ARRAY_SIZE(msm9615_audio_codec_configs));
Rohit Vaswania6815892011-12-15 20:20:39 -0800392
Pavan Kumar27556502012-05-21 18:38:01 -0700393 msm_gpiomux_install(msm9615_wlan_configs,
394 ARRAY_SIZE(msm9615_wlan_configs));
395
Zhang Chang Kena48794b2012-03-31 17:45:21 -0400396#ifdef CONFIG_FB_MSM_EBI2
397 msm_gpiomux_install(msm9615_ebi2_lcdc_configs,
398 ARRAY_SIZE(msm9615_ebi2_lcdc_configs));
399#endif
400
Rohit Vaswania6815892011-12-15 20:20:39 -0800401 return 0;
402}