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