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