blob: e769566848750f7710221a4853c22a25bd6cc4f1 [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
Hemant Kumara945b472012-01-25 15:08:06 -0800119#ifdef CONFIG_USB_EHCI_MSM_HSIC
120static struct gpiomux_setting hsic_act_cfg = {
121 .func = GPIOMUX_FUNC_1,
122 .drv = GPIOMUX_DRV_8MA,
123 .pull = GPIOMUX_PULL_NONE,
124};
125
126static struct gpiomux_setting hsic_sus_cfg = {
127 .func = GPIOMUX_FUNC_GPIO,
128 .drv = GPIOMUX_DRV_2MA,
129 .pull = GPIOMUX_PULL_DOWN,
130 .dir = GPIOMUX_OUT_LOW,
131};
132
133static struct msm_gpiomux_config apq8064_hsic_configs[] = {
134 {
135 .gpio = 88, /*HSIC_STROBE */
136 .settings = {
137 [GPIOMUX_ACTIVE] = &hsic_act_cfg,
138 [GPIOMUX_SUSPENDED] = &hsic_sus_cfg,
139 },
140 },
141 {
142 .gpio = 89, /* HSIC_DATA */
143 .settings = {
144 [GPIOMUX_ACTIVE] = &hsic_act_cfg,
145 [GPIOMUX_SUSPENDED] = &hsic_sus_cfg,
146 },
147 },
148};
149#endif
150
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800151static struct msm_gpiomux_config apq8064_gsbi_configs[] __initdata = {
Stepan Moskovchenko5ea3c312012-01-31 18:19:40 -0800152 {
153 .gpio = 18, /* GSBI1 UART TX */
154 .settings = {
155 [GPIOMUX_SUSPENDED] = &gsbi1_uart_config,
156 },
157 },
158 {
159 .gpio = 19, /* GSBI1 UART RX */
160 .settings = {
161 [GPIOMUX_SUSPENDED] = &gsbi1_uart_config,
162 },
163 },
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800164#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
165 {
166 .gpio = 51, /* GSBI5 QUP SPI_DATA_MOSI */
167 .settings = {
168 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
169 },
170 },
171 {
172 .gpio = 52, /* GSBI5 QUP SPI_DATA_MISO */
173 .settings = {
174 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
175 },
176 },
177 {
Stepan Moskovchenkoc71c9792012-01-31 18:12:44 -0800178 .gpio = 53, /* Funny CS0 */
179 .settings = {
180 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
181 },
182 },
183 {
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800184 .gpio = 31, /* GSBI5 QUP SPI_CS2_N */
185 .settings = {
186 [GPIOMUX_SUSPENDED] = &gpio_spi_cs2_config,
187 },
188 },
189 {
190 .gpio = 54, /* GSBI5 QUP SPI_CLK */
191 .settings = {
192 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
193 },
194 },
195#endif
Stepan Moskovchenkoc71c9792012-01-31 18:12:44 -0800196 {
197 .gpio = 30, /* FP CS */
198 .settings = {
199 [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config,
200 },
201 },
202 {
203 .gpio = 32, /* EPM CS */
204 .settings = {
205 [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config,
206 },
207 },
208 {
209 .gpio = 53, /* NOR CS */
210 .settings = {
211 [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config,
212 },
213 },
Jin Hong4bbbfba2012-02-02 21:48:07 -0800214 {
215 .gpio = 82, /* GSBI7 UART2 TX */
216 .settings = {
217 [GPIOMUX_SUSPENDED] = &gsbi7_func2_cfg,
218 },
219 },
220 {
221 .gpio = 83, /* GSBI7 UART2 RX */
222 .settings = {
223 [GPIOMUX_SUSPENDED] = &gsbi7_func1_cfg,
224 },
225 },
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800226};
227
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800228static struct msm_gpiomux_config apq8064_slimbus_config[] __initdata = {
229 {
230 .gpio = 40, /* slimbus clk */
231 .settings = {
232 [GPIOMUX_SUSPENDED] = &slimbus,
233 },
234 },
235 {
236 .gpio = 41, /* slimbus data */
237 .settings = {
238 [GPIOMUX_SUSPENDED] = &slimbus,
239 },
240 },
241};
242
243static struct msm_gpiomux_config apq8064_audio_codec_configs[] __initdata = {
244 {
245 .gpio = 39,
246 .settings = {
247 [GPIOMUX_SUSPENDED] = &cdc_mclk,
248 },
249 },
250};
251
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800252static struct msm_gpiomux_config apq8064_audio_auxpcm_configs[] __initdata = {
253 {
254 .gpio = 43,
255 .settings = {
256 [GPIOMUX_SUSPENDED] = &audio_auxpcm[0],
257 [GPIOMUX_ACTIVE] = &audio_auxpcm[1],
258 },
259 },
260 {
261 .gpio = 44,
262 .settings = {
263 [GPIOMUX_SUSPENDED] = &audio_auxpcm[0],
264 [GPIOMUX_ACTIVE] = &audio_auxpcm[1],
265 },
266 },
267 {
268 .gpio = 45,
269 .settings = {
270 [GPIOMUX_SUSPENDED] = &audio_auxpcm[0],
271 [GPIOMUX_ACTIVE] = &audio_auxpcm[1],
272 },
273 },
274 {
275 .gpio = 46,
276 .settings = {
277 [GPIOMUX_SUSPENDED] = &audio_auxpcm[0],
278 [GPIOMUX_ACTIVE] = &audio_auxpcm[1],
279 },
280 },
281};
282
David Collinsf0d00732012-01-25 15:46:50 -0800283/* External 3.3 V regulator enable */
284static struct msm_gpiomux_config apq8064_ext_regulator_configs[] __initdata = {
285 {
286 .gpio = APQ8064_EXT_3P3V_REG_EN_GPIO,
287 .settings = {
288 [GPIOMUX_SUSPENDED] = &ext_regulator_config,
289 },
290 },
291};
292
Joel Kingdacbc822012-01-25 13:30:57 -0800293static struct gpiomux_setting ap2mdm_cfg = {
294 .func = GPIOMUX_FUNC_GPIO,
295 .drv = GPIOMUX_DRV_8MA,
296 .pull = GPIOMUX_PULL_DOWN,
297};
298
299static struct gpiomux_setting mdm2ap_status_cfg = {
300 .func = GPIOMUX_FUNC_GPIO,
301 .drv = GPIOMUX_DRV_8MA,
302 .pull = GPIOMUX_PULL_NONE,
303};
304
305static struct gpiomux_setting mdm2ap_errfatal_cfg = {
306 .func = GPIOMUX_FUNC_GPIO,
307 .drv = GPIOMUX_DRV_16MA,
308 .pull = GPIOMUX_PULL_DOWN,
309};
310
311static struct gpiomux_setting ap2mdm_pon_reset_n_cfg = {
312 .func = GPIOMUX_FUNC_GPIO,
313 .drv = GPIOMUX_DRV_8MA,
314 .pull = GPIOMUX_PULL_DOWN,
315};
316
317static struct msm_gpiomux_config mdm_configs[] __initdata = {
318 /* AP2MDM_STATUS */
319 {
320 .gpio = 48,
321 .settings = {
322 [GPIOMUX_SUSPENDED] = &ap2mdm_cfg,
323 }
324 },
325 /* MDM2AP_STATUS */
326 {
327 .gpio = 49,
328 .settings = {
329 [GPIOMUX_SUSPENDED] = &mdm2ap_status_cfg,
330 }
331 },
332 /* MDM2AP_ERRFATAL */
333 {
334 .gpio = 19,
335 .settings = {
336 [GPIOMUX_SUSPENDED] = &mdm2ap_errfatal_cfg,
337 }
338 },
339 /* AP2MDM_ERRFATAL */
340 {
341 .gpio = 18,
342 .settings = {
343 [GPIOMUX_SUSPENDED] = &ap2mdm_cfg,
344 }
345 },
346 /* AP2MDM_PON_RESET_N */
347 {
348 .gpio = 27,
349 .settings = {
350 [GPIOMUX_SUSPENDED] = &ap2mdm_pon_reset_n_cfg,
351 }
352 }
353};
354
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800355void __init apq8064_init_gpiomux(void)
356{
357 int rc;
358
359 rc = msm_gpiomux_init(NR_GPIO_IRQS);
360 if (rc) {
361 pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc);
362 return;
363 }
364
365#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
366 msm_gpiomux_install(apq8064_ethernet_configs,
367 ARRAY_SIZE(apq8064_ethernet_configs));
368#endif
369
370 msm_gpiomux_install(apq8064_gsbi_configs,
371 ARRAY_SIZE(apq8064_gsbi_configs));
372
Swaminathan Sathappancef966d2011-12-15 17:27:04 -0800373 msm_gpiomux_install(apq8064_slimbus_config,
374 ARRAY_SIZE(apq8064_slimbus_config));
375
376 msm_gpiomux_install(apq8064_audio_codec_configs,
377 ARRAY_SIZE(apq8064_audio_codec_configs));
378
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800379 msm_gpiomux_install(apq8064_audio_auxpcm_configs,
380 ARRAY_SIZE(apq8064_audio_auxpcm_configs));
David Collinsf0d00732012-01-25 15:46:50 -0800381
382 msm_gpiomux_install(apq8064_ext_regulator_configs,
383 ARRAY_SIZE(apq8064_ext_regulator_configs));
Joel Kingdacbc822012-01-25 13:30:57 -0800384
385 if (machine_is_apq8064_mtp())
386 msm_gpiomux_install(mdm_configs,
387 ARRAY_SIZE(mdm_configs));
Hemant Kumara945b472012-01-25 15:08:06 -0800388
389#ifdef CONFIG_USB_EHCI_MSM_HSIC
390 msm_gpiomux_install(apq8064_hsic_configs,
391 ARRAY_SIZE(apq8064_hsic_configs));
392#endif
Stepan Moskovchenko2327a952011-12-14 16:31:28 -0800393}