Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2012, Code Aurora Forum. All rights reserved. |
| 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> |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 16 | #include <linux/gpio.h> |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 17 | #include <linux/platform_device.h> |
| 18 | #include <linux/bootmem.h> |
Ravishangar Kalyanam | 59a67b1 | 2012-02-13 14:29:56 -0800 | [diff] [blame] | 19 | #include <linux/ion.h> |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 20 | #include <asm/mach-types.h> |
| 21 | #include <mach/msm_memtypes.h> |
| 22 | #include <mach/board.h> |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 23 | #include <mach/gpiomux.h> |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 24 | #include <mach/ion.h> |
Ravishangar Kalyanam | 59a67b1 | 2012-02-13 14:29:56 -0800 | [diff] [blame] | 25 | #include <mach/msm_bus_board.h> |
Huaibin Yang | 02f981c | 2012-02-27 16:58:41 -0800 | [diff] [blame] | 26 | #include <mach/socinfo.h> |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 27 | |
| 28 | #include "devices.h" |
| 29 | #include "board-8064.h" |
| 30 | |
| 31 | #ifdef CONFIG_FB_MSM_TRIPLE_BUFFER |
| 32 | /* prim = 1366 x 768 x 3(bpp) x 3(pages) */ |
Huaibin Yang | c8946d4 | 2012-05-04 17:22:02 -0700 | [diff] [blame] | 33 | #define MSM_FB_PRIM_BUF_SIZE roundup(1920 * 1088 * 4 * 3, 0x10000) |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 34 | #else |
| 35 | /* prim = 1366 x 768 x 3(bpp) x 2(pages) */ |
Huaibin Yang | c8946d4 | 2012-05-04 17:22:02 -0700 | [diff] [blame] | 36 | #define MSM_FB_PRIM_BUF_SIZE roundup(1920 * 1088 * 4 * 2, 0x10000) |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 37 | #endif |
| 38 | |
Huaibin Yang | c8946d4 | 2012-05-04 17:22:02 -0700 | [diff] [blame] | 39 | #define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE, 4096) |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 40 | |
| 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 | |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 53 | |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 54 | static struct resource msm_fb_resources[] = { |
| 55 | { |
| 56 | .flags = IORESOURCE_DMA, |
| 57 | } |
| 58 | }; |
| 59 | |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 60 | #define LVDS_CHIMEI_PANEL_NAME "lvds_chimei_wxga" |
Zhang Chang Ken | 4a07fcb | 2012-06-03 11:24:51 -0400 | [diff] [blame] | 61 | #define LVDS_FRC_PANEL_NAME "lvds_frc_fhd" |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 62 | #define MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME "mipi_video_toshiba_wsvga" |
| 63 | #define MIPI_VIDEO_CHIMEI_WXGA_PANEL_NAME "mipi_video_chimei_wxga" |
| 64 | #define HDMI_PANEL_NAME "hdmi_msm" |
| 65 | #define TVOUT_PANEL_NAME "tvout_msm" |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 66 | |
Zhang Chang Ken | 4a07fcb | 2012-06-03 11:24:51 -0400 | [diff] [blame] | 67 | #define LVDS_PIXEL_MAP_PATTERN_1 1 |
| 68 | #define LVDS_PIXEL_MAP_PATTERN_2 2 |
| 69 | |
Ravishangar Kalyanam | fda36c4 | 2012-03-26 16:28:19 -0700 | [diff] [blame] | 70 | #ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY |
| 71 | static unsigned char hdmi_is_primary = 1; |
| 72 | #else |
| 73 | static unsigned char hdmi_is_primary; |
| 74 | #endif |
| 75 | |
| 76 | unsigned char apq8064_hdmi_as_primary_selected(void) |
| 77 | { |
| 78 | return hdmi_is_primary; |
| 79 | } |
| 80 | |
Aravind Venkateswaran | 8ac7f41 | 2012-03-16 17:57:30 -0700 | [diff] [blame] | 81 | static void set_mdp_clocks_for_wuxga(void); |
| 82 | |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 83 | static int msm_fb_detect_panel(const char *name) |
| 84 | { |
Ravishangar Kalyanam | ed3593c | 2012-03-08 10:15:04 -0800 | [diff] [blame] | 85 | u32 version; |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 86 | if (machine_is_apq8064_liquid()) { |
Ravishangar Kalyanam | ed3593c | 2012-03-08 10:15:04 -0800 | [diff] [blame] | 87 | version = socinfo_get_platform_version(); |
| 88 | if ((SOCINFO_VERSION_MAJOR(version) == 1) && |
| 89 | (SOCINFO_VERSION_MINOR(version) == 1)) { |
| 90 | if (!strncmp(name, MIPI_VIDEO_CHIMEI_WXGA_PANEL_NAME, |
| 91 | strnlen(MIPI_VIDEO_CHIMEI_WXGA_PANEL_NAME, |
| 92 | PANEL_NAME_MAX_LEN))) |
| 93 | return 0; |
| 94 | } else { |
| 95 | if (!strncmp(name, LVDS_CHIMEI_PANEL_NAME, |
| 96 | strnlen(LVDS_CHIMEI_PANEL_NAME, |
| 97 | PANEL_NAME_MAX_LEN))) |
| 98 | return 0; |
| 99 | } |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 100 | } else if (machine_is_apq8064_mtp()) { |
| 101 | if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME, |
| 102 | strnlen(MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME, |
| 103 | PANEL_NAME_MAX_LEN))) |
| 104 | return 0; |
Zhang Chang Ken | 4a07fcb | 2012-06-03 11:24:51 -0400 | [diff] [blame] | 105 | } else if (machine_is_apq8064_cdp()) { |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 106 | if (!strncmp(name, LVDS_CHIMEI_PANEL_NAME, |
| 107 | strnlen(LVDS_CHIMEI_PANEL_NAME, |
| 108 | PANEL_NAME_MAX_LEN))) |
| 109 | return 0; |
Zhang Chang Ken | 4a07fcb | 2012-06-03 11:24:51 -0400 | [diff] [blame] | 110 | } else if (machine_is_mpq8064_dtv()) { |
| 111 | if (!strncmp(name, LVDS_FRC_PANEL_NAME, |
| 112 | strnlen(LVDS_FRC_PANEL_NAME, |
| 113 | PANEL_NAME_MAX_LEN))) { |
| 114 | set_mdp_clocks_for_wuxga(); |
| 115 | return 0; |
| 116 | } |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | if (!strncmp(name, HDMI_PANEL_NAME, |
Aravind Venkateswaran | 8ac7f41 | 2012-03-16 17:57:30 -0700 | [diff] [blame] | 120 | strnlen(HDMI_PANEL_NAME, |
| 121 | PANEL_NAME_MAX_LEN))) { |
Ravishangar Kalyanam | fda36c4 | 2012-03-26 16:28:19 -0700 | [diff] [blame] | 122 | if (apq8064_hdmi_as_primary_selected()) |
Aravind Venkateswaran | 8ac7f41 | 2012-03-16 17:57:30 -0700 | [diff] [blame] | 123 | set_mdp_clocks_for_wuxga(); |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 124 | return 0; |
Aravind Venkateswaran | 8ac7f41 | 2012-03-16 17:57:30 -0700 | [diff] [blame] | 125 | } |
| 126 | |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 127 | |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 128 | return -ENODEV; |
| 129 | } |
| 130 | |
| 131 | static struct msm_fb_platform_data msm_fb_pdata = { |
| 132 | .detect_client = msm_fb_detect_panel, |
| 133 | }; |
| 134 | |
| 135 | static struct platform_device msm_fb_device = { |
| 136 | .name = "msm_fb", |
| 137 | .id = 0, |
| 138 | .num_resources = ARRAY_SIZE(msm_fb_resources), |
| 139 | .resource = msm_fb_resources, |
| 140 | .dev.platform_data = &msm_fb_pdata, |
| 141 | }; |
| 142 | |
| 143 | void __init apq8064_allocate_fb_region(void) |
| 144 | { |
| 145 | void *addr; |
| 146 | unsigned long size; |
| 147 | |
| 148 | size = MSM_FB_SIZE; |
| 149 | addr = alloc_bootmem_align(size, 0x1000); |
| 150 | msm_fb_resources[0].start = __pa(addr); |
| 151 | msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1; |
| 152 | pr_info("allocating %lu bytes at %p (%lx physical) for fb\n", |
| 153 | size, addr, __pa(addr)); |
| 154 | } |
| 155 | |
| 156 | #define MDP_VSYNC_GPIO 0 |
| 157 | |
Ravishangar Kalyanam | 59a67b1 | 2012-02-13 14:29:56 -0800 | [diff] [blame] | 158 | static struct msm_bus_vectors mdp_init_vectors[] = { |
| 159 | { |
| 160 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 161 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 162 | .ab = 0, |
| 163 | .ib = 0, |
| 164 | }, |
| 165 | }; |
| 166 | |
| 167 | static struct msm_bus_vectors mdp_ui_vectors[] = { |
| 168 | { |
| 169 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 170 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 171 | .ab = 216000000 * 2, |
| 172 | .ib = 270000000 * 2, |
| 173 | }, |
| 174 | }; |
| 175 | |
| 176 | static struct msm_bus_vectors mdp_vga_vectors[] = { |
| 177 | /* VGA and less video */ |
| 178 | { |
| 179 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 180 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 181 | .ab = 216000000 * 2, |
| 182 | .ib = 270000000 * 2, |
| 183 | }, |
| 184 | }; |
| 185 | |
| 186 | static struct msm_bus_vectors mdp_720p_vectors[] = { |
| 187 | /* 720p and less video */ |
| 188 | { |
| 189 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 190 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 191 | .ab = 230400000 * 2, |
| 192 | .ib = 288000000 * 2, |
| 193 | }, |
| 194 | }; |
| 195 | |
| 196 | static struct msm_bus_vectors mdp_1080p_vectors[] = { |
| 197 | /* 1080p and less video */ |
| 198 | { |
| 199 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 200 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 201 | .ab = 334080000 * 2, |
| 202 | .ib = 417600000 * 2, |
| 203 | }, |
| 204 | }; |
| 205 | |
| 206 | static struct msm_bus_paths mdp_bus_scale_usecases[] = { |
| 207 | { |
| 208 | ARRAY_SIZE(mdp_init_vectors), |
| 209 | mdp_init_vectors, |
| 210 | }, |
| 211 | { |
| 212 | ARRAY_SIZE(mdp_ui_vectors), |
| 213 | mdp_ui_vectors, |
| 214 | }, |
| 215 | { |
| 216 | ARRAY_SIZE(mdp_ui_vectors), |
| 217 | mdp_ui_vectors, |
| 218 | }, |
| 219 | { |
| 220 | ARRAY_SIZE(mdp_vga_vectors), |
| 221 | mdp_vga_vectors, |
| 222 | }, |
| 223 | { |
| 224 | ARRAY_SIZE(mdp_720p_vectors), |
| 225 | mdp_720p_vectors, |
| 226 | }, |
| 227 | { |
| 228 | ARRAY_SIZE(mdp_1080p_vectors), |
| 229 | mdp_1080p_vectors, |
| 230 | }, |
| 231 | }; |
| 232 | |
| 233 | static struct msm_bus_scale_pdata mdp_bus_scale_pdata = { |
| 234 | mdp_bus_scale_usecases, |
| 235 | ARRAY_SIZE(mdp_bus_scale_usecases), |
| 236 | .name = "mdp", |
| 237 | }; |
| 238 | |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 239 | static int mdp_core_clk_rate_table[] = { |
Nagamalleswararao Ganji | 90111f2 | 2012-06-01 00:51:33 -0700 | [diff] [blame] | 240 | 59080000, |
Huaibin Yang | 0962b92 | 2012-03-27 10:11:48 -0700 | [diff] [blame] | 241 | 128000000, |
| 242 | 160000000, |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 243 | 200000000, |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 244 | }; |
| 245 | |
| 246 | static struct msm_panel_common_pdata mdp_pdata = { |
| 247 | .gpio = MDP_VSYNC_GPIO, |
Nagamalleswararao Ganji | 90111f2 | 2012-06-01 00:51:33 -0700 | [diff] [blame] | 248 | .mdp_core_clk_rate = 59080000, |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 249 | .mdp_core_clk_table = mdp_core_clk_rate_table, |
| 250 | .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table), |
Ravishangar Kalyanam | 59a67b1 | 2012-02-13 14:29:56 -0800 | [diff] [blame] | 251 | .mdp_bus_scale_table = &mdp_bus_scale_pdata, |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 252 | .mdp_rev = MDP_REV_44, |
| 253 | #ifdef CONFIG_MSM_MULTIMEDIA_USE_ION |
Ravishangar Kalyanam | a3b168b | 2012-03-26 11:13:11 -0700 | [diff] [blame] | 254 | .mem_hid = BIT(ION_CP_MM_HEAP_ID), |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 255 | #else |
| 256 | .mem_hid = MEMTYPE_EBI1, |
| 257 | #endif |
| 258 | }; |
| 259 | |
| 260 | void __init apq8064_mdp_writeback(struct memtype_reserve* reserve_table) |
| 261 | { |
| 262 | mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE; |
| 263 | mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE; |
| 264 | #if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION) |
| 265 | reserve_table[mdp_pdata.mem_hid].size += |
| 266 | mdp_pdata.ov0_wb_size; |
| 267 | reserve_table[mdp_pdata.mem_hid].size += |
| 268 | mdp_pdata.ov1_wb_size; |
| 269 | #endif |
| 270 | } |
| 271 | |
Aravind Venkateswaran | 0507c8c | 2012-02-16 17:16:05 -0800 | [diff] [blame] | 272 | static struct resource hdmi_msm_resources[] = { |
| 273 | { |
| 274 | .name = "hdmi_msm_qfprom_addr", |
| 275 | .start = 0x00700000, |
| 276 | .end = 0x007060FF, |
| 277 | .flags = IORESOURCE_MEM, |
| 278 | }, |
| 279 | { |
| 280 | .name = "hdmi_msm_hdmi_addr", |
| 281 | .start = 0x04A00000, |
| 282 | .end = 0x04A00FFF, |
| 283 | .flags = IORESOURCE_MEM, |
| 284 | }, |
| 285 | { |
| 286 | .name = "hdmi_msm_irq", |
| 287 | .start = HDMI_IRQ, |
| 288 | .end = HDMI_IRQ, |
| 289 | .flags = IORESOURCE_IRQ, |
| 290 | }, |
| 291 | }; |
| 292 | |
| 293 | static int hdmi_enable_5v(int on); |
| 294 | static int hdmi_core_power(int on, int show); |
| 295 | static int hdmi_cec_power(int on); |
Ajay Singh Parmar | 7d11c27 | 2012-06-07 12:25:31 +0530 | [diff] [blame^] | 296 | static int hdmi_gpio_config(int on); |
| 297 | static int hdmi_panel_power(int on); |
Aravind Venkateswaran | 0507c8c | 2012-02-16 17:16:05 -0800 | [diff] [blame] | 298 | |
| 299 | static struct msm_hdmi_platform_data hdmi_msm_data = { |
| 300 | .irq = HDMI_IRQ, |
| 301 | .enable_5v = hdmi_enable_5v, |
| 302 | .core_power = hdmi_core_power, |
| 303 | .cec_power = hdmi_cec_power, |
Ajay Singh Parmar | 7d11c27 | 2012-06-07 12:25:31 +0530 | [diff] [blame^] | 304 | .panel_power = hdmi_panel_power, |
| 305 | .gpio_config = hdmi_gpio_config, |
Aravind Venkateswaran | 0507c8c | 2012-02-16 17:16:05 -0800 | [diff] [blame] | 306 | }; |
| 307 | |
| 308 | static struct platform_device hdmi_msm_device = { |
| 309 | .name = "hdmi_msm", |
| 310 | .id = 0, |
| 311 | .num_resources = ARRAY_SIZE(hdmi_msm_resources), |
| 312 | .resource = hdmi_msm_resources, |
| 313 | .dev.platform_data = &hdmi_msm_data, |
| 314 | }; |
| 315 | |
Mohan Kumar Gubbihalli Lachma Naik | cb7d4e7 | 2012-03-23 18:17:30 -0700 | [diff] [blame] | 316 | #ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL |
| 317 | static struct platform_device wfd_panel_device = { |
| 318 | .name = "wfd_panel", |
| 319 | .id = 0, |
| 320 | .dev.platform_data = NULL, |
| 321 | }; |
| 322 | |
| 323 | static struct platform_device wfd_device = { |
| 324 | .name = "msm_wfd", |
| 325 | .id = -1, |
| 326 | }; |
| 327 | #endif |
| 328 | |
Aravind Venkateswaran | 0507c8c | 2012-02-16 17:16:05 -0800 | [diff] [blame] | 329 | /* HDMI related GPIOs */ |
| 330 | #define HDMI_CEC_VAR_GPIO 69 |
| 331 | #define HDMI_DDC_CLK_GPIO 70 |
| 332 | #define HDMI_DDC_DATA_GPIO 71 |
| 333 | #define HDMI_HPD_GPIO 72 |
| 334 | |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 335 | static bool dsi_power_on; |
| 336 | static int mipi_dsi_panel_power(int on) |
| 337 | { |
| 338 | static struct regulator *reg_lvs7, *reg_l2, *reg_l11, *reg_ext_3p3v; |
| 339 | static int gpio36, gpio25, gpio26, mpp3; |
| 340 | int rc; |
| 341 | |
| 342 | pr_debug("%s: on=%d\n", __func__, on); |
| 343 | |
| 344 | if (!dsi_power_on) { |
| 345 | reg_lvs7 = regulator_get(&msm_mipi_dsi1_device.dev, |
| 346 | "dsi1_vddio"); |
| 347 | if (IS_ERR_OR_NULL(reg_lvs7)) { |
| 348 | pr_err("could not get 8921_lvs7, rc = %ld\n", |
| 349 | PTR_ERR(reg_lvs7)); |
| 350 | return -ENODEV; |
| 351 | } |
| 352 | |
| 353 | reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev, |
| 354 | "dsi1_pll_vdda"); |
| 355 | if (IS_ERR_OR_NULL(reg_l2)) { |
| 356 | pr_err("could not get 8921_l2, rc = %ld\n", |
| 357 | PTR_ERR(reg_l2)); |
| 358 | return -ENODEV; |
| 359 | } |
| 360 | |
| 361 | rc = regulator_set_voltage(reg_l2, 1200000, 1200000); |
| 362 | if (rc) { |
| 363 | pr_err("set_voltage l2 failed, rc=%d\n", rc); |
| 364 | return -EINVAL; |
| 365 | } |
| 366 | reg_l11 = regulator_get(&msm_mipi_dsi1_device.dev, |
| 367 | "dsi1_avdd"); |
| 368 | if (IS_ERR(reg_l11)) { |
| 369 | pr_err("could not get 8921_l11, rc = %ld\n", |
| 370 | PTR_ERR(reg_l11)); |
| 371 | return -ENODEV; |
| 372 | } |
| 373 | rc = regulator_set_voltage(reg_l11, 3000000, 3000000); |
| 374 | if (rc) { |
| 375 | pr_err("set_voltage l11 failed, rc=%d\n", rc); |
| 376 | return -EINVAL; |
| 377 | } |
| 378 | |
| 379 | if (machine_is_apq8064_liquid()) { |
| 380 | reg_ext_3p3v = regulator_get(&msm_mipi_dsi1_device.dev, |
| 381 | "dsi1_vccs_3p3v"); |
| 382 | if (IS_ERR_OR_NULL(reg_ext_3p3v)) { |
| 383 | pr_err("could not get reg_ext_3p3v, rc = %ld\n", |
| 384 | PTR_ERR(reg_ext_3p3v)); |
| 385 | reg_ext_3p3v = NULL; |
| 386 | return -ENODEV; |
| 387 | } |
| 388 | mpp3 = PM8921_MPP_PM_TO_SYS(3); |
| 389 | rc = gpio_request(mpp3, "backlight_en"); |
| 390 | if (rc) { |
| 391 | pr_err("request mpp3 failed, rc=%d\n", rc); |
| 392 | return -ENODEV; |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | gpio25 = PM8921_GPIO_PM_TO_SYS(25); |
| 397 | rc = gpio_request(gpio25, "disp_rst_n"); |
| 398 | if (rc) { |
| 399 | pr_err("request gpio 25 failed, rc=%d\n", rc); |
| 400 | return -ENODEV; |
| 401 | } |
| 402 | |
| 403 | gpio26 = PM8921_GPIO_PM_TO_SYS(26); |
| 404 | rc = gpio_request(gpio26, "pwm_backlight_ctrl"); |
| 405 | if (rc) { |
| 406 | pr_err("request gpio 26 failed, rc=%d\n", rc); |
| 407 | return -ENODEV; |
| 408 | } |
| 409 | |
| 410 | gpio36 = PM8921_GPIO_PM_TO_SYS(36); /* lcd1_pwr_en_n */ |
| 411 | rc = gpio_request(gpio36, "lcd1_pwr_en_n"); |
| 412 | if (rc) { |
| 413 | pr_err("request gpio 36 failed, rc=%d\n", rc); |
| 414 | return -ENODEV; |
| 415 | } |
| 416 | |
| 417 | dsi_power_on = true; |
| 418 | } |
| 419 | |
| 420 | if (on) { |
| 421 | rc = regulator_enable(reg_lvs7); |
| 422 | if (rc) { |
| 423 | pr_err("enable lvs7 failed, rc=%d\n", rc); |
| 424 | return -ENODEV; |
| 425 | } |
| 426 | |
| 427 | rc = regulator_set_optimum_mode(reg_l11, 110000); |
| 428 | if (rc < 0) { |
| 429 | pr_err("set_optimum_mode l11 failed, rc=%d\n", rc); |
| 430 | return -EINVAL; |
| 431 | } |
| 432 | rc = regulator_enable(reg_l11); |
| 433 | if (rc) { |
| 434 | pr_err("enable l11 failed, rc=%d\n", rc); |
| 435 | return -ENODEV; |
| 436 | } |
| 437 | |
| 438 | rc = regulator_set_optimum_mode(reg_l2, 100000); |
| 439 | if (rc < 0) { |
| 440 | pr_err("set_optimum_mode l2 failed, rc=%d\n", rc); |
| 441 | return -EINVAL; |
| 442 | } |
| 443 | rc = regulator_enable(reg_l2); |
| 444 | if (rc) { |
| 445 | pr_err("enable l2 failed, rc=%d\n", rc); |
| 446 | return -ENODEV; |
| 447 | } |
| 448 | |
| 449 | if (machine_is_apq8064_liquid()) { |
| 450 | rc = regulator_enable(reg_ext_3p3v); |
| 451 | if (rc) { |
| 452 | pr_err("enable reg_ext_3p3v failed, rc=%d\n", |
| 453 | rc); |
| 454 | return -ENODEV; |
| 455 | } |
| 456 | gpio_set_value_cansleep(mpp3, 1); |
| 457 | } |
| 458 | |
| 459 | gpio_set_value_cansleep(gpio36, 0); |
| 460 | gpio_set_value_cansleep(gpio25, 1); |
| 461 | } else { |
| 462 | gpio_set_value_cansleep(gpio25, 0); |
| 463 | gpio_set_value_cansleep(gpio36, 1); |
| 464 | |
| 465 | if (machine_is_apq8064_liquid()) { |
| 466 | gpio_set_value_cansleep(mpp3, 0); |
| 467 | |
| 468 | rc = regulator_disable(reg_ext_3p3v); |
| 469 | if (rc) { |
| 470 | pr_err("disable reg_ext_3p3v failed, rc=%d\n", |
| 471 | rc); |
| 472 | return -ENODEV; |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | rc = regulator_disable(reg_lvs7); |
| 477 | if (rc) { |
| 478 | pr_err("disable reg_lvs7 failed, rc=%d\n", rc); |
| 479 | return -ENODEV; |
| 480 | } |
| 481 | rc = regulator_disable(reg_l2); |
| 482 | if (rc) { |
| 483 | pr_err("disable reg_l2 failed, rc=%d\n", rc); |
| 484 | return -ENODEV; |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | return 0; |
| 489 | } |
| 490 | |
| 491 | static struct mipi_dsi_platform_data mipi_dsi_pdata = { |
| 492 | .dsi_power_save = mipi_dsi_panel_power, |
| 493 | }; |
| 494 | |
| 495 | static bool lvds_power_on; |
| 496 | static int lvds_panel_power(int on) |
| 497 | { |
| 498 | static struct regulator *reg_lvs7, *reg_l2, *reg_ext_3p3v; |
| 499 | static int gpio36, gpio26, mpp3; |
| 500 | int rc; |
| 501 | |
| 502 | pr_debug("%s: on=%d\n", __func__, on); |
| 503 | |
| 504 | if (!lvds_power_on) { |
| 505 | reg_lvs7 = regulator_get(&msm_lvds_device.dev, |
| 506 | "lvds_vdda"); |
| 507 | if (IS_ERR_OR_NULL(reg_lvs7)) { |
| 508 | pr_err("could not get 8921_lvs7, rc = %ld\n", |
| 509 | PTR_ERR(reg_lvs7)); |
| 510 | return -ENODEV; |
| 511 | } |
| 512 | |
| 513 | reg_l2 = regulator_get(&msm_lvds_device.dev, |
| 514 | "lvds_pll_vdda"); |
| 515 | if (IS_ERR_OR_NULL(reg_l2)) { |
| 516 | pr_err("could not get 8921_l2, rc = %ld\n", |
| 517 | PTR_ERR(reg_l2)); |
| 518 | return -ENODEV; |
| 519 | } |
| 520 | |
| 521 | rc = regulator_set_voltage(reg_l2, 1200000, 1200000); |
| 522 | if (rc) { |
| 523 | pr_err("set_voltage l2 failed, rc=%d\n", rc); |
| 524 | return -EINVAL; |
| 525 | } |
| 526 | |
| 527 | reg_ext_3p3v = regulator_get(&msm_lvds_device.dev, |
| 528 | "lvds_vccs_3p3v"); |
| 529 | if (IS_ERR_OR_NULL(reg_ext_3p3v)) { |
| 530 | pr_err("could not get reg_ext_3p3v, rc = %ld\n", |
| 531 | PTR_ERR(reg_ext_3p3v)); |
| 532 | return -ENODEV; |
| 533 | } |
| 534 | |
| 535 | gpio26 = PM8921_GPIO_PM_TO_SYS(26); |
| 536 | rc = gpio_request(gpio26, "pwm_backlight_ctrl"); |
| 537 | if (rc) { |
| 538 | pr_err("request gpio 26 failed, rc=%d\n", rc); |
| 539 | return -ENODEV; |
| 540 | } |
| 541 | |
| 542 | gpio36 = PM8921_GPIO_PM_TO_SYS(36); /* lcd1_pwr_en_n */ |
| 543 | rc = gpio_request(gpio36, "lcd1_pwr_en_n"); |
| 544 | if (rc) { |
| 545 | pr_err("request gpio 36 failed, rc=%d\n", rc); |
| 546 | return -ENODEV; |
| 547 | } |
| 548 | |
| 549 | mpp3 = PM8921_MPP_PM_TO_SYS(3); |
| 550 | rc = gpio_request(mpp3, "backlight_en"); |
| 551 | if (rc) { |
| 552 | pr_err("request mpp3 failed, rc=%d\n", rc); |
| 553 | return -ENODEV; |
| 554 | } |
| 555 | |
| 556 | lvds_power_on = true; |
| 557 | } |
| 558 | |
| 559 | if (on) { |
| 560 | rc = regulator_enable(reg_lvs7); |
| 561 | if (rc) { |
| 562 | pr_err("enable lvs7 failed, rc=%d\n", rc); |
| 563 | return -ENODEV; |
| 564 | } |
| 565 | |
| 566 | rc = regulator_set_optimum_mode(reg_l2, 100000); |
| 567 | if (rc < 0) { |
| 568 | pr_err("set_optimum_mode l2 failed, rc=%d\n", rc); |
| 569 | return -EINVAL; |
| 570 | } |
| 571 | rc = regulator_enable(reg_l2); |
| 572 | if (rc) { |
| 573 | pr_err("enable l2 failed, rc=%d\n", rc); |
| 574 | return -ENODEV; |
| 575 | } |
| 576 | |
| 577 | rc = regulator_enable(reg_ext_3p3v); |
| 578 | if (rc) { |
| 579 | pr_err("enable reg_ext_3p3v failed, rc=%d\n", rc); |
| 580 | return -ENODEV; |
| 581 | } |
| 582 | |
| 583 | gpio_set_value_cansleep(gpio36, 0); |
| 584 | gpio_set_value_cansleep(mpp3, 1); |
| 585 | } else { |
| 586 | gpio_set_value_cansleep(mpp3, 0); |
| 587 | gpio_set_value_cansleep(gpio36, 1); |
| 588 | |
| 589 | rc = regulator_disable(reg_lvs7); |
| 590 | if (rc) { |
| 591 | pr_err("disable reg_lvs7 failed, rc=%d\n", rc); |
| 592 | return -ENODEV; |
| 593 | } |
| 594 | rc = regulator_disable(reg_l2); |
| 595 | if (rc) { |
| 596 | pr_err("disable reg_l2 failed, rc=%d\n", rc); |
| 597 | return -ENODEV; |
| 598 | } |
| 599 | rc = regulator_disable(reg_ext_3p3v); |
| 600 | if (rc) { |
| 601 | pr_err("disable reg_ext_3p3v failed, rc=%d\n", rc); |
| 602 | return -ENODEV; |
| 603 | } |
| 604 | } |
| 605 | |
| 606 | return 0; |
| 607 | } |
| 608 | |
Huaibin Yang | 02f981c | 2012-02-27 16:58:41 -0800 | [diff] [blame] | 609 | static int lvds_pixel_remap(void) |
| 610 | { |
| 611 | if (machine_is_apq8064_cdp() || |
| 612 | machine_is_apq8064_liquid()) { |
Ravishangar Kalyanam | 0e3d69e | 2012-05-04 15:55:13 -0700 | [diff] [blame] | 613 | u32 ver = socinfo_get_version(); |
Huaibin Yang | 02f981c | 2012-02-27 16:58:41 -0800 | [diff] [blame] | 614 | if ((SOCINFO_VERSION_MAJOR(ver) == 1) && |
| 615 | (SOCINFO_VERSION_MINOR(ver) == 0)) |
Zhang Chang Ken | 4a07fcb | 2012-06-03 11:24:51 -0400 | [diff] [blame] | 616 | return LVDS_PIXEL_MAP_PATTERN_1; |
| 617 | } else if (machine_is_mpq8064_dtv()) { |
| 618 | return LVDS_PIXEL_MAP_PATTERN_2; |
Huaibin Yang | 02f981c | 2012-02-27 16:58:41 -0800 | [diff] [blame] | 619 | } |
| 620 | return 0; |
| 621 | } |
| 622 | |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 623 | static struct lcdc_platform_data lvds_pdata = { |
| 624 | .lcdc_power_save = lvds_panel_power, |
Huaibin Yang | 02f981c | 2012-02-27 16:58:41 -0800 | [diff] [blame] | 625 | .lvds_pixel_remap = lvds_pixel_remap |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 626 | }; |
| 627 | |
| 628 | #define LPM_CHANNEL 2 |
| 629 | static int lvds_chimei_gpio[] = {LPM_CHANNEL}; |
| 630 | |
| 631 | static struct lvds_panel_platform_data lvds_chimei_pdata = { |
| 632 | .gpio = lvds_chimei_gpio, |
| 633 | }; |
| 634 | |
| 635 | static struct platform_device lvds_chimei_panel_device = { |
| 636 | .name = "lvds_chimei_wxga", |
| 637 | .id = 0, |
| 638 | .dev = { |
| 639 | .platform_data = &lvds_chimei_pdata, |
| 640 | } |
| 641 | }; |
| 642 | |
Zhang Chang Ken | 4a07fcb | 2012-06-03 11:24:51 -0400 | [diff] [blame] | 643 | #define FRC_GPIO_UPDATE (SX150X_EXP4_GPIO_BASE + 8) |
| 644 | #define FRC_GPIO_RESET (SX150X_EXP4_GPIO_BASE + 9) |
| 645 | #define FRC_GPIO_PWR (SX150X_EXP4_GPIO_BASE + 10) |
| 646 | |
| 647 | static int lvds_frc_gpio[] = {FRC_GPIO_UPDATE, FRC_GPIO_RESET, FRC_GPIO_PWR}; |
| 648 | static struct lvds_panel_platform_data lvds_frc_pdata = { |
| 649 | .gpio = lvds_frc_gpio, |
| 650 | }; |
| 651 | |
| 652 | static struct platform_device lvds_frc_panel_device = { |
| 653 | .name = "lvds_frc_fhd", |
| 654 | .id = 0, |
| 655 | .dev = { |
| 656 | .platform_data = &lvds_frc_pdata, |
| 657 | } |
| 658 | }; |
| 659 | |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 660 | static int dsi2lvds_gpio[2] = { |
| 661 | LPM_CHANNEL,/* Backlight PWM-ID=0 for PMIC-GPIO#24 */ |
| 662 | 0x1F08 /* DSI2LVDS Bridge GPIO Output, mask=0x1f, out=0x08 */ |
| 663 | }; |
| 664 | static struct msm_panel_common_pdata mipi_dsi2lvds_pdata = { |
| 665 | .gpio_num = dsi2lvds_gpio, |
| 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 | |
| 674 | static int toshiba_gpio[] = {LPM_CHANNEL}; |
| 675 | static struct mipi_dsi_panel_platform_data toshiba_pdata = { |
| 676 | .gpio = toshiba_gpio, |
| 677 | }; |
| 678 | |
| 679 | static struct platform_device mipi_dsi_toshiba_panel_device = { |
| 680 | .name = "mipi_toshiba", |
| 681 | .id = 0, |
| 682 | .dev = { |
| 683 | .platform_data = &toshiba_pdata, |
| 684 | } |
| 685 | }; |
| 686 | |
Aravind Venkateswaran | 0507c8c | 2012-02-16 17:16:05 -0800 | [diff] [blame] | 687 | static struct msm_bus_vectors dtv_bus_init_vectors[] = { |
| 688 | { |
| 689 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 690 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 691 | .ab = 0, |
| 692 | .ib = 0, |
| 693 | }, |
| 694 | }; |
| 695 | |
Aravind Venkateswaran | 0507c8c | 2012-02-16 17:16:05 -0800 | [diff] [blame] | 696 | static struct msm_bus_vectors dtv_bus_def_vectors[] = { |
| 697 | { |
| 698 | .src = MSM_BUS_MASTER_MDP_PORT0, |
| 699 | .dst = MSM_BUS_SLAVE_EBI_CH0, |
| 700 | .ab = 566092800 * 2, |
| 701 | .ib = 707616000 * 2, |
| 702 | }, |
| 703 | }; |
Aravind Venkateswaran | 0507c8c | 2012-02-16 17:16:05 -0800 | [diff] [blame] | 704 | |
| 705 | static struct msm_bus_paths dtv_bus_scale_usecases[] = { |
| 706 | { |
| 707 | ARRAY_SIZE(dtv_bus_init_vectors), |
| 708 | dtv_bus_init_vectors, |
| 709 | }, |
| 710 | { |
| 711 | ARRAY_SIZE(dtv_bus_def_vectors), |
| 712 | dtv_bus_def_vectors, |
| 713 | }, |
| 714 | }; |
| 715 | static struct msm_bus_scale_pdata dtv_bus_scale_pdata = { |
| 716 | dtv_bus_scale_usecases, |
| 717 | ARRAY_SIZE(dtv_bus_scale_usecases), |
| 718 | .name = "dtv", |
| 719 | }; |
| 720 | |
| 721 | static struct lcdc_platform_data dtv_pdata = { |
| 722 | .bus_scale_table = &dtv_bus_scale_pdata, |
Ajay Singh Parmar | 7d11c27 | 2012-06-07 12:25:31 +0530 | [diff] [blame^] | 723 | .lcdc_power_save = hdmi_panel_power, |
Aravind Venkateswaran | 0507c8c | 2012-02-16 17:16:05 -0800 | [diff] [blame] | 724 | }; |
| 725 | |
Ajay Singh Parmar | 7d11c27 | 2012-06-07 12:25:31 +0530 | [diff] [blame^] | 726 | static int hdmi_panel_power(int on) |
| 727 | { |
| 728 | int rc; |
| 729 | |
| 730 | pr_debug("%s: HDMI Core: %s\n", __func__, (on ? "ON" : "OFF")); |
| 731 | rc = hdmi_core_power(on, 1); |
| 732 | if (rc) |
| 733 | rc = hdmi_cec_power(on); |
| 734 | |
| 735 | pr_debug("%s: HDMI Core: %s Success\n", __func__, (on ? "ON" : "OFF")); |
| 736 | return rc; |
| 737 | } |
| 738 | |
Aravind Venkateswaran | 0507c8c | 2012-02-16 17:16:05 -0800 | [diff] [blame] | 739 | static int hdmi_enable_5v(int on) |
| 740 | { |
| 741 | /* TBD: PM8921 regulator instead of 8901 */ |
| 742 | static struct regulator *reg_8921_hdmi_mvs; /* HDMI_5V */ |
| 743 | static int prev_on; |
| 744 | int rc; |
| 745 | |
| 746 | if (on == prev_on) |
| 747 | return 0; |
| 748 | |
| 749 | if (!reg_8921_hdmi_mvs) { |
| 750 | reg_8921_hdmi_mvs = regulator_get(&hdmi_msm_device.dev, |
| 751 | "hdmi_mvs"); |
| 752 | if (IS_ERR(reg_8921_hdmi_mvs)) { |
| 753 | pr_err("could not get reg_8921_hdmi_mvs, rc = %ld\n", |
| 754 | PTR_ERR(reg_8921_hdmi_mvs)); |
| 755 | reg_8921_hdmi_mvs = NULL; |
| 756 | return -ENODEV; |
| 757 | } |
| 758 | } |
| 759 | |
| 760 | if (on) { |
| 761 | rc = regulator_enable(reg_8921_hdmi_mvs); |
| 762 | if (rc) { |
| 763 | pr_err("'%s' regulator enable failed, rc=%d\n", |
| 764 | "8921_hdmi_mvs", rc); |
| 765 | return rc; |
| 766 | } |
| 767 | pr_debug("%s(on): success\n", __func__); |
| 768 | } else { |
| 769 | rc = regulator_disable(reg_8921_hdmi_mvs); |
| 770 | if (rc) |
| 771 | pr_warning("'%s' regulator disable failed, rc=%d\n", |
| 772 | "8921_hdmi_mvs", rc); |
| 773 | pr_debug("%s(off): success\n", __func__); |
| 774 | } |
| 775 | |
| 776 | prev_on = on; |
| 777 | |
| 778 | return 0; |
| 779 | } |
| 780 | |
| 781 | static int hdmi_core_power(int on, int show) |
| 782 | { |
| 783 | static struct regulator *reg_8921_lvs7, *reg_8921_s4, *reg_ext_3p3v; |
| 784 | static int prev_on; |
| 785 | int rc; |
Aravind Venkateswaran | 0507c8c | 2012-02-16 17:16:05 -0800 | [diff] [blame] | 786 | |
| 787 | if (on == prev_on) |
| 788 | return 0; |
| 789 | |
| 790 | /* TBD: PM8921 regulator instead of 8901 */ |
| 791 | if (!reg_ext_3p3v) { |
| 792 | reg_ext_3p3v = regulator_get(&hdmi_msm_device.dev, |
| 793 | "hdmi_mux_vdd"); |
| 794 | if (IS_ERR_OR_NULL(reg_ext_3p3v)) { |
| 795 | pr_err("could not get reg_ext_3p3v, rc = %ld\n", |
| 796 | PTR_ERR(reg_ext_3p3v)); |
| 797 | reg_ext_3p3v = NULL; |
| 798 | return -ENODEV; |
| 799 | } |
| 800 | } |
| 801 | |
| 802 | if (!reg_8921_lvs7) { |
| 803 | reg_8921_lvs7 = regulator_get(&hdmi_msm_device.dev, |
| 804 | "hdmi_vdda"); |
| 805 | if (IS_ERR(reg_8921_lvs7)) { |
| 806 | pr_err("could not get reg_8921_lvs7, rc = %ld\n", |
| 807 | PTR_ERR(reg_8921_lvs7)); |
| 808 | reg_8921_lvs7 = NULL; |
| 809 | return -ENODEV; |
| 810 | } |
| 811 | } |
| 812 | if (!reg_8921_s4) { |
| 813 | reg_8921_s4 = regulator_get(&hdmi_msm_device.dev, |
| 814 | "hdmi_lvl_tsl"); |
| 815 | if (IS_ERR(reg_8921_s4)) { |
| 816 | pr_err("could not get reg_8921_s4, rc = %ld\n", |
| 817 | PTR_ERR(reg_8921_s4)); |
| 818 | reg_8921_s4 = NULL; |
| 819 | return -ENODEV; |
| 820 | } |
| 821 | rc = regulator_set_voltage(reg_8921_s4, 1800000, 1800000); |
| 822 | if (rc) { |
| 823 | pr_err("set_voltage failed for 8921_s4, rc=%d\n", rc); |
| 824 | return -EINVAL; |
| 825 | } |
| 826 | } |
| 827 | |
| 828 | if (on) { |
| 829 | /* |
| 830 | * Configure 3P3V_BOOST_EN as GPIO, 8mA drive strength, |
| 831 | * pull none, out-high |
| 832 | */ |
| 833 | rc = regulator_set_optimum_mode(reg_ext_3p3v, 290000); |
| 834 | if (rc < 0) { |
| 835 | pr_err("set_optimum_mode ext_3p3v failed, rc=%d\n", rc); |
| 836 | return -EINVAL; |
| 837 | } |
| 838 | |
| 839 | rc = regulator_enable(reg_ext_3p3v); |
| 840 | if (rc) { |
| 841 | pr_err("enable reg_ext_3p3v failed, rc=%d\n", rc); |
Ajay Singh Parmar | 7d11c27 | 2012-06-07 12:25:31 +0530 | [diff] [blame^] | 842 | return rc; |
Aravind Venkateswaran | 0507c8c | 2012-02-16 17:16:05 -0800 | [diff] [blame] | 843 | } |
| 844 | rc = regulator_enable(reg_8921_lvs7); |
| 845 | if (rc) { |
| 846 | pr_err("'%s' regulator enable failed, rc=%d\n", |
| 847 | "hdmi_vdda", rc); |
Ajay Singh Parmar | 7d11c27 | 2012-06-07 12:25:31 +0530 | [diff] [blame^] | 848 | goto error1; |
Aravind Venkateswaran | 0507c8c | 2012-02-16 17:16:05 -0800 | [diff] [blame] | 849 | } |
| 850 | rc = regulator_enable(reg_8921_s4); |
| 851 | if (rc) { |
| 852 | pr_err("'%s' regulator enable failed, rc=%d\n", |
| 853 | "hdmi_lvl_tsl", rc); |
Ajay Singh Parmar | 7d11c27 | 2012-06-07 12:25:31 +0530 | [diff] [blame^] | 854 | goto error2; |
Aravind Venkateswaran | 0507c8c | 2012-02-16 17:16:05 -0800 | [diff] [blame] | 855 | } |
Ajay Singh Parmar | 7d11c27 | 2012-06-07 12:25:31 +0530 | [diff] [blame^] | 856 | pr_debug("%s(on): success\n", __func__); |
| 857 | } else { |
| 858 | rc = regulator_disable(reg_ext_3p3v); |
| 859 | if (rc) { |
| 860 | pr_err("disable reg_ext_3p3v failed, rc=%d\n", rc); |
| 861 | return -ENODEV; |
| 862 | } |
| 863 | rc = regulator_disable(reg_8921_lvs7); |
| 864 | if (rc) { |
| 865 | pr_err("disable reg_8921_l23 failed, rc=%d\n", rc); |
| 866 | return -ENODEV; |
| 867 | } |
| 868 | rc = regulator_disable(reg_8921_s4); |
| 869 | if (rc) { |
| 870 | pr_err("disable reg_8921_s4 failed, rc=%d\n", rc); |
| 871 | return -ENODEV; |
| 872 | } |
| 873 | pr_debug("%s(off): success\n", __func__); |
| 874 | } |
| 875 | |
| 876 | prev_on = on; |
| 877 | |
| 878 | return 0; |
| 879 | |
| 880 | error2: |
| 881 | regulator_disable(reg_8921_lvs7); |
| 882 | error1: |
| 883 | regulator_disable(reg_ext_3p3v); |
| 884 | return rc; |
| 885 | } |
| 886 | |
| 887 | static int hdmi_gpio_config(int on) |
| 888 | { |
| 889 | int rc = 0; |
| 890 | static int prev_on; |
| 891 | int pmic_gpio14 = PM8921_GPIO_PM_TO_SYS(14); |
| 892 | |
| 893 | if (on == prev_on) |
| 894 | return 0; |
| 895 | |
| 896 | if (on) { |
Aravind Venkateswaran | 0507c8c | 2012-02-16 17:16:05 -0800 | [diff] [blame] | 897 | rc = gpio_request(HDMI_DDC_CLK_GPIO, "HDMI_DDC_CLK"); |
| 898 | if (rc) { |
| 899 | pr_err("'%s'(%d) gpio_request failed, rc=%d\n", |
| 900 | "HDMI_DDC_CLK", HDMI_DDC_CLK_GPIO, rc); |
| 901 | goto error1; |
| 902 | } |
| 903 | rc = gpio_request(HDMI_DDC_DATA_GPIO, "HDMI_DDC_DATA"); |
| 904 | if (rc) { |
| 905 | pr_err("'%s'(%d) gpio_request failed, rc=%d\n", |
| 906 | "HDMI_DDC_DATA", HDMI_DDC_DATA_GPIO, rc); |
| 907 | goto error2; |
| 908 | } |
| 909 | rc = gpio_request(HDMI_HPD_GPIO, "HDMI_HPD"); |
| 910 | if (rc) { |
| 911 | pr_err("'%s'(%d) gpio_request failed, rc=%d\n", |
| 912 | "HDMI_HPD", HDMI_HPD_GPIO, rc); |
| 913 | goto error3; |
| 914 | } |
| 915 | if (machine_is_apq8064_liquid()) { |
| 916 | rc = gpio_request(pmic_gpio14, "PMIC_HDMI_MUX_SEL"); |
| 917 | if (rc) { |
| 918 | pr_err("'%s'(%d) gpio_request failed, rc=%d\n", |
| 919 | "PMIC_HDMI_MUX_SEL", 14, rc); |
| 920 | goto error4; |
| 921 | } |
| 922 | gpio_set_value_cansleep(pmic_gpio14, 0); |
| 923 | } |
| 924 | pr_debug("%s(on): success\n", __func__); |
| 925 | } else { |
| 926 | gpio_free(HDMI_DDC_CLK_GPIO); |
| 927 | gpio_free(HDMI_DDC_DATA_GPIO); |
| 928 | gpio_free(HDMI_HPD_GPIO); |
| 929 | |
| 930 | if (machine_is_apq8064_liquid()) { |
| 931 | gpio_set_value_cansleep(pmic_gpio14, 1); |
| 932 | gpio_free(pmic_gpio14); |
| 933 | } |
Aravind Venkateswaran | 0507c8c | 2012-02-16 17:16:05 -0800 | [diff] [blame] | 934 | pr_debug("%s(off): success\n", __func__); |
| 935 | } |
| 936 | |
| 937 | prev_on = on; |
Aravind Venkateswaran | 0507c8c | 2012-02-16 17:16:05 -0800 | [diff] [blame] | 938 | return 0; |
| 939 | |
| 940 | error4: |
| 941 | gpio_free(HDMI_HPD_GPIO); |
| 942 | error3: |
| 943 | gpio_free(HDMI_DDC_DATA_GPIO); |
| 944 | error2: |
| 945 | gpio_free(HDMI_DDC_CLK_GPIO); |
| 946 | error1: |
Aravind Venkateswaran | 0507c8c | 2012-02-16 17:16:05 -0800 | [diff] [blame] | 947 | return rc; |
| 948 | } |
| 949 | |
| 950 | static int hdmi_cec_power(int on) |
| 951 | { |
| 952 | static int prev_on; |
| 953 | int rc; |
| 954 | |
| 955 | if (on == prev_on) |
| 956 | return 0; |
| 957 | |
| 958 | if (on) { |
| 959 | rc = gpio_request(HDMI_CEC_VAR_GPIO, "HDMI_CEC_VAR"); |
| 960 | if (rc) { |
| 961 | pr_err("'%s'(%d) gpio_request failed, rc=%d\n", |
| 962 | "HDMI_CEC_VAR", HDMI_CEC_VAR_GPIO, rc); |
| 963 | goto error; |
| 964 | } |
| 965 | pr_debug("%s(on): success\n", __func__); |
| 966 | } else { |
| 967 | gpio_free(HDMI_CEC_VAR_GPIO); |
| 968 | pr_debug("%s(off): success\n", __func__); |
| 969 | } |
| 970 | |
| 971 | prev_on = on; |
| 972 | |
| 973 | return 0; |
| 974 | error: |
| 975 | return rc; |
| 976 | } |
| 977 | |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 978 | void __init apq8064_init_fb(void) |
| 979 | { |
| 980 | platform_device_register(&msm_fb_device); |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 981 | platform_device_register(&lvds_chimei_panel_device); |
| 982 | |
Mohan Kumar Gubbihalli Lachma Naik | cb7d4e7 | 2012-03-23 18:17:30 -0700 | [diff] [blame] | 983 | #ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL |
| 984 | platform_device_register(&wfd_panel_device); |
| 985 | platform_device_register(&wfd_device); |
| 986 | #endif |
| 987 | |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 988 | if (machine_is_apq8064_liquid()) |
| 989 | platform_device_register(&mipi_dsi2lvds_bridge_device); |
| 990 | if (machine_is_apq8064_mtp()) |
| 991 | platform_device_register(&mipi_dsi_toshiba_panel_device); |
Zhang Chang Ken | 4a07fcb | 2012-06-03 11:24:51 -0400 | [diff] [blame] | 992 | if (machine_is_mpq8064_dtv()) |
| 993 | platform_device_register(&lvds_frc_panel_device); |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 994 | |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 995 | msm_fb_register_device("mdp", &mdp_pdata); |
Ravishangar Kalyanam | c2fee31 | 2012-02-09 19:11:22 -0800 | [diff] [blame] | 996 | msm_fb_register_device("lvds", &lvds_pdata); |
| 997 | msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata); |
Aravind Venkateswaran | 0507c8c | 2012-02-16 17:16:05 -0800 | [diff] [blame] | 998 | platform_device_register(&hdmi_msm_device); |
| 999 | msm_fb_register_device("dtv", &dtv_pdata); |
Huaibin Yang | 4a084e3 | 2011-12-15 15:25:52 -0800 | [diff] [blame] | 1000 | } |
Aravind Venkateswaran | 8ac7f41 | 2012-03-16 17:57:30 -0700 | [diff] [blame] | 1001 | |
| 1002 | /** |
| 1003 | * Set MDP clocks to high frequency to avoid DSI underflow |
| 1004 | * when using high resolution 1200x1920 WUXGA panels |
| 1005 | */ |
| 1006 | static void set_mdp_clocks_for_wuxga(void) |
| 1007 | { |
| 1008 | int i; |
| 1009 | |
| 1010 | mdp_ui_vectors[0].ab = 2000000000; |
| 1011 | mdp_ui_vectors[0].ib = 2000000000; |
| 1012 | mdp_vga_vectors[0].ab = 2000000000; |
| 1013 | mdp_vga_vectors[0].ib = 2000000000; |
| 1014 | mdp_720p_vectors[0].ab = 2000000000; |
| 1015 | mdp_720p_vectors[0].ib = 2000000000; |
| 1016 | mdp_1080p_vectors[0].ab = 2000000000; |
| 1017 | mdp_1080p_vectors[0].ib = 2000000000; |
| 1018 | |
| 1019 | mdp_pdata.mdp_core_clk_rate = 200000000; |
| 1020 | |
| 1021 | for (i = 0; i < ARRAY_SIZE(mdp_core_clk_rate_table); i++) |
| 1022 | mdp_core_clk_rate_table[i] = 200000000; |
| 1023 | |
Ravishangar Kalyanam | fda36c4 | 2012-03-26 16:28:19 -0700 | [diff] [blame] | 1024 | if (apq8064_hdmi_as_primary_selected()) { |
Aravind Venkateswaran | 8ac7f41 | 2012-03-16 17:57:30 -0700 | [diff] [blame] | 1025 | dtv_bus_def_vectors[0].ab = 2000000000; |
| 1026 | dtv_bus_def_vectors[0].ib = 2000000000; |
| 1027 | } |
| 1028 | } |
| 1029 | |
| 1030 | void __init apq8064_set_display_params(char *prim_panel, char *ext_panel) |
| 1031 | { |
Aravind Venkateswaran | d98bc43 | 2012-04-04 16:19:06 -0700 | [diff] [blame] | 1032 | /* |
| 1033 | * For certain MPQ boards, HDMI should be set as primary display |
| 1034 | * by default, with the flexibility to specify any other panel |
| 1035 | * as a primary panel through boot parameters. |
| 1036 | */ |
| 1037 | if (machine_is_mpq8064_hrd() || machine_is_mpq8064_cdp()) { |
| 1038 | pr_debug("HDMI is the primary display by default for MPQ\n"); |
| 1039 | if (!strnlen(prim_panel, PANEL_NAME_MAX_LEN)) |
| 1040 | strlcpy(msm_fb_pdata.prim_panel_name, HDMI_PANEL_NAME, |
| 1041 | PANEL_NAME_MAX_LEN); |
| 1042 | } |
| 1043 | |
Aravind Venkateswaran | 8ac7f41 | 2012-03-16 17:57:30 -0700 | [diff] [blame] | 1044 | if (strnlen(prim_panel, PANEL_NAME_MAX_LEN)) { |
| 1045 | strlcpy(msm_fb_pdata.prim_panel_name, prim_panel, |
| 1046 | PANEL_NAME_MAX_LEN); |
| 1047 | pr_debug("msm_fb_pdata.prim_panel_name %s\n", |
| 1048 | msm_fb_pdata.prim_panel_name); |
| 1049 | |
| 1050 | if (!strncmp((char *)msm_fb_pdata.prim_panel_name, |
| 1051 | HDMI_PANEL_NAME, strnlen(HDMI_PANEL_NAME, |
| 1052 | PANEL_NAME_MAX_LEN))) { |
| 1053 | pr_debug("HDMI is the primary display by" |
| 1054 | " boot parameter\n"); |
| 1055 | hdmi_is_primary = 1; |
| 1056 | set_mdp_clocks_for_wuxga(); |
| 1057 | } |
| 1058 | } |
| 1059 | if (strnlen(ext_panel, PANEL_NAME_MAX_LEN)) { |
| 1060 | strlcpy(msm_fb_pdata.ext_panel_name, ext_panel, |
| 1061 | PANEL_NAME_MAX_LEN); |
| 1062 | pr_debug("msm_fb_pdata.ext_panel_name %s\n", |
| 1063 | msm_fb_pdata.ext_panel_name); |
| 1064 | } |
| 1065 | } |