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