Duy Truong | 790f06d | 2013-02-13 16:38:12 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
Jin Hong | 690e335 | 2012-05-02 09:25:05 -0700 | [diff] [blame] | 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 | |
| 20 | static struct gpiomux_setting gpio_uart_config = { |
Abhimanyu Kapur | 2f9483f | 2012-09-27 16:44:23 -0700 | [diff] [blame] | 21 | .func = GPIOMUX_FUNC_1, |
| 22 | .drv = GPIOMUX_DRV_8MA, |
Jin Hong | 690e335 | 2012-05-02 09:25:05 -0700 | [diff] [blame] | 23 | .pull = GPIOMUX_PULL_NONE, |
| 24 | .dir = GPIOMUX_OUT_HIGH, |
| 25 | }; |
| 26 | |
Rohit Vaswani | 0045df4 | 2012-06-29 16:21:48 -0700 | [diff] [blame] | 27 | static struct gpiomux_setting gpio_spi_cs_config = { |
Gilad Avidov | 09c78ec | 2012-10-18 09:34:35 -0600 | [diff] [blame] | 28 | .func = GPIOMUX_FUNC_1, |
Rohit Vaswani | 0045df4 | 2012-06-29 16:21:48 -0700 | [diff] [blame] | 29 | .drv = GPIOMUX_DRV_12MA, |
| 30 | .pull = GPIOMUX_PULL_NONE, |
| 31 | }; |
| 32 | |
| 33 | static struct gpiomux_setting gpio_spi_config = { |
Gilad Avidov | 09c78ec | 2012-10-18 09:34:35 -0600 | [diff] [blame] | 34 | .func = GPIOMUX_FUNC_1, |
Rohit Vaswani | 0045df4 | 2012-06-29 16:21:48 -0700 | [diff] [blame] | 35 | .drv = GPIOMUX_DRV_12MA, |
| 36 | .pull = GPIOMUX_PULL_NONE, |
| 37 | }; |
| 38 | |
David Collins | 50d4bcd | 2012-11-01 14:31:21 -0700 | [diff] [blame] | 39 | static struct gpiomux_setting gpio_i2c_config = { |
| 40 | .func = GPIOMUX_FUNC_3, |
| 41 | .drv = GPIOMUX_DRV_2MA, |
| 42 | .pull = GPIOMUX_PULL_NONE, |
| 43 | }; |
| 44 | |
Jin Hong | 690e335 | 2012-05-02 09:25:05 -0700 | [diff] [blame] | 45 | static struct msm_gpiomux_config msm_blsp_configs[] __initdata = { |
| 46 | { |
Gilad Avidov | 09c78ec | 2012-10-18 09:34:35 -0600 | [diff] [blame] | 47 | .gpio = 4, /* BLSP1 QUP2 SPI_DATA_MOSI */ |
| 48 | .settings = { |
| 49 | [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| 50 | }, |
| 51 | }, |
| 52 | { |
| 53 | .gpio = 5, /* BLSP1 QUP2 SPI_DATA_MISO */ |
| 54 | .settings = { |
| 55 | [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| 56 | }, |
| 57 | }, |
| 58 | { |
| 59 | .gpio = 6, /* BLSP1 QUP2 SPI_CS_N */ |
| 60 | .settings = { |
| 61 | [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config, |
| 62 | }, |
| 63 | }, |
| 64 | { |
| 65 | .gpio = 7, /* BLSP1 QUP2 SPI_CLK */ |
| 66 | .settings = { |
| 67 | [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| 68 | }, |
| 69 | }, |
| 70 | { |
Abhimanyu Kapur | 2f9483f | 2012-09-27 16:44:23 -0700 | [diff] [blame] | 71 | .gpio = 8, /* BLSP1 UART TX */ |
Jin Hong | 690e335 | 2012-05-02 09:25:05 -0700 | [diff] [blame] | 72 | .settings = { |
| 73 | [GPIOMUX_SUSPENDED] = &gpio_uart_config, |
| 74 | }, |
| 75 | }, |
| 76 | { |
Abhimanyu Kapur | 2f9483f | 2012-09-27 16:44:23 -0700 | [diff] [blame] | 77 | .gpio = 9, /* BLSP1 UART RX */ |
Jin Hong | 690e335 | 2012-05-02 09:25:05 -0700 | [diff] [blame] | 78 | .settings = { |
| 79 | [GPIOMUX_SUSPENDED] = &gpio_uart_config, |
| 80 | }, |
| 81 | }, |
Rohit Vaswani | 0045df4 | 2012-06-29 16:21:48 -0700 | [diff] [blame] | 82 | { |
David Collins | 50d4bcd | 2012-11-01 14:31:21 -0700 | [diff] [blame] | 83 | .gpio = 10, /* BLSP1 QUP3 I2C_DAT */ |
| 84 | .settings = { |
| 85 | [GPIOMUX_SUSPENDED] = &gpio_i2c_config, |
| 86 | }, |
| 87 | }, |
| 88 | { |
| 89 | .gpio = 11, /* BLSP1 QUP3 I2C_CLK */ |
| 90 | .settings = { |
| 91 | [GPIOMUX_SUSPENDED] = &gpio_i2c_config, |
| 92 | }, |
| 93 | }, |
Jin Hong | 690e335 | 2012-05-02 09:25:05 -0700 | [diff] [blame] | 94 | }; |
| 95 | |
Venkat Sudhir | 39711d0 | 2012-10-12 16:47:29 -0700 | [diff] [blame] | 96 | static struct gpiomux_setting mi2s_active_cfg = { |
| 97 | .func = GPIOMUX_FUNC_1, |
| 98 | .drv = GPIOMUX_DRV_8MA, |
| 99 | .pull = GPIOMUX_PULL_NONE, |
| 100 | }; |
| 101 | |
| 102 | static struct gpiomux_setting mi2s_suspend_cfg = { |
| 103 | .func = GPIOMUX_FUNC_GPIO, |
| 104 | .drv = GPIOMUX_DRV_2MA, |
| 105 | .pull = GPIOMUX_PULL_DOWN, |
| 106 | }; |
| 107 | |
| 108 | static struct gpiomux_setting codec_reset = { |
| 109 | .func = GPIOMUX_FUNC_GPIO, |
| 110 | .drv = GPIOMUX_DRV_6MA, |
| 111 | .pull = GPIOMUX_PULL_NONE, |
| 112 | .dir = GPIOMUX_OUT_LOW, |
| 113 | }; |
| 114 | |
| 115 | static struct msm_gpiomux_config mdm9625_mi2s_configs[] __initdata = { |
| 116 | { |
| 117 | .gpio = 12, /* mi2s ws */ |
| 118 | .settings = { |
| 119 | [GPIOMUX_SUSPENDED] = &mi2s_suspend_cfg, |
| 120 | [GPIOMUX_ACTIVE] = &mi2s_active_cfg, |
| 121 | }, |
| 122 | }, |
| 123 | { |
| 124 | .gpio = 15, /* mi2s sclk */ |
| 125 | .settings = { |
| 126 | [GPIOMUX_SUSPENDED] = &mi2s_suspend_cfg, |
| 127 | [GPIOMUX_ACTIVE] = &mi2s_active_cfg, |
| 128 | }, |
| 129 | }, |
| 130 | { |
| 131 | .gpio = 14, /* mi2s dout */ |
| 132 | .settings = { |
| 133 | [GPIOMUX_SUSPENDED] = &mi2s_suspend_cfg, |
| 134 | [GPIOMUX_ACTIVE] = &mi2s_active_cfg, |
| 135 | }, |
| 136 | }, |
| 137 | { |
| 138 | .gpio = 13, /* mi2s din */ |
| 139 | .settings = { |
| 140 | [GPIOMUX_SUSPENDED] = &mi2s_suspend_cfg, |
| 141 | [GPIOMUX_ACTIVE] = &mi2s_active_cfg, |
| 142 | }, |
| 143 | }, |
| 144 | { |
| 145 | .gpio = 71, /* mi2s mclk */ |
| 146 | .settings = { |
| 147 | [GPIOMUX_SUSPENDED] = &mi2s_suspend_cfg, |
| 148 | [GPIOMUX_ACTIVE] = &mi2s_active_cfg, |
| 149 | }, |
| 150 | }, |
| 151 | }; |
| 152 | |
| 153 | static struct msm_gpiomux_config mdm9625_cdc_reset_config[] __initdata = { |
| 154 | { |
| 155 | .gpio = 22, /* SYS_RST_N */ |
| 156 | .settings = { |
| 157 | [GPIOMUX_SUSPENDED] = &codec_reset, |
| 158 | }, |
| 159 | } |
| 160 | }; |
| 161 | |
Oluwafemi Adeyemi | 4926a9e | 2012-09-14 17:39:59 -0700 | [diff] [blame] | 162 | static struct gpiomux_setting sdc3_clk_active_cfg = { |
| 163 | .func = GPIOMUX_FUNC_1, |
| 164 | .drv = GPIOMUX_DRV_8MA, |
| 165 | .pull = GPIOMUX_PULL_NONE, |
| 166 | }; |
| 167 | |
| 168 | static struct gpiomux_setting sdc3_cmd_active_cfg = { |
| 169 | .func = GPIOMUX_FUNC_1, |
| 170 | .drv = GPIOMUX_DRV_8MA, |
| 171 | .pull = GPIOMUX_PULL_UP, |
| 172 | }; |
| 173 | |
| 174 | static struct gpiomux_setting sdc3_data_0_3_active_cfg = { |
| 175 | .func = GPIOMUX_FUNC_6, |
| 176 | .drv = GPIOMUX_DRV_8MA, |
| 177 | .pull = GPIOMUX_PULL_UP, |
| 178 | }; |
| 179 | |
| 180 | static struct gpiomux_setting sdc3_suspended_cfg = { |
| 181 | .func = GPIOMUX_FUNC_GPIO, |
| 182 | .drv = GPIOMUX_DRV_2MA, |
| 183 | .pull = GPIOMUX_PULL_DOWN, |
| 184 | }; |
| 185 | |
| 186 | static struct gpiomux_setting sdc3_data_1_suspended_cfg = { |
| 187 | .func = GPIOMUX_FUNC_GPIO, |
| 188 | .drv = GPIOMUX_DRV_2MA, |
| 189 | .pull = GPIOMUX_PULL_UP, |
| 190 | }; |
| 191 | |
| 192 | static struct msm_gpiomux_config sdc3_configs[] __initdata = { |
| 193 | { |
| 194 | .gpio = 25, |
| 195 | .settings = { |
| 196 | [GPIOMUX_ACTIVE] = &sdc3_clk_active_cfg, |
| 197 | [GPIOMUX_SUSPENDED] = &sdc3_suspended_cfg, |
| 198 | }, |
| 199 | }, |
| 200 | { |
| 201 | .gpio = 24, |
| 202 | .settings = { |
| 203 | [GPIOMUX_ACTIVE] = &sdc3_cmd_active_cfg, |
| 204 | [GPIOMUX_SUSPENDED] = &sdc3_suspended_cfg, |
| 205 | }, |
| 206 | |
| 207 | }, |
| 208 | { |
| 209 | .gpio = 16, |
| 210 | .settings = { |
| 211 | [GPIOMUX_ACTIVE] = &sdc3_data_0_3_active_cfg, |
| 212 | [GPIOMUX_SUSPENDED] = &sdc3_suspended_cfg, |
| 213 | }, |
| 214 | }, |
| 215 | { |
| 216 | .gpio = 17, |
| 217 | .settings = { |
| 218 | [GPIOMUX_ACTIVE] = &sdc3_data_0_3_active_cfg, |
| 219 | [GPIOMUX_SUSPENDED] = &sdc3_data_1_suspended_cfg, |
| 220 | }, |
| 221 | }, |
| 222 | { |
| 223 | .gpio = 18, |
| 224 | .settings = { |
| 225 | [GPIOMUX_ACTIVE] = &sdc3_data_0_3_active_cfg, |
| 226 | [GPIOMUX_SUSPENDED] = &sdc3_suspended_cfg, |
| 227 | }, |
| 228 | }, |
| 229 | { |
| 230 | .gpio = 19, |
| 231 | .settings = { |
| 232 | [GPIOMUX_ACTIVE] = &sdc3_data_0_3_active_cfg, |
| 233 | [GPIOMUX_SUSPENDED] = &sdc3_suspended_cfg, |
| 234 | }, |
| 235 | }, |
| 236 | }; |
| 237 | |
Pavan Kumar | 07c070b | 2012-10-29 18:58:49 -0700 | [diff] [blame] | 238 | static struct gpiomux_setting wlan_ath6kl_active_config = { |
| 239 | .func = GPIOMUX_FUNC_GPIO, |
| 240 | .drv = GPIOMUX_DRV_2MA, |
| 241 | .pull = GPIOMUX_PULL_NONE, |
| 242 | .dir = GPIOMUX_OUT_LOW, |
| 243 | }; |
| 244 | |
| 245 | static struct gpiomux_setting wlan_ath6kl_suspend_config = { |
| 246 | .func = GPIOMUX_FUNC_GPIO, |
| 247 | .drv = GPIOMUX_DRV_2MA, |
| 248 | .pull = GPIOMUX_PULL_NONE, |
| 249 | .dir = GPIOMUX_IN, |
| 250 | }; |
| 251 | |
| 252 | static struct msm_gpiomux_config wlan_ath6kl_configs[] __initdata = { |
| 253 | { |
| 254 | .gpio = 62,/* CHIP_PWD_L */ |
| 255 | .settings = { |
| 256 | [GPIOMUX_ACTIVE] = &wlan_ath6kl_active_config, |
| 257 | [GPIOMUX_SUSPENDED] = &wlan_ath6kl_suspend_config, |
| 258 | }, |
| 259 | }, |
| 260 | }; |
| 261 | |
Oluwafemi Adeyemi | 938a495 | 2012-11-06 14:03:38 -0800 | [diff] [blame] | 262 | static struct gpiomux_setting sdc2_card_det_cfg = { |
| 263 | .func = GPIOMUX_FUNC_GPIO, |
| 264 | .drv = GPIOMUX_DRV_2MA, |
| 265 | .pull = GPIOMUX_PULL_DOWN, |
| 266 | .dir = GPIOMUX_IN, |
| 267 | }; |
| 268 | |
| 269 | struct msm_gpiomux_config sdc2_card_det_config[] __initdata = { |
| 270 | { |
| 271 | .gpio = 66, |
| 272 | .settings = { |
| 273 | [GPIOMUX_ACTIVE] = &sdc2_card_det_cfg, |
| 274 | [GPIOMUX_SUSPENDED] = &sdc2_card_det_cfg, |
| 275 | }, |
| 276 | }, |
| 277 | }; |
| 278 | |
Ken Zhang | 6572aae | 2013-04-17 09:02:02 -0400 | [diff] [blame] | 279 | #ifdef CONFIG_FB_MSM_QPIC |
Ken Zhang | e529ff1 | 2013-01-24 17:02:35 -0500 | [diff] [blame] | 280 | static struct gpiomux_setting qpic_lcdc_a_d = { |
| 281 | .func = GPIOMUX_FUNC_1, |
| 282 | .drv = GPIOMUX_DRV_10MA, |
| 283 | .pull = GPIOMUX_PULL_NONE, |
| 284 | }; |
| 285 | |
| 286 | static struct gpiomux_setting qpic_lcdc_cs = { |
| 287 | .func = GPIOMUX_FUNC_1, |
| 288 | .drv = GPIOMUX_DRV_10MA, |
| 289 | .pull = GPIOMUX_PULL_NONE, |
| 290 | }; |
| 291 | |
| 292 | static struct gpiomux_setting qpic_lcdc_rs = { |
| 293 | .func = GPIOMUX_FUNC_1, |
| 294 | .drv = GPIOMUX_DRV_10MA, |
| 295 | .pull = GPIOMUX_PULL_NONE, |
| 296 | }; |
| 297 | |
| 298 | static struct gpiomux_setting qpic_lcdc_te = { |
| 299 | .func = GPIOMUX_FUNC_7, |
| 300 | .drv = GPIOMUX_DRV_10MA, |
| 301 | .pull = GPIOMUX_PULL_NONE, |
| 302 | }; |
| 303 | |
| 304 | static struct msm_gpiomux_config msm9625_qpic_lcdc_configs[] __initdata = { |
| 305 | { |
| 306 | .gpio = 20, /* a_d */ |
| 307 | .settings = { |
| 308 | [GPIOMUX_SUSPENDED] = &qpic_lcdc_a_d, |
| 309 | }, |
| 310 | }, |
| 311 | { |
| 312 | .gpio = 21, /* cs */ |
| 313 | .settings = { |
| 314 | [GPIOMUX_SUSPENDED] = &qpic_lcdc_cs, |
| 315 | }, |
| 316 | }, |
| 317 | { |
| 318 | .gpio = 22, /* te */ |
| 319 | .settings = { |
| 320 | [GPIOMUX_SUSPENDED] = &qpic_lcdc_te, |
| 321 | }, |
| 322 | }, |
| 323 | { |
| 324 | .gpio = 23, /* rs */ |
| 325 | .settings = { |
| 326 | [GPIOMUX_SUSPENDED] = &qpic_lcdc_rs, |
| 327 | }, |
| 328 | }, |
| 329 | }; |
| 330 | |
Ken Zhang | 6572aae | 2013-04-17 09:02:02 -0400 | [diff] [blame] | 331 | static void msm9625_disp_init_gpiomux(void) |
| 332 | { |
| 333 | msm_gpiomux_install(msm9625_qpic_lcdc_configs, |
| 334 | ARRAY_SIZE(msm9625_qpic_lcdc_configs)); |
| 335 | } |
| 336 | #else |
| 337 | static void msm9625_disp_init_gpiomux(void) |
| 338 | { |
| 339 | } |
| 340 | #endif /* CONFIG_FB_MSM_QPIC */ |
| 341 | |
Jin Hong | 690e335 | 2012-05-02 09:25:05 -0700 | [diff] [blame] | 342 | void __init msm9625_init_gpiomux(void) |
| 343 | { |
| 344 | int rc; |
| 345 | |
Rohit Vaswani | 341c203 | 2012-11-08 18:49:29 -0800 | [diff] [blame] | 346 | rc = msm_gpiomux_init_dt(); |
Jin Hong | 690e335 | 2012-05-02 09:25:05 -0700 | [diff] [blame] | 347 | if (rc) { |
Rohit Vaswani | 341c203 | 2012-11-08 18:49:29 -0800 | [diff] [blame] | 348 | pr_err("%s failed %d\n", __func__, rc); |
Jin Hong | 690e335 | 2012-05-02 09:25:05 -0700 | [diff] [blame] | 349 | return; |
| 350 | } |
| 351 | |
| 352 | msm_gpiomux_install(msm_blsp_configs, ARRAY_SIZE(msm_blsp_configs)); |
Oluwafemi Adeyemi | 4926a9e | 2012-09-14 17:39:59 -0700 | [diff] [blame] | 353 | msm_gpiomux_install(sdc3_configs, ARRAY_SIZE(sdc3_configs)); |
Pavan Kumar | 07c070b | 2012-10-29 18:58:49 -0700 | [diff] [blame] | 354 | msm_gpiomux_install(wlan_ath6kl_configs, |
| 355 | ARRAY_SIZE(wlan_ath6kl_configs)); |
Venkat Sudhir | 39711d0 | 2012-10-12 16:47:29 -0700 | [diff] [blame] | 356 | msm_gpiomux_install(mdm9625_mi2s_configs, |
| 357 | ARRAY_SIZE(mdm9625_mi2s_configs)); |
| 358 | msm_gpiomux_install(mdm9625_cdc_reset_config, |
| 359 | ARRAY_SIZE(mdm9625_cdc_reset_config)); |
Oluwafemi Adeyemi | 938a495 | 2012-11-06 14:03:38 -0800 | [diff] [blame] | 360 | msm_gpiomux_install(sdc2_card_det_config, |
| 361 | ARRAY_SIZE(sdc2_card_det_config)); |
Ken Zhang | 6572aae | 2013-04-17 09:02:02 -0400 | [diff] [blame] | 362 | msm9625_disp_init_gpiomux(); |
Jin Hong | 690e335 | 2012-05-02 09:25:05 -0700 | [diff] [blame] | 363 | } |