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