blob: 9e416dba804461551a34c33c5e680b3527248bcb [file] [log] [blame]
Duy Truonge833aca2013-02-12 13:35:08 -08001/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -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
Sathish Ambleye3154b42012-04-09 10:59:09 -070020#define KS8851_IRQ_GPIO 90
21
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -070022static struct gpiomux_setting gpio_uart_config = {
23 .func = GPIOMUX_FUNC_2,
24 .drv = GPIOMUX_DRV_16MA,
25 .pull = GPIOMUX_PULL_NONE,
26 .dir = GPIOMUX_OUT_HIGH,
27};
28
Sathish Ambleye3154b42012-04-09 10:59:09 -070029#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
30static struct gpiomux_setting gpio_eth_config = {
31 .pull = GPIOMUX_PULL_NONE,
32 .drv = GPIOMUX_DRV_8MA,
33 .func = GPIOMUX_FUNC_GPIO,
34};
35
36static struct gpiomux_setting gpio_spi_cs_config = {
37 .func = GPIOMUX_FUNC_4,
38 .drv = GPIOMUX_DRV_12MA,
39 .pull = GPIOMUX_PULL_NONE,
40};
41
42static struct gpiomux_setting gpio_spi_config = {
43 .func = GPIOMUX_FUNC_1,
44 .drv = GPIOMUX_DRV_12MA,
45 .pull = GPIOMUX_PULL_NONE,
46};
47
48static struct msm_gpiomux_config msm_eth_configs[] = {
49 {
50 .gpio = KS8851_IRQ_GPIO,
51 .settings = {
52 [GPIOMUX_SUSPENDED] = &gpio_eth_config,
53 }
54 },
55};
56#endif
Jin Honga04caaa2012-05-23 10:28:27 -070057static struct gpiomux_setting gpio_i2c_config = {
58 .func = GPIOMUX_FUNC_3,
59 .drv = GPIOMUX_DRV_8MA,
60 .pull = GPIOMUX_PULL_NONE,
61};
62
Sathish Ambleye3154b42012-04-09 10:59:09 -070063
Joonwoo Parkb0795e12012-08-24 22:47:53 -070064static struct gpiomux_setting lcd_en_sus_cfg = {
65 .func = GPIOMUX_FUNC_GPIO,
66 .drv = GPIOMUX_DRV_2MA,
67 .pull = GPIOMUX_PULL_DOWN,
68};
69
70static struct gpiomux_setting atmel_resout_sus_cfg = {
71 .func = GPIOMUX_FUNC_GPIO,
72 .drv = GPIOMUX_DRV_6MA,
73 .pull = GPIOMUX_PULL_DOWN,
74};
75
76static struct gpiomux_setting atmel_resout_act_cfg = {
77 .func = GPIOMUX_FUNC_GPIO,
78 .drv = GPIOMUX_DRV_6MA,
79 .pull = GPIOMUX_PULL_UP,
80};
81
82static struct gpiomux_setting atmel_int_act_cfg = {
83 .func = GPIOMUX_FUNC_GPIO,
84 .drv = GPIOMUX_DRV_8MA,
85 .pull = GPIOMUX_PULL_UP,
86};
87
88static struct gpiomux_setting atmel_int_sus_cfg = {
89 .func = GPIOMUX_FUNC_GPIO,
90 .drv = GPIOMUX_DRV_2MA,
91 .pull = GPIOMUX_PULL_DOWN,
92};
93
94static struct gpiomux_setting taiko_reset = {
95 .func = GPIOMUX_FUNC_GPIO,
96 .drv = GPIOMUX_DRV_6MA,
97 .pull = GPIOMUX_PULL_NONE,
98 .dir = GPIOMUX_OUT_LOW,
99};
100
101static struct msm_gpiomux_config msm_touch_configs[] __initdata = {
102 {
103 .gpio = 60, /* TOUCH RESET */
104 .settings = {
105 [GPIOMUX_ACTIVE] = &atmel_resout_act_cfg,
106 [GPIOMUX_SUSPENDED] = &atmel_resout_sus_cfg,
107 },
108 },
109 {
110 .gpio = 61, /* TOUCH IRQ */
111 .settings = {
112 [GPIOMUX_ACTIVE] = &atmel_int_act_cfg,
113 [GPIOMUX_SUSPENDED] = &atmel_int_sus_cfg,
114 },
115 },
116
117};
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -0700118static struct msm_gpiomux_config msm_blsp_configs[] __initdata = {
Sathish Ambleye3154b42012-04-09 10:59:09 -0700119#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
120 {
121 .gpio = 0, /* BLSP1 QUP SPI_DATA_MOSI */
122 .settings = {
123 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
124 },
125 },
126 {
127 .gpio = 1, /* BLSP1 QUP SPI_DATA_MISO */
128 .settings = {
129 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
130 },
131 },
132 {
133 .gpio = 3, /* BLSP1 QUP SPI_CLK */
134 .settings = {
135 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
136 },
137 },
138 {
139 .gpio = 9, /* BLSP1 QUP SPI_CS_N */
140 .settings = {
141 [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config,
142 },
143 },
144#endif
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -0700145 {
Jin Honga04caaa2012-05-23 10:28:27 -0700146 .gpio = 83, /* BLSP11 QUP I2C_DAT */
147 .settings = {
148 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
149 },
150 },
151 {
152 .gpio = 84, /* BLSP11 QUP I2C_CLK */
153 .settings = {
154 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
155 },
156 },
157 {
Stepan Moskovchenko5269b602012-08-08 17:57:09 -0700158 .gpio = 4, /* BLSP2 UART TX */
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -0700159 .settings = {
160 [GPIOMUX_SUSPENDED] = &gpio_uart_config,
161 },
162 },
163 {
Stepan Moskovchenko5269b602012-08-08 17:57:09 -0700164 .gpio = 5, /* BLSP2 UART RX */
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -0700165 .settings = {
166 [GPIOMUX_SUSPENDED] = &gpio_uart_config,
167 },
168 },
169};
170
Joonwoo Parkb0795e12012-08-24 22:47:53 -0700171static struct msm_gpiomux_config msm8974_slimbus_config[] __initdata = {
172 {
173 .gpio = 70, /* slimbus clk */
174 .settings = {
175 [GPIOMUX_SUSPENDED] = &slimbus,
176 },
177 },
178 {
179 .gpio = 71, /* slimbus data */
180 .settings = {
181 [GPIOMUX_SUSPENDED] = &slimbus,
182 },
183 },
184};
185
186static struct gpiomux_setting cam_settings[] = {
187 {
188 .func = GPIOMUX_FUNC_1, /*active 1*/
189 .drv = GPIOMUX_DRV_2MA,
190 .pull = GPIOMUX_PULL_NONE,
191 },
192
193 {
194 .func = GPIOMUX_FUNC_1, /*suspend*/
195 .drv = GPIOMUX_DRV_2MA,
196 .pull = GPIOMUX_PULL_DOWN,
197 },
198
199 {
200 .func = GPIOMUX_FUNC_1, /*i2c suspend*/
201 .drv = GPIOMUX_DRV_2MA,
202 .pull = GPIOMUX_PULL_KEEPER,
203 },
204};
205
206static struct msm_gpiomux_config msm_sensor_configs[] __initdata = {
207 {
208 .gpio = 15, /* CAM_MCLK0 */
209 .settings = {
210 [GPIOMUX_ACTIVE] = &cam_settings[0],
211 [GPIOMUX_SUSPENDED] = &cam_settings[1],
212 },
213 },
214 {
215 .gpio = 16, /* CAM_MCLK1 */
216 .settings = {
217 [GPIOMUX_ACTIVE] = &cam_settings[0],
218 [GPIOMUX_SUSPENDED] = &cam_settings[1],
219 },
220 },
221 {
222 .gpio = 17, /* CAM_MCLK2 */
223 .settings = {
224 [GPIOMUX_ACTIVE] = &cam_settings[0],
225 [GPIOMUX_SUSPENDED] = &cam_settings[1],
226 },
227 },
228 {
229 .gpio = 18, /* WEBCAM1_RESET_N / CAM_MCLK3 */
230 .settings = {
231 [GPIOMUX_ACTIVE] = &cam_settings[0],
232 [GPIOMUX_SUSPENDED] = &cam_settings[1],
233 },
234 },
235 {
236 .gpio = 19, /* CCI_I2C_SDA0 */
237 .settings = {
238 [GPIOMUX_ACTIVE] = &cam_settings[0],
239 [GPIOMUX_SUSPENDED] = &cam_settings[2],
240 },
241 },
242 {
243 .gpio = 20, /* CCI_I2C_SCL0 */
244 .settings = {
245 [GPIOMUX_ACTIVE] = &cam_settings[0],
246 [GPIOMUX_SUSPENDED] = &cam_settings[2],
247 },
248 },
249 {
250 .gpio = 21, /* CCI_I2C_SDA1 */
251 .settings = {
252 [GPIOMUX_ACTIVE] = &cam_settings[0],
253 [GPIOMUX_SUSPENDED] = &cam_settings[2],
254 },
255 },
256 {
257 .gpio = 22, /* CCI_I2C_SCL1 */
258 .settings = {
259 [GPIOMUX_ACTIVE] = &cam_settings[0],
260 [GPIOMUX_SUSPENDED] = &cam_settings[2],
261 },
262 },
263 {
264 .gpio = 23, /* FLASH_LED_EN */
265 .settings = {
266 [GPIOMUX_ACTIVE] = &cam_settings[0],
267 [GPIOMUX_SUSPENDED] = &cam_settings[1],
268 },
269 },
270 {
271 .gpio = 24, /* FLASH_LED_NOW */
272 .settings = {
273 [GPIOMUX_ACTIVE] = &cam_settings[0],
274 [GPIOMUX_SUSPENDED] = &cam_settings[1],
275 },
276 },
277 {
278 .gpio = 25, /* WEBCAM2_RESET_N */
279 .settings = {
280 [GPIOMUX_ACTIVE] = &cam_settings[0],
281 [GPIOMUX_SUSPENDED] = &cam_settings[1],
282 },
283 },
284 {
285 .gpio = 26, /* CAM_IRQ */
286 .settings = {
287 [GPIOMUX_ACTIVE] = &cam_settings[0],
288 [GPIOMUX_SUSPENDED] = &cam_settings[1],
289 },
290 },
291 {
292 .gpio = 27, /* OIS_SYNC */
293 .settings = {
294 [GPIOMUX_ACTIVE] = &cam_settings[0],
295 [GPIOMUX_SUSPENDED] = &cam_settings[1],
296 },
297 },
298 {
299 .gpio = 28, /* WEBCAM1_STANDBY */
300 .settings = {
301 [GPIOMUX_ACTIVE] = &cam_settings[0],
302 [GPIOMUX_SUSPENDED] = &cam_settings[1],
303 },
304 },
305 {
306 .gpio = 89, /* CAM1_STANDBY_N */
307 .settings = {
308 [GPIOMUX_ACTIVE] = &cam_settings[0],
309 [GPIOMUX_SUSPENDED] = &cam_settings[1],
310 },
311 },
312 {
313 .gpio = 90, /* CAM1_RST_N */
314 .settings = {
315 [GPIOMUX_ACTIVE] = &cam_settings[0],
316 [GPIOMUX_SUSPENDED] = &cam_settings[1],
317 },
318 },
319 {
320 .gpio = 91, /* CAM2_STANDBY_N */
321 .settings = {
322 [GPIOMUX_ACTIVE] = &cam_settings[0],
323 [GPIOMUX_SUSPENDED] = &cam_settings[1],
324 },
325 },
326 {
327 .gpio = 92, /* CAM2_RST_N */
328 .settings = {
329 [GPIOMUX_ACTIVE] = &cam_settings[0],
330 [GPIOMUX_SUSPENDED] = &cam_settings[1],
331 },
332 },
333};
334
335static struct msm_gpiomux_config msm_taiko_config[] __initdata = {
336 {
337 .gpio = 63, /* SYS_RST_N */
338 .settings = {
339 [GPIOMUX_SUSPENDED] = &taiko_reset,
340 },
341 }
342};
343
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700344void __init msm_8974_init_gpiomux(void)
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -0700345{
346 int rc;
347
348 rc = msm_gpiomux_init(NR_GPIO_IRQS);
349 if (rc) {
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700350 pr_err(KERN_ERR "msm_8974_init_gpiomux failed %d\n", rc);
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -0700351 return;
352 }
353
Sathish Ambleye3154b42012-04-09 10:59:09 -0700354#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
355 msm_gpiomux_install(msm_eth_configs, ARRAY_SIZE(msm_eth_configs));
356#endif
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -0700357 msm_gpiomux_install(msm_blsp_configs, ARRAY_SIZE(msm_blsp_configs));
Joonwoo Parkb0795e12012-08-24 22:47:53 -0700358
359 msm_gpiomux_install(msm8974_slimbus_config,
360 ARRAY_SIZE(msm8974_slimbus_config));
361
362 msm_gpiomux_install(msm_touch_configs, ARRAY_SIZE(msm_touch_configs));
363
364 msm_gpiomux_install(msm_sensor_configs, ARRAY_SIZE(msm_sensor_configs));
365
366 msm_gpiomux_install(msm_taiko_config, ARRAY_SIZE(msm_taiko_config));
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -0700367}