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 | 24cd864 | 2011-11-29 13:07:53 -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> |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 18 | #include <linux/ion.h> |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 19 | #include <asm/mach-types.h> |
| 20 | #include <mach/msm_bus_board.h> |
Huaibin Yang | a541942 | 2011-12-08 23:52:10 -0800 | [diff] [blame] | 21 | #include <mach/msm_memtypes.h> |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 22 | #include <mach/board.h> |
| 23 | #include <mach/gpio.h> |
| 24 | #include <mach/gpiomux.h> |
Nagamalleswararao Ganji | 937a119 | 2011-12-07 19:00:52 -0800 | [diff] [blame] | 25 | #include <mach/ion.h> |
Amir Samuelov | 6f1e500 | 2012-02-01 17:42:43 +0200 | [diff] [blame] | 26 | #include <mach/socinfo.h> |
Nagamalleswararao Ganji | 937a119 | 2011-12-07 19:00:52 -0800 | [diff] [blame] | 27 | |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 28 | #include "devices.h" |
Stepan Moskovchenko | 5a83dba | 2011-12-05 17:30:17 -0800 | [diff] [blame] | 29 | #include "board-8960.h" |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 30 | |
| 31 | #ifdef CONFIG_FB_MSM_TRIPLE_BUFFER |
Padmanabhan Komanduru | ede0a63 | 2012-01-25 12:01:28 +0530 | [diff] [blame] | 32 | #define MSM_FB_PRIM_BUF_SIZE \ |
| 33 | (roundup((1920 * 1200 * 4), 4096) * 3) /* 4 bpp x 3 pages */ |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 34 | #else |
Padmanabhan Komanduru | ede0a63 | 2012-01-25 12:01:28 +0530 | [diff] [blame] | 35 | #define MSM_FB_PRIM_BUF_SIZE \ |
| 36 | (roundup((1920 * 1200 * 4), 4096) * 2) /* 4 bpp x 2 pages */ |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 37 | #endif |
| 38 | |
| 39 | #ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL |
Padmanabhan Komanduru | ede0a63 | 2012-01-25 12:01:28 +0530 | [diff] [blame] | 40 | #define MSM_FB_EXT_BUF_SIZE \ |
| 41 | (roundup((1920 * 1088 * 2), 4096) * 1) /* 2 bpp x 1 page */ |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 42 | #elif defined(CONFIG_FB_MSM_TVOUT) |
Padmanabhan Komanduru | ede0a63 | 2012-01-25 12:01:28 +0530 | [diff] [blame] | 43 | #define MSM_FB_EXT_BUF_SIZE \ |
| 44 | (roundup((720 * 576 * 2), 4096) * 2) /* 2 bpp x 2 pages */ |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 45 | #else |
| 46 | #define MSM_FB_EXT_BUF_SIZE 0 |
| 47 | #endif |
| 48 | |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 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 | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 51 | |
Huaibin Yang | a541942 | 2011-12-08 23:52:10 -0800 | [diff] [blame] | 52 | #ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK |
Amir Samuelov | d762103 | 2011-12-25 12:24:04 +0200 | [diff] [blame] | 53 | #define MSM_FB_OVERLAY0_WRITEBACK_SIZE roundup((1920 * 1200 * 3 * 2), 4096) |
Huaibin Yang | a541942 | 2011-12-08 23:52:10 -0800 | [diff] [blame] | 54 | #else |
| 55 | #define MSM_FB_OVERLAY0_WRITEBACK_SIZE (0) |
| 56 | #endif /* CONFIG_FB_MSM_OVERLAY0_WRITEBACK */ |
| 57 | |
| 58 | #ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK |
| 59 | #define MSM_FB_OVERLAY1_WRITEBACK_SIZE roundup((1920 * 1088 * 3 * 2), 4096) |
| 60 | #else |
| 61 | #define MSM_FB_OVERLAY1_WRITEBACK_SIZE (0) |
| 62 | #endif /* CONFIG_FB_MSM_OVERLAY1_WRITEBACK */ |
| 63 | |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 64 | #define MDP_VSYNC_GPIO 0 |
| 65 | |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 66 | #define MIPI_CMD_NOVATEK_QHD_PANEL_NAME "mipi_cmd_novatek_qhd" |
| 67 | #define MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME "mipi_video_novatek_qhd" |
| 68 | #define MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME "mipi_video_toshiba_wsvga" |
Ravishangar Kalyanam | da07f66 | 2012-02-16 13:29:43 -0800 | [diff] [blame] | 69 | #define MIPI_VIDEO_TOSHIBA_WUXGA_PANEL_NAME "mipi_video_toshiba_wuxga" |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 70 | #define MIPI_VIDEO_CHIMEI_WXGA_PANEL_NAME "mipi_video_chimei_wxga" |
Amir Samuelov | 6f1e500 | 2012-02-01 17:42:43 +0200 | [diff] [blame] | 71 | #define MIPI_VIDEO_CHIMEI_WUXGA_PANEL_NAME "mipi_video_chimei_wuxga" |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 72 | #define MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME "mipi_video_simulator_vga" |
| 73 | #define MIPI_CMD_RENESAS_FWVGA_PANEL_NAME "mipi_cmd_renesas_fwvga" |
Ravishangar Kalyanam | e2d015c | 2012-01-26 14:47:14 -0800 | [diff] [blame^] | 74 | #define MIPI_VIDEO_ORISE_720P_PANEL_NAME "mipi_video_orise_720p" |
| 75 | #define MIPI_CMD_ORISE_720P_PANEL_NAME "mipi_cmd_orise_720p" |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 76 | #define HDMI_PANEL_NAME "hdmi_msm" |
| 77 | #define TVOUT_PANEL_NAME "tvout_msm" |
| 78 | |
Ravishangar Kalyanam | 8c79ead | 2011-12-02 21:05:01 -0800 | [diff] [blame] | 79 | #ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY |
| 80 | unsigned char hdmi_is_primary = 1; |
| 81 | #else |
| 82 | unsigned char hdmi_is_primary; |
| 83 | #endif |
| 84 | |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 85 | static struct resource msm_fb_resources[] = { |
| 86 | { |
| 87 | .flags = IORESOURCE_DMA, |
| 88 | } |
| 89 | }; |
| 90 | |
Ravishangar Kalyanam | 8e78425 | 2012-02-10 16:27:51 -0800 | [diff] [blame] | 91 | static void set_mdp_clocks_for_wuxga(void); |
Amir Samuelov | f0d1f54 | 2012-02-06 12:50:42 +0200 | [diff] [blame] | 92 | |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 93 | static int msm_fb_detect_panel(const char *name) |
| 94 | { |
| 95 | if (machine_is_msm8960_liquid()) { |
Amir Samuelov | 6f1e500 | 2012-02-01 17:42:43 +0200 | [diff] [blame] | 96 | u32 ver = socinfo_get_platform_version(); |
| 97 | if (SOCINFO_VERSION_MAJOR(ver) == 3) { |
| 98 | if (!strncmp(name, MIPI_VIDEO_CHIMEI_WUXGA_PANEL_NAME, |
| 99 | strnlen(MIPI_VIDEO_CHIMEI_WUXGA_PANEL_NAME, |
Amir Samuelov | f0d1f54 | 2012-02-06 12:50:42 +0200 | [diff] [blame] | 100 | PANEL_NAME_MAX_LEN))) { |
Ravishangar Kalyanam | 8e78425 | 2012-02-10 16:27:51 -0800 | [diff] [blame] | 101 | set_mdp_clocks_for_wuxga(); |
Amir Samuelov | 6f1e500 | 2012-02-01 17:42:43 +0200 | [diff] [blame] | 102 | return 0; |
Amir Samuelov | f0d1f54 | 2012-02-06 12:50:42 +0200 | [diff] [blame] | 103 | } |
Amir Samuelov | 6f1e500 | 2012-02-01 17:42:43 +0200 | [diff] [blame] | 104 | } else { |
| 105 | if (!strncmp(name, MIPI_VIDEO_CHIMEI_WXGA_PANEL_NAME, |
| 106 | strnlen(MIPI_VIDEO_CHIMEI_WXGA_PANEL_NAME, |
| 107 | PANEL_NAME_MAX_LEN))) |
| 108 | return 0; |
| 109 | } |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 110 | } else { |
| 111 | if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME, |
| 112 | strnlen(MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME, |
| 113 | PANEL_NAME_MAX_LEN))) |
| 114 | return 0; |
| 115 | |
Ravishangar Kalyanam | a4286d7 | 2012-02-15 16:09:58 -0800 | [diff] [blame] | 116 | #if !defined(CONFIG_FB_MSM_LVDS_MIPI_PANEL_DETECT) && \ |
| 117 | !defined(CONFIG_FB_MSM_MIPI_PANEL_DETECT) |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 118 | if (!strncmp(name, MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME, |
| 119 | strnlen(MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME, |
| 120 | PANEL_NAME_MAX_LEN))) |
| 121 | return 0; |
| 122 | |
| 123 | if (!strncmp(name, MIPI_CMD_NOVATEK_QHD_PANEL_NAME, |
| 124 | strnlen(MIPI_CMD_NOVATEK_QHD_PANEL_NAME, |
| 125 | PANEL_NAME_MAX_LEN))) |
| 126 | return 0; |
| 127 | |
| 128 | if (!strncmp(name, MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME, |
| 129 | strnlen(MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME, |
| 130 | PANEL_NAME_MAX_LEN))) |
| 131 | return 0; |
| 132 | |
| 133 | if (!strncmp(name, MIPI_CMD_RENESAS_FWVGA_PANEL_NAME, |
| 134 | strnlen(MIPI_CMD_RENESAS_FWVGA_PANEL_NAME, |
| 135 | PANEL_NAME_MAX_LEN))) |
| 136 | return 0; |
Ravishangar Kalyanam | 8e78425 | 2012-02-10 16:27:51 -0800 | [diff] [blame] | 137 | |
Ravishangar Kalyanam | da07f66 | 2012-02-16 13:29:43 -0800 | [diff] [blame] | 138 | if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WUXGA_PANEL_NAME, |
| 139 | strnlen(MIPI_VIDEO_TOSHIBA_WUXGA_PANEL_NAME, |
Ravishangar Kalyanam | 8e78425 | 2012-02-10 16:27:51 -0800 | [diff] [blame] | 140 | PANEL_NAME_MAX_LEN))) { |
| 141 | set_mdp_clocks_for_wuxga(); |
| 142 | return 0; |
| 143 | } |
Ravishangar Kalyanam | e2d015c | 2012-01-26 14:47:14 -0800 | [diff] [blame^] | 144 | |
| 145 | if (!strncmp(name, MIPI_VIDEO_ORISE_720P_PANEL_NAME, |
| 146 | strnlen(MIPI_VIDEO_ORISE_720P_PANEL_NAME, |
| 147 | PANEL_NAME_MAX_LEN))) |
| 148 | return 0; |
| 149 | |
| 150 | if (!strncmp(name, MIPI_CMD_ORISE_720P_PANEL_NAME, |
| 151 | strnlen(MIPI_CMD_ORISE_720P_PANEL_NAME, |
| 152 | PANEL_NAME_MAX_LEN))) |
| 153 | return 0; |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 154 | #endif |
| 155 | } |
| 156 | |
| 157 | if (!strncmp(name, HDMI_PANEL_NAME, |
| 158 | strnlen(HDMI_PANEL_NAME, |
| 159 | PANEL_NAME_MAX_LEN))) |
| 160 | return 0; |
| 161 | |
| 162 | if (!strncmp(name, TVOUT_PANEL_NAME, |
| 163 | strnlen(TVOUT_PANEL_NAME, |
| 164 | PANEL_NAME_MAX_LEN))) |
| 165 | return 0; |
| 166 | |
| 167 | pr_warning("%s: not supported '%s'", __func__, name); |
| 168 | return -ENODEV; |
| 169 | } |
| 170 | |
| 171 | static struct msm_fb_platform_data msm_fb_pdata = { |
| 172 | .detect_client = msm_fb_detect_panel, |
| 173 | }; |
| 174 | |
| 175 | static struct platform_device msm_fb_device = { |
| 176 | .name = "msm_fb", |
| 177 | .id = 0, |
| 178 | .num_resources = ARRAY_SIZE(msm_fb_resources), |
| 179 | .resource = msm_fb_resources, |
| 180 | .dev.platform_data = &msm_fb_pdata, |
| 181 | }; |
| 182 | |
| 183 | static bool dsi_power_on; |
| 184 | |
| 185 | /** |
| 186 | * LiQUID panel on/off |
| 187 | * |
| 188 | * @param on |
| 189 | * |
| 190 | * @return int |
| 191 | */ |
| 192 | static int mipi_dsi_liquid_panel_power(int on) |
| 193 | { |
| 194 | static struct regulator *reg_l2, *reg_ext_3p3v; |
| 195 | static int gpio21, gpio24, gpio43; |
| 196 | int rc; |
| 197 | |
Jeff Ohlstein | 2cbe5ba | 2011-12-16 13:32:56 -0800 | [diff] [blame] | 198 | pr_debug("%s: on=%d\n", __func__, on); |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 199 | |
| 200 | gpio21 = PM8921_GPIO_PM_TO_SYS(21); /* disp power enable_n */ |
| 201 | gpio43 = PM8921_GPIO_PM_TO_SYS(43); /* Displays Enable (rst_n)*/ |
| 202 | gpio24 = PM8921_GPIO_PM_TO_SYS(24); /* Backlight PWM */ |
| 203 | |
| 204 | if (!dsi_power_on) { |
| 205 | |
| 206 | reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev, |
| 207 | "dsi_vdda"); |
| 208 | if (IS_ERR(reg_l2)) { |
| 209 | pr_err("could not get 8921_l2, rc = %ld\n", |
| 210 | PTR_ERR(reg_l2)); |
| 211 | return -ENODEV; |
| 212 | } |
| 213 | |
| 214 | rc = regulator_set_voltage(reg_l2, 1200000, 1200000); |
| 215 | if (rc) { |
| 216 | pr_err("set_voltage l2 failed, rc=%d\n", rc); |
| 217 | return -EINVAL; |
| 218 | } |
| 219 | |
| 220 | reg_ext_3p3v = regulator_get(&msm_mipi_dsi1_device.dev, |
| 221 | "vdd_lvds_3p3v"); |
| 222 | if (IS_ERR(reg_ext_3p3v)) { |
| 223 | pr_err("could not get reg_ext_3p3v, rc = %ld\n", |
| 224 | PTR_ERR(reg_ext_3p3v)); |
| 225 | return -ENODEV; |
| 226 | } |
| 227 | |
| 228 | rc = gpio_request(gpio21, "disp_pwr_en_n"); |
| 229 | if (rc) { |
| 230 | pr_err("request gpio 21 failed, rc=%d\n", rc); |
| 231 | return -ENODEV; |
| 232 | } |
| 233 | |
| 234 | rc = gpio_request(gpio43, "disp_rst_n"); |
| 235 | if (rc) { |
| 236 | pr_err("request gpio 43 failed, rc=%d\n", rc); |
| 237 | return -ENODEV; |
| 238 | } |
| 239 | |
| 240 | rc = gpio_request(gpio24, "disp_backlight_pwm"); |
| 241 | if (rc) { |
| 242 | pr_err("request gpio 24 failed, rc=%d\n", rc); |
| 243 | return -ENODEV; |
| 244 | } |
| 245 | |
| 246 | dsi_power_on = true; |
| 247 | } |
| 248 | |
| 249 | if (on) { |
| 250 | rc = regulator_set_optimum_mode(reg_l2, 100000); |
| 251 | if (rc < 0) { |
| 252 | pr_err("set_optimum_mode l2 failed, rc=%d\n", rc); |
| 253 | return -EINVAL; |
| 254 | } |
| 255 | rc = regulator_enable(reg_l2); |
| 256 | if (rc) { |
| 257 | pr_err("enable l2 failed, rc=%d\n", rc); |
| 258 | return -ENODEV; |
| 259 | } |
| 260 | |
| 261 | rc = regulator_enable(reg_ext_3p3v); |
| 262 | if (rc) { |
| 263 | pr_err("enable reg_ext_3p3v failed, rc=%d\n", rc); |
| 264 | return -ENODEV; |
| 265 | } |
| 266 | |
| 267 | /* set reset pin before power enable */ |
| 268 | gpio_set_value_cansleep(gpio43, 0); /* disp disable (resx=0) */ |
| 269 | |
| 270 | gpio_set_value_cansleep(gpio21, 0); /* disp power enable_n */ |
| 271 | msleep(20); |
| 272 | gpio_set_value_cansleep(gpio43, 1); /* disp enable */ |
| 273 | msleep(20); |
| 274 | gpio_set_value_cansleep(gpio43, 0); /* disp enable */ |
| 275 | msleep(20); |
| 276 | gpio_set_value_cansleep(gpio43, 1); /* disp enable */ |
| 277 | msleep(20); |
| 278 | } else { |
| 279 | gpio_set_value_cansleep(gpio43, 0); |
| 280 | gpio_set_value_cansleep(gpio21, 1); |
| 281 | |
| 282 | rc = regulator_disable(reg_l2); |
| 283 | if (rc) { |
| 284 | pr_err("disable reg_l2 failed, rc=%d\n", rc); |
| 285 | return -ENODEV; |
| 286 | } |
| 287 | rc = regulator_disable(reg_ext_3p3v); |
| 288 | if (rc) { |
| 289 | pr_err("disable reg_ext_3p3v failed, rc=%d\n", rc); |
| 290 | return -ENODEV; |
| 291 | } |
| 292 | rc = regulator_set_optimum_mode(reg_l2, 100); |
| 293 | if (rc < 0) { |
| 294 | pr_err("set_optimum_mode l2 failed, rc=%d\n", rc); |
| 295 | return -EINVAL; |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | return 0; |
| 300 | } |
| 301 | |
| 302 | static int mipi_dsi_cdp_panel_power(int on) |
| 303 | { |
| 304 | static struct regulator *reg_l8, *reg_l23, *reg_l2; |
| 305 | static int gpio43; |
| 306 | int rc; |
| 307 | |
Jeff Ohlstein | 2cbe5ba | 2011-12-16 13:32:56 -0800 | [diff] [blame] | 308 | pr_debug("%s: state : %d\n", __func__, on); |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 309 | |
| 310 | if (!dsi_power_on) { |
| 311 | |
| 312 | reg_l8 = regulator_get(&msm_mipi_dsi1_device.dev, |
| 313 | "dsi_vdc"); |
| 314 | if (IS_ERR(reg_l8)) { |
| 315 | pr_err("could not get 8921_l8, rc = %ld\n", |
| 316 | PTR_ERR(reg_l8)); |
| 317 | return -ENODEV; |
| 318 | } |
| 319 | reg_l23 = regulator_get(&msm_mipi_dsi1_device.dev, |
| 320 | "dsi_vddio"); |
| 321 | if (IS_ERR(reg_l23)) { |
| 322 | pr_err("could not get 8921_l23, rc = %ld\n", |
| 323 | PTR_ERR(reg_l23)); |
| 324 | return -ENODEV; |
| 325 | } |
| 326 | reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev, |
| 327 | "dsi_vdda"); |
| 328 | if (IS_ERR(reg_l2)) { |
| 329 | pr_err("could not get 8921_l2, rc = %ld\n", |
| 330 | PTR_ERR(reg_l2)); |
| 331 | return -ENODEV; |
| 332 | } |
| 333 | rc = regulator_set_voltage(reg_l8, 2800000, 3000000); |
| 334 | if (rc) { |
| 335 | pr_err("set_voltage l8 failed, rc=%d\n", rc); |
| 336 | return -EINVAL; |
| 337 | } |
| 338 | rc = regulator_set_voltage(reg_l23, 1800000, 1800000); |
| 339 | if (rc) { |
| 340 | pr_err("set_voltage l23 failed, rc=%d\n", rc); |
| 341 | return -EINVAL; |
| 342 | } |
| 343 | rc = regulator_set_voltage(reg_l2, 1200000, 1200000); |
| 344 | if (rc) { |
| 345 | pr_err("set_voltage l2 failed, rc=%d\n", rc); |
| 346 | return -EINVAL; |
| 347 | } |
| 348 | gpio43 = PM8921_GPIO_PM_TO_SYS(43); |
| 349 | rc = gpio_request(gpio43, "disp_rst_n"); |
| 350 | if (rc) { |
| 351 | pr_err("request gpio 43 failed, rc=%d\n", rc); |
| 352 | return -ENODEV; |
| 353 | } |
| 354 | dsi_power_on = true; |
| 355 | } |
| 356 | if (on) { |
| 357 | rc = regulator_set_optimum_mode(reg_l8, 100000); |
| 358 | if (rc < 0) { |
| 359 | pr_err("set_optimum_mode l8 failed, rc=%d\n", rc); |
| 360 | return -EINVAL; |
| 361 | } |
| 362 | rc = regulator_set_optimum_mode(reg_l23, 100000); |
| 363 | if (rc < 0) { |
| 364 | pr_err("set_optimum_mode l23 failed, rc=%d\n", rc); |
| 365 | return -EINVAL; |
| 366 | } |
| 367 | rc = regulator_set_optimum_mode(reg_l2, 100000); |
| 368 | if (rc < 0) { |
| 369 | pr_err("set_optimum_mode l2 failed, rc=%d\n", rc); |
| 370 | return -EINVAL; |
| 371 | } |
| 372 | rc = regulator_enable(reg_l8); |
| 373 | if (rc) { |
| 374 | pr_err("enable l8 failed, rc=%d\n", rc); |
| 375 | return -ENODEV; |
| 376 | } |
| 377 | rc = regulator_enable(reg_l23); |
| 378 | if (rc) { |
| 379 | pr_err("enable l8 failed, rc=%d\n", rc); |
| 380 | return -ENODEV; |
| 381 | } |
| 382 | rc = regulator_enable(reg_l2); |
| 383 | if (rc) { |
| 384 | pr_err("enable l2 failed, rc=%d\n", rc); |
| 385 | return -ENODEV; |
| 386 | } |
| 387 | gpio_set_value_cansleep(gpio43, 1); |
| 388 | } else { |
| 389 | rc = regulator_disable(reg_l2); |
| 390 | if (rc) { |
| 391 | pr_err("disable reg_l2 failed, rc=%d\n", rc); |
| 392 | return -ENODEV; |
| 393 | } |
| 394 | rc = regulator_disable(reg_l8); |
| 395 | if (rc) { |
| 396 | pr_err("disable reg_l8 failed, rc=%d\n", rc); |
| 397 | return -ENODEV; |
| 398 | } |
| 399 | rc = regulator_disable(reg_l23); |
| 400 | if (rc) { |
| 401 | pr_err("disable reg_l23 failed, rc=%d\n", rc); |
| 402 | return -ENODEV; |
| 403 | } |
| 404 | rc = regulator_set_optimum_mode(reg_l8, 100); |
| 405 | if (rc < 0) { |
| 406 | pr_err("set_optimum_mode l8 failed, rc=%d\n", rc); |
| 407 | return -EINVAL; |
| 408 | } |
| 409 | rc = regulator_set_optimum_mode(reg_l23, 100); |
| 410 | if (rc < 0) { |
| 411 | pr_err("set_optimum_mode l23 failed, rc=%d\n", rc); |
| 412 | return -EINVAL; |
| 413 | } |
| 414 | rc = regulator_set_optimum_mode(reg_l2, 100); |
| 415 | if (rc < 0) { |
| 416 | pr_err("set_optimum_mode l2 failed, rc=%d\n", rc); |
| 417 | return -EINVAL; |
| 418 | } |
| 419 | gpio_set_value_cansleep(gpio43, 0); |
| 420 | } |
| 421 | return 0; |
| 422 | } |
| 423 | |
| 424 | static int mipi_dsi_panel_power(int on) |
| 425 | { |
| 426 | int ret; |
| 427 | |
Jeff Ohlstein | 2cbe5ba | 2011-12-16 13:32:56 -0800 | [diff] [blame] | 428 | pr_debug("%s: on=%d\n", __func__, on); |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 429 | |
| 430 | if (machine_is_msm8960_liquid()) |
| 431 | ret = mipi_dsi_liquid_panel_power(on); |
| 432 | else |
| 433 | ret = mipi_dsi_cdp_panel_power(on); |
| 434 | |
| 435 | return ret; |
| 436 | } |
| 437 | |
| 438 | static struct mipi_dsi_platform_data mipi_dsi_pdata = { |
| 439 | .vsync_gpio = MDP_VSYNC_GPIO, |
| 440 | .dsi_power_save = mipi_dsi_panel_power, |
| 441 | }; |
| 442 | |
| 443 | #ifdef CONFIG_MSM_BUS_SCALING |
| 444 | |
Nagamalleswararao Ganji | 5fabbd6 | 2011-11-06 23:10:43 -0800 | [diff] [blame] | 445 | static struct msm_bus_vectors rotator_init_vectors[] = { |
| 446 | { |
| 447 | .src = MSM_BUS_MASTER_ROTATOR, |
| 448 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 449 | .ab = 0, |
| 450 | .ib = 0, |
| 451 | }, |
| 452 | }; |
| 453 | |
| 454 | static struct msm_bus_vectors rotator_ui_vectors[] = { |
| 455 | { |
| 456 | .src = MSM_BUS_MASTER_ROTATOR, |
| 457 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 458 | .ab = (1024 * 600 * 4 * 2 * 60), |
| 459 | .ib = (1024 * 600 * 4 * 2 * 60 * 1.5), |
| 460 | }, |
| 461 | }; |
| 462 | |
| 463 | static struct msm_bus_vectors rotator_vga_vectors[] = { |
| 464 | { |
| 465 | .src = MSM_BUS_MASTER_ROTATOR, |
| 466 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 467 | .ab = (640 * 480 * 2 * 2 * 30), |
| 468 | .ib = (640 * 480 * 2 * 2 * 30 * 1.5), |
| 469 | }, |
| 470 | }; |
| 471 | static struct msm_bus_vectors rotator_720p_vectors[] = { |
| 472 | { |
| 473 | .src = MSM_BUS_MASTER_ROTATOR, |
| 474 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 475 | .ab = (1280 * 736 * 2 * 2 * 30), |
| 476 | .ib = (1280 * 736 * 2 * 2 * 30 * 1.5), |
| 477 | }, |
| 478 | }; |
| 479 | |
| 480 | static struct msm_bus_vectors rotator_1080p_vectors[] = { |
| 481 | { |
| 482 | .src = MSM_BUS_MASTER_ROTATOR, |
| 483 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 484 | .ab = (1920 * 1088 * 2 * 2 * 30), |
| 485 | .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5), |
| 486 | }, |
| 487 | }; |
| 488 | |
| 489 | static struct msm_bus_paths rotator_bus_scale_usecases[] = { |
| 490 | { |
| 491 | ARRAY_SIZE(rotator_init_vectors), |
| 492 | rotator_init_vectors, |
| 493 | }, |
| 494 | { |
| 495 | ARRAY_SIZE(rotator_ui_vectors), |
| 496 | rotator_ui_vectors, |
| 497 | }, |
| 498 | { |
| 499 | ARRAY_SIZE(rotator_vga_vectors), |
| 500 | rotator_vga_vectors, |
| 501 | }, |
| 502 | { |
| 503 | ARRAY_SIZE(rotator_720p_vectors), |
| 504 | rotator_720p_vectors, |
| 505 | }, |
| 506 | { |
| 507 | ARRAY_SIZE(rotator_1080p_vectors), |
| 508 | rotator_1080p_vectors, |
| 509 | }, |
| 510 | }; |
| 511 | |
| 512 | struct msm_bus_scale_pdata rotator_bus_scale_pdata = { |
| 513 | rotator_bus_scale_usecases, |
| 514 | ARRAY_SIZE(rotator_bus_scale_usecases), |
| 515 | .name = "rotator", |
| 516 | }; |
| 517 | |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 518 | static struct msm_bus_vectors mdp_init_vectors[] = { |
| 519 | { |
| 520 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 521 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 522 | .ab = 0, |
| 523 | .ib = 0, |
| 524 | }, |
| 525 | }; |
| 526 | |
| 527 | #ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY |
| 528 | static struct msm_bus_vectors hdmi_as_primary_vectors[] = { |
| 529 | /* If HDMI is used as primary */ |
| 530 | { |
| 531 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 532 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 533 | .ab = 2000000000, |
| 534 | .ib = 2000000000, |
| 535 | }, |
| 536 | }; |
| 537 | static struct msm_bus_paths mdp_bus_scale_usecases[] = { |
| 538 | { |
| 539 | ARRAY_SIZE(mdp_init_vectors), |
| 540 | mdp_init_vectors, |
| 541 | }, |
| 542 | { |
| 543 | ARRAY_SIZE(hdmi_as_primary_vectors), |
| 544 | hdmi_as_primary_vectors, |
| 545 | }, |
| 546 | { |
| 547 | ARRAY_SIZE(hdmi_as_primary_vectors), |
| 548 | hdmi_as_primary_vectors, |
| 549 | }, |
| 550 | { |
| 551 | ARRAY_SIZE(hdmi_as_primary_vectors), |
| 552 | hdmi_as_primary_vectors, |
| 553 | }, |
| 554 | { |
| 555 | ARRAY_SIZE(hdmi_as_primary_vectors), |
| 556 | hdmi_as_primary_vectors, |
| 557 | }, |
| 558 | { |
| 559 | ARRAY_SIZE(hdmi_as_primary_vectors), |
| 560 | hdmi_as_primary_vectors, |
| 561 | }, |
| 562 | }; |
| 563 | #else |
| 564 | static struct msm_bus_vectors mdp_ui_vectors[] = { |
| 565 | { |
| 566 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 567 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 568 | .ab = 216000000 * 2, |
| 569 | .ib = 270000000 * 2, |
| 570 | }, |
| 571 | }; |
| 572 | |
| 573 | static struct msm_bus_vectors mdp_vga_vectors[] = { |
| 574 | /* VGA and less video */ |
| 575 | { |
| 576 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 577 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 578 | .ab = 216000000 * 2, |
| 579 | .ib = 270000000 * 2, |
| 580 | }, |
| 581 | }; |
| 582 | |
| 583 | static struct msm_bus_vectors mdp_720p_vectors[] = { |
| 584 | /* 720p and less video */ |
| 585 | { |
| 586 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 587 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 588 | .ab = 230400000 * 2, |
| 589 | .ib = 288000000 * 2, |
| 590 | }, |
| 591 | }; |
| 592 | |
| 593 | static struct msm_bus_vectors mdp_1080p_vectors[] = { |
| 594 | /* 1080p and less video */ |
| 595 | { |
| 596 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 597 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 598 | .ab = 334080000 * 2, |
| 599 | .ib = 417600000 * 2, |
| 600 | }, |
| 601 | }; |
| 602 | |
| 603 | static struct msm_bus_paths mdp_bus_scale_usecases[] = { |
| 604 | { |
| 605 | ARRAY_SIZE(mdp_init_vectors), |
| 606 | mdp_init_vectors, |
| 607 | }, |
| 608 | { |
| 609 | ARRAY_SIZE(mdp_ui_vectors), |
| 610 | mdp_ui_vectors, |
| 611 | }, |
| 612 | { |
| 613 | ARRAY_SIZE(mdp_ui_vectors), |
| 614 | mdp_ui_vectors, |
| 615 | }, |
| 616 | { |
| 617 | ARRAY_SIZE(mdp_vga_vectors), |
| 618 | mdp_vga_vectors, |
| 619 | }, |
| 620 | { |
| 621 | ARRAY_SIZE(mdp_720p_vectors), |
| 622 | mdp_720p_vectors, |
| 623 | }, |
| 624 | { |
| 625 | ARRAY_SIZE(mdp_1080p_vectors), |
| 626 | mdp_1080p_vectors, |
| 627 | }, |
| 628 | }; |
| 629 | #endif |
| 630 | |
| 631 | static struct msm_bus_scale_pdata mdp_bus_scale_pdata = { |
| 632 | mdp_bus_scale_usecases, |
| 633 | ARRAY_SIZE(mdp_bus_scale_usecases), |
| 634 | .name = "mdp", |
| 635 | }; |
| 636 | |
| 637 | #endif |
| 638 | |
Stepan Moskovchenko | fc70d90 | 2011-11-30 12:39:36 -0800 | [diff] [blame] | 639 | static int mdp_core_clk_rate_table[] = { |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 640 | 85330000, |
Huaibin Yang | 1f180ee | 2012-01-30 16:23:06 -0800 | [diff] [blame] | 641 | 128000000, |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 642 | 160000000, |
| 643 | 200000000, |
| 644 | }; |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 645 | |
| 646 | static struct msm_panel_common_pdata mdp_pdata = { |
| 647 | .gpio = MDP_VSYNC_GPIO, |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 648 | .mdp_core_clk_rate = 85330000, |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 649 | .mdp_core_clk_table = mdp_core_clk_rate_table, |
| 650 | .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table), |
| 651 | #ifdef CONFIG_MSM_BUS_SCALING |
| 652 | .mdp_bus_scale_table = &mdp_bus_scale_pdata, |
| 653 | #endif |
| 654 | .mdp_rev = MDP_REV_42, |
Nagamalleswararao Ganji | 937a119 | 2011-12-07 19:00:52 -0800 | [diff] [blame] | 655 | #ifdef CONFIG_MSM_MULTIMEDIA_USE_ION |
| 656 | .mem_hid = ION_CP_MM_HEAP_ID, |
| 657 | #else |
| 658 | .mem_hid = MEMTYPE_EBI1, |
| 659 | #endif |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 660 | }; |
| 661 | |
Amir Samuelov | f0d1f54 | 2012-02-06 12:50:42 +0200 | [diff] [blame] | 662 | /** |
| 663 | * Set MDP clocks to high frequency to avoid DSI underflow |
Ravishangar Kalyanam | 8e78425 | 2012-02-10 16:27:51 -0800 | [diff] [blame] | 664 | * when using high resolution 1200x1920 WUXGA panels |
Amir Samuelov | f0d1f54 | 2012-02-06 12:50:42 +0200 | [diff] [blame] | 665 | */ |
Ravishangar Kalyanam | 8e78425 | 2012-02-10 16:27:51 -0800 | [diff] [blame] | 666 | static void set_mdp_clocks_for_wuxga(void) |
Amir Samuelov | f0d1f54 | 2012-02-06 12:50:42 +0200 | [diff] [blame] | 667 | { |
| 668 | int i; |
| 669 | |
| 670 | mdp_ui_vectors[0].ab = 2000000000; |
| 671 | mdp_ui_vectors[0].ib = 2000000000; |
Ravishangar Kalyanam | 3017087 | 2012-02-25 17:47:18 -0800 | [diff] [blame] | 672 | mdp_vga_vectors[0].ab = 2000000000; |
| 673 | mdp_vga_vectors[0].ib = 2000000000; |
| 674 | mdp_720p_vectors[0].ab = 2000000000; |
| 675 | mdp_720p_vectors[0].ib = 2000000000; |
| 676 | mdp_1080p_vectors[0].ab = 2000000000; |
| 677 | mdp_1080p_vectors[0].ib = 2000000000; |
Amir Samuelov | f0d1f54 | 2012-02-06 12:50:42 +0200 | [diff] [blame] | 678 | |
| 679 | mdp_pdata.mdp_core_clk_rate = 200000000; |
| 680 | |
| 681 | for (i = 0; i < ARRAY_SIZE(mdp_core_clk_rate_table); i++) |
| 682 | mdp_core_clk_rate_table[i] = 200000000; |
| 683 | |
| 684 | } |
| 685 | |
Huaibin Yang | a541942 | 2011-12-08 23:52:10 -0800 | [diff] [blame] | 686 | void __init msm8960_mdp_writeback(struct memtype_reserve* reserve_table) |
| 687 | { |
Nagamalleswararao Ganji | 937a119 | 2011-12-07 19:00:52 -0800 | [diff] [blame] | 688 | mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE; |
| 689 | mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE; |
| 690 | #if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION) |
| 691 | reserve_table[mdp_pdata.mem_hid].size += |
| 692 | mdp_pdata.ov0_wb_size; |
| 693 | reserve_table[mdp_pdata.mem_hid].size += |
| 694 | mdp_pdata.ov1_wb_size; |
| 695 | #endif |
Huaibin Yang | a541942 | 2011-12-08 23:52:10 -0800 | [diff] [blame] | 696 | } |
| 697 | |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 698 | static struct platform_device mipi_dsi_renesas_panel_device = { |
| 699 | .name = "mipi_renesas", |
| 700 | .id = 0, |
| 701 | }; |
| 702 | |
| 703 | static struct platform_device mipi_dsi_simulator_panel_device = { |
| 704 | .name = "mipi_simulator", |
| 705 | .id = 0, |
| 706 | }; |
| 707 | |
| 708 | #define LPM_CHANNEL0 0 |
| 709 | static int toshiba_gpio[] = {LPM_CHANNEL0}; |
| 710 | |
| 711 | static struct mipi_dsi_panel_platform_data toshiba_pdata = { |
| 712 | .gpio = toshiba_gpio, |
| 713 | }; |
| 714 | |
| 715 | static struct platform_device mipi_dsi_toshiba_panel_device = { |
| 716 | .name = "mipi_toshiba", |
| 717 | .id = 0, |
| 718 | .dev = { |
| 719 | .platform_data = &toshiba_pdata, |
| 720 | } |
| 721 | }; |
| 722 | |
| 723 | #define FPGA_3D_GPIO_CONFIG_ADDR 0xB5 |
Amir Samuelov | ca199b9 | 2012-01-31 14:50:04 +0200 | [diff] [blame] | 724 | static int dsi2lvds_gpio[4] = { |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 725 | 0,/* Backlight PWM-ID=0 for PMIC-GPIO#24 */ |
Amir Samuelov | ca199b9 | 2012-01-31 14:50:04 +0200 | [diff] [blame] | 726 | 0x1F08, /* DSI2LVDS Bridge GPIO Output, mask=0x1f, out=0x08 */ |
| 727 | GPIO_LIQUID_EXPANDER_BASE+6, /* TN Enable */ |
| 728 | GPIO_LIQUID_EXPANDER_BASE+7, /* TN Mode */ |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 729 | }; |
| 730 | |
| 731 | static struct msm_panel_common_pdata mipi_dsi2lvds_pdata = { |
| 732 | .gpio_num = dsi2lvds_gpio, |
| 733 | }; |
| 734 | |
| 735 | static struct mipi_dsi_phy_ctrl dsi_novatek_cmd_mode_phy_db = { |
| 736 | |
| 737 | /* DSI_BIT_CLK at 500MHz, 2 lane, RGB888 */ |
| 738 | {0x0F, 0x0a, 0x04, 0x00, 0x20}, /* regulator */ |
| 739 | /* timing */ |
| 740 | {0xab, 0x8a, 0x18, 0x00, 0x92, 0x97, 0x1b, 0x8c, |
| 741 | 0x0c, 0x03, 0x04, 0xa0}, |
| 742 | {0x5f, 0x00, 0x00, 0x10}, /* phy ctrl */ |
| 743 | {0xff, 0x00, 0x06, 0x00}, /* strength */ |
| 744 | /* pll control */ |
| 745 | {0x40, 0xf9, 0x30, 0xda, 0x00, 0x40, 0x03, 0x62, |
| 746 | 0x40, 0x07, 0x03, |
| 747 | 0x00, 0x1a, 0x00, 0x00, 0x02, 0x00, 0x20, 0x00, 0x01}, |
| 748 | }; |
| 749 | |
| 750 | static struct mipi_dsi_panel_platform_data novatek_pdata = { |
| 751 | .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR, |
| 752 | .fpga_ctrl_mode = FPGA_SPI_INTF, |
| 753 | .phy_ctrl_settings = &dsi_novatek_cmd_mode_phy_db, |
| 754 | }; |
| 755 | |
| 756 | static struct platform_device mipi_dsi_novatek_panel_device = { |
| 757 | .name = "mipi_novatek", |
| 758 | .id = 0, |
| 759 | .dev = { |
| 760 | .platform_data = &novatek_pdata, |
| 761 | } |
| 762 | }; |
| 763 | |
| 764 | static struct platform_device mipi_dsi2lvds_bridge_device = { |
| 765 | .name = "mipi_tc358764", |
| 766 | .id = 0, |
| 767 | .dev.platform_data = &mipi_dsi2lvds_pdata, |
| 768 | }; |
| 769 | |
Ravishangar Kalyanam | e2d015c | 2012-01-26 14:47:14 -0800 | [diff] [blame^] | 770 | static struct platform_device mipi_dsi_orise_panel_device = { |
| 771 | .name = "mipi_orise", |
| 772 | .id = 0, |
| 773 | }; |
| 774 | |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 775 | #ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL |
| 776 | static struct resource hdmi_msm_resources[] = { |
| 777 | { |
| 778 | .name = "hdmi_msm_qfprom_addr", |
| 779 | .start = 0x00700000, |
| 780 | .end = 0x007060FF, |
| 781 | .flags = IORESOURCE_MEM, |
| 782 | }, |
| 783 | { |
| 784 | .name = "hdmi_msm_hdmi_addr", |
| 785 | .start = 0x04A00000, |
| 786 | .end = 0x04A00FFF, |
| 787 | .flags = IORESOURCE_MEM, |
| 788 | }, |
| 789 | { |
| 790 | .name = "hdmi_msm_irq", |
| 791 | .start = HDMI_IRQ, |
| 792 | .end = HDMI_IRQ, |
| 793 | .flags = IORESOURCE_IRQ, |
| 794 | }, |
| 795 | }; |
| 796 | |
| 797 | static int hdmi_enable_5v(int on); |
| 798 | static int hdmi_core_power(int on, int show); |
| 799 | static int hdmi_cec_power(int on); |
| 800 | |
| 801 | static struct msm_hdmi_platform_data hdmi_msm_data = { |
| 802 | .irq = HDMI_IRQ, |
| 803 | .enable_5v = hdmi_enable_5v, |
| 804 | .core_power = hdmi_core_power, |
| 805 | .cec_power = hdmi_cec_power, |
| 806 | }; |
| 807 | |
| 808 | static struct platform_device hdmi_msm_device = { |
| 809 | .name = "hdmi_msm", |
| 810 | .id = 0, |
| 811 | .num_resources = ARRAY_SIZE(hdmi_msm_resources), |
| 812 | .resource = hdmi_msm_resources, |
| 813 | .dev.platform_data = &hdmi_msm_data, |
| 814 | }; |
| 815 | #endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */ |
| 816 | |
| 817 | #ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL |
| 818 | static struct platform_device wfd_panel_device = { |
| 819 | .name = "wfd_panel", |
| 820 | .id = 0, |
| 821 | .dev.platform_data = NULL, |
| 822 | }; |
Stepan Moskovchenko | 270888d | 2011-11-30 12:19:11 -0800 | [diff] [blame] | 823 | |
| 824 | static struct platform_device wfd_device = { |
| 825 | .name = "msm_wfd", |
| 826 | .id = -1, |
| 827 | }; |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 828 | #endif |
| 829 | |
| 830 | #ifdef CONFIG_MSM_BUS_SCALING |
| 831 | static struct msm_bus_vectors dtv_bus_init_vectors[] = { |
| 832 | { |
| 833 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 834 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 835 | .ab = 0, |
| 836 | .ib = 0, |
| 837 | }, |
| 838 | }; |
| 839 | |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 840 | static struct msm_bus_vectors dtv_bus_def_vectors[] = { |
| 841 | { |
| 842 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 843 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 844 | .ab = 566092800 * 2, |
| 845 | .ib = 707616000 * 2, |
| 846 | }, |
| 847 | }; |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 848 | |
| 849 | static struct msm_bus_paths dtv_bus_scale_usecases[] = { |
| 850 | { |
| 851 | ARRAY_SIZE(dtv_bus_init_vectors), |
| 852 | dtv_bus_init_vectors, |
| 853 | }, |
| 854 | { |
| 855 | ARRAY_SIZE(dtv_bus_def_vectors), |
| 856 | dtv_bus_def_vectors, |
| 857 | }, |
| 858 | }; |
| 859 | static struct msm_bus_scale_pdata dtv_bus_scale_pdata = { |
| 860 | dtv_bus_scale_usecases, |
| 861 | ARRAY_SIZE(dtv_bus_scale_usecases), |
| 862 | .name = "dtv", |
| 863 | }; |
| 864 | |
| 865 | static struct lcdc_platform_data dtv_pdata = { |
| 866 | .bus_scale_table = &dtv_bus_scale_pdata, |
| 867 | }; |
| 868 | #endif |
| 869 | |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 870 | #ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 871 | static int hdmi_enable_5v(int on) |
| 872 | { |
| 873 | /* TBD: PM8921 regulator instead of 8901 */ |
| 874 | static struct regulator *reg_8921_hdmi_mvs; /* HDMI_5V */ |
| 875 | static int prev_on; |
| 876 | int rc; |
| 877 | |
| 878 | if (on == prev_on) |
| 879 | return 0; |
| 880 | |
Ajay Singh Parmar | 0784764 | 2011-12-09 02:57:45 +0530 | [diff] [blame] | 881 | if (!reg_8921_hdmi_mvs) { |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 882 | reg_8921_hdmi_mvs = regulator_get(&hdmi_msm_device.dev, |
Ajay Singh Parmar | 0784764 | 2011-12-09 02:57:45 +0530 | [diff] [blame] | 883 | "hdmi_mvs"); |
| 884 | if (IS_ERR(reg_8921_hdmi_mvs)) { |
| 885 | pr_err("'%s' regulator not found, rc=%ld\n", |
| 886 | "hdmi_mvs", IS_ERR(reg_8921_hdmi_mvs)); |
| 887 | reg_8921_hdmi_mvs = NULL; |
| 888 | return -ENODEV; |
| 889 | } |
| 890 | } |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 891 | |
| 892 | if (on) { |
| 893 | rc = regulator_enable(reg_8921_hdmi_mvs); |
| 894 | if (rc) { |
| 895 | pr_err("'%s' regulator enable failed, rc=%d\n", |
| 896 | "8921_hdmi_mvs", rc); |
| 897 | return rc; |
| 898 | } |
| 899 | pr_debug("%s(on): success\n", __func__); |
| 900 | } else { |
| 901 | rc = regulator_disable(reg_8921_hdmi_mvs); |
| 902 | if (rc) |
| 903 | pr_warning("'%s' regulator disable failed, rc=%d\n", |
| 904 | "8921_hdmi_mvs", rc); |
| 905 | pr_debug("%s(off): success\n", __func__); |
| 906 | } |
| 907 | |
| 908 | prev_on = on; |
| 909 | |
| 910 | return 0; |
| 911 | } |
| 912 | |
| 913 | static int hdmi_core_power(int on, int show) |
| 914 | { |
| 915 | static struct regulator *reg_8921_l23, *reg_8921_s4; |
| 916 | static int prev_on; |
| 917 | int rc; |
| 918 | |
| 919 | if (on == prev_on) |
| 920 | return 0; |
| 921 | |
| 922 | /* TBD: PM8921 regulator instead of 8901 */ |
| 923 | if (!reg_8921_l23) { |
| 924 | reg_8921_l23 = regulator_get(&hdmi_msm_device.dev, "hdmi_avdd"); |
| 925 | if (IS_ERR(reg_8921_l23)) { |
| 926 | pr_err("could not get reg_8921_l23, rc = %ld\n", |
| 927 | PTR_ERR(reg_8921_l23)); |
| 928 | return -ENODEV; |
| 929 | } |
| 930 | rc = regulator_set_voltage(reg_8921_l23, 1800000, 1800000); |
| 931 | if (rc) { |
| 932 | pr_err("set_voltage failed for 8921_l23, rc=%d\n", rc); |
| 933 | return -EINVAL; |
| 934 | } |
| 935 | } |
| 936 | if (!reg_8921_s4) { |
| 937 | reg_8921_s4 = regulator_get(&hdmi_msm_device.dev, "hdmi_vcc"); |
| 938 | if (IS_ERR(reg_8921_s4)) { |
| 939 | pr_err("could not get reg_8921_s4, rc = %ld\n", |
| 940 | PTR_ERR(reg_8921_s4)); |
| 941 | return -ENODEV; |
| 942 | } |
| 943 | rc = regulator_set_voltage(reg_8921_s4, 1800000, 1800000); |
| 944 | if (rc) { |
| 945 | pr_err("set_voltage failed for 8921_s4, rc=%d\n", rc); |
| 946 | return -EINVAL; |
| 947 | } |
| 948 | } |
| 949 | |
| 950 | if (on) { |
| 951 | rc = regulator_set_optimum_mode(reg_8921_l23, 100000); |
| 952 | if (rc < 0) { |
| 953 | pr_err("set_optimum_mode l23 failed, rc=%d\n", rc); |
| 954 | return -EINVAL; |
| 955 | } |
| 956 | rc = regulator_enable(reg_8921_l23); |
| 957 | if (rc) { |
| 958 | pr_err("'%s' regulator enable failed, rc=%d\n", |
| 959 | "hdmi_avdd", rc); |
| 960 | return rc; |
| 961 | } |
| 962 | rc = regulator_enable(reg_8921_s4); |
| 963 | if (rc) { |
| 964 | pr_err("'%s' regulator enable failed, rc=%d\n", |
| 965 | "hdmi_vcc", rc); |
| 966 | return rc; |
| 967 | } |
| 968 | rc = gpio_request(100, "HDMI_DDC_CLK"); |
| 969 | if (rc) { |
| 970 | pr_err("'%s'(%d) gpio_request failed, rc=%d\n", |
| 971 | "HDMI_DDC_CLK", 100, rc); |
| 972 | goto error1; |
| 973 | } |
| 974 | rc = gpio_request(101, "HDMI_DDC_DATA"); |
| 975 | if (rc) { |
| 976 | pr_err("'%s'(%d) gpio_request failed, rc=%d\n", |
| 977 | "HDMI_DDC_DATA", 101, rc); |
| 978 | goto error2; |
| 979 | } |
| 980 | rc = gpio_request(102, "HDMI_HPD"); |
| 981 | if (rc) { |
| 982 | pr_err("'%s'(%d) gpio_request failed, rc=%d\n", |
| 983 | "HDMI_HPD", 102, rc); |
| 984 | goto error3; |
| 985 | } |
| 986 | pr_debug("%s(on): success\n", __func__); |
| 987 | } else { |
| 988 | gpio_free(100); |
| 989 | gpio_free(101); |
| 990 | gpio_free(102); |
| 991 | |
| 992 | rc = regulator_disable(reg_8921_l23); |
| 993 | if (rc) { |
| 994 | pr_err("disable reg_8921_l23 failed, rc=%d\n", rc); |
| 995 | return -ENODEV; |
| 996 | } |
| 997 | rc = regulator_disable(reg_8921_s4); |
| 998 | if (rc) { |
| 999 | pr_err("disable reg_8921_s4 failed, rc=%d\n", rc); |
| 1000 | return -ENODEV; |
| 1001 | } |
| 1002 | rc = regulator_set_optimum_mode(reg_8921_l23, 100); |
| 1003 | if (rc < 0) { |
| 1004 | pr_err("set_optimum_mode l23 failed, rc=%d\n", rc); |
| 1005 | return -EINVAL; |
| 1006 | } |
| 1007 | pr_debug("%s(off): success\n", __func__); |
| 1008 | } |
| 1009 | |
| 1010 | prev_on = on; |
| 1011 | |
| 1012 | return 0; |
| 1013 | |
| 1014 | error3: |
| 1015 | gpio_free(101); |
| 1016 | error2: |
| 1017 | gpio_free(100); |
| 1018 | error1: |
| 1019 | regulator_disable(reg_8921_l23); |
| 1020 | regulator_disable(reg_8921_s4); |
| 1021 | return rc; |
| 1022 | } |
| 1023 | |
| 1024 | static int hdmi_cec_power(int on) |
| 1025 | { |
| 1026 | static int prev_on; |
| 1027 | int rc; |
| 1028 | |
| 1029 | if (on == prev_on) |
| 1030 | return 0; |
| 1031 | |
| 1032 | if (on) { |
| 1033 | rc = gpio_request(99, "HDMI_CEC_VAR"); |
| 1034 | if (rc) { |
| 1035 | pr_err("'%s'(%d) gpio_request failed, rc=%d\n", |
| 1036 | "HDMI_CEC_VAR", 99, rc); |
| 1037 | goto error; |
| 1038 | } |
| 1039 | pr_debug("%s(on): success\n", __func__); |
| 1040 | } else { |
| 1041 | gpio_free(99); |
| 1042 | pr_debug("%s(off): success\n", __func__); |
| 1043 | } |
| 1044 | |
| 1045 | prev_on = on; |
| 1046 | |
| 1047 | return 0; |
| 1048 | error: |
| 1049 | return rc; |
| 1050 | } |
| 1051 | #endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */ |
| 1052 | |
| 1053 | void __init msm8960_init_fb(void) |
| 1054 | { |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 1055 | platform_device_register(&msm_fb_device); |
| 1056 | |
Stepan Moskovchenko | 270888d | 2011-11-30 12:19:11 -0800 | [diff] [blame] | 1057 | #ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL |
| 1058 | platform_device_register(&wfd_panel_device); |
| 1059 | platform_device_register(&wfd_device); |
| 1060 | #endif |
| 1061 | |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 1062 | if (machine_is_msm8960_sim()) |
| 1063 | platform_device_register(&mipi_dsi_simulator_panel_device); |
| 1064 | |
| 1065 | if (machine_is_msm8960_rumi3()) |
| 1066 | platform_device_register(&mipi_dsi_renesas_panel_device); |
| 1067 | |
| 1068 | if (!machine_is_msm8960_sim() && !machine_is_msm8960_rumi3()) { |
| 1069 | platform_device_register(&mipi_dsi_novatek_panel_device); |
Ravishangar Kalyanam | e2d015c | 2012-01-26 14:47:14 -0800 | [diff] [blame^] | 1070 | platform_device_register(&mipi_dsi_orise_panel_device); |
Stepan Moskovchenko | 24cd864 | 2011-11-29 13:07:53 -0800 | [diff] [blame] | 1071 | |
| 1072 | #ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL |
| 1073 | platform_device_register(&hdmi_msm_device); |
| 1074 | #endif |
| 1075 | } |
| 1076 | |
| 1077 | if (machine_is_msm8960_liquid()) |
| 1078 | platform_device_register(&mipi_dsi2lvds_bridge_device); |
| 1079 | else |
| 1080 | platform_device_register(&mipi_dsi_toshiba_panel_device); |
| 1081 | |
| 1082 | if (machine_is_msm8x60_rumi3()) { |
| 1083 | msm_fb_register_device("mdp", NULL); |
| 1084 | mipi_dsi_pdata.target_type = 1; |
| 1085 | } else |
| 1086 | msm_fb_register_device("mdp", &mdp_pdata); |
| 1087 | msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata); |
| 1088 | #ifdef CONFIG_MSM_BUS_SCALING |
| 1089 | msm_fb_register_device("dtv", &dtv_pdata); |
| 1090 | #endif |
| 1091 | } |
| 1092 | |
| 1093 | void __init msm8960_allocate_fb_region(void) |
| 1094 | { |
| 1095 | void *addr; |
| 1096 | unsigned long size; |
| 1097 | |
| 1098 | size = MSM_FB_SIZE; |
| 1099 | addr = alloc_bootmem_align(size, 0x1000); |
| 1100 | msm_fb_resources[0].start = __pa(addr); |
| 1101 | msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1; |
| 1102 | pr_info("allocating %lu bytes at %p (%lx physical) for fb\n", |
| 1103 | size, addr, __pa(addr)); |
| 1104 | } |
Ravishangar Kalyanam | 8c79ead | 2011-12-02 21:05:01 -0800 | [diff] [blame] | 1105 | |
| 1106 | void __init msm8960_set_display_params(char *prim_panel, char *ext_panel) |
| 1107 | { |
| 1108 | if (strnlen(prim_panel, PANEL_NAME_MAX_LEN)) { |
| 1109 | strlcpy(msm_fb_pdata.prim_panel_name, prim_panel, |
| 1110 | PANEL_NAME_MAX_LEN); |
| 1111 | pr_debug("msm_fb_pdata.prim_panel_name %s\n", |
| 1112 | msm_fb_pdata.prim_panel_name); |
| 1113 | |
| 1114 | if (!strncmp((char *)msm_fb_pdata.prim_panel_name, |
| 1115 | HDMI_PANEL_NAME, strnlen(HDMI_PANEL_NAME, |
| 1116 | PANEL_NAME_MAX_LEN))) { |
| 1117 | pr_debug("HDMI is the primary display by" |
| 1118 | " boot parameter\n"); |
| 1119 | hdmi_is_primary = 1; |
| 1120 | } |
| 1121 | } |
| 1122 | if (strnlen(ext_panel, PANEL_NAME_MAX_LEN)) { |
| 1123 | strlcpy(msm_fb_pdata.ext_panel_name, ext_panel, |
| 1124 | PANEL_NAME_MAX_LEN); |
| 1125 | pr_debug("msm_fb_pdata.ext_panel_name %s\n", |
| 1126 | msm_fb_pdata.ext_panel_name); |
| 1127 | } |
| 1128 | } |