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