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 | |
Syed Rameez Mustafa | 01d15eb | 2012-12-20 15:30:17 -0800 | [diff] [blame] | 20 | #define KS8851_IRQ_GPIO 75 |
| 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 | |
Gilad Avidov | 28e18eb | 2012-11-21 18:13:25 -0700 | [diff] [blame] | 87 | static struct gpiomux_setting gpio_i2c_config = { |
| 88 | .func = GPIOMUX_FUNC_3, |
| 89 | .drv = GPIOMUX_DRV_2MA, |
| 90 | .pull = GPIOMUX_PULL_NONE, |
| 91 | }; |
Syed Rameez Mustafa | 01d15eb | 2012-12-20 15:30:17 -0800 | [diff] [blame] | 92 | |
Amy Maloche | 24c59dd | 2013-03-05 11:43:55 -0800 | [diff] [blame] | 93 | static struct msm_gpiomux_config msm_keypad_configs[] __initdata = { |
| 94 | { |
| 95 | .gpio = 106, |
| 96 | .settings = { |
| 97 | [GPIOMUX_ACTIVE] = &gpio_keys_active, |
| 98 | [GPIOMUX_SUSPENDED] = &gpio_keys_suspend, |
| 99 | }, |
| 100 | }, |
| 101 | { |
| 102 | .gpio = 107, |
| 103 | .settings = { |
| 104 | [GPIOMUX_ACTIVE] = &gpio_keys_active, |
| 105 | [GPIOMUX_SUSPENDED] = &gpio_keys_suspend, |
| 106 | }, |
| 107 | }, |
| 108 | { |
| 109 | .gpio = 108, |
| 110 | .settings = { |
| 111 | [GPIOMUX_ACTIVE] = &gpio_keys_active, |
| 112 | [GPIOMUX_SUSPENDED] = &gpio_keys_suspend, |
| 113 | }, |
| 114 | }, |
| 115 | }; |
| 116 | |
Aravind Venkateswaran | f60fb21 | 2013-03-08 13:57:06 -0800 | [diff] [blame] | 117 | static struct gpiomux_setting lcd_rst_act_cfg = { |
| 118 | .func = GPIOMUX_FUNC_GPIO, |
| 119 | .drv = GPIOMUX_DRV_8MA, |
| 120 | .pull = GPIOMUX_PULL_NONE, |
| 121 | .dir = GPIOMUX_OUT_LOW, |
| 122 | }; |
| 123 | |
| 124 | static struct gpiomux_setting lcd_rst_sus_cfg = { |
| 125 | .func = GPIOMUX_FUNC_GPIO, |
| 126 | .drv = GPIOMUX_DRV_2MA, |
| 127 | .pull = GPIOMUX_PULL_DOWN, |
| 128 | }; |
| 129 | |
| 130 | static struct msm_gpiomux_config msm_lcd_configs[] __initdata = { |
| 131 | { |
| 132 | .gpio = 25, |
| 133 | .settings = { |
| 134 | [GPIOMUX_ACTIVE] = &lcd_rst_act_cfg, |
| 135 | [GPIOMUX_SUSPENDED] = &lcd_rst_sus_cfg, |
| 136 | }, |
| 137 | } |
| 138 | }; |
| 139 | |
Syed Rameez Mustafa | 01d15eb | 2012-12-20 15:30:17 -0800 | [diff] [blame] | 140 | static struct msm_gpiomux_config msm_blsp_configs[] __initdata = { |
| 141 | { |
Gilad Avidov | d59217c | 2013-02-01 13:45:59 -0700 | [diff] [blame] | 142 | .gpio = 0, /* BLSP1 QUP1 SPI_DATA_MOSI */ |
Syed Rameez Mustafa | 01d15eb | 2012-12-20 15:30:17 -0800 | [diff] [blame] | 143 | .settings = { |
| 144 | [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| 145 | }, |
| 146 | }, |
| 147 | { |
Gilad Avidov | d59217c | 2013-02-01 13:45:59 -0700 | [diff] [blame] | 148 | .gpio = 1, /* BLSP1 QUP1 SPI_DATA_MISO */ |
Syed Rameez Mustafa | 01d15eb | 2012-12-20 15:30:17 -0800 | [diff] [blame] | 149 | .settings = { |
| 150 | [GPIOMUX_SUSPENDED] = &gpio_spi_config, |
| 151 | }, |
| 152 | }, |
| 153 | { |
Gilad Avidov | d59217c | 2013-02-01 13:45:59 -0700 | [diff] [blame] | 154 | .gpio = 2, /* BLSP1 QUP1 SPI_CS1 */ |
| 155 | .settings = { |
| 156 | [GPIOMUX_SUSPENDED] = &gpio_spi_cs_config, |
| 157 | }, |
| 158 | }, |
| 159 | { |
| 160 | .gpio = 3, /* BLSP1 QUP1 SPI_CLK */ |
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 = 14, /* BLSP1 QUP4 I2C_SDA */ |
Gilad Avidov | 28e18eb | 2012-11-21 18:13:25 -0700 | [diff] [blame] | 167 | .settings = { |
| 168 | [GPIOMUX_SUSPENDED] = &gpio_i2c_config, |
| 169 | }, |
| 170 | }, |
| 171 | { |
Gilad Avidov | d59217c | 2013-02-01 13:45:59 -0700 | [diff] [blame] | 172 | .gpio = 15, /* BLSP1 QUP4 I2C_SCL */ |
Gilad Avidov | 28e18eb | 2012-11-21 18:13:25 -0700 | [diff] [blame] | 173 | .settings = { |
| 174 | [GPIOMUX_SUSPENDED] = &gpio_i2c_config, |
| 175 | }, |
| 176 | }, |
Amy Maloche | 41708ba | 2013-03-03 15:19:27 -0800 | [diff] [blame] | 177 | { |
| 178 | .gpio = 18, /* BLSP1 QUP5 I2C_SDA */ |
| 179 | .settings = { |
| 180 | [GPIOMUX_SUSPENDED] = &gpio_i2c_config, |
| 181 | }, |
| 182 | }, |
| 183 | { |
| 184 | .gpio = 19, /* BLSP1 QUP5 I2C_SCL */ |
| 185 | .settings = { |
| 186 | [GPIOMUX_SUSPENDED] = &gpio_i2c_config, |
| 187 | }, |
| 188 | }, |
| 189 | }; |
| 190 | |
| 191 | static struct msm_gpiomux_config msm_synaptics_configs[] __initdata = { |
| 192 | { |
| 193 | .gpio = 16, |
| 194 | .settings = { |
| 195 | [GPIOMUX_ACTIVE] = &synaptics_reset_act_cfg, |
| 196 | [GPIOMUX_SUSPENDED] = &synaptics_reset_sus_cfg, |
| 197 | }, |
| 198 | }, |
| 199 | { |
| 200 | .gpio = 17, |
| 201 | .settings = { |
| 202 | [GPIOMUX_ACTIVE] = &synaptics_int_act_cfg, |
| 203 | [GPIOMUX_SUSPENDED] = &synaptics_int_sus_cfg, |
| 204 | }, |
| 205 | }, |
Syed Rameez Mustafa | 01d15eb | 2012-12-20 15:30:17 -0800 | [diff] [blame] | 206 | }; |
Syed Rameez Mustafa | 01d15eb | 2012-12-20 15:30:17 -0800 | [diff] [blame] | 207 | |
Krishna Konda | 7af5df9 | 2013-03-06 20:35:30 -0800 | [diff] [blame] | 208 | static struct gpiomux_setting sd_card_det_active_config = { |
| 209 | .func = GPIOMUX_FUNC_GPIO, |
| 210 | .drv = GPIOMUX_DRV_2MA, |
| 211 | .pull = GPIOMUX_PULL_NONE, |
| 212 | .dir = GPIOMUX_IN, |
| 213 | }; |
| 214 | |
| 215 | static struct gpiomux_setting sd_card_det_sleep_config = { |
| 216 | .func = GPIOMUX_FUNC_GPIO, |
| 217 | .drv = GPIOMUX_DRV_2MA, |
| 218 | .pull = GPIOMUX_PULL_UP, |
| 219 | .dir = GPIOMUX_IN, |
| 220 | }; |
| 221 | |
| 222 | static struct msm_gpiomux_config sd_card_det __initdata = { |
| 223 | .gpio = 38, |
| 224 | .settings = { |
| 225 | [GPIOMUX_ACTIVE] = &sd_card_det_active_config, |
| 226 | [GPIOMUX_SUSPENDED] = &sd_card_det_sleep_config, |
| 227 | }, |
| 228 | }; |
| 229 | |
Syed Rameez Mustafa | 9d16c4f | 2012-09-10 14:16:55 -0700 | [diff] [blame] | 230 | void __init msm8226_init_gpiomux(void) |
| 231 | { |
| 232 | int rc; |
| 233 | |
Rohit Vaswani | 341c203 | 2012-11-08 18:49:29 -0800 | [diff] [blame] | 234 | rc = msm_gpiomux_init_dt(); |
Syed Rameez Mustafa | 9d16c4f | 2012-09-10 14:16:55 -0700 | [diff] [blame] | 235 | if (rc) { |
Rohit Vaswani | 341c203 | 2012-11-08 18:49:29 -0800 | [diff] [blame] | 236 | pr_err("%s failed %d\n", __func__, rc); |
Syed Rameez Mustafa | 9d16c4f | 2012-09-10 14:16:55 -0700 | [diff] [blame] | 237 | return; |
| 238 | } |
Gilad Avidov | 28e18eb | 2012-11-21 18:13:25 -0700 | [diff] [blame] | 239 | |
Syed Rameez Mustafa | 01d15eb | 2012-12-20 15:30:17 -0800 | [diff] [blame] | 240 | #if defined(CONFIG_KS8851) || defined(CONFIG_KS8851_MODULE) |
| 241 | msm_gpiomux_install(msm_eth_configs, ARRAY_SIZE(msm_eth_configs)); |
Syed Rameez Mustafa | 01d15eb | 2012-12-20 15:30:17 -0800 | [diff] [blame] | 242 | #endif |
Amy Maloche | 24c59dd | 2013-03-05 11:43:55 -0800 | [diff] [blame] | 243 | msm_gpiomux_install(msm_keypad_configs, |
| 244 | ARRAY_SIZE(msm_keypad_configs)); |
Gilad Avidov | 28e18eb | 2012-11-21 18:13:25 -0700 | [diff] [blame] | 245 | |
| 246 | msm_gpiomux_install(msm_blsp_configs, ARRAY_SIZE(msm_blsp_configs)); |
Krishna Konda | 7af5df9 | 2013-03-06 20:35:30 -0800 | [diff] [blame] | 247 | |
| 248 | msm_gpiomux_install(&sd_card_det, 1); |
Amy Maloche | 41708ba | 2013-03-03 15:19:27 -0800 | [diff] [blame] | 249 | msm_gpiomux_install(msm_synaptics_configs, |
| 250 | ARRAY_SIZE(msm_synaptics_configs)); |
Aravind Venkateswaran | f60fb21 | 2013-03-08 13:57:06 -0800 | [diff] [blame] | 251 | msm_gpiomux_install_nowrite(msm_lcd_configs, |
| 252 | ARRAY_SIZE(msm_lcd_configs)); |
Syed Rameez Mustafa | 9d16c4f | 2012-09-10 14:16:55 -0700 | [diff] [blame] | 253 | } |