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