blob: 41263f80f47874a3669a28d5538e5ac23bd15ba4 [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
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -080020#define KS8851_IRQ_GPIO 75
21
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
Gilad Avidov28e18eb2012-11-21 18:13:25 -070087static struct gpiomux_setting gpio_i2c_config = {
88 .func = GPIOMUX_FUNC_3,
89 .drv = GPIOMUX_DRV_2MA,
90 .pull = GPIOMUX_PULL_NONE,
91};
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -080092
Amy Maloche24c59dd2013-03-05 11:43:55 -080093static struct msm_gpiomux_config msm_keypad_configs[] __initdata = {
94 {
95 .gpio = 106,
96 .settings = {
97 [GPIOMUX_ACTIVE] = &gpio_keys_active,
98 [GPIOMUX_SUSPENDED] = &gpio_keys_suspend,
99 },
100 },
101 {
102 .gpio = 107,
103 .settings = {
104 [GPIOMUX_ACTIVE] = &gpio_keys_active,
105 [GPIOMUX_SUSPENDED] = &gpio_keys_suspend,
106 },
107 },
108 {
109 .gpio = 108,
110 .settings = {
111 [GPIOMUX_ACTIVE] = &gpio_keys_active,
112 [GPIOMUX_SUSPENDED] = &gpio_keys_suspend,
113 },
114 },
115};
116
Aravind Venkateswaranf60fb212013-03-08 13:57:06 -0800117static struct gpiomux_setting lcd_rst_act_cfg = {
118 .func = GPIOMUX_FUNC_GPIO,
119 .drv = GPIOMUX_DRV_8MA,
120 .pull = GPIOMUX_PULL_NONE,
121 .dir = GPIOMUX_OUT_LOW,
122};
123
124static struct gpiomux_setting lcd_rst_sus_cfg = {
125 .func = GPIOMUX_FUNC_GPIO,
126 .drv = GPIOMUX_DRV_2MA,
127 .pull = GPIOMUX_PULL_DOWN,
128};
129
130static struct msm_gpiomux_config msm_lcd_configs[] __initdata = {
131 {
132 .gpio = 25,
133 .settings = {
134 [GPIOMUX_ACTIVE] = &lcd_rst_act_cfg,
135 [GPIOMUX_SUSPENDED] = &lcd_rst_sus_cfg,
136 },
137 }
138};
139
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800140static struct msm_gpiomux_config msm_blsp_configs[] __initdata = {
141 {
Gilad Avidovd59217c2013-02-01 13:45:59 -0700142 .gpio = 0, /* BLSP1 QUP1 SPI_DATA_MOSI */
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800143 .settings = {
144 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
145 },
146 },
147 {
Gilad Avidovd59217c2013-02-01 13:45:59 -0700148 .gpio = 1, /* BLSP1 QUP1 SPI_DATA_MISO */
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800149 .settings = {
150 [GPIOMUX_SUSPENDED] = &gpio_spi_config,
151 },
152 },
153 {
Gilad Avidovd59217c2013-02-01 13:45:59 -0700154 .gpio = 2, /* BLSP1 QUP1 SPI_CS1 */
155 .settings = {
156 [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config,
157 },
158 },
159 {
160 .gpio = 3, /* BLSP1 QUP1 SPI_CLK */
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 = 14, /* BLSP1 QUP4 I2C_SDA */
Gilad Avidov28e18eb2012-11-21 18:13:25 -0700167 .settings = {
168 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
169 },
170 },
171 {
Gilad Avidovd59217c2013-02-01 13:45:59 -0700172 .gpio = 15, /* BLSP1 QUP4 I2C_SCL */
Gilad Avidov28e18eb2012-11-21 18:13:25 -0700173 .settings = {
174 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
175 },
176 },
Amy Maloche41708ba2013-03-03 15:19:27 -0800177 {
178 .gpio = 18, /* BLSP1 QUP5 I2C_SDA */
179 .settings = {
180 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
181 },
182 },
183 {
184 .gpio = 19, /* BLSP1 QUP5 I2C_SCL */
185 .settings = {
186 [GPIOMUX_SUSPENDED] = &gpio_i2c_config,
187 },
188 },
189};
190
191static struct msm_gpiomux_config msm_synaptics_configs[] __initdata = {
192 {
193 .gpio = 16,
194 .settings = {
195 [GPIOMUX_ACTIVE] = &synaptics_reset_act_cfg,
196 [GPIOMUX_SUSPENDED] = &synaptics_reset_sus_cfg,
197 },
198 },
199 {
200 .gpio = 17,
201 .settings = {
202 [GPIOMUX_ACTIVE] = &synaptics_int_act_cfg,
203 [GPIOMUX_SUSPENDED] = &synaptics_int_sus_cfg,
204 },
205 },
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800206};
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800207
Krishna Konda7af5df92013-03-06 20:35:30 -0800208static struct gpiomux_setting sd_card_det_active_config = {
209 .func = GPIOMUX_FUNC_GPIO,
210 .drv = GPIOMUX_DRV_2MA,
211 .pull = GPIOMUX_PULL_NONE,
212 .dir = GPIOMUX_IN,
213};
214
215static struct gpiomux_setting sd_card_det_sleep_config = {
216 .func = GPIOMUX_FUNC_GPIO,
217 .drv = GPIOMUX_DRV_2MA,
218 .pull = GPIOMUX_PULL_UP,
219 .dir = GPIOMUX_IN,
220};
221
222static struct msm_gpiomux_config sd_card_det __initdata = {
223 .gpio = 38,
224 .settings = {
225 [GPIOMUX_ACTIVE] = &sd_card_det_active_config,
226 [GPIOMUX_SUSPENDED] = &sd_card_det_sleep_config,
227 },
228};
229
Syed Rameez Mustafa9d16c4f2012-09-10 14:16:55 -0700230void __init msm8226_init_gpiomux(void)
231{
232 int rc;
233
Rohit Vaswani341c2032012-11-08 18:49:29 -0800234 rc = msm_gpiomux_init_dt();
Syed Rameez Mustafa9d16c4f2012-09-10 14:16:55 -0700235 if (rc) {
Rohit Vaswani341c2032012-11-08 18:49:29 -0800236 pr_err("%s failed %d\n", __func__, rc);
Syed Rameez Mustafa9d16c4f2012-09-10 14:16:55 -0700237 return;
238 }
Gilad Avidov28e18eb2012-11-21 18:13:25 -0700239
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800240#if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE)
241 msm_gpiomux_install(msm_eth_configs, ARRAY_SIZE(msm_eth_configs));
Syed Rameez Mustafa01d15eb2012-12-20 15:30:17 -0800242#endif
Amy Maloche24c59dd2013-03-05 11:43:55 -0800243 msm_gpiomux_install(msm_keypad_configs,
244 ARRAY_SIZE(msm_keypad_configs));
Gilad Avidov28e18eb2012-11-21 18:13:25 -0700245
246 msm_gpiomux_install(msm_blsp_configs, ARRAY_SIZE(msm_blsp_configs));
Krishna Konda7af5df92013-03-06 20:35:30 -0800247
248 msm_gpiomux_install(&sd_card_det, 1);
Amy Maloche41708ba2013-03-03 15:19:27 -0800249 msm_gpiomux_install(msm_synaptics_configs,
250 ARRAY_SIZE(msm_synaptics_configs));
Aravind Venkateswaranf60fb212013-03-08 13:57:06 -0800251 msm_gpiomux_install_nowrite(msm_lcd_configs,
252 ARRAY_SIZE(msm_lcd_configs));
Syed Rameez Mustafa9d16c4f2012-09-10 14:16:55 -0700253}