blob: a6ac986d7303a10de3f4027094447469ec183032 [file] [log] [blame]
Duy Truong790f06d2013-02-13 16:38:12 -08001/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
Jin Hong690e3352012-05-02 09:25:05 -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
20static struct gpiomux_setting gpio_uart_config = {
Abhimanyu Kapur2f9483f2012-09-27 16:44:23 -070021 .func = GPIOMUX_FUNC_1,
22 .drv = GPIOMUX_DRV_8MA,
Jin Hong690e3352012-05-02 09:25:05 -070023 .pull = GPIOMUX_PULL_NONE,
24 .dir = GPIOMUX_OUT_HIGH,
25};
26
Rohit Vaswani0045df42012-06-29 16:21:48 -070027static struct gpiomux_setting gpio_spi_cs_config = {
Gilad Avidov09c78ec2012-10-18 09:34:35 -060028 .func = GPIOMUX_FUNC_1,
Rohit Vaswani0045df42012-06-29 16:21:48 -070029 .drv = GPIOMUX_DRV_12MA,
30 .pull = GPIOMUX_PULL_NONE,
31};
32
33static struct gpiomux_setting gpio_spi_config = {
Gilad Avidov09c78ec2012-10-18 09:34:35 -060034 .func = GPIOMUX_FUNC_1,
Rohit Vaswani0045df42012-06-29 16:21:48 -070035 .drv = GPIOMUX_DRV_12MA,
36 .pull = GPIOMUX_PULL_NONE,
37};
38
David Collins50d4bcd2012-11-01 14:31:21 -070039static struct gpiomux_setting gpio_i2c_config = {
40 .func = GPIOMUX_FUNC_3,
41 .drv = GPIOMUX_DRV_2MA,
42 .pull = GPIOMUX_PULL_NONE,
43};
44
Jin Hong690e3352012-05-02 09:25:05 -070045static struct msm_gpiomux_config msm_blsp_configs[] __initdata = {
46 {
Gilad Avidov09c78ec2012-10-18 09:34:35 -060047 .gpio = 4, /* BLSP1 QUP2 SPI_DATA_MOSI */
48 .settings = {
49 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
50 },
51 },
52 {
53 .gpio = 5, /* BLSP1 QUP2 SPI_DATA_MISO */
54 .settings = {
55 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
56 },
57 },
58 {
59 .gpio = 6, /* BLSP1 QUP2 SPI_CS_N */
60 .settings = {
61 [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config,
62 },
63 },
64 {
65 .gpio = 7, /* BLSP1 QUP2 SPI_CLK */
66 .settings = {
67 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
68 },
69 },
70 {
Abhimanyu Kapur2f9483f2012-09-27 16:44:23 -070071 .gpio = 8, /* BLSP1 UART TX */
Jin Hong690e3352012-05-02 09:25:05 -070072 .settings = {
73 [GPIOMUX_SUSPENDED] = &gpio_uart_config,
74 },
75 },
76 {
Abhimanyu Kapur2f9483f2012-09-27 16:44:23 -070077 .gpio = 9, /* BLSP1 UART RX */
Jin Hong690e3352012-05-02 09:25:05 -070078 .settings = {
79 [GPIOMUX_SUSPENDED] = &gpio_uart_config,
80 },
81 },
Rohit Vaswani0045df42012-06-29 16:21:48 -070082 {
David Collins50d4bcd2012-11-01 14:31:21 -070083 .gpio = 10, /* BLSP1 QUP3 I2C_DAT */
84 .settings = {
85 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
86 },
87 },
88 {
89 .gpio = 11, /* BLSP1 QUP3 I2C_CLK */
90 .settings = {
91 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
92 },
93 },
Jin Hong690e3352012-05-02 09:25:05 -070094};
95
Venkat Sudhir39711d02012-10-12 16:47:29 -070096static struct gpiomux_setting mi2s_active_cfg = {
97 .func = GPIOMUX_FUNC_1,
98 .drv = GPIOMUX_DRV_8MA,
99 .pull = GPIOMUX_PULL_NONE,
100};
101
102static struct gpiomux_setting mi2s_suspend_cfg = {
103 .func = GPIOMUX_FUNC_GPIO,
104 .drv = GPIOMUX_DRV_2MA,
105 .pull = GPIOMUX_PULL_DOWN,
106};
107
108static struct gpiomux_setting codec_reset = {
109 .func = GPIOMUX_FUNC_GPIO,
110 .drv = GPIOMUX_DRV_6MA,
111 .pull = GPIOMUX_PULL_NONE,
112 .dir = GPIOMUX_OUT_LOW,
113};
114
115static struct msm_gpiomux_config mdm9625_mi2s_configs[] __initdata = {
116 {
117 .gpio = 12, /* mi2s ws */
118 .settings = {
119 [GPIOMUX_SUSPENDED] = &mi2s_suspend_cfg,
120 [GPIOMUX_ACTIVE] = &mi2s_active_cfg,
121 },
122 },
123 {
124 .gpio = 15, /* mi2s sclk */
125 .settings = {
126 [GPIOMUX_SUSPENDED] = &mi2s_suspend_cfg,
127 [GPIOMUX_ACTIVE] = &mi2s_active_cfg,
128 },
129 },
130 {
131 .gpio = 14, /* mi2s dout */
132 .settings = {
133 [GPIOMUX_SUSPENDED] = &mi2s_suspend_cfg,
134 [GPIOMUX_ACTIVE] = &mi2s_active_cfg,
135 },
136 },
137 {
138 .gpio = 13, /* mi2s din */
139 .settings = {
140 [GPIOMUX_SUSPENDED] = &mi2s_suspend_cfg,
141 [GPIOMUX_ACTIVE] = &mi2s_active_cfg,
142 },
143 },
144 {
145 .gpio = 71, /* mi2s mclk */
146 .settings = {
147 [GPIOMUX_SUSPENDED] = &mi2s_suspend_cfg,
148 [GPIOMUX_ACTIVE] = &mi2s_active_cfg,
149 },
150 },
151};
152
153static struct msm_gpiomux_config mdm9625_cdc_reset_config[] __initdata = {
154 {
155 .gpio = 22, /* SYS_RST_N */
156 .settings = {
157 [GPIOMUX_SUSPENDED] = &codec_reset,
158 },
159 }
160};
161
Oluwafemi Adeyemi4926a9e2012-09-14 17:39:59 -0700162static struct gpiomux_setting sdc3_clk_active_cfg = {
163 .func = GPIOMUX_FUNC_1,
164 .drv = GPIOMUX_DRV_8MA,
165 .pull = GPIOMUX_PULL_NONE,
166};
167
168static struct gpiomux_setting sdc3_cmd_active_cfg = {
169 .func = GPIOMUX_FUNC_1,
170 .drv = GPIOMUX_DRV_8MA,
171 .pull = GPIOMUX_PULL_UP,
172};
173
174static struct gpiomux_setting sdc3_data_0_3_active_cfg = {
175 .func = GPIOMUX_FUNC_6,
176 .drv = GPIOMUX_DRV_8MA,
177 .pull = GPIOMUX_PULL_UP,
178};
179
180static struct gpiomux_setting sdc3_suspended_cfg = {
181 .func = GPIOMUX_FUNC_GPIO,
182 .drv = GPIOMUX_DRV_2MA,
183 .pull = GPIOMUX_PULL_DOWN,
184};
185
186static struct gpiomux_setting sdc3_data_1_suspended_cfg = {
187 .func = GPIOMUX_FUNC_GPIO,
188 .drv = GPIOMUX_DRV_2MA,
189 .pull = GPIOMUX_PULL_UP,
190};
191
192static struct msm_gpiomux_config sdc3_configs[] __initdata = {
193 {
194 .gpio = 25,
195 .settings = {
196 [GPIOMUX_ACTIVE] = &sdc3_clk_active_cfg,
197 [GPIOMUX_SUSPENDED] = &sdc3_suspended_cfg,
198 },
199 },
200 {
201 .gpio = 24,
202 .settings = {
203 [GPIOMUX_ACTIVE] = &sdc3_cmd_active_cfg,
204 [GPIOMUX_SUSPENDED] = &sdc3_suspended_cfg,
205 },
206
207 },
208 {
209 .gpio = 16,
210 .settings = {
211 [GPIOMUX_ACTIVE] = &sdc3_data_0_3_active_cfg,
212 [GPIOMUX_SUSPENDED] = &sdc3_suspended_cfg,
213 },
214 },
215 {
216 .gpio = 17,
217 .settings = {
218 [GPIOMUX_ACTIVE] = &sdc3_data_0_3_active_cfg,
219 [GPIOMUX_SUSPENDED] = &sdc3_data_1_suspended_cfg,
220 },
221 },
222 {
223 .gpio = 18,
224 .settings = {
225 [GPIOMUX_ACTIVE] = &sdc3_data_0_3_active_cfg,
226 [GPIOMUX_SUSPENDED] = &sdc3_suspended_cfg,
227 },
228 },
229 {
230 .gpio = 19,
231 .settings = {
232 [GPIOMUX_ACTIVE] = &sdc3_data_0_3_active_cfg,
233 [GPIOMUX_SUSPENDED] = &sdc3_suspended_cfg,
234 },
235 },
236};
237
Pavan Kumar07c070b2012-10-29 18:58:49 -0700238static struct gpiomux_setting wlan_ath6kl_active_config = {
239 .func = GPIOMUX_FUNC_GPIO,
240 .drv = GPIOMUX_DRV_2MA,
241 .pull = GPIOMUX_PULL_NONE,
242 .dir = GPIOMUX_OUT_LOW,
243};
244
245static struct gpiomux_setting wlan_ath6kl_suspend_config = {
246 .func = GPIOMUX_FUNC_GPIO,
247 .drv = GPIOMUX_DRV_2MA,
248 .pull = GPIOMUX_PULL_NONE,
249 .dir = GPIOMUX_IN,
250};
251
252static struct msm_gpiomux_config wlan_ath6kl_configs[] __initdata = {
253 {
254 .gpio = 62,/* CHIP_PWD_L */
255 .settings = {
256 [GPIOMUX_ACTIVE] = &wlan_ath6kl_active_config,
257 [GPIOMUX_SUSPENDED] = &wlan_ath6kl_suspend_config,
258 },
259 },
260};
261
Oluwafemi Adeyemi938a4952012-11-06 14:03:38 -0800262static struct gpiomux_setting sdc2_card_det_cfg = {
263 .func = GPIOMUX_FUNC_GPIO,
264 .drv = GPIOMUX_DRV_2MA,
265 .pull = GPIOMUX_PULL_DOWN,
266 .dir = GPIOMUX_IN,
267};
268
269struct msm_gpiomux_config sdc2_card_det_config[] __initdata = {
270 {
271 .gpio = 66,
272 .settings = {
273 [GPIOMUX_ACTIVE] = &sdc2_card_det_cfg,
274 [GPIOMUX_SUSPENDED] = &sdc2_card_det_cfg,
275 },
276 },
277};
278
Ken Zhang6572aae2013-04-17 09:02:02 -0400279#ifdef CONFIG_FB_MSM_QPIC
Ken Zhange529ff12013-01-24 17:02:35 -0500280static struct gpiomux_setting qpic_lcdc_a_d = {
281 .func = GPIOMUX_FUNC_1,
282 .drv = GPIOMUX_DRV_10MA,
283 .pull = GPIOMUX_PULL_NONE,
284};
285
286static struct gpiomux_setting qpic_lcdc_cs = {
287 .func = GPIOMUX_FUNC_1,
288 .drv = GPIOMUX_DRV_10MA,
289 .pull = GPIOMUX_PULL_NONE,
290};
291
292static struct gpiomux_setting qpic_lcdc_rs = {
293 .func = GPIOMUX_FUNC_1,
294 .drv = GPIOMUX_DRV_10MA,
295 .pull = GPIOMUX_PULL_NONE,
296};
297
298static struct gpiomux_setting qpic_lcdc_te = {
299 .func = GPIOMUX_FUNC_7,
300 .drv = GPIOMUX_DRV_10MA,
301 .pull = GPIOMUX_PULL_NONE,
302};
303
304static struct msm_gpiomux_config msm9625_qpic_lcdc_configs[] __initdata = {
305 {
306 .gpio = 20, /* a_d */
307 .settings = {
308 [GPIOMUX_SUSPENDED] = &qpic_lcdc_a_d,
309 },
310 },
311 {
312 .gpio = 21, /* cs */
313 .settings = {
314 [GPIOMUX_SUSPENDED] = &qpic_lcdc_cs,
315 },
316 },
317 {
318 .gpio = 22, /* te */
319 .settings = {
320 [GPIOMUX_SUSPENDED] = &qpic_lcdc_te,
321 },
322 },
323 {
324 .gpio = 23, /* rs */
325 .settings = {
326 [GPIOMUX_SUSPENDED] = &qpic_lcdc_rs,
327 },
328 },
329};
330
Ken Zhang6572aae2013-04-17 09:02:02 -0400331static void msm9625_disp_init_gpiomux(void)
332{
333 msm_gpiomux_install(msm9625_qpic_lcdc_configs,
334 ARRAY_SIZE(msm9625_qpic_lcdc_configs));
335}
336#else
337static void msm9625_disp_init_gpiomux(void)
338{
339}
340#endif /* CONFIG_FB_MSM_QPIC */
341
Jin Hong690e3352012-05-02 09:25:05 -0700342void __init msm9625_init_gpiomux(void)
343{
344 int rc;
345
Rohit Vaswani341c2032012-11-08 18:49:29 -0800346 rc = msm_gpiomux_init_dt();
Jin Hong690e3352012-05-02 09:25:05 -0700347 if (rc) {
Rohit Vaswani341c2032012-11-08 18:49:29 -0800348 pr_err("%s failed %d\n", __func__, rc);
Jin Hong690e3352012-05-02 09:25:05 -0700349 return;
350 }
351
352 msm_gpiomux_install(msm_blsp_configs, ARRAY_SIZE(msm_blsp_configs));
Oluwafemi Adeyemi4926a9e2012-09-14 17:39:59 -0700353 msm_gpiomux_install(sdc3_configs, ARRAY_SIZE(sdc3_configs));
Pavan Kumar07c070b2012-10-29 18:58:49 -0700354 msm_gpiomux_install(wlan_ath6kl_configs,
355 ARRAY_SIZE(wlan_ath6kl_configs));
Venkat Sudhir39711d02012-10-12 16:47:29 -0700356 msm_gpiomux_install(mdm9625_mi2s_configs,
357 ARRAY_SIZE(mdm9625_mi2s_configs));
358 msm_gpiomux_install(mdm9625_cdc_reset_config,
359 ARRAY_SIZE(mdm9625_cdc_reset_config));
Oluwafemi Adeyemi938a4952012-11-06 14:03:38 -0800360 msm_gpiomux_install(sdc2_card_det_config,
361 ARRAY_SIZE(sdc2_card_det_config));
Ken Zhang6572aae2013-04-17 09:02:02 -0400362 msm9625_disp_init_gpiomux();
Jin Hong690e3352012-05-02 09:25:05 -0700363}