blob: 8aafeb54fb5d1dcc0d3fb740506055d24fd3ec97 [file] [log] [blame]
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -07001/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
2 *
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
Sagar Dhariaa8e6b0a2012-08-10 20:52:30 -060029static struct gpiomux_setting slimbus = {
30 .func = GPIOMUX_FUNC_1,
31 .drv = GPIOMUX_DRV_8MA,
32 .pull = GPIOMUX_PULL_KEEPER,
33};
34
Sathish Ambleye3154b42012-04-09 10:59:09 -070035#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
36static struct gpiomux_setting gpio_eth_config = {
37 .pull = GPIOMUX_PULL_NONE,
38 .drv = GPIOMUX_DRV_8MA,
39 .func = GPIOMUX_FUNC_GPIO,
40};
41
42static struct gpiomux_setting gpio_spi_cs_config = {
43 .func = GPIOMUX_FUNC_4,
44 .drv = GPIOMUX_DRV_12MA,
45 .pull = GPIOMUX_PULL_NONE,
46};
47
48static struct gpiomux_setting gpio_spi_config = {
49 .func = GPIOMUX_FUNC_1,
50 .drv = GPIOMUX_DRV_12MA,
51 .pull = GPIOMUX_PULL_NONE,
52};
53
54static struct msm_gpiomux_config msm_eth_configs[] = {
55 {
56 .gpio = KS8851_IRQ_GPIO,
57 .settings = {
58 [GPIOMUX_SUSPENDED] = &gpio_eth_config,
59 }
60 },
61};
62#endif
Jin Honga04caaa2012-05-23 10:28:27 -070063static struct gpiomux_setting gpio_i2c_config = {
64 .func = GPIOMUX_FUNC_3,
65 .drv = GPIOMUX_DRV_8MA,
66 .pull = GPIOMUX_PULL_NONE,
67};
68
Chandan Uddaraju88b26d72012-08-13 22:28:44 -070069static struct gpiomux_setting lcd_en_act_cfg = {
70 .func = GPIOMUX_FUNC_GPIO,
71 .drv = GPIOMUX_DRV_8MA,
72 .pull = GPIOMUX_PULL_NONE,
73};
74
75static struct gpiomux_setting lcd_en_sus_cfg = {
76 .func = GPIOMUX_FUNC_GPIO,
77 .drv = GPIOMUX_DRV_2MA,
78 .pull = GPIOMUX_PULL_DOWN,
79};
Sathish Ambleye3154b42012-04-09 10:59:09 -070080
Amy Maloche9e99a792012-08-15 23:27:51 -070081static struct gpiomux_setting atmel_resout_sus_cfg = {
82 .func = GPIOMUX_FUNC_GPIO,
83 .drv = GPIOMUX_DRV_6MA,
84 .pull = GPIOMUX_PULL_DOWN,
85};
86
87static struct gpiomux_setting atmel_resout_act_cfg = {
88 .func = GPIOMUX_FUNC_GPIO,
89 .drv = GPIOMUX_DRV_6MA,
90 .pull = GPIOMUX_PULL_UP,
91};
92
93static struct gpiomux_setting atmel_int_act_cfg = {
94 .func = GPIOMUX_FUNC_GPIO,
95 .drv = GPIOMUX_DRV_8MA,
96 .pull = GPIOMUX_PULL_UP,
97};
98
99static struct gpiomux_setting atmel_int_sus_cfg = {
100 .func = GPIOMUX_FUNC_GPIO,
101 .drv = GPIOMUX_DRV_2MA,
102 .pull = GPIOMUX_PULL_DOWN,
103};
104
105static struct msm_gpiomux_config msm_touch_configs[] __initdata = {
106 {
107 .gpio = 60, /* TOUCH RESET */
108 .settings = {
109 [GPIOMUX_ACTIVE] = &atmel_resout_act_cfg,
110 [GPIOMUX_SUSPENDED] = &atmel_resout_sus_cfg,
111 },
112 },
113 {
114 .gpio = 61, /* TOUCH IRQ */
115 .settings = {
116 [GPIOMUX_ACTIVE] = &atmel_int_act_cfg,
117 [GPIOMUX_SUSPENDED] = &atmel_int_sus_cfg,
118 },
119 },
120
121};
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -0700122static struct msm_gpiomux_config msm_blsp_configs[] __initdata = {
Sathish Ambleye3154b42012-04-09 10:59:09 -0700123#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
124 {
125 .gpio = 0, /* BLSP1 QUP SPI_DATA_MOSI */
126 .settings = {
127 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
128 },
129 },
130 {
131 .gpio = 1, /* BLSP1 QUP SPI_DATA_MISO */
132 .settings = {
133 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
134 },
135 },
136 {
137 .gpio = 3, /* BLSP1 QUP SPI_CLK */
138 .settings = {
139 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
140 },
141 },
142 {
143 .gpio = 9, /* BLSP1 QUP SPI_CS_N */
144 .settings = {
145 [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config,
146 },
147 },
148#endif
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -0700149 {
Chandan Uddaraju88b26d72012-08-13 22:28:44 -0700150 .gpio = 58,
151 .settings = {
152 [GPIOMUX_ACTIVE] = &lcd_en_act_cfg,
153 [GPIOMUX_SUSPENDED] = &lcd_en_sus_cfg,
154 },
155 },
156 {
Amy Malochebc7e9672012-08-15 10:30:40 -0700157 .gpio = 6, /* BLSP1 QUP2 I2C_DAT */
158 .settings = {
159 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
160 },
161 },
162 {
163 .gpio = 7, /* BLSP1 QUP2 I2C_CLK */
164 .settings = {
165 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
166 },
167 },
168 {
Jin Honga04caaa2012-05-23 10:28:27 -0700169 .gpio = 83, /* BLSP11 QUP I2C_DAT */
170 .settings = {
171 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
172 },
173 },
174 {
175 .gpio = 84, /* BLSP11 QUP I2C_CLK */
176 .settings = {
177 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
178 },
179 },
180 {
Stepan Moskovchenko5269b602012-08-08 17:57:09 -0700181 .gpio = 4, /* BLSP2 UART TX */
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -0700182 .settings = {
183 [GPIOMUX_SUSPENDED] = &gpio_uart_config,
184 },
185 },
186 {
Stepan Moskovchenko5269b602012-08-08 17:57:09 -0700187 .gpio = 5, /* BLSP2 UART RX */
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -0700188 .settings = {
189 [GPIOMUX_SUSPENDED] = &gpio_uart_config,
190 },
191 },
192};
193
Sagar Dhariaa8e6b0a2012-08-10 20:52:30 -0600194static struct msm_gpiomux_config msm8974_slimbus_config[] __initdata = {
195 {
196 .gpio = 70, /* slimbus clk */
197 .settings = {
198 [GPIOMUX_SUSPENDED] = &slimbus,
199 },
200 },
201 {
202 .gpio = 71, /* slimbus data */
203 .settings = {
204 [GPIOMUX_SUSPENDED] = &slimbus,
205 },
206 },
207};
208
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700209void __init msm_8974_init_gpiomux(void)
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -0700210{
211 int rc;
212
213 rc = msm_gpiomux_init(NR_GPIO_IRQS);
214 if (rc) {
Abhimanyu Kapur90ced6e2012-06-26 17:41:25 -0700215 pr_err(KERN_ERR "msm_8974_init_gpiomux failed %d\n", rc);
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -0700216 return;
217 }
218
Sathish Ambleye3154b42012-04-09 10:59:09 -0700219#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
220 msm_gpiomux_install(msm_eth_configs, ARRAY_SIZE(msm_eth_configs));
221#endif
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -0700222 msm_gpiomux_install(msm_blsp_configs, ARRAY_SIZE(msm_blsp_configs));
Sagar Dhariaa8e6b0a2012-08-10 20:52:30 -0600223
224 msm_gpiomux_install(msm8974_slimbus_config,
225 ARRAY_SIZE(msm8974_slimbus_config));
226
Amy Maloche9e99a792012-08-15 23:27:51 -0700227 msm_gpiomux_install(msm_touch_configs, ARRAY_SIZE(msm_touch_configs));
Sathish Ambleyb17ec7e2012-04-03 15:20:03 -0700228}