Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2012, Code Aurora Forum. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | */ |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/ioport.h> |
| 15 | #include <linux/platform_device.h> |
| 16 | #include <linux/bootmem.h> |
| 17 | #include <linux/regulator/consumer.h> |
| 18 | #include <asm/mach-types.h> |
| 19 | #include <asm/io.h> |
| 20 | #include <mach/msm_bus_board.h> |
| 21 | #include <mach/msm_memtypes.h> |
| 22 | #include <mach/board.h> |
| 23 | #include <mach/gpio.h> |
| 24 | #include <mach/gpiomux.h> |
| 25 | #include <mach/socinfo.h> |
| 26 | #include <mach/rpc_pmapp.h> |
| 27 | #include "devices.h" |
| 28 | #include "board-msm7627a.h" |
| 29 | |
| 30 | #ifdef CONFIG_FB_MSM_TRIPLE_BUFFER |
Padmanabhan Komanduru | ede0a63 | 2012-01-25 12:01:28 +0530 | [diff] [blame] | 31 | #define MSM_FB_SIZE 0x261000 |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 32 | #define MSM7x25A_MSM_FB_SIZE 0xE1000 |
| 33 | #else |
Padmanabhan Komanduru | ede0a63 | 2012-01-25 12:01:28 +0530 | [diff] [blame] | 34 | #define MSM_FB_SIZE 0x196000 |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 35 | #define MSM7x25A_MSM_FB_SIZE 0x96000 |
| 36 | #endif |
| 37 | |
Alhad Purnapatre | c55856c | 2012-02-28 13:24:57 -0800 | [diff] [blame^] | 38 | /* |
| 39 | * Reserve enough v4l2 space for a double buffered full screen |
| 40 | * res image (864x480x1.5x2) |
| 41 | */ |
| 42 | #define MSM_V4L2_VIDEO_OVERLAY_BUF_SIZE 1244160 |
| 43 | |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 44 | static unsigned fb_size = MSM_FB_SIZE; |
| 45 | static int __init fb_size_setup(char *p) |
| 46 | { |
| 47 | fb_size = memparse(p, NULL); |
| 48 | return 0; |
| 49 | } |
| 50 | |
| 51 | early_param("fb_size", fb_size_setup); |
| 52 | |
Jeevan Shriram | 901a15f | 2012-03-09 11:53:23 +0530 | [diff] [blame] | 53 | static uint32_t lcdc_truly_gpio_initialized; |
| 54 | static struct regulator_bulk_data regs_truly_lcdc[] = { |
| 55 | { .supply = "rfrx1", .min_uV = 1800000, .max_uV = 1800000 }, |
| 56 | }; |
| 57 | |
| 58 | #define SKU3_LCDC_GPIO_DISPLAY_RESET 90 |
| 59 | #define SKU3_LCDC_GPIO_SPI_MOSI 19 |
| 60 | #define SKU3_LCDC_GPIO_SPI_CLK 20 |
| 61 | #define SKU3_LCDC_GPIO_SPI_CS0_N 21 |
| 62 | #define SKU3_LCDC_LCD_CAMERA_LDO_2V8 35 /*LCD_CAMERA_LDO_2V8*/ |
| 63 | #define SKU3_LCDC_LCD_CAMERA_LDO_1V8 34 /*LCD_CAMERA_LDO_1V8*/ |
| 64 | #define SKU3_1_LCDC_LCD_CAMERA_LDO_1V8 58 /*LCD_CAMERA_LDO_1V8*/ |
| 65 | |
| 66 | static uint32_t lcdc_truly_gpio_table[] = { |
| 67 | 19, |
| 68 | 20, |
| 69 | 21, |
| 70 | 89, |
| 71 | 90, |
| 72 | }; |
| 73 | |
| 74 | static char *lcdc_gpio_name_table[5] = { |
| 75 | "spi_mosi", |
| 76 | "spi_clk", |
| 77 | "spi_cs", |
| 78 | "gpio_bkl_en", |
| 79 | "gpio_disp_reset", |
| 80 | }; |
| 81 | |
| 82 | static int lcdc_truly_gpio_init(void) |
| 83 | { |
| 84 | int i; |
| 85 | int rc = 0; |
| 86 | |
| 87 | if (!lcdc_truly_gpio_initialized) { |
| 88 | for (i = 0; i < ARRAY_SIZE(lcdc_truly_gpio_table); i++) { |
| 89 | rc = gpio_request(lcdc_truly_gpio_table[i], |
| 90 | lcdc_gpio_name_table[i]); |
| 91 | if (rc < 0) { |
| 92 | pr_err("Error request gpio %s\n", |
| 93 | lcdc_gpio_name_table[i]); |
| 94 | goto truly_gpio_fail; |
| 95 | } |
| 96 | rc = gpio_tlmm_config(GPIO_CFG(lcdc_truly_gpio_table[i], |
| 97 | 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, |
| 98 | GPIO_CFG_2MA), GPIO_CFG_ENABLE); |
| 99 | if (rc < 0) { |
| 100 | pr_err("Error config lcdc gpio:%d\n", |
| 101 | lcdc_truly_gpio_table[i]); |
| 102 | goto truly_gpio_fail; |
| 103 | } |
| 104 | rc = gpio_direction_output(lcdc_truly_gpio_table[i], 0); |
| 105 | if (rc < 0) { |
| 106 | pr_err("Error direct lcdc gpio:%d\n", |
| 107 | lcdc_truly_gpio_table[i]); |
| 108 | goto truly_gpio_fail; |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | lcdc_truly_gpio_initialized = 1; |
| 113 | } |
| 114 | |
| 115 | return rc; |
| 116 | |
| 117 | truly_gpio_fail: |
| 118 | for (; i >= 0; i--) { |
| 119 | pr_err("Freeing GPIO: %d", lcdc_truly_gpio_table[i]); |
| 120 | gpio_free(lcdc_truly_gpio_table[i]); |
| 121 | } |
| 122 | |
| 123 | lcdc_truly_gpio_initialized = 0; |
| 124 | return rc; |
| 125 | } |
| 126 | |
| 127 | |
| 128 | void sku3_lcdc_lcd_camera_power_init(void) |
| 129 | { |
| 130 | int rc = 0; |
| 131 | u32 socinfo = socinfo_get_platform_type(); |
| 132 | |
| 133 | /* LDO_EXT2V8 */ |
| 134 | if (gpio_request(SKU3_LCDC_LCD_CAMERA_LDO_2V8, "lcd_camera_ldo_2v8")) { |
| 135 | pr_err("failed to request gpio lcd_camera_ldo_2v8\n"); |
| 136 | return; |
| 137 | } |
| 138 | |
| 139 | rc = gpio_tlmm_config(GPIO_CFG(SKU3_LCDC_LCD_CAMERA_LDO_2V8, 0, |
| 140 | GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 141 | GPIO_CFG_ENABLE); |
| 142 | |
| 143 | if (rc < 0) { |
| 144 | pr_err("%s:unable to enable lcd_camera_ldo_2v8!\n", __func__); |
| 145 | goto fail_gpio2; |
| 146 | } |
| 147 | |
| 148 | /* LDO_EVT1V8 */ |
| 149 | if (socinfo == 0x0B) { |
| 150 | if (gpio_request(SKU3_LCDC_LCD_CAMERA_LDO_1V8, |
| 151 | "lcd_camera_ldo_1v8")) { |
| 152 | pr_err("failed to request gpio lcd_camera_ldo_1v8\n"); |
| 153 | goto fail_gpio1; |
| 154 | } |
| 155 | |
| 156 | rc = gpio_tlmm_config(GPIO_CFG(SKU3_LCDC_LCD_CAMERA_LDO_1V8, 0, |
| 157 | GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 158 | GPIO_CFG_ENABLE); |
| 159 | |
| 160 | if (rc < 0) { |
| 161 | pr_err("%s: unable to enable lcdc_camera_ldo_1v8!\n", |
| 162 | __func__); |
| 163 | goto fail_gpio1; |
| 164 | } |
Jeevan Shriram | 045cdc7 | 2012-03-27 07:04:15 +0530 | [diff] [blame] | 165 | } else if (socinfo == 0x0F || machine_is_msm8625_qrd7()) { |
Jeevan Shriram | 901a15f | 2012-03-09 11:53:23 +0530 | [diff] [blame] | 166 | if (gpio_request(SKU3_1_LCDC_LCD_CAMERA_LDO_1V8, |
| 167 | "lcd_camera_ldo_1v8")) { |
| 168 | pr_err("failed to request gpio lcd_camera_ldo_1v8\n"); |
| 169 | goto fail_gpio1; |
| 170 | } |
| 171 | |
| 172 | rc = gpio_tlmm_config(GPIO_CFG(SKU3_1_LCDC_LCD_CAMERA_LDO_1V8, |
| 173 | 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), |
| 174 | GPIO_CFG_ENABLE); |
| 175 | |
| 176 | if (rc < 0) { |
| 177 | pr_err("%s: unable to enable lcdc_camera_ldo_1v8!\n", |
| 178 | __func__); |
| 179 | goto fail_gpio1; |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_truly_lcdc), |
| 184 | regs_truly_lcdc); |
| 185 | if (rc) |
| 186 | pr_err("%s: could not get regulators: %d\n", __func__, rc); |
| 187 | |
| 188 | rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_truly_lcdc), |
| 189 | regs_truly_lcdc); |
| 190 | if (rc) |
| 191 | pr_err("%s: could not set voltages: %d\n", __func__, rc); |
| 192 | |
| 193 | return; |
| 194 | |
| 195 | fail_gpio1: |
| 196 | if (socinfo == 0x0B) |
| 197 | gpio_free(SKU3_LCDC_LCD_CAMERA_LDO_1V8); |
Jeevan Shriram | 045cdc7 | 2012-03-27 07:04:15 +0530 | [diff] [blame] | 198 | else if (socinfo == 0x0F || machine_is_msm8625_qrd7()) |
Jeevan Shriram | 901a15f | 2012-03-09 11:53:23 +0530 | [diff] [blame] | 199 | gpio_free(SKU3_1_LCDC_LCD_CAMERA_LDO_1V8); |
| 200 | fail_gpio2: |
| 201 | gpio_free(SKU3_LCDC_LCD_CAMERA_LDO_2V8); |
| 202 | return; |
| 203 | } |
| 204 | |
| 205 | int sku3_lcdc_lcd_camera_power_onoff(int on) |
| 206 | { |
| 207 | int rc = 0; |
| 208 | u32 socinfo = socinfo_get_platform_type(); |
| 209 | |
| 210 | if (on) { |
| 211 | if (socinfo == 0x0B) |
| 212 | gpio_set_value_cansleep(SKU3_LCDC_LCD_CAMERA_LDO_1V8, |
| 213 | 1); |
Jeevan Shriram | 045cdc7 | 2012-03-27 07:04:15 +0530 | [diff] [blame] | 214 | else if (socinfo == 0x0F || machine_is_msm8625_qrd7()) |
Jeevan Shriram | 901a15f | 2012-03-09 11:53:23 +0530 | [diff] [blame] | 215 | gpio_set_value_cansleep(SKU3_1_LCDC_LCD_CAMERA_LDO_1V8, |
| 216 | 1); |
| 217 | |
| 218 | gpio_set_value_cansleep(SKU3_LCDC_LCD_CAMERA_LDO_2V8, 1); |
| 219 | |
| 220 | rc = regulator_bulk_enable(ARRAY_SIZE(regs_truly_lcdc), |
| 221 | regs_truly_lcdc); |
| 222 | if (rc) |
| 223 | pr_err("%s: could not enable regulators: %d\n", |
| 224 | __func__, rc); |
| 225 | } else { |
| 226 | if (socinfo == 0x0B) |
| 227 | gpio_set_value_cansleep(SKU3_LCDC_LCD_CAMERA_LDO_1V8, |
| 228 | 0); |
Jeevan Shriram | 045cdc7 | 2012-03-27 07:04:15 +0530 | [diff] [blame] | 229 | else if (socinfo == 0x0F || machine_is_msm8625_qrd7()) |
Jeevan Shriram | 901a15f | 2012-03-09 11:53:23 +0530 | [diff] [blame] | 230 | gpio_set_value_cansleep(SKU3_1_LCDC_LCD_CAMERA_LDO_1V8, |
| 231 | 0); |
| 232 | |
| 233 | gpio_set_value_cansleep(SKU3_LCDC_LCD_CAMERA_LDO_2V8, 0); |
| 234 | |
| 235 | rc = regulator_bulk_disable(ARRAY_SIZE(regs_truly_lcdc), |
| 236 | regs_truly_lcdc); |
| 237 | if (rc) |
| 238 | pr_err("%s: could not disable regulators: %d\n", |
| 239 | __func__, rc); |
| 240 | } |
| 241 | |
| 242 | return rc; |
| 243 | } |
| 244 | |
| 245 | static int sku3_lcdc_power_save(int on) |
| 246 | { |
| 247 | int rc = 0; |
| 248 | |
| 249 | if (on) { |
| 250 | sku3_lcdc_lcd_camera_power_onoff(1); |
| 251 | rc = lcdc_truly_gpio_init(); |
| 252 | if (rc < 0) { |
| 253 | pr_err("%s(): Truly GPIO initializations failed", |
| 254 | __func__); |
| 255 | return rc; |
| 256 | } |
| 257 | |
| 258 | if (lcdc_truly_gpio_initialized) { |
| 259 | /*LCD reset*/ |
| 260 | gpio_set_value(SKU3_LCDC_GPIO_DISPLAY_RESET, 1); |
| 261 | msleep(20); |
| 262 | gpio_set_value(SKU3_LCDC_GPIO_DISPLAY_RESET, 0); |
| 263 | msleep(20); |
| 264 | gpio_set_value(SKU3_LCDC_GPIO_DISPLAY_RESET, 1); |
| 265 | msleep(20); |
| 266 | } |
| 267 | } else { |
| 268 | /* pull down LCD IO to avoid current leakage */ |
| 269 | gpio_set_value(SKU3_LCDC_GPIO_SPI_MOSI, 0); |
| 270 | gpio_set_value(SKU3_LCDC_GPIO_SPI_CLK, 0); |
| 271 | gpio_set_value(SKU3_LCDC_GPIO_SPI_CS0_N, 0); |
| 272 | gpio_set_value(SKU3_LCDC_GPIO_DISPLAY_RESET, 0); |
| 273 | |
| 274 | sku3_lcdc_lcd_camera_power_onoff(0); |
| 275 | } |
| 276 | return rc; |
| 277 | } |
| 278 | |
| 279 | static struct msm_panel_common_pdata lcdc_truly_panel_data = { |
| 280 | .panel_config_gpio = NULL, |
| 281 | .gpio_num = lcdc_truly_gpio_table, |
| 282 | }; |
| 283 | |
| 284 | static struct platform_device lcdc_truly_panel_device = { |
| 285 | .name = "lcdc_truly_hvga_ips3p2335_pt", |
| 286 | .id = 0, |
| 287 | .dev = { |
| 288 | .platform_data = &lcdc_truly_panel_data, |
| 289 | } |
| 290 | }; |
| 291 | |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 292 | static struct regulator_bulk_data regs_lcdc[] = { |
| 293 | { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 }, |
| 294 | { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 }, |
| 295 | }; |
| 296 | static uint32_t lcdc_gpio_initialized; |
| 297 | |
| 298 | static void lcdc_toshiba_gpio_init(void) |
| 299 | { |
| 300 | int rc = 0; |
| 301 | if (!lcdc_gpio_initialized) { |
| 302 | if (gpio_request(GPIO_SPI_CLK, "spi_clk")) { |
| 303 | pr_err("failed to request gpio spi_clk\n"); |
| 304 | return; |
| 305 | } |
| 306 | if (gpio_request(GPIO_SPI_CS0_N, "spi_cs")) { |
| 307 | pr_err("failed to request gpio spi_cs0_N\n"); |
| 308 | goto fail_gpio6; |
| 309 | } |
| 310 | if (gpio_request(GPIO_SPI_MOSI, "spi_mosi")) { |
| 311 | pr_err("failed to request gpio spi_mosi\n"); |
| 312 | goto fail_gpio5; |
| 313 | } |
| 314 | if (gpio_request(GPIO_SPI_MISO, "spi_miso")) { |
| 315 | pr_err("failed to request gpio spi_miso\n"); |
| 316 | goto fail_gpio4; |
| 317 | } |
| 318 | if (gpio_request(GPIO_DISPLAY_PWR_EN, "gpio_disp_pwr")) { |
| 319 | pr_err("failed to request gpio_disp_pwr\n"); |
| 320 | goto fail_gpio3; |
| 321 | } |
| 322 | if (gpio_request(GPIO_BACKLIGHT_EN, "gpio_bkl_en")) { |
| 323 | pr_err("failed to request gpio_bkl_en\n"); |
| 324 | goto fail_gpio2; |
| 325 | } |
| 326 | pmapp_disp_backlight_init(); |
| 327 | |
| 328 | rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_lcdc), |
| 329 | regs_lcdc); |
| 330 | if (rc) { |
| 331 | pr_err("%s: could not get regulators: %d\n", |
| 332 | __func__, rc); |
| 333 | goto fail_gpio1; |
| 334 | } |
| 335 | |
| 336 | rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_lcdc), |
| 337 | regs_lcdc); |
| 338 | if (rc) { |
| 339 | pr_err("%s: could not set voltages: %d\n", |
| 340 | __func__, rc); |
| 341 | goto fail_vreg; |
| 342 | } |
| 343 | lcdc_gpio_initialized = 1; |
| 344 | } |
| 345 | return; |
| 346 | fail_vreg: |
| 347 | regulator_bulk_free(ARRAY_SIZE(regs_lcdc), regs_lcdc); |
| 348 | fail_gpio1: |
| 349 | gpio_free(GPIO_BACKLIGHT_EN); |
| 350 | fail_gpio2: |
| 351 | gpio_free(GPIO_DISPLAY_PWR_EN); |
| 352 | fail_gpio3: |
| 353 | gpio_free(GPIO_SPI_MISO); |
| 354 | fail_gpio4: |
| 355 | gpio_free(GPIO_SPI_MOSI); |
| 356 | fail_gpio5: |
| 357 | gpio_free(GPIO_SPI_CS0_N); |
| 358 | fail_gpio6: |
| 359 | gpio_free(GPIO_SPI_CLK); |
| 360 | lcdc_gpio_initialized = 0; |
| 361 | } |
| 362 | |
| 363 | static uint32_t lcdc_gpio_table[] = { |
| 364 | GPIO_SPI_CLK, |
| 365 | GPIO_SPI_CS0_N, |
| 366 | GPIO_SPI_MOSI, |
| 367 | GPIO_DISPLAY_PWR_EN, |
| 368 | GPIO_BACKLIGHT_EN, |
| 369 | GPIO_SPI_MISO, |
| 370 | }; |
| 371 | |
| 372 | static void config_lcdc_gpio_table(uint32_t *table, int len, unsigned enable) |
| 373 | { |
| 374 | int n; |
| 375 | |
| 376 | if (lcdc_gpio_initialized) { |
| 377 | /* All are IO Expander GPIOs */ |
| 378 | for (n = 0; n < (len - 1); n++) |
| 379 | gpio_direction_output(table[n], 1); |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | static void lcdc_toshiba_config_gpios(int enable) |
| 384 | { |
| 385 | config_lcdc_gpio_table(lcdc_gpio_table, |
| 386 | ARRAY_SIZE(lcdc_gpio_table), enable); |
| 387 | } |
| 388 | |
| 389 | static int msm_fb_lcdc_power_save(int on) |
| 390 | { |
| 391 | int rc = 0; |
| 392 | /* Doing the init of the LCDC GPIOs very late as they are from |
| 393 | an I2C-controlled IO Expander */ |
| 394 | lcdc_toshiba_gpio_init(); |
| 395 | |
| 396 | if (lcdc_gpio_initialized) { |
| 397 | gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, on); |
| 398 | gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, on); |
| 399 | |
| 400 | rc = on ? regulator_bulk_enable( |
| 401 | ARRAY_SIZE(regs_lcdc), regs_lcdc) : |
| 402 | regulator_bulk_disable( |
| 403 | ARRAY_SIZE(regs_lcdc), regs_lcdc); |
| 404 | |
| 405 | if (rc) |
| 406 | pr_err("%s: could not %sable regulators: %d\n", |
| 407 | __func__, on ? "en" : "dis", rc); |
| 408 | } |
| 409 | |
| 410 | return rc; |
| 411 | } |
| 412 | |
| 413 | static int lcdc_toshiba_set_bl(int level) |
| 414 | { |
| 415 | int ret; |
| 416 | |
| 417 | ret = pmapp_disp_backlight_set_brightness(level); |
| 418 | if (ret) |
| 419 | pr_err("%s: can't set lcd backlight!\n", __func__); |
| 420 | |
| 421 | return ret; |
| 422 | } |
| 423 | |
Jeevan Shriram | 901a15f | 2012-03-09 11:53:23 +0530 | [diff] [blame] | 424 | |
| 425 | static int msm_lcdc_power_save(int on) |
| 426 | { |
| 427 | int rc = 0; |
Jeevan Shriram | 045cdc7 | 2012-03-27 07:04:15 +0530 | [diff] [blame] | 428 | if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7()) |
Jeevan Shriram | 901a15f | 2012-03-09 11:53:23 +0530 | [diff] [blame] | 429 | rc = sku3_lcdc_power_save(on); |
| 430 | else |
| 431 | rc = msm_fb_lcdc_power_save(on); |
| 432 | |
| 433 | return rc; |
| 434 | } |
| 435 | |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 436 | static struct lcdc_platform_data lcdc_pdata = { |
| 437 | .lcdc_gpio_config = NULL, |
Jeevan Shriram | 901a15f | 2012-03-09 11:53:23 +0530 | [diff] [blame] | 438 | .lcdc_power_save = msm_lcdc_power_save, |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 439 | }; |
| 440 | |
| 441 | static int lcd_panel_spi_gpio_num[] = { |
| 442 | GPIO_SPI_MOSI, /* spi_sdi */ |
| 443 | GPIO_SPI_MISO, /* spi_sdoi */ |
| 444 | GPIO_SPI_CLK, /* spi_clk */ |
| 445 | GPIO_SPI_CS0_N, /* spi_cs */ |
| 446 | }; |
| 447 | |
| 448 | static struct msm_panel_common_pdata lcdc_toshiba_panel_data = { |
| 449 | .panel_config_gpio = lcdc_toshiba_config_gpios, |
| 450 | .pmic_backlight = lcdc_toshiba_set_bl, |
| 451 | .gpio_num = lcd_panel_spi_gpio_num, |
| 452 | }; |
| 453 | |
| 454 | static struct platform_device lcdc_toshiba_panel_device = { |
| 455 | .name = "lcdc_toshiba_fwvga_pt", |
| 456 | .id = 0, |
| 457 | .dev = { |
| 458 | .platform_data = &lcdc_toshiba_panel_data, |
| 459 | } |
| 460 | }; |
| 461 | |
| 462 | static struct resource msm_fb_resources[] = { |
| 463 | { |
| 464 | .flags = IORESOURCE_DMA, |
| 465 | } |
| 466 | }; |
| 467 | |
Alhad Purnapatre | c55856c | 2012-02-28 13:24:57 -0800 | [diff] [blame^] | 468 | #ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE |
| 469 | static struct resource msm_v4l2_video_overlay_resources[] = { |
| 470 | { |
| 471 | .flags = IORESOURCE_DMA, |
| 472 | } |
| 473 | }; |
| 474 | #endif |
| 475 | |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 476 | #define LCDC_TOSHIBA_FWVGA_PANEL_NAME "lcdc_toshiba_fwvga_pt" |
| 477 | #define MIPI_CMD_RENESAS_FWVGA_PANEL_NAME "mipi_cmd_renesas_fwvga" |
| 478 | |
| 479 | static int msm_fb_detect_panel(const char *name) |
| 480 | { |
| 481 | int ret = -ENODEV; |
| 482 | |
Taniya Das | e3027e2 | 2012-02-27 16:32:27 +0530 | [diff] [blame] | 483 | if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf() || |
| 484 | machine_is_msm8625_surf()) { |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 485 | if (!strncmp(name, "lcdc_toshiba_fwvga_pt", 21) || |
| 486 | !strncmp(name, "mipi_cmd_renesas_fwvga", 22)) |
| 487 | ret = 0; |
| 488 | } else if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()) { |
| 489 | if (!strncmp(name, "mipi_cmd_renesas_fwvga", 22)) |
| 490 | ret = 0; |
| 491 | } else if (machine_is_msm7627a_qrd1()) { |
| 492 | if (!strncmp(name, "mipi_video_truly_wvga", 21)) |
| 493 | ret = 0; |
Jeevan Shriram | 045cdc7 | 2012-03-27 07:04:15 +0530 | [diff] [blame] | 494 | } else if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7()) { |
Jeevan Shriram | 901a15f | 2012-03-09 11:53:23 +0530 | [diff] [blame] | 495 | if (!strncmp(name, "lcdc_truly_hvga_ips3p2335_pt", 28)) |
| 496 | ret = 0; |
Chintan Pandya | f4ad400 | 2012-02-28 19:49:03 +0530 | [diff] [blame] | 497 | } else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) { |
Jeevan Shriram | e941df4 | 2012-01-23 12:40:21 +0530 | [diff] [blame] | 498 | if (!strncmp(name, "mipi_cmd_nt35510_wvga", 21)) |
| 499 | ret = 0; |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 500 | } |
| 501 | |
| 502 | #if !defined(CONFIG_FB_MSM_LCDC_AUTO_DETECT) && \ |
| 503 | !defined(CONFIG_FB_MSM_MIPI_PANEL_AUTO_DETECT) && \ |
| 504 | !defined(CONFIG_FB_MSM_LCDC_MIPI_PANEL_AUTO_DETECT) |
| 505 | if (machine_is_msm7x27a_surf() || |
Taniya Das | e3027e2 | 2012-02-27 16:32:27 +0530 | [diff] [blame] | 506 | machine_is_msm7625a_surf() || |
| 507 | machine_is_msm8625_surf()) { |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 508 | if (!strncmp(name, LCDC_TOSHIBA_FWVGA_PANEL_NAME, |
| 509 | strnlen(LCDC_TOSHIBA_FWVGA_PANEL_NAME, |
| 510 | PANEL_NAME_MAX_LEN))) |
| 511 | return 0; |
| 512 | } |
| 513 | #endif |
| 514 | |
| 515 | return ret; |
| 516 | } |
| 517 | |
| 518 | static int mipi_truly_set_bl(int on) |
| 519 | { |
| 520 | gpio_set_value_cansleep(QRD_GPIO_BACKLIGHT_EN, !!on); |
| 521 | |
| 522 | return 1; |
| 523 | } |
| 524 | |
| 525 | static struct msm_fb_platform_data msm_fb_pdata = { |
| 526 | .detect_client = msm_fb_detect_panel, |
| 527 | }; |
| 528 | |
| 529 | static struct platform_device msm_fb_device = { |
| 530 | .name = "msm_fb", |
| 531 | .id = 0, |
| 532 | .num_resources = ARRAY_SIZE(msm_fb_resources), |
| 533 | .resource = msm_fb_resources, |
| 534 | .dev = { |
| 535 | .platform_data = &msm_fb_pdata, |
| 536 | } |
| 537 | }; |
| 538 | |
Alhad Purnapatre | c55856c | 2012-02-28 13:24:57 -0800 | [diff] [blame^] | 539 | #ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE |
| 540 | static struct platform_device msm_v4l2_video_overlay_device = { |
| 541 | .name = "msm_v4l2_overlay_pd", |
| 542 | .id = 0, |
| 543 | .num_resources = ARRAY_SIZE(msm_v4l2_video_overlay_resources), |
| 544 | .resource = msm_v4l2_video_overlay_resources, |
| 545 | }; |
| 546 | #endif |
| 547 | |
| 548 | |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 549 | #ifdef CONFIG_FB_MSM_MIPI_DSI |
| 550 | static int mipi_renesas_set_bl(int level) |
| 551 | { |
| 552 | int ret; |
| 553 | |
| 554 | ret = pmapp_disp_backlight_set_brightness(level); |
| 555 | |
| 556 | if (ret) |
| 557 | pr_err("%s: can't set lcd backlight!\n", __func__); |
| 558 | |
| 559 | return ret; |
| 560 | } |
| 561 | |
| 562 | static struct msm_panel_common_pdata mipi_renesas_pdata = { |
| 563 | .pmic_backlight = mipi_renesas_set_bl, |
| 564 | }; |
| 565 | |
| 566 | |
| 567 | static struct platform_device mipi_dsi_renesas_panel_device = { |
| 568 | .name = "mipi_renesas", |
| 569 | .id = 0, |
| 570 | .dev = { |
| 571 | .platform_data = &mipi_renesas_pdata, |
| 572 | } |
| 573 | }; |
| 574 | #endif |
| 575 | |
| 576 | static struct msm_panel_common_pdata mipi_truly_pdata = { |
| 577 | .pmic_backlight = mipi_truly_set_bl, |
| 578 | }; |
| 579 | |
| 580 | static struct platform_device mipi_dsi_truly_panel_device = { |
| 581 | .name = "mipi_truly", |
| 582 | .id = 0, |
| 583 | .dev = { |
| 584 | .platform_data = &mipi_truly_pdata, |
| 585 | } |
| 586 | }; |
| 587 | |
Jeevan Shriram | e941df4 | 2012-01-23 12:40:21 +0530 | [diff] [blame] | 588 | static struct msm_panel_common_pdata mipi_NT35510_pdata = { |
Padmanabhan Komanduru | 75cf6b8 | 2012-03-30 15:04:52 +0530 | [diff] [blame] | 589 | .pmic_backlight = NULL,/*mipi_NT35510_set_bl,*/ |
Jeevan Shriram | e941df4 | 2012-01-23 12:40:21 +0530 | [diff] [blame] | 590 | }; |
| 591 | |
| 592 | static struct platform_device mipi_dsi_NT35510_panel_device = { |
| 593 | .name = "mipi_NT35510", |
| 594 | .id = 0, |
| 595 | .dev = { |
| 596 | .platform_data = &mipi_NT35510_pdata, |
| 597 | } |
| 598 | }; |
| 599 | |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 600 | static struct platform_device *msm_fb_devices[] __initdata = { |
| 601 | &msm_fb_device, |
| 602 | &lcdc_toshiba_panel_device, |
| 603 | #ifdef CONFIG_FB_MSM_MIPI_DSI |
| 604 | &mipi_dsi_renesas_panel_device, |
| 605 | #endif |
Alhad Purnapatre | c55856c | 2012-02-28 13:24:57 -0800 | [diff] [blame^] | 606 | #ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE |
| 607 | &msm_v4l2_video_overlay_device, |
| 608 | #endif |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 609 | }; |
| 610 | |
| 611 | static struct platform_device *qrd_fb_devices[] __initdata = { |
| 612 | &msm_fb_device, |
| 613 | &mipi_dsi_truly_panel_device, |
| 614 | }; |
| 615 | |
Jeevan Shriram | 901a15f | 2012-03-09 11:53:23 +0530 | [diff] [blame] | 616 | static struct platform_device *qrd3_fb_devices[] __initdata = { |
| 617 | &msm_fb_device, |
| 618 | &lcdc_truly_panel_device, |
| 619 | }; |
| 620 | |
Taniya Das | c868a2e | 2012-01-03 10:18:47 +0530 | [diff] [blame] | 621 | static struct platform_device *evb_fb_devices[] __initdata = { |
Jeevan Shriram | e941df4 | 2012-01-23 12:40:21 +0530 | [diff] [blame] | 622 | &msm_fb_device, |
| 623 | &mipi_dsi_NT35510_panel_device, |
Taniya Das | c868a2e | 2012-01-03 10:18:47 +0530 | [diff] [blame] | 624 | }; |
| 625 | |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 626 | void __init msm_msm7627a_allocate_memory_regions(void) |
| 627 | { |
| 628 | void *addr; |
| 629 | unsigned long fb_size; |
| 630 | |
| 631 | if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) |
| 632 | fb_size = MSM7x25A_MSM_FB_SIZE; |
| 633 | else |
| 634 | fb_size = MSM_FB_SIZE; |
| 635 | addr = alloc_bootmem_align(fb_size, 0x1000); |
| 636 | msm_fb_resources[0].start = __pa(addr); |
| 637 | msm_fb_resources[0].end = msm_fb_resources[0].start + fb_size - 1; |
| 638 | pr_info("allocating %lu bytes at %p (%lx physical) for fb\n", fb_size, |
| 639 | addr, __pa(addr)); |
Alhad Purnapatre | c55856c | 2012-02-28 13:24:57 -0800 | [diff] [blame^] | 640 | |
| 641 | #ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE |
| 642 | fb_size = MSM_V4L2_VIDEO_OVERLAY_BUF_SIZE; |
| 643 | addr = alloc_bootmem_align(fb_size, 0x1000); |
| 644 | msm_v4l2_video_overlay_resources[0].start = __pa(addr); |
| 645 | msm_v4l2_video_overlay_resources[0].end = |
| 646 | msm_v4l2_video_overlay_resources[0].start + fb_size - 1; |
| 647 | pr_debug("allocating %lu bytes at %p (%lx physical) for v4l2\n", |
| 648 | fb_size, addr, __pa(addr)); |
| 649 | #endif |
| 650 | |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 651 | } |
| 652 | |
| 653 | static struct msm_panel_common_pdata mdp_pdata = { |
| 654 | .gpio = 97, |
| 655 | .mdp_rev = MDP_REV_303, |
| 656 | }; |
| 657 | |
| 658 | #define GPIO_LCDC_BRDG_PD 128 |
| 659 | #define GPIO_LCDC_BRDG_RESET_N 129 |
| 660 | #define GPIO_LCD_DSI_SEL 125 |
| 661 | #define LCDC_RESET_PHYS 0x90008014 |
| 662 | |
| 663 | static void __iomem *lcdc_reset_ptr; |
| 664 | |
| 665 | static unsigned mipi_dsi_gpio[] = { |
| 666 | GPIO_CFG(GPIO_LCDC_BRDG_RESET_N, 0, GPIO_CFG_OUTPUT, |
| 667 | GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* LCDC_BRDG_RESET_N */ |
| 668 | GPIO_CFG(GPIO_LCDC_BRDG_PD, 0, GPIO_CFG_OUTPUT, |
| 669 | GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* LCDC_BRDG_PD */ |
| 670 | }; |
| 671 | |
| 672 | static unsigned lcd_dsi_sel_gpio[] = { |
| 673 | GPIO_CFG(GPIO_LCD_DSI_SEL, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, |
| 674 | GPIO_CFG_2MA), |
| 675 | }; |
| 676 | |
| 677 | enum { |
| 678 | DSI_SINGLE_LANE = 1, |
| 679 | DSI_TWO_LANES, |
| 680 | }; |
| 681 | |
| 682 | static int msm_fb_get_lane_config(void) |
| 683 | { |
| 684 | /* For MSM7627A SURF/FFA and QRD */ |
| 685 | int rc = DSI_TWO_LANES; |
| 686 | if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) { |
| 687 | rc = DSI_SINGLE_LANE; |
| 688 | pr_info("DSI_SINGLE_LANES\n"); |
| 689 | } else { |
| 690 | pr_info("DSI_TWO_LANES\n"); |
| 691 | } |
| 692 | return rc; |
| 693 | } |
| 694 | |
| 695 | static int msm_fb_dsi_client_msm_reset(void) |
| 696 | { |
| 697 | int rc = 0; |
| 698 | |
| 699 | rc = gpio_request(GPIO_LCDC_BRDG_RESET_N, "lcdc_brdg_reset_n"); |
| 700 | if (rc < 0) { |
| 701 | pr_err("failed to request lcd brdg reset_n\n"); |
| 702 | return rc; |
| 703 | } |
| 704 | |
| 705 | rc = gpio_request(GPIO_LCDC_BRDG_PD, "lcdc_brdg_pd"); |
| 706 | if (rc < 0) { |
| 707 | pr_err("failed to request lcd brdg pd\n"); |
| 708 | return rc; |
| 709 | } |
| 710 | |
| 711 | rc = gpio_tlmm_config(mipi_dsi_gpio[0], GPIO_CFG_ENABLE); |
| 712 | if (rc) { |
| 713 | pr_err("Failed to enable LCDC Bridge reset enable\n"); |
| 714 | goto gpio_error; |
| 715 | } |
| 716 | |
| 717 | rc = gpio_tlmm_config(mipi_dsi_gpio[1], GPIO_CFG_ENABLE); |
| 718 | if (rc) { |
| 719 | pr_err("Failed to enable LCDC Bridge pd enable\n"); |
| 720 | goto gpio_error2; |
| 721 | } |
| 722 | |
| 723 | rc = gpio_direction_output(GPIO_LCDC_BRDG_RESET_N, 1); |
| 724 | rc |= gpio_direction_output(GPIO_LCDC_BRDG_PD, 1); |
| 725 | gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 0); |
| 726 | |
| 727 | if (!rc) { |
Taniya Das | e3027e2 | 2012-02-27 16:32:27 +0530 | [diff] [blame] | 728 | if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf() |
| 729 | || machine_is_msm8625_surf()) { |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 730 | lcdc_reset_ptr = ioremap_nocache(LCDC_RESET_PHYS, |
| 731 | sizeof(uint32_t)); |
| 732 | |
| 733 | if (!lcdc_reset_ptr) |
| 734 | return 0; |
| 735 | } |
| 736 | return rc; |
| 737 | } else { |
| 738 | goto gpio_error; |
| 739 | } |
| 740 | |
| 741 | gpio_error2: |
| 742 | pr_err("Failed GPIO bridge pd\n"); |
| 743 | gpio_free(GPIO_LCDC_BRDG_PD); |
| 744 | |
| 745 | gpio_error: |
| 746 | pr_err("Failed GPIO bridge reset\n"); |
| 747 | gpio_free(GPIO_LCDC_BRDG_RESET_N); |
| 748 | return rc; |
| 749 | } |
| 750 | |
| 751 | static int mipi_truly_sel_mode(int video_mode) |
| 752 | { |
| 753 | int rc = 0; |
| 754 | |
| 755 | rc = gpio_request(GPIO_LCD_DSI_SEL, "lcd_dsi_sel"); |
| 756 | if (rc < 0) |
| 757 | goto gpio_error; |
| 758 | |
| 759 | rc = gpio_tlmm_config(lcd_dsi_sel_gpio[0], GPIO_CFG_ENABLE); |
| 760 | if (rc) |
| 761 | goto gpio_error; |
| 762 | |
| 763 | rc = gpio_direction_output(GPIO_LCD_DSI_SEL, 1); |
| 764 | if (!rc) { |
| 765 | gpio_set_value_cansleep(GPIO_LCD_DSI_SEL, video_mode); |
| 766 | return rc; |
| 767 | } else { |
| 768 | goto gpio_error; |
| 769 | } |
| 770 | |
| 771 | gpio_error: |
| 772 | pr_err("mipi_truly_sel_mode failed\n"); |
| 773 | gpio_free(GPIO_LCD_DSI_SEL); |
| 774 | return rc; |
| 775 | } |
| 776 | |
| 777 | static int msm_fb_dsi_client_qrd1_reset(void) |
| 778 | { |
| 779 | int rc = 0; |
| 780 | |
| 781 | rc = gpio_request(GPIO_LCDC_BRDG_RESET_N, "lcdc_brdg_reset_n"); |
| 782 | if (rc < 0) { |
| 783 | pr_err("failed to request lcd brdg reset_n\n"); |
| 784 | return rc; |
| 785 | } |
| 786 | |
| 787 | rc = gpio_tlmm_config(mipi_dsi_gpio[0], GPIO_CFG_ENABLE); |
| 788 | if (rc < 0) { |
| 789 | pr_err("Failed to enable LCDC Bridge reset enable\n"); |
| 790 | return rc; |
| 791 | } |
| 792 | |
| 793 | rc = gpio_direction_output(GPIO_LCDC_BRDG_RESET_N, 1); |
| 794 | if (rc < 0) { |
| 795 | pr_err("Failed GPIO bridge pd\n"); |
| 796 | gpio_free(GPIO_LCDC_BRDG_RESET_N); |
| 797 | return rc; |
| 798 | } |
| 799 | |
| 800 | mipi_truly_sel_mode(1); |
| 801 | |
| 802 | return rc; |
| 803 | } |
| 804 | |
Jeevan Shriram | e941df4 | 2012-01-23 12:40:21 +0530 | [diff] [blame] | 805 | #define GPIO_QRD3_LCD_BRDG_RESET_N 85 |
| 806 | #define GPIO_QRD3_LCD_BACKLIGHT_EN 96 |
| 807 | #define GPIO_QRD3_LCD_EXT_2V85_EN 35 |
| 808 | #define GPIO_QRD3_LCD_EXT_1V8_EN 40 |
| 809 | |
| 810 | static unsigned qrd3_mipi_dsi_gpio[] = { |
| 811 | GPIO_CFG(GPIO_QRD3_LCD_BRDG_RESET_N, 0, GPIO_CFG_OUTPUT, |
| 812 | GPIO_CFG_NO_PULL, |
| 813 | GPIO_CFG_2MA), /* GPIO_QRD3_LCD_BRDG_RESET_N */ |
| 814 | GPIO_CFG(GPIO_QRD3_LCD_BACKLIGHT_EN, 0, GPIO_CFG_OUTPUT, |
| 815 | GPIO_CFG_NO_PULL, |
| 816 | GPIO_CFG_2MA), /* GPIO_QRD3_LCD_BACKLIGHT_EN */ |
| 817 | GPIO_CFG(GPIO_QRD3_LCD_EXT_2V85_EN, 0, GPIO_CFG_OUTPUT, |
| 818 | GPIO_CFG_NO_PULL, |
| 819 | GPIO_CFG_2MA), /* GPIO_QRD3_LCD_EXT_2V85_EN */ |
| 820 | GPIO_CFG(GPIO_QRD3_LCD_EXT_1V8_EN, 0, GPIO_CFG_OUTPUT, |
| 821 | GPIO_CFG_NO_PULL, |
| 822 | GPIO_CFG_2MA), /* GPIO_QRD3_LCD_EXT_1V8_EN */ |
| 823 | }; |
| 824 | |
| 825 | static int msm_fb_dsi_client_qrd3_reset(void) |
| 826 | { |
| 827 | int rc = 0; |
| 828 | |
| 829 | rc = gpio_request(GPIO_QRD3_LCD_BRDG_RESET_N, "qrd3_lcd_brdg_reset_n"); |
| 830 | if (rc < 0) { |
| 831 | pr_err("failed to request qrd3 lcd brdg reset_n\n"); |
| 832 | return rc; |
| 833 | } |
| 834 | |
Jeevan Shriram | e941df4 | 2012-01-23 12:40:21 +0530 | [diff] [blame] | 835 | return rc; |
| 836 | } |
| 837 | |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 838 | static int msm_fb_dsi_client_reset(void) |
| 839 | { |
| 840 | int rc = 0; |
| 841 | |
| 842 | if (machine_is_msm7627a_qrd1()) |
| 843 | rc = msm_fb_dsi_client_qrd1_reset(); |
Chintan Pandya | f4ad400 | 2012-02-28 19:49:03 +0530 | [diff] [blame] | 844 | else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) |
Jeevan Shriram | e941df4 | 2012-01-23 12:40:21 +0530 | [diff] [blame] | 845 | rc = msm_fb_dsi_client_qrd3_reset(); |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 846 | else |
| 847 | rc = msm_fb_dsi_client_msm_reset(); |
| 848 | |
| 849 | return rc; |
| 850 | |
| 851 | } |
| 852 | |
| 853 | static struct regulator_bulk_data regs_dsi[] = { |
| 854 | { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 }, |
| 855 | { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 }, |
| 856 | }; |
| 857 | |
| 858 | static int dsi_gpio_initialized; |
| 859 | |
| 860 | static int mipi_dsi_panel_msm_power(int on) |
| 861 | { |
| 862 | int rc = 0; |
| 863 | uint32_t lcdc_reset_cfg; |
| 864 | |
| 865 | /* I2C-controlled GPIO Expander -init of the GPIOs very late */ |
| 866 | if (unlikely(!dsi_gpio_initialized)) { |
| 867 | pmapp_disp_backlight_init(); |
| 868 | |
| 869 | rc = gpio_request(GPIO_DISPLAY_PWR_EN, "gpio_disp_pwr"); |
| 870 | if (rc < 0) { |
| 871 | pr_err("failed to request gpio_disp_pwr\n"); |
| 872 | return rc; |
| 873 | } |
| 874 | |
Taniya Das | e3027e2 | 2012-02-27 16:32:27 +0530 | [diff] [blame] | 875 | if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf() |
| 876 | || machine_is_msm8625_surf()) { |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 877 | rc = gpio_direction_output(GPIO_DISPLAY_PWR_EN, 1); |
| 878 | if (rc < 0) { |
| 879 | pr_err("failed to enable display pwr\n"); |
| 880 | goto fail_gpio1; |
| 881 | } |
| 882 | |
| 883 | rc = gpio_request(GPIO_BACKLIGHT_EN, "gpio_bkl_en"); |
| 884 | if (rc < 0) { |
| 885 | pr_err("failed to request gpio_bkl_en\n"); |
| 886 | goto fail_gpio1; |
| 887 | } |
| 888 | |
| 889 | rc = gpio_direction_output(GPIO_BACKLIGHT_EN, 1); |
| 890 | if (rc < 0) { |
| 891 | pr_err("failed to enable backlight\n"); |
| 892 | goto fail_gpio2; |
| 893 | } |
| 894 | } |
| 895 | |
| 896 | rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_dsi), regs_dsi); |
| 897 | if (rc) { |
| 898 | pr_err("%s: could not get regulators: %d\n", |
| 899 | __func__, rc); |
| 900 | goto fail_gpio2; |
| 901 | } |
| 902 | |
| 903 | rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_dsi), |
| 904 | regs_dsi); |
| 905 | if (rc) { |
| 906 | pr_err("%s: could not set voltages: %d\n", |
| 907 | __func__, rc); |
| 908 | goto fail_vreg; |
| 909 | } |
| 910 | if (pmapp_disp_backlight_set_brightness(100)) |
| 911 | pr_err("backlight set brightness failed\n"); |
| 912 | |
| 913 | dsi_gpio_initialized = 1; |
| 914 | } |
Taniya Das | e3027e2 | 2012-02-27 16:32:27 +0530 | [diff] [blame] | 915 | if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf() || |
| 916 | machine_is_msm8625_surf()) { |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 917 | gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, on); |
| 918 | gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, on); |
| 919 | } else if (machine_is_msm7x27a_ffa() || |
| 920 | machine_is_msm7625a_ffa()) { |
| 921 | if (on) { |
| 922 | /* This line drives an active low pin on FFA */ |
| 923 | rc = gpio_direction_output(GPIO_DISPLAY_PWR_EN, !on); |
| 924 | if (rc < 0) |
| 925 | pr_err("failed to set direction for " |
| 926 | "display pwr\n"); |
| 927 | } else { |
| 928 | gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, !on); |
| 929 | rc = gpio_direction_input(GPIO_DISPLAY_PWR_EN); |
| 930 | if (rc < 0) |
| 931 | pr_err("failed to set direction for " |
| 932 | "display pwr\n"); |
| 933 | } |
| 934 | } |
| 935 | |
| 936 | if (on) { |
| 937 | gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 0); |
| 938 | |
| 939 | if (machine_is_msm7x27a_surf() || |
Taniya Das | e3027e2 | 2012-02-27 16:32:27 +0530 | [diff] [blame] | 940 | machine_is_msm7625a_surf() || |
| 941 | machine_is_msm8625_surf()) { |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 942 | lcdc_reset_cfg = readl_relaxed(lcdc_reset_ptr); |
| 943 | rmb(); |
| 944 | lcdc_reset_cfg &= ~1; |
| 945 | |
| 946 | writel_relaxed(lcdc_reset_cfg, lcdc_reset_ptr); |
| 947 | msleep(20); |
| 948 | wmb(); |
| 949 | lcdc_reset_cfg |= 1; |
| 950 | writel_relaxed(lcdc_reset_cfg, lcdc_reset_ptr); |
| 951 | } else { |
| 952 | gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 0); |
| 953 | msleep(20); |
| 954 | gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1); |
| 955 | } |
| 956 | } else { |
| 957 | gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 1); |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 958 | } |
| 959 | |
| 960 | rc = on ? regulator_bulk_enable(ARRAY_SIZE(regs_dsi), regs_dsi) : |
| 961 | regulator_bulk_disable(ARRAY_SIZE(regs_dsi), regs_dsi); |
| 962 | |
| 963 | if (rc) |
| 964 | pr_err("%s: could not %sable regulators: %d\n", |
| 965 | __func__, on ? "en" : "dis", rc); |
| 966 | |
| 967 | return rc; |
| 968 | fail_vreg: |
| 969 | regulator_bulk_free(ARRAY_SIZE(regs_dsi), regs_dsi); |
| 970 | fail_gpio2: |
| 971 | gpio_free(GPIO_BACKLIGHT_EN); |
| 972 | fail_gpio1: |
| 973 | gpio_free(GPIO_DISPLAY_PWR_EN); |
| 974 | dsi_gpio_initialized = 0; |
| 975 | return rc; |
| 976 | } |
| 977 | |
| 978 | static int mipi_dsi_panel_qrd1_power(int on) |
| 979 | { |
| 980 | int rc = 0; |
| 981 | |
| 982 | if (!dsi_gpio_initialized) { |
| 983 | rc = gpio_request(QRD_GPIO_BACKLIGHT_EN, "gpio_bkl_en"); |
| 984 | if (rc < 0) |
| 985 | return rc; |
| 986 | |
| 987 | rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_BACKLIGHT_EN, 0, |
| 988 | GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 989 | GPIO_CFG_ENABLE); |
| 990 | if (rc < 0) { |
| 991 | pr_err("failed GPIO_BACKLIGHT_EN tlmm config\n"); |
| 992 | return rc; |
| 993 | } |
| 994 | |
| 995 | rc = gpio_direction_output(QRD_GPIO_BACKLIGHT_EN, 1); |
| 996 | if (rc < 0) { |
| 997 | pr_err("failed to enable backlight\n"); |
| 998 | gpio_free(QRD_GPIO_BACKLIGHT_EN); |
| 999 | return rc; |
| 1000 | } |
| 1001 | dsi_gpio_initialized = 1; |
| 1002 | } |
| 1003 | |
| 1004 | gpio_set_value_cansleep(QRD_GPIO_BACKLIGHT_EN, !!on); |
| 1005 | |
Jeevan Shriram | e941df4 | 2012-01-23 12:40:21 +0530 | [diff] [blame] | 1006 | if (on) { |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 1007 | gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1); |
| 1008 | msleep(20); |
| 1009 | gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 0); |
| 1010 | msleep(20); |
| 1011 | gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1); |
| 1012 | |
| 1013 | } |
| 1014 | |
| 1015 | return rc; |
| 1016 | } |
| 1017 | |
Jeevan Shriram | e941df4 | 2012-01-23 12:40:21 +0530 | [diff] [blame] | 1018 | static int qrd3_dsi_gpio_initialized; |
| 1019 | |
| 1020 | static int mipi_dsi_panel_qrd3_power(int on) |
| 1021 | { |
| 1022 | int rc = 0; |
| 1023 | |
| 1024 | if (!qrd3_dsi_gpio_initialized) { |
| 1025 | rc = gpio_request(GPIO_QRD3_LCD_BACKLIGHT_EN, |
| 1026 | "qrd3_gpio_bkl_en"); |
| 1027 | if (rc < 0) |
| 1028 | return rc; |
| 1029 | |
| 1030 | rc = gpio_tlmm_config(GPIO_CFG(GPIO_QRD3_LCD_BACKLIGHT_EN, 0, |
Padmanabhan Komanduru | 75cf6b8 | 2012-03-30 15:04:52 +0530 | [diff] [blame] | 1031 | GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
Jeevan Shriram | e941df4 | 2012-01-23 12:40:21 +0530 | [diff] [blame] | 1032 | GPIO_CFG_ENABLE); |
| 1033 | if (rc < 0) { |
| 1034 | pr_err("failed QRD3 GPIO_BACKLIGHT_EN tlmm config\n"); |
| 1035 | return rc; |
| 1036 | } |
| 1037 | rc = gpio_direction_output(GPIO_QRD3_LCD_BACKLIGHT_EN, 1); |
| 1038 | if (rc < 0) { |
| 1039 | pr_err("failed to enable backlight\n"); |
| 1040 | gpio_free(GPIO_QRD3_LCD_BACKLIGHT_EN); |
| 1041 | return rc; |
| 1042 | } |
| 1043 | |
| 1044 | rc = gpio_request(GPIO_QRD3_LCD_EXT_2V85_EN, |
| 1045 | "qrd3_gpio_ext_2v85_en"); |
| 1046 | if (rc < 0) |
| 1047 | return rc; |
| 1048 | |
| 1049 | rc = gpio_tlmm_config(GPIO_CFG(GPIO_QRD3_LCD_EXT_2V85_EN, 0, |
| 1050 | GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 1051 | GPIO_CFG_ENABLE); |
| 1052 | if (rc < 0) { |
| 1053 | pr_err("failed QRD3 GPIO_QRD3_LCD_EXT_2V85_EN tlmm config\n"); |
| 1054 | return rc; |
| 1055 | } |
| 1056 | |
| 1057 | rc = gpio_direction_output(GPIO_QRD3_LCD_EXT_2V85_EN, 1); |
| 1058 | if (rc < 0) { |
| 1059 | pr_err("failed to enable external 2V85\n"); |
| 1060 | gpio_free(GPIO_QRD3_LCD_EXT_2V85_EN); |
| 1061 | return rc; |
| 1062 | } |
| 1063 | |
| 1064 | rc = gpio_request(GPIO_QRD3_LCD_EXT_1V8_EN, |
| 1065 | "qrd3_gpio_ext_1v8_en"); |
| 1066 | if (rc < 0) |
| 1067 | return rc; |
| 1068 | |
| 1069 | rc = gpio_tlmm_config(GPIO_CFG(GPIO_QRD3_LCD_EXT_1V8_EN, 0, |
| 1070 | GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 1071 | GPIO_CFG_ENABLE); |
| 1072 | if (rc < 0) { |
| 1073 | pr_err("failed QRD3 GPIO_QRD3_LCD_EXT_1V8_EN tlmm config\n"); |
| 1074 | return rc; |
| 1075 | } |
| 1076 | |
| 1077 | rc = gpio_direction_output(GPIO_QRD3_LCD_EXT_1V8_EN, 1); |
| 1078 | if (rc < 0) { |
| 1079 | pr_err("failed to enable external 1v8\n"); |
| 1080 | gpio_free(GPIO_QRD3_LCD_EXT_1V8_EN); |
| 1081 | return rc; |
| 1082 | } |
| 1083 | |
| 1084 | qrd3_dsi_gpio_initialized = 1; |
| 1085 | } |
| 1086 | |
Padmanabhan Komanduru | 75cf6b8 | 2012-03-30 15:04:52 +0530 | [diff] [blame] | 1087 | gpio_set_value_cansleep(GPIO_QRD3_LCD_BACKLIGHT_EN, !!on); |
Jeevan Shriram | e941df4 | 2012-01-23 12:40:21 +0530 | [diff] [blame] | 1088 | gpio_set_value_cansleep(GPIO_QRD3_LCD_EXT_2V85_EN, !!on); |
| 1089 | gpio_set_value_cansleep(GPIO_QRD3_LCD_EXT_1V8_EN, !!on); |
| 1090 | |
| 1091 | if (on) { |
Padmanabhan Komanduru | 599d355 | 2012-02-21 16:53:05 +0530 | [diff] [blame] | 1092 | rc = gpio_tlmm_config(qrd3_mipi_dsi_gpio[0], GPIO_CFG_ENABLE); |
| 1093 | |
| 1094 | if (rc < 0) { |
| 1095 | pr_err("Failed to enable LCD Bridge reset enable\n"); |
| 1096 | return rc; |
| 1097 | } |
| 1098 | |
| 1099 | rc = gpio_direction_output(GPIO_QRD3_LCD_BRDG_RESET_N, 1); |
| 1100 | |
| 1101 | if (rc < 0) { |
| 1102 | pr_err("Failed GPIO bridge Reset\n"); |
| 1103 | gpio_free(GPIO_QRD3_LCD_BRDG_RESET_N); |
| 1104 | return rc; |
| 1105 | } |
| 1106 | |
Jeevan Shriram | e941df4 | 2012-01-23 12:40:21 +0530 | [diff] [blame] | 1107 | msleep(20); |
| 1108 | gpio_set_value_cansleep(GPIO_QRD3_LCD_BRDG_RESET_N, 0); |
| 1109 | msleep(20); |
| 1110 | gpio_set_value_cansleep(GPIO_QRD3_LCD_BRDG_RESET_N, 1); |
| 1111 | msleep(20); |
Padmanabhan Komanduru | 599d355 | 2012-02-21 16:53:05 +0530 | [diff] [blame] | 1112 | } else { |
| 1113 | gpio_tlmm_config(GPIO_CFG(GPIO_QRD3_LCD_BRDG_RESET_N, 0, |
| 1114 | GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), |
| 1115 | GPIO_CFG_DISABLE); |
Jeevan Shriram | e941df4 | 2012-01-23 12:40:21 +0530 | [diff] [blame] | 1116 | } |
| 1117 | |
| 1118 | return rc; |
| 1119 | } |
| 1120 | |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 1121 | static int mipi_dsi_panel_power(int on) |
| 1122 | { |
| 1123 | int rc = 0; |
| 1124 | |
| 1125 | if (machine_is_msm7627a_qrd1()) |
| 1126 | rc = mipi_dsi_panel_qrd1_power(on); |
Chintan Pandya | f4ad400 | 2012-02-28 19:49:03 +0530 | [diff] [blame] | 1127 | else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) |
Jeevan Shriram | e941df4 | 2012-01-23 12:40:21 +0530 | [diff] [blame] | 1128 | rc = mipi_dsi_panel_qrd3_power(on); |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 1129 | else |
| 1130 | rc = mipi_dsi_panel_msm_power(on); |
| 1131 | return rc; |
| 1132 | } |
| 1133 | |
| 1134 | #define MDP_303_VSYNC_GPIO 97 |
| 1135 | |
Jeevan Shriram | 901a15f | 2012-03-09 11:53:23 +0530 | [diff] [blame] | 1136 | #ifdef CONFIG_FB_MSM_MIPI_DSI |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 1137 | static struct mipi_dsi_platform_data mipi_dsi_pdata = { |
| 1138 | .vsync_gpio = MDP_303_VSYNC_GPIO, |
| 1139 | .dsi_power_save = mipi_dsi_panel_power, |
| 1140 | .dsi_client_reset = msm_fb_dsi_client_reset, |
| 1141 | .get_lane_config = msm_fb_get_lane_config, |
| 1142 | }; |
| 1143 | #endif |
| 1144 | |
| 1145 | void __init msm_fb_add_devices(void) |
| 1146 | { |
| 1147 | if (machine_is_msm7627a_qrd1()) |
| 1148 | platform_add_devices(qrd_fb_devices, |
| 1149 | ARRAY_SIZE(qrd_fb_devices)); |
Padmanabhan Komanduru | 75cf6b8 | 2012-03-30 15:04:52 +0530 | [diff] [blame] | 1150 | else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) |
Taniya Das | c868a2e | 2012-01-03 10:18:47 +0530 | [diff] [blame] | 1151 | platform_add_devices(evb_fb_devices, |
| 1152 | ARRAY_SIZE(evb_fb_devices)); |
Padmanabhan Komanduru | 75cf6b8 | 2012-03-30 15:04:52 +0530 | [diff] [blame] | 1153 | else if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7()) { |
Jeevan Shriram | 901a15f | 2012-03-09 11:53:23 +0530 | [diff] [blame] | 1154 | sku3_lcdc_lcd_camera_power_init(); |
| 1155 | platform_add_devices(qrd3_fb_devices, |
| 1156 | ARRAY_SIZE(qrd3_fb_devices)); |
| 1157 | } else |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 1158 | platform_add_devices(msm_fb_devices, |
| 1159 | ARRAY_SIZE(msm_fb_devices)); |
| 1160 | |
| 1161 | msm_fb_register_device("mdp", &mdp_pdata); |
Taniya Das | e3027e2 | 2012-02-27 16:32:27 +0530 | [diff] [blame] | 1162 | if (machine_is_msm7625a_surf() || machine_is_msm7x27a_surf() || |
Jeevan Shriram | 045cdc7 | 2012-03-27 07:04:15 +0530 | [diff] [blame] | 1163 | machine_is_msm8625_surf() || machine_is_msm7627a_qrd3() |
| 1164 | || machine_is_msm8625_qrd7()) |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 1165 | msm_fb_register_device("lcdc", &lcdc_pdata); |
Jeevan Shriram | 901a15f | 2012-03-09 11:53:23 +0530 | [diff] [blame] | 1166 | #ifdef CONFIG_FB_MSM_MIPI_DSI |
Chintan Pandya | 250c2e5 | 2012-01-19 17:15:49 +0530 | [diff] [blame] | 1167 | msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata); |
| 1168 | #endif |
| 1169 | } |