Gilad Avidov | 28e18eb | 2012-11-21 18:13:25 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
Syed Rameez Mustafa | 9d16c4f | 2012-09-10 14:16:55 -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 | |
aiquny | 76b4608 | 2013-03-13 15:58:08 -0700 | [diff] [blame] | 20 | #define KS8851_IRQ_GPIO 115 |
Syed Rameez Mustafa | 01d15eb | 2012-12-20 15:30:17 -0800 | [diff] [blame] | 21 | |
| 22 | #if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE) |
| 23 | static struct gpiomux_setting gpio_eth_config = { |
| 24 | .pull = GPIOMUX_PULL_UP, |
| 25 | .drv = GPIOMUX_DRV_2MA, |
| 26 | .func = GPIOMUX_FUNC_GPIO, |
| 27 | }; |
Syed Rameez Mustafa | 01d15eb | 2012-12-20 15:30:17 -0800 | [diff] [blame] | 28 | |
| 29 | static 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 Avidov | 28e18eb | 2012-11-21 18:13:25 -0700 | [diff] [blame] | 37 | #endif |
| 38 | |
Amy Maloche | 41708ba | 2013-03-03 15:19:27 -0800 | [diff] [blame] | 39 | static struct gpiomux_setting synaptics_int_act_cfg = { |
| 40 | .func = GPIOMUX_FUNC_GPIO, |
| 41 | .drv = GPIOMUX_DRV_8MA, |
| 42 | .pull = GPIOMUX_PULL_UP, |
| 43 | }; |
| 44 | |
| 45 | static struct gpiomux_setting synaptics_int_sus_cfg = { |
| 46 | .func = GPIOMUX_FUNC_GPIO, |
| 47 | .drv = GPIOMUX_DRV_2MA, |
| 48 | .pull = GPIOMUX_PULL_DOWN, |
| 49 | }; |
| 50 | |
| 51 | static struct gpiomux_setting synaptics_reset_act_cfg = { |
| 52 | .func = GPIOMUX_FUNC_GPIO, |
| 53 | .drv = GPIOMUX_DRV_6MA, |
| 54 | .pull = GPIOMUX_PULL_DOWN, |
| 55 | }; |
| 56 | |
| 57 | static 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 Maloche | 24c59dd | 2013-03-05 11:43:55 -0800 | [diff] [blame] | 63 | static struct gpiomux_setting gpio_keys_active = { |
| 64 | .func = GPIOMUX_FUNC_GPIO, |
| 65 | .drv = GPIOMUX_DRV_2MA, |
| 66 | .pull = GPIOMUX_PULL_UP, |
| 67 | }; |
| 68 | |
| 69 | static struct gpiomux_setting gpio_keys_suspend = { |
| 70 | .func = GPIOMUX_FUNC_GPIO, |
| 71 | .drv = GPIOMUX_DRV_2MA, |
| 72 | .pull = GPIOMUX_PULL_NONE, |
| 73 | }; |
| 74 | |
Gilad Avidov | 28e18eb | 2012-11-21 18:13:25 -0700 | [diff] [blame] | 75 | static struct gpiomux_setting gpio_spi_config = { |
| 76 | .func = GPIOMUX_FUNC_1, |
| 77 | .drv = GPIOMUX_DRV_8MA, |
| 78 | .pull = GPIOMUX_PULL_NONE, |
| 79 | }; |
| 80 | |
Gilad Avidov | d59217c | 2013-02-01 13:45:59 -0700 | [diff] [blame] | 81 | static struct gpiomux_setting gpio_spi_cs_config = { |
| 82 | .func = GPIOMUX_FUNC_1, |
| 83 | .drv = GPIOMUX_DRV_6MA, |
| 84 | .pull = GPIOMUX_PULL_DOWN, |
| 85 | }; |
| 86 | |
aiquny | 76b4608 | 2013-03-13 15:58:08 -0700 | [diff] [blame] | 87 | static 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 Fang | 6746c3f | 2013-03-19 08:37:13 +0800 | [diff] [blame] | 93 | static struct gpiomux_setting wcnss_5wire_suspend_cfg = { |
| 94 | .func = GPIOMUX_FUNC_GPIO, |
| 95 | .drv = GPIOMUX_DRV_2MA, |
| 96 | .pull = GPIOMUX_PULL_UP, |
| 97 | }; |
| 98 | |
| 99 | static 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 Avidov | 28e18eb | 2012-11-21 18:13:25 -0700 | [diff] [blame] | 105 | static struct gpiomux_setting gpio_i2c_config = { |
| 106 | .func = GPIOMUX_FUNC_3, |
| 107 | .drv = GPIOMUX_DRV_2MA, |
| 108 | .pull = GPIOMUX_PULL_NONE, |
| 109 | }; |
Syed Rameez Mustafa | 01d15eb | 2012-12-20 15:30:17 -0800 | [diff] [blame] | 110 | |
Amy Maloche | 24c59dd | 2013-03-05 11:43:55 -0800 | [diff] [blame] | 111 | static 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 Venkateswaran | f60fb21 | 2013-03-08 13:57:06 -0800 | [diff] [blame] | 135 | static 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 | |
| 142 | static struct gpiomux_setting lcd_rst_sus_cfg = { |
| 143 | .func = GPIOMUX_FUNC_GPIO, |
| 144 | .drv = GPIOMUX_DRV_2MA, |
| 145 | .pull = GPIOMUX_PULL_DOWN, |
| 146 | }; |
| 147 | |
| 148 | static 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 Mustafa | 01d15eb | 2012-12-20 15:30:17 -0800 | [diff] [blame] | 158 | static struct msm_gpiomux_config msm_blsp_configs[] __initdata = { |
| 159 | { |
Gilad Avidov | d59217c | 2013-02-01 13:45:59 -0700 | [diff] [blame] | 160 | .gpio = 0, /* BLSP1 QUP1 SPI_DATA_MOSI */ |
Syed Rameez Mustafa | 01d15eb | 2012-12-20 15:30:17 -0800 | [diff] [blame] | 161 | .settings = { |
| 162 | [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| 163 | }, |
| 164 | }, |
| 165 | { |
Gilad Avidov | d59217c | 2013-02-01 13:45:59 -0700 | [diff] [blame] | 166 | .gpio = 1, /* BLSP1 QUP1 SPI_DATA_MISO */ |
Syed Rameez Mustafa | 01d15eb | 2012-12-20 15:30:17 -0800 | [diff] [blame] | 167 | .settings = { |
| 168 | [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| 169 | }, |
| 170 | }, |
| 171 | { |
Gilad Avidov | d59217c | 2013-02-01 13:45:59 -0700 | [diff] [blame] | 172 | .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 Mustafa | 01d15eb | 2012-12-20 15:30:17 -0800 | [diff] [blame] | 179 | .settings = { |
| 180 | [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| 181 | }, |
| 182 | }, |
| 183 | { |
Gilad Avidov | d59217c | 2013-02-01 13:45:59 -0700 | [diff] [blame] | 184 | .gpio = 14, /* BLSP1 QUP4 I2C_SDA */ |
Gilad Avidov | 28e18eb | 2012-11-21 18:13:25 -0700 | [diff] [blame] | 185 | .settings = { |
| 186 | [GPIOMUX_SUSPENDED] = &gpio_i2c_config, |
| 187 | }, |
| 188 | }, |
| 189 | { |
Gilad Avidov | d59217c | 2013-02-01 13:45:59 -0700 | [diff] [blame] | 190 | .gpio = 15, /* BLSP1 QUP4 I2C_SCL */ |
Gilad Avidov | 28e18eb | 2012-11-21 18:13:25 -0700 | [diff] [blame] | 191 | .settings = { |
| 192 | [GPIOMUX_SUSPENDED] = &gpio_i2c_config, |
| 193 | }, |
| 194 | }, |
Amy Maloche | 41708ba | 2013-03-03 15:19:27 -0800 | [diff] [blame] | 195 | { |
| 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 | }, |
aiquny | 76b4608 | 2013-03-13 15:58:08 -0700 | [diff] [blame] | 207 | { |
| 208 | .gpio = 22, /* BLSP1 QUP1 SPI_CS_ETH */ |
| 209 | .settings = { |
| 210 | [GPIOMUX_SUSPENDED] = &gpio_spi_cs_eth_config, |
| 211 | }, |
| 212 | }, |
Amy Maloche | 41708ba | 2013-03-03 15:19:27 -0800 | [diff] [blame] | 213 | }; |
| 214 | |
| 215 | static 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 Mustafa | 01d15eb | 2012-12-20 15:30:17 -0800 | [diff] [blame] | 230 | }; |
Syed Rameez Mustafa | 01d15eb | 2012-12-20 15:30:17 -0800 | [diff] [blame] | 231 | |
Krishna Konda | 7af5df9 | 2013-03-06 20:35:30 -0800 | [diff] [blame] | 232 | static 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 | |
| 239 | static 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 | |
| 246 | static 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 Fang | 6746c3f | 2013-03-19 08:37:13 +0800 | [diff] [blame] | 254 | static 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 Mustafa | 9d16c4f | 2012-09-10 14:16:55 -0700 | [diff] [blame] | 291 | void __init msm8226_init_gpiomux(void) |
| 292 | { |
| 293 | int rc; |
| 294 | |
Rohit Vaswani | 341c203 | 2012-11-08 18:49:29 -0800 | [diff] [blame] | 295 | rc = msm_gpiomux_init_dt(); |
Syed Rameez Mustafa | 9d16c4f | 2012-09-10 14:16:55 -0700 | [diff] [blame] | 296 | if (rc) { |
Rohit Vaswani | 341c203 | 2012-11-08 18:49:29 -0800 | [diff] [blame] | 297 | pr_err("%s failed %d\n", __func__, rc); |
Syed Rameez Mustafa | 9d16c4f | 2012-09-10 14:16:55 -0700 | [diff] [blame] | 298 | return; |
| 299 | } |
Gilad Avidov | 28e18eb | 2012-11-21 18:13:25 -0700 | [diff] [blame] | 300 | |
Syed Rameez Mustafa | 01d15eb | 2012-12-20 15:30:17 -0800 | [diff] [blame] | 301 | #if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE) |
| 302 | msm_gpiomux_install(msm_eth_configs, ARRAY_SIZE(msm_eth_configs)); |
Syed Rameez Mustafa | 01d15eb | 2012-12-20 15:30:17 -0800 | [diff] [blame] | 303 | #endif |
Amy Maloche | 24c59dd | 2013-03-05 11:43:55 -0800 | [diff] [blame] | 304 | msm_gpiomux_install(msm_keypad_configs, |
| 305 | ARRAY_SIZE(msm_keypad_configs)); |
Gilad Avidov | 28e18eb | 2012-11-21 18:13:25 -0700 | [diff] [blame] | 306 | |
| 307 | msm_gpiomux_install(msm_blsp_configs, ARRAY_SIZE(msm_blsp_configs)); |
Sheng Fang | 6746c3f | 2013-03-19 08:37:13 +0800 | [diff] [blame] | 308 | msm_gpiomux_install(wcnss_5wire_interface, |
| 309 | ARRAY_SIZE(wcnss_5wire_interface)); |
Krishna Konda | 7af5df9 | 2013-03-06 20:35:30 -0800 | [diff] [blame] | 310 | |
| 311 | msm_gpiomux_install(&sd_card_det, 1); |
Amy Maloche | 41708ba | 2013-03-03 15:19:27 -0800 | [diff] [blame] | 312 | msm_gpiomux_install(msm_synaptics_configs, |
| 313 | ARRAY_SIZE(msm_synaptics_configs)); |
Aravind Venkateswaran | f60fb21 | 2013-03-08 13:57:06 -0800 | [diff] [blame] | 314 | msm_gpiomux_install_nowrite(msm_lcd_configs, |
| 315 | ARRAY_SIZE(msm_lcd_configs)); |
Syed Rameez Mustafa | 9d16c4f | 2012-09-10 14:16:55 -0700 | [diff] [blame] | 316 | } |