Stepan Moskovchenko | 39236d7 | 2011-11-30 17:42:23 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #include <linux/init.h> |
| 15 | #include <linux/ioport.h> |
| 16 | #include <linux/platform_device.h> |
| 17 | #include <linux/bootmem.h> |
| 18 | #include <asm/mach-types.h> |
| 19 | #include <mach/msm_bus_board.h> |
| 20 | #include <mach/board.h> |
| 21 | #include <mach/gpio.h> |
| 22 | #include <mach/gpiomux.h> |
Ajay Dudani | 9114be7 | 2011-12-03 07:46:35 -0800 | [diff] [blame] | 23 | #include <mach/socinfo.h> |
Stepan Moskovchenko | 39236d7 | 2011-11-30 17:42:23 -0800 | [diff] [blame] | 24 | #include "devices.h" |
Jay Chokshi | 06fa754 | 2011-12-07 13:09:17 -0800 | [diff] [blame] | 25 | |
| 26 | /* TODO: Remove this once PM8038 physically becomes |
| 27 | * available. |
| 28 | */ |
| 29 | #ifndef MSM8930_PHASE_2 |
| 30 | #include "board-8960.h" |
| 31 | #else |
Stepan Moskovchenko | 5a83dba | 2011-12-05 17:30:17 -0800 | [diff] [blame] | 32 | #include "board-8930.h" |
Jay Chokshi | 06fa754 | 2011-12-07 13:09:17 -0800 | [diff] [blame] | 33 | #endif |
Stepan Moskovchenko | 39236d7 | 2011-11-30 17:42:23 -0800 | [diff] [blame] | 34 | |
| 35 | #ifdef CONFIG_FB_MSM_TRIPLE_BUFFER |
| 36 | #define MSM_FB_PRIM_BUF_SIZE (1376 * 768 * 4 * 3) /* 4 bpp x 3 pages */ |
| 37 | #else |
| 38 | #define MSM_FB_PRIM_BUF_SIZE (1376 * 768 * 4 * 2) /* 4 bpp x 2 pages */ |
| 39 | #endif |
| 40 | |
| 41 | #ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL |
| 42 | #define MSM_FB_EXT_BUF_SIZE (1920 * 1088 * 2 * 1) /* 2 bpp x 1 page */ |
| 43 | #elif defined(CONFIG_FB_MSM_TVOUT) |
| 44 | #define MSM_FB_EXT_BUF_SIZE (720 * 576 * 2 * 2) /* 2 bpp x 2 pages */ |
| 45 | #else |
| 46 | #define MSM_FB_EXT_BUF_SIZE 0 |
| 47 | #endif |
| 48 | |
| 49 | #ifdef CONFIG_FB_MSM_OVERLAY_WRITEBACK |
| 50 | /* width x height x 3 bpp x 2 frame buffer */ |
| 51 | #define MSM_FB_WRITEBACK_SIZE (1376 * 768 * 3 * 2) |
| 52 | #define MSM_FB_WRITEBACK_OFFSET \ |
| 53 | (MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE) |
| 54 | #else |
| 55 | #define MSM_FB_WRITEBACK_SIZE 0 |
| 56 | #define MSM_FB_WRITEBACK_OFFSET 0 |
| 57 | #endif |
| 58 | |
| 59 | #ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY |
| 60 | /* 4 bpp x 2 page HDMI case */ |
| 61 | #define MSM_FB_SIZE roundup((1920 * 1088 * 4 * 2), 4096) |
| 62 | #else |
| 63 | /* Note: must be multiple of 4096 */ |
| 64 | #define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE + \ |
| 65 | MSM_FB_WRITEBACK_SIZE, 4096) |
| 66 | #endif |
| 67 | |
| 68 | #define MDP_VSYNC_GPIO 0 |
| 69 | |
| 70 | #define PANEL_NAME_MAX_LEN 30 |
| 71 | #define MIPI_CMD_NOVATEK_QHD_PANEL_NAME "mipi_cmd_novatek_qhd" |
| 72 | #define MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME "mipi_video_novatek_qhd" |
| 73 | #define MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME "mipi_video_toshiba_wsvga" |
| 74 | #define MIPI_VIDEO_CHIMEI_WXGA_PANEL_NAME "mipi_video_chimei_wxga" |
| 75 | #define MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME "mipi_video_simulator_vga" |
| 76 | #define MIPI_CMD_RENESAS_FWVGA_PANEL_NAME "mipi_cmd_renesas_fwvga" |
| 77 | #define HDMI_PANEL_NAME "hdmi_msm" |
| 78 | #define TVOUT_PANEL_NAME "tvout_msm" |
| 79 | |
| 80 | static int writeback_offset(void) |
| 81 | { |
| 82 | return MSM_FB_WRITEBACK_OFFSET; |
| 83 | } |
| 84 | |
| 85 | static struct resource msm_fb_resources[] = { |
| 86 | { |
| 87 | .flags = IORESOURCE_DMA, |
| 88 | } |
| 89 | }; |
| 90 | |
| 91 | static int msm_fb_detect_panel(const char *name) |
| 92 | { |
| 93 | if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME, |
| 94 | strnlen(MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME, |
| 95 | PANEL_NAME_MAX_LEN))) |
| 96 | return 0; |
| 97 | |
| 98 | #ifndef CONFIG_FB_MSM_MIPI_PANEL_DETECT |
| 99 | if (!strncmp(name, MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME, |
| 100 | strnlen(MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME, |
| 101 | PANEL_NAME_MAX_LEN))) |
| 102 | return 0; |
| 103 | |
| 104 | if (!strncmp(name, MIPI_CMD_NOVATEK_QHD_PANEL_NAME, |
| 105 | strnlen(MIPI_CMD_NOVATEK_QHD_PANEL_NAME, |
| 106 | PANEL_NAME_MAX_LEN))) |
| 107 | return 0; |
| 108 | |
| 109 | if (!strncmp(name, MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME, |
| 110 | strnlen(MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME, |
| 111 | PANEL_NAME_MAX_LEN))) |
| 112 | return 0; |
| 113 | |
| 114 | if (!strncmp(name, MIPI_CMD_RENESAS_FWVGA_PANEL_NAME, |
| 115 | strnlen(MIPI_CMD_RENESAS_FWVGA_PANEL_NAME, |
| 116 | PANEL_NAME_MAX_LEN))) |
| 117 | return 0; |
| 118 | #endif |
| 119 | |
| 120 | if (!strncmp(name, HDMI_PANEL_NAME, |
| 121 | strnlen(HDMI_PANEL_NAME, |
| 122 | PANEL_NAME_MAX_LEN))) |
| 123 | return 0; |
| 124 | |
| 125 | if (!strncmp(name, TVOUT_PANEL_NAME, |
| 126 | strnlen(TVOUT_PANEL_NAME, |
| 127 | PANEL_NAME_MAX_LEN))) |
| 128 | return 0; |
| 129 | |
| 130 | pr_warning("%s: not supported '%s'", __func__, name); |
| 131 | return -ENODEV; |
| 132 | } |
| 133 | |
| 134 | static struct msm_fb_platform_data msm_fb_pdata = { |
| 135 | .detect_client = msm_fb_detect_panel, |
| 136 | }; |
| 137 | |
| 138 | static struct platform_device msm_fb_device = { |
| 139 | .name = "msm_fb", |
| 140 | .id = 0, |
| 141 | .num_resources = ARRAY_SIZE(msm_fb_resources), |
| 142 | .resource = msm_fb_resources, |
| 143 | .dev.platform_data = &msm_fb_pdata, |
| 144 | }; |
| 145 | |
| 146 | static bool dsi_power_on; |
| 147 | |
Jay Chokshi | 06fa754 | 2011-12-07 13:09:17 -0800 | [diff] [blame] | 148 | /* |
| 149 | * TODO: When physical 8930/PM8038 hardware becomes |
| 150 | * available, replace mipi_dsi_cdp_panel_power with |
| 151 | * appropriate function. |
| 152 | */ |
| 153 | #ifndef MSM8930_PHASE_2 |
Stepan Moskovchenko | 39236d7 | 2011-11-30 17:42:23 -0800 | [diff] [blame] | 154 | static int mipi_dsi_cdp_panel_power(int on) |
| 155 | { |
| 156 | static struct regulator *reg_l8, *reg_l23, *reg_l2; |
| 157 | static int gpio43; |
| 158 | int rc; |
| 159 | |
| 160 | pr_info("%s: state : %d\n", __func__, on); |
| 161 | |
| 162 | if (!dsi_power_on) { |
| 163 | |
| 164 | reg_l8 = regulator_get(&msm_mipi_dsi1_device.dev, |
| 165 | "dsi_vdc"); |
| 166 | if (IS_ERR(reg_l8)) { |
| 167 | pr_err("could not get 8921_l8, rc = %ld\n", |
| 168 | PTR_ERR(reg_l8)); |
| 169 | return -ENODEV; |
| 170 | } |
| 171 | reg_l23 = regulator_get(&msm_mipi_dsi1_device.dev, |
| 172 | "dsi_vddio"); |
| 173 | if (IS_ERR(reg_l23)) { |
| 174 | pr_err("could not get 8921_l23, rc = %ld\n", |
| 175 | PTR_ERR(reg_l23)); |
| 176 | return -ENODEV; |
| 177 | } |
| 178 | reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev, |
| 179 | "dsi_vdda"); |
| 180 | if (IS_ERR(reg_l2)) { |
| 181 | pr_err("could not get 8921_l2, rc = %ld\n", |
| 182 | PTR_ERR(reg_l2)); |
| 183 | return -ENODEV; |
| 184 | } |
| 185 | rc = regulator_set_voltage(reg_l8, 2800000, 3000000); |
| 186 | if (rc) { |
| 187 | pr_err("set_voltage l8 failed, rc=%d\n", rc); |
| 188 | return -EINVAL; |
| 189 | } |
| 190 | rc = regulator_set_voltage(reg_l23, 1800000, 1800000); |
| 191 | if (rc) { |
| 192 | pr_err("set_voltage l23 failed, rc=%d\n", rc); |
| 193 | return -EINVAL; |
| 194 | } |
| 195 | rc = regulator_set_voltage(reg_l2, 1200000, 1200000); |
| 196 | if (rc) { |
| 197 | pr_err("set_voltage l2 failed, rc=%d\n", rc); |
| 198 | return -EINVAL; |
| 199 | } |
| 200 | gpio43 = PM8921_GPIO_PM_TO_SYS(43); |
| 201 | rc = gpio_request(gpio43, "disp_rst_n"); |
| 202 | if (rc) { |
| 203 | pr_err("request gpio 43 failed, rc=%d\n", rc); |
| 204 | return -ENODEV; |
| 205 | } |
| 206 | dsi_power_on = true; |
| 207 | } |
| 208 | if (on) { |
| 209 | rc = regulator_set_optimum_mode(reg_l8, 100000); |
| 210 | if (rc < 0) { |
| 211 | pr_err("set_optimum_mode l8 failed, rc=%d\n", rc); |
| 212 | return -EINVAL; |
| 213 | } |
| 214 | rc = regulator_set_optimum_mode(reg_l23, 100000); |
| 215 | if (rc < 0) { |
| 216 | pr_err("set_optimum_mode l23 failed, rc=%d\n", rc); |
| 217 | return -EINVAL; |
| 218 | } |
| 219 | rc = regulator_set_optimum_mode(reg_l2, 100000); |
| 220 | if (rc < 0) { |
| 221 | pr_err("set_optimum_mode l2 failed, rc=%d\n", rc); |
| 222 | return -EINVAL; |
| 223 | } |
| 224 | rc = regulator_enable(reg_l8); |
| 225 | if (rc) { |
| 226 | pr_err("enable l8 failed, rc=%d\n", rc); |
| 227 | return -ENODEV; |
| 228 | } |
| 229 | rc = regulator_enable(reg_l23); |
| 230 | if (rc) { |
| 231 | pr_err("enable l8 failed, rc=%d\n", rc); |
| 232 | return -ENODEV; |
| 233 | } |
| 234 | rc = regulator_enable(reg_l2); |
| 235 | if (rc) { |
| 236 | pr_err("enable l2 failed, rc=%d\n", rc); |
| 237 | return -ENODEV; |
| 238 | } |
| 239 | gpio_set_value_cansleep(gpio43, 1); |
| 240 | } else { |
| 241 | rc = regulator_disable(reg_l2); |
| 242 | if (rc) { |
| 243 | pr_err("disable reg_l2 failed, rc=%d\n", rc); |
| 244 | return -ENODEV; |
| 245 | } |
| 246 | rc = regulator_disable(reg_l8); |
| 247 | if (rc) { |
| 248 | pr_err("disable reg_l8 failed, rc=%d\n", rc); |
| 249 | return -ENODEV; |
| 250 | } |
| 251 | rc = regulator_disable(reg_l23); |
| 252 | if (rc) { |
| 253 | pr_err("disable reg_l23 failed, rc=%d\n", rc); |
| 254 | return -ENODEV; |
| 255 | } |
| 256 | rc = regulator_set_optimum_mode(reg_l8, 100); |
| 257 | if (rc < 0) { |
| 258 | pr_err("set_optimum_mode l8 failed, rc=%d\n", rc); |
| 259 | return -EINVAL; |
| 260 | } |
| 261 | rc = regulator_set_optimum_mode(reg_l23, 100); |
| 262 | if (rc < 0) { |
| 263 | pr_err("set_optimum_mode l23 failed, rc=%d\n", rc); |
| 264 | return -EINVAL; |
| 265 | } |
| 266 | rc = regulator_set_optimum_mode(reg_l2, 100); |
| 267 | if (rc < 0) { |
| 268 | pr_err("set_optimum_mode l2 failed, rc=%d\n", rc); |
| 269 | return -EINVAL; |
| 270 | } |
| 271 | gpio_set_value_cansleep(gpio43, 0); |
| 272 | } |
| 273 | return 0; |
| 274 | } |
Jay Chokshi | 06fa754 | 2011-12-07 13:09:17 -0800 | [diff] [blame] | 275 | #endif |
Stepan Moskovchenko | 39236d7 | 2011-11-30 17:42:23 -0800 | [diff] [blame] | 276 | |
| 277 | static int mipi_dsi_panel_power(int on) |
| 278 | { |
| 279 | pr_info("%s: on=%d\n", __func__, on); |
| 280 | |
| 281 | return mipi_dsi_cdp_panel_power(on); |
| 282 | } |
| 283 | |
| 284 | static struct mipi_dsi_platform_data mipi_dsi_pdata = { |
| 285 | .vsync_gpio = MDP_VSYNC_GPIO, |
| 286 | .dsi_power_save = mipi_dsi_panel_power, |
| 287 | }; |
| 288 | |
| 289 | #ifdef CONFIG_MSM_BUS_SCALING |
| 290 | |
| 291 | static struct msm_bus_vectors mdp_init_vectors[] = { |
| 292 | { |
| 293 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 294 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 295 | .ab = 0, |
| 296 | .ib = 0, |
| 297 | }, |
| 298 | }; |
| 299 | |
| 300 | #ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY |
| 301 | static struct msm_bus_vectors hdmi_as_primary_vectors[] = { |
| 302 | /* If HDMI is used as primary */ |
| 303 | { |
| 304 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 305 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 306 | .ab = 2000000000, |
| 307 | .ib = 2000000000, |
| 308 | }, |
| 309 | }; |
| 310 | static struct msm_bus_paths mdp_bus_scale_usecases[] = { |
| 311 | { |
| 312 | ARRAY_SIZE(mdp_init_vectors), |
| 313 | mdp_init_vectors, |
| 314 | }, |
| 315 | { |
| 316 | ARRAY_SIZE(hdmi_as_primary_vectors), |
| 317 | hdmi_as_primary_vectors, |
| 318 | }, |
| 319 | { |
| 320 | ARRAY_SIZE(hdmi_as_primary_vectors), |
| 321 | hdmi_as_primary_vectors, |
| 322 | }, |
| 323 | { |
| 324 | ARRAY_SIZE(hdmi_as_primary_vectors), |
| 325 | hdmi_as_primary_vectors, |
| 326 | }, |
| 327 | { |
| 328 | ARRAY_SIZE(hdmi_as_primary_vectors), |
| 329 | hdmi_as_primary_vectors, |
| 330 | }, |
| 331 | { |
| 332 | ARRAY_SIZE(hdmi_as_primary_vectors), |
| 333 | hdmi_as_primary_vectors, |
| 334 | }, |
| 335 | }; |
| 336 | #else |
| 337 | static struct msm_bus_vectors mdp_ui_vectors[] = { |
| 338 | { |
| 339 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 340 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 341 | .ab = 216000000 * 2, |
| 342 | .ib = 270000000 * 2, |
| 343 | }, |
| 344 | }; |
| 345 | |
| 346 | static struct msm_bus_vectors mdp_vga_vectors[] = { |
| 347 | /* VGA and less video */ |
| 348 | { |
| 349 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 350 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 351 | .ab = 216000000 * 2, |
| 352 | .ib = 270000000 * 2, |
| 353 | }, |
| 354 | }; |
| 355 | |
| 356 | static struct msm_bus_vectors mdp_720p_vectors[] = { |
| 357 | /* 720p and less video */ |
| 358 | { |
| 359 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 360 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 361 | .ab = 230400000 * 2, |
| 362 | .ib = 288000000 * 2, |
| 363 | }, |
| 364 | }; |
| 365 | |
| 366 | static struct msm_bus_vectors mdp_1080p_vectors[] = { |
| 367 | /* 1080p and less video */ |
| 368 | { |
| 369 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 370 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 371 | .ab = 334080000 * 2, |
| 372 | .ib = 417600000 * 2, |
| 373 | }, |
| 374 | }; |
| 375 | |
| 376 | static struct msm_bus_paths mdp_bus_scale_usecases[] = { |
| 377 | { |
| 378 | ARRAY_SIZE(mdp_init_vectors), |
| 379 | mdp_init_vectors, |
| 380 | }, |
| 381 | { |
| 382 | ARRAY_SIZE(mdp_ui_vectors), |
| 383 | mdp_ui_vectors, |
| 384 | }, |
| 385 | { |
| 386 | ARRAY_SIZE(mdp_ui_vectors), |
| 387 | mdp_ui_vectors, |
| 388 | }, |
| 389 | { |
| 390 | ARRAY_SIZE(mdp_vga_vectors), |
| 391 | mdp_vga_vectors, |
| 392 | }, |
| 393 | { |
| 394 | ARRAY_SIZE(mdp_720p_vectors), |
| 395 | mdp_720p_vectors, |
| 396 | }, |
| 397 | { |
| 398 | ARRAY_SIZE(mdp_1080p_vectors), |
| 399 | mdp_1080p_vectors, |
| 400 | }, |
| 401 | }; |
| 402 | #endif |
| 403 | |
| 404 | static struct msm_bus_scale_pdata mdp_bus_scale_pdata = { |
| 405 | mdp_bus_scale_usecases, |
| 406 | ARRAY_SIZE(mdp_bus_scale_usecases), |
| 407 | .name = "mdp", |
| 408 | }; |
| 409 | |
| 410 | #endif |
| 411 | |
| 412 | #ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY |
| 413 | static int mdp_core_clk_rate_table[] = { |
| 414 | 200000000, |
| 415 | 200000000, |
| 416 | 200000000, |
| 417 | 200000000, |
| 418 | }; |
| 419 | #else |
| 420 | static int mdp_core_clk_rate_table[] = { |
| 421 | 85330000, |
| 422 | 85330000, |
| 423 | 160000000, |
| 424 | 200000000, |
| 425 | }; |
| 426 | #endif |
| 427 | |
| 428 | static struct msm_panel_common_pdata mdp_pdata = { |
| 429 | .gpio = MDP_VSYNC_GPIO, |
| 430 | #ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY |
| 431 | .mdp_core_clk_rate = 200000000, |
| 432 | #else |
| 433 | .mdp_core_clk_rate = 85330000, |
| 434 | #endif |
| 435 | .mdp_core_clk_table = mdp_core_clk_rate_table, |
| 436 | .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table), |
| 437 | #ifdef CONFIG_MSM_BUS_SCALING |
| 438 | .mdp_bus_scale_table = &mdp_bus_scale_pdata, |
| 439 | #endif |
| 440 | .mdp_rev = MDP_REV_42, |
| 441 | .writeback_offset = writeback_offset, |
| 442 | }; |
| 443 | |
| 444 | #define LPM_CHANNEL0 0 |
| 445 | static int toshiba_gpio[] = {LPM_CHANNEL0}; |
| 446 | |
| 447 | static struct mipi_dsi_panel_platform_data toshiba_pdata = { |
| 448 | .gpio = toshiba_gpio, |
| 449 | }; |
| 450 | |
| 451 | static struct platform_device mipi_dsi_toshiba_panel_device = { |
| 452 | .name = "mipi_toshiba", |
| 453 | .id = 0, |
| 454 | .dev = { |
| 455 | .platform_data = &toshiba_pdata, |
| 456 | } |
| 457 | }; |
| 458 | |
| 459 | #define FPGA_3D_GPIO_CONFIG_ADDR 0xB5 |
| 460 | |
| 461 | static struct mipi_dsi_phy_ctrl dsi_novatek_cmd_mode_phy_db = { |
| 462 | |
| 463 | /* DSI_BIT_CLK at 500MHz, 2 lane, RGB888 */ |
| 464 | {0x0F, 0x0a, 0x04, 0x00, 0x20}, /* regulator */ |
| 465 | /* timing */ |
| 466 | {0xab, 0x8a, 0x18, 0x00, 0x92, 0x97, 0x1b, 0x8c, |
| 467 | 0x0c, 0x03, 0x04, 0xa0}, |
| 468 | {0x5f, 0x00, 0x00, 0x10}, /* phy ctrl */ |
| 469 | {0xff, 0x00, 0x06, 0x00}, /* strength */ |
| 470 | /* pll control */ |
| 471 | {0x40, 0xf9, 0x30, 0xda, 0x00, 0x40, 0x03, 0x62, |
| 472 | 0x40, 0x07, 0x03, |
| 473 | 0x00, 0x1a, 0x00, 0x00, 0x02, 0x00, 0x20, 0x00, 0x01}, |
| 474 | }; |
| 475 | |
| 476 | static struct mipi_dsi_panel_platform_data novatek_pdata = { |
| 477 | .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR, |
| 478 | .fpga_ctrl_mode = FPGA_SPI_INTF, |
| 479 | .phy_ctrl_settings = &dsi_novatek_cmd_mode_phy_db, |
| 480 | }; |
| 481 | |
| 482 | static struct platform_device mipi_dsi_novatek_panel_device = { |
| 483 | .name = "mipi_novatek", |
| 484 | .id = 0, |
| 485 | .dev = { |
| 486 | .platform_data = &novatek_pdata, |
| 487 | } |
| 488 | }; |
| 489 | |
| 490 | #ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL |
| 491 | static struct resource hdmi_msm_resources[] = { |
| 492 | { |
| 493 | .name = "hdmi_msm_qfprom_addr", |
| 494 | .start = 0x00700000, |
| 495 | .end = 0x007060FF, |
| 496 | .flags = IORESOURCE_MEM, |
| 497 | }, |
| 498 | { |
| 499 | .name = "hdmi_msm_hdmi_addr", |
| 500 | .start = 0x04A00000, |
| 501 | .end = 0x04A00FFF, |
| 502 | .flags = IORESOURCE_MEM, |
| 503 | }, |
| 504 | { |
| 505 | .name = "hdmi_msm_irq", |
| 506 | .start = HDMI_IRQ, |
| 507 | .end = HDMI_IRQ, |
| 508 | .flags = IORESOURCE_IRQ, |
| 509 | }, |
| 510 | }; |
| 511 | |
| 512 | static int hdmi_enable_5v(int on); |
| 513 | static int hdmi_core_power(int on, int show); |
| 514 | static int hdmi_cec_power(int on); |
| 515 | |
| 516 | static struct msm_hdmi_platform_data hdmi_msm_data = { |
| 517 | .irq = HDMI_IRQ, |
| 518 | .enable_5v = hdmi_enable_5v, |
| 519 | .core_power = hdmi_core_power, |
| 520 | .cec_power = hdmi_cec_power, |
| 521 | }; |
| 522 | |
| 523 | static struct platform_device hdmi_msm_device = { |
| 524 | .name = "hdmi_msm", |
| 525 | .id = 0, |
| 526 | .num_resources = ARRAY_SIZE(hdmi_msm_resources), |
| 527 | .resource = hdmi_msm_resources, |
| 528 | .dev.platform_data = &hdmi_msm_data, |
| 529 | }; |
| 530 | #endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */ |
| 531 | |
| 532 | #ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL |
| 533 | static struct platform_device wfd_panel_device = { |
| 534 | .name = "wfd_panel", |
| 535 | .id = 0, |
| 536 | .dev.platform_data = NULL, |
| 537 | }; |
| 538 | |
| 539 | static struct platform_device wfd_device = { |
| 540 | .name = "msm_wfd", |
| 541 | .id = -1, |
| 542 | }; |
| 543 | #endif |
| 544 | |
| 545 | #ifdef CONFIG_MSM_BUS_SCALING |
| 546 | static struct msm_bus_vectors dtv_bus_init_vectors[] = { |
| 547 | { |
| 548 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 549 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 550 | .ab = 0, |
| 551 | .ib = 0, |
| 552 | }, |
| 553 | }; |
| 554 | |
| 555 | #ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY |
| 556 | static struct msm_bus_vectors dtv_bus_def_vectors[] = { |
| 557 | { |
| 558 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 559 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 560 | .ab = 2000000000, |
| 561 | .ib = 2000000000, |
| 562 | }, |
| 563 | }; |
| 564 | #else |
| 565 | static struct msm_bus_vectors dtv_bus_def_vectors[] = { |
| 566 | { |
| 567 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 568 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 569 | .ab = 566092800 * 2, |
| 570 | .ib = 707616000 * 2, |
| 571 | }, |
| 572 | }; |
| 573 | #endif |
| 574 | |
| 575 | static struct msm_bus_paths dtv_bus_scale_usecases[] = { |
| 576 | { |
| 577 | ARRAY_SIZE(dtv_bus_init_vectors), |
| 578 | dtv_bus_init_vectors, |
| 579 | }, |
| 580 | { |
| 581 | ARRAY_SIZE(dtv_bus_def_vectors), |
| 582 | dtv_bus_def_vectors, |
| 583 | }, |
| 584 | }; |
| 585 | static struct msm_bus_scale_pdata dtv_bus_scale_pdata = { |
| 586 | dtv_bus_scale_usecases, |
| 587 | ARRAY_SIZE(dtv_bus_scale_usecases), |
| 588 | .name = "dtv", |
| 589 | }; |
| 590 | |
| 591 | static struct lcdc_platform_data dtv_pdata = { |
| 592 | .bus_scale_table = &dtv_bus_scale_pdata, |
| 593 | }; |
| 594 | #endif |
| 595 | |
Stepan Moskovchenko | 39236d7 | 2011-11-30 17:42:23 -0800 | [diff] [blame] | 596 | #ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL |
Stepan Moskovchenko | 39236d7 | 2011-11-30 17:42:23 -0800 | [diff] [blame] | 597 | static int hdmi_enable_5v(int on) |
| 598 | { |
| 599 | /* TBD: PM8921 regulator instead of 8901 */ |
| 600 | static struct regulator *reg_8921_hdmi_mvs; /* HDMI_5V */ |
| 601 | static int prev_on; |
| 602 | int rc; |
| 603 | |
| 604 | if (on == prev_on) |
| 605 | return 0; |
| 606 | |
| 607 | if (!reg_8921_hdmi_mvs) |
| 608 | reg_8921_hdmi_mvs = regulator_get(&hdmi_msm_device.dev, |
| 609 | "hdmi_mvs"); |
| 610 | |
| 611 | if (on) { |
| 612 | rc = regulator_enable(reg_8921_hdmi_mvs); |
| 613 | if (rc) { |
| 614 | pr_err("'%s' regulator enable failed, rc=%d\n", |
| 615 | "8921_hdmi_mvs", rc); |
| 616 | return rc; |
| 617 | } |
| 618 | pr_debug("%s(on): success\n", __func__); |
| 619 | } else { |
| 620 | rc = regulator_disable(reg_8921_hdmi_mvs); |
| 621 | if (rc) |
| 622 | pr_warning("'%s' regulator disable failed, rc=%d\n", |
| 623 | "8921_hdmi_mvs", rc); |
| 624 | pr_debug("%s(off): success\n", __func__); |
| 625 | } |
| 626 | |
| 627 | prev_on = on; |
| 628 | |
| 629 | return 0; |
| 630 | } |
| 631 | |
| 632 | static int hdmi_core_power(int on, int show) |
| 633 | { |
| 634 | static struct regulator *reg_8921_l23, *reg_8921_s4; |
| 635 | static int prev_on; |
| 636 | int rc; |
| 637 | |
| 638 | if (on == prev_on) |
| 639 | return 0; |
| 640 | |
| 641 | /* TBD: PM8921 regulator instead of 8901 */ |
| 642 | if (!reg_8921_l23) { |
| 643 | reg_8921_l23 = regulator_get(&hdmi_msm_device.dev, "hdmi_avdd"); |
| 644 | if (IS_ERR(reg_8921_l23)) { |
| 645 | pr_err("could not get reg_8921_l23, rc = %ld\n", |
| 646 | PTR_ERR(reg_8921_l23)); |
| 647 | return -ENODEV; |
| 648 | } |
| 649 | rc = regulator_set_voltage(reg_8921_l23, 1800000, 1800000); |
| 650 | if (rc) { |
| 651 | pr_err("set_voltage failed for 8921_l23, rc=%d\n", rc); |
| 652 | return -EINVAL; |
| 653 | } |
| 654 | } |
| 655 | if (!reg_8921_s4) { |
| 656 | reg_8921_s4 = regulator_get(&hdmi_msm_device.dev, "hdmi_vcc"); |
| 657 | if (IS_ERR(reg_8921_s4)) { |
| 658 | pr_err("could not get reg_8921_s4, rc = %ld\n", |
| 659 | PTR_ERR(reg_8921_s4)); |
| 660 | return -ENODEV; |
| 661 | } |
| 662 | rc = regulator_set_voltage(reg_8921_s4, 1800000, 1800000); |
| 663 | if (rc) { |
| 664 | pr_err("set_voltage failed for 8921_s4, rc=%d\n", rc); |
| 665 | return -EINVAL; |
| 666 | } |
| 667 | } |
| 668 | |
| 669 | if (on) { |
| 670 | rc = regulator_set_optimum_mode(reg_8921_l23, 100000); |
| 671 | if (rc < 0) { |
| 672 | pr_err("set_optimum_mode l23 failed, rc=%d\n", rc); |
| 673 | return -EINVAL; |
| 674 | } |
| 675 | rc = regulator_enable(reg_8921_l23); |
| 676 | if (rc) { |
| 677 | pr_err("'%s' regulator enable failed, rc=%d\n", |
| 678 | "hdmi_avdd", rc); |
| 679 | return rc; |
| 680 | } |
| 681 | rc = regulator_enable(reg_8921_s4); |
| 682 | if (rc) { |
| 683 | pr_err("'%s' regulator enable failed, rc=%d\n", |
| 684 | "hdmi_vcc", rc); |
| 685 | return rc; |
| 686 | } |
| 687 | rc = gpio_request(100, "HDMI_DDC_CLK"); |
| 688 | if (rc) { |
| 689 | pr_err("'%s'(%d) gpio_request failed, rc=%d\n", |
| 690 | "HDMI_DDC_CLK", 100, rc); |
| 691 | goto error1; |
| 692 | } |
| 693 | rc = gpio_request(101, "HDMI_DDC_DATA"); |
| 694 | if (rc) { |
| 695 | pr_err("'%s'(%d) gpio_request failed, rc=%d\n", |
| 696 | "HDMI_DDC_DATA", 101, rc); |
| 697 | goto error2; |
| 698 | } |
| 699 | rc = gpio_request(102, "HDMI_HPD"); |
| 700 | if (rc) { |
| 701 | pr_err("'%s'(%d) gpio_request failed, rc=%d\n", |
| 702 | "HDMI_HPD", 102, rc); |
| 703 | goto error3; |
| 704 | } |
| 705 | pr_debug("%s(on): success\n", __func__); |
| 706 | } else { |
| 707 | gpio_free(100); |
| 708 | gpio_free(101); |
| 709 | gpio_free(102); |
| 710 | |
| 711 | rc = regulator_disable(reg_8921_l23); |
| 712 | if (rc) { |
| 713 | pr_err("disable reg_8921_l23 failed, rc=%d\n", rc); |
| 714 | return -ENODEV; |
| 715 | } |
| 716 | rc = regulator_disable(reg_8921_s4); |
| 717 | if (rc) { |
| 718 | pr_err("disable reg_8921_s4 failed, rc=%d\n", rc); |
| 719 | return -ENODEV; |
| 720 | } |
| 721 | rc = regulator_set_optimum_mode(reg_8921_l23, 100); |
| 722 | if (rc < 0) { |
| 723 | pr_err("set_optimum_mode l23 failed, rc=%d\n", rc); |
| 724 | return -EINVAL; |
| 725 | } |
| 726 | pr_debug("%s(off): success\n", __func__); |
| 727 | } |
| 728 | |
| 729 | prev_on = on; |
| 730 | |
| 731 | return 0; |
| 732 | |
| 733 | error3: |
| 734 | gpio_free(101); |
| 735 | error2: |
| 736 | gpio_free(100); |
| 737 | error1: |
| 738 | regulator_disable(reg_8921_l23); |
| 739 | regulator_disable(reg_8921_s4); |
| 740 | return rc; |
| 741 | } |
| 742 | |
| 743 | static int hdmi_cec_power(int on) |
| 744 | { |
| 745 | static int prev_on; |
| 746 | int rc; |
| 747 | |
| 748 | if (on == prev_on) |
| 749 | return 0; |
| 750 | |
| 751 | if (on) { |
| 752 | rc = gpio_request(99, "HDMI_CEC_VAR"); |
| 753 | if (rc) { |
| 754 | pr_err("'%s'(%d) gpio_request failed, rc=%d\n", |
| 755 | "HDMI_CEC_VAR", 99, rc); |
| 756 | goto error; |
| 757 | } |
| 758 | pr_debug("%s(on): success\n", __func__); |
| 759 | } else { |
| 760 | gpio_free(99); |
| 761 | pr_debug("%s(off): success\n", __func__); |
| 762 | } |
| 763 | |
| 764 | prev_on = on; |
| 765 | |
| 766 | return 0; |
| 767 | error: |
| 768 | return rc; |
| 769 | } |
| 770 | #endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */ |
| 771 | |
| 772 | void __init msm8930_init_fb(void) |
| 773 | { |
Stepan Moskovchenko | 39236d7 | 2011-11-30 17:42:23 -0800 | [diff] [blame] | 774 | platform_device_register(&msm_fb_device); |
| 775 | |
| 776 | #ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL |
| 777 | platform_device_register(&wfd_panel_device); |
| 778 | platform_device_register(&wfd_device); |
| 779 | #endif |
| 780 | |
| 781 | platform_device_register(&mipi_dsi_novatek_panel_device); |
| 782 | |
| 783 | #ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL |
Ajay Dudani | 52e8823 | 2011-12-13 13:33:10 -0800 | [diff] [blame^] | 784 | if (!cpu_is_msm8930()) |
Ajay Dudani | 9114be7 | 2011-12-03 07:46:35 -0800 | [diff] [blame] | 785 | platform_device_register(&hdmi_msm_device); |
Stepan Moskovchenko | 39236d7 | 2011-11-30 17:42:23 -0800 | [diff] [blame] | 786 | #endif |
| 787 | |
| 788 | platform_device_register(&mipi_dsi_toshiba_panel_device); |
| 789 | |
| 790 | msm_fb_register_device("mdp", &mdp_pdata); |
| 791 | msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata); |
| 792 | #ifdef CONFIG_MSM_BUS_SCALING |
| 793 | msm_fb_register_device("dtv", &dtv_pdata); |
| 794 | #endif |
| 795 | } |
| 796 | |
| 797 | void __init msm8930_allocate_fb_region(void) |
| 798 | { |
| 799 | void *addr; |
| 800 | unsigned long size; |
| 801 | |
| 802 | size = MSM_FB_SIZE; |
| 803 | addr = alloc_bootmem_align(size, 0x1000); |
| 804 | msm_fb_resources[0].start = __pa(addr); |
| 805 | msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1; |
| 806 | pr_info("allocating %lu bytes at %p (%lx physical) for fb\n", |
| 807 | size, addr, __pa(addr)); |
| 808 | } |