Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [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 | |
| 14 | #include <linux/init.h> |
| 15 | #include <linux/ioport.h> |
| 16 | #include <linux/platform_device.h> |
| 17 | #include <linux/bootmem.h> |
Ravishangar Kalyanam | 59a67b1 | 2012-02-13 14:29:56 -0800 | [diff] [blame^] | 18 | #include <linux/ion.h> |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 19 | #include <asm/mach-types.h> |
| 20 | #include <mach/msm_memtypes.h> |
| 21 | #include <mach/board.h> |
| 22 | #include <mach/gpio.h> |
| 23 | #include <mach/gpiomux.h> |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 24 | #include <mach/ion.h> |
Ravishangar Kalyanam | 59a67b1 | 2012-02-13 14:29:56 -0800 | [diff] [blame^] | 25 | #include <mach/msm_bus_board.h> |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 26 | |
| 27 | #include "devices.h" |
| 28 | #include "board-8064.h" |
| 29 | |
| 30 | #ifdef CONFIG_FB_MSM_TRIPLE_BUFFER |
| 31 | /* prim = 1366 x 768 x 3(bpp) x 3(pages) */ |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 32 | #define MSM_FB_PRIM_BUF_SIZE roundup(1376 * 768 * 4 * 3, 0x10000) |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 33 | #else |
| 34 | /* prim = 1366 x 768 x 3(bpp) x 2(pages) */ |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 35 | #define MSM_FB_PRIM_BUF_SIZE roundup(1376 * 768 * 4 * 2, 0x10000) |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 36 | #endif |
| 37 | |
| 38 | #ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL |
| 39 | /* hdmi = 1920 x 1088 x 2(bpp) x 1(page) */ |
| 40 | #define MSM_FB_EXT_BUF_SIZE 0x3FC000 |
| 41 | #elif defined(CONFIG_FB_MSM_TVOUT) |
| 42 | /* tvout = 720 x 576 x 2(bpp) x 2(pages) */ |
| 43 | #define MSM_FB_EXT_BUF_SIZE 0x195000 |
| 44 | #else /* CONFIG_FB_MSM_HDMI_MSM_PANEL */ |
| 45 | #define MSM_FB_EXT_BUF_SIZE 0 |
| 46 | #endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */ |
| 47 | |
| 48 | #define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE, 4096) |
| 49 | |
| 50 | #ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK |
| 51 | #define MSM_FB_OVERLAY0_WRITEBACK_SIZE roundup((1376 * 768 * 3 * 2), 4096) |
| 52 | #else |
| 53 | #define MSM_FB_OVERLAY0_WRITEBACK_SIZE (0) |
| 54 | #endif /* CONFIG_FB_MSM_OVERLAY0_WRITEBACK */ |
| 55 | |
| 56 | #ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK |
| 57 | #define MSM_FB_OVERLAY1_WRITEBACK_SIZE roundup((1920 * 1088 * 3 * 2), 4096) |
| 58 | #else |
| 59 | #define MSM_FB_OVERLAY1_WRITEBACK_SIZE (0) |
| 60 | #endif /* CONFIG_FB_MSM_OVERLAY1_WRITEBACK */ |
| 61 | |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 62 | |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 63 | static struct resource msm_fb_resources[] = { |
| 64 | { |
| 65 | .flags = IORESOURCE_DMA, |
| 66 | } |
| 67 | }; |
| 68 | |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 69 | #define PANEL_NAME_MAX_LEN 30 |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 70 | #define LVDS_CHIMEI_PANEL_NAME "lvds_chimei_wxga" |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 71 | #define MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME "mipi_video_toshiba_wsvga" |
| 72 | #define MIPI_VIDEO_CHIMEI_WXGA_PANEL_NAME "mipi_video_chimei_wxga" |
| 73 | #define HDMI_PANEL_NAME "hdmi_msm" |
| 74 | #define TVOUT_PANEL_NAME "tvout_msm" |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 75 | |
| 76 | static int msm_fb_detect_panel(const char *name) |
| 77 | { |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 78 | if (machine_is_apq8064_liquid()) { |
| 79 | if (!strncmp(name, LVDS_CHIMEI_PANEL_NAME, |
| 80 | strnlen(LVDS_CHIMEI_PANEL_NAME, |
| 81 | PANEL_NAME_MAX_LEN))) |
| 82 | return 0; |
| 83 | |
| 84 | #if !defined(CONFIG_FB_MSM_LVDS_MIPI_PANEL_DETECT) && \ |
| 85 | !defined(CONFIG_FB_MSM_MIPI_PANEL_DETECT) |
| 86 | if (!strncmp(name, MIPI_VIDEO_CHIMEI_WXGA_PANEL_NAME, |
| 87 | strnlen(MIPI_VIDEO_CHIMEI_WXGA_PANEL_NAME, |
| 88 | PANEL_NAME_MAX_LEN))) |
| 89 | return 0; |
| 90 | #endif |
| 91 | } else if (machine_is_apq8064_mtp()) { |
| 92 | if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME, |
| 93 | strnlen(MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME, |
| 94 | PANEL_NAME_MAX_LEN))) |
| 95 | return 0; |
| 96 | } else if (machine_is_apq8064_cdp()) { |
| 97 | if (!strncmp(name, LVDS_CHIMEI_PANEL_NAME, |
| 98 | strnlen(LVDS_CHIMEI_PANEL_NAME, |
| 99 | PANEL_NAME_MAX_LEN))) |
| 100 | return 0; |
| 101 | } |
| 102 | |
| 103 | if (!strncmp(name, HDMI_PANEL_NAME, |
| 104 | strnlen(HDMI_PANEL_NAME, |
| 105 | PANEL_NAME_MAX_LEN))) |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 106 | return 0; |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 107 | |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 108 | return -ENODEV; |
| 109 | } |
| 110 | |
| 111 | static struct msm_fb_platform_data msm_fb_pdata = { |
| 112 | .detect_client = msm_fb_detect_panel, |
| 113 | }; |
| 114 | |
| 115 | static struct platform_device msm_fb_device = { |
| 116 | .name = "msm_fb", |
| 117 | .id = 0, |
| 118 | .num_resources = ARRAY_SIZE(msm_fb_resources), |
| 119 | .resource = msm_fb_resources, |
| 120 | .dev.platform_data = &msm_fb_pdata, |
| 121 | }; |
| 122 | |
| 123 | void __init apq8064_allocate_fb_region(void) |
| 124 | { |
| 125 | void *addr; |
| 126 | unsigned long size; |
| 127 | |
| 128 | size = MSM_FB_SIZE; |
| 129 | addr = alloc_bootmem_align(size, 0x1000); |
| 130 | msm_fb_resources[0].start = __pa(addr); |
| 131 | msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1; |
| 132 | pr_info("allocating %lu bytes at %p (%lx physical) for fb\n", |
| 133 | size, addr, __pa(addr)); |
| 134 | } |
| 135 | |
| 136 | #define MDP_VSYNC_GPIO 0 |
| 137 | |
Ravishangar Kalyanam | 59a67b1 | 2012-02-13 14:29:56 -0800 | [diff] [blame^] | 138 | #ifdef CONFIG_MSM_BUS_SCALING |
| 139 | static struct msm_bus_vectors mdp_init_vectors[] = { |
| 140 | { |
| 141 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 142 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 143 | .ab = 0, |
| 144 | .ib = 0, |
| 145 | }, |
| 146 | }; |
| 147 | |
| 148 | static struct msm_bus_vectors mdp_ui_vectors[] = { |
| 149 | { |
| 150 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 151 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 152 | .ab = 216000000 * 2, |
| 153 | .ib = 270000000 * 2, |
| 154 | }, |
| 155 | }; |
| 156 | |
| 157 | static struct msm_bus_vectors mdp_vga_vectors[] = { |
| 158 | /* VGA and less video */ |
| 159 | { |
| 160 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 161 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 162 | .ab = 216000000 * 2, |
| 163 | .ib = 270000000 * 2, |
| 164 | }, |
| 165 | }; |
| 166 | |
| 167 | static struct msm_bus_vectors mdp_720p_vectors[] = { |
| 168 | /* 720p and less video */ |
| 169 | { |
| 170 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 171 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 172 | .ab = 230400000 * 2, |
| 173 | .ib = 288000000 * 2, |
| 174 | }, |
| 175 | }; |
| 176 | |
| 177 | static struct msm_bus_vectors mdp_1080p_vectors[] = { |
| 178 | /* 1080p and less video */ |
| 179 | { |
| 180 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 181 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 182 | .ab = 334080000 * 2, |
| 183 | .ib = 417600000 * 2, |
| 184 | }, |
| 185 | }; |
| 186 | |
| 187 | static struct msm_bus_paths mdp_bus_scale_usecases[] = { |
| 188 | { |
| 189 | ARRAY_SIZE(mdp_init_vectors), |
| 190 | mdp_init_vectors, |
| 191 | }, |
| 192 | { |
| 193 | ARRAY_SIZE(mdp_ui_vectors), |
| 194 | mdp_ui_vectors, |
| 195 | }, |
| 196 | { |
| 197 | ARRAY_SIZE(mdp_ui_vectors), |
| 198 | mdp_ui_vectors, |
| 199 | }, |
| 200 | { |
| 201 | ARRAY_SIZE(mdp_vga_vectors), |
| 202 | mdp_vga_vectors, |
| 203 | }, |
| 204 | { |
| 205 | ARRAY_SIZE(mdp_720p_vectors), |
| 206 | mdp_720p_vectors, |
| 207 | }, |
| 208 | { |
| 209 | ARRAY_SIZE(mdp_1080p_vectors), |
| 210 | mdp_1080p_vectors, |
| 211 | }, |
| 212 | }; |
| 213 | |
| 214 | static struct msm_bus_scale_pdata mdp_bus_scale_pdata = { |
| 215 | mdp_bus_scale_usecases, |
| 216 | ARRAY_SIZE(mdp_bus_scale_usecases), |
| 217 | .name = "mdp", |
| 218 | }; |
| 219 | |
| 220 | #endif |
| 221 | |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 222 | static int mdp_core_clk_rate_table[] = { |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 223 | 200000000, |
| 224 | 200000000, |
| 225 | 200000000, |
| 226 | 200000000, |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 227 | }; |
| 228 | |
| 229 | static struct msm_panel_common_pdata mdp_pdata = { |
| 230 | .gpio = MDP_VSYNC_GPIO, |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 231 | .mdp_core_clk_rate = 200000000, |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 232 | .mdp_core_clk_table = mdp_core_clk_rate_table, |
| 233 | .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table), |
Ravishangar Kalyanam | 59a67b1 | 2012-02-13 14:29:56 -0800 | [diff] [blame^] | 234 | #ifdef CONFIG_MSM_BUS_SCALING |
| 235 | .mdp_bus_scale_table = &mdp_bus_scale_pdata, |
| 236 | #endif |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 237 | .mdp_rev = MDP_REV_44, |
| 238 | #ifdef CONFIG_MSM_MULTIMEDIA_USE_ION |
| 239 | .mem_hid = ION_CP_MM_HEAP_ID, |
| 240 | #else |
| 241 | .mem_hid = MEMTYPE_EBI1, |
| 242 | #endif |
| 243 | }; |
| 244 | |
| 245 | void __init apq8064_mdp_writeback(struct memtype_reserve* reserve_table) |
| 246 | { |
| 247 | mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE; |
| 248 | mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE; |
| 249 | #if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION) |
| 250 | reserve_table[mdp_pdata.mem_hid].size += |
| 251 | mdp_pdata.ov0_wb_size; |
| 252 | reserve_table[mdp_pdata.mem_hid].size += |
| 253 | mdp_pdata.ov1_wb_size; |
| 254 | #endif |
| 255 | } |
| 256 | |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 257 | static bool dsi_power_on; |
| 258 | static int mipi_dsi_panel_power(int on) |
| 259 | { |
| 260 | static struct regulator *reg_lvs7, *reg_l2, *reg_l11, *reg_ext_3p3v; |
| 261 | static int gpio36, gpio25, gpio26, mpp3; |
| 262 | int rc; |
| 263 | |
| 264 | pr_debug("%s: on=%d\n", __func__, on); |
| 265 | |
| 266 | if (!dsi_power_on) { |
| 267 | reg_lvs7 = regulator_get(&msm_mipi_dsi1_device.dev, |
| 268 | "dsi1_vddio"); |
| 269 | if (IS_ERR_OR_NULL(reg_lvs7)) { |
| 270 | pr_err("could not get 8921_lvs7, rc = %ld\n", |
| 271 | PTR_ERR(reg_lvs7)); |
| 272 | return -ENODEV; |
| 273 | } |
| 274 | |
| 275 | reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev, |
| 276 | "dsi1_pll_vdda"); |
| 277 | if (IS_ERR_OR_NULL(reg_l2)) { |
| 278 | pr_err("could not get 8921_l2, rc = %ld\n", |
| 279 | PTR_ERR(reg_l2)); |
| 280 | return -ENODEV; |
| 281 | } |
| 282 | |
| 283 | rc = regulator_set_voltage(reg_l2, 1200000, 1200000); |
| 284 | if (rc) { |
| 285 | pr_err("set_voltage l2 failed, rc=%d\n", rc); |
| 286 | return -EINVAL; |
| 287 | } |
| 288 | reg_l11 = regulator_get(&msm_mipi_dsi1_device.dev, |
| 289 | "dsi1_avdd"); |
| 290 | if (IS_ERR(reg_l11)) { |
| 291 | pr_err("could not get 8921_l11, rc = %ld\n", |
| 292 | PTR_ERR(reg_l11)); |
| 293 | return -ENODEV; |
| 294 | } |
| 295 | rc = regulator_set_voltage(reg_l11, 3000000, 3000000); |
| 296 | if (rc) { |
| 297 | pr_err("set_voltage l11 failed, rc=%d\n", rc); |
| 298 | return -EINVAL; |
| 299 | } |
| 300 | |
| 301 | if (machine_is_apq8064_liquid()) { |
| 302 | reg_ext_3p3v = regulator_get(&msm_mipi_dsi1_device.dev, |
| 303 | "dsi1_vccs_3p3v"); |
| 304 | if (IS_ERR_OR_NULL(reg_ext_3p3v)) { |
| 305 | pr_err("could not get reg_ext_3p3v, rc = %ld\n", |
| 306 | PTR_ERR(reg_ext_3p3v)); |
| 307 | reg_ext_3p3v = NULL; |
| 308 | return -ENODEV; |
| 309 | } |
| 310 | mpp3 = PM8921_MPP_PM_TO_SYS(3); |
| 311 | rc = gpio_request(mpp3, "backlight_en"); |
| 312 | if (rc) { |
| 313 | pr_err("request mpp3 failed, rc=%d\n", rc); |
| 314 | return -ENODEV; |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | gpio25 = PM8921_GPIO_PM_TO_SYS(25); |
| 319 | rc = gpio_request(gpio25, "disp_rst_n"); |
| 320 | if (rc) { |
| 321 | pr_err("request gpio 25 failed, rc=%d\n", rc); |
| 322 | return -ENODEV; |
| 323 | } |
| 324 | |
| 325 | gpio26 = PM8921_GPIO_PM_TO_SYS(26); |
| 326 | rc = gpio_request(gpio26, "pwm_backlight_ctrl"); |
| 327 | if (rc) { |
| 328 | pr_err("request gpio 26 failed, rc=%d\n", rc); |
| 329 | return -ENODEV; |
| 330 | } |
| 331 | |
| 332 | gpio36 = PM8921_GPIO_PM_TO_SYS(36); /* lcd1_pwr_en_n */ |
| 333 | rc = gpio_request(gpio36, "lcd1_pwr_en_n"); |
| 334 | if (rc) { |
| 335 | pr_err("request gpio 36 failed, rc=%d\n", rc); |
| 336 | return -ENODEV; |
| 337 | } |
| 338 | |
| 339 | dsi_power_on = true; |
| 340 | } |
| 341 | |
| 342 | if (on) { |
| 343 | rc = regulator_enable(reg_lvs7); |
| 344 | if (rc) { |
| 345 | pr_err("enable lvs7 failed, rc=%d\n", rc); |
| 346 | return -ENODEV; |
| 347 | } |
| 348 | |
| 349 | rc = regulator_set_optimum_mode(reg_l11, 110000); |
| 350 | if (rc < 0) { |
| 351 | pr_err("set_optimum_mode l11 failed, rc=%d\n", rc); |
| 352 | return -EINVAL; |
| 353 | } |
| 354 | rc = regulator_enable(reg_l11); |
| 355 | if (rc) { |
| 356 | pr_err("enable l11 failed, rc=%d\n", rc); |
| 357 | return -ENODEV; |
| 358 | } |
| 359 | |
| 360 | rc = regulator_set_optimum_mode(reg_l2, 100000); |
| 361 | if (rc < 0) { |
| 362 | pr_err("set_optimum_mode l2 failed, rc=%d\n", rc); |
| 363 | return -EINVAL; |
| 364 | } |
| 365 | rc = regulator_enable(reg_l2); |
| 366 | if (rc) { |
| 367 | pr_err("enable l2 failed, rc=%d\n", rc); |
| 368 | return -ENODEV; |
| 369 | } |
| 370 | |
| 371 | if (machine_is_apq8064_liquid()) { |
| 372 | rc = regulator_enable(reg_ext_3p3v); |
| 373 | if (rc) { |
| 374 | pr_err("enable reg_ext_3p3v failed, rc=%d\n", |
| 375 | rc); |
| 376 | return -ENODEV; |
| 377 | } |
| 378 | gpio_set_value_cansleep(mpp3, 1); |
| 379 | } |
| 380 | |
| 381 | gpio_set_value_cansleep(gpio36, 0); |
| 382 | gpio_set_value_cansleep(gpio25, 1); |
| 383 | } else { |
| 384 | gpio_set_value_cansleep(gpio25, 0); |
| 385 | gpio_set_value_cansleep(gpio36, 1); |
| 386 | |
| 387 | if (machine_is_apq8064_liquid()) { |
| 388 | gpio_set_value_cansleep(mpp3, 0); |
| 389 | |
| 390 | rc = regulator_disable(reg_ext_3p3v); |
| 391 | if (rc) { |
| 392 | pr_err("disable reg_ext_3p3v failed, rc=%d\n", |
| 393 | rc); |
| 394 | return -ENODEV; |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | rc = regulator_disable(reg_lvs7); |
| 399 | if (rc) { |
| 400 | pr_err("disable reg_lvs7 failed, rc=%d\n", rc); |
| 401 | return -ENODEV; |
| 402 | } |
| 403 | rc = regulator_disable(reg_l2); |
| 404 | if (rc) { |
| 405 | pr_err("disable reg_l2 failed, rc=%d\n", rc); |
| 406 | return -ENODEV; |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | return 0; |
| 411 | } |
| 412 | |
| 413 | static struct mipi_dsi_platform_data mipi_dsi_pdata = { |
| 414 | .dsi_power_save = mipi_dsi_panel_power, |
| 415 | }; |
| 416 | |
| 417 | static bool lvds_power_on; |
| 418 | static int lvds_panel_power(int on) |
| 419 | { |
| 420 | static struct regulator *reg_lvs7, *reg_l2, *reg_ext_3p3v; |
| 421 | static int gpio36, gpio26, mpp3; |
| 422 | int rc; |
| 423 | |
| 424 | pr_debug("%s: on=%d\n", __func__, on); |
| 425 | |
| 426 | if (!lvds_power_on) { |
| 427 | reg_lvs7 = regulator_get(&msm_lvds_device.dev, |
| 428 | "lvds_vdda"); |
| 429 | if (IS_ERR_OR_NULL(reg_lvs7)) { |
| 430 | pr_err("could not get 8921_lvs7, rc = %ld\n", |
| 431 | PTR_ERR(reg_lvs7)); |
| 432 | return -ENODEV; |
| 433 | } |
| 434 | |
| 435 | reg_l2 = regulator_get(&msm_lvds_device.dev, |
| 436 | "lvds_pll_vdda"); |
| 437 | if (IS_ERR_OR_NULL(reg_l2)) { |
| 438 | pr_err("could not get 8921_l2, rc = %ld\n", |
| 439 | PTR_ERR(reg_l2)); |
| 440 | return -ENODEV; |
| 441 | } |
| 442 | |
| 443 | rc = regulator_set_voltage(reg_l2, 1200000, 1200000); |
| 444 | if (rc) { |
| 445 | pr_err("set_voltage l2 failed, rc=%d\n", rc); |
| 446 | return -EINVAL; |
| 447 | } |
| 448 | |
| 449 | reg_ext_3p3v = regulator_get(&msm_lvds_device.dev, |
| 450 | "lvds_vccs_3p3v"); |
| 451 | if (IS_ERR_OR_NULL(reg_ext_3p3v)) { |
| 452 | pr_err("could not get reg_ext_3p3v, rc = %ld\n", |
| 453 | PTR_ERR(reg_ext_3p3v)); |
| 454 | return -ENODEV; |
| 455 | } |
| 456 | |
| 457 | gpio26 = PM8921_GPIO_PM_TO_SYS(26); |
| 458 | rc = gpio_request(gpio26, "pwm_backlight_ctrl"); |
| 459 | if (rc) { |
| 460 | pr_err("request gpio 26 failed, rc=%d\n", rc); |
| 461 | return -ENODEV; |
| 462 | } |
| 463 | |
| 464 | gpio36 = PM8921_GPIO_PM_TO_SYS(36); /* lcd1_pwr_en_n */ |
| 465 | rc = gpio_request(gpio36, "lcd1_pwr_en_n"); |
| 466 | if (rc) { |
| 467 | pr_err("request gpio 36 failed, rc=%d\n", rc); |
| 468 | return -ENODEV; |
| 469 | } |
| 470 | |
| 471 | mpp3 = PM8921_MPP_PM_TO_SYS(3); |
| 472 | rc = gpio_request(mpp3, "backlight_en"); |
| 473 | if (rc) { |
| 474 | pr_err("request mpp3 failed, rc=%d\n", rc); |
| 475 | return -ENODEV; |
| 476 | } |
| 477 | |
| 478 | lvds_power_on = true; |
| 479 | } |
| 480 | |
| 481 | if (on) { |
| 482 | rc = regulator_enable(reg_lvs7); |
| 483 | if (rc) { |
| 484 | pr_err("enable lvs7 failed, rc=%d\n", rc); |
| 485 | return -ENODEV; |
| 486 | } |
| 487 | |
| 488 | rc = regulator_set_optimum_mode(reg_l2, 100000); |
| 489 | if (rc < 0) { |
| 490 | pr_err("set_optimum_mode l2 failed, rc=%d\n", rc); |
| 491 | return -EINVAL; |
| 492 | } |
| 493 | rc = regulator_enable(reg_l2); |
| 494 | if (rc) { |
| 495 | pr_err("enable l2 failed, rc=%d\n", rc); |
| 496 | return -ENODEV; |
| 497 | } |
| 498 | |
| 499 | rc = regulator_enable(reg_ext_3p3v); |
| 500 | if (rc) { |
| 501 | pr_err("enable reg_ext_3p3v failed, rc=%d\n", rc); |
| 502 | return -ENODEV; |
| 503 | } |
| 504 | |
| 505 | gpio_set_value_cansleep(gpio36, 0); |
| 506 | gpio_set_value_cansleep(mpp3, 1); |
| 507 | } else { |
| 508 | gpio_set_value_cansleep(mpp3, 0); |
| 509 | gpio_set_value_cansleep(gpio36, 1); |
| 510 | |
| 511 | rc = regulator_disable(reg_lvs7); |
| 512 | if (rc) { |
| 513 | pr_err("disable reg_lvs7 failed, rc=%d\n", rc); |
| 514 | return -ENODEV; |
| 515 | } |
| 516 | rc = regulator_disable(reg_l2); |
| 517 | if (rc) { |
| 518 | pr_err("disable reg_l2 failed, rc=%d\n", rc); |
| 519 | return -ENODEV; |
| 520 | } |
| 521 | rc = regulator_disable(reg_ext_3p3v); |
| 522 | if (rc) { |
| 523 | pr_err("disable reg_ext_3p3v failed, rc=%d\n", rc); |
| 524 | return -ENODEV; |
| 525 | } |
| 526 | } |
| 527 | |
| 528 | return 0; |
| 529 | } |
| 530 | |
| 531 | static struct lcdc_platform_data lvds_pdata = { |
| 532 | .lcdc_power_save = lvds_panel_power, |
| 533 | }; |
| 534 | |
| 535 | #define LPM_CHANNEL 2 |
| 536 | static int lvds_chimei_gpio[] = {LPM_CHANNEL}; |
| 537 | |
| 538 | static struct lvds_panel_platform_data lvds_chimei_pdata = { |
| 539 | .gpio = lvds_chimei_gpio, |
| 540 | }; |
| 541 | |
| 542 | static struct platform_device lvds_chimei_panel_device = { |
| 543 | .name = "lvds_chimei_wxga", |
| 544 | .id = 0, |
| 545 | .dev = { |
| 546 | .platform_data = &lvds_chimei_pdata, |
| 547 | } |
| 548 | }; |
| 549 | |
| 550 | static int dsi2lvds_gpio[2] = { |
| 551 | LPM_CHANNEL,/* Backlight PWM-ID=0 for PMIC-GPIO#24 */ |
| 552 | 0x1F08 /* DSI2LVDS Bridge GPIO Output, mask=0x1f, out=0x08 */ |
| 553 | }; |
| 554 | static struct msm_panel_common_pdata mipi_dsi2lvds_pdata = { |
| 555 | .gpio_num = dsi2lvds_gpio, |
| 556 | }; |
| 557 | |
| 558 | static struct platform_device mipi_dsi2lvds_bridge_device = { |
| 559 | .name = "mipi_tc358764", |
| 560 | .id = 0, |
| 561 | .dev.platform_data = &mipi_dsi2lvds_pdata, |
| 562 | }; |
| 563 | |
| 564 | static int toshiba_gpio[] = {LPM_CHANNEL}; |
| 565 | static struct mipi_dsi_panel_platform_data toshiba_pdata = { |
| 566 | .gpio = toshiba_gpio, |
| 567 | }; |
| 568 | |
| 569 | static struct platform_device mipi_dsi_toshiba_panel_device = { |
| 570 | .name = "mipi_toshiba", |
| 571 | .id = 0, |
| 572 | .dev = { |
| 573 | .platform_data = &toshiba_pdata, |
| 574 | } |
| 575 | }; |
| 576 | |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 577 | void __init apq8064_init_fb(void) |
| 578 | { |
| 579 | platform_device_register(&msm_fb_device); |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 580 | platform_device_register(&lvds_chimei_panel_device); |
| 581 | |
| 582 | if (machine_is_apq8064_liquid()) |
| 583 | platform_device_register(&mipi_dsi2lvds_bridge_device); |
| 584 | if (machine_is_apq8064_mtp()) |
| 585 | platform_device_register(&mipi_dsi_toshiba_panel_device); |
| 586 | |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 587 | msm_fb_register_device("mdp", &mdp_pdata); |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 588 | msm_fb_register_device("lvds", &lvds_pdata); |
| 589 | msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata); |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 590 | } |