Stepan Moskovchenko | 5ea3c31 | 2012-01-31 18:19:40 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved. |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [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 <linux/platform_device.h> |
| 17 | #include <linux/bootmem.h> |
| 18 | #include <asm/mach-types.h> |
| 19 | #include <asm/mach/mmc.h> |
| 20 | #include <mach/msm_bus_board.h> |
| 21 | #include <mach/board.h> |
| 22 | #include <mach/gpio.h> |
| 23 | #include <mach/gpiomux.h> |
Joel King | dacbc82 | 2012-01-25 13:30:57 -0800 | [diff] [blame] | 24 | #include <mach/socinfo.h> |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 25 | #include "devices.h" |
| 26 | #include "board-8064.h" |
| 27 | |
| 28 | #if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE) |
| 29 | static struct gpiomux_setting gpio_eth_config = { |
| 30 | .pull = GPIOMUX_PULL_NONE, |
| 31 | .drv = GPIOMUX_DRV_8MA, |
| 32 | .func = GPIOMUX_FUNC_GPIO, |
| 33 | }; |
| 34 | |
| 35 | /* The SPI configurations apply to GSBI 5*/ |
| 36 | static struct gpiomux_setting gpio_spi_config = { |
| 37 | .func = GPIOMUX_FUNC_2, |
Stepan Moskovchenko | c71c979 | 2012-01-31 18:12:44 -0800 | [diff] [blame] | 38 | .drv = GPIOMUX_DRV_12MA, |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 39 | .pull = GPIOMUX_PULL_NONE, |
| 40 | }; |
| 41 | |
| 42 | /* The SPI configurations apply to GSBI 5 chip select 2*/ |
| 43 | static struct gpiomux_setting gpio_spi_cs2_config = { |
| 44 | .func = GPIOMUX_FUNC_3, |
Stepan Moskovchenko | c71c979 | 2012-01-31 18:12:44 -0800 | [diff] [blame] | 45 | .drv = GPIOMUX_DRV_12MA, |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 46 | .pull = GPIOMUX_PULL_NONE, |
| 47 | }; |
| 48 | |
Stepan Moskovchenko | c71c979 | 2012-01-31 18:12:44 -0800 | [diff] [blame] | 49 | /* Chip selects for SPI clients */ |
| 50 | static struct gpiomux_setting gpio_spi_cs_config = { |
| 51 | .func = GPIOMUX_FUNC_GPIO, |
| 52 | .drv = GPIOMUX_DRV_12MA, |
| 53 | .pull = GPIOMUX_PULL_UP, |
| 54 | }; |
| 55 | |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 56 | struct msm_gpiomux_config apq8064_ethernet_configs[] = { |
| 57 | { |
| 58 | .gpio = 43, |
| 59 | .settings = { |
| 60 | [GPIOMUX_SUSPENDED] = &gpio_eth_config, |
| 61 | [GPIOMUX_ACTIVE] = &gpio_eth_config, |
| 62 | } |
| 63 | }, |
| 64 | }; |
| 65 | #endif |
| 66 | |
Swaminathan Sathappan | cef966d | 2011-12-15 17:27:04 -0800 | [diff] [blame] | 67 | static struct gpiomux_setting cdc_mclk = { |
| 68 | .func = GPIOMUX_FUNC_1, |
| 69 | .drv = GPIOMUX_DRV_8MA, |
| 70 | .pull = GPIOMUX_PULL_NONE, |
| 71 | }; |
| 72 | |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 73 | static struct gpiomux_setting audio_auxpcm[] = { |
| 74 | /* Suspended state */ |
| 75 | { |
| 76 | .func = GPIOMUX_FUNC_GPIO, |
| 77 | .drv = GPIOMUX_DRV_2MA, |
| 78 | .pull = GPIOMUX_PULL_NONE, |
| 79 | }, |
| 80 | /* Active state */ |
| 81 | { |
| 82 | .func = GPIOMUX_FUNC_1, |
| 83 | .drv = GPIOMUX_DRV_2MA, |
| 84 | .pull = GPIOMUX_PULL_NONE, |
| 85 | }, |
| 86 | }; |
| 87 | |
Swaminathan Sathappan | cef966d | 2011-12-15 17:27:04 -0800 | [diff] [blame] | 88 | static struct gpiomux_setting slimbus = { |
| 89 | .func = GPIOMUX_FUNC_1, |
| 90 | .drv = GPIOMUX_DRV_8MA, |
| 91 | .pull = GPIOMUX_PULL_KEEPER, |
| 92 | }; |
| 93 | |
Stepan Moskovchenko | 5ea3c31 | 2012-01-31 18:19:40 -0800 | [diff] [blame] | 94 | static struct gpiomux_setting gsbi1_uart_config = { |
| 95 | .func = GPIOMUX_FUNC_1, |
| 96 | .drv = GPIOMUX_DRV_16MA, |
| 97 | .pull = GPIOMUX_PULL_NONE, |
| 98 | }; |
| 99 | |
David Collins | f0d0073 | 2012-01-25 15:46:50 -0800 | [diff] [blame] | 100 | static struct gpiomux_setting ext_regulator_config = { |
| 101 | .func = GPIOMUX_FUNC_GPIO, |
| 102 | .drv = GPIOMUX_DRV_8MA, |
| 103 | .pull = GPIOMUX_PULL_NONE, |
| 104 | .dir = GPIOMUX_OUT_LOW, |
| 105 | }; |
| 106 | |
Hemant Kumar | a945b47 | 2012-01-25 15:08:06 -0800 | [diff] [blame^] | 107 | #ifdef CONFIG_USB_EHCI_MSM_HSIC |
| 108 | static struct gpiomux_setting hsic_act_cfg = { |
| 109 | .func = GPIOMUX_FUNC_1, |
| 110 | .drv = GPIOMUX_DRV_8MA, |
| 111 | .pull = GPIOMUX_PULL_NONE, |
| 112 | }; |
| 113 | |
| 114 | static struct gpiomux_setting hsic_sus_cfg = { |
| 115 | .func = GPIOMUX_FUNC_GPIO, |
| 116 | .drv = GPIOMUX_DRV_2MA, |
| 117 | .pull = GPIOMUX_PULL_DOWN, |
| 118 | .dir = GPIOMUX_OUT_LOW, |
| 119 | }; |
| 120 | |
| 121 | static struct msm_gpiomux_config apq8064_hsic_configs[] = { |
| 122 | { |
| 123 | .gpio = 88, /*HSIC_STROBE */ |
| 124 | .settings = { |
| 125 | [GPIOMUX_ACTIVE] = &hsic_act_cfg, |
| 126 | [GPIOMUX_SUSPENDED] = &hsic_sus_cfg, |
| 127 | }, |
| 128 | }, |
| 129 | { |
| 130 | .gpio = 89, /* HSIC_DATA */ |
| 131 | .settings = { |
| 132 | [GPIOMUX_ACTIVE] = &hsic_act_cfg, |
| 133 | [GPIOMUX_SUSPENDED] = &hsic_sus_cfg, |
| 134 | }, |
| 135 | }, |
| 136 | }; |
| 137 | #endif |
| 138 | |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 139 | static struct msm_gpiomux_config apq8064_gsbi_configs[] __initdata = { |
Stepan Moskovchenko | 5ea3c31 | 2012-01-31 18:19:40 -0800 | [diff] [blame] | 140 | { |
| 141 | .gpio = 18, /* GSBI1 UART TX */ |
| 142 | .settings = { |
| 143 | [GPIOMUX_SUSPENDED] = &gsbi1_uart_config, |
| 144 | }, |
| 145 | }, |
| 146 | { |
| 147 | .gpio = 19, /* GSBI1 UART RX */ |
| 148 | .settings = { |
| 149 | [GPIOMUX_SUSPENDED] = &gsbi1_uart_config, |
| 150 | }, |
| 151 | }, |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 152 | #if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE) |
| 153 | { |
| 154 | .gpio = 51, /* GSBI5 QUP SPI_DATA_MOSI */ |
| 155 | .settings = { |
| 156 | [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| 157 | }, |
| 158 | }, |
| 159 | { |
| 160 | .gpio = 52, /* GSBI5 QUP SPI_DATA_MISO */ |
| 161 | .settings = { |
| 162 | [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| 163 | }, |
| 164 | }, |
| 165 | { |
Stepan Moskovchenko | c71c979 | 2012-01-31 18:12:44 -0800 | [diff] [blame] | 166 | .gpio = 53, /* Funny CS0 */ |
| 167 | .settings = { |
| 168 | [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| 169 | }, |
| 170 | }, |
| 171 | { |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 172 | .gpio = 31, /* GSBI5 QUP SPI_CS2_N */ |
| 173 | .settings = { |
| 174 | [GPIOMUX_SUSPENDED] = &gpio_spi_cs2_config, |
| 175 | }, |
| 176 | }, |
| 177 | { |
| 178 | .gpio = 54, /* GSBI5 QUP SPI_CLK */ |
| 179 | .settings = { |
| 180 | [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| 181 | }, |
| 182 | }, |
| 183 | #endif |
Stepan Moskovchenko | c71c979 | 2012-01-31 18:12:44 -0800 | [diff] [blame] | 184 | { |
| 185 | .gpio = 30, /* FP CS */ |
| 186 | .settings = { |
| 187 | [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config, |
| 188 | }, |
| 189 | }, |
| 190 | { |
| 191 | .gpio = 32, /* EPM CS */ |
| 192 | .settings = { |
| 193 | [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config, |
| 194 | }, |
| 195 | }, |
| 196 | { |
| 197 | .gpio = 53, /* NOR CS */ |
| 198 | .settings = { |
| 199 | [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config, |
| 200 | }, |
| 201 | }, |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 202 | }; |
| 203 | |
Swaminathan Sathappan | cef966d | 2011-12-15 17:27:04 -0800 | [diff] [blame] | 204 | static struct msm_gpiomux_config apq8064_slimbus_config[] __initdata = { |
| 205 | { |
| 206 | .gpio = 40, /* slimbus clk */ |
| 207 | .settings = { |
| 208 | [GPIOMUX_SUSPENDED] = &slimbus, |
| 209 | }, |
| 210 | }, |
| 211 | { |
| 212 | .gpio = 41, /* slimbus data */ |
| 213 | .settings = { |
| 214 | [GPIOMUX_SUSPENDED] = &slimbus, |
| 215 | }, |
| 216 | }, |
| 217 | }; |
| 218 | |
| 219 | static struct msm_gpiomux_config apq8064_audio_codec_configs[] __initdata = { |
| 220 | { |
| 221 | .gpio = 39, |
| 222 | .settings = { |
| 223 | [GPIOMUX_SUSPENDED] = &cdc_mclk, |
| 224 | }, |
| 225 | }, |
| 226 | }; |
| 227 | |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 228 | static struct msm_gpiomux_config apq8064_audio_auxpcm_configs[] __initdata = { |
| 229 | { |
| 230 | .gpio = 43, |
| 231 | .settings = { |
| 232 | [GPIOMUX_SUSPENDED] = &audio_auxpcm[0], |
| 233 | [GPIOMUX_ACTIVE] = &audio_auxpcm[1], |
| 234 | }, |
| 235 | }, |
| 236 | { |
| 237 | .gpio = 44, |
| 238 | .settings = { |
| 239 | [GPIOMUX_SUSPENDED] = &audio_auxpcm[0], |
| 240 | [GPIOMUX_ACTIVE] = &audio_auxpcm[1], |
| 241 | }, |
| 242 | }, |
| 243 | { |
| 244 | .gpio = 45, |
| 245 | .settings = { |
| 246 | [GPIOMUX_SUSPENDED] = &audio_auxpcm[0], |
| 247 | [GPIOMUX_ACTIVE] = &audio_auxpcm[1], |
| 248 | }, |
| 249 | }, |
| 250 | { |
| 251 | .gpio = 46, |
| 252 | .settings = { |
| 253 | [GPIOMUX_SUSPENDED] = &audio_auxpcm[0], |
| 254 | [GPIOMUX_ACTIVE] = &audio_auxpcm[1], |
| 255 | }, |
| 256 | }, |
| 257 | }; |
| 258 | |
David Collins | f0d0073 | 2012-01-25 15:46:50 -0800 | [diff] [blame] | 259 | /* External 3.3 V regulator enable */ |
| 260 | static struct msm_gpiomux_config apq8064_ext_regulator_configs[] __initdata = { |
| 261 | { |
| 262 | .gpio = APQ8064_EXT_3P3V_REG_EN_GPIO, |
| 263 | .settings = { |
| 264 | [GPIOMUX_SUSPENDED] = &ext_regulator_config, |
| 265 | }, |
| 266 | }, |
| 267 | }; |
| 268 | |
Joel King | dacbc82 | 2012-01-25 13:30:57 -0800 | [diff] [blame] | 269 | static struct gpiomux_setting ap2mdm_cfg = { |
| 270 | .func = GPIOMUX_FUNC_GPIO, |
| 271 | .drv = GPIOMUX_DRV_8MA, |
| 272 | .pull = GPIOMUX_PULL_DOWN, |
| 273 | }; |
| 274 | |
| 275 | static struct gpiomux_setting mdm2ap_status_cfg = { |
| 276 | .func = GPIOMUX_FUNC_GPIO, |
| 277 | .drv = GPIOMUX_DRV_8MA, |
| 278 | .pull = GPIOMUX_PULL_NONE, |
| 279 | }; |
| 280 | |
| 281 | static struct gpiomux_setting mdm2ap_errfatal_cfg = { |
| 282 | .func = GPIOMUX_FUNC_GPIO, |
| 283 | .drv = GPIOMUX_DRV_16MA, |
| 284 | .pull = GPIOMUX_PULL_DOWN, |
| 285 | }; |
| 286 | |
| 287 | static struct gpiomux_setting ap2mdm_pon_reset_n_cfg = { |
| 288 | .func = GPIOMUX_FUNC_GPIO, |
| 289 | .drv = GPIOMUX_DRV_8MA, |
| 290 | .pull = GPIOMUX_PULL_DOWN, |
| 291 | }; |
| 292 | |
| 293 | static struct msm_gpiomux_config mdm_configs[] __initdata = { |
| 294 | /* AP2MDM_STATUS */ |
| 295 | { |
| 296 | .gpio = 48, |
| 297 | .settings = { |
| 298 | [GPIOMUX_SUSPENDED] = &ap2mdm_cfg, |
| 299 | } |
| 300 | }, |
| 301 | /* MDM2AP_STATUS */ |
| 302 | { |
| 303 | .gpio = 49, |
| 304 | .settings = { |
| 305 | [GPIOMUX_SUSPENDED] = &mdm2ap_status_cfg, |
| 306 | } |
| 307 | }, |
| 308 | /* MDM2AP_ERRFATAL */ |
| 309 | { |
| 310 | .gpio = 19, |
| 311 | .settings = { |
| 312 | [GPIOMUX_SUSPENDED] = &mdm2ap_errfatal_cfg, |
| 313 | } |
| 314 | }, |
| 315 | /* AP2MDM_ERRFATAL */ |
| 316 | { |
| 317 | .gpio = 18, |
| 318 | .settings = { |
| 319 | [GPIOMUX_SUSPENDED] = &ap2mdm_cfg, |
| 320 | } |
| 321 | }, |
| 322 | /* AP2MDM_PON_RESET_N */ |
| 323 | { |
| 324 | .gpio = 27, |
| 325 | .settings = { |
| 326 | [GPIOMUX_SUSPENDED] = &ap2mdm_pon_reset_n_cfg, |
| 327 | } |
| 328 | } |
| 329 | }; |
| 330 | |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 331 | void __init apq8064_init_gpiomux(void) |
| 332 | { |
| 333 | int rc; |
| 334 | |
| 335 | rc = msm_gpiomux_init(NR_GPIO_IRQS); |
| 336 | if (rc) { |
| 337 | pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc); |
| 338 | return; |
| 339 | } |
| 340 | |
| 341 | #if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE) |
| 342 | msm_gpiomux_install(apq8064_ethernet_configs, |
| 343 | ARRAY_SIZE(apq8064_ethernet_configs)); |
| 344 | #endif |
| 345 | |
| 346 | msm_gpiomux_install(apq8064_gsbi_configs, |
| 347 | ARRAY_SIZE(apq8064_gsbi_configs)); |
| 348 | |
Swaminathan Sathappan | cef966d | 2011-12-15 17:27:04 -0800 | [diff] [blame] | 349 | msm_gpiomux_install(apq8064_slimbus_config, |
| 350 | ARRAY_SIZE(apq8064_slimbus_config)); |
| 351 | |
| 352 | msm_gpiomux_install(apq8064_audio_codec_configs, |
| 353 | ARRAY_SIZE(apq8064_audio_codec_configs)); |
| 354 | |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 355 | msm_gpiomux_install(apq8064_audio_auxpcm_configs, |
| 356 | ARRAY_SIZE(apq8064_audio_auxpcm_configs)); |
David Collins | f0d0073 | 2012-01-25 15:46:50 -0800 | [diff] [blame] | 357 | |
| 358 | msm_gpiomux_install(apq8064_ext_regulator_configs, |
| 359 | ARRAY_SIZE(apq8064_ext_regulator_configs)); |
Joel King | dacbc82 | 2012-01-25 13:30:57 -0800 | [diff] [blame] | 360 | |
| 361 | if (machine_is_apq8064_mtp()) |
| 362 | msm_gpiomux_install(mdm_configs, |
| 363 | ARRAY_SIZE(mdm_configs)); |
Hemant Kumar | a945b47 | 2012-01-25 15:08:06 -0800 | [diff] [blame^] | 364 | |
| 365 | #ifdef CONFIG_USB_EHCI_MSM_HSIC |
| 366 | msm_gpiomux_install(apq8064_hsic_configs, |
| 367 | ARRAY_SIZE(apq8064_hsic_configs)); |
| 368 | #endif |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 369 | } |