blob: 0a41f6dc39e74a26531af67e9895208bb69c3887 [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
145static struct msm_gpiomux_config apq8064_hsic_configs[] = {
146 {
147 .gpio = 88, /*HSIC_STROBE */
148 .settings = {
149 [GPIOMUX_ACTIVE] = &hsic_act_cfg,
150 [GPIOMUX_SUSPENDED] = &hsic_sus_cfg,
151 },
152 },
153 {
154 .gpio = 89, /* HSIC_DATA */
155 .settings = {
156 [GPIOMUX_ACTIVE] = &hsic_act_cfg,
157 [GPIOMUX_SUSPENDED] = &hsic_sus_cfg,
158 },
159 },
160};
161#endif
162
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800163static struct msm_gpiomux_config apq8064_gsbi_configs[] __initdata = {
Stepan Moskovchenko5ea3c312012-01-31 18:19:40 -0800164 {
Jing Lin04601f92012-02-05 15:36:07 -0800165 .gpio = 8, /* GSBI3 I2C QUP SDA */
166 .settings = {
167 [GPIOMUX_SUSPENDED] = &gsbi3_suspended_cfg,
168 [GPIOMUX_ACTIVE] = &gsbi3_active_cfg,
169 },
170 },
171 {
172 .gpio = 9, /* GSBI3 I2C QUP SCL */
173 .settings = {
174 [GPIOMUX_SUSPENDED] = &gsbi3_suspended_cfg,
175 [GPIOMUX_ACTIVE] = &gsbi3_active_cfg,
176 },
177 },
178 {
Stepan Moskovchenko5ea3c312012-01-31 18:19:40 -0800179 .gpio = 18, /* GSBI1 UART TX */
180 .settings = {
181 [GPIOMUX_SUSPENDED] = &gsbi1_uart_config,
182 },
183 },
184 {
185 .gpio = 19, /* GSBI1 UART RX */
186 .settings = {
187 [GPIOMUX_SUSPENDED] = &gsbi1_uart_config,
188 },
189 },
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800190#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
191 {
192 .gpio = 51, /* GSBI5 QUP SPI_DATA_MOSI */
193 .settings = {
194 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
195 },
196 },
197 {
198 .gpio = 52, /* GSBI5 QUP SPI_DATA_MISO */
199 .settings = {
200 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
201 },
202 },
203 {
Stepan Moskovchenkoc71c9792012-01-31 18:12:44 -0800204 .gpio = 53, /* Funny CS0 */
205 .settings = {
206 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
207 },
208 },
209 {
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800210 .gpio = 31, /* GSBI5 QUP SPI_CS2_N */
211 .settings = {
212 [GPIOMUX_SUSPENDED] = &gpio_spi_cs2_config,
213 },
214 },
215 {
216 .gpio = 54, /* GSBI5 QUP SPI_CLK */
217 .settings = {
218 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
219 },
220 },
221#endif
Stepan Moskovchenkoc71c9792012-01-31 18:12:44 -0800222 {
223 .gpio = 30, /* FP CS */
224 .settings = {
225 [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config,
226 },
227 },
228 {
229 .gpio = 32, /* EPM CS */
230 .settings = {
231 [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config,
232 },
233 },
234 {
235 .gpio = 53, /* NOR CS */
236 .settings = {
237 [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config,
238 },
239 },
Jin Hong4bbbfba2012-02-02 21:48:07 -0800240 {
241 .gpio = 82, /* GSBI7 UART2 TX */
242 .settings = {
243 [GPIOMUX_SUSPENDED] = &gsbi7_func2_cfg,
244 },
245 },
246 {
247 .gpio = 83, /* GSBI7 UART2 RX */
248 .settings = {
249 [GPIOMUX_SUSPENDED] = &gsbi7_func1_cfg,
250 },
251 },
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800252};
253
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800254static struct msm_gpiomux_config apq8064_slimbus_config[] __initdata = {
255 {
256 .gpio = 40, /* slimbus clk */
257 .settings = {
258 [GPIOMUX_SUSPENDED] = &slimbus,
259 },
260 },
261 {
262 .gpio = 41, /* slimbus data */
263 .settings = {
264 [GPIOMUX_SUSPENDED] = &slimbus,
265 },
266 },
267};
268
269static struct msm_gpiomux_config apq8064_audio_codec_configs[] __initdata = {
270 {
271 .gpio = 39,
272 .settings = {
273 [GPIOMUX_SUSPENDED] = &cdc_mclk,
274 },
275 },
276};
277
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800278static struct msm_gpiomux_config apq8064_audio_auxpcm_configs[] __initdata = {
279 {
280 .gpio = 43,
281 .settings = {
282 [GPIOMUX_SUSPENDED] = &audio_auxpcm[0],
283 [GPIOMUX_ACTIVE] = &audio_auxpcm[1],
284 },
285 },
286 {
287 .gpio = 44,
288 .settings = {
289 [GPIOMUX_SUSPENDED] = &audio_auxpcm[0],
290 [GPIOMUX_ACTIVE] = &audio_auxpcm[1],
291 },
292 },
293 {
294 .gpio = 45,
295 .settings = {
296 [GPIOMUX_SUSPENDED] = &audio_auxpcm[0],
297 [GPIOMUX_ACTIVE] = &audio_auxpcm[1],
298 },
299 },
300 {
301 .gpio = 46,
302 .settings = {
303 [GPIOMUX_SUSPENDED] = &audio_auxpcm[0],
304 [GPIOMUX_ACTIVE] = &audio_auxpcm[1],
305 },
306 },
307};
308
David Collinsf0d00732012-01-25 15:46:50 -0800309/* External 3.3 V regulator enable */
310static struct msm_gpiomux_config apq8064_ext_regulator_configs[] __initdata = {
311 {
312 .gpio = APQ8064_EXT_3P3V_REG_EN_GPIO,
313 .settings = {
314 [GPIOMUX_SUSPENDED] = &ext_regulator_config,
315 },
316 },
317};
318
Joel Kingdacbc822012-01-25 13:30:57 -0800319static struct gpiomux_setting ap2mdm_cfg = {
320 .func = GPIOMUX_FUNC_GPIO,
321 .drv = GPIOMUX_DRV_8MA,
322 .pull = GPIOMUX_PULL_DOWN,
323};
324
325static struct gpiomux_setting mdm2ap_status_cfg = {
326 .func = GPIOMUX_FUNC_GPIO,
327 .drv = GPIOMUX_DRV_8MA,
328 .pull = GPIOMUX_PULL_NONE,
329};
330
331static struct gpiomux_setting mdm2ap_errfatal_cfg = {
332 .func = GPIOMUX_FUNC_GPIO,
333 .drv = GPIOMUX_DRV_16MA,
334 .pull = GPIOMUX_PULL_DOWN,
335};
336
337static struct gpiomux_setting ap2mdm_pon_reset_n_cfg = {
338 .func = GPIOMUX_FUNC_GPIO,
339 .drv = GPIOMUX_DRV_8MA,
340 .pull = GPIOMUX_PULL_DOWN,
341};
342
343static struct msm_gpiomux_config mdm_configs[] __initdata = {
344 /* AP2MDM_STATUS */
345 {
346 .gpio = 48,
347 .settings = {
348 [GPIOMUX_SUSPENDED] = &ap2mdm_cfg,
349 }
350 },
351 /* MDM2AP_STATUS */
352 {
353 .gpio = 49,
354 .settings = {
355 [GPIOMUX_SUSPENDED] = &mdm2ap_status_cfg,
356 }
357 },
358 /* MDM2AP_ERRFATAL */
359 {
360 .gpio = 19,
361 .settings = {
362 [GPIOMUX_SUSPENDED] = &mdm2ap_errfatal_cfg,
363 }
364 },
365 /* AP2MDM_ERRFATAL */
366 {
367 .gpio = 18,
368 .settings = {
369 [GPIOMUX_SUSPENDED] = &ap2mdm_cfg,
370 }
371 },
372 /* AP2MDM_PON_RESET_N */
373 {
374 .gpio = 27,
375 .settings = {
376 [GPIOMUX_SUSPENDED] = &ap2mdm_pon_reset_n_cfg,
377 }
378 }
379};
380
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800381void __init apq8064_init_gpiomux(void)
382{
383 int rc;
384
385 rc = msm_gpiomux_init(NR_GPIO_IRQS);
386 if (rc) {
387 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
388 return;
389 }
390
391#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
392 msm_gpiomux_install(apq8064_ethernet_configs,
393 ARRAY_SIZE(apq8064_ethernet_configs));
394#endif
395
396 msm_gpiomux_install(apq8064_gsbi_configs,
397 ARRAY_SIZE(apq8064_gsbi_configs));
398
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800399 msm_gpiomux_install(apq8064_slimbus_config,
400 ARRAY_SIZE(apq8064_slimbus_config));
401
402 msm_gpiomux_install(apq8064_audio_codec_configs,
403 ARRAY_SIZE(apq8064_audio_codec_configs));
404
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800405 msm_gpiomux_install(apq8064_audio_auxpcm_configs,
406 ARRAY_SIZE(apq8064_audio_auxpcm_configs));
David Collinsf0d00732012-01-25 15:46:50 -0800407
408 msm_gpiomux_install(apq8064_ext_regulator_configs,
409 ARRAY_SIZE(apq8064_ext_regulator_configs));
Joel Kingdacbc822012-01-25 13:30:57 -0800410
411 if (machine_is_apq8064_mtp())
412 msm_gpiomux_install(mdm_configs,
413 ARRAY_SIZE(mdm_configs));
Hemant Kumara945b472012-01-25 15:08:06 -0800414
415#ifdef CONFIG_USB_EHCI_MSM_HSIC
416 msm_gpiomux_install(apq8064_hsic_configs,
417 ARRAY_SIZE(apq8064_hsic_configs));
418#endif
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800419}