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