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 | |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 107 | static struct msm_gpiomux_config apq8064_gsbi_configs[] __initdata = { |
Stepan Moskovchenko | 5ea3c31 | 2012-01-31 18:19:40 -0800 | [diff] [blame] | 108 | { |
| 109 | .gpio = 18, /* GSBI1 UART TX */ |
| 110 | .settings = { |
| 111 | [GPIOMUX_SUSPENDED] = &gsbi1_uart_config, |
| 112 | }, |
| 113 | }, |
| 114 | { |
| 115 | .gpio = 19, /* GSBI1 UART RX */ |
| 116 | .settings = { |
| 117 | [GPIOMUX_SUSPENDED] = &gsbi1_uart_config, |
| 118 | }, |
| 119 | }, |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 120 | #if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE) |
| 121 | { |
| 122 | .gpio = 51, /* GSBI5 QUP SPI_DATA_MOSI */ |
| 123 | .settings = { |
| 124 | [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| 125 | }, |
| 126 | }, |
| 127 | { |
| 128 | .gpio = 52, /* GSBI5 QUP SPI_DATA_MISO */ |
| 129 | .settings = { |
| 130 | [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| 131 | }, |
| 132 | }, |
| 133 | { |
Stepan Moskovchenko | c71c979 | 2012-01-31 18:12:44 -0800 | [diff] [blame] | 134 | .gpio = 53, /* Funny CS0 */ |
| 135 | .settings = { |
| 136 | [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| 137 | }, |
| 138 | }, |
| 139 | { |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 140 | .gpio = 31, /* GSBI5 QUP SPI_CS2_N */ |
| 141 | .settings = { |
| 142 | [GPIOMUX_SUSPENDED] = &gpio_spi_cs2_config, |
| 143 | }, |
| 144 | }, |
| 145 | { |
| 146 | .gpio = 54, /* GSBI5 QUP SPI_CLK */ |
| 147 | .settings = { |
| 148 | [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| 149 | }, |
| 150 | }, |
| 151 | #endif |
Stepan Moskovchenko | c71c979 | 2012-01-31 18:12:44 -0800 | [diff] [blame] | 152 | { |
| 153 | .gpio = 30, /* FP CS */ |
| 154 | .settings = { |
| 155 | [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config, |
| 156 | }, |
| 157 | }, |
| 158 | { |
| 159 | .gpio = 32, /* EPM CS */ |
| 160 | .settings = { |
| 161 | [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config, |
| 162 | }, |
| 163 | }, |
| 164 | { |
| 165 | .gpio = 53, /* NOR CS */ |
| 166 | .settings = { |
| 167 | [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config, |
| 168 | }, |
| 169 | }, |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 170 | }; |
| 171 | |
Swaminathan Sathappan | cef966d | 2011-12-15 17:27:04 -0800 | [diff] [blame] | 172 | static struct msm_gpiomux_config apq8064_slimbus_config[] __initdata = { |
| 173 | { |
| 174 | .gpio = 40, /* slimbus clk */ |
| 175 | .settings = { |
| 176 | [GPIOMUX_SUSPENDED] = &slimbus, |
| 177 | }, |
| 178 | }, |
| 179 | { |
| 180 | .gpio = 41, /* slimbus data */ |
| 181 | .settings = { |
| 182 | [GPIOMUX_SUSPENDED] = &slimbus, |
| 183 | }, |
| 184 | }, |
| 185 | }; |
| 186 | |
| 187 | static struct msm_gpiomux_config apq8064_audio_codec_configs[] __initdata = { |
| 188 | { |
| 189 | .gpio = 39, |
| 190 | .settings = { |
| 191 | [GPIOMUX_SUSPENDED] = &cdc_mclk, |
| 192 | }, |
| 193 | }, |
| 194 | }; |
| 195 | |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 196 | static struct msm_gpiomux_config apq8064_audio_auxpcm_configs[] __initdata = { |
| 197 | { |
| 198 | .gpio = 43, |
| 199 | .settings = { |
| 200 | [GPIOMUX_SUSPENDED] = &audio_auxpcm[0], |
| 201 | [GPIOMUX_ACTIVE] = &audio_auxpcm[1], |
| 202 | }, |
| 203 | }, |
| 204 | { |
| 205 | .gpio = 44, |
| 206 | .settings = { |
| 207 | [GPIOMUX_SUSPENDED] = &audio_auxpcm[0], |
| 208 | [GPIOMUX_ACTIVE] = &audio_auxpcm[1], |
| 209 | }, |
| 210 | }, |
| 211 | { |
| 212 | .gpio = 45, |
| 213 | .settings = { |
| 214 | [GPIOMUX_SUSPENDED] = &audio_auxpcm[0], |
| 215 | [GPIOMUX_ACTIVE] = &audio_auxpcm[1], |
| 216 | }, |
| 217 | }, |
| 218 | { |
| 219 | .gpio = 46, |
| 220 | .settings = { |
| 221 | [GPIOMUX_SUSPENDED] = &audio_auxpcm[0], |
| 222 | [GPIOMUX_ACTIVE] = &audio_auxpcm[1], |
| 223 | }, |
| 224 | }, |
| 225 | }; |
| 226 | |
David Collins | f0d0073 | 2012-01-25 15:46:50 -0800 | [diff] [blame] | 227 | /* External 3.3 V regulator enable */ |
| 228 | static struct msm_gpiomux_config apq8064_ext_regulator_configs[] __initdata = { |
| 229 | { |
| 230 | .gpio = APQ8064_EXT_3P3V_REG_EN_GPIO, |
| 231 | .settings = { |
| 232 | [GPIOMUX_SUSPENDED] = &ext_regulator_config, |
| 233 | }, |
| 234 | }, |
| 235 | }; |
| 236 | |
Joel King | dacbc82 | 2012-01-25 13:30:57 -0800 | [diff] [blame^] | 237 | static struct gpiomux_setting ap2mdm_cfg = { |
| 238 | .func = GPIOMUX_FUNC_GPIO, |
| 239 | .drv = GPIOMUX_DRV_8MA, |
| 240 | .pull = GPIOMUX_PULL_DOWN, |
| 241 | }; |
| 242 | |
| 243 | static struct gpiomux_setting mdm2ap_status_cfg = { |
| 244 | .func = GPIOMUX_FUNC_GPIO, |
| 245 | .drv = GPIOMUX_DRV_8MA, |
| 246 | .pull = GPIOMUX_PULL_NONE, |
| 247 | }; |
| 248 | |
| 249 | static struct gpiomux_setting mdm2ap_errfatal_cfg = { |
| 250 | .func = GPIOMUX_FUNC_GPIO, |
| 251 | .drv = GPIOMUX_DRV_16MA, |
| 252 | .pull = GPIOMUX_PULL_DOWN, |
| 253 | }; |
| 254 | |
| 255 | static struct gpiomux_setting ap2mdm_pon_reset_n_cfg = { |
| 256 | .func = GPIOMUX_FUNC_GPIO, |
| 257 | .drv = GPIOMUX_DRV_8MA, |
| 258 | .pull = GPIOMUX_PULL_DOWN, |
| 259 | }; |
| 260 | |
| 261 | static struct msm_gpiomux_config mdm_configs[] __initdata = { |
| 262 | /* AP2MDM_STATUS */ |
| 263 | { |
| 264 | .gpio = 48, |
| 265 | .settings = { |
| 266 | [GPIOMUX_SUSPENDED] = &ap2mdm_cfg, |
| 267 | } |
| 268 | }, |
| 269 | /* MDM2AP_STATUS */ |
| 270 | { |
| 271 | .gpio = 49, |
| 272 | .settings = { |
| 273 | [GPIOMUX_SUSPENDED] = &mdm2ap_status_cfg, |
| 274 | } |
| 275 | }, |
| 276 | /* MDM2AP_ERRFATAL */ |
| 277 | { |
| 278 | .gpio = 19, |
| 279 | .settings = { |
| 280 | [GPIOMUX_SUSPENDED] = &mdm2ap_errfatal_cfg, |
| 281 | } |
| 282 | }, |
| 283 | /* AP2MDM_ERRFATAL */ |
| 284 | { |
| 285 | .gpio = 18, |
| 286 | .settings = { |
| 287 | [GPIOMUX_SUSPENDED] = &ap2mdm_cfg, |
| 288 | } |
| 289 | }, |
| 290 | /* AP2MDM_PON_RESET_N */ |
| 291 | { |
| 292 | .gpio = 27, |
| 293 | .settings = { |
| 294 | [GPIOMUX_SUSPENDED] = &ap2mdm_pon_reset_n_cfg, |
| 295 | } |
| 296 | } |
| 297 | }; |
| 298 | |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 299 | void __init apq8064_init_gpiomux(void) |
| 300 | { |
| 301 | int rc; |
| 302 | |
| 303 | rc = msm_gpiomux_init(NR_GPIO_IRQS); |
| 304 | if (rc) { |
| 305 | pr_err(KERN_ERR "msm_gpiomux_init failed %d\n", rc); |
| 306 | return; |
| 307 | } |
| 308 | |
| 309 | #if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE) |
| 310 | msm_gpiomux_install(apq8064_ethernet_configs, |
| 311 | ARRAY_SIZE(apq8064_ethernet_configs)); |
| 312 | #endif |
| 313 | |
| 314 | msm_gpiomux_install(apq8064_gsbi_configs, |
| 315 | ARRAY_SIZE(apq8064_gsbi_configs)); |
| 316 | |
Swaminathan Sathappan | cef966d | 2011-12-15 17:27:04 -0800 | [diff] [blame] | 317 | msm_gpiomux_install(apq8064_slimbus_config, |
| 318 | ARRAY_SIZE(apq8064_slimbus_config)); |
| 319 | |
| 320 | msm_gpiomux_install(apq8064_audio_codec_configs, |
| 321 | ARRAY_SIZE(apq8064_audio_codec_configs)); |
| 322 | |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 323 | msm_gpiomux_install(apq8064_audio_auxpcm_configs, |
| 324 | ARRAY_SIZE(apq8064_audio_auxpcm_configs)); |
David Collins | f0d0073 | 2012-01-25 15:46:50 -0800 | [diff] [blame] | 325 | |
| 326 | msm_gpiomux_install(apq8064_ext_regulator_configs, |
| 327 | ARRAY_SIZE(apq8064_ext_regulator_configs)); |
Joel King | dacbc82 | 2012-01-25 13:30:57 -0800 | [diff] [blame^] | 328 | |
| 329 | if (machine_is_apq8064_mtp()) |
| 330 | msm_gpiomux_install(mdm_configs, |
| 331 | ARRAY_SIZE(mdm_configs)); |
Stepan Moskovchenko | 2327a95 | 2011-12-14 16:31:28 -0800 | [diff] [blame] | 332 | } |