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