Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2011, 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 | #include <linux/kernel.h> |
| 14 | #include <linux/init.h> |
| 15 | #include <linux/gpio_event.h> |
Pankaj Kumar | 6f84174 | 2011-10-10 15:52:14 +0530 | [diff] [blame] | 16 | #include <linux/usb/android.h> |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 17 | #include <linux/platform_device.h> |
| 18 | #include <linux/io.h> |
| 19 | #include <linux/gpio.h> |
| 20 | #include <linux/mtd/nand.h> |
| 21 | #include <linux/mtd/partitions.h> |
| 22 | #include <linux/i2c.h> |
| 23 | #include <linux/android_pmem.h> |
| 24 | #include <linux/bootmem.h> |
| 25 | #include <linux/mfd/marimba.h> |
| 26 | #include <linux/power_supply.h> |
Taniya Das | da40882 | 2011-09-06 12:54:06 +0530 | [diff] [blame] | 27 | #include <linux/input/rmi_platformdata.h> |
| 28 | #include <linux/input/rmi_i2c.h> |
Pankaj Kumar | 3cec058 | 2011-11-18 11:13:29 +0530 | [diff] [blame] | 29 | #include <linux/regulator/consumer.h> |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 30 | #include <asm/mach/mmc.h> |
| 31 | #include <asm/mach-types.h> |
| 32 | #include <asm/mach/arch.h> |
| 33 | #include <mach/board.h> |
| 34 | #include <mach/msm_iomap.h> |
| 35 | #include <mach/msm_hsusb.h> |
| 36 | #include <mach/rpc_hsusb.h> |
| 37 | #include <mach/rpc_pmapp.h> |
| 38 | #include <mach/usbdiag.h> |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 39 | #include <mach/msm_memtypes.h> |
| 40 | #include <mach/msm_serial_hs.h> |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 41 | #include <mach/pmic.h> |
| 42 | #include <mach/socinfo.h> |
| 43 | #include <mach/vreg.h> |
| 44 | #include <mach/rpc_pmapp.h> |
| 45 | #include <mach/msm_battery.h> |
| 46 | #include <mach/rpc_server_handset.h> |
| 47 | #include <mach/socinfo.h> |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 48 | #include "board-msm7x27a-regulator.h" |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 49 | #include "devices.h" |
| 50 | #include "devices-msm7x2xa.h" |
| 51 | #include "pm.h" |
| 52 | #include "timer.h" |
Murali Nalajala | a182784 | 2011-11-13 14:12:39 +0530 | [diff] [blame] | 53 | #include "pm-boot.h" |
Pankaj Kumar | 3cec058 | 2011-11-18 11:13:29 +0530 | [diff] [blame] | 54 | #include "board-msm7x27a-regulator.h" |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 55 | |
| 56 | #define PMEM_KERNEL_EBI1_SIZE 0x3A000 |
| 57 | #define MSM_PMEM_AUDIO_SIZE 0x5B000 |
| 58 | #define BAHAMA_SLAVE_ID_FM_ADDR 0x2A |
| 59 | #define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B |
| 60 | #define BAHAMA_SLAVE_ID_FM_REG 0x02 |
| 61 | #define FM_GPIO 83 |
| 62 | |
| 63 | enum { |
| 64 | GPIO_HOST_VBUS_EN = 107, |
| 65 | GPIO_BT_SYS_REST_EN = 114, |
| 66 | GPIO_WAKE_ON_WIRELESS, |
| 67 | GPIO_BACKLIGHT_EN, |
Taniya Das | 7a22cdd | 2011-09-08 14:57:00 +0530 | [diff] [blame] | 68 | GPIO_NC, |
| 69 | GPIO_CAM_3MP_PWDN, /* CAM_VGA */ |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 70 | GPIO_WLAN_EN, |
| 71 | GPIO_CAM_5MP_SHDN_EN, |
| 72 | GPIO_CAM_5MP_RESET, |
Taniya Das | 7a22cdd | 2011-09-08 14:57:00 +0530 | [diff] [blame] | 73 | GPIO_TP, |
| 74 | GPIO_CAM_GP_CAMIF_RESET, |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | /* FM Platform power and shutdown routines */ |
| 78 | #define FPGA_MSM_CNTRL_REG2 0x90008010 |
| 79 | |
Chintan Pandya | 3b2aff7 | 2011-11-25 16:26:08 +0530 | [diff] [blame] | 80 | #if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE) |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 81 | static void config_pcm_i2s_mode(int mode) |
| 82 | { |
| 83 | void __iomem *cfg_ptr; |
| 84 | u8 reg2; |
| 85 | |
| 86 | cfg_ptr = ioremap_nocache(FPGA_MSM_CNTRL_REG2, sizeof(char)); |
| 87 | |
| 88 | if (!cfg_ptr) |
| 89 | return; |
| 90 | if (mode) { |
| 91 | /*enable the pcm mode in FPGA*/ |
| 92 | reg2 = readb_relaxed(cfg_ptr); |
| 93 | if (reg2 == 0) { |
| 94 | reg2 = 1; |
| 95 | writeb_relaxed(reg2, cfg_ptr); |
| 96 | } |
| 97 | } else { |
| 98 | /*enable i2s mode in FPGA*/ |
| 99 | reg2 = readb_relaxed(cfg_ptr); |
| 100 | if (reg2 == 1) { |
| 101 | reg2 = 0; |
| 102 | writeb_relaxed(reg2, cfg_ptr); |
| 103 | } |
| 104 | } |
| 105 | iounmap(cfg_ptr); |
| 106 | } |
| 107 | |
| 108 | static unsigned fm_i2s_config_power_on[] = { |
| 109 | /*FM_I2S_SD*/ |
| 110 | GPIO_CFG(68, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 111 | /*FM_I2S_WS*/ |
| 112 | GPIO_CFG(70, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 113 | /*FM_I2S_SCK*/ |
| 114 | GPIO_CFG(71, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 115 | }; |
| 116 | |
| 117 | static unsigned fm_i2s_config_power_off[] = { |
| 118 | /*FM_I2S_SD*/ |
| 119 | GPIO_CFG(68, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 120 | /*FM_I2S_WS*/ |
| 121 | GPIO_CFG(70, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 122 | /*FM_I2S_SCK*/ |
| 123 | GPIO_CFG(71, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 124 | }; |
| 125 | |
| 126 | static unsigned bt_config_power_on[] = { |
| 127 | /*RFR*/ |
| 128 | GPIO_CFG(43, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 129 | /*CTS*/ |
| 130 | GPIO_CFG(44, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 131 | /*RX*/ |
| 132 | GPIO_CFG(45, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 133 | /*TX*/ |
| 134 | GPIO_CFG(46, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 135 | }; |
| 136 | static unsigned bt_config_pcm_on[] = { |
| 137 | /*PCM_DOUT*/ |
| 138 | GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 139 | /*PCM_DIN*/ |
| 140 | GPIO_CFG(69, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 141 | /*PCM_SYNC*/ |
| 142 | GPIO_CFG(70, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 143 | /*PCM_CLK*/ |
| 144 | GPIO_CFG(71, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 145 | }; |
| 146 | static unsigned bt_config_power_off[] = { |
| 147 | /*RFR*/ |
| 148 | GPIO_CFG(43, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 149 | /*CTS*/ |
| 150 | GPIO_CFG(44, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 151 | /*RX*/ |
| 152 | GPIO_CFG(45, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 153 | /*TX*/ |
| 154 | GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 155 | }; |
| 156 | static unsigned bt_config_pcm_off[] = { |
| 157 | /*PCM_DOUT*/ |
| 158 | GPIO_CFG(68, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 159 | /*PCM_DIN*/ |
| 160 | GPIO_CFG(69, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 161 | /*PCM_SYNC*/ |
| 162 | GPIO_CFG(70, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 163 | /*PCM_CLK*/ |
| 164 | GPIO_CFG(71, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 165 | }; |
| 166 | |
| 167 | |
| 168 | static int config_i2s(int mode) |
| 169 | { |
| 170 | int pin, rc = 0; |
| 171 | |
| 172 | if (mode == FM_I2S_ON) { |
| 173 | if (machine_is_msm7627a_qrd1()) |
| 174 | config_pcm_i2s_mode(0); |
| 175 | pr_err("%s mode = FM_I2S_ON", __func__); |
| 176 | for (pin = 0; pin < ARRAY_SIZE(fm_i2s_config_power_on); |
| 177 | pin++) { |
| 178 | rc = gpio_tlmm_config( |
| 179 | fm_i2s_config_power_on[pin], |
| 180 | GPIO_CFG_ENABLE |
| 181 | ); |
| 182 | if (rc < 0) |
| 183 | return rc; |
| 184 | } |
| 185 | } else if (mode == FM_I2S_OFF) { |
| 186 | pr_err("%s mode = FM_I2S_OFF", __func__); |
| 187 | for (pin = 0; pin < ARRAY_SIZE(fm_i2s_config_power_off); |
| 188 | pin++) { |
| 189 | rc = gpio_tlmm_config( |
| 190 | fm_i2s_config_power_off[pin], |
| 191 | GPIO_CFG_ENABLE |
| 192 | ); |
| 193 | if (rc < 0) |
| 194 | return rc; |
| 195 | } |
| 196 | } |
| 197 | return rc; |
| 198 | } |
| 199 | static int config_pcm(int mode) |
| 200 | { |
| 201 | int pin, rc = 0; |
| 202 | |
| 203 | if (mode == BT_PCM_ON) { |
| 204 | if (machine_is_msm7627a_qrd1()) |
| 205 | config_pcm_i2s_mode(1); |
| 206 | pr_err("%s mode =BT_PCM_ON", __func__); |
| 207 | for (pin = 0; pin < ARRAY_SIZE(bt_config_pcm_on); |
| 208 | pin++) { |
| 209 | rc = gpio_tlmm_config(bt_config_pcm_on[pin], |
| 210 | GPIO_CFG_ENABLE); |
| 211 | if (rc < 0) |
| 212 | return rc; |
| 213 | } |
| 214 | } else if (mode == BT_PCM_OFF) { |
| 215 | pr_err("%s mode =BT_PCM_OFF", __func__); |
| 216 | for (pin = 0; pin < ARRAY_SIZE(bt_config_pcm_off); |
| 217 | pin++) { |
| 218 | rc = gpio_tlmm_config(bt_config_pcm_off[pin], |
| 219 | GPIO_CFG_ENABLE); |
| 220 | if (rc < 0) |
| 221 | return rc; |
| 222 | } |
| 223 | |
| 224 | } |
| 225 | |
| 226 | return rc; |
| 227 | } |
| 228 | |
| 229 | static int msm_bahama_setup_pcm_i2s(int mode) |
| 230 | { |
| 231 | int fm_state = 0, bt_state = 0; |
| 232 | int rc = 0; |
| 233 | struct marimba config = { .mod_id = SLAVE_ID_BAHAMA}; |
| 234 | |
| 235 | fm_state = marimba_get_fm_status(&config); |
| 236 | bt_state = marimba_get_bt_status(&config); |
| 237 | |
| 238 | switch (mode) { |
| 239 | case BT_PCM_ON: |
| 240 | case BT_PCM_OFF: |
| 241 | if (!fm_state) |
| 242 | rc = config_pcm(mode); |
| 243 | break; |
| 244 | case FM_I2S_ON: |
| 245 | rc = config_i2s(mode); |
| 246 | break; |
| 247 | case FM_I2S_OFF: |
| 248 | if (bt_state) |
| 249 | rc = config_pcm(BT_PCM_ON); |
| 250 | else |
| 251 | rc = config_i2s(mode); |
| 252 | break; |
| 253 | default: |
| 254 | rc = -EIO; |
| 255 | pr_err("%s:Unsupported mode", __func__); |
| 256 | } |
| 257 | return rc; |
| 258 | } |
| 259 | |
| 260 | static int bt_set_gpio(int on) |
| 261 | { |
| 262 | int rc = 0; |
| 263 | struct marimba config = { .mod_id = SLAVE_ID_BAHAMA}; |
| 264 | |
| 265 | if (on) { |
| 266 | rc = gpio_direction_output(GPIO_BT_SYS_REST_EN, 1); |
| 267 | msleep(100); |
| 268 | } else { |
| 269 | if (!marimba_get_fm_status(&config) && |
| 270 | !marimba_get_bt_status(&config)) { |
| 271 | gpio_set_value_cansleep(GPIO_BT_SYS_REST_EN, 0); |
| 272 | rc = gpio_direction_input(GPIO_BT_SYS_REST_EN); |
| 273 | msleep(100); |
| 274 | } |
| 275 | } |
| 276 | if (rc) |
| 277 | pr_err("%s: BT sys_reset_en GPIO : Error", __func__); |
| 278 | |
| 279 | return rc; |
| 280 | } |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 281 | static struct regulator *fm_regulator; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 282 | static int fm_radio_setup(struct marimba_fm_platform_data *pdata) |
| 283 | { |
| 284 | int rc = 0; |
| 285 | const char *id = "FMPW"; |
| 286 | uint32_t irqcfg; |
| 287 | struct marimba config = { .mod_id = SLAVE_ID_BAHAMA}; |
| 288 | u8 value; |
| 289 | |
| 290 | /* Voting for 1.8V Regulator */ |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 291 | fm_regulator = regulator_get(NULL , "msme1"); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 292 | if (IS_ERR(fm_regulator)) { |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 293 | rc = PTR_ERR(fm_regulator); |
| 294 | pr_err("%s: could not get regulator: %d\n", __func__, rc); |
| 295 | goto out; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | /* Set the voltage level to 1.8V */ |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 299 | rc = regulator_set_voltage(fm_regulator, 1800000, 1800000); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 300 | if (rc < 0) { |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 301 | pr_err("%s: could not set voltage: %d\n", __func__, rc); |
| 302 | goto reg_free; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | /* Enabling the 1.8V regulator */ |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 306 | rc = regulator_enable(fm_regulator); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 307 | if (rc) { |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 308 | pr_err("%s: could not enable regulator: %d\n", __func__, rc); |
| 309 | goto reg_free; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | /* Voting for 19.2MHz clock */ |
| 313 | rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1, |
| 314 | PMAPP_CLOCK_VOTE_ON); |
| 315 | if (rc < 0) { |
| 316 | pr_err("%s: clock vote failed with :(%d)\n", |
| 317 | __func__, rc); |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 318 | goto reg_disable; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | rc = bt_set_gpio(1); |
| 322 | if (rc) { |
| 323 | pr_err("%s: bt_set_gpio = %d", __func__, rc); |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 324 | goto gpio_deconfig; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 325 | } |
| 326 | /*re-write FM Slave Id, after reset*/ |
| 327 | value = BAHAMA_SLAVE_ID_FM_ADDR; |
| 328 | rc = marimba_write_bit_mask(&config, |
| 329 | BAHAMA_SLAVE_ID_FM_REG, &value, 1, 0xFF); |
| 330 | if (rc < 0) { |
| 331 | pr_err("%s: FM Slave ID rewrite Failed = %d", __func__, rc); |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 332 | goto gpio_deconfig; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 333 | } |
| 334 | /* Configuring the FM GPIO */ |
| 335 | irqcfg = GPIO_CFG(FM_GPIO, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, |
| 336 | GPIO_CFG_2MA); |
| 337 | |
| 338 | rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE); |
| 339 | if (rc) { |
| 340 | pr_err("%s: gpio_tlmm_config(%#x)=%d\n", |
| 341 | __func__, irqcfg, rc); |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 342 | goto gpio_deconfig; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | return 0; |
| 346 | |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 347 | gpio_deconfig: |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 348 | pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1, |
| 349 | PMAPP_CLOCK_VOTE_OFF); |
| 350 | bt_set_gpio(0); |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 351 | reg_disable: |
| 352 | regulator_disable(fm_regulator); |
| 353 | reg_free: |
| 354 | regulator_put(fm_regulator); |
| 355 | fm_regulator = NULL; |
| 356 | out: |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 357 | return rc; |
| 358 | }; |
| 359 | |
| 360 | static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata) |
| 361 | { |
| 362 | int rc; |
| 363 | const char *id = "FMPW"; |
| 364 | |
| 365 | /* Releasing the GPIO line used by FM */ |
| 366 | uint32_t irqcfg = GPIO_CFG(FM_GPIO, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, |
| 367 | GPIO_CFG_2MA); |
| 368 | |
| 369 | rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE); |
| 370 | if (rc) |
| 371 | pr_err("%s: gpio_tlmm_config(%#x)=%d\n", |
| 372 | __func__, irqcfg, rc); |
| 373 | |
| 374 | /* Releasing the 1.8V Regulator */ |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 375 | if (!IS_ERR_OR_NULL(fm_regulator)) { |
| 376 | rc = regulator_disable(fm_regulator); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 377 | if (rc) |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 378 | pr_err("%s: could not disable regulator: %d\n", |
| 379 | __func__, rc); |
| 380 | regulator_put(fm_regulator); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 381 | fm_regulator = NULL; |
| 382 | } |
| 383 | |
| 384 | /* Voting off the clock */ |
| 385 | rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1, |
| 386 | PMAPP_CLOCK_VOTE_OFF); |
| 387 | if (rc < 0) |
| 388 | pr_err("%s: voting off failed with :(%d)\n", |
| 389 | __func__, rc); |
| 390 | rc = bt_set_gpio(0); |
| 391 | if (rc) |
| 392 | pr_err("%s: bt_set_gpio = %d", __func__, rc); |
| 393 | } |
| 394 | |
| 395 | static struct marimba_fm_platform_data marimba_fm_pdata = { |
| 396 | .fm_setup = fm_radio_setup, |
| 397 | .fm_shutdown = fm_radio_shutdown, |
| 398 | .irq = MSM_GPIO_TO_INT(FM_GPIO), |
| 399 | .vreg_s2 = NULL, |
| 400 | .vreg_xo_out = NULL, |
| 401 | /* Configuring the FM SoC as I2S Master */ |
| 402 | .is_fm_soc_i2s_master = true, |
| 403 | .config_i2s_gpio = msm_bahama_setup_pcm_i2s, |
| 404 | }; |
Chintan Pandya | 3b2aff7 | 2011-11-25 16:26:08 +0530 | [diff] [blame] | 405 | #endif |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 406 | |
| 407 | static struct platform_device msm_wlan_ar6000_pm_device = { |
| 408 | .name = "wlan_ar6000_pm_dev", |
| 409 | .id = -1, |
| 410 | }; |
| 411 | |
| 412 | #if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE) |
| 413 | |
| 414 | static struct platform_device msm_bt_power_device = { |
| 415 | .name = "bt_power", |
| 416 | }; |
| 417 | struct bahama_config_register { |
| 418 | u8 reg; |
| 419 | u8 value; |
| 420 | u8 mask; |
| 421 | }; |
| 422 | struct bt_vreg_info { |
| 423 | const char *name; |
| 424 | unsigned int pmapp_id; |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 425 | unsigned int min_level; |
| 426 | unsigned int max_level; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 427 | unsigned int is_pin_controlled; |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 428 | struct regulator *reg; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 429 | }; |
| 430 | static struct bt_vreg_info bt_vregs[] = { |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 431 | {"msme1", 2, 1800000, 1800000, 0, NULL}, |
| 432 | {"bt", 21, 2900000, 3050000, 1, NULL} |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 433 | }; |
| 434 | |
| 435 | static int bahama_bt(int on) |
| 436 | { |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 437 | int rc = 0; |
| 438 | int i; |
| 439 | |
| 440 | struct marimba config = { .mod_id = SLAVE_ID_BAHAMA}; |
| 441 | |
| 442 | struct bahama_variant_register { |
| 443 | const size_t size; |
| 444 | const struct bahama_config_register *set; |
| 445 | }; |
| 446 | |
| 447 | const struct bahama_config_register *p; |
| 448 | |
| 449 | u8 version; |
| 450 | |
| 451 | const struct bahama_config_register v10_bt_on[] = { |
| 452 | { 0xE9, 0x00, 0xFF }, |
| 453 | { 0xF4, 0x80, 0xFF }, |
| 454 | { 0xE4, 0x00, 0xFF }, |
| 455 | { 0xE5, 0x00, 0x0F }, |
| 456 | #ifdef CONFIG_WLAN |
| 457 | { 0xE6, 0x38, 0x7F }, |
| 458 | { 0xE7, 0x06, 0xFF }, |
| 459 | #endif |
| 460 | { 0xE9, 0x21, 0xFF }, |
| 461 | { 0x01, 0x0C, 0x1F }, |
| 462 | { 0x01, 0x08, 0x1F }, |
| 463 | }; |
| 464 | |
| 465 | const struct bahama_config_register v20_bt_on_fm_off[] = { |
| 466 | { 0x11, 0x0C, 0xFF }, |
| 467 | { 0x13, 0x01, 0xFF }, |
| 468 | { 0xF4, 0x80, 0xFF }, |
| 469 | { 0xF0, 0x00, 0xFF }, |
| 470 | { 0xE9, 0x00, 0xFF }, |
| 471 | #ifdef CONFIG_WLAN |
| 472 | { 0x81, 0x00, 0x7F }, |
| 473 | { 0x82, 0x00, 0xFF }, |
| 474 | { 0xE6, 0x38, 0x7F }, |
| 475 | { 0xE7, 0x06, 0xFF }, |
| 476 | #endif |
| 477 | { 0x8E, 0x15, 0xFF }, |
| 478 | { 0x8F, 0x15, 0xFF }, |
| 479 | { 0x90, 0x15, 0xFF }, |
| 480 | |
| 481 | { 0xE9, 0x21, 0xFF }, |
| 482 | }; |
| 483 | |
| 484 | const struct bahama_config_register v20_bt_on_fm_on[] = { |
| 485 | { 0x11, 0x0C, 0xFF }, |
| 486 | { 0x13, 0x01, 0xFF }, |
| 487 | { 0xF4, 0x86, 0xFF }, |
| 488 | { 0xF0, 0x06, 0xFF }, |
| 489 | { 0xE9, 0x00, 0xFF }, |
| 490 | #ifdef CONFIG_WLAN |
| 491 | { 0x81, 0x00, 0x7F }, |
| 492 | { 0x82, 0x00, 0xFF }, |
| 493 | { 0xE6, 0x38, 0x7F }, |
| 494 | { 0xE7, 0x06, 0xFF }, |
| 495 | #endif |
| 496 | { 0xE9, 0x21, 0xFF }, |
| 497 | }; |
| 498 | |
| 499 | const struct bahama_config_register v10_bt_off[] = { |
| 500 | { 0xE9, 0x00, 0xFF }, |
| 501 | }; |
| 502 | |
| 503 | const struct bahama_config_register v20_bt_off_fm_off[] = { |
| 504 | { 0xF4, 0x84, 0xFF }, |
| 505 | { 0xF0, 0x04, 0xFF }, |
| 506 | { 0xE9, 0x00, 0xFF } |
| 507 | }; |
| 508 | |
| 509 | const struct bahama_config_register v20_bt_off_fm_on[] = { |
| 510 | { 0xF4, 0x86, 0xFF }, |
| 511 | { 0xF0, 0x06, 0xFF }, |
| 512 | { 0xE9, 0x00, 0xFF } |
| 513 | }; |
| 514 | const struct bahama_variant_register bt_bahama[2][3] = { |
| 515 | { |
| 516 | { ARRAY_SIZE(v10_bt_off), v10_bt_off }, |
| 517 | { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off }, |
| 518 | { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on } |
| 519 | }, |
| 520 | { |
| 521 | { ARRAY_SIZE(v10_bt_on), v10_bt_on }, |
| 522 | { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off }, |
| 523 | { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on } |
| 524 | } |
| 525 | }; |
| 526 | |
| 527 | u8 offset = 0; /* index into bahama configs */ |
| 528 | on = on ? 1 : 0; |
| 529 | version = marimba_read_bahama_ver(&config); |
| 530 | if ((int)version < 0 || version == BAHAMA_VER_UNSUPPORTED) { |
| 531 | dev_err(&msm_bt_power_device.dev, "%s: Bahama \ |
| 532 | version read Error, version = %d \n", |
| 533 | __func__, version); |
| 534 | return -EIO; |
| 535 | } |
| 536 | |
| 537 | if (version == BAHAMA_VER_2_0) { |
| 538 | if (marimba_get_fm_status(&config)) |
| 539 | offset = 0x01; |
| 540 | } |
| 541 | |
| 542 | p = bt_bahama[on][version + offset].set; |
| 543 | |
| 544 | dev_info(&msm_bt_power_device.dev, |
| 545 | "%s: found version %d\n", __func__, version); |
| 546 | |
| 547 | for (i = 0; i < bt_bahama[on][version + offset].size; i++) { |
| 548 | u8 value = (p+i)->value; |
| 549 | rc = marimba_write_bit_mask(&config, |
| 550 | (p+i)->reg, |
| 551 | &value, |
| 552 | sizeof((p+i)->value), |
| 553 | (p+i)->mask); |
| 554 | if (rc < 0) { |
| 555 | dev_err(&msm_bt_power_device.dev, |
| 556 | "%s: reg %x write failed: %d\n", |
| 557 | __func__, (p+i)->reg, rc); |
| 558 | return rc; |
| 559 | } |
| 560 | dev_dbg(&msm_bt_power_device.dev, |
| 561 | "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n", |
| 562 | __func__, (p+i)->reg, |
| 563 | value, (p+i)->mask); |
| 564 | value = 0; |
| 565 | rc = marimba_read_bit_mask(&config, |
| 566 | (p+i)->reg, &value, |
| 567 | sizeof((p+i)->value), (p+i)->mask); |
| 568 | if (rc < 0) |
| 569 | dev_err(&msm_bt_power_device.dev, "%s marimba_read_bit_mask- error", |
| 570 | __func__); |
| 571 | dev_dbg(&msm_bt_power_device.dev, |
| 572 | "%s: reg 0x%02x read value 0x%02x mask 0x%02x\n", |
| 573 | __func__, (p+i)->reg, |
| 574 | value, (p+i)->mask); |
| 575 | } |
| 576 | /* Update BT Status */ |
| 577 | if (on) |
| 578 | marimba_set_bt_status(&config, true); |
| 579 | else |
| 580 | marimba_set_bt_status(&config, false); |
| 581 | return rc; |
| 582 | } |
| 583 | static int bluetooth_switch_regulators(int on) |
| 584 | { |
| 585 | int i, rc = 0; |
| 586 | const char *id = "BTPW"; |
| 587 | |
| 588 | for (i = 0; i < ARRAY_SIZE(bt_vregs); i++) { |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 589 | if (IS_ERR_OR_NULL(bt_vregs[i].reg)) { |
| 590 | rc = bt_vregs[i].reg ? |
| 591 | PTR_ERR(bt_vregs[i].reg) : |
| 592 | -ENODEV; |
| 593 | dev_err(&msm_bt_power_device.dev, |
| 594 | "%s: invalid regulator handle for %s: %d\n", |
| 595 | __func__, bt_vregs[i].name, rc); |
| 596 | goto reg_disable; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 597 | } |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 598 | |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 599 | rc = on ? regulator_set_voltage(bt_vregs[i].reg, |
| 600 | bt_vregs[i].min_level, |
| 601 | bt_vregs[i].max_level) : 0; |
| 602 | if (rc) { |
| 603 | dev_err(&msm_bt_power_device.dev, |
| 604 | "%s: could not set voltage for %s: %d\n", |
| 605 | __func__, bt_vregs[i].name, rc); |
| 606 | goto reg_disable; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 607 | } |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 608 | |
| 609 | rc = on ? regulator_enable(bt_vregs[i].reg) : 0; |
| 610 | if (rc) { |
| 611 | dev_err(&msm_bt_power_device.dev, |
| 612 | "%s: could not %sable regulator %s: %d\n", |
| 613 | __func__, "en", bt_vregs[i].name, rc); |
| 614 | goto reg_disable; |
| 615 | } |
| 616 | |
| 617 | if (bt_vregs[i].is_pin_controlled) { |
| 618 | rc = pmapp_vreg_lpm_pincntrl_vote(id, |
| 619 | bt_vregs[i].pmapp_id, |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 620 | PMAPP_CLOCK_ID_D1, |
| 621 | on ? PMAPP_CLOCK_VOTE_ON : |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 622 | PMAPP_CLOCK_VOTE_OFF); |
| 623 | if (rc) { |
| 624 | dev_err(&msm_bt_power_device.dev, |
| 625 | "%s: pin control failed for %s: %d\n", |
| 626 | __func__, bt_vregs[i].name, rc); |
| 627 | goto pin_cnt_fail; |
| 628 | } |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 629 | } |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 630 | rc = on ? 0 : regulator_disable(bt_vregs[i].reg); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 631 | |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 632 | if (rc) { |
| 633 | dev_err(&msm_bt_power_device.dev, |
| 634 | "%s: could not %sable regulator %s: %d\n", |
| 635 | __func__, "dis", bt_vregs[i].name, rc); |
| 636 | goto reg_disable; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 637 | } |
| 638 | } |
| 639 | |
| 640 | return rc; |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 641 | pin_cnt_fail: |
| 642 | if (on) |
| 643 | regulator_disable(bt_vregs[i].reg); |
| 644 | reg_disable: |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 645 | while (i) { |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 646 | if (on) { |
| 647 | i--; |
| 648 | regulator_disable(bt_vregs[i].reg); |
| 649 | regulator_put(bt_vregs[i].reg); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 650 | } |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 651 | } |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 652 | return rc; |
| 653 | } |
| 654 | |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 655 | static struct regulator *reg_s3; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 656 | static unsigned int msm_bahama_setup_power(void) |
| 657 | { |
| 658 | int rc = 0; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 659 | |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 660 | reg_s3 = regulator_get(NULL, "msme1"); |
| 661 | if (IS_ERR(reg_s3)) { |
| 662 | rc = PTR_ERR(reg_s3); |
| 663 | pr_err("%s: could not get regulator: %d\n", __func__, rc); |
| 664 | goto out; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 665 | } |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 666 | |
| 667 | rc = regulator_set_voltage(reg_s3, 1800000, 1800000); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 668 | if (rc < 0) { |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 669 | pr_err("%s: could not set voltage: %d\n", __func__, rc); |
| 670 | goto reg_fail; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 671 | } |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 672 | |
| 673 | rc = regulator_enable(reg_s3); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 674 | if (rc < 0) { |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 675 | pr_err("%s: could not enable regulator: %d\n", __func__, rc); |
| 676 | goto reg_fail; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 677 | } |
| 678 | |
Rahul Kashyap | 5e59b89 | 2011-12-12 16:54:04 +0530 | [diff] [blame] | 679 | gpio_tlmm_config(GPIO_CFG(GPIO_BT_SYS_REST_EN, 0, |
| 680 | GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, |
| 681 | GPIO_CFG_2MA), GPIO_CFG_ENABLE); |
| 682 | |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 683 | /*setup Bahama_sys_reset_n*/ |
| 684 | rc = gpio_request(GPIO_BT_SYS_REST_EN, "bahama sys_rst_n"); |
| 685 | if (rc < 0) { |
| 686 | pr_err("%s: gpio_request %d = %d\n", __func__, |
| 687 | GPIO_BT_SYS_REST_EN, rc); |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 688 | goto reg_disable; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 689 | } |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 690 | |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 691 | rc = bt_set_gpio(1); |
| 692 | if (rc < 0) { |
| 693 | pr_err("%s: bt_set_gpio %d = %d\n", __func__, |
| 694 | GPIO_BT_SYS_REST_EN, rc); |
| 695 | goto gpio_fail; |
| 696 | } |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 697 | |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 698 | return rc; |
| 699 | |
| 700 | gpio_fail: |
| 701 | gpio_free(GPIO_BT_SYS_REST_EN); |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 702 | reg_disable: |
| 703 | regulator_disable(reg_s3); |
| 704 | reg_fail: |
| 705 | regulator_put(reg_s3); |
| 706 | out: |
| 707 | reg_s3 = NULL; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 708 | return rc; |
| 709 | } |
| 710 | |
| 711 | static unsigned int msm_bahama_shutdown_power(int value) |
| 712 | { |
| 713 | int rc = 0; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 714 | |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 715 | if (IS_ERR_OR_NULL(reg_s3)) { |
| 716 | rc = reg_s3 ? PTR_ERR(reg_s3) : -ENODEV; |
| 717 | goto out; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 718 | } |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 719 | |
| 720 | rc = regulator_disable(reg_s3); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 721 | if (rc) { |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 722 | pr_err("%s: could not disable regulator: %d\n", __func__, rc); |
| 723 | goto out; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 724 | } |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 725 | |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 726 | if (value == BAHAMA_ID) { |
| 727 | rc = bt_set_gpio(0); |
| 728 | if (rc) { |
| 729 | pr_err("%s: bt_set_gpio = %d\n", |
| 730 | __func__, rc); |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 731 | goto reg_enable; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 732 | } |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 733 | gpio_free(GPIO_BT_SYS_REST_EN); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 734 | } |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 735 | |
| 736 | regulator_put(reg_s3); |
| 737 | reg_s3 = NULL; |
| 738 | |
| 739 | return 0; |
| 740 | |
| 741 | reg_enable: |
| 742 | regulator_enable(reg_s3); |
| 743 | out: |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 744 | return rc; |
| 745 | } |
| 746 | |
| 747 | static unsigned int msm_bahama_core_config(int type) |
| 748 | { |
| 749 | int rc = 0; |
| 750 | |
| 751 | if (type == BAHAMA_ID) { |
| 752 | int i; |
| 753 | struct marimba config = { .mod_id = SLAVE_ID_BAHAMA}; |
| 754 | const struct bahama_config_register v20_init[] = { |
| 755 | /* reg, value, mask */ |
| 756 | { 0xF4, 0x84, 0xFF }, /* AREG */ |
| 757 | { 0xF0, 0x04, 0xFF } /* DREG */ |
| 758 | }; |
| 759 | if (marimba_read_bahama_ver(&config) == BAHAMA_VER_2_0) { |
| 760 | for (i = 0; i < ARRAY_SIZE(v20_init); i++) { |
| 761 | u8 value = v20_init[i].value; |
| 762 | rc = marimba_write_bit_mask(&config, |
| 763 | v20_init[i].reg, |
| 764 | &value, |
| 765 | sizeof(v20_init[i].value), |
| 766 | v20_init[i].mask); |
| 767 | if (rc < 0) { |
| 768 | pr_err("%s: reg %d write failed: %d\n", |
| 769 | __func__, v20_init[i].reg, rc); |
| 770 | return rc; |
| 771 | } |
| 772 | pr_debug("%s: reg 0x%02x value 0x%02x" |
| 773 | " mask 0x%02x\n", |
| 774 | __func__, v20_init[i].reg, |
| 775 | v20_init[i].value, v20_init[i].mask); |
| 776 | } |
| 777 | } |
| 778 | } |
| 779 | rc = bt_set_gpio(0); |
| 780 | if (rc) { |
| 781 | pr_err("%s: bt_set_gpio = %d\n", |
| 782 | __func__, rc); |
| 783 | } |
| 784 | pr_debug("core type: %d\n", type); |
| 785 | return rc; |
| 786 | } |
| 787 | |
| 788 | static int bluetooth_power(int on) |
| 789 | { |
| 790 | int pin, rc = 0; |
| 791 | const char *id = "BTPW"; |
| 792 | int cid = 0; |
| 793 | |
| 794 | cid = adie_get_detected_connectivity_type(); |
| 795 | if (cid != BAHAMA_ID) { |
| 796 | pr_err("%s: unexpected adie connectivity type: %d\n", |
| 797 | __func__, cid); |
| 798 | return -ENODEV; |
| 799 | } |
| 800 | if (on) { |
| 801 | /*setup power for BT SOC*/ |
| 802 | rc = bt_set_gpio(on); |
| 803 | if (rc) { |
| 804 | pr_err("%s: bt_set_gpio = %d\n", |
| 805 | __func__, rc); |
| 806 | goto exit; |
| 807 | } |
| 808 | rc = bluetooth_switch_regulators(on); |
| 809 | if (rc < 0) { |
| 810 | pr_err("%s: bluetooth_switch_regulators rc = %d", |
| 811 | __func__, rc); |
| 812 | goto exit; |
| 813 | } |
| 814 | /*setup BT GPIO lines*/ |
| 815 | for (pin = 0; pin < ARRAY_SIZE(bt_config_power_on); |
| 816 | pin++) { |
| 817 | rc = gpio_tlmm_config(bt_config_power_on[pin], |
| 818 | GPIO_CFG_ENABLE); |
| 819 | if (rc < 0) { |
| 820 | pr_err("%s: gpio_tlmm_config(%#x)=%d\n", |
| 821 | __func__, |
| 822 | bt_config_power_on[pin], |
| 823 | rc); |
| 824 | goto fail_power; |
| 825 | } |
| 826 | } |
| 827 | /*Setup BT clocks*/ |
| 828 | rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1, |
| 829 | PMAPP_CLOCK_VOTE_ON); |
| 830 | if (rc < 0) { |
| 831 | pr_err("Failed to vote for TCXO_D1 ON\n"); |
| 832 | goto fail_clock; |
| 833 | } |
| 834 | msleep(20); |
| 835 | |
| 836 | /*I2C config for Bahama*/ |
| 837 | rc = bahama_bt(1); |
| 838 | if (rc < 0) { |
| 839 | pr_err("%s: bahama_bt rc = %d", __func__, rc); |
| 840 | goto fail_i2c; |
| 841 | } |
| 842 | msleep(20); |
| 843 | |
| 844 | /*setup BT PCM lines*/ |
| 845 | rc = msm_bahama_setup_pcm_i2s(BT_PCM_ON); |
| 846 | if (rc < 0) { |
| 847 | pr_err("%s: msm_bahama_setup_pcm_i2s , rc =%d\n", |
| 848 | __func__, rc); |
| 849 | goto fail_power; |
| 850 | } |
| 851 | rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1, |
| 852 | PMAPP_CLOCK_VOTE_PIN_CTRL); |
| 853 | if (rc < 0) |
| 854 | pr_err("%s:Pin Control Failed, rc = %d", |
| 855 | __func__, rc); |
| 856 | |
| 857 | } else { |
| 858 | rc = bahama_bt(0); |
| 859 | if (rc < 0) |
| 860 | pr_err("%s: bahama_bt rc = %d", __func__, rc); |
| 861 | |
| 862 | rc = bt_set_gpio(on); |
| 863 | if (rc) { |
| 864 | pr_err("%s: bt_set_gpio = %d\n", |
| 865 | __func__, rc); |
| 866 | } |
| 867 | fail_i2c: |
| 868 | rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1, |
| 869 | PMAPP_CLOCK_VOTE_OFF); |
| 870 | if (rc < 0) |
| 871 | pr_err("%s: Failed to vote Off D1\n", __func__); |
| 872 | fail_clock: |
| 873 | for (pin = 0; pin < ARRAY_SIZE(bt_config_power_off); |
| 874 | pin++) { |
| 875 | rc = gpio_tlmm_config(bt_config_power_off[pin], |
| 876 | GPIO_CFG_ENABLE); |
| 877 | if (rc < 0) { |
| 878 | pr_err("%s: gpio_tlmm_config(%#x)=%d\n", |
| 879 | __func__, bt_config_power_off[pin], rc); |
| 880 | } |
| 881 | } |
| 882 | rc = msm_bahama_setup_pcm_i2s(BT_PCM_OFF); |
| 883 | if (rc < 0) { |
| 884 | pr_err("%s: msm_bahama_setup_pcm_i2s, rc =%d\n", |
| 885 | __func__, rc); |
| 886 | } |
| 887 | fail_power: |
| 888 | rc = bluetooth_switch_regulators(0); |
| 889 | if (rc < 0) { |
| 890 | pr_err("%s: switch_regulators : rc = %d",\ |
| 891 | __func__, rc); |
| 892 | goto exit; |
| 893 | } |
| 894 | } |
| 895 | return rc; |
| 896 | exit: |
| 897 | pr_err("%s: failed with rc = %d", __func__, rc); |
| 898 | return rc; |
| 899 | } |
| 900 | |
| 901 | static int __init bt_power_init(void) |
| 902 | { |
| 903 | int i, rc = 0; |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 904 | struct device *dev = &msm_bt_power_device.dev; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 905 | |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 906 | for (i = 0; i < ARRAY_SIZE(bt_vregs); i++) { |
| 907 | bt_vregs[i].reg = regulator_get(dev, bt_vregs[i].name); |
| 908 | if (IS_ERR(bt_vregs[i].reg)) { |
| 909 | rc = PTR_ERR(bt_vregs[i].reg); |
| 910 | dev_err(dev, "%s: could not get regulator %s: %d\n", |
| 911 | __func__, bt_vregs[i].name, rc); |
| 912 | goto reg_get_fail; |
| 913 | } |
| 914 | } |
| 915 | |
| 916 | dev->platform_data = &bluetooth_power; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 917 | |
| 918 | return rc; |
| 919 | |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 920 | reg_get_fail: |
| 921 | while (i--) { |
| 922 | regulator_put(bt_vregs[i].reg); |
| 923 | bt_vregs[i].reg = NULL; |
| 924 | } |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 925 | return rc; |
| 926 | } |
| 927 | |
| 928 | static struct marimba_platform_data marimba_pdata = { |
| 929 | .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR, |
| 930 | .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR, |
| 931 | .bahama_setup = msm_bahama_setup_power, |
| 932 | .bahama_shutdown = msm_bahama_shutdown_power, |
| 933 | .bahama_core_config = msm_bahama_core_config, |
| 934 | .fm = &marimba_fm_pdata, |
| 935 | }; |
| 936 | |
| 937 | #endif |
| 938 | |
| 939 | #if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE) |
| 940 | static struct i2c_board_info bahama_devices[] = { |
| 941 | { |
| 942 | I2C_BOARD_INFO("marimba", 0xc), |
| 943 | .platform_data = &marimba_pdata, |
| 944 | }, |
| 945 | }; |
| 946 | #endif |
| 947 | |
| 948 | static struct msm_gpio qup_i2c_gpios_io[] = { |
| 949 | { GPIO_CFG(60, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 950 | "qup_scl" }, |
| 951 | { GPIO_CFG(61, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 952 | "qup_sda" }, |
| 953 | { GPIO_CFG(131, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 954 | "qup_scl" }, |
| 955 | { GPIO_CFG(132, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 956 | "qup_sda" }, |
| 957 | }; |
| 958 | |
| 959 | static struct msm_gpio qup_i2c_gpios_hw[] = { |
| 960 | { GPIO_CFG(60, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 961 | "qup_scl" }, |
| 962 | { GPIO_CFG(61, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 963 | "qup_sda" }, |
| 964 | { GPIO_CFG(131, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 965 | "qup_scl" }, |
| 966 | { GPIO_CFG(132, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 967 | "qup_sda" }, |
| 968 | }; |
| 969 | |
| 970 | static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type) |
| 971 | { |
| 972 | int rc; |
| 973 | |
| 974 | if (adap_id < 0 || adap_id > 1) |
| 975 | return; |
| 976 | |
| 977 | /* Each adapter gets 2 lines from the table */ |
| 978 | if (config_type) |
| 979 | rc = msm_gpios_request_enable(&qup_i2c_gpios_hw[adap_id*2], 2); |
| 980 | else |
| 981 | rc = msm_gpios_request_enable(&qup_i2c_gpios_io[adap_id*2], 2); |
| 982 | if (rc < 0) |
| 983 | pr_err("QUP GPIO request/enable failed: %d\n", rc); |
| 984 | } |
| 985 | |
| 986 | static struct msm_i2c_platform_data msm_gsbi0_qup_i2c_pdata = { |
| 987 | .clk_freq = 100000, |
| 988 | .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config, |
| 989 | }; |
| 990 | |
| 991 | static struct msm_i2c_platform_data msm_gsbi1_qup_i2c_pdata = { |
| 992 | .clk_freq = 100000, |
| 993 | .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config, |
| 994 | }; |
| 995 | |
| 996 | #ifdef CONFIG_ARCH_MSM7X27A |
| 997 | #define MSM_PMEM_MDP_SIZE 0x1DD1000 |
| 998 | #define MSM_PMEM_ADSP_SIZE 0x1000000 |
| 999 | |
| 1000 | #ifdef CONFIG_FB_MSM_TRIPLE_BUFFER |
| 1001 | #define MSM_FB_SIZE 0x260000 |
| 1002 | #else |
| 1003 | #define MSM_FB_SIZE 0x195000 |
| 1004 | #endif |
| 1005 | |
| 1006 | #endif |
| 1007 | |
Taniya Das | da40882 | 2011-09-06 12:54:06 +0530 | [diff] [blame] | 1008 | #if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C) || \ |
| 1009 | defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C_MODULE) |
| 1010 | |
| 1011 | #ifndef CLEARPAD3000_ATTEN_GPIO |
| 1012 | #define CLEARPAD3000_ATTEN_GPIO (48) |
| 1013 | #endif |
| 1014 | |
| 1015 | #ifndef CLEARPAD3000_RESET_GPIO |
| 1016 | #define CLEARPAD3000_RESET_GPIO (26) |
| 1017 | #endif |
| 1018 | |
| 1019 | static int synaptics_touchpad_setup(void); |
| 1020 | |
| 1021 | static struct msm_gpio clearpad3000_cfg_data[] = { |
| 1022 | {GPIO_CFG(CLEARPAD3000_ATTEN_GPIO, 0, GPIO_CFG_INPUT, |
| 1023 | GPIO_CFG_NO_PULL, GPIO_CFG_6MA), "rmi4_attn"}, |
| 1024 | {GPIO_CFG(CLEARPAD3000_RESET_GPIO, 0, GPIO_CFG_OUTPUT, |
| 1025 | GPIO_CFG_PULL_DOWN, GPIO_CFG_8MA), "rmi4_reset"}, |
| 1026 | }; |
| 1027 | |
| 1028 | static struct rmi_XY_pair rmi_offset = {.x = 0, .y = 0}; |
| 1029 | static struct rmi_range rmi_clipx = {.min = 48, .max = 980}; |
| 1030 | static struct rmi_range rmi_clipy = {.min = 7, .max = 1647}; |
| 1031 | static struct rmi_f11_functiondata synaptics_f11_data = { |
| 1032 | .swap_axes = false, |
| 1033 | .flipX = false, |
| 1034 | .flipY = false, |
| 1035 | .offset = &rmi_offset, |
| 1036 | .button_height = 113, |
| 1037 | .clipX = &rmi_clipx, |
| 1038 | .clipY = &rmi_clipy, |
| 1039 | }; |
| 1040 | |
| 1041 | #define MAX_LEN 100 |
| 1042 | |
| 1043 | static ssize_t clearpad3000_virtual_keys_register(struct kobject *kobj, |
| 1044 | struct kobj_attribute *attr, char *buf) |
| 1045 | { |
| 1046 | char *virtual_keys = __stringify(EV_KEY) ":" __stringify(KEY_MENU) \ |
| 1047 | ":60:830:120:60" ":" __stringify(EV_KEY) \ |
| 1048 | ":" __stringify(KEY_HOME) ":180:830:120:60" \ |
| 1049 | ":" __stringify(EV_KEY) ":" \ |
| 1050 | __stringify(KEY_SEARCH) ":300:830:120:60" \ |
| 1051 | ":" __stringify(EV_KEY) ":" \ |
| 1052 | __stringify(KEY_BACK) ":420:830:120:60" "\n"; |
| 1053 | |
| 1054 | return snprintf(buf, strnlen(virtual_keys, MAX_LEN) + 1 , "%s", |
| 1055 | virtual_keys); |
| 1056 | } |
| 1057 | |
| 1058 | static struct kobj_attribute clearpad3000_virtual_keys_attr = { |
| 1059 | .attr = { |
| 1060 | .name = "virtualkeys.sensor00fn11", |
| 1061 | .mode = S_IRUGO, |
| 1062 | }, |
| 1063 | .show = &clearpad3000_virtual_keys_register, |
| 1064 | }; |
| 1065 | |
| 1066 | static struct attribute *virtual_key_properties_attrs[] = { |
| 1067 | &clearpad3000_virtual_keys_attr.attr, |
| 1068 | NULL |
| 1069 | }; |
| 1070 | |
| 1071 | static struct attribute_group virtual_key_properties_attr_group = { |
| 1072 | .attrs = virtual_key_properties_attrs, |
| 1073 | }; |
| 1074 | |
| 1075 | struct kobject *virtual_key_properties_kobj; |
| 1076 | |
| 1077 | static struct rmi_functiondata synaptics_functiondata[] = { |
| 1078 | { |
| 1079 | .function_index = RMI_F11_INDEX, |
| 1080 | .data = &synaptics_f11_data, |
| 1081 | }, |
| 1082 | }; |
| 1083 | |
| 1084 | static struct rmi_functiondata_list synaptics_perfunctiondata = { |
| 1085 | .count = ARRAY_SIZE(synaptics_functiondata), |
| 1086 | .functiondata = synaptics_functiondata, |
| 1087 | }; |
| 1088 | |
| 1089 | static struct rmi_sensordata synaptics_sensordata = { |
| 1090 | .perfunctiondata = &synaptics_perfunctiondata, |
| 1091 | .rmi_sensor_setup = synaptics_touchpad_setup, |
| 1092 | }; |
| 1093 | |
| 1094 | static struct rmi_i2c_platformdata synaptics_platformdata = { |
| 1095 | .i2c_address = 0x2c, |
| 1096 | .irq_type = IORESOURCE_IRQ_LOWLEVEL, |
| 1097 | .sensordata = &synaptics_sensordata, |
| 1098 | }; |
| 1099 | |
| 1100 | static struct i2c_board_info synaptic_i2c_clearpad3k[] = { |
| 1101 | { |
| 1102 | I2C_BOARD_INFO("rmi4_ts", 0x2c), |
| 1103 | .platform_data = &synaptics_platformdata, |
| 1104 | }, |
| 1105 | }; |
| 1106 | |
| 1107 | static int synaptics_touchpad_setup(void) |
| 1108 | { |
| 1109 | int retval = 0; |
| 1110 | |
| 1111 | virtual_key_properties_kobj = |
| 1112 | kobject_create_and_add("board_properties", NULL); |
| 1113 | if (virtual_key_properties_kobj) |
| 1114 | retval = sysfs_create_group(virtual_key_properties_kobj, |
| 1115 | &virtual_key_properties_attr_group); |
| 1116 | if (!virtual_key_properties_kobj || retval) |
| 1117 | pr_err("failed to create ft5202 board_properties\n"); |
| 1118 | |
| 1119 | retval = msm_gpios_request_enable(clearpad3000_cfg_data, |
| 1120 | sizeof(clearpad3000_cfg_data)/sizeof(struct msm_gpio)); |
| 1121 | if (retval) { |
| 1122 | pr_err("%s:Failed to obtain touchpad GPIO %d. Code: %d.", |
| 1123 | __func__, CLEARPAD3000_ATTEN_GPIO, retval); |
| 1124 | retval = 0; /* ignore the err */ |
| 1125 | } |
| 1126 | synaptics_platformdata.irq = gpio_to_irq(CLEARPAD3000_ATTEN_GPIO); |
| 1127 | |
| 1128 | gpio_set_value(CLEARPAD3000_RESET_GPIO, 0); |
| 1129 | usleep(10000); |
| 1130 | gpio_set_value(CLEARPAD3000_RESET_GPIO, 1); |
| 1131 | usleep(50000); |
| 1132 | |
| 1133 | return retval; |
| 1134 | } |
| 1135 | #endif |
| 1136 | |
| 1137 | |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1138 | static struct android_usb_platform_data android_usb_pdata = { |
Pankaj Kumar | 6f84174 | 2011-10-10 15:52:14 +0530 | [diff] [blame] | 1139 | .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num, |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1140 | }; |
| 1141 | |
| 1142 | static struct platform_device android_usb_device = { |
| 1143 | .name = "android_usb", |
| 1144 | .id = -1, |
| 1145 | .dev = { |
| 1146 | .platform_data = &android_usb_pdata, |
| 1147 | }, |
| 1148 | }; |
| 1149 | |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1150 | #ifdef CONFIG_USB_EHCI_MSM_72K |
| 1151 | static void msm_hsusb_vbus_power(unsigned phy_info, int on) |
| 1152 | { |
| 1153 | int rc = 0; |
| 1154 | unsigned gpio; |
| 1155 | |
| 1156 | gpio = GPIO_HOST_VBUS_EN; |
| 1157 | |
| 1158 | rc = gpio_request(gpio, "i2c_host_vbus_en"); |
| 1159 | if (rc < 0) { |
| 1160 | pr_err("failed to request %d GPIO\n", gpio); |
| 1161 | return; |
| 1162 | } |
| 1163 | gpio_direction_output(gpio, !!on); |
| 1164 | gpio_set_value_cansleep(gpio, !!on); |
| 1165 | gpio_free(gpio); |
| 1166 | } |
| 1167 | |
| 1168 | static struct msm_usb_host_platform_data msm_usb_host_pdata = { |
| 1169 | .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM), |
| 1170 | }; |
| 1171 | |
| 1172 | static void __init msm7627a_init_host(void) |
| 1173 | { |
| 1174 | msm_add_host(0, &msm_usb_host_pdata); |
| 1175 | } |
| 1176 | #endif |
| 1177 | |
| 1178 | #ifdef CONFIG_USB_MSM_OTG_72K |
| 1179 | static int hsusb_rpc_connect(int connect) |
| 1180 | { |
| 1181 | if (connect) |
| 1182 | return msm_hsusb_rpc_connect(); |
| 1183 | else |
| 1184 | return msm_hsusb_rpc_close(); |
| 1185 | } |
| 1186 | |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 1187 | static struct regulator *reg_hsusb; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1188 | static int msm_hsusb_ldo_init(int init) |
| 1189 | { |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 1190 | int rc = 0; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1191 | |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 1192 | if (init) { |
| 1193 | reg_hsusb = regulator_get(NULL, "usb"); |
| 1194 | if (IS_ERR(reg_hsusb)) { |
| 1195 | rc = PTR_ERR(reg_hsusb); |
| 1196 | pr_err("%s: could not get regulator: %d\n", |
| 1197 | __func__, rc); |
| 1198 | goto out; |
| 1199 | } |
| 1200 | |
| 1201 | rc = regulator_set_voltage(reg_hsusb, 3300000, 3300000); |
| 1202 | if (rc) { |
| 1203 | pr_err("%s: could not set voltage: %d\n", |
| 1204 | __func__, rc); |
| 1205 | goto reg_free; |
| 1206 | } |
| 1207 | |
| 1208 | return 0; |
| 1209 | } |
| 1210 | /* else fall through */ |
| 1211 | reg_free: |
| 1212 | regulator_put(reg_hsusb); |
| 1213 | out: |
| 1214 | reg_hsusb = NULL; |
| 1215 | return rc; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1216 | } |
| 1217 | |
| 1218 | static int msm_hsusb_ldo_enable(int enable) |
| 1219 | { |
| 1220 | static int ldo_status; |
| 1221 | |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 1222 | if (IS_ERR_OR_NULL(reg_hsusb)) |
| 1223 | return reg_hsusb ? PTR_ERR(reg_hsusb) : -ENODEV; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1224 | |
| 1225 | if (ldo_status == enable) |
| 1226 | return 0; |
| 1227 | |
| 1228 | ldo_status = enable; |
| 1229 | |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 1230 | return enable ? |
| 1231 | regulator_enable(reg_hsusb) : |
| 1232 | regulator_disable(reg_hsusb); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1233 | } |
| 1234 | |
| 1235 | #ifndef CONFIG_USB_EHCI_MSM_72K |
| 1236 | static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init) |
| 1237 | { |
| 1238 | int ret = 0; |
| 1239 | |
| 1240 | if (init) |
| 1241 | ret = msm_pm_app_rpc_init(callback); |
| 1242 | else |
| 1243 | msm_pm_app_rpc_deinit(callback); |
| 1244 | |
| 1245 | return ret; |
| 1246 | } |
| 1247 | #endif |
| 1248 | |
| 1249 | static struct msm_otg_platform_data msm_otg_pdata = { |
| 1250 | #ifndef CONFIG_USB_EHCI_MSM_72K |
| 1251 | .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init, |
| 1252 | #else |
| 1253 | .vbus_power = msm_hsusb_vbus_power, |
| 1254 | #endif |
| 1255 | .rpc_connect = hsusb_rpc_connect, |
| 1256 | .core_clk = 1, |
| 1257 | .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT, |
| 1258 | .cdr_autoreset = CDR_AUTO_RESET_DISABLE, |
| 1259 | .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT, |
| 1260 | .se1_gating = SE1_GATING_DISABLE, |
| 1261 | .ldo_init = msm_hsusb_ldo_init, |
| 1262 | .ldo_enable = msm_hsusb_ldo_enable, |
| 1263 | .chg_init = hsusb_chg_init, |
| 1264 | .chg_connected = hsusb_chg_connected, |
| 1265 | .chg_vbus_draw = hsusb_chg_vbus_draw, |
| 1266 | }; |
| 1267 | #endif |
| 1268 | |
| 1269 | static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = { |
| 1270 | .is_phy_status_timer_on = 1, |
| 1271 | }; |
| 1272 | |
| 1273 | #if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\ |
| 1274 | || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\ |
| 1275 | || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\ |
| 1276 | || defined(CONFIG_MMC_MSM_SDC4_SUPPORT)) |
| 1277 | |
| 1278 | static unsigned long vreg_sts, gpio_sts; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1279 | |
| 1280 | struct sdcc_gpio { |
| 1281 | struct msm_gpio *cfg_data; |
| 1282 | uint32_t size; |
| 1283 | struct msm_gpio *sleep_cfg_data; |
| 1284 | }; |
| 1285 | |
| 1286 | /** |
| 1287 | * Due to insufficient drive strengths for SDC GPIO lines some old versioned |
| 1288 | * SD/MMC cards may cause data CRC errors. Hence, set optimal values |
| 1289 | * for SDC slots based on timing closure and marginality. SDC1 slot |
| 1290 | * require higher value since it should handle bad signal quality due |
| 1291 | * to size of T-flash adapters. |
| 1292 | */ |
| 1293 | static struct msm_gpio sdc1_cfg_data[] = { |
| 1294 | {GPIO_CFG(51, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_14MA), |
| 1295 | "sdc1_dat_3"}, |
| 1296 | {GPIO_CFG(52, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_14MA), |
| 1297 | "sdc1_dat_2"}, |
| 1298 | {GPIO_CFG(53, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_14MA), |
| 1299 | "sdc1_dat_1"}, |
| 1300 | {GPIO_CFG(54, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_14MA), |
| 1301 | "sdc1_dat_0"}, |
| 1302 | {GPIO_CFG(55, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_14MA), |
| 1303 | "sdc1_cmd"}, |
| 1304 | {GPIO_CFG(56, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_14MA), |
| 1305 | "sdc1_clk"}, |
| 1306 | }; |
| 1307 | |
| 1308 | static struct msm_gpio sdc2_cfg_data[] = { |
| 1309 | {GPIO_CFG(62, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 1310 | "sdc2_clk"}, |
| 1311 | {GPIO_CFG(63, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
| 1312 | "sdc2_cmd"}, |
| 1313 | {GPIO_CFG(64, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
| 1314 | "sdc2_dat_3"}, |
| 1315 | {GPIO_CFG(65, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
| 1316 | "sdc2_dat_2"}, |
| 1317 | {GPIO_CFG(66, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
| 1318 | "sdc2_dat_1"}, |
| 1319 | {GPIO_CFG(67, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
| 1320 | "sdc2_dat_0"}, |
| 1321 | }; |
| 1322 | |
| 1323 | static struct msm_gpio sdc2_sleep_cfg_data[] = { |
| 1324 | {GPIO_CFG(62, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 1325 | "sdc2_clk"}, |
| 1326 | {GPIO_CFG(63, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 1327 | "sdc2_cmd"}, |
| 1328 | {GPIO_CFG(64, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 1329 | "sdc2_dat_3"}, |
| 1330 | {GPIO_CFG(65, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 1331 | "sdc2_dat_2"}, |
| 1332 | {GPIO_CFG(66, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 1333 | "sdc2_dat_1"}, |
| 1334 | {GPIO_CFG(67, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 1335 | "sdc2_dat_0"}, |
| 1336 | }; |
| 1337 | static struct msm_gpio sdc3_cfg_data[] = { |
| 1338 | {GPIO_CFG(88, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 1339 | "sdc3_clk"}, |
| 1340 | {GPIO_CFG(89, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
| 1341 | "sdc3_cmd"}, |
| 1342 | {GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
| 1343 | "sdc3_dat_3"}, |
| 1344 | {GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
| 1345 | "sdc3_dat_2"}, |
| 1346 | {GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
| 1347 | "sdc3_dat_1"}, |
| 1348 | {GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
| 1349 | "sdc3_dat_0"}, |
| 1350 | #ifdef CONFIG_MMC_MSM_SDC3_8_BIT_SUPPORT |
| 1351 | {GPIO_CFG(19, 3, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
| 1352 | "sdc3_dat_7"}, |
| 1353 | {GPIO_CFG(20, 3, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
| 1354 | "sdc3_dat_6"}, |
| 1355 | {GPIO_CFG(21, 3, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
| 1356 | "sdc3_dat_5"}, |
| 1357 | {GPIO_CFG(108, 3, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
| 1358 | "sdc3_dat_4"}, |
| 1359 | #endif |
| 1360 | }; |
| 1361 | |
| 1362 | static struct msm_gpio sdc4_cfg_data[] = { |
| 1363 | {GPIO_CFG(19, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
| 1364 | "sdc4_dat_3"}, |
| 1365 | {GPIO_CFG(20, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
| 1366 | "sdc4_dat_2"}, |
| 1367 | {GPIO_CFG(21, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
| 1368 | "sdc4_dat_1"}, |
| 1369 | {GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
| 1370 | "sdc4_cmd"}, |
| 1371 | {GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
| 1372 | "sdc4_dat_0"}, |
| 1373 | {GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 1374 | "sdc4_clk"}, |
| 1375 | }; |
| 1376 | |
| 1377 | static struct sdcc_gpio sdcc_cfg_data[] = { |
| 1378 | { |
| 1379 | .cfg_data = sdc1_cfg_data, |
| 1380 | .size = ARRAY_SIZE(sdc1_cfg_data), |
| 1381 | }, |
| 1382 | { |
| 1383 | .cfg_data = sdc2_cfg_data, |
| 1384 | .size = ARRAY_SIZE(sdc2_cfg_data), |
| 1385 | .sleep_cfg_data = sdc2_sleep_cfg_data, |
| 1386 | }, |
| 1387 | { |
| 1388 | .cfg_data = sdc3_cfg_data, |
| 1389 | .size = ARRAY_SIZE(sdc3_cfg_data), |
| 1390 | }, |
| 1391 | { |
| 1392 | .cfg_data = sdc4_cfg_data, |
| 1393 | .size = ARRAY_SIZE(sdc4_cfg_data), |
| 1394 | }, |
| 1395 | }; |
| 1396 | |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 1397 | static struct regulator *sdcc_vreg_data[ARRAY_SIZE(sdcc_cfg_data)]; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1398 | static int msm_sdcc_setup_gpio(int dev_id, unsigned int enable) |
| 1399 | { |
| 1400 | int rc = 0; |
| 1401 | struct sdcc_gpio *curr; |
| 1402 | |
| 1403 | curr = &sdcc_cfg_data[dev_id - 1]; |
| 1404 | if (!(test_bit(dev_id, &gpio_sts)^enable)) |
| 1405 | return rc; |
| 1406 | |
| 1407 | if (enable) { |
| 1408 | set_bit(dev_id, &gpio_sts); |
| 1409 | rc = msm_gpios_request_enable(curr->cfg_data, curr->size); |
| 1410 | if (rc) |
| 1411 | pr_err("%s: Failed to turn on GPIOs for slot %d\n", |
| 1412 | __func__, dev_id); |
| 1413 | } else { |
| 1414 | clear_bit(dev_id, &gpio_sts); |
| 1415 | if (curr->sleep_cfg_data) { |
| 1416 | rc = msm_gpios_enable(curr->sleep_cfg_data, curr->size); |
| 1417 | msm_gpios_free(curr->sleep_cfg_data, curr->size); |
| 1418 | return rc; |
| 1419 | } |
| 1420 | msm_gpios_disable_free(curr->cfg_data, curr->size); |
| 1421 | } |
| 1422 | return rc; |
| 1423 | } |
| 1424 | |
| 1425 | static int msm_sdcc_setup_vreg(int dev_id, unsigned int enable) |
| 1426 | { |
| 1427 | int rc = 0; |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 1428 | struct regulator *curr = sdcc_vreg_data[dev_id - 1]; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1429 | |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 1430 | if (test_bit(dev_id, &vreg_sts) == enable) |
| 1431 | return 0; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1432 | |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 1433 | if (!curr) |
| 1434 | return -ENODEV; |
| 1435 | |
| 1436 | if (IS_ERR(curr)) |
| 1437 | return PTR_ERR(curr); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1438 | |
| 1439 | if (enable) { |
| 1440 | set_bit(dev_id, &vreg_sts); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1441 | |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 1442 | rc = regulator_enable(curr); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1443 | if (rc) |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 1444 | pr_err("%s: could not enable regulator: %d\n", |
| 1445 | __func__, rc); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1446 | } else { |
| 1447 | clear_bit(dev_id, &vreg_sts); |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 1448 | |
| 1449 | rc = regulator_disable(curr); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1450 | if (rc) |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 1451 | pr_err("%s: could not disable regulator: %d\n", |
| 1452 | __func__, rc); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1453 | } |
| 1454 | return rc; |
| 1455 | } |
| 1456 | |
| 1457 | static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd) |
| 1458 | { |
| 1459 | int rc = 0; |
| 1460 | struct platform_device *pdev; |
| 1461 | |
| 1462 | pdev = container_of(dv, struct platform_device, dev); |
| 1463 | |
| 1464 | rc = msm_sdcc_setup_gpio(pdev->id, !!vdd); |
| 1465 | if (rc) |
| 1466 | goto out; |
| 1467 | |
| 1468 | rc = msm_sdcc_setup_vreg(pdev->id, !!vdd); |
| 1469 | out: |
| 1470 | return rc; |
| 1471 | } |
| 1472 | |
Sujit Reddy Thumma | 535c9e3 | 2011-10-28 09:45:33 +0530 | [diff] [blame] | 1473 | #define GPIO_SDC1_HW_DET 42 |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1474 | |
| 1475 | #if defined(CONFIG_MMC_MSM_SDC1_SUPPORT) \ |
| 1476 | && defined(CONFIG_MMC_MSM_CARD_HW_DETECTION) |
| 1477 | static unsigned int msm7627a_sdcc_slot_status(struct device *dev) |
| 1478 | { |
| 1479 | int status; |
| 1480 | |
| 1481 | status = gpio_tlmm_config(GPIO_CFG(GPIO_SDC1_HW_DET, 2, GPIO_CFG_INPUT, |
| 1482 | GPIO_CFG_PULL_UP, GPIO_CFG_8MA), GPIO_CFG_ENABLE); |
| 1483 | if (status) |
| 1484 | pr_err("%s:Failed to configure tlmm for GPIO %d\n", __func__, |
| 1485 | GPIO_SDC1_HW_DET); |
| 1486 | |
| 1487 | status = gpio_request(GPIO_SDC1_HW_DET, "SD_HW_Detect"); |
| 1488 | if (status) { |
| 1489 | pr_err("%s:Failed to request GPIO %d\n", __func__, |
| 1490 | GPIO_SDC1_HW_DET); |
| 1491 | } else { |
| 1492 | status = gpio_direction_input(GPIO_SDC1_HW_DET); |
| 1493 | if (!status) |
Sujit Reddy Thumma | 535c9e3 | 2011-10-28 09:45:33 +0530 | [diff] [blame] | 1494 | status = !gpio_get_value(GPIO_SDC1_HW_DET); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1495 | gpio_free(GPIO_SDC1_HW_DET); |
| 1496 | } |
| 1497 | return status; |
| 1498 | } |
| 1499 | #endif |
| 1500 | |
| 1501 | #ifdef CONFIG_MMC_MSM_SDC1_SUPPORT |
| 1502 | static struct mmc_platform_data sdc1_plat_data = { |
| 1503 | .ocr_mask = MMC_VDD_28_29, |
| 1504 | .translate_vdd = msm_sdcc_setup_power, |
| 1505 | .mmc_bus_width = MMC_CAP_4_BIT_DATA, |
| 1506 | .msmsdcc_fmin = 144000, |
| 1507 | .msmsdcc_fmid = 24576000, |
| 1508 | .msmsdcc_fmax = 49152000, |
| 1509 | #ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION |
| 1510 | .status = msm7627a_sdcc_slot_status, |
| 1511 | .status_irq = MSM_GPIO_TO_INT(GPIO_SDC1_HW_DET), |
| 1512 | .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
| 1513 | #endif |
| 1514 | }; |
| 1515 | #endif |
| 1516 | |
| 1517 | #ifdef CONFIG_MMC_MSM_SDC2_SUPPORT |
| 1518 | static struct mmc_platform_data sdc2_plat_data = { |
| 1519 | /* |
| 1520 | * SDC2 supports only 1.8V, claim for 2.85V range is just |
| 1521 | * for allowing buggy cards who advertise 2.8V even though |
| 1522 | * they can operate at 1.8V supply. |
| 1523 | */ |
| 1524 | .ocr_mask = MMC_VDD_28_29 | MMC_VDD_165_195, |
| 1525 | .translate_vdd = msm_sdcc_setup_power, |
| 1526 | .mmc_bus_width = MMC_CAP_4_BIT_DATA, |
| 1527 | #ifdef CONFIG_MMC_MSM_SDIO_SUPPORT |
| 1528 | .sdiowakeup_irq = MSM_GPIO_TO_INT(66), |
| 1529 | #endif |
| 1530 | .msmsdcc_fmin = 144000, |
| 1531 | .msmsdcc_fmid = 24576000, |
| 1532 | .msmsdcc_fmax = 49152000, |
| 1533 | #ifdef CONFIG_MMC_MSM_SDC2_DUMMY52_REQUIRED |
| 1534 | .dummy52_required = 1, |
| 1535 | #endif |
| 1536 | }; |
| 1537 | #endif |
| 1538 | |
| 1539 | #ifdef CONFIG_MMC_MSM_SDC3_SUPPORT |
| 1540 | static struct mmc_platform_data sdc3_plat_data = { |
| 1541 | .ocr_mask = MMC_VDD_28_29, |
| 1542 | .translate_vdd = msm_sdcc_setup_power, |
| 1543 | #ifdef CONFIG_MMC_MSM_SDC3_8_BIT_SUPPORT |
| 1544 | .mmc_bus_width = MMC_CAP_8_BIT_DATA, |
| 1545 | #else |
| 1546 | .mmc_bus_width = MMC_CAP_4_BIT_DATA, |
| 1547 | #endif |
| 1548 | .msmsdcc_fmin = 144000, |
| 1549 | .msmsdcc_fmid = 24576000, |
| 1550 | .msmsdcc_fmax = 49152000, |
| 1551 | .nonremovable = 1, |
| 1552 | }; |
| 1553 | #endif |
| 1554 | |
| 1555 | #if (defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\ |
| 1556 | && !defined(CONFIG_MMC_MSM_SDC3_8_BIT_SUPPORT)) |
| 1557 | static struct mmc_platform_data sdc4_plat_data = { |
| 1558 | .ocr_mask = MMC_VDD_28_29, |
| 1559 | .translate_vdd = msm_sdcc_setup_power, |
| 1560 | .mmc_bus_width = MMC_CAP_4_BIT_DATA, |
| 1561 | .msmsdcc_fmin = 144000, |
| 1562 | .msmsdcc_fmid = 24576000, |
| 1563 | .msmsdcc_fmax = 49152000, |
| 1564 | }; |
| 1565 | #endif |
| 1566 | #endif |
| 1567 | |
| 1568 | #ifdef CONFIG_SERIAL_MSM_HS |
| 1569 | static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = { |
| 1570 | .inject_rx_on_wakeup = 1, |
| 1571 | .rx_to_inject = 0xFD, |
| 1572 | }; |
| 1573 | #endif |
| 1574 | static struct msm_pm_platform_data msm7627a_pm_data[MSM_PM_SLEEP_MODE_NR] = { |
| 1575 | [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = { |
| 1576 | .idle_supported = 1, |
| 1577 | .suspend_supported = 1, |
| 1578 | .idle_enabled = 1, |
| 1579 | .suspend_enabled = 1, |
| 1580 | .latency = 16000, |
| 1581 | .residency = 20000, |
| 1582 | }, |
| 1583 | [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] = { |
| 1584 | .idle_supported = 1, |
| 1585 | .suspend_supported = 1, |
| 1586 | .idle_enabled = 1, |
| 1587 | .suspend_enabled = 1, |
| 1588 | .latency = 12000, |
| 1589 | .residency = 20000, |
| 1590 | }, |
| 1591 | [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT] = { |
| 1592 | .idle_supported = 1, |
| 1593 | .suspend_supported = 1, |
| 1594 | .idle_enabled = 0, |
| 1595 | .suspend_enabled = 1, |
| 1596 | .latency = 2000, |
| 1597 | .residency = 0, |
| 1598 | }, |
| 1599 | [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT] = { |
| 1600 | .idle_supported = 1, |
| 1601 | .suspend_supported = 1, |
| 1602 | .idle_enabled = 1, |
| 1603 | .suspend_enabled = 1, |
| 1604 | .latency = 2, |
| 1605 | .residency = 0, |
| 1606 | }, |
| 1607 | }; |
| 1608 | |
Maheshkumar Sivasubramanian | c6c5503 | 2011-10-25 16:01:32 -0600 | [diff] [blame^] | 1609 | static struct msm_pm_boot_platform_data msm_pm_boot_pdata __initdata = { |
| 1610 | .mode = MSM_PM_BOOT_CONFIG_RESET_VECTOR_VIRT, |
| 1611 | .v_addr = (uint32_t *)PAGE_OFFSET, |
| 1612 | }; |
| 1613 | |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1614 | static struct android_pmem_platform_data android_pmem_adsp_pdata = { |
| 1615 | .name = "pmem_adsp", |
| 1616 | .allocator_type = PMEM_ALLOCATORTYPE_BITMAP, |
| 1617 | .cached = 1, |
| 1618 | .memory_type = MEMTYPE_EBI1, |
| 1619 | }; |
| 1620 | |
| 1621 | static struct platform_device android_pmem_adsp_device = { |
| 1622 | .name = "android_pmem", |
| 1623 | .id = 1, |
| 1624 | .dev = { .platform_data = &android_pmem_adsp_pdata }, |
| 1625 | }; |
| 1626 | |
| 1627 | static unsigned pmem_mdp_size = MSM_PMEM_MDP_SIZE; |
| 1628 | static int __init pmem_mdp_size_setup(char *p) |
| 1629 | { |
| 1630 | pmem_mdp_size = memparse(p, NULL); |
| 1631 | return 0; |
| 1632 | } |
| 1633 | |
| 1634 | early_param("pmem_mdp_size", pmem_mdp_size_setup); |
| 1635 | |
| 1636 | static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE; |
| 1637 | static int __init pmem_adsp_size_setup(char *p) |
| 1638 | { |
| 1639 | pmem_adsp_size = memparse(p, NULL); |
| 1640 | return 0; |
| 1641 | } |
| 1642 | |
| 1643 | early_param("pmem_adsp_size", pmem_adsp_size_setup); |
| 1644 | |
| 1645 | static unsigned fb_size = MSM_FB_SIZE; |
| 1646 | static int __init fb_size_setup(char *p) |
| 1647 | { |
| 1648 | fb_size = memparse(p, NULL); |
| 1649 | return 0; |
| 1650 | } |
| 1651 | |
| 1652 | early_param("fb_size", fb_size_setup); |
| 1653 | |
Taniya Das | 0a5303a | 2011-08-23 18:47:48 +0530 | [diff] [blame] | 1654 | static struct resource msm_fb_resources[] = { |
| 1655 | { |
| 1656 | .flags = IORESOURCE_DMA, |
| 1657 | } |
| 1658 | }; |
| 1659 | |
| 1660 | static int msm_fb_detect_panel(const char *name) |
| 1661 | { |
| 1662 | int ret; |
| 1663 | |
| 1664 | if (!strncmp(name, "mipi_video_truly_wvga", 21)) |
| 1665 | ret = 0; |
| 1666 | else |
| 1667 | ret = -ENODEV; |
| 1668 | |
| 1669 | return ret; |
| 1670 | } |
| 1671 | |
| 1672 | static int mipi_truly_set_bl(int on) |
| 1673 | { |
| 1674 | gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, !!on); |
| 1675 | |
| 1676 | return 1; |
| 1677 | } |
| 1678 | |
| 1679 | static struct msm_fb_platform_data msm_fb_pdata = { |
| 1680 | .detect_client = msm_fb_detect_panel, |
| 1681 | }; |
| 1682 | |
| 1683 | static struct platform_device msm_fb_device = { |
| 1684 | .name = "msm_fb", |
| 1685 | .id = 0, |
| 1686 | .num_resources = ARRAY_SIZE(msm_fb_resources), |
| 1687 | .resource = msm_fb_resources, |
| 1688 | .dev = { |
| 1689 | .platform_data = &msm_fb_pdata, |
| 1690 | } |
| 1691 | }; |
| 1692 | |
| 1693 | static struct msm_panel_common_pdata mipi_truly_pdata = { |
| 1694 | .pmic_backlight = mipi_truly_set_bl, |
| 1695 | }; |
| 1696 | |
| 1697 | static struct platform_device mipi_dsi_truly_panel_device = { |
| 1698 | .name = "mipi_truly", |
| 1699 | .id = 0, |
| 1700 | .dev = { |
| 1701 | .platform_data = &mipi_truly_pdata, |
| 1702 | } |
| 1703 | }; |
| 1704 | |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 1705 | static int __init mmc_regulator_init(int sdcc_no, const char *supply, int uV) |
| 1706 | { |
| 1707 | int rc; |
| 1708 | |
| 1709 | BUG_ON(sdcc_no < 1 || sdcc_no > 4); |
| 1710 | |
| 1711 | sdcc_no--; |
| 1712 | |
| 1713 | sdcc_vreg_data[sdcc_no] = regulator_get(NULL, supply); |
| 1714 | |
| 1715 | if (IS_ERR(sdcc_vreg_data[sdcc_no])) { |
| 1716 | rc = PTR_ERR(sdcc_vreg_data[sdcc_no]); |
| 1717 | pr_err("%s: could not get regulator \"%s\": %d\n", |
| 1718 | __func__, supply, rc); |
| 1719 | goto out; |
| 1720 | } |
| 1721 | |
| 1722 | rc = regulator_set_voltage(sdcc_vreg_data[sdcc_no], uV, uV); |
| 1723 | |
| 1724 | if (rc) { |
| 1725 | pr_err("%s: could not set voltage for \"%s\" to %d uV: %d\n", |
| 1726 | __func__, supply, uV, rc); |
| 1727 | goto reg_free; |
| 1728 | } |
| 1729 | |
| 1730 | return rc; |
| 1731 | |
| 1732 | reg_free: |
| 1733 | regulator_put(sdcc_vreg_data[sdcc_no]); |
| 1734 | out: |
| 1735 | sdcc_vreg_data[sdcc_no] = NULL; |
| 1736 | return rc; |
| 1737 | } |
| 1738 | |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1739 | static void __init msm7627a_init_mmc(void) |
| 1740 | { |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1741 | /* eMMC slot */ |
| 1742 | #ifdef CONFIG_MMC_MSM_SDC3_SUPPORT |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 1743 | if (mmc_regulator_init(3, "emmc", 3000000)) |
| 1744 | return; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1745 | msm_add_sdcc(3, &sdc3_plat_data); |
| 1746 | #endif |
| 1747 | /* Micro-SD slot */ |
| 1748 | #ifdef CONFIG_MMC_MSM_SDC1_SUPPORT |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 1749 | if (mmc_regulator_init(1, "mmc", 2850000)) |
| 1750 | return; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1751 | msm_add_sdcc(1, &sdc1_plat_data); |
| 1752 | #endif |
| 1753 | /* SDIO WLAN slot */ |
| 1754 | #ifdef CONFIG_MMC_MSM_SDC2_SUPPORT |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 1755 | if (mmc_regulator_init(2, "mmc", 2850000)) |
| 1756 | return; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1757 | msm_add_sdcc(2, &sdc2_plat_data); |
| 1758 | #endif |
| 1759 | /* Not Used */ |
| 1760 | #if (defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\ |
| 1761 | && !defined(CONFIG_MMC_MSM_SDC3_8_BIT_SUPPORT)) |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 1762 | if (mmc_regulator_init(4, "mmc", 2850000)) |
| 1763 | return; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1764 | msm_add_sdcc(4, &sdc4_plat_data); |
| 1765 | #endif |
| 1766 | } |
| 1767 | |
| 1768 | #define SND(desc, num) { .name = #desc, .id = num } |
| 1769 | static struct snd_endpoint snd_endpoints_list[] = { |
| 1770 | SND(HANDSET, 0), |
| 1771 | SND(MONO_HEADSET, 2), |
| 1772 | SND(HEADSET, 3), |
| 1773 | SND(SPEAKER, 6), |
| 1774 | SND(TTY_HEADSET, 8), |
| 1775 | SND(TTY_VCO, 9), |
| 1776 | SND(TTY_HCO, 10), |
| 1777 | SND(BT, 12), |
| 1778 | SND(IN_S_SADC_OUT_HANDSET, 16), |
| 1779 | SND(IN_S_SADC_OUT_SPEAKER_PHONE, 25), |
| 1780 | SND(FM_DIGITAL_STEREO_HEADSET, 26), |
| 1781 | SND(FM_DIGITAL_SPEAKER_PHONE, 27), |
| 1782 | SND(FM_DIGITAL_BT_A2DP_HEADSET, 28), |
Shashi Kumar | 64e0760 | 2011-10-11 13:18:57 +0530 | [diff] [blame] | 1783 | SND(STEREO_HEADSET_AND_SPEAKER, 31), |
Phani Kumar Allada | d697125 | 2011-10-19 10:50:15 +0530 | [diff] [blame] | 1784 | SND(CURRENT, 0x7FFFFFFE), |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 1785 | SND(FM_ANALOG_STEREO_HEADSET, 35), |
| 1786 | SND(FM_ANALOG_STEREO_HEADSET_CODEC, 36), |
| 1787 | }; |
| 1788 | #undef SND |
| 1789 | |
| 1790 | static struct msm_snd_endpoints msm_device_snd_endpoints = { |
| 1791 | .endpoints = snd_endpoints_list, |
| 1792 | .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint) |
| 1793 | }; |
| 1794 | |
| 1795 | static struct platform_device msm_device_snd = { |
| 1796 | .name = "msm_snd", |
| 1797 | .id = -1, |
| 1798 | .dev = { |
| 1799 | .platform_data = &msm_device_snd_endpoints |
| 1800 | }, |
| 1801 | }; |
| 1802 | |
| 1803 | #define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \ |
| 1804 | (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \ |
| 1805 | (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \ |
| 1806 | (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \ |
| 1807 | (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \ |
| 1808 | (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP)) |
| 1809 | #define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \ |
| 1810 | (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \ |
| 1811 | (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \ |
| 1812 | (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \ |
| 1813 | (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \ |
| 1814 | (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP)) |
| 1815 | #define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \ |
| 1816 | (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \ |
| 1817 | (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \ |
| 1818 | (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \ |
| 1819 | (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \ |
| 1820 | (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP)) |
| 1821 | #define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \ |
| 1822 | (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \ |
| 1823 | (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \ |
| 1824 | (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \ |
| 1825 | (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \ |
| 1826 | (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP)) |
| 1827 | #define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI) |
| 1828 | |
| 1829 | static unsigned int dec_concurrency_table[] = { |
| 1830 | /* Audio LP */ |
| 1831 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DMA)), 0, |
| 1832 | 0, 0, 0, |
| 1833 | |
| 1834 | /* Concurrency 1 */ |
| 1835 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 1836 | (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 1837 | (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 1838 | (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 1839 | (DEC4_FORMAT), |
| 1840 | |
| 1841 | /* Concurrency 2 */ |
| 1842 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 1843 | (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 1844 | (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 1845 | (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 1846 | (DEC4_FORMAT), |
| 1847 | |
| 1848 | /* Concurrency 3 */ |
| 1849 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 1850 | (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 1851 | (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 1852 | (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 1853 | (DEC4_FORMAT), |
| 1854 | |
| 1855 | /* Concurrency 4 */ |
| 1856 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 1857 | (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 1858 | (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 1859 | (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 1860 | (DEC4_FORMAT), |
| 1861 | |
| 1862 | /* Concurrency 5 */ |
| 1863 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 1864 | (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 1865 | (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 1866 | (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 1867 | (DEC4_FORMAT), |
| 1868 | |
| 1869 | /* Concurrency 6 */ |
| 1870 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 1871 | 0, 0, 0, 0, |
| 1872 | |
| 1873 | /* Concurrency 7 */ |
| 1874 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 1875 | (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 1876 | (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 1877 | (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 1878 | (DEC4_FORMAT), |
| 1879 | }; |
| 1880 | |
| 1881 | #define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \ |
| 1882 | .module_queueid = queueid, .module_decid = decid, \ |
| 1883 | .nr_codec_support = nr_codec} |
| 1884 | |
| 1885 | static struct msm_adspdec_info dec_info_list[] = { |
| 1886 | DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */ |
| 1887 | DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */ |
| 1888 | DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */ |
| 1889 | DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */ |
| 1890 | DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */ |
| 1891 | }; |
| 1892 | |
| 1893 | static struct msm_adspdec_database msm_device_adspdec_database = { |
| 1894 | .num_dec = ARRAY_SIZE(dec_info_list), |
| 1895 | .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \ |
| 1896 | ARRAY_SIZE(dec_info_list)), |
| 1897 | .dec_concurrency_table = dec_concurrency_table, |
| 1898 | .dec_info_list = dec_info_list, |
| 1899 | }; |
| 1900 | |
| 1901 | static struct platform_device msm_device_adspdec = { |
| 1902 | .name = "msm_adspdec", |
| 1903 | .id = -1, |
| 1904 | .dev = { |
| 1905 | .platform_data = &msm_device_adspdec_database |
| 1906 | }, |
| 1907 | }; |
| 1908 | |
| 1909 | static struct android_pmem_platform_data android_pmem_audio_pdata = { |
| 1910 | .name = "pmem_audio", |
| 1911 | .allocator_type = PMEM_ALLOCATORTYPE_BITMAP, |
| 1912 | .cached = 0, |
| 1913 | .memory_type = MEMTYPE_EBI1, |
| 1914 | }; |
| 1915 | |
| 1916 | static struct platform_device android_pmem_audio_device = { |
| 1917 | .name = "android_pmem", |
| 1918 | .id = 2, |
| 1919 | .dev = { .platform_data = &android_pmem_audio_pdata }, |
| 1920 | }; |
| 1921 | |
| 1922 | static struct android_pmem_platform_data android_pmem_pdata = { |
| 1923 | .name = "pmem", |
| 1924 | .allocator_type = PMEM_ALLOCATORTYPE_BITMAP, |
| 1925 | .cached = 1, |
| 1926 | .memory_type = MEMTYPE_EBI1, |
| 1927 | }; |
| 1928 | static struct platform_device android_pmem_device = { |
| 1929 | .name = "android_pmem", |
| 1930 | .id = 0, |
| 1931 | .dev = { .platform_data = &android_pmem_pdata }, |
| 1932 | }; |
| 1933 | |
| 1934 | static u32 msm_calculate_batt_capacity(u32 current_voltage); |
| 1935 | |
| 1936 | static struct msm_psy_batt_pdata msm_psy_batt_data = { |
| 1937 | .voltage_min_design = 2800, |
| 1938 | .voltage_max_design = 4300, |
| 1939 | .avail_chg_sources = AC_CHG | USB_CHG , |
| 1940 | .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION, |
| 1941 | .calculate_capacity = &msm_calculate_batt_capacity, |
| 1942 | }; |
| 1943 | |
| 1944 | static u32 msm_calculate_batt_capacity(u32 current_voltage) |
| 1945 | { |
| 1946 | u32 low_voltage = msm_psy_batt_data.voltage_min_design; |
| 1947 | u32 high_voltage = msm_psy_batt_data.voltage_max_design; |
| 1948 | |
| 1949 | return (current_voltage - low_voltage) * 100 |
| 1950 | / (high_voltage - low_voltage); |
| 1951 | } |
| 1952 | |
| 1953 | static struct platform_device msm_batt_device = { |
| 1954 | .name = "msm-battery", |
| 1955 | .id = -1, |
| 1956 | .dev.platform_data = &msm_psy_batt_data, |
| 1957 | }; |
| 1958 | |
Taniya Das | 7a22cdd | 2011-09-08 14:57:00 +0530 | [diff] [blame] | 1959 | #ifdef CONFIG_MSM_CAMERA |
| 1960 | static uint32_t camera_off_gpio_table[] = { |
| 1961 | GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 1962 | }; |
| 1963 | |
| 1964 | static uint32_t camera_on_gpio_table[] = { |
| 1965 | GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 1966 | }; |
| 1967 | |
| 1968 | static void qrd1_camera_gpio_cfg(void) |
| 1969 | { |
| 1970 | |
| 1971 | int rc = 0; |
| 1972 | |
| 1973 | rc = gpio_request(GPIO_CAM_5MP_SHDN_EN, "ov5640"); |
| 1974 | if (rc < 0) |
| 1975 | pr_err("%s: gpio_request---GPIO_CAM_5MP_SHDN_EN failed!", |
| 1976 | __func__); |
| 1977 | |
| 1978 | |
| 1979 | rc = gpio_tlmm_config(GPIO_CFG(GPIO_CAM_5MP_SHDN_EN, 0, |
| 1980 | GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, |
| 1981 | GPIO_CFG_2MA), GPIO_CFG_ENABLE); |
| 1982 | if (rc < 0) { |
| 1983 | pr_err("%s: unable to enable Power Down gpio for main" |
| 1984 | "camera!\n", __func__); |
| 1985 | gpio_free(GPIO_CAM_5MP_SHDN_EN); |
| 1986 | } |
| 1987 | |
| 1988 | |
| 1989 | rc = gpio_request(GPIO_CAM_5MP_RESET, "ov5640"); |
| 1990 | if (rc < 0) { |
| 1991 | pr_err("%s: gpio_request---GPIO_CAM_5MP_RESET failed!", |
| 1992 | __func__); |
| 1993 | gpio_free(GPIO_CAM_5MP_SHDN_EN); |
| 1994 | } |
| 1995 | |
| 1996 | |
| 1997 | rc = gpio_tlmm_config(GPIO_CFG(GPIO_CAM_5MP_RESET, 0, |
| 1998 | GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, |
| 1999 | GPIO_CFG_2MA), GPIO_CFG_ENABLE); |
| 2000 | if (rc < 0) { |
| 2001 | pr_err("%s: unable to enable reset gpio for main camera!\n", |
| 2002 | __func__); |
| 2003 | gpio_free(GPIO_CAM_5MP_RESET); |
| 2004 | } |
| 2005 | |
| 2006 | rc = gpio_request(GPIO_CAM_3MP_PWDN, "ov7692"); |
| 2007 | if (rc < 0) |
| 2008 | pr_err("%s: gpio_request---GPIO_CAM_3MP_PWDN failed!", |
| 2009 | __func__); |
| 2010 | |
| 2011 | rc = gpio_tlmm_config(GPIO_CFG(GPIO_CAM_3MP_PWDN, 0, |
| 2012 | GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, |
| 2013 | GPIO_CFG_2MA), GPIO_CFG_ENABLE); |
| 2014 | if (rc < 0) { |
| 2015 | pr_err("%s: unable to enable Power Down gpio for front" |
| 2016 | "camera!\n", __func__); |
| 2017 | gpio_free(GPIO_CAM_3MP_PWDN); |
| 2018 | } |
| 2019 | |
| 2020 | gpio_direction_output(GPIO_CAM_5MP_SHDN_EN, 1); |
| 2021 | gpio_direction_output(GPIO_CAM_5MP_RESET, 1); |
| 2022 | gpio_direction_output(GPIO_CAM_3MP_PWDN, 1); |
| 2023 | } |
| 2024 | |
| 2025 | #endif |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 2026 | static struct regulator_bulk_data regs_camera[] = { |
| 2027 | { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 }, |
| 2028 | { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 }, |
| 2029 | { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 }, |
| 2030 | }; |
| 2031 | |
| 2032 | static void __init msm_camera_vreg_init(void) |
Taniya Das | 7a22cdd | 2011-09-08 14:57:00 +0530 | [diff] [blame] | 2033 | { |
| 2034 | int rc; |
| 2035 | |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 2036 | rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_camera), regs_camera); |
| 2037 | if (rc) { |
| 2038 | pr_err("%s: could not get regulators: %d\n", __func__, rc); |
| 2039 | return; |
Taniya Das | 7a22cdd | 2011-09-08 14:57:00 +0530 | [diff] [blame] | 2040 | } |
| 2041 | |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 2042 | rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_camera), regs_camera); |
| 2043 | if (rc) { |
| 2044 | pr_err("%s: could not set voltages: %d\n", __func__, rc); |
| 2045 | return; |
Taniya Das | 7a22cdd | 2011-09-08 14:57:00 +0530 | [diff] [blame] | 2046 | } |
| 2047 | } |
| 2048 | |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 2049 | static void msm_camera_vreg_config(int vreg_en) |
| 2050 | { |
| 2051 | int rc = vreg_en ? |
| 2052 | regulator_bulk_enable(ARRAY_SIZE(regs_camera), regs_camera) : |
| 2053 | regulator_bulk_disable(ARRAY_SIZE(regs_camera), regs_camera); |
| 2054 | |
| 2055 | if (rc) |
| 2056 | pr_err("%s: could not %sable regulators: %d\n", |
| 2057 | __func__, vreg_en ? "en" : "dis", rc); |
| 2058 | } |
Taniya Das | 7a22cdd | 2011-09-08 14:57:00 +0530 | [diff] [blame] | 2059 | static int config_gpio_table(uint32_t *table, int len) |
| 2060 | { |
| 2061 | int rc = 0, i = 0; |
| 2062 | |
| 2063 | for (i = 0; i < len; i++) { |
| 2064 | rc = gpio_tlmm_config(table[i], GPIO_CFG_ENABLE); |
| 2065 | if (rc) { |
| 2066 | pr_err("%s not able to get gpio\n", __func__); |
| 2067 | for (i--; i >= 0; i--) |
| 2068 | gpio_tlmm_config(camera_off_gpio_table[i], |
| 2069 | GPIO_CFG_ENABLE); |
| 2070 | break; |
| 2071 | } |
| 2072 | } |
| 2073 | return rc; |
| 2074 | } |
| 2075 | |
| 2076 | static int config_camera_on_gpios_rear(void) |
| 2077 | { |
| 2078 | int rc = 0; |
| 2079 | |
| 2080 | msm_camera_vreg_config(1); |
| 2081 | |
| 2082 | rc = config_gpio_table(camera_on_gpio_table, |
| 2083 | ARRAY_SIZE(camera_on_gpio_table)); |
| 2084 | if (rc < 0) { |
| 2085 | pr_err("%s: CAMSENSOR gpio table request" |
| 2086 | "failed\n", __func__); |
| 2087 | return rc; |
| 2088 | } |
| 2089 | |
| 2090 | return rc; |
| 2091 | } |
| 2092 | |
| 2093 | static void config_camera_off_gpios_rear(void) |
| 2094 | { |
| 2095 | msm_camera_vreg_config(0); |
| 2096 | config_gpio_table(camera_off_gpio_table, |
| 2097 | ARRAY_SIZE(camera_off_gpio_table)); |
| 2098 | } |
| 2099 | |
| 2100 | static int config_camera_on_gpios_front(void) |
| 2101 | { |
| 2102 | int rc = 0; |
| 2103 | |
| 2104 | msm_camera_vreg_config(1); |
| 2105 | |
| 2106 | rc = config_gpio_table(camera_on_gpio_table, |
| 2107 | ARRAY_SIZE(camera_on_gpio_table)); |
| 2108 | if (rc < 0) { |
| 2109 | pr_err("%s: CAMSENSOR gpio table request" |
| 2110 | "failed\n", __func__); |
| 2111 | return rc; |
| 2112 | } |
| 2113 | |
| 2114 | return rc; |
| 2115 | } |
| 2116 | |
| 2117 | static void config_camera_off_gpios_front(void) |
| 2118 | { |
| 2119 | msm_camera_vreg_config(0); |
| 2120 | |
| 2121 | config_gpio_table(camera_off_gpio_table, |
| 2122 | ARRAY_SIZE(camera_off_gpio_table)); |
| 2123 | } |
| 2124 | |
| 2125 | struct msm_camera_device_platform_data msm_camera_data_rear = { |
| 2126 | .camera_gpio_on = config_camera_on_gpios_rear, |
| 2127 | .camera_gpio_off = config_camera_off_gpios_rear, |
| 2128 | .ioext.csiphy = 0xA1000000, |
| 2129 | .ioext.csisz = 0x00100000, |
| 2130 | .ioext.csiirq = INT_CSI_IRQ_1, |
| 2131 | .ioclk.mclk_clk_rate = 24000000, |
| 2132 | .ioclk.vfe_clk_rate = 192000000, |
| 2133 | .ioext.appphy = MSM_CLK_CTL_PHYS, |
| 2134 | .ioext.appsz = MSM_CLK_CTL_SIZE, |
| 2135 | }; |
| 2136 | |
| 2137 | struct msm_camera_device_platform_data msm_camera_data_front = { |
| 2138 | .camera_gpio_on = config_camera_on_gpios_front, |
| 2139 | .camera_gpio_off = config_camera_off_gpios_front, |
| 2140 | .ioext.csiphy = 0xA0F00000, |
| 2141 | .ioext.csisz = 0x00100000, |
| 2142 | .ioext.csiirq = INT_CSI_IRQ_0, |
| 2143 | .ioclk.mclk_clk_rate = 24000000, |
| 2144 | .ioclk.vfe_clk_rate = 192000000, |
| 2145 | .ioext.appphy = MSM_CLK_CTL_PHYS, |
| 2146 | .ioext.appsz = MSM_CLK_CTL_SIZE, |
| 2147 | }; |
| 2148 | |
| 2149 | #ifdef CONFIG_OV5640 |
| 2150 | static struct msm_camera_sensor_platform_info ov5640_sensor_info = { |
| 2151 | .mount_angle = 90 |
| 2152 | }; |
| 2153 | |
| 2154 | static struct msm_camera_sensor_flash_src msm_flash_src_ov5640 = { |
| 2155 | .flash_sr_type = MSM_CAMERA_FLASH_SRC_LED, |
| 2156 | ._fsrc.led_src.led_name = "flashlight", |
| 2157 | ._fsrc.led_src.led_name_len = 10, |
| 2158 | }; |
| 2159 | |
| 2160 | static struct msm_camera_sensor_flash_data flash_ov5640 = { |
| 2161 | .flash_type = MSM_CAMERA_FLASH_LED, |
| 2162 | .flash_src = &msm_flash_src_ov5640, |
| 2163 | }; |
| 2164 | |
| 2165 | static struct msm_camera_sensor_info msm_camera_sensor_ov5640_data = { |
| 2166 | .sensor_name = "ov5640", |
| 2167 | .sensor_reset_enable = 1, |
| 2168 | .sensor_reset = GPIO_CAM_5MP_RESET, |
| 2169 | .sensor_pwd = GPIO_CAM_5MP_SHDN_EN, |
| 2170 | .vcm_pwd = 0, |
| 2171 | .vcm_enable = 0, |
| 2172 | .pdata = &msm_camera_data_rear, |
| 2173 | .flash_data = &flash_ov5640, |
| 2174 | .sensor_platform_info = &ov5640_sensor_info, |
| 2175 | .csi_if = 1, |
| 2176 | }; |
| 2177 | |
| 2178 | static struct platform_device msm_camera_sensor_ov5640 = { |
| 2179 | .name = "msm_camera_ov5640", |
| 2180 | .dev = { |
| 2181 | .platform_data = &msm_camera_sensor_ov5640_data, |
| 2182 | }, |
| 2183 | }; |
| 2184 | #endif |
| 2185 | |
| 2186 | #ifdef CONFIG_WEBCAM_OV7692_QRD |
| 2187 | static struct msm_camera_sensor_platform_info ov7692_sensor_7627a_info = { |
| 2188 | .mount_angle = 90 |
| 2189 | }; |
| 2190 | |
| 2191 | static struct msm_camera_sensor_flash_data flash_ov7692 = { |
| 2192 | .flash_type = MSM_CAMERA_FLASH_NONE, |
| 2193 | }; |
| 2194 | |
| 2195 | static struct msm_camera_sensor_info msm_camera_sensor_ov7692_data = { |
| 2196 | .sensor_name = "ov7692", |
| 2197 | .sensor_reset_enable = 0, |
| 2198 | .sensor_reset = 0, |
| 2199 | .sensor_pwd = GPIO_CAM_3MP_PWDN, |
| 2200 | .vcm_pwd = 0, |
| 2201 | .vcm_enable = 0, |
| 2202 | .pdata = &msm_camera_data_front, |
| 2203 | .flash_data = &flash_ov7692, |
| 2204 | .sensor_platform_info = &ov7692_sensor_7627a_info, |
| 2205 | .csi_if = 1, |
| 2206 | }; |
| 2207 | |
| 2208 | static struct platform_device msm_camera_sensor_ov7692 = { |
| 2209 | .name = "msm_camera_ov7692", |
| 2210 | .dev = { |
| 2211 | .platform_data = &msm_camera_sensor_ov7692_data, |
| 2212 | }, |
| 2213 | }; |
| 2214 | #endif |
| 2215 | |
| 2216 | static struct i2c_board_info i2c_camera_devices[] = { |
| 2217 | #ifdef CONFIG_OV5640 |
| 2218 | { |
| 2219 | I2C_BOARD_INFO("ov5640", 0x78 >> 1), |
| 2220 | }, |
| 2221 | #endif |
| 2222 | #ifdef CONFIG_WEBCAM_OV7692_QRD |
| 2223 | { |
| 2224 | I2C_BOARD_INFO("ov7692", 0x78), |
| 2225 | }, |
| 2226 | #endif |
| 2227 | }; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 2228 | static struct platform_device *qrd1_devices[] __initdata = { |
| 2229 | &msm_device_dmov, |
| 2230 | &msm_device_smd, |
| 2231 | &msm_device_uart1, |
| 2232 | &msm_device_uart_dm1, |
| 2233 | &msm_gsbi0_qup_i2c_device, |
| 2234 | &msm_gsbi1_qup_i2c_device, |
| 2235 | &msm_device_otg, |
| 2236 | &msm_device_gadget_peripheral, |
| 2237 | &android_usb_device, |
| 2238 | &android_pmem_device, |
| 2239 | &android_pmem_adsp_device, |
Taniya Das | 0a5303a | 2011-08-23 18:47:48 +0530 | [diff] [blame] | 2240 | &msm_fb_device, |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 2241 | &android_pmem_audio_device, |
| 2242 | &msm_device_snd, |
| 2243 | &msm_device_adspdec, |
| 2244 | &msm_batt_device, |
Taniya Das | 7a22cdd | 2011-09-08 14:57:00 +0530 | [diff] [blame] | 2245 | #ifdef CONFIG_OV5640 |
| 2246 | &msm_camera_sensor_ov5640, |
| 2247 | #endif |
| 2248 | #ifdef CONFIG_WEBCAM_OV7692_QRD |
| 2249 | &msm_camera_sensor_ov7692, |
| 2250 | #endif |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 2251 | &msm_kgsl_3d0, |
| 2252 | #ifdef CONFIG_BT |
| 2253 | &msm_bt_power_device, |
| 2254 | #endif |
Taniya Das | 0a5303a | 2011-08-23 18:47:48 +0530 | [diff] [blame] | 2255 | &mipi_dsi_truly_panel_device, |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 2256 | &msm_wlan_ar6000_pm_device, |
| 2257 | &asoc_msm_pcm, |
| 2258 | &asoc_msm_dai0, |
| 2259 | &asoc_msm_dai1, |
| 2260 | }; |
| 2261 | |
| 2262 | static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE; |
| 2263 | static int __init pmem_kernel_ebi1_size_setup(char *p) |
| 2264 | { |
| 2265 | pmem_kernel_ebi1_size = memparse(p, NULL); |
| 2266 | return 0; |
| 2267 | } |
| 2268 | early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup); |
| 2269 | |
| 2270 | static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE; |
| 2271 | static int __init pmem_audio_size_setup(char *p) |
| 2272 | { |
| 2273 | pmem_audio_size = memparse(p, NULL); |
| 2274 | return 0; |
| 2275 | } |
| 2276 | early_param("pmem_audio_size", pmem_audio_size_setup); |
| 2277 | |
| 2278 | static void __init msm_msm7627a_allocate_memory_regions(void) |
| 2279 | { |
Taniya Das | 0a5303a | 2011-08-23 18:47:48 +0530 | [diff] [blame] | 2280 | void *addr; |
| 2281 | unsigned long size; |
| 2282 | |
| 2283 | size = fb_size ? : MSM_FB_SIZE; |
| 2284 | addr = alloc_bootmem_align(size, 0x1000); |
| 2285 | msm_fb_resources[0].start = __pa(addr); |
| 2286 | msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1; |
| 2287 | pr_info("allocating %lu bytes at %p (%lx physical) for fb\n", size, |
| 2288 | addr, __pa(addr)); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 2289 | } |
| 2290 | |
| 2291 | static struct memtype_reserve msm7627a_reserve_table[] __initdata = { |
| 2292 | [MEMTYPE_SMI] = { |
| 2293 | }, |
| 2294 | [MEMTYPE_EBI0] = { |
| 2295 | .flags = MEMTYPE_FLAGS_1M_ALIGN, |
| 2296 | }, |
| 2297 | [MEMTYPE_EBI1] = { |
| 2298 | .flags = MEMTYPE_FLAGS_1M_ALIGN, |
| 2299 | }, |
| 2300 | }; |
| 2301 | |
Taniya Das | 0a5303a | 2011-08-23 18:47:48 +0530 | [diff] [blame] | 2302 | static struct msm_panel_common_pdata mdp_pdata = { |
| 2303 | .gpio = 97, |
| 2304 | .mdp_rev = MDP_REV_303, |
| 2305 | }; |
| 2306 | |
| 2307 | #define GPIO_LCDC_BRDG_PD 128 |
| 2308 | #define GPIO_LCDC_BRDG_RESET_N 129 |
| 2309 | #define GPIO_LCD_DSI_SEL 125 |
| 2310 | |
| 2311 | static unsigned mipi_dsi_gpio[] = { |
| 2312 | GPIO_CFG(GPIO_LCDC_BRDG_RESET_N, 0, GPIO_CFG_OUTPUT, |
| 2313 | GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* LCDC_BRDG_RESET_N */ |
| 2314 | GPIO_CFG(GPIO_LCDC_BRDG_PD, 0, GPIO_CFG_OUTPUT, |
| 2315 | GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* LCDC_BRDG_PD */ |
| 2316 | }; |
| 2317 | |
| 2318 | static unsigned lcd_dsi_sel_gpio[] = { |
| 2319 | GPIO_CFG(GPIO_LCD_DSI_SEL, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, |
| 2320 | GPIO_CFG_2MA), |
| 2321 | }; |
| 2322 | |
| 2323 | enum { |
| 2324 | DSI_SINGLE_LANE = 1, |
| 2325 | DSI_TWO_LANES, |
| 2326 | }; |
| 2327 | |
| 2328 | static int msm_fb_get_lane_config(void) |
| 2329 | { |
| 2330 | pr_info("DSI_TWO_LANES\n"); |
| 2331 | return DSI_TWO_LANES; |
| 2332 | } |
| 2333 | |
| 2334 | static int mipi_truly_sel_mode(int video_mode) |
| 2335 | { |
| 2336 | int rc = 0; |
| 2337 | |
| 2338 | rc = gpio_request(GPIO_LCD_DSI_SEL, "lcd_dsi_sel"); |
| 2339 | if (rc < 0) |
| 2340 | goto gpio_error; |
| 2341 | |
| 2342 | rc = gpio_tlmm_config(lcd_dsi_sel_gpio[0], GPIO_CFG_ENABLE); |
| 2343 | if (rc) |
| 2344 | goto gpio_error; |
| 2345 | |
| 2346 | rc = gpio_direction_output(GPIO_LCD_DSI_SEL, 1); |
| 2347 | if (!rc) { |
| 2348 | gpio_set_value_cansleep(GPIO_LCD_DSI_SEL, video_mode); |
| 2349 | return rc; |
| 2350 | } else { |
| 2351 | goto gpio_error; |
| 2352 | } |
| 2353 | |
| 2354 | gpio_error: |
| 2355 | pr_err("mipi_truly_sel_mode failed\n"); |
| 2356 | gpio_free(GPIO_LCD_DSI_SEL); |
| 2357 | return rc; |
| 2358 | } |
| 2359 | |
| 2360 | static int msm_fb_dsi_client_qrd1_reset(void) |
| 2361 | { |
| 2362 | int rc = 0; |
| 2363 | |
| 2364 | rc = gpio_request(GPIO_LCDC_BRDG_RESET_N, "lcdc_brdg_reset_n"); |
| 2365 | if (rc < 0) { |
| 2366 | pr_err("failed to request lcd brdg reset_n\n"); |
| 2367 | return rc; |
| 2368 | } |
| 2369 | |
| 2370 | rc = gpio_tlmm_config(mipi_dsi_gpio[0], GPIO_CFG_ENABLE); |
| 2371 | if (rc < 0) { |
| 2372 | pr_err("Failed to enable LCDC Bridge reset enable\n"); |
| 2373 | return rc; |
| 2374 | } |
| 2375 | |
| 2376 | rc = gpio_direction_output(GPIO_LCDC_BRDG_RESET_N, 1); |
| 2377 | if (rc < 0) { |
| 2378 | pr_err("Failed GPIO bridge pd\n"); |
| 2379 | gpio_free(GPIO_LCDC_BRDG_RESET_N); |
| 2380 | return rc; |
| 2381 | } |
| 2382 | |
| 2383 | mipi_truly_sel_mode(1); |
| 2384 | |
| 2385 | return rc; |
| 2386 | } |
| 2387 | |
| 2388 | static int msm_fb_dsi_client_reset(void) |
| 2389 | { |
| 2390 | int rc = 0; |
| 2391 | |
| 2392 | rc = msm_fb_dsi_client_qrd1_reset(); |
| 2393 | return rc; |
| 2394 | } |
| 2395 | |
| 2396 | static int dsi_gpio_initialized; |
| 2397 | |
| 2398 | static int mipi_dsi_panel_qrd1_power(int on) |
| 2399 | { |
| 2400 | int rc = 0; |
| 2401 | |
| 2402 | if (!dsi_gpio_initialized) { |
| 2403 | rc = gpio_request(GPIO_BACKLIGHT_EN, "gpio_bkl_en"); |
| 2404 | if (rc < 0) |
| 2405 | return rc; |
| 2406 | |
Jeevan Shriram | 72e4cc6 | 2011-11-10 14:57:22 +0530 | [diff] [blame] | 2407 | rc = gpio_tlmm_config(GPIO_CFG(GPIO_BACKLIGHT_EN, 0, |
| 2408 | GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 2409 | GPIO_CFG_ENABLE); |
| 2410 | if (rc < 0) { |
| 2411 | pr_err("failed GPIO_BACKLIGHT_EN tlmm config\n"); |
| 2412 | return rc; |
| 2413 | } |
| 2414 | |
Taniya Das | 0a5303a | 2011-08-23 18:47:48 +0530 | [diff] [blame] | 2415 | rc = gpio_direction_output(GPIO_BACKLIGHT_EN, 1); |
| 2416 | if (rc < 0) { |
| 2417 | pr_err("failed to enable backlight\n"); |
| 2418 | gpio_free(GPIO_BACKLIGHT_EN); |
| 2419 | return rc; |
| 2420 | } |
| 2421 | dsi_gpio_initialized = 1; |
| 2422 | } |
| 2423 | |
| 2424 | gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, !!on); |
| 2425 | |
| 2426 | if (!on) { |
| 2427 | gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1); |
| 2428 | msleep(20); |
| 2429 | gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 0); |
| 2430 | msleep(20); |
| 2431 | gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1); |
| 2432 | |
| 2433 | } |
| 2434 | |
| 2435 | return rc; |
| 2436 | } |
| 2437 | |
| 2438 | static int mipi_dsi_panel_power(int on) |
| 2439 | { |
| 2440 | int rc = 0; |
| 2441 | |
| 2442 | rc = mipi_dsi_panel_qrd1_power(on); |
| 2443 | return rc; |
| 2444 | } |
| 2445 | |
| 2446 | #define MDP_303_VSYNC_GPIO 97 |
| 2447 | |
| 2448 | #ifdef CONFIG_FB_MSM_MDP303 |
| 2449 | static struct mipi_dsi_platform_data mipi_dsi_pdata = { |
| 2450 | .vsync_gpio = MDP_303_VSYNC_GPIO, |
| 2451 | .dsi_power_save = mipi_dsi_panel_power, |
| 2452 | .dsi_client_reset = msm_fb_dsi_client_reset, |
| 2453 | .get_lane_config = msm_fb_get_lane_config, |
| 2454 | }; |
| 2455 | #endif |
| 2456 | |
| 2457 | static void __init msm_fb_add_devices(void) |
| 2458 | { |
| 2459 | msm_fb_register_device("mdp", &mdp_pdata); |
| 2460 | msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata); |
| 2461 | } |
| 2462 | |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 2463 | static void __init size_pmem_devices(void) |
| 2464 | { |
| 2465 | #ifdef CONFIG_ANDROID_PMEM |
| 2466 | android_pmem_adsp_pdata.size = pmem_adsp_size; |
| 2467 | android_pmem_pdata.size = pmem_mdp_size; |
| 2468 | android_pmem_audio_pdata.size = pmem_audio_size; |
| 2469 | #endif |
| 2470 | } |
| 2471 | |
| 2472 | static void __init reserve_memory_for(struct android_pmem_platform_data *p) |
| 2473 | { |
| 2474 | msm7627a_reserve_table[p->memory_type].size += p->size; |
| 2475 | } |
| 2476 | |
| 2477 | static void __init reserve_pmem_memory(void) |
| 2478 | { |
| 2479 | #ifdef CONFIG_ANDROID_PMEM |
| 2480 | reserve_memory_for(&android_pmem_adsp_pdata); |
| 2481 | reserve_memory_for(&android_pmem_pdata); |
| 2482 | reserve_memory_for(&android_pmem_audio_pdata); |
| 2483 | msm7627a_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size; |
| 2484 | #endif |
| 2485 | } |
| 2486 | |
| 2487 | static void __init msm7627a_calculate_reserve_sizes(void) |
| 2488 | { |
| 2489 | size_pmem_devices(); |
| 2490 | reserve_pmem_memory(); |
| 2491 | } |
| 2492 | |
| 2493 | static int msm7627a_paddr_to_memtype(unsigned int paddr) |
| 2494 | { |
| 2495 | return MEMTYPE_EBI1; |
| 2496 | } |
| 2497 | |
| 2498 | static struct reserve_info msm7627a_reserve_info __initdata = { |
| 2499 | .memtype_reserve_table = msm7627a_reserve_table, |
| 2500 | .calculate_reserve_sizes = msm7627a_calculate_reserve_sizes, |
| 2501 | .paddr_to_memtype = msm7627a_paddr_to_memtype, |
| 2502 | }; |
| 2503 | |
| 2504 | static void __init msm7627a_reserve(void) |
| 2505 | { |
| 2506 | reserve_info = &msm7627a_reserve_info; |
| 2507 | msm_reserve(); |
| 2508 | } |
| 2509 | |
| 2510 | static void __init msm_device_i2c_init(void) |
| 2511 | { |
| 2512 | msm_gsbi0_qup_i2c_device.dev.platform_data = &msm_gsbi0_qup_i2c_pdata; |
| 2513 | msm_gsbi1_qup_i2c_device.dev.platform_data = &msm_gsbi1_qup_i2c_pdata; |
| 2514 | } |
| 2515 | |
| 2516 | static struct msm_handset_platform_data hs_platform_data = { |
| 2517 | .hs_name = "7k_handset", |
| 2518 | .pwr_key_delay_ms = 500, /* 0 will disable end key */ |
| 2519 | }; |
| 2520 | |
| 2521 | static struct platform_device hs_pdev = { |
| 2522 | .name = "msm-handset", |
| 2523 | .id = -1, |
| 2524 | .dev = { |
| 2525 | .platform_data = &hs_platform_data, |
| 2526 | }, |
| 2527 | }; |
| 2528 | |
Pankaj Kumar | 3cec058 | 2011-11-18 11:13:29 +0530 | [diff] [blame] | 2529 | static struct platform_device msm_proccomm_regulator_dev = { |
| 2530 | .name = PROCCOMM_REGULATOR_DEV_NAME, |
| 2531 | .id = -1, |
| 2532 | .dev = { |
| 2533 | .platform_data = &msm7x27a_proccomm_regulator_data |
| 2534 | } |
| 2535 | }; |
| 2536 | |
| 2537 | static void __init msm7627a_init_regulators(void) |
| 2538 | { |
| 2539 | int rc = platform_device_register(&msm_proccomm_regulator_dev); |
| 2540 | if (rc) |
| 2541 | pr_err("%s: could not register regulator device: %d\n", |
| 2542 | __func__, rc); |
| 2543 | } |
| 2544 | |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 2545 | #define UART1DM_RX_GPIO 45 |
| 2546 | static void __init msm_qrd1_init(void) |
| 2547 | { |
| 2548 | msm7x2x_misc_init(); |
Pankaj Kumar | 3cec058 | 2011-11-18 11:13:29 +0530 | [diff] [blame] | 2549 | msm7627a_init_regulators(); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 2550 | msm_device_i2c_init(); |
| 2551 | msm7627a_init_mmc(); |
| 2552 | |
Taniya Das | 7a22cdd | 2011-09-08 14:57:00 +0530 | [diff] [blame] | 2553 | qrd1_camera_gpio_cfg(); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 2554 | #ifdef CONFIG_SERIAL_MSM_HS |
| 2555 | msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(UART1DM_RX_GPIO); |
| 2556 | msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata; |
| 2557 | #endif |
| 2558 | |
| 2559 | #ifdef CONFIG_USB_MSM_OTG_72K |
| 2560 | msm_otg_pdata.swfi_latency = msm7627a_pm_data |
| 2561 | [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency; |
| 2562 | msm_device_otg.dev.platform_data = &msm_otg_pdata; |
| 2563 | #endif |
| 2564 | msm_device_gadget_peripheral.dev.platform_data = |
Taniya Das | 7a22cdd | 2011-09-08 14:57:00 +0530 | [diff] [blame] | 2565 | &msm_gadget_pdata; |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 2566 | platform_add_devices(qrd1_devices, |
Taniya Das | 7a22cdd | 2011-09-08 14:57:00 +0530 | [diff] [blame] | 2567 | ARRAY_SIZE(qrd1_devices)); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 2568 | #ifdef CONFIG_USB_EHCI_MSM_72K |
| 2569 | msm7627a_init_host(); |
| 2570 | #endif |
| 2571 | msm_pm_set_platform_data(msm7627a_pm_data, |
| 2572 | ARRAY_SIZE(msm7627a_pm_data)); |
Maheshkumar Sivasubramanian | c6c5503 | 2011-10-25 16:01:32 -0600 | [diff] [blame^] | 2573 | BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata)); |
Murali Nalajala | a182784 | 2011-11-13 14:12:39 +0530 | [diff] [blame] | 2574 | |
Taniya Das | 0a5303a | 2011-08-23 18:47:48 +0530 | [diff] [blame] | 2575 | msm_fb_add_devices(); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 2576 | |
| 2577 | #if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE) |
| 2578 | i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID, |
Taniya Das | 7a22cdd | 2011-09-08 14:57:00 +0530 | [diff] [blame] | 2579 | bahama_devices, |
| 2580 | ARRAY_SIZE(bahama_devices)); |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 2581 | bt_power_init(); |
| 2582 | #endif |
Taniya Das | da40882 | 2011-09-06 12:54:06 +0530 | [diff] [blame] | 2583 | |
Pankaj Kumar | 27c0264 | 2011-09-22 15:55:55 +0530 | [diff] [blame] | 2584 | msm_camera_vreg_init(); |
Taniya Das | 7a22cdd | 2011-09-08 14:57:00 +0530 | [diff] [blame] | 2585 | i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID, i2c_camera_devices, |
| 2586 | ARRAY_SIZE(i2c_camera_devices)); |
| 2587 | |
Taniya Das | da40882 | 2011-09-06 12:54:06 +0530 | [diff] [blame] | 2588 | #if defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C) || \ |
| 2589 | defined(CONFIG_TOUCHSCREEN_SYNAPTICS_RMI4_I2C_MODULE) |
| 2590 | i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID, |
| 2591 | synaptic_i2c_clearpad3k, |
| 2592 | ARRAY_SIZE(synaptic_i2c_clearpad3k)); |
| 2593 | #endif |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 2594 | platform_device_register(&hs_pdev); |
| 2595 | |
| 2596 | #ifdef CONFIG_MSM_RPC_VIBRATOR |
| 2597 | msm_init_pmic_vibrator(); |
| 2598 | #endif |
| 2599 | } |
| 2600 | |
| 2601 | static void __init qrd7627a_init_early(void) |
| 2602 | { |
| 2603 | msm_msm7627a_allocate_memory_regions(); |
| 2604 | } |
| 2605 | |
| 2606 | MACHINE_START(MSM7627A_QRD1, "QRD MSM7627a QRD1") |
| 2607 | .boot_params = PHYS_OFFSET + 0x100, |
| 2608 | .map_io = msm_common_io_init, |
| 2609 | .reserve = msm7627a_reserve, |
| 2610 | .init_irq = msm_init_irq, |
| 2611 | .init_machine = msm_qrd1_init, |
| 2612 | .timer = &msm_timer, |
| 2613 | .init_early = qrd7627a_init_early, |
Pankaj Kumar | bf8a2a3 | 2011-10-21 11:47:21 +0530 | [diff] [blame] | 2614 | .handle_irq = vic_handle_irq, |
Taniya Das | c98bfbc | 2011-08-23 09:58:55 +0530 | [diff] [blame] | 2615 | MACHINE_END |