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