blob: 2b70e7c094f818279d619135aab6542d7c049dc1 [file] [log] [blame]
Gilad Avidov28e18eb2012-11-21 18:13:25 -07001/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
Syed Rameez Mustafa9d16c4f2012-09-10 14:16:55 -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
aiquny76b46082013-03-13 15:58:08 -070020#define KS8851_IRQ_GPIO 115
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -080021
22#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
23static struct gpiomux_setting gpio_eth_config = {
24 .pull = GPIOMUX_PULL_UP,
25 .drv = GPIOMUX_DRV_2MA,
26 .func = GPIOMUX_FUNC_GPIO,
27};
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -080028
29static struct msm_gpiomux_config msm_eth_configs[] = {
30 {
31 .gpio = KS8851_IRQ_GPIO,
32 .settings = {
33 [GPIOMUX_SUSPENDED] = &gpio_eth_config,
34 }
35 },
36};
Gilad Avidov28e18eb2012-11-21 18:13:25 -070037#endif
38
Amy Maloche41708ba2013-03-03 15:19:27 -080039static struct gpiomux_setting synaptics_int_act_cfg = {
40 .func = GPIOMUX_FUNC_GPIO,
41 .drv = GPIOMUX_DRV_8MA,
42 .pull = GPIOMUX_PULL_UP,
43};
44
45static struct gpiomux_setting synaptics_int_sus_cfg = {
46 .func = GPIOMUX_FUNC_GPIO,
47 .drv = GPIOMUX_DRV_2MA,
48 .pull = GPIOMUX_PULL_DOWN,
49};
50
51static struct gpiomux_setting synaptics_reset_act_cfg = {
52 .func = GPIOMUX_FUNC_GPIO,
53 .drv = GPIOMUX_DRV_6MA,
54 .pull = GPIOMUX_PULL_DOWN,
55};
56
57static struct gpiomux_setting synaptics_reset_sus_cfg = {
58 .func = GPIOMUX_FUNC_GPIO,
59 .drv = GPIOMUX_DRV_6MA,
60 .pull = GPIOMUX_PULL_DOWN,
61};
62
Amy Maloche24c59dd2013-03-05 11:43:55 -080063static struct gpiomux_setting gpio_keys_active = {
64 .func = GPIOMUX_FUNC_GPIO,
65 .drv = GPIOMUX_DRV_2MA,
66 .pull = GPIOMUX_PULL_UP,
67};
68
69static struct gpiomux_setting gpio_keys_suspend = {
70 .func = GPIOMUX_FUNC_GPIO,
71 .drv = GPIOMUX_DRV_2MA,
72 .pull = GPIOMUX_PULL_NONE,
73};
74
Gilad Avidov28e18eb2012-11-21 18:13:25 -070075static struct gpiomux_setting gpio_spi_config = {
76 .func = GPIOMUX_FUNC_1,
77 .drv = GPIOMUX_DRV_8MA,
78 .pull = GPIOMUX_PULL_NONE,
79};
80
Gilad Avidovd59217c2013-02-01 13:45:59 -070081static struct gpiomux_setting gpio_spi_cs_config = {
82 .func = GPIOMUX_FUNC_1,
83 .drv = GPIOMUX_DRV_6MA,
84 .pull = GPIOMUX_PULL_DOWN,
85};
86
aiquny76b46082013-03-13 15:58:08 -070087static struct gpiomux_setting gpio_spi_cs_eth_config = {
88 .func = GPIOMUX_FUNC_4,
89 .drv = GPIOMUX_DRV_6MA,
90 .pull = GPIOMUX_PULL_DOWN,
91};
92
Sheng Fang6746c3f2013-03-19 08:37:13 +080093static struct gpiomux_setting wcnss_5wire_suspend_cfg = {
94 .func = GPIOMUX_FUNC_GPIO,
95 .drv = GPIOMUX_DRV_2MA,
96 .pull = GPIOMUX_PULL_UP,
97};
98
99static struct gpiomux_setting wcnss_5wire_active_cfg = {
100 .func = GPIOMUX_FUNC_1,
101 .drv = GPIOMUX_DRV_6MA,
102 .pull = GPIOMUX_PULL_DOWN,
103};
104
Gilad Avidov28e18eb2012-11-21 18:13:25 -0700105static struct gpiomux_setting gpio_i2c_config = {
106 .func = GPIOMUX_FUNC_3,
107 .drv = GPIOMUX_DRV_2MA,
108 .pull = GPIOMUX_PULL_NONE,
109};
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800110
Amy Maloche24c59dd2013-03-05 11:43:55 -0800111static struct msm_gpiomux_config msm_keypad_configs[] __initdata = {
112 {
113 .gpio = 106,
114 .settings = {
115 [GPIOMUX_ACTIVE] = &gpio_keys_active,
116 [GPIOMUX_SUSPENDED] = &gpio_keys_suspend,
117 },
118 },
119 {
120 .gpio = 107,
121 .settings = {
122 [GPIOMUX_ACTIVE] = &gpio_keys_active,
123 [GPIOMUX_SUSPENDED] = &gpio_keys_suspend,
124 },
125 },
126 {
127 .gpio = 108,
128 .settings = {
129 [GPIOMUX_ACTIVE] = &gpio_keys_active,
130 [GPIOMUX_SUSPENDED] = &gpio_keys_suspend,
131 },
132 },
133};
134
Aravind Venkateswaranf60fb212013-03-08 13:57:06 -0800135static struct gpiomux_setting lcd_rst_act_cfg = {
136 .func = GPIOMUX_FUNC_GPIO,
137 .drv = GPIOMUX_DRV_8MA,
138 .pull = GPIOMUX_PULL_NONE,
139 .dir = GPIOMUX_OUT_LOW,
140};
141
142static struct gpiomux_setting lcd_rst_sus_cfg = {
143 .func = GPIOMUX_FUNC_GPIO,
144 .drv = GPIOMUX_DRV_2MA,
145 .pull = GPIOMUX_PULL_DOWN,
146};
147
148static struct msm_gpiomux_config msm_lcd_configs[] __initdata = {
149 {
150 .gpio = 25,
151 .settings = {
152 [GPIOMUX_ACTIVE] = &lcd_rst_act_cfg,
153 [GPIOMUX_SUSPENDED] = &lcd_rst_sus_cfg,
154 },
155 }
156};
157
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800158static struct msm_gpiomux_config msm_blsp_configs[] __initdata = {
159 {
Gilad Avidovd59217c2013-02-01 13:45:59 -0700160 .gpio = 0, /* BLSP1 QUP1 SPI_DATA_MOSI */
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800161 .settings = {
162 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
163 },
164 },
165 {
Gilad Avidovd59217c2013-02-01 13:45:59 -0700166 .gpio = 1, /* BLSP1 QUP1 SPI_DATA_MISO */
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800167 .settings = {
168 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
169 },
170 },
171 {
Gilad Avidovd59217c2013-02-01 13:45:59 -0700172 .gpio = 2, /* BLSP1 QUP1 SPI_CS1 */
173 .settings = {
174 [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config,
175 },
176 },
177 {
178 .gpio = 3, /* BLSP1 QUP1 SPI_CLK */
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800179 .settings = {
180 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
181 },
182 },
183 {
Gilad Avidovd59217c2013-02-01 13:45:59 -0700184 .gpio = 14, /* BLSP1 QUP4 I2C_SDA */
Gilad Avidov28e18eb2012-11-21 18:13:25 -0700185 .settings = {
186 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
187 },
188 },
189 {
Gilad Avidovd59217c2013-02-01 13:45:59 -0700190 .gpio = 15, /* BLSP1 QUP4 I2C_SCL */
Gilad Avidov28e18eb2012-11-21 18:13:25 -0700191 .settings = {
192 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
193 },
194 },
Amy Maloche41708ba2013-03-03 15:19:27 -0800195 {
196 .gpio = 18, /* BLSP1 QUP5 I2C_SDA */
197 .settings = {
198 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
199 },
200 },
201 {
202 .gpio = 19, /* BLSP1 QUP5 I2C_SCL */
203 .settings = {
204 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
205 },
206 },
aiquny76b46082013-03-13 15:58:08 -0700207 {
208 .gpio = 22, /* BLSP1 QUP1 SPI_CS_ETH */
209 .settings = {
210 [GPIOMUX_SUSPENDED] = &gpio_spi_cs_eth_config,
211 },
212 },
Amy Maloche41708ba2013-03-03 15:19:27 -0800213};
214
215static struct msm_gpiomux_config msm_synaptics_configs[] __initdata = {
216 {
217 .gpio = 16,
218 .settings = {
219 [GPIOMUX_ACTIVE] = &synaptics_reset_act_cfg,
220 [GPIOMUX_SUSPENDED] = &synaptics_reset_sus_cfg,
221 },
222 },
223 {
224 .gpio = 17,
225 .settings = {
226 [GPIOMUX_ACTIVE] = &synaptics_int_act_cfg,
227 [GPIOMUX_SUSPENDED] = &synaptics_int_sus_cfg,
228 },
229 },
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800230};
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800231
Krishna Konda7af5df92013-03-06 20:35:30 -0800232static struct gpiomux_setting sd_card_det_active_config = {
233 .func = GPIOMUX_FUNC_GPIO,
234 .drv = GPIOMUX_DRV_2MA,
235 .pull = GPIOMUX_PULL_NONE,
236 .dir = GPIOMUX_IN,
237};
238
239static struct gpiomux_setting sd_card_det_sleep_config = {
240 .func = GPIOMUX_FUNC_GPIO,
241 .drv = GPIOMUX_DRV_2MA,
242 .pull = GPIOMUX_PULL_UP,
243 .dir = GPIOMUX_IN,
244};
245
246static struct msm_gpiomux_config sd_card_det __initdata = {
247 .gpio = 38,
248 .settings = {
249 [GPIOMUX_ACTIVE] = &sd_card_det_active_config,
250 [GPIOMUX_SUSPENDED] = &sd_card_det_sleep_config,
251 },
252};
253
Sheng Fang6746c3f2013-03-19 08:37:13 +0800254static struct msm_gpiomux_config wcnss_5wire_interface[] = {
255 {
256 .gpio = 40,
257 .settings = {
258 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
259 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
260 },
261 },
262 {
263 .gpio = 41,
264 .settings = {
265 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
266 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
267 },
268 },
269 {
270 .gpio = 42,
271 .settings = {
272 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
273 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
274 },
275 },
276 {
277 .gpio = 43,
278 .settings = {
279 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
280 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
281 },
282 },
283 {
284 .gpio = 44,
285 .settings = {
286 [GPIOMUX_ACTIVE] = &wcnss_5wire_active_cfg,
287 [GPIOMUX_SUSPENDED] = &wcnss_5wire_suspend_cfg,
288 },
289 },
290};
Syed Rameez Mustafa9d16c4f2012-09-10 14:16:55 -0700291void __init msm8226_init_gpiomux(void)
292{
293 int rc;
294
Rohit Vaswani341c2032012-11-08 18:49:29 -0800295 rc = msm_gpiomux_init_dt();
Syed Rameez Mustafa9d16c4f2012-09-10 14:16:55 -0700296 if (rc) {
Rohit Vaswani341c2032012-11-08 18:49:29 -0800297 pr_err("%s failed %d\n", __func__, rc);
Syed Rameez Mustafa9d16c4f2012-09-10 14:16:55 -0700298 return;
299 }
Gilad Avidov28e18eb2012-11-21 18:13:25 -0700300
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800301#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
302 msm_gpiomux_install(msm_eth_configs, ARRAY_SIZE(msm_eth_configs));
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800303#endif
Amy Maloche24c59dd2013-03-05 11:43:55 -0800304 msm_gpiomux_install(msm_keypad_configs,
305 ARRAY_SIZE(msm_keypad_configs));
Gilad Avidov28e18eb2012-11-21 18:13:25 -0700306
307 msm_gpiomux_install(msm_blsp_configs, ARRAY_SIZE(msm_blsp_configs));
Sheng Fang6746c3f2013-03-19 08:37:13 +0800308 msm_gpiomux_install(wcnss_5wire_interface,
309 ARRAY_SIZE(wcnss_5wire_interface));
Krishna Konda7af5df92013-03-06 20:35:30 -0800310
311 msm_gpiomux_install(&sd_card_det, 1);
Amy Maloche41708ba2013-03-03 15:19:27 -0800312 msm_gpiomux_install(msm_synaptics_configs,
313 ARRAY_SIZE(msm_synaptics_configs));
Aravind Venkateswaranf60fb212013-03-08 13:57:06 -0800314 msm_gpiomux_install_nowrite(msm_lcd_configs,
315 ARRAY_SIZE(msm_lcd_configs));
Syed Rameez Mustafa9d16c4f2012-09-10 14:16:55 -0700316}