Jin Hong | 690e335 | 2012-05-02 09:25:05 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2012, Code Aurora Forum. All rights reserved. |
| 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 | |
Jin Hong | 690e335 | 2012-05-02 09:25:05 -0700 | [diff] [blame] | 262 | void __init msm9625_init_gpiomux(void) |
| 263 | { |
| 264 | int rc; |
| 265 | |
| 266 | rc = msm_gpiomux_init(NR_GPIO_IRQS); |
| 267 | if (rc) { |
| 268 | pr_err(KERN_ERR "msm9625_init_gpiomux failed %d\n", rc); |
| 269 | return; |
| 270 | } |
| 271 | |
| 272 | msm_gpiomux_install(msm_blsp_configs, ARRAY_SIZE(msm_blsp_configs)); |
Oluwafemi Adeyemi | 4926a9e | 2012-09-14 17:39:59 -0700 | [diff] [blame] | 273 | msm_gpiomux_install(sdc3_configs, ARRAY_SIZE(sdc3_configs)); |
Pavan Kumar | 07c070b | 2012-10-29 18:58:49 -0700 | [diff] [blame] | 274 | msm_gpiomux_install(wlan_ath6kl_configs, |
| 275 | ARRAY_SIZE(wlan_ath6kl_configs)); |
Venkat Sudhir | 39711d0 | 2012-10-12 16:47:29 -0700 | [diff] [blame] | 276 | msm_gpiomux_install(mdm9625_mi2s_configs, |
| 277 | ARRAY_SIZE(mdm9625_mi2s_configs)); |
| 278 | msm_gpiomux_install(mdm9625_cdc_reset_config, |
| 279 | ARRAY_SIZE(mdm9625_cdc_reset_config)); |
Jin Hong | 690e335 | 2012-05-02 09:25:05 -0700 | [diff] [blame] | 280 | } |