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