Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [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 | #include <linux/kernel.h> |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/gpio_event.h> |
| 15 | #include <asm/mach-types.h> |
| 16 | #include <asm/mach/arch.h> |
| 17 | #include <mach/board.h> |
| 18 | #include <mach/msm_iomap.h> |
| 19 | #include <mach/msm_hsusb.h> |
| 20 | #include <mach/rpc_hsusb.h> |
| 21 | #include <mach/rpc_pmapp.h> |
| 22 | #include <mach/usbdiag.h> |
| 23 | #include <mach/msm_memtypes.h> |
| 24 | #include <mach/msm_serial_hs.h> |
| 25 | #include <linux/usb/android.h> |
| 26 | #include <linux/platform_device.h> |
| 27 | #include <linux/io.h> |
| 28 | #include <linux/gpio.h> |
| 29 | #include <mach/vreg.h> |
| 30 | #include <mach/pmic.h> |
| 31 | #include <mach/socinfo.h> |
| 32 | #include <linux/mtd/nand.h> |
| 33 | #include <linux/mtd/partitions.h> |
| 34 | #include <asm/mach/mmc.h> |
| 35 | #include <linux/i2c.h> |
| 36 | #include <linux/i2c/sx150x.h> |
| 37 | #include <linux/gpio.h> |
| 38 | #include <linux/android_pmem.h> |
| 39 | #include <linux/bootmem.h> |
| 40 | #include <linux/mfd/marimba.h> |
| 41 | #include <mach/vreg.h> |
| 42 | #include <linux/power_supply.h> |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 43 | #include <linux/regulator/consumer.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 44 | #include <mach/rpc_pmapp.h> |
| 45 | |
| 46 | #include <mach/msm_battery.h> |
| 47 | #include <linux/smsc911x.h> |
| 48 | #include <linux/atmel_maxtouch.h> |
| 49 | #include "devices.h" |
| 50 | #include "timer.h" |
Justin Paupore | b3a33b7 | 2011-08-23 15:30:32 -0700 | [diff] [blame] | 51 | #include "board-msm7x27a-regulator.h" |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 52 | #include "devices-msm7x2xa.h" |
| 53 | #include "pm.h" |
| 54 | #include <mach/rpc_server_handset.h> |
| 55 | #include <mach/socinfo.h> |
Maheshkumar Sivasubramanian | 8ccc16e | 2011-10-25 15:59:57 -0600 | [diff] [blame] | 56 | #include "pm-boot.h" |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 57 | |
| 58 | #define PMEM_KERNEL_EBI1_SIZE 0x3A000 |
| 59 | #define MSM_PMEM_AUDIO_SIZE 0x5B000 |
| 60 | #define BAHAMA_SLAVE_ID_FM_ADDR 0x2A |
| 61 | #define BAHAMA_SLAVE_ID_QMEMBIST_ADDR 0x7B |
Rahul Kashyap | 181d555 | 2011-07-07 10:39:23 +0530 | [diff] [blame] | 62 | #define BAHAMA_SLAVE_ID_FM_REG 0x02 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 63 | #define FM_GPIO 83 |
Srinivas Krovvidi | 1cea4d3 | 2011-12-06 15:40:56 +0530 | [diff] [blame] | 64 | #define BT_PCM_BCLK_MODE 0x88 |
| 65 | #define BT_PCM_DIN_MODE 0x89 |
| 66 | #define BT_PCM_DOUT_MODE 0x8A |
| 67 | #define BT_PCM_SYNC_MODE 0x8B |
| 68 | #define FM_I2S_SD_MODE 0x8E |
| 69 | #define FM_I2S_WS_MODE 0x8F |
| 70 | #define FM_I2S_SCK_MODE 0x90 |
| 71 | #define I2C_PIN_CTL 0x15 |
| 72 | #define I2C_NORMAL 0x40 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 73 | |
| 74 | enum { |
| 75 | GPIO_EXPANDER_IRQ_BASE = NR_MSM_IRQS + NR_GPIO_IRQS, |
| 76 | GPIO_EXPANDER_GPIO_BASE = NR_MSM_GPIOS, |
| 77 | /* SURF expander */ |
| 78 | GPIO_CORE_EXPANDER_BASE = GPIO_EXPANDER_GPIO_BASE, |
| 79 | GPIO_BT_SYS_REST_EN = GPIO_CORE_EXPANDER_BASE, |
| 80 | GPIO_WLAN_EXT_POR_N, |
| 81 | GPIO_DISPLAY_PWR_EN, |
| 82 | GPIO_BACKLIGHT_EN, |
| 83 | GPIO_PRESSURE_XCLR, |
| 84 | GPIO_VREG_S3_EXP, |
| 85 | GPIO_UBM2M_PWRDWN, |
| 86 | GPIO_ETM_MODE_CS_N, |
| 87 | GPIO_HOST_VBUS_EN, |
| 88 | GPIO_SPI_MOSI, |
| 89 | GPIO_SPI_MISO, |
| 90 | GPIO_SPI_CLK, |
| 91 | GPIO_SPI_CS0_N, |
| 92 | GPIO_CORE_EXPANDER_IO13, |
| 93 | GPIO_CORE_EXPANDER_IO14, |
| 94 | GPIO_CORE_EXPANDER_IO15, |
| 95 | /* Camera expander */ |
| 96 | GPIO_CAM_EXPANDER_BASE = GPIO_CORE_EXPANDER_BASE + 16, |
| 97 | GPIO_CAM_GP_STROBE_READY = GPIO_CAM_EXPANDER_BASE, |
| 98 | GPIO_CAM_GP_AFBUSY, |
| 99 | GPIO_CAM_GP_CAM_PWDN, |
| 100 | GPIO_CAM_GP_CAM1MP_XCLR, |
| 101 | GPIO_CAM_GP_CAMIF_RESET_N, |
| 102 | GPIO_CAM_GP_STROBE_CE, |
| 103 | GPIO_CAM_GP_LED_EN1, |
| 104 | GPIO_CAM_GP_LED_EN2, |
| 105 | }; |
| 106 | |
| 107 | #if defined(CONFIG_GPIO_SX150X) |
| 108 | enum { |
| 109 | SX150X_CORE, |
| 110 | SX150X_CAM, |
| 111 | }; |
| 112 | |
| 113 | static struct sx150x_platform_data sx150x_data[] __initdata = { |
| 114 | [SX150X_CORE] = { |
| 115 | .gpio_base = GPIO_CORE_EXPANDER_BASE, |
| 116 | .oscio_is_gpo = false, |
| 117 | .io_pullup_ena = 0, |
pankaj kumar | c5c0139 | 2011-08-12 13:44:05 +0530 | [diff] [blame] | 118 | .io_pulldn_ena = 0x02, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 119 | .io_open_drain_ena = 0xfef8, |
| 120 | .irq_summary = -1, |
| 121 | }, |
| 122 | [SX150X_CAM] = { |
| 123 | .gpio_base = GPIO_CAM_EXPANDER_BASE, |
| 124 | .oscio_is_gpo = false, |
| 125 | .io_pullup_ena = 0, |
| 126 | .io_pulldn_ena = 0, |
| 127 | .io_open_drain_ena = 0x23, |
| 128 | .irq_summary = -1, |
| 129 | }, |
| 130 | }; |
| 131 | #endif |
| 132 | |
| 133 | #if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE) |
| 134 | |
| 135 | /* FM Platform power and shutdown routines */ |
| 136 | #define FPGA_MSM_CNTRL_REG2 0x90008010 |
Srinivas Krovvidi | 1cea4d3 | 2011-12-06 15:40:56 +0530 | [diff] [blame] | 137 | static int switch_pcm_i2s_reg_mode(int mode) |
| 138 | { |
| 139 | unsigned char reg = 0; |
| 140 | int rc = -1; |
| 141 | unsigned char set = I2C_PIN_CTL; /*SET PIN CTL mode*/ |
| 142 | unsigned char unset = I2C_NORMAL; /* UNSET PIN CTL MODE*/ |
| 143 | struct marimba config = { .mod_id = SLAVE_ID_BAHAMA}; |
| 144 | |
| 145 | if (mode == 0) { |
| 146 | /* as we need to switch path to FM we need to move |
| 147 | BT AUX PCM lines to PIN CONTROL mode then move |
| 148 | FM to normal mode.*/ |
| 149 | for (reg = BT_PCM_BCLK_MODE; reg <= BT_PCM_SYNC_MODE; reg++) { |
| 150 | rc = marimba_write(&config, reg, &set, 1); |
| 151 | if (rc < 0) { |
| 152 | pr_err("pcm pinctl failed = %d", rc); |
| 153 | goto err_all; |
| 154 | } |
| 155 | } |
| 156 | for (reg = FM_I2S_SD_MODE; reg <= FM_I2S_SCK_MODE; reg++) { |
| 157 | rc = marimba_write(&config, reg, &unset, 1); |
| 158 | if (rc < 0) { |
| 159 | pr_err("i2s normal failed = %d", rc); |
| 160 | goto err_all; |
| 161 | } |
| 162 | } |
| 163 | } else { |
| 164 | /* as we need to switch path to AUXPCM we need to move |
| 165 | FM I2S lines to PIN CONTROL mode then move |
| 166 | BT AUX_PCM to normal mode.*/ |
| 167 | for (reg = FM_I2S_SD_MODE; reg <= FM_I2S_SCK_MODE; reg++) { |
| 168 | rc = marimba_write(&config, reg, &set, 1); |
| 169 | if (rc < 0) { |
| 170 | pr_err("i2s pinctl failed = %d", rc); |
| 171 | goto err_all; |
| 172 | } |
| 173 | } |
| 174 | for (reg = BT_PCM_BCLK_MODE; reg <= BT_PCM_SYNC_MODE; reg++) { |
| 175 | rc = marimba_write(&config, reg, &unset, 1); |
| 176 | if (rc < 0) { |
| 177 | pr_err("pcm normal failed = %d", rc); |
| 178 | goto err_all; |
| 179 | } |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | return 0; |
| 184 | |
| 185 | err_all: |
| 186 | return rc; |
| 187 | } |
Rahul Kashyap | 6e66946 | 2011-07-23 16:42:56 +0530 | [diff] [blame] | 188 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 189 | static void config_pcm_i2s_mode(int mode) |
| 190 | { |
| 191 | void __iomem *cfg_ptr; |
| 192 | u8 reg2; |
| 193 | |
| 194 | cfg_ptr = ioremap_nocache(FPGA_MSM_CNTRL_REG2, sizeof(char)); |
| 195 | |
| 196 | if (!cfg_ptr) |
| 197 | return; |
| 198 | if (mode) { |
| 199 | /*enable the pcm mode in FPGA*/ |
| 200 | reg2 = readb_relaxed(cfg_ptr); |
| 201 | if (reg2 == 0) { |
| 202 | reg2 = 1; |
| 203 | writeb_relaxed(reg2, cfg_ptr); |
| 204 | } |
| 205 | } else { |
| 206 | /*enable i2s mode in FPGA*/ |
| 207 | reg2 = readb_relaxed(cfg_ptr); |
| 208 | if (reg2 == 1) { |
| 209 | reg2 = 0; |
| 210 | writeb_relaxed(reg2, cfg_ptr); |
| 211 | } |
| 212 | } |
| 213 | iounmap(cfg_ptr); |
| 214 | } |
| 215 | |
| 216 | static unsigned fm_i2s_config_power_on[] = { |
| 217 | /*FM_I2S_SD*/ |
| 218 | GPIO_CFG(68, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 219 | /*FM_I2S_WS*/ |
| 220 | GPIO_CFG(70, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 221 | /*FM_I2S_SCK*/ |
| 222 | GPIO_CFG(71, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 223 | }; |
| 224 | |
| 225 | static unsigned fm_i2s_config_power_off[] = { |
| 226 | /*FM_I2S_SD*/ |
| 227 | GPIO_CFG(68, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 228 | /*FM_I2S_WS*/ |
| 229 | GPIO_CFG(70, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 230 | /*FM_I2S_SCK*/ |
| 231 | GPIO_CFG(71, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 232 | }; |
| 233 | |
| 234 | static unsigned bt_config_power_on[] = { |
| 235 | /*RFR*/ |
| 236 | GPIO_CFG(43, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 237 | /*CTS*/ |
| 238 | GPIO_CFG(44, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 239 | /*RX*/ |
| 240 | GPIO_CFG(45, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 241 | /*TX*/ |
| 242 | GPIO_CFG(46, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 243 | }; |
| 244 | static unsigned bt_config_pcm_on[] = { |
| 245 | /*PCM_DOUT*/ |
| 246 | GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 247 | /*PCM_DIN*/ |
| 248 | GPIO_CFG(69, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 249 | /*PCM_SYNC*/ |
| 250 | GPIO_CFG(70, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 251 | /*PCM_CLK*/ |
| 252 | GPIO_CFG(71, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 253 | }; |
| 254 | static unsigned bt_config_power_off[] = { |
| 255 | /*RFR*/ |
| 256 | GPIO_CFG(43, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 257 | /*CTS*/ |
| 258 | GPIO_CFG(44, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 259 | /*RX*/ |
| 260 | GPIO_CFG(45, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 261 | /*TX*/ |
| 262 | GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 263 | }; |
| 264 | static unsigned bt_config_pcm_off[] = { |
| 265 | /*PCM_DOUT*/ |
| 266 | GPIO_CFG(68, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 267 | /*PCM_DIN*/ |
| 268 | GPIO_CFG(69, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 269 | /*PCM_SYNC*/ |
| 270 | GPIO_CFG(70, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 271 | /*PCM_CLK*/ |
| 272 | GPIO_CFG(71, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 273 | }; |
| 274 | |
| 275 | static int config_i2s(int mode) |
| 276 | { |
| 277 | int pin, rc = 0; |
| 278 | |
| 279 | if (mode == FM_I2S_ON) { |
Trilok Soni | 3d0f6c5 | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 280 | if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf()) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 281 | config_pcm_i2s_mode(0); |
| 282 | pr_err("%s mode = FM_I2S_ON", __func__); |
Srinivas Krovvidi | 1cea4d3 | 2011-12-06 15:40:56 +0530 | [diff] [blame] | 283 | |
| 284 | rc = switch_pcm_i2s_reg_mode(0); |
| 285 | if (rc) { |
| 286 | pr_err("switch mode failed"); |
| 287 | return rc; |
| 288 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 289 | for (pin = 0; pin < ARRAY_SIZE(fm_i2s_config_power_on); |
| 290 | pin++) { |
| 291 | rc = gpio_tlmm_config( |
| 292 | fm_i2s_config_power_on[pin], |
| 293 | GPIO_CFG_ENABLE |
| 294 | ); |
| 295 | if (rc < 0) |
| 296 | return rc; |
| 297 | } |
| 298 | } else if (mode == FM_I2S_OFF) { |
| 299 | pr_err("%s mode = FM_I2S_OFF", __func__); |
Srinivas Krovvidi | 1cea4d3 | 2011-12-06 15:40:56 +0530 | [diff] [blame] | 300 | rc = switch_pcm_i2s_reg_mode(1); |
| 301 | if (rc) { |
| 302 | pr_err("switch mode failed"); |
| 303 | return rc; |
| 304 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 305 | for (pin = 0; pin < ARRAY_SIZE(fm_i2s_config_power_off); |
| 306 | pin++) { |
| 307 | rc = gpio_tlmm_config( |
| 308 | fm_i2s_config_power_off[pin], |
| 309 | GPIO_CFG_ENABLE |
| 310 | ); |
| 311 | if (rc < 0) |
| 312 | return rc; |
| 313 | } |
| 314 | } |
| 315 | return rc; |
| 316 | } |
| 317 | static int config_pcm(int mode) |
| 318 | { |
| 319 | int pin, rc = 0; |
| 320 | |
| 321 | if (mode == BT_PCM_ON) { |
Trilok Soni | 3d0f6c5 | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 322 | if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf()) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 323 | config_pcm_i2s_mode(1); |
| 324 | pr_err("%s mode =BT_PCM_ON", __func__); |
Srinivas Krovvidi | 1cea4d3 | 2011-12-06 15:40:56 +0530 | [diff] [blame] | 325 | rc = switch_pcm_i2s_reg_mode(1); |
| 326 | if (rc) { |
| 327 | pr_err("switch mode failed"); |
| 328 | return rc; |
| 329 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 330 | for (pin = 0; pin < ARRAY_SIZE(bt_config_pcm_on); |
| 331 | pin++) { |
| 332 | rc = gpio_tlmm_config(bt_config_pcm_on[pin], |
| 333 | GPIO_CFG_ENABLE); |
| 334 | if (rc < 0) |
| 335 | return rc; |
| 336 | } |
| 337 | } else if (mode == BT_PCM_OFF) { |
| 338 | pr_err("%s mode =BT_PCM_OFF", __func__); |
Srinivas Krovvidi | 1cea4d3 | 2011-12-06 15:40:56 +0530 | [diff] [blame] | 339 | rc = switch_pcm_i2s_reg_mode(0); |
| 340 | if (rc) { |
| 341 | pr_err("switch mode failed"); |
| 342 | return rc; |
| 343 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 344 | for (pin = 0; pin < ARRAY_SIZE(bt_config_pcm_off); |
| 345 | pin++) { |
| 346 | rc = gpio_tlmm_config(bt_config_pcm_off[pin], |
| 347 | GPIO_CFG_ENABLE); |
| 348 | if (rc < 0) |
| 349 | return rc; |
| 350 | } |
| 351 | |
| 352 | } |
| 353 | |
| 354 | return rc; |
| 355 | } |
| 356 | |
| 357 | static int msm_bahama_setup_pcm_i2s(int mode) |
| 358 | { |
| 359 | int fm_state = 0, bt_state = 0; |
| 360 | int rc = 0; |
| 361 | struct marimba config = { .mod_id = SLAVE_ID_BAHAMA}; |
| 362 | |
| 363 | fm_state = marimba_get_fm_status(&config); |
| 364 | bt_state = marimba_get_bt_status(&config); |
| 365 | |
| 366 | switch (mode) { |
| 367 | case BT_PCM_ON: |
| 368 | case BT_PCM_OFF: |
| 369 | if (!fm_state) |
| 370 | rc = config_pcm(mode); |
| 371 | break; |
| 372 | case FM_I2S_ON: |
| 373 | rc = config_i2s(mode); |
| 374 | break; |
| 375 | case FM_I2S_OFF: |
| 376 | if (bt_state) |
| 377 | rc = config_pcm(BT_PCM_ON); |
| 378 | else |
| 379 | rc = config_i2s(mode); |
| 380 | break; |
| 381 | default: |
| 382 | rc = -EIO; |
| 383 | pr_err("%s:Unsupported mode", __func__); |
| 384 | } |
| 385 | return rc; |
| 386 | } |
| 387 | |
Rahul Kashyap | 181d555 | 2011-07-07 10:39:23 +0530 | [diff] [blame] | 388 | static int bt_set_gpio(int on) |
| 389 | { |
| 390 | int rc = 0; |
| 391 | struct marimba config = { .mod_id = SLAVE_ID_BAHAMA}; |
| 392 | |
| 393 | if (on) { |
| 394 | rc = gpio_direction_output(GPIO_BT_SYS_REST_EN, 1); |
| 395 | msleep(100); |
| 396 | } else { |
| 397 | if (!marimba_get_fm_status(&config) && |
| 398 | !marimba_get_bt_status(&config)) { |
| 399 | gpio_set_value_cansleep(GPIO_BT_SYS_REST_EN, 0); |
| 400 | rc = gpio_direction_input(GPIO_BT_SYS_REST_EN); |
| 401 | msleep(100); |
| 402 | } |
| 403 | } |
| 404 | if (rc) |
| 405 | pr_err("%s: BT sys_reset_en GPIO : Error", __func__); |
| 406 | |
| 407 | return rc; |
| 408 | } |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 409 | static struct regulator *fm_regulator; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 410 | static int fm_radio_setup(struct marimba_fm_platform_data *pdata) |
| 411 | { |
| 412 | int rc = 0; |
| 413 | const char *id = "FMPW"; |
| 414 | uint32_t irqcfg; |
Rahul Kashyap | 181d555 | 2011-07-07 10:39:23 +0530 | [diff] [blame] | 415 | struct marimba config = { .mod_id = SLAVE_ID_BAHAMA}; |
| 416 | u8 value; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 417 | |
| 418 | /* Voting for 1.8V Regulator */ |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 419 | fm_regulator = regulator_get(NULL, "msme1"); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 420 | if (IS_ERR(fm_regulator)) { |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 421 | rc = PTR_ERR(fm_regulator); |
| 422 | pr_err("%s: could not get regulator: %d\n", __func__, rc); |
| 423 | goto out; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | /* Set the voltage level to 1.8V */ |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 427 | rc = regulator_set_voltage(fm_regulator, 1800000, 1800000); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 428 | if (rc < 0) { |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 429 | pr_err("%s: could not set voltage: %d\n", __func__, rc); |
| 430 | goto reg_free; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 431 | } |
| 432 | |
| 433 | /* Enabling the 1.8V regulator */ |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 434 | rc = regulator_enable(fm_regulator); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 435 | if (rc) { |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 436 | pr_err("%s: could not enable regulator: %d\n", __func__, rc); |
| 437 | goto reg_free; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 438 | } |
| 439 | |
| 440 | /* Voting for 19.2MHz clock */ |
| 441 | rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1, |
| 442 | PMAPP_CLOCK_VOTE_ON); |
| 443 | if (rc < 0) { |
| 444 | pr_err("%s: clock vote failed with :(%d)\n", |
| 445 | __func__, rc); |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 446 | goto reg_disable; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 447 | } |
| 448 | |
Rahul Kashyap | 181d555 | 2011-07-07 10:39:23 +0530 | [diff] [blame] | 449 | rc = bt_set_gpio(1); |
| 450 | if (rc) { |
| 451 | pr_err("%s: bt_set_gpio = %d", __func__, rc); |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 452 | goto gpio_deconfig; |
Rahul Kashyap | 181d555 | 2011-07-07 10:39:23 +0530 | [diff] [blame] | 453 | } |
| 454 | /*re-write FM Slave Id, after reset*/ |
| 455 | value = BAHAMA_SLAVE_ID_FM_ADDR; |
| 456 | rc = marimba_write_bit_mask(&config, |
| 457 | BAHAMA_SLAVE_ID_FM_REG, &value, 1, 0xFF); |
| 458 | if (rc < 0) { |
| 459 | pr_err("%s: FM Slave ID rewrite Failed = %d", __func__, rc); |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 460 | goto gpio_deconfig; |
Rahul Kashyap | 181d555 | 2011-07-07 10:39:23 +0530 | [diff] [blame] | 461 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 462 | /* Configuring the FM GPIO */ |
| 463 | irqcfg = GPIO_CFG(FM_GPIO, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, |
| 464 | GPIO_CFG_2MA); |
| 465 | |
| 466 | rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE); |
| 467 | if (rc) { |
| 468 | pr_err("%s: gpio_tlmm_config(%#x)=%d\n", |
| 469 | __func__, irqcfg, rc); |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 470 | goto gpio_deconfig; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 471 | } |
| 472 | |
| 473 | return 0; |
| 474 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 475 | gpio_deconfig: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 476 | pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1, |
| 477 | PMAPP_CLOCK_VOTE_OFF); |
Rahul Kashyap | 181d555 | 2011-07-07 10:39:23 +0530 | [diff] [blame] | 478 | bt_set_gpio(0); |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 479 | reg_disable: |
| 480 | regulator_disable(fm_regulator); |
| 481 | reg_free: |
| 482 | regulator_put(fm_regulator); |
| 483 | fm_regulator = NULL; |
| 484 | out: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 485 | return rc; |
| 486 | }; |
| 487 | |
| 488 | static void fm_radio_shutdown(struct marimba_fm_platform_data *pdata) |
| 489 | { |
| 490 | int rc; |
| 491 | const char *id = "FMPW"; |
| 492 | |
| 493 | /* Releasing the GPIO line used by FM */ |
| 494 | uint32_t irqcfg = GPIO_CFG(FM_GPIO, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, |
| 495 | GPIO_CFG_2MA); |
| 496 | |
| 497 | rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE); |
| 498 | if (rc) |
| 499 | pr_err("%s: gpio_tlmm_config(%#x)=%d\n", |
| 500 | __func__, irqcfg, rc); |
| 501 | |
| 502 | /* Releasing the 1.8V Regulator */ |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 503 | if (!IS_ERR_OR_NULL(fm_regulator)) { |
| 504 | rc = regulator_disable(fm_regulator); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 505 | if (rc) |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 506 | pr_err("%s: could not disable regulator: %d\n", |
| 507 | __func__, rc); |
| 508 | regulator_put(fm_regulator); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 509 | fm_regulator = NULL; |
| 510 | } |
| 511 | |
| 512 | /* Voting off the clock */ |
| 513 | rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1, |
| 514 | PMAPP_CLOCK_VOTE_OFF); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 515 | if (rc < 0) |
| 516 | pr_err("%s: voting off failed with :(%d)\n", |
| 517 | __func__, rc); |
Rahul Kashyap | 181d555 | 2011-07-07 10:39:23 +0530 | [diff] [blame] | 518 | rc = bt_set_gpio(0); |
| 519 | if (rc) |
| 520 | pr_err("%s: bt_set_gpio = %d", __func__, rc); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 521 | } |
| 522 | |
| 523 | static struct marimba_fm_platform_data marimba_fm_pdata = { |
| 524 | .fm_setup = fm_radio_setup, |
| 525 | .fm_shutdown = fm_radio_shutdown, |
| 526 | .irq = MSM_GPIO_TO_INT(FM_GPIO), |
| 527 | .vreg_s2 = NULL, |
| 528 | .vreg_xo_out = NULL, |
| 529 | /* Configuring the FM SoC as I2S Master */ |
| 530 | .is_fm_soc_i2s_master = true, |
| 531 | .config_i2s_gpio = msm_bahama_setup_pcm_i2s, |
| 532 | }; |
| 533 | |
Santosh Sajjan | 6822c68 | 2011-07-26 10:49:36 +0530 | [diff] [blame] | 534 | static struct platform_device msm_wlan_ar6000_pm_device = { |
| 535 | .name = "wlan_ar6000_pm_dev", |
| 536 | .id = -1, |
| 537 | }; |
| 538 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 539 | static struct platform_device msm_bt_power_device = { |
| 540 | .name = "bt_power", |
| 541 | }; |
Rahul Kashyap | 6e66946 | 2011-07-23 16:42:56 +0530 | [diff] [blame] | 542 | struct bahama_config_register { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 543 | u8 reg; |
| 544 | u8 value; |
| 545 | u8 mask; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 546 | }; |
Rahul Kashyap | 6e66946 | 2011-07-23 16:42:56 +0530 | [diff] [blame] | 547 | struct bt_vreg_info { |
| 548 | const char *name; |
| 549 | unsigned int pmapp_id; |
Pankaj Kumar | 6ac59af | 2011-10-12 12:45:40 +0530 | [diff] [blame] | 550 | unsigned int min_level; |
| 551 | unsigned int max_level; |
Rahul Kashyap | 6e66946 | 2011-07-23 16:42:56 +0530 | [diff] [blame] | 552 | unsigned int is_pin_controlled; |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 553 | struct regulator *reg; |
Rahul Kashyap | 6e66946 | 2011-07-23 16:42:56 +0530 | [diff] [blame] | 554 | }; |
| 555 | static struct bt_vreg_info bt_vregs[] = { |
Pankaj Kumar | 6ac59af | 2011-10-12 12:45:40 +0530 | [diff] [blame] | 556 | {"msme1", 2, 1800000, 1800000, 0, NULL}, |
| 557 | {"bt", 21, 2900000, 3050000, 1, NULL} |
Rahul Kashyap | 6e66946 | 2011-07-23 16:42:56 +0530 | [diff] [blame] | 558 | }; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 559 | |
| 560 | static int bahama_bt(int on) |
| 561 | { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 562 | int rc = 0; |
| 563 | int i; |
| 564 | |
| 565 | struct marimba config = { .mod_id = SLAVE_ID_BAHAMA}; |
| 566 | |
| 567 | struct bahama_variant_register { |
| 568 | const size_t size; |
| 569 | const struct bahama_config_register *set; |
| 570 | }; |
| 571 | |
| 572 | const struct bahama_config_register *p; |
| 573 | |
| 574 | u8 version; |
| 575 | |
| 576 | const struct bahama_config_register v10_bt_on[] = { |
| 577 | { 0xE9, 0x00, 0xFF }, |
| 578 | { 0xF4, 0x80, 0xFF }, |
| 579 | { 0xE4, 0x00, 0xFF }, |
| 580 | { 0xE5, 0x00, 0x0F }, |
| 581 | #ifdef CONFIG_WLAN |
| 582 | { 0xE6, 0x38, 0x7F }, |
| 583 | { 0xE7, 0x06, 0xFF }, |
| 584 | #endif |
| 585 | { 0xE9, 0x21, 0xFF }, |
| 586 | { 0x01, 0x0C, 0x1F }, |
| 587 | { 0x01, 0x08, 0x1F }, |
| 588 | }; |
| 589 | |
| 590 | const struct bahama_config_register v20_bt_on_fm_off[] = { |
| 591 | { 0x11, 0x0C, 0xFF }, |
| 592 | { 0x13, 0x01, 0xFF }, |
| 593 | { 0xF4, 0x80, 0xFF }, |
| 594 | { 0xF0, 0x00, 0xFF }, |
| 595 | { 0xE9, 0x00, 0xFF }, |
| 596 | #ifdef CONFIG_WLAN |
| 597 | { 0x81, 0x00, 0x7F }, |
| 598 | { 0x82, 0x00, 0xFF }, |
| 599 | { 0xE6, 0x38, 0x7F }, |
| 600 | { 0xE7, 0x06, 0xFF }, |
| 601 | #endif |
| 602 | { 0x8E, 0x15, 0xFF }, |
| 603 | { 0x8F, 0x15, 0xFF }, |
| 604 | { 0x90, 0x15, 0xFF }, |
| 605 | |
| 606 | { 0xE9, 0x21, 0xFF }, |
| 607 | }; |
| 608 | |
| 609 | const struct bahama_config_register v20_bt_on_fm_on[] = { |
| 610 | { 0x11, 0x0C, 0xFF }, |
| 611 | { 0x13, 0x01, 0xFF }, |
| 612 | { 0xF4, 0x86, 0xFF }, |
| 613 | { 0xF0, 0x06, 0xFF }, |
| 614 | { 0xE9, 0x00, 0xFF }, |
| 615 | #ifdef CONFIG_WLAN |
| 616 | { 0x81, 0x00, 0x7F }, |
| 617 | { 0x82, 0x00, 0xFF }, |
| 618 | { 0xE6, 0x38, 0x7F }, |
| 619 | { 0xE7, 0x06, 0xFF }, |
| 620 | #endif |
| 621 | { 0xE9, 0x21, 0xFF }, |
| 622 | }; |
| 623 | |
| 624 | const struct bahama_config_register v10_bt_off[] = { |
| 625 | { 0xE9, 0x00, 0xFF }, |
| 626 | }; |
| 627 | |
| 628 | const struct bahama_config_register v20_bt_off_fm_off[] = { |
| 629 | { 0xF4, 0x84, 0xFF }, |
| 630 | { 0xF0, 0x04, 0xFF }, |
| 631 | { 0xE9, 0x00, 0xFF } |
| 632 | }; |
| 633 | |
| 634 | const struct bahama_config_register v20_bt_off_fm_on[] = { |
| 635 | { 0xF4, 0x86, 0xFF }, |
| 636 | { 0xF0, 0x06, 0xFF }, |
| 637 | { 0xE9, 0x00, 0xFF } |
| 638 | }; |
| 639 | const struct bahama_variant_register bt_bahama[2][3] = { |
| 640 | { |
| 641 | { ARRAY_SIZE(v10_bt_off), v10_bt_off }, |
| 642 | { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off }, |
| 643 | { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on } |
| 644 | }, |
| 645 | { |
| 646 | { ARRAY_SIZE(v10_bt_on), v10_bt_on }, |
| 647 | { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off }, |
| 648 | { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on } |
| 649 | } |
| 650 | }; |
| 651 | |
| 652 | u8 offset = 0; /* index into bahama configs */ |
| 653 | on = on ? 1 : 0; |
| 654 | version = marimba_read_bahama_ver(&config); |
Rahul Kashyap | 92497af | 2011-07-07 12:13:52 +0530 | [diff] [blame] | 655 | if ((int)version < 0 || version == BAHAMA_VER_UNSUPPORTED) { |
| 656 | dev_err(&msm_bt_power_device.dev, "%s: Bahama \ |
| 657 | version read Error, version = %d \n", |
| 658 | __func__, version); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 659 | return -EIO; |
| 660 | } |
| 661 | |
| 662 | if (version == BAHAMA_VER_2_0) { |
| 663 | if (marimba_get_fm_status(&config)) |
| 664 | offset = 0x01; |
| 665 | } |
| 666 | |
| 667 | p = bt_bahama[on][version + offset].set; |
| 668 | |
| 669 | dev_info(&msm_bt_power_device.dev, |
| 670 | "%s: found version %d\n", __func__, version); |
| 671 | |
| 672 | for (i = 0; i < bt_bahama[on][version + offset].size; i++) { |
| 673 | u8 value = (p+i)->value; |
| 674 | rc = marimba_write_bit_mask(&config, |
| 675 | (p+i)->reg, |
| 676 | &value, |
| 677 | sizeof((p+i)->value), |
| 678 | (p+i)->mask); |
| 679 | if (rc < 0) { |
| 680 | dev_err(&msm_bt_power_device.dev, |
| 681 | "%s: reg %x write failed: %d\n", |
| 682 | __func__, (p+i)->reg, rc); |
| 683 | return rc; |
| 684 | } |
Rahul Kashyap | 92497af | 2011-07-07 12:13:52 +0530 | [diff] [blame] | 685 | dev_dbg(&msm_bt_power_device.dev, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 686 | "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n", |
| 687 | __func__, (p+i)->reg, |
| 688 | value, (p+i)->mask); |
| 689 | value = 0; |
| 690 | rc = marimba_read_bit_mask(&config, |
| 691 | (p+i)->reg, &value, |
| 692 | sizeof((p+i)->value), (p+i)->mask); |
| 693 | if (rc < 0) |
| 694 | dev_err(&msm_bt_power_device.dev, "%s marimba_read_bit_mask- error", |
| 695 | __func__); |
Rahul Kashyap | 92497af | 2011-07-07 12:13:52 +0530 | [diff] [blame] | 696 | dev_dbg(&msm_bt_power_device.dev, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 697 | "%s: reg 0x%02x read value 0x%02x mask 0x%02x\n", |
| 698 | __func__, (p+i)->reg, |
| 699 | value, (p+i)->mask); |
| 700 | } |
| 701 | /* Update BT Status */ |
| 702 | if (on) |
| 703 | marimba_set_bt_status(&config, true); |
| 704 | else |
| 705 | marimba_set_bt_status(&config, false); |
| 706 | return rc; |
| 707 | } |
| 708 | static int bluetooth_switch_regulators(int on) |
| 709 | { |
| 710 | int i, rc = 0; |
Rahul Kashyap | 6e66946 | 2011-07-23 16:42:56 +0530 | [diff] [blame] | 711 | const char *id = "BTPW"; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 712 | |
Rahul Kashyap | 6e66946 | 2011-07-23 16:42:56 +0530 | [diff] [blame] | 713 | for (i = 0; i < ARRAY_SIZE(bt_vregs); i++) { |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 714 | if (IS_ERR_OR_NULL(bt_vregs[i].reg)) { |
| 715 | rc = bt_vregs[i].reg ? |
| 716 | PTR_ERR(bt_vregs[i].reg) : |
| 717 | -ENODEV; |
| 718 | dev_err(&msm_bt_power_device.dev, |
| 719 | "%s: invalid regulator handle for %s: %d\n", |
| 720 | __func__, bt_vregs[i].name, rc); |
| 721 | goto reg_disable; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 722 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 723 | |
Pankaj Kumar | a9d576c | 2011-09-29 10:56:53 +0530 | [diff] [blame] | 724 | rc = on ? regulator_set_voltage(bt_vregs[i].reg, |
Pankaj Kumar | 6ac59af | 2011-10-12 12:45:40 +0530 | [diff] [blame] | 725 | bt_vregs[i].min_level, |
| 726 | bt_vregs[i].max_level) : 0; |
Pankaj Kumar | a9d576c | 2011-09-29 10:56:53 +0530 | [diff] [blame] | 727 | if (rc) { |
| 728 | dev_err(&msm_bt_power_device.dev, |
| 729 | "%s: could not set voltage for %s: %d\n", |
| 730 | __func__, bt_vregs[i].name, rc); |
| 731 | goto reg_disable; |
| 732 | } |
| 733 | |
| 734 | rc = on ? regulator_enable(bt_vregs[i].reg) : 0; |
| 735 | if (rc) { |
| 736 | dev_err(&msm_bt_power_device.dev, |
| 737 | "%s: could not %sable regulator %s: %d\n", |
| 738 | __func__, "en", bt_vregs[i].name, rc); |
| 739 | goto reg_disable; |
| 740 | } |
| 741 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 742 | if (bt_vregs[i].is_pin_controlled) { |
Pankaj Kumar | a9d576c | 2011-09-29 10:56:53 +0530 | [diff] [blame] | 743 | rc = pmapp_vreg_lpm_pincntrl_vote(id, |
Rahul Kashyap | 6e66946 | 2011-07-23 16:42:56 +0530 | [diff] [blame] | 744 | bt_vregs[i].pmapp_id, |
| 745 | PMAPP_CLOCK_ID_D1, |
| 746 | on ? PMAPP_CLOCK_VOTE_ON : |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 747 | PMAPP_CLOCK_VOTE_OFF); |
Pankaj Kumar | a9d576c | 2011-09-29 10:56:53 +0530 | [diff] [blame] | 748 | if (rc) { |
| 749 | dev_err(&msm_bt_power_device.dev, |
| 750 | "%s: pin control failed for %s: %d\n", |
| 751 | __func__, bt_vregs[i].name, rc); |
| 752 | goto pin_cnt_fail; |
| 753 | } |
Rahul Kashyap | 6e66946 | 2011-07-23 16:42:56 +0530 | [diff] [blame] | 754 | } |
Pankaj Kumar | a9d576c | 2011-09-29 10:56:53 +0530 | [diff] [blame] | 755 | rc = on ? 0 : regulator_disable(bt_vregs[i].reg); |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 756 | |
| 757 | if (rc) { |
| 758 | dev_err(&msm_bt_power_device.dev, |
| 759 | "%s: could not %sable regulator %s: %d\n", |
Pankaj Kumar | a9d576c | 2011-09-29 10:56:53 +0530 | [diff] [blame] | 760 | __func__, "dis", bt_vregs[i].name, rc); |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 761 | goto reg_disable; |
Rahul Kashyap | 6e66946 | 2011-07-23 16:42:56 +0530 | [diff] [blame] | 762 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 763 | } |
Rahul Kashyap | 6e66946 | 2011-07-23 16:42:56 +0530 | [diff] [blame] | 764 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 765 | return rc; |
Pankaj Kumar | a9d576c | 2011-09-29 10:56:53 +0530 | [diff] [blame] | 766 | pin_cnt_fail: |
| 767 | if (on) |
| 768 | regulator_disable(bt_vregs[i].reg); |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 769 | reg_disable: |
Pankaj Kumar | a9d576c | 2011-09-29 10:56:53 +0530 | [diff] [blame] | 770 | while (i) { |
| 771 | if (on) { |
| 772 | i--; |
| 773 | regulator_disable(bt_vregs[i].reg); |
| 774 | regulator_put(bt_vregs[i].reg); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 775 | } |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 776 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 777 | return rc; |
| 778 | } |
| 779 | |
Pankaj Kumar | a9d576c | 2011-09-29 10:56:53 +0530 | [diff] [blame] | 780 | static struct regulator *reg_s3; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 781 | static unsigned int msm_bahama_setup_power(void) |
| 782 | { |
| 783 | int rc = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 784 | |
Pankaj Kumar | a9d576c | 2011-09-29 10:56:53 +0530 | [diff] [blame] | 785 | reg_s3 = regulator_get(NULL, "msme1"); |
| 786 | if (IS_ERR(reg_s3)) { |
| 787 | rc = PTR_ERR(reg_s3); |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 788 | pr_err("%s: could not get regulator: %d\n", __func__, rc); |
| 789 | goto out; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 790 | } |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 791 | |
Pankaj Kumar | a9d576c | 2011-09-29 10:56:53 +0530 | [diff] [blame] | 792 | rc = regulator_set_voltage(reg_s3, 1800000, 1800000); |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 793 | if (rc) { |
| 794 | pr_err("%s: could not set voltage: %d\n", __func__, rc); |
| 795 | goto reg_fail; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 796 | } |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 797 | |
Pankaj Kumar | a9d576c | 2011-09-29 10:56:53 +0530 | [diff] [blame] | 798 | rc = regulator_enable(reg_s3); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 799 | if (rc < 0) { |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 800 | pr_err("%s: could not enable regulator: %d\n", __func__, rc); |
| 801 | goto reg_fail; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 802 | } |
| 803 | |
| 804 | /*setup Bahama_sys_reset_n*/ |
| 805 | rc = gpio_request(GPIO_BT_SYS_REST_EN, "bahama sys_rst_n"); |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 806 | if (rc) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 807 | pr_err("%s: gpio_request %d = %d\n", __func__, |
| 808 | GPIO_BT_SYS_REST_EN, rc); |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 809 | goto reg_disable; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 810 | } |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 811 | |
Rahul Kashyap | 181d555 | 2011-07-07 10:39:23 +0530 | [diff] [blame] | 812 | rc = bt_set_gpio(1); |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 813 | if (rc) { |
Rahul Kashyap | 181d555 | 2011-07-07 10:39:23 +0530 | [diff] [blame] | 814 | pr_err("%s: bt_set_gpio %d = %d\n", __func__, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 815 | GPIO_BT_SYS_REST_EN, rc); |
| 816 | goto gpio_fail; |
| 817 | } |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 818 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 819 | return rc; |
| 820 | |
| 821 | gpio_fail: |
| 822 | gpio_free(GPIO_BT_SYS_REST_EN); |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 823 | reg_disable: |
Pankaj Kumar | a9d576c | 2011-09-29 10:56:53 +0530 | [diff] [blame] | 824 | regulator_disable(reg_s3); |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 825 | reg_fail: |
Pankaj Kumar | a9d576c | 2011-09-29 10:56:53 +0530 | [diff] [blame] | 826 | regulator_put(reg_s3); |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 827 | out: |
Pankaj Kumar | a9d576c | 2011-09-29 10:56:53 +0530 | [diff] [blame] | 828 | reg_s3 = NULL; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 829 | return rc; |
| 830 | } |
| 831 | |
| 832 | static unsigned int msm_bahama_shutdown_power(int value) |
| 833 | { |
| 834 | int rc = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 835 | |
Pankaj Kumar | a9d576c | 2011-09-29 10:56:53 +0530 | [diff] [blame] | 836 | if (IS_ERR_OR_NULL(reg_s3)) { |
| 837 | rc = reg_s3 ? PTR_ERR(reg_s3) : -ENODEV; |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 838 | goto out; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 839 | } |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 840 | |
Pankaj Kumar | a9d576c | 2011-09-29 10:56:53 +0530 | [diff] [blame] | 841 | rc = regulator_disable(reg_s3); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 842 | if (rc) { |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 843 | pr_err("%s: could not disable regulator: %d\n", __func__, rc); |
| 844 | goto out; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 845 | } |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 846 | |
Rahul Kashyap | e8698c6 | 2011-07-20 20:43:05 +0530 | [diff] [blame] | 847 | if (value == BAHAMA_ID) { |
| 848 | rc = bt_set_gpio(0); |
| 849 | if (rc) { |
| 850 | pr_err("%s: bt_set_gpio = %d\n", |
| 851 | __func__, rc); |
| 852 | } |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 853 | gpio_free(GPIO_BT_SYS_REST_EN); |
Rahul Kashyap | 181d555 | 2011-07-07 10:39:23 +0530 | [diff] [blame] | 854 | } |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 855 | |
Pankaj Kumar | a9d576c | 2011-09-29 10:56:53 +0530 | [diff] [blame] | 856 | regulator_put(reg_s3); |
| 857 | reg_s3 = NULL; |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 858 | |
| 859 | return 0; |
| 860 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 861 | out: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 862 | return rc; |
| 863 | } |
| 864 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 865 | static unsigned int msm_bahama_core_config(int type) |
| 866 | { |
| 867 | int rc = 0; |
| 868 | |
| 869 | if (type == BAHAMA_ID) { |
| 870 | int i; |
Rahul Kashyap | 181d555 | 2011-07-07 10:39:23 +0530 | [diff] [blame] | 871 | struct marimba config = { .mod_id = SLAVE_ID_BAHAMA}; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 872 | const struct bahama_config_register v20_init[] = { |
| 873 | /* reg, value, mask */ |
| 874 | { 0xF4, 0x84, 0xFF }, /* AREG */ |
| 875 | { 0xF0, 0x04, 0xFF } /* DREG */ |
| 876 | }; |
| 877 | if (marimba_read_bahama_ver(&config) == BAHAMA_VER_2_0) { |
| 878 | for (i = 0; i < ARRAY_SIZE(v20_init); i++) { |
| 879 | u8 value = v20_init[i].value; |
| 880 | rc = marimba_write_bit_mask(&config, |
| 881 | v20_init[i].reg, |
| 882 | &value, |
| 883 | sizeof(v20_init[i].value), |
| 884 | v20_init[i].mask); |
| 885 | if (rc < 0) { |
| 886 | pr_err("%s: reg %d write failed: %d\n", |
| 887 | __func__, v20_init[i].reg, rc); |
| 888 | return rc; |
| 889 | } |
| 890 | pr_debug("%s: reg 0x%02x value 0x%02x" |
| 891 | " mask 0x%02x\n", |
| 892 | __func__, v20_init[i].reg, |
| 893 | v20_init[i].value, v20_init[i].mask); |
| 894 | } |
| 895 | } |
| 896 | } |
Rahul Kashyap | 181d555 | 2011-07-07 10:39:23 +0530 | [diff] [blame] | 897 | rc = bt_set_gpio(0); |
| 898 | if (rc) { |
| 899 | pr_err("%s: bt_set_gpio = %d\n", |
| 900 | __func__, rc); |
| 901 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 902 | pr_debug("core type: %d\n", type); |
| 903 | return rc; |
| 904 | } |
| 905 | |
| 906 | static int bluetooth_power(int on) |
| 907 | { |
| 908 | int pin, rc = 0; |
| 909 | const char *id = "BTPW"; |
| 910 | int cid = 0; |
| 911 | |
| 912 | cid = adie_get_detected_connectivity_type(); |
| 913 | if (cid != BAHAMA_ID) { |
| 914 | pr_err("%s: unexpected adie connectivity type: %d\n", |
| 915 | __func__, cid); |
| 916 | return -ENODEV; |
| 917 | } |
| 918 | if (on) { |
| 919 | /*setup power for BT SOC*/ |
Rahul Kashyap | 181d555 | 2011-07-07 10:39:23 +0530 | [diff] [blame] | 920 | rc = bt_set_gpio(on); |
| 921 | if (rc) { |
| 922 | pr_err("%s: bt_set_gpio = %d\n", |
| 923 | __func__, rc); |
| 924 | goto exit; |
| 925 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 926 | rc = bluetooth_switch_regulators(on); |
| 927 | if (rc < 0) { |
| 928 | pr_err("%s: bluetooth_switch_regulators rc = %d", |
| 929 | __func__, rc); |
| 930 | goto exit; |
| 931 | } |
| 932 | /*setup BT GPIO lines*/ |
| 933 | for (pin = 0; pin < ARRAY_SIZE(bt_config_power_on); |
| 934 | pin++) { |
| 935 | rc = gpio_tlmm_config(bt_config_power_on[pin], |
| 936 | GPIO_CFG_ENABLE); |
| 937 | if (rc < 0) { |
| 938 | pr_err("%s: gpio_tlmm_config(%#x)=%d\n", |
| 939 | __func__, |
| 940 | bt_config_power_on[pin], |
| 941 | rc); |
| 942 | goto fail_power; |
| 943 | } |
| 944 | } |
| 945 | /*Setup BT clocks*/ |
| 946 | rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1, |
| 947 | PMAPP_CLOCK_VOTE_ON); |
| 948 | if (rc < 0) { |
| 949 | pr_err("Failed to vote for TCXO_D1 ON\n"); |
| 950 | goto fail_clock; |
| 951 | } |
| 952 | msleep(20); |
| 953 | |
| 954 | /*I2C config for Bahama*/ |
| 955 | rc = bahama_bt(1); |
| 956 | if (rc < 0) { |
| 957 | pr_err("%s: bahama_bt rc = %d", __func__, rc); |
| 958 | goto fail_i2c; |
| 959 | } |
| 960 | msleep(20); |
| 961 | |
| 962 | /*setup BT PCM lines*/ |
| 963 | rc = msm_bahama_setup_pcm_i2s(BT_PCM_ON); |
| 964 | if (rc < 0) { |
| 965 | pr_err("%s: msm_bahama_setup_pcm_i2s , rc =%d\n", |
| 966 | __func__, rc); |
| 967 | goto fail_power; |
| 968 | } |
| 969 | rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1, |
| 970 | PMAPP_CLOCK_VOTE_PIN_CTRL); |
| 971 | if (rc < 0) |
| 972 | pr_err("%s:Pin Control Failed, rc = %d", |
| 973 | __func__, rc); |
| 974 | |
| 975 | } else { |
| 976 | rc = bahama_bt(0); |
| 977 | if (rc < 0) |
| 978 | pr_err("%s: bahama_bt rc = %d", __func__, rc); |
Rahul Kashyap | 181d555 | 2011-07-07 10:39:23 +0530 | [diff] [blame] | 979 | |
| 980 | rc = bt_set_gpio(on); |
| 981 | if (rc) { |
| 982 | pr_err("%s: bt_set_gpio = %d\n", |
| 983 | __func__, rc); |
| 984 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 985 | fail_i2c: |
| 986 | rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_D1, |
| 987 | PMAPP_CLOCK_VOTE_OFF); |
| 988 | if (rc < 0) |
| 989 | pr_err("%s: Failed to vote Off D1\n", __func__); |
| 990 | fail_clock: |
| 991 | for (pin = 0; pin < ARRAY_SIZE(bt_config_power_off); |
| 992 | pin++) { |
| 993 | rc = gpio_tlmm_config(bt_config_power_off[pin], |
| 994 | GPIO_CFG_ENABLE); |
| 995 | if (rc < 0) { |
| 996 | pr_err("%s: gpio_tlmm_config(%#x)=%d\n", |
| 997 | __func__, bt_config_power_off[pin], rc); |
| 998 | } |
| 999 | } |
| 1000 | rc = msm_bahama_setup_pcm_i2s(BT_PCM_OFF); |
| 1001 | if (rc < 0) { |
| 1002 | pr_err("%s: msm_bahama_setup_pcm_i2s, rc =%d\n", |
| 1003 | __func__, rc); |
| 1004 | } |
| 1005 | fail_power: |
| 1006 | rc = bluetooth_switch_regulators(0); |
| 1007 | if (rc < 0) { |
| 1008 | pr_err("%s: switch_regulators : rc = %d",\ |
| 1009 | __func__, rc); |
| 1010 | goto exit; |
| 1011 | } |
| 1012 | } |
| 1013 | return rc; |
| 1014 | exit: |
| 1015 | pr_err("%s: failed with rc = %d", __func__, rc); |
| 1016 | return rc; |
| 1017 | } |
| 1018 | |
| 1019 | static int __init bt_power_init(void) |
| 1020 | { |
| 1021 | int i, rc = 0; |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 1022 | struct device *dev = &msm_bt_power_device.dev; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1023 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 1024 | for (i = 0; i < ARRAY_SIZE(bt_vregs); i++) { |
| 1025 | bt_vregs[i].reg = regulator_get(dev, bt_vregs[i].name); |
| 1026 | if (IS_ERR(bt_vregs[i].reg)) { |
| 1027 | rc = PTR_ERR(bt_vregs[i].reg); |
| 1028 | dev_err(dev, "%s: could not get regulator %s: %d\n", |
| 1029 | __func__, bt_vregs[i].name, rc); |
| 1030 | goto reg_get_fail; |
| 1031 | } |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 1032 | } |
| 1033 | |
| 1034 | dev->platform_data = &bluetooth_power; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1035 | |
| 1036 | return rc; |
| 1037 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 1038 | reg_get_fail: |
| 1039 | while (i--) { |
| 1040 | regulator_put(bt_vregs[i].reg); |
| 1041 | bt_vregs[i].reg = NULL; |
| 1042 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1043 | return rc; |
| 1044 | } |
| 1045 | |
| 1046 | static struct marimba_platform_data marimba_pdata = { |
| 1047 | .slave_id[SLAVE_ID_BAHAMA_FM] = BAHAMA_SLAVE_ID_FM_ADDR, |
| 1048 | .slave_id[SLAVE_ID_BAHAMA_QMEMBIST] = BAHAMA_SLAVE_ID_QMEMBIST_ADDR, |
| 1049 | .bahama_setup = msm_bahama_setup_power, |
| 1050 | .bahama_shutdown = msm_bahama_shutdown_power, |
| 1051 | .bahama_core_config = msm_bahama_core_config, |
| 1052 | .fm = &marimba_fm_pdata, |
| 1053 | }; |
| 1054 | |
| 1055 | #endif |
| 1056 | |
| 1057 | #if defined(CONFIG_I2C) && defined(CONFIG_GPIO_SX150X) |
| 1058 | static struct i2c_board_info core_exp_i2c_info[] __initdata = { |
| 1059 | { |
| 1060 | I2C_BOARD_INFO("sx1509q", 0x3e), |
| 1061 | }, |
| 1062 | }; |
| 1063 | static struct i2c_board_info cam_exp_i2c_info[] __initdata = { |
| 1064 | { |
| 1065 | I2C_BOARD_INFO("sx1508q", 0x22), |
| 1066 | .platform_data = &sx150x_data[SX150X_CAM], |
| 1067 | }, |
| 1068 | }; |
| 1069 | #endif |
| 1070 | #if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE) |
| 1071 | static struct i2c_board_info bahama_devices[] = { |
| 1072 | { |
| 1073 | I2C_BOARD_INFO("marimba", 0xc), |
| 1074 | .platform_data = &marimba_pdata, |
| 1075 | }, |
| 1076 | }; |
| 1077 | #endif |
| 1078 | |
| 1079 | #if defined(CONFIG_I2C) && defined(CONFIG_GPIO_SX150X) |
| 1080 | static void __init register_i2c_devices(void) |
| 1081 | { |
| 1082 | |
| 1083 | i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID, |
| 1084 | cam_exp_i2c_info, |
| 1085 | ARRAY_SIZE(cam_exp_i2c_info)); |
| 1086 | |
Trilok Soni | 3d0f6c5 | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 1087 | if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf()) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1088 | sx150x_data[SX150X_CORE].io_open_drain_ena = 0xe0f0; |
| 1089 | |
| 1090 | core_exp_i2c_info[0].platform_data = |
| 1091 | &sx150x_data[SX150X_CORE]; |
| 1092 | |
| 1093 | i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID, |
| 1094 | core_exp_i2c_info, |
| 1095 | ARRAY_SIZE(core_exp_i2c_info)); |
| 1096 | #if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE) |
| 1097 | i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID, |
| 1098 | bahama_devices, |
| 1099 | ARRAY_SIZE(bahama_devices)); |
| 1100 | #endif |
| 1101 | } |
| 1102 | #endif |
| 1103 | |
| 1104 | static struct msm_gpio qup_i2c_gpios_io[] = { |
| 1105 | { GPIO_CFG(60, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 1106 | "qup_scl" }, |
| 1107 | { GPIO_CFG(61, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 1108 | "qup_sda" }, |
| 1109 | { GPIO_CFG(131, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 1110 | "qup_scl" }, |
| 1111 | { GPIO_CFG(132, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 1112 | "qup_sda" }, |
| 1113 | }; |
| 1114 | |
| 1115 | static struct msm_gpio qup_i2c_gpios_hw[] = { |
| 1116 | { GPIO_CFG(60, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 1117 | "qup_scl" }, |
| 1118 | { GPIO_CFG(61, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 1119 | "qup_sda" }, |
| 1120 | { GPIO_CFG(131, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 1121 | "qup_scl" }, |
| 1122 | { GPIO_CFG(132, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 1123 | "qup_sda" }, |
| 1124 | }; |
| 1125 | |
| 1126 | static void gsbi_qup_i2c_gpio_config(int adap_id, int config_type) |
| 1127 | { |
| 1128 | int rc; |
| 1129 | |
| 1130 | if (adap_id < 0 || adap_id > 1) |
| 1131 | return; |
| 1132 | |
| 1133 | /* Each adapter gets 2 lines from the table */ |
| 1134 | if (config_type) |
| 1135 | rc = msm_gpios_request_enable(&qup_i2c_gpios_hw[adap_id*2], 2); |
| 1136 | else |
| 1137 | rc = msm_gpios_request_enable(&qup_i2c_gpios_io[adap_id*2], 2); |
| 1138 | if (rc < 0) |
| 1139 | pr_err("QUP GPIO request/enable failed: %d\n", rc); |
| 1140 | } |
| 1141 | |
| 1142 | static struct msm_i2c_platform_data msm_gsbi0_qup_i2c_pdata = { |
| 1143 | .clk_freq = 100000, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1144 | .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config, |
| 1145 | }; |
| 1146 | |
| 1147 | static struct msm_i2c_platform_data msm_gsbi1_qup_i2c_pdata = { |
| 1148 | .clk_freq = 100000, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1149 | .msm_i2c_config_gpio = gsbi_qup_i2c_gpio_config, |
| 1150 | }; |
| 1151 | |
| 1152 | #ifdef CONFIG_ARCH_MSM7X27A |
Neti Ravi Kumar | 061726e | 2011-12-08 15:14:57 +0530 | [diff] [blame^] | 1153 | #define MSM_PMEM_MDP_SIZE 0x2300000 |
| 1154 | #define MSM7x25A_MSM_PMEM_MDP_SIZE 0x1500000 |
Jeevan Shriram | f40764e | 2011-10-31 23:28:26 +0530 | [diff] [blame] | 1155 | |
Roja Rani Yarubandi | 0998656 | 2011-12-06 18:54:47 +0530 | [diff] [blame] | 1156 | #define MSM_PMEM_ADSP_SIZE 0x1000000 |
Jeevan Shriram | f40764e | 2011-10-31 23:28:26 +0530 | [diff] [blame] | 1157 | #define MSM7x25A_MSM_PMEM_ADSP_SIZE 0xB91000 |
| 1158 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1159 | |
| 1160 | #ifdef CONFIG_FB_MSM_TRIPLE_BUFFER |
Jeevan Shriram | f40764e | 2011-10-31 23:28:26 +0530 | [diff] [blame] | 1161 | #define MSM_FB_SIZE 0x260000 |
| 1162 | #define MSM7x25A_MSM_FB_SIZE 0xE1000 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1163 | #else |
Jeevan Shriram | f40764e | 2011-10-31 23:28:26 +0530 | [diff] [blame] | 1164 | #define MSM_FB_SIZE 0x195000 |
| 1165 | #define MSM7x25A_MSM_FB_SIZE 0xE1000 |
| 1166 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1167 | #endif |
| 1168 | |
| 1169 | #endif |
| 1170 | |
| 1171 | static struct android_usb_platform_data android_usb_pdata = { |
| 1172 | .update_pid_and_serial_num = usb_diag_update_pid_and_serial_num, |
| 1173 | }; |
| 1174 | |
| 1175 | static struct platform_device android_usb_device = { |
| 1176 | .name = "android_usb", |
| 1177 | .id = -1, |
| 1178 | .dev = { |
| 1179 | .platform_data = &android_usb_pdata, |
| 1180 | }, |
| 1181 | }; |
| 1182 | |
| 1183 | #ifdef CONFIG_USB_EHCI_MSM_72K |
| 1184 | static void msm_hsusb_vbus_power(unsigned phy_info, int on) |
| 1185 | { |
| 1186 | int rc = 0; |
| 1187 | unsigned gpio; |
| 1188 | |
| 1189 | gpio = GPIO_HOST_VBUS_EN; |
| 1190 | |
| 1191 | rc = gpio_request(gpio, "i2c_host_vbus_en"); |
| 1192 | if (rc < 0) { |
| 1193 | pr_err("failed to request %d GPIO\n", gpio); |
| 1194 | return; |
| 1195 | } |
| 1196 | gpio_direction_output(gpio, !!on); |
| 1197 | gpio_set_value_cansleep(gpio, !!on); |
| 1198 | gpio_free(gpio); |
| 1199 | } |
| 1200 | |
| 1201 | static struct msm_usb_host_platform_data msm_usb_host_pdata = { |
| 1202 | .phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM), |
| 1203 | }; |
| 1204 | |
| 1205 | static void __init msm7x2x_init_host(void) |
| 1206 | { |
| 1207 | msm_add_host(0, &msm_usb_host_pdata); |
| 1208 | } |
| 1209 | #endif |
| 1210 | |
| 1211 | #ifdef CONFIG_USB_MSM_OTG_72K |
| 1212 | static int hsusb_rpc_connect(int connect) |
| 1213 | { |
| 1214 | if (connect) |
| 1215 | return msm_hsusb_rpc_connect(); |
| 1216 | else |
| 1217 | return msm_hsusb_rpc_close(); |
| 1218 | } |
| 1219 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 1220 | static struct regulator *reg_hsusb; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1221 | static int msm_hsusb_ldo_init(int init) |
| 1222 | { |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 1223 | int rc = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1224 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 1225 | if (init) { |
| 1226 | reg_hsusb = regulator_get(NULL, "usb"); |
| 1227 | if (IS_ERR(reg_hsusb)) { |
| 1228 | rc = PTR_ERR(reg_hsusb); |
| 1229 | pr_err("%s: could not get regulator: %d\n", |
| 1230 | __func__, rc); |
| 1231 | goto out; |
| 1232 | } |
| 1233 | |
| 1234 | rc = regulator_set_voltage(reg_hsusb, 3300000, 3300000); |
| 1235 | if (rc) { |
| 1236 | pr_err("%s: could not set voltage: %d\n", |
| 1237 | __func__, rc); |
| 1238 | goto reg_free; |
| 1239 | } |
| 1240 | |
| 1241 | return 0; |
| 1242 | } |
| 1243 | /* else fall through */ |
| 1244 | reg_free: |
| 1245 | regulator_put(reg_hsusb); |
| 1246 | out: |
| 1247 | reg_hsusb = NULL; |
| 1248 | return rc; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1249 | } |
| 1250 | |
| 1251 | static int msm_hsusb_ldo_enable(int enable) |
| 1252 | { |
| 1253 | static int ldo_status; |
| 1254 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 1255 | if (IS_ERR_OR_NULL(reg_hsusb)) |
| 1256 | return reg_hsusb ? PTR_ERR(reg_hsusb) : -ENODEV; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1257 | |
| 1258 | if (ldo_status == enable) |
| 1259 | return 0; |
| 1260 | |
| 1261 | ldo_status = enable; |
| 1262 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 1263 | return enable ? |
| 1264 | regulator_enable(reg_hsusb) : |
| 1265 | regulator_disable(reg_hsusb); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1266 | } |
| 1267 | |
| 1268 | #ifndef CONFIG_USB_EHCI_MSM_72K |
| 1269 | static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init) |
| 1270 | { |
| 1271 | int ret = 0; |
| 1272 | |
| 1273 | if (init) |
| 1274 | ret = msm_pm_app_rpc_init(callback); |
| 1275 | else |
| 1276 | msm_pm_app_rpc_deinit(callback); |
| 1277 | |
| 1278 | return ret; |
| 1279 | } |
| 1280 | #endif |
| 1281 | |
| 1282 | static struct msm_otg_platform_data msm_otg_pdata = { |
| 1283 | #ifndef CONFIG_USB_EHCI_MSM_72K |
| 1284 | .pmic_vbus_notif_init = msm_hsusb_pmic_notif_init, |
| 1285 | #else |
| 1286 | .vbus_power = msm_hsusb_vbus_power, |
| 1287 | #endif |
| 1288 | .rpc_connect = hsusb_rpc_connect, |
| 1289 | .core_clk = 1, |
| 1290 | .pemp_level = PRE_EMPHASIS_WITH_20_PERCENT, |
| 1291 | .cdr_autoreset = CDR_AUTO_RESET_DISABLE, |
| 1292 | .drv_ampl = HS_DRV_AMPLITUDE_DEFAULT, |
| 1293 | .se1_gating = SE1_GATING_DISABLE, |
| 1294 | .ldo_init = msm_hsusb_ldo_init, |
| 1295 | .ldo_enable = msm_hsusb_ldo_enable, |
| 1296 | .chg_init = hsusb_chg_init, |
| 1297 | .chg_connected = hsusb_chg_connected, |
| 1298 | .chg_vbus_draw = hsusb_chg_vbus_draw, |
| 1299 | }; |
| 1300 | #endif |
| 1301 | |
| 1302 | static struct msm_hsusb_gadget_platform_data msm_gadget_pdata = { |
| 1303 | .is_phy_status_timer_on = 1, |
| 1304 | }; |
| 1305 | |
| 1306 | static struct resource smc91x_resources[] = { |
| 1307 | [0] = { |
| 1308 | .start = 0x90000300, |
| 1309 | .end = 0x900003ff, |
| 1310 | .flags = IORESOURCE_MEM, |
| 1311 | }, |
| 1312 | [1] = { |
| 1313 | .start = MSM_GPIO_TO_INT(4), |
| 1314 | .end = MSM_GPIO_TO_INT(4), |
| 1315 | .flags = IORESOURCE_IRQ, |
| 1316 | }, |
| 1317 | }; |
| 1318 | |
| 1319 | static struct platform_device smc91x_device = { |
| 1320 | .name = "smc91x", |
| 1321 | .id = 0, |
| 1322 | .num_resources = ARRAY_SIZE(smc91x_resources), |
| 1323 | .resource = smc91x_resources, |
| 1324 | }; |
| 1325 | |
| 1326 | #if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\ |
| 1327 | || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\ |
| 1328 | || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\ |
| 1329 | || defined(CONFIG_MMC_MSM_SDC4_SUPPORT)) |
| 1330 | |
| 1331 | static unsigned long vreg_sts, gpio_sts; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1332 | |
| 1333 | struct sdcc_gpio { |
| 1334 | struct msm_gpio *cfg_data; |
| 1335 | uint32_t size; |
| 1336 | struct msm_gpio *sleep_cfg_data; |
| 1337 | }; |
| 1338 | |
Sujith Reddy Thumma | 70391a3 | 2011-08-01 10:33:21 +0530 | [diff] [blame] | 1339 | /** |
| 1340 | * Due to insufficient drive strengths for SDC GPIO lines some old versioned |
| 1341 | * SD/MMC cards may cause data CRC errors. Hence, set optimal values |
| 1342 | * for SDC slots based on timing closure and marginality. SDC1 slot |
| 1343 | * require higher value since it should handle bad signal quality due |
| 1344 | * to size of T-flash adapters. |
| 1345 | */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1346 | static struct msm_gpio sdc1_cfg_data[] = { |
Sujith Reddy Thumma | 70391a3 | 2011-08-01 10:33:21 +0530 | [diff] [blame] | 1347 | {GPIO_CFG(51, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_14MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1348 | "sdc1_dat_3"}, |
Sujith Reddy Thumma | 70391a3 | 2011-08-01 10:33:21 +0530 | [diff] [blame] | 1349 | {GPIO_CFG(52, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_14MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1350 | "sdc1_dat_2"}, |
Sujith Reddy Thumma | 70391a3 | 2011-08-01 10:33:21 +0530 | [diff] [blame] | 1351 | {GPIO_CFG(53, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_14MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1352 | "sdc1_dat_1"}, |
Sujith Reddy Thumma | 70391a3 | 2011-08-01 10:33:21 +0530 | [diff] [blame] | 1353 | {GPIO_CFG(54, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_14MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1354 | "sdc1_dat_0"}, |
Sujith Reddy Thumma | 70391a3 | 2011-08-01 10:33:21 +0530 | [diff] [blame] | 1355 | {GPIO_CFG(55, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_14MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1356 | "sdc1_cmd"}, |
Sujith Reddy Thumma | 70391a3 | 2011-08-01 10:33:21 +0530 | [diff] [blame] | 1357 | {GPIO_CFG(56, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_14MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1358 | "sdc1_clk"}, |
| 1359 | }; |
| 1360 | |
| 1361 | static struct msm_gpio sdc2_cfg_data[] = { |
| 1362 | {GPIO_CFG(62, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 1363 | "sdc2_clk"}, |
Sujith Reddy Thumma | 70391a3 | 2011-08-01 10:33:21 +0530 | [diff] [blame] | 1364 | {GPIO_CFG(63, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1365 | "sdc2_cmd"}, |
Sujith Reddy Thumma | 70391a3 | 2011-08-01 10:33:21 +0530 | [diff] [blame] | 1366 | {GPIO_CFG(64, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1367 | "sdc2_dat_3"}, |
Sujith Reddy Thumma | 70391a3 | 2011-08-01 10:33:21 +0530 | [diff] [blame] | 1368 | {GPIO_CFG(65, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1369 | "sdc2_dat_2"}, |
Sujith Reddy Thumma | 70391a3 | 2011-08-01 10:33:21 +0530 | [diff] [blame] | 1370 | {GPIO_CFG(66, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1371 | "sdc2_dat_1"}, |
Sujith Reddy Thumma | 70391a3 | 2011-08-01 10:33:21 +0530 | [diff] [blame] | 1372 | {GPIO_CFG(67, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1373 | "sdc2_dat_0"}, |
| 1374 | }; |
| 1375 | |
| 1376 | static struct msm_gpio sdc2_sleep_cfg_data[] = { |
Sujith Reddy Thumma | f353567 | 2011-08-22 08:53:44 +0530 | [diff] [blame] | 1377 | {GPIO_CFG(62, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1378 | "sdc2_clk"}, |
Sujith Reddy Thumma | f353567 | 2011-08-22 08:53:44 +0530 | [diff] [blame] | 1379 | {GPIO_CFG(63, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1380 | "sdc2_cmd"}, |
Sujith Reddy Thumma | f353567 | 2011-08-22 08:53:44 +0530 | [diff] [blame] | 1381 | {GPIO_CFG(64, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1382 | "sdc2_dat_3"}, |
Sujith Reddy Thumma | f353567 | 2011-08-22 08:53:44 +0530 | [diff] [blame] | 1383 | {GPIO_CFG(65, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1384 | "sdc2_dat_2"}, |
Sujith Reddy Thumma | f353567 | 2011-08-22 08:53:44 +0530 | [diff] [blame] | 1385 | {GPIO_CFG(66, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1386 | "sdc2_dat_1"}, |
Sujith Reddy Thumma | f353567 | 2011-08-22 08:53:44 +0530 | [diff] [blame] | 1387 | {GPIO_CFG(67, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1388 | "sdc2_dat_0"}, |
| 1389 | }; |
| 1390 | static struct msm_gpio sdc3_cfg_data[] = { |
| 1391 | {GPIO_CFG(88, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 1392 | "sdc3_clk"}, |
Sujith Reddy Thumma | 70391a3 | 2011-08-01 10:33:21 +0530 | [diff] [blame] | 1393 | {GPIO_CFG(89, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1394 | "sdc3_cmd"}, |
Sujith Reddy Thumma | 70391a3 | 2011-08-01 10:33:21 +0530 | [diff] [blame] | 1395 | {GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1396 | "sdc3_dat_3"}, |
Sujith Reddy Thumma | 70391a3 | 2011-08-01 10:33:21 +0530 | [diff] [blame] | 1397 | {GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1398 | "sdc3_dat_2"}, |
Sujith Reddy Thumma | 70391a3 | 2011-08-01 10:33:21 +0530 | [diff] [blame] | 1399 | {GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1400 | "sdc3_dat_1"}, |
Sujith Reddy Thumma | 70391a3 | 2011-08-01 10:33:21 +0530 | [diff] [blame] | 1401 | {GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1402 | "sdc3_dat_0"}, |
| 1403 | #ifdef CONFIG_MMC_MSM_SDC3_8_BIT_SUPPORT |
Sujith Reddy Thumma | 70391a3 | 2011-08-01 10:33:21 +0530 | [diff] [blame] | 1404 | {GPIO_CFG(19, 3, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1405 | "sdc3_dat_7"}, |
Sujith Reddy Thumma | 70391a3 | 2011-08-01 10:33:21 +0530 | [diff] [blame] | 1406 | {GPIO_CFG(20, 3, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1407 | "sdc3_dat_6"}, |
Sujith Reddy Thumma | 70391a3 | 2011-08-01 10:33:21 +0530 | [diff] [blame] | 1408 | {GPIO_CFG(21, 3, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1409 | "sdc3_dat_5"}, |
Sujith Reddy Thumma | 70391a3 | 2011-08-01 10:33:21 +0530 | [diff] [blame] | 1410 | {GPIO_CFG(108, 3, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1411 | "sdc3_dat_4"}, |
| 1412 | #endif |
| 1413 | }; |
| 1414 | |
| 1415 | static struct msm_gpio sdc4_cfg_data[] = { |
Sujith Reddy Thumma | 70391a3 | 2011-08-01 10:33:21 +0530 | [diff] [blame] | 1416 | {GPIO_CFG(19, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1417 | "sdc4_dat_3"}, |
Sujith Reddy Thumma | 70391a3 | 2011-08-01 10:33:21 +0530 | [diff] [blame] | 1418 | {GPIO_CFG(20, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1419 | "sdc4_dat_2"}, |
Sujith Reddy Thumma | 70391a3 | 2011-08-01 10:33:21 +0530 | [diff] [blame] | 1420 | {GPIO_CFG(21, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1421 | "sdc4_dat_1"}, |
Sujith Reddy Thumma | 70391a3 | 2011-08-01 10:33:21 +0530 | [diff] [blame] | 1422 | {GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1423 | "sdc4_cmd"}, |
Sujith Reddy Thumma | 70391a3 | 2011-08-01 10:33:21 +0530 | [diff] [blame] | 1424 | {GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_10MA), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1425 | "sdc4_dat_0"}, |
| 1426 | {GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), |
| 1427 | "sdc4_clk"}, |
| 1428 | }; |
| 1429 | |
| 1430 | static struct sdcc_gpio sdcc_cfg_data[] = { |
| 1431 | { |
| 1432 | .cfg_data = sdc1_cfg_data, |
| 1433 | .size = ARRAY_SIZE(sdc1_cfg_data), |
| 1434 | }, |
| 1435 | { |
| 1436 | .cfg_data = sdc2_cfg_data, |
| 1437 | .size = ARRAY_SIZE(sdc2_cfg_data), |
| 1438 | .sleep_cfg_data = sdc2_sleep_cfg_data, |
| 1439 | }, |
| 1440 | { |
| 1441 | .cfg_data = sdc3_cfg_data, |
| 1442 | .size = ARRAY_SIZE(sdc3_cfg_data), |
| 1443 | }, |
| 1444 | { |
| 1445 | .cfg_data = sdc4_cfg_data, |
| 1446 | .size = ARRAY_SIZE(sdc4_cfg_data), |
| 1447 | }, |
| 1448 | }; |
| 1449 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 1450 | static struct regulator *sdcc_vreg_data[ARRAY_SIZE(sdcc_cfg_data)]; |
| 1451 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1452 | static int msm_sdcc_setup_gpio(int dev_id, unsigned int enable) |
| 1453 | { |
| 1454 | int rc = 0; |
| 1455 | struct sdcc_gpio *curr; |
| 1456 | |
| 1457 | curr = &sdcc_cfg_data[dev_id - 1]; |
| 1458 | if (!(test_bit(dev_id, &gpio_sts)^enable)) |
| 1459 | return rc; |
| 1460 | |
| 1461 | if (enable) { |
| 1462 | set_bit(dev_id, &gpio_sts); |
| 1463 | rc = msm_gpios_request_enable(curr->cfg_data, curr->size); |
| 1464 | if (rc) |
| 1465 | pr_err("%s: Failed to turn on GPIOs for slot %d\n", |
| 1466 | __func__, dev_id); |
| 1467 | } else { |
| 1468 | clear_bit(dev_id, &gpio_sts); |
| 1469 | if (curr->sleep_cfg_data) { |
| 1470 | rc = msm_gpios_enable(curr->sleep_cfg_data, curr->size); |
| 1471 | msm_gpios_free(curr->sleep_cfg_data, curr->size); |
| 1472 | return rc; |
| 1473 | } |
| 1474 | msm_gpios_disable_free(curr->cfg_data, curr->size); |
| 1475 | } |
| 1476 | return rc; |
| 1477 | } |
| 1478 | |
| 1479 | static int msm_sdcc_setup_vreg(int dev_id, unsigned int enable) |
| 1480 | { |
| 1481 | int rc = 0; |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 1482 | struct regulator *curr = sdcc_vreg_data[dev_id - 1]; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1483 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 1484 | if (test_bit(dev_id, &vreg_sts) == enable) |
| 1485 | return 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1486 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 1487 | if (!curr) |
| 1488 | return -ENODEV; |
| 1489 | |
| 1490 | if (IS_ERR(curr)) |
| 1491 | return PTR_ERR(curr); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1492 | |
| 1493 | if (enable) { |
| 1494 | set_bit(dev_id, &vreg_sts); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1495 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 1496 | rc = regulator_enable(curr); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1497 | if (rc) |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 1498 | pr_err("%s: could not enable regulator: %d\n", |
| 1499 | __func__, rc); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1500 | } else { |
| 1501 | clear_bit(dev_id, &vreg_sts); |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 1502 | |
| 1503 | rc = regulator_disable(curr); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1504 | if (rc) |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 1505 | pr_err("%s: could not disable regulator: %d\n", |
| 1506 | __func__, rc); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1507 | } |
| 1508 | return rc; |
| 1509 | } |
| 1510 | |
| 1511 | static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd) |
| 1512 | { |
| 1513 | int rc = 0; |
| 1514 | struct platform_device *pdev; |
| 1515 | |
| 1516 | pdev = container_of(dv, struct platform_device, dev); |
| 1517 | |
| 1518 | rc = msm_sdcc_setup_gpio(pdev->id, !!vdd); |
| 1519 | if (rc) |
| 1520 | goto out; |
| 1521 | |
| 1522 | rc = msm_sdcc_setup_vreg(pdev->id, !!vdd); |
| 1523 | out: |
| 1524 | return rc; |
| 1525 | } |
| 1526 | |
| 1527 | #define GPIO_SDC1_HW_DET 85 |
| 1528 | |
| 1529 | #if defined(CONFIG_MMC_MSM_SDC1_SUPPORT) \ |
| 1530 | && defined(CONFIG_MMC_MSM_CARD_HW_DETECTION) |
| 1531 | static unsigned int msm7x2xa_sdcc_slot_status(struct device *dev) |
| 1532 | { |
| 1533 | int status; |
| 1534 | |
| 1535 | status = gpio_tlmm_config(GPIO_CFG(GPIO_SDC1_HW_DET, 2, GPIO_CFG_INPUT, |
| 1536 | GPIO_CFG_PULL_UP, GPIO_CFG_8MA), GPIO_CFG_ENABLE); |
| 1537 | if (status) |
| 1538 | pr_err("%s:Failed to configure tlmm for GPIO %d\n", __func__, |
| 1539 | GPIO_SDC1_HW_DET); |
| 1540 | |
| 1541 | status = gpio_request(GPIO_SDC1_HW_DET, "SD_HW_Detect"); |
| 1542 | if (status) { |
| 1543 | pr_err("%s:Failed to request GPIO %d\n", __func__, |
| 1544 | GPIO_SDC1_HW_DET); |
| 1545 | } else { |
| 1546 | status = gpio_direction_input(GPIO_SDC1_HW_DET); |
| 1547 | if (!status) |
| 1548 | status = gpio_get_value(GPIO_SDC1_HW_DET); |
| 1549 | gpio_free(GPIO_SDC1_HW_DET); |
| 1550 | } |
| 1551 | return status; |
| 1552 | } |
| 1553 | #endif |
| 1554 | |
| 1555 | #ifdef CONFIG_MMC_MSM_SDC1_SUPPORT |
| 1556 | static struct mmc_platform_data sdc1_plat_data = { |
| 1557 | .ocr_mask = MMC_VDD_28_29, |
| 1558 | .translate_vdd = msm_sdcc_setup_power, |
| 1559 | .mmc_bus_width = MMC_CAP_4_BIT_DATA, |
| 1560 | .msmsdcc_fmin = 144000, |
| 1561 | .msmsdcc_fmid = 24576000, |
| 1562 | .msmsdcc_fmax = 49152000, |
| 1563 | #ifdef CONFIG_MMC_MSM_CARD_HW_DETECTION |
| 1564 | .status = msm7x2xa_sdcc_slot_status, |
| 1565 | .status_irq = MSM_GPIO_TO_INT(GPIO_SDC1_HW_DET), |
| 1566 | .irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
| 1567 | #endif |
| 1568 | }; |
| 1569 | #endif |
| 1570 | |
| 1571 | #ifdef CONFIG_MMC_MSM_SDC2_SUPPORT |
| 1572 | static struct mmc_platform_data sdc2_plat_data = { |
| 1573 | /* |
| 1574 | * SDC2 supports only 1.8V, claim for 2.85V range is just |
| 1575 | * for allowing buggy cards who advertise 2.8V even though |
| 1576 | * they can operate at 1.8V supply. |
| 1577 | */ |
| 1578 | .ocr_mask = MMC_VDD_28_29 | MMC_VDD_165_195, |
| 1579 | .translate_vdd = msm_sdcc_setup_power, |
| 1580 | .mmc_bus_width = MMC_CAP_4_BIT_DATA, |
| 1581 | #ifdef CONFIG_MMC_MSM_SDIO_SUPPORT |
| 1582 | .sdiowakeup_irq = MSM_GPIO_TO_INT(66), |
| 1583 | #endif |
| 1584 | .msmsdcc_fmin = 144000, |
| 1585 | .msmsdcc_fmid = 24576000, |
| 1586 | .msmsdcc_fmax = 49152000, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1587 | }; |
| 1588 | #endif |
| 1589 | |
| 1590 | #ifdef CONFIG_MMC_MSM_SDC3_SUPPORT |
| 1591 | static struct mmc_platform_data sdc3_plat_data = { |
| 1592 | .ocr_mask = MMC_VDD_28_29, |
| 1593 | .translate_vdd = msm_sdcc_setup_power, |
| 1594 | #ifdef CONFIG_MMC_MSM_SDC3_8_BIT_SUPPORT |
| 1595 | .mmc_bus_width = MMC_CAP_8_BIT_DATA, |
| 1596 | #else |
| 1597 | .mmc_bus_width = MMC_CAP_4_BIT_DATA, |
| 1598 | #endif |
| 1599 | .msmsdcc_fmin = 144000, |
| 1600 | .msmsdcc_fmid = 24576000, |
| 1601 | .msmsdcc_fmax = 49152000, |
| 1602 | .nonremovable = 1, |
| 1603 | }; |
| 1604 | #endif |
| 1605 | |
| 1606 | #if (defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\ |
| 1607 | && !defined(CONFIG_MMC_MSM_SDC3_8_BIT_SUPPORT)) |
| 1608 | static struct mmc_platform_data sdc4_plat_data = { |
| 1609 | .ocr_mask = MMC_VDD_28_29, |
| 1610 | .translate_vdd = msm_sdcc_setup_power, |
| 1611 | .mmc_bus_width = MMC_CAP_4_BIT_DATA, |
| 1612 | .msmsdcc_fmin = 144000, |
| 1613 | .msmsdcc_fmid = 24576000, |
| 1614 | .msmsdcc_fmax = 49152000, |
| 1615 | }; |
| 1616 | #endif |
Pankaj Kumar | b3e55c6 | 2011-09-26 11:59:39 +0530 | [diff] [blame] | 1617 | |
| 1618 | static int __init mmc_regulator_init(int sdcc_no, const char *supply, int uV) |
| 1619 | { |
| 1620 | int rc; |
| 1621 | |
| 1622 | BUG_ON(sdcc_no < 1 || sdcc_no > 4); |
| 1623 | |
| 1624 | sdcc_no--; |
| 1625 | |
| 1626 | sdcc_vreg_data[sdcc_no] = regulator_get(NULL, supply); |
| 1627 | |
| 1628 | if (IS_ERR(sdcc_vreg_data[sdcc_no])) { |
| 1629 | rc = PTR_ERR(sdcc_vreg_data[sdcc_no]); |
| 1630 | pr_err("%s: could not get regulator \"%s\": %d\n", |
| 1631 | __func__, supply, rc); |
| 1632 | goto out; |
| 1633 | } |
| 1634 | |
| 1635 | rc = regulator_set_voltage(sdcc_vreg_data[sdcc_no], uV, uV); |
| 1636 | |
| 1637 | if (rc) { |
| 1638 | pr_err("%s: could not set voltage for \"%s\" to %d uV: %d\n", |
| 1639 | __func__, supply, uV, rc); |
| 1640 | goto reg_free; |
| 1641 | } |
| 1642 | |
| 1643 | return rc; |
| 1644 | |
| 1645 | reg_free: |
| 1646 | regulator_put(sdcc_vreg_data[sdcc_no]); |
| 1647 | out: |
| 1648 | sdcc_vreg_data[sdcc_no] = NULL; |
| 1649 | return rc; |
| 1650 | } |
| 1651 | |
| 1652 | static void __init msm7x27a_init_mmc(void) |
| 1653 | { |
| 1654 | /* eMMC slot */ |
| 1655 | #ifdef CONFIG_MMC_MSM_SDC3_SUPPORT |
| 1656 | if (mmc_regulator_init(3, "emmc", 3000000)) |
| 1657 | return; |
| 1658 | msm_add_sdcc(3, &sdc3_plat_data); |
| 1659 | #endif |
| 1660 | /* Micro-SD slot */ |
| 1661 | #ifdef CONFIG_MMC_MSM_SDC1_SUPPORT |
| 1662 | if (mmc_regulator_init(1, "mmc", 2850000)) |
| 1663 | return; |
| 1664 | msm_add_sdcc(1, &sdc1_plat_data); |
| 1665 | #endif |
| 1666 | /* SDIO WLAN slot */ |
| 1667 | #ifdef CONFIG_MMC_MSM_SDC2_SUPPORT |
| 1668 | if (mmc_regulator_init(2, "mmc", 2850000)) |
| 1669 | return; |
| 1670 | msm_add_sdcc(2, &sdc2_plat_data); |
| 1671 | #endif |
| 1672 | /* Not Used */ |
| 1673 | #if (defined(CONFIG_MMC_MSM_SDC4_SUPPORT)\ |
| 1674 | && !defined(CONFIG_MMC_MSM_SDC3_8_BIT_SUPPORT)) |
| 1675 | if (mmc_regulator_init(4, "mmc", 2850000)) |
| 1676 | return; |
| 1677 | msm_add_sdcc(4, &sdc4_plat_data); |
| 1678 | #endif |
| 1679 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1680 | #endif |
| 1681 | |
| 1682 | #ifdef CONFIG_SERIAL_MSM_HS |
| 1683 | static struct msm_serial_hs_platform_data msm_uart_dm1_pdata = { |
| 1684 | .inject_rx_on_wakeup = 1, |
| 1685 | .rx_to_inject = 0xFD, |
| 1686 | }; |
| 1687 | #endif |
| 1688 | static struct msm_pm_platform_data msm7x27a_pm_data[MSM_PM_SLEEP_MODE_NR] = { |
| 1689 | [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = { |
| 1690 | .idle_supported = 1, |
| 1691 | .suspend_supported = 1, |
| 1692 | .idle_enabled = 1, |
| 1693 | .suspend_enabled = 1, |
| 1694 | .latency = 16000, |
| 1695 | .residency = 20000, |
| 1696 | }, |
| 1697 | [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN] = { |
| 1698 | .idle_supported = 1, |
| 1699 | .suspend_supported = 1, |
| 1700 | .idle_enabled = 1, |
| 1701 | .suspend_enabled = 1, |
| 1702 | .latency = 12000, |
| 1703 | .residency = 20000, |
| 1704 | }, |
| 1705 | [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT] = { |
| 1706 | .idle_supported = 1, |
| 1707 | .suspend_supported = 1, |
| 1708 | .idle_enabled = 0, |
| 1709 | .suspend_enabled = 1, |
| 1710 | .latency = 2000, |
| 1711 | .residency = 0, |
| 1712 | }, |
| 1713 | [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT] = { |
| 1714 | .idle_supported = 1, |
| 1715 | .suspend_supported = 1, |
| 1716 | .idle_enabled = 1, |
| 1717 | .suspend_enabled = 1, |
| 1718 | .latency = 2, |
| 1719 | .residency = 0, |
| 1720 | }, |
| 1721 | }; |
| 1722 | |
| 1723 | static struct android_pmem_platform_data android_pmem_adsp_pdata = { |
| 1724 | .name = "pmem_adsp", |
| 1725 | .allocator_type = PMEM_ALLOCATORTYPE_BITMAP, |
Mahesh Lanka | c6af7eb | 2011-08-02 18:00:35 +0530 | [diff] [blame] | 1726 | .cached = 1, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1727 | .memory_type = MEMTYPE_EBI1, |
| 1728 | }; |
| 1729 | |
| 1730 | static struct platform_device android_pmem_adsp_device = { |
| 1731 | .name = "android_pmem", |
| 1732 | .id = 1, |
| 1733 | .dev = { .platform_data = &android_pmem_adsp_pdata }, |
| 1734 | }; |
| 1735 | |
| 1736 | static unsigned pmem_mdp_size = MSM_PMEM_MDP_SIZE; |
| 1737 | static int __init pmem_mdp_size_setup(char *p) |
| 1738 | { |
| 1739 | pmem_mdp_size = memparse(p, NULL); |
| 1740 | return 0; |
| 1741 | } |
| 1742 | |
| 1743 | early_param("pmem_mdp_size", pmem_mdp_size_setup); |
| 1744 | |
| 1745 | static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE; |
| 1746 | static int __init pmem_adsp_size_setup(char *p) |
| 1747 | { |
| 1748 | pmem_adsp_size = memparse(p, NULL); |
| 1749 | return 0; |
| 1750 | } |
| 1751 | |
| 1752 | early_param("pmem_adsp_size", pmem_adsp_size_setup); |
| 1753 | |
| 1754 | static unsigned fb_size = MSM_FB_SIZE; |
| 1755 | static int __init fb_size_setup(char *p) |
| 1756 | { |
| 1757 | fb_size = memparse(p, NULL); |
| 1758 | return 0; |
| 1759 | } |
| 1760 | |
| 1761 | early_param("fb_size", fb_size_setup); |
| 1762 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 1763 | static struct regulator_bulk_data regs_lcdc[] = { |
| 1764 | { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 }, |
| 1765 | { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 }, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1766 | }; |
| 1767 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1768 | static uint32_t lcdc_gpio_initialized; |
| 1769 | |
| 1770 | static void lcdc_toshiba_gpio_init(void) |
| 1771 | { |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 1772 | int rc = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1773 | if (!lcdc_gpio_initialized) { |
| 1774 | if (gpio_request(GPIO_SPI_CLK, "spi_clk")) { |
| 1775 | pr_err("failed to request gpio spi_clk\n"); |
| 1776 | return; |
| 1777 | } |
| 1778 | if (gpio_request(GPIO_SPI_CS0_N, "spi_cs")) { |
| 1779 | pr_err("failed to request gpio spi_cs0_N\n"); |
| 1780 | goto fail_gpio6; |
| 1781 | } |
| 1782 | if (gpio_request(GPIO_SPI_MOSI, "spi_mosi")) { |
| 1783 | pr_err("failed to request gpio spi_mosi\n"); |
| 1784 | goto fail_gpio5; |
| 1785 | } |
| 1786 | if (gpio_request(GPIO_SPI_MISO, "spi_miso")) { |
| 1787 | pr_err("failed to request gpio spi_miso\n"); |
| 1788 | goto fail_gpio4; |
| 1789 | } |
| 1790 | if (gpio_request(GPIO_DISPLAY_PWR_EN, "gpio_disp_pwr")) { |
| 1791 | pr_err("failed to request gpio_disp_pwr\n"); |
| 1792 | goto fail_gpio3; |
| 1793 | } |
| 1794 | if (gpio_request(GPIO_BACKLIGHT_EN, "gpio_bkl_en")) { |
| 1795 | pr_err("failed to request gpio_bkl_en\n"); |
| 1796 | goto fail_gpio2; |
| 1797 | } |
| 1798 | pmapp_disp_backlight_init(); |
| 1799 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 1800 | rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_lcdc), regs_lcdc); |
| 1801 | if (rc) { |
| 1802 | pr_err("%s: could not get regulators: %d\n", |
| 1803 | __func__, rc); |
| 1804 | goto fail_gpio1; |
| 1805 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1806 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 1807 | rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_lcdc), |
| 1808 | regs_lcdc); |
| 1809 | if (rc) { |
| 1810 | pr_err("%s: could not set voltages: %d\n", |
| 1811 | __func__, rc); |
| 1812 | goto fail_vreg; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1813 | } |
| 1814 | lcdc_gpio_initialized = 1; |
| 1815 | } |
| 1816 | return; |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 1817 | fail_vreg: |
| 1818 | regulator_bulk_free(ARRAY_SIZE(regs_lcdc), regs_lcdc); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1819 | fail_gpio1: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1820 | gpio_free(GPIO_BACKLIGHT_EN); |
| 1821 | fail_gpio2: |
| 1822 | gpio_free(GPIO_DISPLAY_PWR_EN); |
| 1823 | fail_gpio3: |
| 1824 | gpio_free(GPIO_SPI_MISO); |
| 1825 | fail_gpio4: |
| 1826 | gpio_free(GPIO_SPI_MOSI); |
| 1827 | fail_gpio5: |
| 1828 | gpio_free(GPIO_SPI_CS0_N); |
| 1829 | fail_gpio6: |
| 1830 | gpio_free(GPIO_SPI_CLK); |
| 1831 | lcdc_gpio_initialized = 0; |
| 1832 | } |
| 1833 | |
| 1834 | static uint32_t lcdc_gpio_table[] = { |
| 1835 | GPIO_SPI_CLK, |
| 1836 | GPIO_SPI_CS0_N, |
| 1837 | GPIO_SPI_MOSI, |
| 1838 | GPIO_DISPLAY_PWR_EN, |
| 1839 | GPIO_BACKLIGHT_EN, |
| 1840 | GPIO_SPI_MISO, |
| 1841 | }; |
| 1842 | |
| 1843 | static void config_lcdc_gpio_table(uint32_t *table, int len, unsigned enable) |
| 1844 | { |
| 1845 | int n; |
| 1846 | |
| 1847 | if (lcdc_gpio_initialized) { |
| 1848 | /* All are IO Expander GPIOs */ |
| 1849 | for (n = 0; n < (len - 1); n++) |
| 1850 | gpio_direction_output(table[n], 1); |
| 1851 | } |
| 1852 | } |
| 1853 | |
| 1854 | static void lcdc_toshiba_config_gpios(int enable) |
| 1855 | { |
| 1856 | config_lcdc_gpio_table(lcdc_gpio_table, |
| 1857 | ARRAY_SIZE(lcdc_gpio_table), enable); |
| 1858 | } |
| 1859 | |
| 1860 | static int msm_fb_lcdc_power_save(int on) |
| 1861 | { |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 1862 | int rc = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1863 | /* Doing the init of the LCDC GPIOs very late as they are from |
| 1864 | an I2C-controlled IO Expander */ |
| 1865 | lcdc_toshiba_gpio_init(); |
| 1866 | |
| 1867 | if (lcdc_gpio_initialized) { |
| 1868 | gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, on); |
| 1869 | gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, on); |
| 1870 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 1871 | rc = on ? regulator_bulk_enable( |
| 1872 | ARRAY_SIZE(regs_lcdc), regs_lcdc) : |
| 1873 | regulator_bulk_disable( |
| 1874 | ARRAY_SIZE(regs_lcdc), regs_lcdc); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1875 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 1876 | if (rc) |
| 1877 | pr_err("%s: could not %sable regulators: %d\n", |
| 1878 | __func__, on ? "en" : "dis", rc); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1879 | } |
| 1880 | |
| 1881 | return rc; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1882 | } |
| 1883 | |
| 1884 | |
| 1885 | static int lcdc_toshiba_set_bl(int level) |
| 1886 | { |
| 1887 | int ret; |
| 1888 | |
| 1889 | ret = pmapp_disp_backlight_set_brightness(level); |
| 1890 | if (ret) |
| 1891 | pr_err("%s: can't set lcd backlight!\n", __func__); |
| 1892 | |
| 1893 | return ret; |
| 1894 | } |
| 1895 | |
| 1896 | |
| 1897 | static struct lcdc_platform_data lcdc_pdata = { |
Jeevan Shriram | 15f2a5e | 2011-07-13 21:45:26 +0530 | [diff] [blame] | 1898 | .lcdc_gpio_config = NULL, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1899 | .lcdc_power_save = msm_fb_lcdc_power_save, |
| 1900 | }; |
| 1901 | |
| 1902 | static int lcd_panel_spi_gpio_num[] = { |
| 1903 | GPIO_SPI_MOSI, /* spi_sdi */ |
| 1904 | GPIO_SPI_MISO, /* spi_sdoi */ |
| 1905 | GPIO_SPI_CLK, /* spi_clk */ |
| 1906 | GPIO_SPI_CS0_N, /* spi_cs */ |
| 1907 | }; |
| 1908 | |
| 1909 | static struct msm_panel_common_pdata lcdc_toshiba_panel_data = { |
| 1910 | .panel_config_gpio = lcdc_toshiba_config_gpios, |
| 1911 | .pmic_backlight = lcdc_toshiba_set_bl, |
| 1912 | .gpio_num = lcd_panel_spi_gpio_num, |
| 1913 | }; |
| 1914 | |
| 1915 | static struct platform_device lcdc_toshiba_panel_device = { |
| 1916 | .name = "lcdc_toshiba_fwvga_pt", |
| 1917 | .id = 0, |
| 1918 | .dev = { |
| 1919 | .platform_data = &lcdc_toshiba_panel_data, |
| 1920 | } |
| 1921 | }; |
| 1922 | |
| 1923 | static struct resource msm_fb_resources[] = { |
| 1924 | { |
| 1925 | .flags = IORESOURCE_DMA, |
| 1926 | } |
| 1927 | }; |
| 1928 | |
Ajay Singh Parmar | eede70e | 2011-08-24 17:36:08 +0530 | [diff] [blame] | 1929 | #define PANEL_NAME_MAX_LEN 30 |
| 1930 | #define LCDC_TOSHIBA_FWVGA_PANEL_NAME "lcdc_toshiba_fwvga_pt" |
| 1931 | #define MIPI_CMD_RENESAS_FWVGA_PANEL_NAME "mipi_cmd_renesas_fwvga" |
| 1932 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1933 | static int msm_fb_detect_panel(const char *name) |
| 1934 | { |
Taniya Das | 0a5303a | 2011-08-23 18:47:48 +0530 | [diff] [blame] | 1935 | int ret = -ENODEV; |
| 1936 | |
| 1937 | if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf()) { |
| 1938 | if (!strncmp(name, "lcdc_toshiba_fwvga_pt", 21) || |
| 1939 | !strncmp(name, "mipi_cmd_renesas_fwvga", 22)) |
| 1940 | ret = 0; |
Jeevan Shriram | 29c9e95 | 2011-10-27 11:22:46 +0530 | [diff] [blame] | 1941 | } else if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()) { |
Taniya Das | 0a5303a | 2011-08-23 18:47:48 +0530 | [diff] [blame] | 1942 | if (!strncmp(name, "mipi_cmd_renesas_fwvga", 22)) |
| 1943 | ret = 0; |
| 1944 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1945 | |
Ajay Singh Parmar | eede70e | 2011-08-24 17:36:08 +0530 | [diff] [blame] | 1946 | #if !defined(CONFIG_FB_MSM_LCDC_AUTO_DETECT) && \ |
| 1947 | !defined(CONFIG_FB_MSM_MIPI_PANEL_AUTO_DETECT) && \ |
| 1948 | !defined(CONFIG_FB_MSM_LCDC_MIPI_PANEL_AUTO_DETECT) |
| 1949 | if (machine_is_msm7x27a_surf() || |
| 1950 | machine_is_msm7625a_surf()) { |
| 1951 | if (!strncmp(name, LCDC_TOSHIBA_FWVGA_PANEL_NAME, |
| 1952 | strnlen(LCDC_TOSHIBA_FWVGA_PANEL_NAME, |
| 1953 | PANEL_NAME_MAX_LEN))) |
| 1954 | return 0; |
| 1955 | } |
| 1956 | #endif |
Taniya Das | 0a5303a | 2011-08-23 18:47:48 +0530 | [diff] [blame] | 1957 | return ret; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1958 | } |
| 1959 | |
| 1960 | static struct msm_fb_platform_data msm_fb_pdata = { |
| 1961 | .detect_client = msm_fb_detect_panel, |
| 1962 | }; |
| 1963 | |
| 1964 | static struct platform_device msm_fb_device = { |
| 1965 | .name = "msm_fb", |
| 1966 | .id = 0, |
| 1967 | .num_resources = ARRAY_SIZE(msm_fb_resources), |
| 1968 | .resource = msm_fb_resources, |
| 1969 | .dev = { |
| 1970 | .platform_data = &msm_fb_pdata, |
| 1971 | } |
| 1972 | }; |
| 1973 | |
| 1974 | #ifdef CONFIG_FB_MSM_MIPI_DSI |
| 1975 | static int mipi_renesas_set_bl(int level) |
| 1976 | { |
| 1977 | int ret; |
| 1978 | |
| 1979 | ret = pmapp_disp_backlight_set_brightness(level); |
| 1980 | |
| 1981 | if (ret) |
| 1982 | pr_err("%s: can't set lcd backlight!\n", __func__); |
| 1983 | |
| 1984 | return ret; |
| 1985 | } |
| 1986 | |
| 1987 | static struct msm_panel_common_pdata mipi_renesas_pdata = { |
| 1988 | .pmic_backlight = mipi_renesas_set_bl, |
| 1989 | }; |
| 1990 | |
| 1991 | |
| 1992 | static struct platform_device mipi_dsi_renesas_panel_device = { |
| 1993 | .name = "mipi_renesas", |
| 1994 | .id = 0, |
| 1995 | .dev = { |
| 1996 | .platform_data = &mipi_renesas_pdata, |
| 1997 | } |
| 1998 | }; |
| 1999 | #endif |
| 2000 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2001 | #define SND(desc, num) { .name = #desc, .id = num } |
| 2002 | static struct snd_endpoint snd_endpoints_list[] = { |
| 2003 | SND(HANDSET, 0), |
| 2004 | SND(MONO_HEADSET, 2), |
| 2005 | SND(HEADSET, 3), |
| 2006 | SND(SPEAKER, 6), |
| 2007 | SND(TTY_HEADSET, 8), |
| 2008 | SND(TTY_VCO, 9), |
| 2009 | SND(TTY_HCO, 10), |
| 2010 | SND(BT, 12), |
| 2011 | SND(IN_S_SADC_OUT_HANDSET, 16), |
| 2012 | SND(IN_S_SADC_OUT_SPEAKER_PHONE, 25), |
| 2013 | SND(FM_DIGITAL_STEREO_HEADSET, 26), |
| 2014 | SND(FM_DIGITAL_SPEAKER_PHONE, 27), |
| 2015 | SND(FM_DIGITAL_BT_A2DP_HEADSET, 28), |
Shashi Kumar | 64e0760 | 2011-10-11 13:18:57 +0530 | [diff] [blame] | 2016 | SND(STEREO_HEADSET_AND_SPEAKER, 31), |
Sidipotu Ashok | ab34ca4 | 2011-07-22 16:34:20 +0530 | [diff] [blame] | 2017 | SND(CURRENT, 0x7FFFFFFE), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2018 | SND(FM_ANALOG_STEREO_HEADSET, 35), |
| 2019 | SND(FM_ANALOG_STEREO_HEADSET_CODEC, 36), |
| 2020 | }; |
| 2021 | #undef SND |
| 2022 | |
| 2023 | static struct msm_snd_endpoints msm_device_snd_endpoints = { |
| 2024 | .endpoints = snd_endpoints_list, |
| 2025 | .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint) |
| 2026 | }; |
| 2027 | |
| 2028 | static struct platform_device msm_device_snd = { |
| 2029 | .name = "msm_snd", |
| 2030 | .id = -1, |
| 2031 | .dev = { |
| 2032 | .platform_data = &msm_device_snd_endpoints |
| 2033 | }, |
| 2034 | }; |
| 2035 | |
| 2036 | #define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \ |
| 2037 | (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \ |
| 2038 | (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \ |
| 2039 | (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \ |
| 2040 | (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \ |
| 2041 | (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP)) |
| 2042 | #define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \ |
| 2043 | (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \ |
| 2044 | (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \ |
| 2045 | (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \ |
| 2046 | (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \ |
| 2047 | (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP)) |
| 2048 | #define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \ |
| 2049 | (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \ |
| 2050 | (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \ |
| 2051 | (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \ |
| 2052 | (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \ |
| 2053 | (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP)) |
| 2054 | #define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \ |
| 2055 | (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \ |
| 2056 | (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \ |
| 2057 | (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \ |
| 2058 | (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \ |
| 2059 | (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP)) |
| 2060 | #define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI) |
| 2061 | |
| 2062 | static unsigned int dec_concurrency_table[] = { |
| 2063 | /* Audio LP */ |
| 2064 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DMA)), 0, |
| 2065 | 0, 0, 0, |
| 2066 | |
| 2067 | /* Concurrency 1 */ |
| 2068 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2069 | (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2070 | (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2071 | (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2072 | (DEC4_FORMAT), |
| 2073 | |
| 2074 | /* Concurrency 2 */ |
| 2075 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2076 | (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2077 | (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2078 | (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2079 | (DEC4_FORMAT), |
| 2080 | |
| 2081 | /* Concurrency 3 */ |
| 2082 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2083 | (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2084 | (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2085 | (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2086 | (DEC4_FORMAT), |
| 2087 | |
| 2088 | /* Concurrency 4 */ |
| 2089 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2090 | (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2091 | (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2092 | (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2093 | (DEC4_FORMAT), |
| 2094 | |
| 2095 | /* Concurrency 5 */ |
| 2096 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2097 | (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2098 | (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2099 | (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2100 | (DEC4_FORMAT), |
| 2101 | |
| 2102 | /* Concurrency 6 */ |
| 2103 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2104 | 0, 0, 0, 0, |
| 2105 | |
| 2106 | /* Concurrency 7 */ |
| 2107 | (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2108 | (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2109 | (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2110 | (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)), |
| 2111 | (DEC4_FORMAT), |
| 2112 | }; |
| 2113 | |
| 2114 | #define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \ |
| 2115 | .module_queueid = queueid, .module_decid = decid, \ |
| 2116 | .nr_codec_support = nr_codec} |
| 2117 | |
| 2118 | static struct msm_adspdec_info dec_info_list[] = { |
| 2119 | DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */ |
| 2120 | DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* AudPlay1BitStreamCtrlQueue */ |
| 2121 | DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* AudPlay2BitStreamCtrlQueue */ |
| 2122 | DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* AudPlay3BitStreamCtrlQueue */ |
| 2123 | DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* AudPlay4BitStreamCtrlQueue */ |
| 2124 | }; |
| 2125 | |
| 2126 | static struct msm_adspdec_database msm_device_adspdec_database = { |
| 2127 | .num_dec = ARRAY_SIZE(dec_info_list), |
| 2128 | .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \ |
| 2129 | ARRAY_SIZE(dec_info_list)), |
| 2130 | .dec_concurrency_table = dec_concurrency_table, |
| 2131 | .dec_info_list = dec_info_list, |
| 2132 | }; |
| 2133 | |
| 2134 | static struct platform_device msm_device_adspdec = { |
| 2135 | .name = "msm_adspdec", |
| 2136 | .id = -1, |
| 2137 | .dev = { |
| 2138 | .platform_data = &msm_device_adspdec_database |
| 2139 | }, |
| 2140 | }; |
| 2141 | |
| 2142 | static struct android_pmem_platform_data android_pmem_audio_pdata = { |
| 2143 | .name = "pmem_audio", |
| 2144 | .allocator_type = PMEM_ALLOCATORTYPE_BITMAP, |
| 2145 | .cached = 0, |
| 2146 | .memory_type = MEMTYPE_EBI1, |
| 2147 | }; |
| 2148 | |
| 2149 | static struct platform_device android_pmem_audio_device = { |
| 2150 | .name = "android_pmem", |
| 2151 | .id = 2, |
| 2152 | .dev = { .platform_data = &android_pmem_audio_pdata }, |
| 2153 | }; |
| 2154 | |
| 2155 | static struct android_pmem_platform_data android_pmem_pdata = { |
| 2156 | .name = "pmem", |
| 2157 | .allocator_type = PMEM_ALLOCATORTYPE_BITMAP, |
| 2158 | .cached = 1, |
| 2159 | .memory_type = MEMTYPE_EBI1, |
| 2160 | }; |
| 2161 | static struct platform_device android_pmem_device = { |
| 2162 | .name = "android_pmem", |
| 2163 | .id = 0, |
| 2164 | .dev = { .platform_data = &android_pmem_pdata }, |
| 2165 | }; |
| 2166 | |
| 2167 | static u32 msm_calculate_batt_capacity(u32 current_voltage); |
| 2168 | |
| 2169 | static struct msm_psy_batt_pdata msm_psy_batt_data = { |
| 2170 | .voltage_min_design = 2800, |
| 2171 | .voltage_max_design = 4300, |
| 2172 | .avail_chg_sources = AC_CHG | USB_CHG , |
| 2173 | .batt_technology = POWER_SUPPLY_TECHNOLOGY_LION, |
| 2174 | .calculate_capacity = &msm_calculate_batt_capacity, |
| 2175 | }; |
| 2176 | |
| 2177 | static u32 msm_calculate_batt_capacity(u32 current_voltage) |
| 2178 | { |
| 2179 | u32 low_voltage = msm_psy_batt_data.voltage_min_design; |
| 2180 | u32 high_voltage = msm_psy_batt_data.voltage_max_design; |
| 2181 | |
| 2182 | return (current_voltage - low_voltage) * 100 |
| 2183 | / (high_voltage - low_voltage); |
| 2184 | } |
| 2185 | |
| 2186 | static struct platform_device msm_batt_device = { |
| 2187 | .name = "msm-battery", |
| 2188 | .id = -1, |
| 2189 | .dev.platform_data = &msm_psy_batt_data, |
| 2190 | }; |
| 2191 | |
| 2192 | static struct smsc911x_platform_config smsc911x_config = { |
| 2193 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH, |
| 2194 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, |
| 2195 | .flags = SMSC911X_USE_16BIT, |
| 2196 | }; |
| 2197 | |
| 2198 | static struct resource smsc911x_resources[] = { |
| 2199 | [0] = { |
| 2200 | .start = 0x90000000, |
| 2201 | .end = 0x90007fff, |
| 2202 | .flags = IORESOURCE_MEM, |
| 2203 | }, |
| 2204 | [1] = { |
| 2205 | .start = MSM_GPIO_TO_INT(48), |
| 2206 | .end = MSM_GPIO_TO_INT(48), |
| 2207 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL, |
| 2208 | }, |
| 2209 | }; |
| 2210 | |
| 2211 | static struct platform_device smsc911x_device = { |
| 2212 | .name = "smsc911x", |
| 2213 | .id = 0, |
| 2214 | .num_resources = ARRAY_SIZE(smsc911x_resources), |
| 2215 | .resource = smsc911x_resources, |
| 2216 | .dev = { |
| 2217 | .platform_data = &smsc911x_config, |
| 2218 | }, |
| 2219 | }; |
| 2220 | |
| 2221 | static struct msm_gpio smsc911x_gpios[] = { |
| 2222 | { GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_6MA), |
| 2223 | "smsc911x_irq" }, |
| 2224 | { GPIO_CFG(49, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_6MA), |
| 2225 | "eth_fifo_sel" }, |
| 2226 | }; |
| 2227 | |
| 2228 | #define ETH_FIFO_SEL_GPIO 49 |
| 2229 | static void msm7x27a_cfg_smsc911x(void) |
| 2230 | { |
| 2231 | int res; |
| 2232 | |
| 2233 | res = msm_gpios_request_enable(smsc911x_gpios, |
| 2234 | ARRAY_SIZE(smsc911x_gpios)); |
| 2235 | if (res) { |
| 2236 | pr_err("%s: unable to enable gpios for SMSC911x\n", __func__); |
| 2237 | return; |
| 2238 | } |
| 2239 | |
| 2240 | /* ETH_FIFO_SEL */ |
| 2241 | res = gpio_direction_output(ETH_FIFO_SEL_GPIO, 0); |
| 2242 | if (res) { |
| 2243 | pr_err("%s: unable to get direction for gpio %d\n", __func__, |
| 2244 | ETH_FIFO_SEL_GPIO); |
| 2245 | msm_gpios_disable_free(smsc911x_gpios, |
| 2246 | ARRAY_SIZE(smsc911x_gpios)); |
| 2247 | return; |
| 2248 | } |
| 2249 | gpio_set_value(ETH_FIFO_SEL_GPIO, 0); |
| 2250 | } |
| 2251 | |
| 2252 | #ifdef CONFIG_MSM_CAMERA |
| 2253 | static uint32_t camera_off_gpio_table[] = { |
| 2254 | GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 2255 | }; |
| 2256 | |
| 2257 | static uint32_t camera_on_gpio_table[] = { |
| 2258 | GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 2259 | }; |
| 2260 | |
| 2261 | #ifdef CONFIG_MSM_CAMERA_FLASH |
| 2262 | static struct msm_camera_sensor_flash_src msm_flash_src = { |
Nishant Pandit | 474f225 | 2011-07-23 23:17:56 +0530 | [diff] [blame] | 2263 | .flash_sr_type = MSM_CAMERA_FLASH_SRC_EXT, |
| 2264 | ._fsrc.ext_driver_src.led_en = GPIO_CAM_GP_LED_EN1, |
| 2265 | ._fsrc.ext_driver_src.led_flash_en = GPIO_CAM_GP_LED_EN2, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2266 | }; |
| 2267 | #endif |
| 2268 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 2269 | static struct regulator_bulk_data regs_camera[] = { |
| 2270 | { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 }, |
| 2271 | { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 }, |
| 2272 | { .supply = "usb2", .min_uV = 1800000, .max_uV = 1800000 }, |
| 2273 | }; |
| 2274 | |
| 2275 | static void __init msm_camera_vreg_init(void) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2276 | { |
| 2277 | int rc; |
| 2278 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 2279 | rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_camera), regs_camera); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2280 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 2281 | if (rc) { |
| 2282 | pr_err("%s: could not get regulators: %d\n", __func__, rc); |
| 2283 | return; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2284 | } |
| 2285 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 2286 | rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_camera), regs_camera); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2287 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 2288 | if (rc) { |
| 2289 | pr_err("%s: could not set voltages: %d\n", __func__, rc); |
| 2290 | return; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2291 | } |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 2292 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2293 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 2294 | static void msm_camera_vreg_config(int vreg_en) |
| 2295 | { |
| 2296 | int rc = vreg_en ? |
| 2297 | regulator_bulk_enable(ARRAY_SIZE(regs_camera), regs_camera) : |
| 2298 | regulator_bulk_disable(ARRAY_SIZE(regs_camera), regs_camera); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2299 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 2300 | if (rc) |
| 2301 | pr_err("%s: could not %sable regulators: %d\n", |
| 2302 | __func__, vreg_en ? "en" : "dis", rc); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2303 | } |
| 2304 | |
| 2305 | static int config_gpio_table(uint32_t *table, int len) |
| 2306 | { |
| 2307 | int rc = 0, i = 0; |
| 2308 | |
| 2309 | for (i = 0; i < len; i++) { |
| 2310 | rc = gpio_tlmm_config(table[i], GPIO_CFG_ENABLE); |
| 2311 | if (rc) { |
| 2312 | pr_err("%s not able to get gpio\n", __func__); |
| 2313 | for (i--; i >= 0; i--) |
| 2314 | gpio_tlmm_config(camera_off_gpio_table[i], |
| 2315 | GPIO_CFG_ENABLE); |
| 2316 | break; |
| 2317 | } |
| 2318 | } |
| 2319 | return rc; |
| 2320 | } |
| 2321 | |
| 2322 | static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data; |
| 2323 | static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data; |
| 2324 | static int config_camera_on_gpios_rear(void) |
| 2325 | { |
| 2326 | int rc = 0; |
| 2327 | |
Trilok Soni | 3d0f6c5 | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 2328 | if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2329 | msm_camera_vreg_config(1); |
| 2330 | |
| 2331 | rc = config_gpio_table(camera_on_gpio_table, |
| 2332 | ARRAY_SIZE(camera_on_gpio_table)); |
| 2333 | if (rc < 0) { |
| 2334 | pr_err("%s: CAMSENSOR gpio table request" |
| 2335 | "failed\n", __func__); |
| 2336 | return rc; |
| 2337 | } |
| 2338 | |
| 2339 | return rc; |
| 2340 | } |
| 2341 | |
| 2342 | static void config_camera_off_gpios_rear(void) |
| 2343 | { |
Trilok Soni | 3d0f6c5 | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 2344 | if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2345 | msm_camera_vreg_config(0); |
| 2346 | |
| 2347 | config_gpio_table(camera_off_gpio_table, |
| 2348 | ARRAY_SIZE(camera_off_gpio_table)); |
| 2349 | } |
| 2350 | |
| 2351 | static int config_camera_on_gpios_front(void) |
| 2352 | { |
| 2353 | int rc = 0; |
| 2354 | |
Trilok Soni | 3d0f6c5 | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 2355 | if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2356 | msm_camera_vreg_config(1); |
| 2357 | |
| 2358 | rc = config_gpio_table(camera_on_gpio_table, |
| 2359 | ARRAY_SIZE(camera_on_gpio_table)); |
| 2360 | if (rc < 0) { |
| 2361 | pr_err("%s: CAMSENSOR gpio table request" |
| 2362 | "failed\n", __func__); |
| 2363 | return rc; |
| 2364 | } |
| 2365 | |
| 2366 | return rc; |
| 2367 | } |
| 2368 | |
| 2369 | static void config_camera_off_gpios_front(void) |
| 2370 | { |
Trilok Soni | 3d0f6c5 | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 2371 | if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2372 | msm_camera_vreg_config(0); |
| 2373 | |
| 2374 | config_gpio_table(camera_off_gpio_table, |
| 2375 | ARRAY_SIZE(camera_off_gpio_table)); |
| 2376 | } |
| 2377 | |
| 2378 | struct msm_camera_device_platform_data msm_camera_device_data_rear = { |
| 2379 | .camera_gpio_on = config_camera_on_gpios_rear, |
| 2380 | .camera_gpio_off = config_camera_off_gpios_rear, |
| 2381 | .ioext.csiphy = 0xA1000000, |
| 2382 | .ioext.csisz = 0x00100000, |
| 2383 | .ioext.csiirq = INT_CSI_IRQ_1, |
| 2384 | .ioclk.mclk_clk_rate = 24000000, |
| 2385 | .ioclk.vfe_clk_rate = 192000000, |
| 2386 | .ioext.appphy = MSM_CLK_CTL_PHYS, |
| 2387 | .ioext.appsz = MSM_CLK_CTL_SIZE, |
| 2388 | }; |
| 2389 | |
| 2390 | struct msm_camera_device_platform_data msm_camera_device_data_front = { |
| 2391 | .camera_gpio_on = config_camera_on_gpios_front, |
| 2392 | .camera_gpio_off = config_camera_off_gpios_front, |
| 2393 | .ioext.csiphy = 0xA0F00000, |
| 2394 | .ioext.csisz = 0x00100000, |
| 2395 | .ioext.csiirq = INT_CSI_IRQ_0, |
| 2396 | .ioclk.mclk_clk_rate = 24000000, |
| 2397 | .ioclk.vfe_clk_rate = 192000000, |
| 2398 | .ioext.appphy = MSM_CLK_CTL_PHYS, |
| 2399 | .ioext.appsz = MSM_CLK_CTL_SIZE, |
| 2400 | }; |
| 2401 | |
| 2402 | #ifdef CONFIG_S5K4E1 |
| 2403 | static struct msm_camera_sensor_platform_info s5k4e1_sensor_7627a_info = { |
| 2404 | .mount_angle = 90 |
| 2405 | }; |
| 2406 | |
| 2407 | static struct msm_camera_sensor_flash_data flash_s5k4e1 = { |
| 2408 | .flash_type = MSM_CAMERA_FLASH_LED, |
| 2409 | .flash_src = &msm_flash_src |
| 2410 | }; |
| 2411 | |
| 2412 | static struct msm_camera_sensor_info msm_camera_sensor_s5k4e1_data = { |
| 2413 | .sensor_name = "s5k4e1", |
| 2414 | .sensor_reset_enable = 1, |
| 2415 | .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N, |
| 2416 | .sensor_pwd = 85, |
| 2417 | .vcm_pwd = GPIO_CAM_GP_CAM_PWDN, |
| 2418 | .vcm_enable = 1, |
| 2419 | .pdata = &msm_camera_device_data_rear, |
| 2420 | .flash_data = &flash_s5k4e1, |
| 2421 | .sensor_platform_info = &s5k4e1_sensor_7627a_info, |
| 2422 | .csi_if = 1 |
| 2423 | }; |
| 2424 | |
| 2425 | static struct platform_device msm_camera_sensor_s5k4e1 = { |
| 2426 | .name = "msm_camera_s5k4e1", |
| 2427 | .dev = { |
| 2428 | .platform_data = &msm_camera_sensor_s5k4e1_data, |
| 2429 | }, |
| 2430 | }; |
| 2431 | #endif |
| 2432 | |
| 2433 | #ifdef CONFIG_IMX072 |
| 2434 | static struct msm_camera_sensor_platform_info imx072_sensor_7627a_info = { |
| 2435 | .mount_angle = 90 |
| 2436 | }; |
| 2437 | |
| 2438 | static struct msm_camera_sensor_flash_data flash_imx072 = { |
| 2439 | .flash_type = MSM_CAMERA_FLASH_LED, |
| 2440 | .flash_src = &msm_flash_src |
| 2441 | }; |
| 2442 | |
| 2443 | static struct msm_camera_sensor_info msm_camera_sensor_imx072_data = { |
| 2444 | .sensor_name = "imx072", |
| 2445 | .sensor_reset_enable = 1, |
| 2446 | .sensor_reset = GPIO_CAM_GP_CAMIF_RESET_N, /* TODO 106,*/ |
| 2447 | .sensor_pwd = 85, |
| 2448 | .vcm_pwd = GPIO_CAM_GP_CAM_PWDN, |
| 2449 | .vcm_enable = 1, |
| 2450 | .pdata = &msm_camera_device_data_rear, |
| 2451 | .flash_data = &flash_imx072, |
| 2452 | .sensor_platform_info = &imx072_sensor_7627a_info, |
| 2453 | .csi_if = 1 |
| 2454 | }; |
| 2455 | |
| 2456 | static struct platform_device msm_camera_sensor_imx072 = { |
| 2457 | .name = "msm_camera_imx072", |
| 2458 | .dev = { |
| 2459 | .platform_data = &msm_camera_sensor_imx072_data, |
| 2460 | }, |
| 2461 | }; |
| 2462 | #endif |
| 2463 | |
| 2464 | #ifdef CONFIG_WEBCAM_OV9726 |
| 2465 | static struct msm_camera_sensor_platform_info ov9726_sensor_7627a_info = { |
| 2466 | .mount_angle = 90 |
| 2467 | }; |
| 2468 | |
| 2469 | static struct msm_camera_sensor_flash_data flash_ov9726 = { |
| 2470 | .flash_type = MSM_CAMERA_FLASH_NONE, |
| 2471 | .flash_src = &msm_flash_src |
| 2472 | }; |
| 2473 | |
| 2474 | static struct msm_camera_sensor_info msm_camera_sensor_ov9726_data = { |
| 2475 | .sensor_name = "ov9726", |
| 2476 | .sensor_reset_enable = 0, |
| 2477 | .sensor_reset = GPIO_CAM_GP_CAM1MP_XCLR, |
| 2478 | .sensor_pwd = 85, |
| 2479 | .vcm_pwd = 1, |
| 2480 | .vcm_enable = 0, |
| 2481 | .pdata = &msm_camera_device_data_front, |
| 2482 | .flash_data = &flash_ov9726, |
| 2483 | .sensor_platform_info = &ov9726_sensor_7627a_info, |
| 2484 | .csi_if = 1 |
| 2485 | }; |
| 2486 | |
| 2487 | static struct platform_device msm_camera_sensor_ov9726 = { |
| 2488 | .name = "msm_camera_ov9726", |
| 2489 | .dev = { |
| 2490 | .platform_data = &msm_camera_sensor_ov9726_data, |
| 2491 | }, |
| 2492 | }; |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 2493 | #else |
| 2494 | static inline void msm_camera_vreg_init(void) { } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2495 | #endif |
| 2496 | |
| 2497 | #ifdef CONFIG_MT9E013 |
| 2498 | static struct msm_camera_sensor_platform_info mt9e013_sensor_7627a_info = { |
| 2499 | .mount_angle = 90 |
| 2500 | }; |
| 2501 | |
| 2502 | static struct msm_camera_sensor_flash_data flash_mt9e013 = { |
| 2503 | .flash_type = MSM_CAMERA_FLASH_LED, |
| 2504 | .flash_src = &msm_flash_src |
| 2505 | }; |
| 2506 | |
| 2507 | static struct msm_camera_sensor_info msm_camera_sensor_mt9e013_data = { |
| 2508 | .sensor_name = "mt9e013", |
| 2509 | .sensor_reset = 0, |
| 2510 | .sensor_reset_enable = 1, |
| 2511 | .sensor_pwd = 85, |
| 2512 | .vcm_pwd = 1, |
| 2513 | .vcm_enable = 0, |
| 2514 | .pdata = &msm_camera_device_data_rear, |
| 2515 | .flash_data = &flash_mt9e013, |
| 2516 | .sensor_platform_info = &mt9e013_sensor_7627a_info, |
| 2517 | .csi_if = 1 |
| 2518 | }; |
| 2519 | |
| 2520 | static struct platform_device msm_camera_sensor_mt9e013 = { |
| 2521 | .name = "msm_camera_mt9e013", |
| 2522 | .dev = { |
| 2523 | .platform_data = &msm_camera_sensor_mt9e013_data, |
| 2524 | }, |
| 2525 | }; |
| 2526 | #endif |
| 2527 | |
| 2528 | static struct i2c_board_info i2c_camera_devices[] = { |
| 2529 | #ifdef CONFIG_S5K4E1 |
| 2530 | { |
| 2531 | I2C_BOARD_INFO("s5k4e1", 0x36), |
| 2532 | }, |
| 2533 | { |
| 2534 | I2C_BOARD_INFO("s5k4e1_af", 0x8c >> 1), |
| 2535 | }, |
| 2536 | #endif |
| 2537 | #ifdef CONFIG_WEBCAM_OV9726 |
| 2538 | { |
| 2539 | I2C_BOARD_INFO("ov9726", 0x10), |
| 2540 | }, |
| 2541 | #endif |
| 2542 | #ifdef CONFIG_IMX072 |
| 2543 | { |
| 2544 | I2C_BOARD_INFO("imx072", 0x34), |
| 2545 | }, |
| 2546 | #endif |
| 2547 | #ifdef CONFIG_MT9E013 |
| 2548 | { |
| 2549 | I2C_BOARD_INFO("mt9e013", 0x6C >> 2), |
| 2550 | }, |
| 2551 | #endif |
| 2552 | { |
Nishant Pandit | 474f225 | 2011-07-23 23:17:56 +0530 | [diff] [blame] | 2553 | I2C_BOARD_INFO("sc628a", 0x6E), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2554 | }, |
| 2555 | }; |
| 2556 | #endif |
| 2557 | #if defined(CONFIG_SERIAL_MSM_HSL_CONSOLE) \ |
| 2558 | && defined(CONFIG_MSM_SHARED_GPIO_FOR_UART2DM) |
| 2559 | static struct msm_gpio uart2dm_gpios[] = { |
| 2560 | {GPIO_CFG(19, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 2561 | "uart2dm_rfr_n" }, |
| 2562 | {GPIO_CFG(20, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 2563 | "uart2dm_cts_n" }, |
| 2564 | {GPIO_CFG(21, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 2565 | "uart2dm_rx" }, |
| 2566 | {GPIO_CFG(108, 2, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 2567 | "uart2dm_tx" }, |
| 2568 | }; |
| 2569 | |
| 2570 | static void msm7x27a_cfg_uart2dm_serial(void) |
| 2571 | { |
| 2572 | int ret; |
| 2573 | ret = msm_gpios_request_enable(uart2dm_gpios, |
| 2574 | ARRAY_SIZE(uart2dm_gpios)); |
| 2575 | if (ret) |
| 2576 | pr_err("%s: unable to enable gpios for uart2dm\n", __func__); |
| 2577 | } |
| 2578 | #else |
| 2579 | static void msm7x27a_cfg_uart2dm_serial(void) { } |
| 2580 | #endif |
| 2581 | |
| 2582 | static struct platform_device *rumi_sim_devices[] __initdata = { |
| 2583 | &msm_device_dmov, |
| 2584 | &msm_device_smd, |
| 2585 | &smc91x_device, |
| 2586 | &msm_device_uart1, |
| 2587 | &msm_device_nand, |
| 2588 | &msm_device_uart_dm1, |
| 2589 | &msm_gsbi0_qup_i2c_device, |
| 2590 | &msm_gsbi1_qup_i2c_device, |
| 2591 | }; |
| 2592 | |
| 2593 | static struct platform_device *surf_ffa_devices[] __initdata = { |
| 2594 | &msm_device_dmov, |
| 2595 | &msm_device_smd, |
| 2596 | &msm_device_uart1, |
| 2597 | &msm_device_uart_dm1, |
| 2598 | &msm_device_uart_dm2, |
| 2599 | &msm_device_nand, |
| 2600 | &msm_gsbi0_qup_i2c_device, |
| 2601 | &msm_gsbi1_qup_i2c_device, |
| 2602 | &msm_device_otg, |
| 2603 | &msm_device_gadget_peripheral, |
| 2604 | &android_usb_device, |
| 2605 | &android_pmem_device, |
| 2606 | &android_pmem_adsp_device, |
| 2607 | &android_pmem_audio_device, |
| 2608 | &msm_device_snd, |
| 2609 | &msm_device_adspdec, |
| 2610 | &msm_fb_device, |
| 2611 | &lcdc_toshiba_panel_device, |
| 2612 | &msm_batt_device, |
| 2613 | &smsc911x_device, |
| 2614 | #ifdef CONFIG_S5K4E1 |
| 2615 | &msm_camera_sensor_s5k4e1, |
| 2616 | #endif |
| 2617 | #ifdef CONFIG_IMX072 |
| 2618 | &msm_camera_sensor_imx072, |
| 2619 | #endif |
| 2620 | #ifdef CONFIG_WEBCAM_OV9726 |
| 2621 | &msm_camera_sensor_ov9726, |
| 2622 | #endif |
| 2623 | #ifdef CONFIG_MT9E013 |
| 2624 | &msm_camera_sensor_mt9e013, |
| 2625 | #endif |
| 2626 | #ifdef CONFIG_FB_MSM_MIPI_DSI |
| 2627 | &mipi_dsi_renesas_panel_device, |
| 2628 | #endif |
| 2629 | &msm_kgsl_3d0, |
| 2630 | #ifdef CONFIG_BT |
| 2631 | &msm_bt_power_device, |
| 2632 | #endif |
Manish Dewangan | 3a26099 | 2011-06-24 18:01:34 +0530 | [diff] [blame] | 2633 | &asoc_msm_pcm, |
| 2634 | &asoc_msm_dai0, |
| 2635 | &asoc_msm_dai1, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2636 | }; |
| 2637 | |
| 2638 | static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE; |
| 2639 | static int __init pmem_kernel_ebi1_size_setup(char *p) |
| 2640 | { |
| 2641 | pmem_kernel_ebi1_size = memparse(p, NULL); |
| 2642 | return 0; |
| 2643 | } |
| 2644 | early_param("pmem_kernel_ebi1_size", pmem_kernel_ebi1_size_setup); |
| 2645 | |
| 2646 | static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE; |
| 2647 | static int __init pmem_audio_size_setup(char *p) |
| 2648 | { |
| 2649 | pmem_audio_size = memparse(p, NULL); |
| 2650 | return 0; |
| 2651 | } |
| 2652 | early_param("pmem_audio_size", pmem_audio_size_setup); |
| 2653 | |
| 2654 | static void __init msm_msm7x2x_allocate_memory_regions(void) |
| 2655 | { |
| 2656 | void *addr; |
| 2657 | unsigned long size; |
| 2658 | |
Jeevan Shriram | f40764e | 2011-10-31 23:28:26 +0530 | [diff] [blame] | 2659 | if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) |
| 2660 | fb_size = MSM7x25A_MSM_FB_SIZE; |
| 2661 | else |
| 2662 | fb_size = MSM_FB_SIZE; |
| 2663 | |
| 2664 | size = fb_size; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2665 | addr = alloc_bootmem_align(size, 0x1000); |
| 2666 | msm_fb_resources[0].start = __pa(addr); |
| 2667 | msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1; |
| 2668 | pr_info("allocating %lu bytes at %p (%lx physical) for fb\n", |
| 2669 | size, addr, __pa(addr)); |
| 2670 | } |
| 2671 | |
| 2672 | static struct memtype_reserve msm7x27a_reserve_table[] __initdata = { |
| 2673 | [MEMTYPE_SMI] = { |
| 2674 | }, |
| 2675 | [MEMTYPE_EBI0] = { |
| 2676 | .flags = MEMTYPE_FLAGS_1M_ALIGN, |
| 2677 | }, |
| 2678 | [MEMTYPE_EBI1] = { |
| 2679 | .flags = MEMTYPE_FLAGS_1M_ALIGN, |
| 2680 | }, |
| 2681 | }; |
| 2682 | |
| 2683 | static void __init size_pmem_devices(void) |
| 2684 | { |
Jeevan Shriram | f40764e | 2011-10-31 23:28:26 +0530 | [diff] [blame] | 2685 | |
| 2686 | if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) { |
| 2687 | pmem_mdp_size = MSM7x25A_MSM_PMEM_MDP_SIZE; |
| 2688 | pmem_adsp_size = MSM7x25A_MSM_PMEM_ADSP_SIZE; |
| 2689 | } else { |
| 2690 | pmem_mdp_size = MSM_PMEM_MDP_SIZE; |
| 2691 | pmem_adsp_size = MSM_PMEM_ADSP_SIZE; |
| 2692 | } |
| 2693 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2694 | #ifdef CONFIG_ANDROID_PMEM |
| 2695 | android_pmem_adsp_pdata.size = pmem_adsp_size; |
| 2696 | android_pmem_pdata.size = pmem_mdp_size; |
| 2697 | android_pmem_audio_pdata.size = pmem_audio_size; |
| 2698 | #endif |
| 2699 | } |
| 2700 | |
| 2701 | static void __init reserve_memory_for(struct android_pmem_platform_data *p) |
| 2702 | { |
| 2703 | msm7x27a_reserve_table[p->memory_type].size += p->size; |
| 2704 | } |
| 2705 | |
| 2706 | static void __init reserve_pmem_memory(void) |
| 2707 | { |
| 2708 | #ifdef CONFIG_ANDROID_PMEM |
| 2709 | reserve_memory_for(&android_pmem_adsp_pdata); |
| 2710 | reserve_memory_for(&android_pmem_pdata); |
| 2711 | reserve_memory_for(&android_pmem_audio_pdata); |
| 2712 | msm7x27a_reserve_table[MEMTYPE_EBI1].size += pmem_kernel_ebi1_size; |
| 2713 | #endif |
| 2714 | } |
| 2715 | |
| 2716 | static void __init msm7x27a_calculate_reserve_sizes(void) |
| 2717 | { |
| 2718 | size_pmem_devices(); |
| 2719 | reserve_pmem_memory(); |
| 2720 | } |
| 2721 | |
| 2722 | static int msm7x27a_paddr_to_memtype(unsigned int paddr) |
| 2723 | { |
| 2724 | return MEMTYPE_EBI1; |
| 2725 | } |
| 2726 | |
| 2727 | static struct reserve_info msm7x27a_reserve_info __initdata = { |
| 2728 | .memtype_reserve_table = msm7x27a_reserve_table, |
| 2729 | .calculate_reserve_sizes = msm7x27a_calculate_reserve_sizes, |
| 2730 | .paddr_to_memtype = msm7x27a_paddr_to_memtype, |
| 2731 | }; |
| 2732 | |
| 2733 | static void __init msm7x27a_reserve(void) |
| 2734 | { |
| 2735 | reserve_info = &msm7x27a_reserve_info; |
| 2736 | msm_reserve(); |
| 2737 | } |
| 2738 | |
| 2739 | static void __init msm_device_i2c_init(void) |
| 2740 | { |
| 2741 | msm_gsbi0_qup_i2c_device.dev.platform_data = &msm_gsbi0_qup_i2c_pdata; |
| 2742 | msm_gsbi1_qup_i2c_device.dev.platform_data = &msm_gsbi1_qup_i2c_pdata; |
| 2743 | } |
| 2744 | |
| 2745 | static struct msm_panel_common_pdata mdp_pdata = { |
| 2746 | .gpio = 97, |
| 2747 | .mdp_rev = MDP_REV_303, |
| 2748 | }; |
| 2749 | |
Pankaj Kumar | ffdaec8 | 2011-09-26 12:24:45 +0530 | [diff] [blame] | 2750 | |
| 2751 | #ifdef CONFIG_FB_MSM |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2752 | #define GPIO_LCDC_BRDG_PD 128 |
| 2753 | #define GPIO_LCDC_BRDG_RESET_N 129 |
| 2754 | |
| 2755 | #define LCDC_RESET_PHYS 0x90008014 |
Pankaj Kumar | ffdaec8 | 2011-09-26 12:24:45 +0530 | [diff] [blame] | 2756 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2757 | static void __iomem *lcdc_reset_ptr; |
| 2758 | |
| 2759 | static unsigned mipi_dsi_gpio[] = { |
| 2760 | GPIO_CFG(GPIO_LCDC_BRDG_RESET_N, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, |
| 2761 | GPIO_CFG_2MA), /* LCDC_BRDG_RESET_N */ |
| 2762 | GPIO_CFG(GPIO_LCDC_BRDG_PD, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, |
| 2763 | GPIO_CFG_2MA), /* LCDC_BRDG_RESET_N */ |
| 2764 | }; |
| 2765 | |
| 2766 | enum { |
| 2767 | DSI_SINGLE_LANE = 1, |
| 2768 | DSI_TWO_LANES, |
| 2769 | }; |
| 2770 | |
| 2771 | static int msm_fb_get_lane_config(void) |
| 2772 | { |
| 2773 | int rc = DSI_TWO_LANES; |
| 2774 | |
Trilok Soni | 3d0f6c5 | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 2775 | if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2776 | rc = DSI_SINGLE_LANE; |
| 2777 | pr_info("DSI Single Lane\n"); |
| 2778 | } else { |
| 2779 | pr_info("DSI Two Lanes\n"); |
| 2780 | } |
| 2781 | return rc; |
| 2782 | } |
| 2783 | |
| 2784 | static int msm_fb_dsi_client_reset(void) |
| 2785 | { |
| 2786 | int rc = 0; |
| 2787 | |
| 2788 | rc = gpio_request(GPIO_LCDC_BRDG_RESET_N, "lcdc_brdg_reset_n"); |
| 2789 | if (rc < 0) { |
| 2790 | pr_err("failed to request lcd brdg reset_n\n"); |
| 2791 | return rc; |
| 2792 | } |
| 2793 | |
| 2794 | rc = gpio_request(GPIO_LCDC_BRDG_PD, "lcdc_brdg_pd"); |
| 2795 | if (rc < 0) { |
| 2796 | pr_err("failed to request lcd brdg pd\n"); |
| 2797 | return rc; |
| 2798 | } |
| 2799 | |
| 2800 | rc = gpio_tlmm_config(mipi_dsi_gpio[0], GPIO_CFG_ENABLE); |
| 2801 | if (rc) { |
| 2802 | pr_err("Failed to enable LCDC Bridge reset enable\n"); |
| 2803 | goto gpio_error; |
| 2804 | } |
| 2805 | |
| 2806 | rc = gpio_tlmm_config(mipi_dsi_gpio[1], GPIO_CFG_ENABLE); |
| 2807 | if (rc) { |
| 2808 | pr_err("Failed to enable LCDC Bridge pd enable\n"); |
| 2809 | goto gpio_error2; |
| 2810 | } |
| 2811 | |
| 2812 | rc = gpio_direction_output(GPIO_LCDC_BRDG_RESET_N, 1); |
| 2813 | rc |= gpio_direction_output(GPIO_LCDC_BRDG_PD, 1); |
| 2814 | gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 0); |
| 2815 | |
| 2816 | if (!rc) { |
Trilok Soni | 3d0f6c5 | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 2817 | if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf()) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2818 | lcdc_reset_ptr = ioremap_nocache(LCDC_RESET_PHYS, |
| 2819 | sizeof(uint32_t)); |
| 2820 | |
| 2821 | if (!lcdc_reset_ptr) |
| 2822 | return 0; |
| 2823 | } |
| 2824 | return rc; |
| 2825 | } else { |
| 2826 | goto gpio_error; |
| 2827 | } |
| 2828 | |
| 2829 | gpio_error2: |
| 2830 | pr_err("Failed GPIO bridge pd\n"); |
| 2831 | gpio_free(GPIO_LCDC_BRDG_PD); |
| 2832 | |
| 2833 | gpio_error: |
| 2834 | pr_err("Failed GPIO bridge reset\n"); |
| 2835 | gpio_free(GPIO_LCDC_BRDG_RESET_N); |
| 2836 | return rc; |
| 2837 | } |
| 2838 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 2839 | static struct regulator_bulk_data regs_dsi[] = { |
| 2840 | { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 }, |
| 2841 | { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 }, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2842 | }; |
| 2843 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2844 | static int dsi_gpio_initialized; |
| 2845 | |
| 2846 | static int mipi_dsi_panel_power(int on) |
| 2847 | { |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 2848 | int rc = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2849 | uint32_t lcdc_reset_cfg; |
| 2850 | |
| 2851 | /* I2C-controlled GPIO Expander -init of the GPIOs very late */ |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 2852 | if (unlikely(!dsi_gpio_initialized)) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2853 | pmapp_disp_backlight_init(); |
| 2854 | |
| 2855 | rc = gpio_request(GPIO_DISPLAY_PWR_EN, "gpio_disp_pwr"); |
| 2856 | if (rc < 0) { |
| 2857 | pr_err("failed to request gpio_disp_pwr\n"); |
| 2858 | return rc; |
| 2859 | } |
| 2860 | |
Trilok Soni | 3d0f6c5 | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 2861 | if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf()) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2862 | rc = gpio_direction_output(GPIO_DISPLAY_PWR_EN, 1); |
| 2863 | if (rc < 0) { |
| 2864 | pr_err("failed to enable display pwr\n"); |
| 2865 | goto fail_gpio1; |
| 2866 | } |
| 2867 | |
| 2868 | rc = gpio_request(GPIO_BACKLIGHT_EN, "gpio_bkl_en"); |
| 2869 | if (rc < 0) { |
| 2870 | pr_err("failed to request gpio_bkl_en\n"); |
| 2871 | goto fail_gpio1; |
| 2872 | } |
| 2873 | |
| 2874 | rc = gpio_direction_output(GPIO_BACKLIGHT_EN, 1); |
| 2875 | if (rc < 0) { |
| 2876 | pr_err("failed to enable backlight\n"); |
| 2877 | goto fail_gpio2; |
| 2878 | } |
| 2879 | } |
| 2880 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 2881 | rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_dsi), regs_dsi); |
| 2882 | if (rc) { |
| 2883 | pr_err("%s: could not get regulators: %d\n", |
| 2884 | __func__, rc); |
| 2885 | goto fail_gpio2; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2886 | } |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 2887 | |
| 2888 | rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_dsi), regs_dsi); |
| 2889 | if (rc) { |
| 2890 | pr_err("%s: could not set voltages: %d\n", |
| 2891 | __func__, rc); |
| 2892 | goto fail_vreg; |
| 2893 | } |
| 2894 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2895 | dsi_gpio_initialized = 1; |
| 2896 | } |
| 2897 | |
Trilok Soni | 3d0f6c5 | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 2898 | if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf()) { |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 2899 | gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, on); |
| 2900 | gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, on); |
Trilok Soni | 3d0f6c5 | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 2901 | } else if (machine_is_msm7x27a_ffa() || |
| 2902 | machine_is_msm7625a_ffa()) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2903 | if (on) { |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 2904 | /* This line drives an active low pin on FFA */ |
| 2905 | rc = gpio_direction_output(GPIO_DISPLAY_PWR_EN, !on); |
| 2906 | if (rc < 0) |
| 2907 | pr_err("failed to set direction for " |
| 2908 | "display pwr\n"); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2909 | } else { |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 2910 | gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, !on); |
| 2911 | rc = gpio_direction_input(GPIO_DISPLAY_PWR_EN); |
| 2912 | if (rc < 0) |
| 2913 | pr_err("failed to set direction for " |
| 2914 | "display pwr\n"); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2915 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2916 | } |
| 2917 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 2918 | if (on) { |
| 2919 | gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 0); |
| 2920 | |
Trilok Soni | 3d0f6c5 | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 2921 | if (machine_is_msm7x27a_surf() || |
| 2922 | machine_is_msm7625a_surf()) { |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 2923 | lcdc_reset_cfg = readl_relaxed(lcdc_reset_ptr); |
| 2924 | rmb(); |
| 2925 | lcdc_reset_cfg &= ~1; |
| 2926 | |
| 2927 | writel_relaxed(lcdc_reset_cfg, lcdc_reset_ptr); |
| 2928 | msleep(20); |
| 2929 | wmb(); |
| 2930 | lcdc_reset_cfg |= 1; |
| 2931 | writel_relaxed(lcdc_reset_cfg, lcdc_reset_ptr); |
| 2932 | } else { |
| 2933 | gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 0); |
| 2934 | msleep(20); |
| 2935 | gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1); |
| 2936 | } |
| 2937 | |
| 2938 | if (pmapp_disp_backlight_set_brightness(100)) |
| 2939 | pr_err("backlight set brightness failed\n"); |
| 2940 | } else { |
| 2941 | gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 1); |
| 2942 | |
| 2943 | if (pmapp_disp_backlight_set_brightness(0)) |
| 2944 | pr_err("backlight set brightness failed\n"); |
| 2945 | } |
| 2946 | |
| 2947 | rc = on ? regulator_bulk_enable(ARRAY_SIZE(regs_dsi), regs_dsi) : |
| 2948 | regulator_bulk_disable(ARRAY_SIZE(regs_dsi), regs_dsi); |
| 2949 | |
| 2950 | if (rc) |
| 2951 | pr_err("%s: could not %sable regulators: %d\n", |
| 2952 | __func__, on ? "en" : "dis", rc); |
| 2953 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2954 | return rc; |
| 2955 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 2956 | fail_vreg: |
| 2957 | regulator_bulk_free(ARRAY_SIZE(regs_dsi), regs_dsi); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2958 | fail_gpio2: |
| 2959 | gpio_free(GPIO_BACKLIGHT_EN); |
| 2960 | fail_gpio1: |
| 2961 | gpio_free(GPIO_DISPLAY_PWR_EN); |
| 2962 | dsi_gpio_initialized = 0; |
| 2963 | return rc; |
| 2964 | } |
Pankaj Kumar | ffdaec8 | 2011-09-26 12:24:45 +0530 | [diff] [blame] | 2965 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2966 | |
| 2967 | #define MDP_303_VSYNC_GPIO 97 |
| 2968 | |
| 2969 | #ifdef CONFIG_FB_MSM_MDP303 |
| 2970 | static struct mipi_dsi_platform_data mipi_dsi_pdata = { |
| 2971 | .vsync_gpio = MDP_303_VSYNC_GPIO, |
| 2972 | .dsi_power_save = mipi_dsi_panel_power, |
| 2973 | .dsi_client_reset = msm_fb_dsi_client_reset, |
| 2974 | .get_lane_config = msm_fb_get_lane_config, |
| 2975 | }; |
| 2976 | #endif |
| 2977 | |
| 2978 | static void __init msm_fb_add_devices(void) |
| 2979 | { |
| 2980 | msm_fb_register_device("mdp", &mdp_pdata); |
| 2981 | msm_fb_register_device("lcdc", &lcdc_pdata); |
Pankaj Kumar | ffdaec8 | 2011-09-26 12:24:45 +0530 | [diff] [blame] | 2982 | #ifdef CONFIG_FB_MSM_MDP303 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2983 | msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata); |
Pankaj Kumar | ffdaec8 | 2011-09-26 12:24:45 +0530 | [diff] [blame] | 2984 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2985 | } |
| 2986 | |
| 2987 | #define MSM_EBI2_PHYS 0xa0d00000 |
| 2988 | #define MSM_EBI2_XMEM_CS2_CFG1 0xa0d10030 |
| 2989 | |
| 2990 | static void __init msm7x27a_init_ebi2(void) |
| 2991 | { |
| 2992 | uint32_t ebi2_cfg; |
| 2993 | void __iomem *ebi2_cfg_ptr; |
| 2994 | |
| 2995 | ebi2_cfg_ptr = ioremap_nocache(MSM_EBI2_PHYS, sizeof(uint32_t)); |
| 2996 | if (!ebi2_cfg_ptr) |
| 2997 | return; |
| 2998 | |
| 2999 | ebi2_cfg = readl(ebi2_cfg_ptr); |
Trilok Soni | 3d0f6c5 | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 3000 | if (machine_is_msm7x27a_rumi3() || machine_is_msm7x27a_surf() || |
| 3001 | machine_is_msm7625a_surf()) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3002 | ebi2_cfg |= (1 << 4); /* CS2 */ |
| 3003 | |
| 3004 | writel(ebi2_cfg, ebi2_cfg_ptr); |
| 3005 | iounmap(ebi2_cfg_ptr); |
| 3006 | |
| 3007 | /* Enable A/D MUX[bit 31] from EBI2_XMEM_CS2_CFG1 */ |
| 3008 | ebi2_cfg_ptr = ioremap_nocache(MSM_EBI2_XMEM_CS2_CFG1, |
| 3009 | sizeof(uint32_t)); |
| 3010 | if (!ebi2_cfg_ptr) |
| 3011 | return; |
| 3012 | |
| 3013 | ebi2_cfg = readl(ebi2_cfg_ptr); |
Trilok Soni | 3d0f6c5 | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 3014 | if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf()) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3015 | ebi2_cfg |= (1 << 31); |
| 3016 | |
| 3017 | writel(ebi2_cfg, ebi2_cfg_ptr); |
| 3018 | iounmap(ebi2_cfg_ptr); |
| 3019 | } |
| 3020 | |
| 3021 | #define ATMEL_TS_I2C_NAME "maXTouch" |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 3022 | |
| 3023 | static struct regulator_bulk_data regs_atmel[] = { |
| 3024 | { .supply = "ldo2", .min_uV = 2850000, .max_uV = 2850000 }, |
| 3025 | { .supply = "smps3", .min_uV = 1800000, .max_uV = 1800000 }, |
| 3026 | }; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3027 | |
| 3028 | #define ATMEL_TS_GPIO_IRQ 82 |
| 3029 | |
| 3030 | static int atmel_ts_power_on(bool on) |
| 3031 | { |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 3032 | int rc = on ? |
| 3033 | regulator_bulk_enable(ARRAY_SIZE(regs_atmel), regs_atmel) : |
| 3034 | regulator_bulk_disable(ARRAY_SIZE(regs_atmel), regs_atmel); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3035 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 3036 | if (rc) |
| 3037 | pr_err("%s: could not %sable regulators: %d\n", |
| 3038 | __func__, on ? "en" : "dis", rc); |
| 3039 | else |
| 3040 | msleep(50); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3041 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 3042 | return rc; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3043 | } |
| 3044 | |
| 3045 | static int atmel_ts_platform_init(struct i2c_client *client) |
| 3046 | { |
| 3047 | int rc; |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 3048 | struct device *dev = &client->dev; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3049 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 3050 | rc = regulator_bulk_get(dev, ARRAY_SIZE(regs_atmel), regs_atmel); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3051 | if (rc) { |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 3052 | dev_err(dev, "%s: could not get regulators: %d\n", |
| 3053 | __func__, rc); |
| 3054 | goto out; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3055 | } |
| 3056 | |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 3057 | rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_atmel), regs_atmel); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3058 | if (rc) { |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 3059 | dev_err(dev, "%s: could not set voltages: %d\n", |
| 3060 | __func__, rc); |
| 3061 | goto reg_free; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3062 | } |
| 3063 | |
| 3064 | rc = gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0, |
| 3065 | GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, |
| 3066 | GPIO_CFG_8MA), GPIO_CFG_ENABLE); |
| 3067 | if (rc) { |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 3068 | dev_err(dev, "%s: gpio_tlmm_config for %d failed\n", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3069 | __func__, ATMEL_TS_GPIO_IRQ); |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 3070 | goto reg_free; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3071 | } |
| 3072 | |
| 3073 | /* configure touchscreen interrupt gpio */ |
| 3074 | rc = gpio_request(ATMEL_TS_GPIO_IRQ, "atmel_maxtouch_gpio"); |
| 3075 | if (rc) { |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 3076 | dev_err(dev, "%s: unable to request gpio %d\n", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3077 | __func__, ATMEL_TS_GPIO_IRQ); |
| 3078 | goto ts_gpio_tlmm_unconfig; |
| 3079 | } |
| 3080 | |
| 3081 | rc = gpio_direction_input(ATMEL_TS_GPIO_IRQ); |
| 3082 | if (rc < 0) { |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 3083 | dev_err(dev, "%s: unable to set the direction of gpio %d\n", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3084 | __func__, ATMEL_TS_GPIO_IRQ); |
| 3085 | goto free_ts_gpio; |
| 3086 | } |
| 3087 | return 0; |
| 3088 | |
| 3089 | free_ts_gpio: |
| 3090 | gpio_free(ATMEL_TS_GPIO_IRQ); |
| 3091 | ts_gpio_tlmm_unconfig: |
| 3092 | gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0, |
| 3093 | GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, |
| 3094 | GPIO_CFG_2MA), GPIO_CFG_DISABLE); |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 3095 | reg_free: |
| 3096 | regulator_bulk_free(ARRAY_SIZE(regs_atmel), regs_atmel); |
| 3097 | out: |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3098 | return rc; |
| 3099 | } |
| 3100 | |
| 3101 | static int atmel_ts_platform_exit(struct i2c_client *client) |
| 3102 | { |
| 3103 | gpio_free(ATMEL_TS_GPIO_IRQ); |
| 3104 | gpio_tlmm_config(GPIO_CFG(ATMEL_TS_GPIO_IRQ, 0, |
| 3105 | GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, |
| 3106 | GPIO_CFG_2MA), GPIO_CFG_DISABLE); |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 3107 | regulator_bulk_free(ARRAY_SIZE(regs_atmel), regs_atmel); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3108 | return 0; |
| 3109 | } |
| 3110 | |
| 3111 | static u8 atmel_ts_read_chg(void) |
| 3112 | { |
| 3113 | return gpio_get_value(ATMEL_TS_GPIO_IRQ); |
| 3114 | } |
| 3115 | |
| 3116 | static u8 atmel_ts_valid_interrupt(void) |
| 3117 | { |
| 3118 | return !atmel_ts_read_chg(); |
| 3119 | } |
| 3120 | |
| 3121 | #define ATMEL_X_OFFSET 13 |
| 3122 | #define ATMEL_Y_OFFSET 0 |
| 3123 | |
Mohan Pallaka | 4e9a94e | 2011-11-23 16:34:21 +0530 | [diff] [blame] | 3124 | static struct maxtouch_platform_data atmel_ts_pdata = { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3125 | .numtouch = 4, |
| 3126 | .init_platform_hw = atmel_ts_platform_init, |
| 3127 | .exit_platform_hw = atmel_ts_platform_exit, |
| 3128 | .power_on = atmel_ts_power_on, |
| 3129 | .display_res_x = 480, |
| 3130 | .display_res_y = 864, |
| 3131 | .min_x = ATMEL_X_OFFSET, |
| 3132 | .max_x = (505 - ATMEL_X_OFFSET), |
| 3133 | .min_y = ATMEL_Y_OFFSET, |
| 3134 | .max_y = (863 - ATMEL_Y_OFFSET), |
| 3135 | .valid_interrupt = atmel_ts_valid_interrupt, |
| 3136 | .read_chg = atmel_ts_read_chg, |
| 3137 | }; |
| 3138 | |
| 3139 | static struct i2c_board_info atmel_ts_i2c_info[] __initdata = { |
| 3140 | { |
| 3141 | I2C_BOARD_INFO(ATMEL_TS_I2C_NAME, 0x4a), |
| 3142 | .platform_data = &atmel_ts_pdata, |
| 3143 | .irq = MSM_GPIO_TO_INT(ATMEL_TS_GPIO_IRQ), |
| 3144 | }, |
| 3145 | }; |
| 3146 | |
| 3147 | #define KP_INDEX(row, col) ((row)*ARRAY_SIZE(kp_col_gpios) + (col)) |
| 3148 | |
| 3149 | static unsigned int kp_row_gpios[] = {31, 32, 33, 34, 35}; |
| 3150 | static unsigned int kp_col_gpios[] = {36, 37, 38, 39, 40}; |
| 3151 | |
| 3152 | static const unsigned short keymap[ARRAY_SIZE(kp_col_gpios) * |
| 3153 | ARRAY_SIZE(kp_row_gpios)] = { |
| 3154 | [KP_INDEX(0, 0)] = KEY_7, |
| 3155 | [KP_INDEX(0, 1)] = KEY_DOWN, |
| 3156 | [KP_INDEX(0, 2)] = KEY_UP, |
| 3157 | [KP_INDEX(0, 3)] = KEY_RIGHT, |
| 3158 | [KP_INDEX(0, 4)] = KEY_ENTER, |
| 3159 | |
| 3160 | [KP_INDEX(1, 0)] = KEY_LEFT, |
| 3161 | [KP_INDEX(1, 1)] = KEY_SEND, |
| 3162 | [KP_INDEX(1, 2)] = KEY_1, |
| 3163 | [KP_INDEX(1, 3)] = KEY_4, |
| 3164 | [KP_INDEX(1, 4)] = KEY_CLEAR, |
| 3165 | |
| 3166 | [KP_INDEX(2, 0)] = KEY_6, |
| 3167 | [KP_INDEX(2, 1)] = KEY_5, |
| 3168 | [KP_INDEX(2, 2)] = KEY_8, |
| 3169 | [KP_INDEX(2, 3)] = KEY_3, |
| 3170 | [KP_INDEX(2, 4)] = KEY_NUMERIC_STAR, |
| 3171 | |
| 3172 | [KP_INDEX(3, 0)] = KEY_9, |
| 3173 | [KP_INDEX(3, 1)] = KEY_NUMERIC_POUND, |
| 3174 | [KP_INDEX(3, 2)] = KEY_0, |
| 3175 | [KP_INDEX(3, 3)] = KEY_2, |
| 3176 | [KP_INDEX(3, 4)] = KEY_SLEEP, |
| 3177 | |
| 3178 | [KP_INDEX(4, 0)] = KEY_BACK, |
| 3179 | [KP_INDEX(4, 1)] = KEY_HOME, |
| 3180 | [KP_INDEX(4, 2)] = KEY_MENU, |
| 3181 | [KP_INDEX(4, 3)] = KEY_VOLUMEUP, |
| 3182 | [KP_INDEX(4, 4)] = KEY_VOLUMEDOWN, |
| 3183 | }; |
| 3184 | |
| 3185 | /* SURF keypad platform device information */ |
| 3186 | static struct gpio_event_matrix_info kp_matrix_info = { |
| 3187 | .info.func = gpio_event_matrix_func, |
| 3188 | .keymap = keymap, |
| 3189 | .output_gpios = kp_row_gpios, |
| 3190 | .input_gpios = kp_col_gpios, |
| 3191 | .noutputs = ARRAY_SIZE(kp_row_gpios), |
| 3192 | .ninputs = ARRAY_SIZE(kp_col_gpios), |
| 3193 | .settle_time.tv_nsec = 40 * NSEC_PER_USEC, |
| 3194 | .poll_time.tv_nsec = 20 * NSEC_PER_MSEC, |
| 3195 | .flags = GPIOKPF_LEVEL_TRIGGERED_IRQ | GPIOKPF_DRIVE_INACTIVE | |
| 3196 | GPIOKPF_PRINT_UNMAPPED_KEYS, |
| 3197 | }; |
| 3198 | |
| 3199 | static struct gpio_event_info *kp_info[] = { |
| 3200 | &kp_matrix_info.info |
| 3201 | }; |
| 3202 | |
| 3203 | static struct gpio_event_platform_data kp_pdata = { |
| 3204 | .name = "7x27a_kp", |
| 3205 | .info = kp_info, |
| 3206 | .info_count = ARRAY_SIZE(kp_info) |
| 3207 | }; |
| 3208 | |
| 3209 | static struct platform_device kp_pdev = { |
| 3210 | .name = GPIO_EVENT_DEV_NAME, |
| 3211 | .id = -1, |
| 3212 | .dev = { |
| 3213 | .platform_data = &kp_pdata, |
| 3214 | }, |
| 3215 | }; |
| 3216 | |
| 3217 | static struct msm_handset_platform_data hs_platform_data = { |
| 3218 | .hs_name = "7k_handset", |
| 3219 | .pwr_key_delay_ms = 500, /* 0 will disable end key */ |
| 3220 | }; |
| 3221 | |
| 3222 | static struct platform_device hs_pdev = { |
| 3223 | .name = "msm-handset", |
| 3224 | .id = -1, |
| 3225 | .dev = { |
| 3226 | .platform_data = &hs_platform_data, |
| 3227 | }, |
| 3228 | }; |
| 3229 | |
Justin Paupore | b3a33b7 | 2011-08-23 15:30:32 -0700 | [diff] [blame] | 3230 | static struct platform_device msm_proccomm_regulator_dev = { |
| 3231 | .name = PROCCOMM_REGULATOR_DEV_NAME, |
| 3232 | .id = -1, |
| 3233 | .dev = { |
| 3234 | .platform_data = &msm7x27a_proccomm_regulator_data |
| 3235 | } |
| 3236 | }; |
| 3237 | |
Trilok Soni | 16f61af | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 3238 | static void __init msm7627a_rumi3_init(void) |
| 3239 | { |
| 3240 | msm7x27a_init_ebi2(); |
| 3241 | platform_add_devices(rumi_sim_devices, |
| 3242 | ARRAY_SIZE(rumi_sim_devices)); |
| 3243 | } |
| 3244 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3245 | #define LED_GPIO_PDM 96 |
| 3246 | #define UART1DM_RX_GPIO 45 |
Santosh Sajjan | b479f0f | 2011-08-18 21:00:44 +0530 | [diff] [blame] | 3247 | |
| 3248 | #if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE) |
| 3249 | static int __init msm7x27a_init_ar6000pm(void) |
| 3250 | { |
| 3251 | return platform_device_register(&msm_wlan_ar6000_pm_device); |
| 3252 | } |
| 3253 | #else |
| 3254 | static int __init msm7x27a_init_ar6000pm(void) { return 0; } |
| 3255 | #endif |
| 3256 | |
Justin Paupore | b3a33b7 | 2011-08-23 15:30:32 -0700 | [diff] [blame] | 3257 | static void __init msm7x27a_init_regulators(void) |
| 3258 | { |
| 3259 | int rc = platform_device_register(&msm_proccomm_regulator_dev); |
| 3260 | if (rc) |
| 3261 | pr_err("%s: could not register regulator device: %d\n", |
| 3262 | __func__, rc); |
| 3263 | } |
| 3264 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3265 | static void __init msm7x2x_init(void) |
| 3266 | { |
Trilok Soni | a416c49 | 2011-07-22 20:20:23 +0530 | [diff] [blame] | 3267 | msm7x2x_misc_init(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3268 | |
Justin Paupore | b3a33b7 | 2011-08-23 15:30:32 -0700 | [diff] [blame] | 3269 | /* Initialize regulators first so that other devices can use them */ |
| 3270 | msm7x27a_init_regulators(); |
| 3271 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3272 | /* Common functions for SURF/FFA/RUMI3 */ |
| 3273 | msm_device_i2c_init(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3274 | msm7x27a_init_ebi2(); |
| 3275 | msm7x27a_cfg_uart2dm_serial(); |
| 3276 | #ifdef CONFIG_SERIAL_MSM_HS |
| 3277 | msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(UART1DM_RX_GPIO); |
| 3278 | msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata; |
| 3279 | #endif |
| 3280 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3281 | #ifdef CONFIG_USB_MSM_OTG_72K |
Trilok Soni | 16f61af | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 3282 | msm_otg_pdata.swfi_latency = |
| 3283 | msm7x27a_pm_data |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3284 | [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency; |
Trilok Soni | 16f61af | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 3285 | msm_device_otg.dev.platform_data = &msm_otg_pdata; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3286 | #endif |
Trilok Soni | 16f61af | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 3287 | msm_device_gadget_peripheral.dev.platform_data = |
| 3288 | &msm_gadget_pdata; |
| 3289 | msm7x27a_cfg_smsc911x(); |
| 3290 | platform_add_devices(msm_footswitch_devices, |
| 3291 | msm_num_footswitch_devices); |
| 3292 | platform_add_devices(surf_ffa_devices, |
| 3293 | ARRAY_SIZE(surf_ffa_devices)); |
Sujith Reddy Thumma | ad7c9a8 | 2011-09-30 20:54:38 +0530 | [diff] [blame] | 3294 | /* Ensure ar6000pm device is registered before MMC/SDC */ |
| 3295 | msm7x27a_init_ar6000pm(); |
| 3296 | #ifdef CONFIG_MMC_MSM |
| 3297 | msm7x27a_init_mmc(); |
| 3298 | #endif |
Trilok Soni | 16f61af | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 3299 | msm_fb_add_devices(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3300 | #ifdef CONFIG_USB_EHCI_MSM_72K |
Trilok Soni | 16f61af | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 3301 | msm7x2x_init_host(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3302 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3303 | |
| 3304 | msm_pm_set_platform_data(msm7x27a_pm_data, |
| 3305 | ARRAY_SIZE(msm7x27a_pm_data)); |
Maheshkumar Sivasubramanian | 8ccc16e | 2011-10-25 15:59:57 -0600 | [diff] [blame] | 3306 | BUG_ON(msm_pm_boot_init(MSM_PM_BOOT_CONFIG_RESET_VECTOR, |
| 3307 | ioremap(0, PAGE_SIZE))); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3308 | |
| 3309 | #if defined(CONFIG_I2C) && defined(CONFIG_GPIO_SX150X) |
| 3310 | register_i2c_devices(); |
| 3311 | #endif |
| 3312 | #if defined(CONFIG_BT) && defined(CONFIG_MARIMBA_CORE) |
| 3313 | bt_power_init(); |
| 3314 | #endif |
Trilok Soni | 3d0f6c5 | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 3315 | if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3316 | atmel_ts_pdata.min_x = 0; |
| 3317 | atmel_ts_pdata.max_x = 480; |
| 3318 | atmel_ts_pdata.min_y = 0; |
| 3319 | atmel_ts_pdata.max_y = 320; |
| 3320 | } |
| 3321 | |
| 3322 | i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID, |
| 3323 | atmel_ts_i2c_info, |
| 3324 | ARRAY_SIZE(atmel_ts_i2c_info)); |
| 3325 | |
Pankaj Kumar | 5be2a3e | 2011-09-26 11:45:02 +0530 | [diff] [blame] | 3326 | #if defined(CONFIG_MSM_CAMERA) |
Justin Paupore | d98328e | 2011-08-19 13:48:31 -0700 | [diff] [blame] | 3327 | msm_camera_vreg_init(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3328 | i2c_register_board_info(MSM_GSBI0_QUP_I2C_BUS_ID, |
| 3329 | i2c_camera_devices, |
| 3330 | ARRAY_SIZE(i2c_camera_devices)); |
Pankaj Kumar | 5be2a3e | 2011-09-26 11:45:02 +0530 | [diff] [blame] | 3331 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3332 | platform_device_register(&kp_pdev); |
| 3333 | platform_device_register(&hs_pdev); |
| 3334 | |
| 3335 | /* configure it as a pdm function*/ |
| 3336 | if (gpio_tlmm_config(GPIO_CFG(LED_GPIO_PDM, 3, |
| 3337 | GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, |
| 3338 | GPIO_CFG_8MA), GPIO_CFG_ENABLE)) |
| 3339 | pr_err("%s: gpio_tlmm_config for %d failed\n", |
| 3340 | __func__, LED_GPIO_PDM); |
| 3341 | else |
| 3342 | platform_device_register(&led_pdev); |
| 3343 | |
| 3344 | #ifdef CONFIG_MSM_RPC_VIBRATOR |
Trilok Soni | 3d0f6c5 | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 3345 | if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3346 | msm_init_pmic_vibrator(); |
| 3347 | #endif |
| 3348 | /*7x25a kgsl initializations*/ |
| 3349 | msm7x25a_kgsl_3d0_init(); |
| 3350 | } |
| 3351 | |
| 3352 | static void __init msm7x2x_init_early(void) |
| 3353 | { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3354 | msm_msm7x2x_allocate_memory_regions(); |
| 3355 | } |
| 3356 | |
| 3357 | MACHINE_START(MSM7X27A_RUMI3, "QCT MSM7x27a RUMI3") |
| 3358 | .boot_params = PHYS_OFFSET + 0x100, |
| 3359 | .map_io = msm_common_io_init, |
| 3360 | .reserve = msm7x27a_reserve, |
| 3361 | .init_irq = msm_init_irq, |
Trilok Soni | 16f61af | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 3362 | .init_machine = msm7627a_rumi3_init, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3363 | .timer = &msm_timer, |
| 3364 | .init_early = msm7x2x_init_early, |
Taniya Das | 86e0e13 | 2011-10-19 11:32:00 +0530 | [diff] [blame] | 3365 | .handle_irq = vic_handle_irq, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3366 | MACHINE_END |
| 3367 | MACHINE_START(MSM7X27A_SURF, "QCT MSM7x27a SURF") |
| 3368 | .boot_params = PHYS_OFFSET + 0x100, |
| 3369 | .map_io = msm_common_io_init, |
| 3370 | .reserve = msm7x27a_reserve, |
| 3371 | .init_irq = msm_init_irq, |
| 3372 | .init_machine = msm7x2x_init, |
| 3373 | .timer = &msm_timer, |
| 3374 | .init_early = msm7x2x_init_early, |
Taniya Das | 86e0e13 | 2011-10-19 11:32:00 +0530 | [diff] [blame] | 3375 | .handle_irq = vic_handle_irq, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3376 | MACHINE_END |
| 3377 | MACHINE_START(MSM7X27A_FFA, "QCT MSM7x27a FFA") |
| 3378 | .boot_params = PHYS_OFFSET + 0x100, |
| 3379 | .map_io = msm_common_io_init, |
| 3380 | .reserve = msm7x27a_reserve, |
| 3381 | .init_irq = msm_init_irq, |
| 3382 | .init_machine = msm7x2x_init, |
| 3383 | .timer = &msm_timer, |
| 3384 | .init_early = msm7x2x_init_early, |
Taniya Das | 86e0e13 | 2011-10-19 11:32:00 +0530 | [diff] [blame] | 3385 | .handle_irq = vic_handle_irq, |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 3386 | MACHINE_END |
Trilok Soni | 3d0f6c5 | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 3387 | MACHINE_START(MSM7625A_SURF, "QCT MSM7625a SURF") |
| 3388 | .boot_params = PHYS_OFFSET + 0x100, |
| 3389 | .map_io = msm_common_io_init, |
| 3390 | .reserve = msm7x27a_reserve, |
| 3391 | .init_irq = msm_init_irq, |
| 3392 | .init_machine = msm7x2x_init, |
| 3393 | .timer = &msm_timer, |
| 3394 | .init_early = msm7x2x_init_early, |
Taniya Das | 86e0e13 | 2011-10-19 11:32:00 +0530 | [diff] [blame] | 3395 | .handle_irq = vic_handle_irq, |
Trilok Soni | 3d0f6c5 | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 3396 | MACHINE_END |
| 3397 | MACHINE_START(MSM7625A_FFA, "QCT MSM7625a FFA") |
| 3398 | .boot_params = PHYS_OFFSET + 0x100, |
| 3399 | .map_io = msm_common_io_init, |
| 3400 | .reserve = msm7x27a_reserve, |
| 3401 | .init_irq = msm_init_irq, |
| 3402 | .init_machine = msm7x2x_init, |
| 3403 | .timer = &msm_timer, |
| 3404 | .init_early = msm7x2x_init_early, |
Taniya Das | 86e0e13 | 2011-10-19 11:32:00 +0530 | [diff] [blame] | 3405 | .handle_irq = vic_handle_irq, |
Trilok Soni | 3d0f6c5 | 2011-07-26 16:06:58 +0530 | [diff] [blame] | 3406 | MACHINE_END |