blob: 61547693ef718b5dfcf9916f5d1d30cf95f0eafb [file] [log] [blame]
Duy Truong790f06d2013-02-13 16:38:12 -08001/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
Stepan Moskovchenko39236d72011-11-30 17:42:23 -08002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 */
13
14#include <linux/init.h>
15#include <linux/ioport.h>
16#include <linux/platform_device.h>
17#include <linux/bootmem.h>
Steve Mucklef132c6c2012-06-06 18:30:57 -070018#include <linux/gpio.h>
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080019#include <asm/mach-types.h>
20#include <mach/msm_bus_board.h>
Huaibin Yanga5419422011-12-08 23:52:10 -080021#include <mach/msm_memtypes.h>
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080022#include <mach/board.h>
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080023#include <mach/gpiomux.h>
Ajay Dudani9114be72011-12-03 07:46:35 -080024#include <mach/socinfo.h>
Mitchel Humpherysd0b5da02012-09-06 11:33:09 -070025#include <linux/msm_ion.h>
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -080026#include <mach/ion.h>
27
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080028#include "devices.h"
Stepan Moskovchenko5a83dba2011-12-05 17:30:17 -080029#include "board-8930.h"
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080030
31#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +053032#define MSM_FB_PRIM_BUF_SIZE \
Huaibin Yangc8946d42012-05-04 17:22:02 -070033 (roundup((1920 * 1088 * 4), 4096) * 3) /* 4 bpp x 3 pages */
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080034#else
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +053035#define MSM_FB_PRIM_BUF_SIZE \
Huaibin Yangc8946d42012-05-04 17:22:02 -070036 (roundup((1920 * 1088 * 4), 4096) * 2) /* 4 bpp x 2 pages */
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080037#endif
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080038/* Note: must be multiple of 4096 */
Huaibin Yangc8946d42012-05-04 17:22:02 -070039#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE, 4096)
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080040
Huaibin Yanga5419422011-12-08 23:52:10 -080041#ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK
42#define MSM_FB_OVERLAY0_WRITEBACK_SIZE roundup((1376 * 768 * 3 * 2), 4096)
43#else
44#define MSM_FB_OVERLAY0_WRITEBACK_SIZE (0)
45#endif /* CONFIG_FB_MSM_OVERLAY0_WRITEBACK */
46
47#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
48#define MSM_FB_OVERLAY1_WRITEBACK_SIZE roundup((1920 * 1088 * 3 * 2), 4096)
49#else
50#define MSM_FB_OVERLAY1_WRITEBACK_SIZE (0)
51#endif /* CONFIG_FB_MSM_OVERLAY1_WRITEBACK */
52
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080053#define MDP_VSYNC_GPIO 0
54
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080055#define MIPI_CMD_NOVATEK_QHD_PANEL_NAME "mipi_cmd_novatek_qhd"
56#define MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME "mipi_video_novatek_qhd"
57#define MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME "mipi_video_toshiba_wsvga"
58#define MIPI_VIDEO_CHIMEI_WXGA_PANEL_NAME "mipi_video_chimei_wxga"
59#define MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME "mipi_video_simulator_vga"
60#define MIPI_CMD_RENESAS_FWVGA_PANEL_NAME "mipi_cmd_renesas_fwvga"
61#define HDMI_PANEL_NAME "hdmi_msm"
Aravind Venkateswaran06a46352012-08-16 14:52:39 -070062#define MHL_PANEL_NAME "hdmi_msm,mhl_8334"
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080063#define TVOUT_PANEL_NAME "tvout_msm"
64
Aravind Venkateswaran06a46352012-08-16 14:52:39 -070065static unsigned char mhl_display_enabled;
66
67unsigned char msm8930_mhl_display_enabled(void)
68{
69 return mhl_display_enabled;
70}
71
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080072static struct resource msm_fb_resources[] = {
73 {
74 .flags = IORESOURCE_DMA,
75 }
76};
77
78static int msm_fb_detect_panel(const char *name)
79{
Chandan Uddaraju59894ca2011-12-05 17:07:02 -080080 if (!strncmp(name, MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
81 strnlen(MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080082 PANEL_NAME_MAX_LEN)))
83 return 0;
84
Ravishangar Kalyanama4286d72012-02-15 16:09:58 -080085#if !defined(CONFIG_FB_MSM_LVDS_MIPI_PANEL_DETECT) && \
86 !defined(CONFIG_FB_MSM_MIPI_PANEL_DETECT)
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080087 if (!strncmp(name, MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
88 strnlen(MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
89 PANEL_NAME_MAX_LEN)))
90 return 0;
91
Chandan Uddaraju59894ca2011-12-05 17:07:02 -080092 if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME,
93 strnlen(MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080094 PANEL_NAME_MAX_LEN)))
95 return 0;
96
97 if (!strncmp(name, MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME,
98 strnlen(MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME,
99 PANEL_NAME_MAX_LEN)))
100 return 0;
101
102 if (!strncmp(name, MIPI_CMD_RENESAS_FWVGA_PANEL_NAME,
103 strnlen(MIPI_CMD_RENESAS_FWVGA_PANEL_NAME,
104 PANEL_NAME_MAX_LEN)))
105 return 0;
106#endif
107
108 if (!strncmp(name, HDMI_PANEL_NAME,
109 strnlen(HDMI_PANEL_NAME,
110 PANEL_NAME_MAX_LEN)))
111 return 0;
112
113 if (!strncmp(name, TVOUT_PANEL_NAME,
114 strnlen(TVOUT_PANEL_NAME,
115 PANEL_NAME_MAX_LEN)))
116 return 0;
117
118 pr_warning("%s: not supported '%s'", __func__, name);
119 return -ENODEV;
120}
121
122static struct msm_fb_platform_data msm_fb_pdata = {
123 .detect_client = msm_fb_detect_panel,
124};
125
126static struct platform_device msm_fb_device = {
127 .name = "msm_fb",
128 .id = 0,
129 .num_resources = ARRAY_SIZE(msm_fb_resources),
130 .resource = msm_fb_resources,
131 .dev.platform_data = &msm_fb_pdata,
132};
133
134static bool dsi_power_on;
Huaibin Yanga07d7872012-11-08 14:05:24 -0800135static struct mipi_dsi_panel_platform_data novatek_pdata;
136static void pm8917_gpio_set_backlight(int bl_level)
137{
138 int gpio24 = PM8917_GPIO_PM_TO_SYS(24);
139 if (bl_level > 0)
140 gpio_set_value_cansleep(gpio24, 1);
141 else
142 gpio_set_value_cansleep(gpio24, 0);
143}
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800144
Jay Chokshi06fa7542011-12-07 13:09:17 -0800145/*
146 * TODO: When physical 8930/PM8038 hardware becomes
147 * available, replace mipi_dsi_cdp_panel_power with
148 * appropriate function.
149 */
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800150#define DISP_RST_GPIO 58
Siddhartha Agrawalf5a8e382012-07-18 16:33:18 -0700151#define DISP_3D_2D_MODE 1
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800152static int mipi_dsi_cdp_panel_power(int on)
153{
154 static struct regulator *reg_l8, *reg_l23, *reg_l2;
David Collins9898ac32012-08-10 17:24:38 -0700155 /* Control backlight GPIO (24) directly when using PM8917 */
156 int gpio24 = PM8917_GPIO_PM_TO_SYS(24);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800157 int rc;
158
Jeff Ohlstein2cbe5ba2011-12-16 13:32:56 -0800159 pr_debug("%s: state : %d\n", __func__, on);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800160
161 if (!dsi_power_on) {
162
163 reg_l8 = regulator_get(&msm_mipi_dsi1_device.dev,
164 "dsi_vdc");
165 if (IS_ERR(reg_l8)) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800166 pr_err("could not get 8038_l8, rc = %ld\n",
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800167 PTR_ERR(reg_l8));
168 return -ENODEV;
169 }
170 reg_l23 = regulator_get(&msm_mipi_dsi1_device.dev,
171 "dsi_vddio");
172 if (IS_ERR(reg_l23)) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800173 pr_err("could not get 8038_l23, rc = %ld\n",
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800174 PTR_ERR(reg_l23));
175 return -ENODEV;
176 }
177 reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev,
178 "dsi_vdda");
179 if (IS_ERR(reg_l2)) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800180 pr_err("could not get 8038_l2, rc = %ld\n",
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800181 PTR_ERR(reg_l2));
182 return -ENODEV;
183 }
184 rc = regulator_set_voltage(reg_l8, 2800000, 3000000);
185 if (rc) {
186 pr_err("set_voltage l8 failed, rc=%d\n", rc);
187 return -EINVAL;
188 }
189 rc = regulator_set_voltage(reg_l23, 1800000, 1800000);
190 if (rc) {
191 pr_err("set_voltage l23 failed, rc=%d\n", rc);
192 return -EINVAL;
193 }
194 rc = regulator_set_voltage(reg_l2, 1200000, 1200000);
195 if (rc) {
196 pr_err("set_voltage l2 failed, rc=%d\n", rc);
197 return -EINVAL;
198 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800199 rc = gpio_request(DISP_RST_GPIO, "disp_rst_n");
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800200 if (rc) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800201 pr_err("request gpio DISP_RST_GPIO failed, rc=%d\n",
202 rc);
203 gpio_free(DISP_RST_GPIO);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800204 return -ENODEV;
205 }
Siddhartha Agrawalf5a8e382012-07-18 16:33:18 -0700206 rc = gpio_request(DISP_3D_2D_MODE, "disp_3d_2d");
207 if (rc) {
208 pr_err("request gpio DISP_3D_2D_MODE failed, rc=%d\n",
209 rc);
210 gpio_free(DISP_3D_2D_MODE);
211 return -ENODEV;
David Collins9898ac32012-08-10 17:24:38 -0700212 }
Siddhartha Agrawalf5a8e382012-07-18 16:33:18 -0700213 rc = gpio_direction_output(DISP_3D_2D_MODE, 0);
214 if (rc) {
215 pr_err("gpio_direction_output failed for %d gpio rc=%d\n",
216 DISP_3D_2D_MODE, rc);
217 return -ENODEV;
David Collins9898ac32012-08-10 17:24:38 -0700218 }
219 if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917) {
220 rc = gpio_request(gpio24, "disp_bl");
221 if (rc) {
222 pr_err("request for gpio 24 failed, rc=%d\n",
223 rc);
224 return -ENODEV;
Siddhartha Agrawalf5a8e382012-07-18 16:33:18 -0700225 }
Huaibin Yanga07d7872012-11-08 14:05:24 -0800226 gpio_set_value_cansleep(gpio24, 0);
227 novatek_pdata.gpio_set_backlight =
228 pm8917_gpio_set_backlight;
David Collins9898ac32012-08-10 17:24:38 -0700229 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800230 dsi_power_on = true;
231 }
Huaibin Yanga07d7872012-11-08 14:05:24 -0800232
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800233 if (on) {
234 rc = regulator_set_optimum_mode(reg_l8, 100000);
235 if (rc < 0) {
236 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
237 return -EINVAL;
238 }
239 rc = regulator_set_optimum_mode(reg_l23, 100000);
240 if (rc < 0) {
241 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
242 return -EINVAL;
243 }
244 rc = regulator_set_optimum_mode(reg_l2, 100000);
245 if (rc < 0) {
246 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
247 return -EINVAL;
248 }
249 rc = regulator_enable(reg_l8);
250 if (rc) {
251 pr_err("enable l8 failed, rc=%d\n", rc);
252 return -ENODEV;
253 }
254 rc = regulator_enable(reg_l23);
255 if (rc) {
256 pr_err("enable l8 failed, rc=%d\n", rc);
257 return -ENODEV;
258 }
259 rc = regulator_enable(reg_l2);
260 if (rc) {
261 pr_err("enable l2 failed, rc=%d\n", rc);
262 return -ENODEV;
263 }
Ravishangar Kalyanam87c5fb62012-01-28 21:24:58 -0800264 usleep(10000);
265 gpio_set_value(DISP_RST_GPIO, 1);
266 usleep(10);
267 gpio_set_value(DISP_RST_GPIO, 0);
268 usleep(20);
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800269 gpio_set_value(DISP_RST_GPIO, 1);
Siddhartha Agrawalf5a8e382012-07-18 16:33:18 -0700270 gpio_set_value(DISP_3D_2D_MODE, 1);
271 usleep(20);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800272 } else {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800273
274 gpio_set_value(DISP_RST_GPIO, 0);
275
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800276 rc = regulator_disable(reg_l2);
277 if (rc) {
278 pr_err("disable reg_l2 failed, rc=%d\n", rc);
279 return -ENODEV;
280 }
281 rc = regulator_disable(reg_l8);
282 if (rc) {
283 pr_err("disable reg_l8 failed, rc=%d\n", rc);
284 return -ENODEV;
285 }
286 rc = regulator_disable(reg_l23);
287 if (rc) {
288 pr_err("disable reg_l23 failed, rc=%d\n", rc);
289 return -ENODEV;
290 }
291 rc = regulator_set_optimum_mode(reg_l8, 100);
292 if (rc < 0) {
293 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
294 return -EINVAL;
295 }
296 rc = regulator_set_optimum_mode(reg_l23, 100);
297 if (rc < 0) {
298 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
299 return -EINVAL;
300 }
301 rc = regulator_set_optimum_mode(reg_l2, 100);
302 if (rc < 0) {
303 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
304 return -EINVAL;
305 }
Siddhartha Agrawalf5a8e382012-07-18 16:33:18 -0700306 gpio_set_value(DISP_3D_2D_MODE, 0);
307 usleep(20);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800308 }
309 return 0;
310}
311
312static int mipi_dsi_panel_power(int on)
313{
Jeff Ohlstein2cbe5ba2011-12-16 13:32:56 -0800314 pr_debug("%s: on=%d\n", __func__, on);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800315
316 return mipi_dsi_cdp_panel_power(on);
317}
318
319static struct mipi_dsi_platform_data mipi_dsi_pdata = {
320 .vsync_gpio = MDP_VSYNC_GPIO,
321 .dsi_power_save = mipi_dsi_panel_power,
322};
323
324#ifdef CONFIG_MSM_BUS_SCALING
325
326static struct msm_bus_vectors mdp_init_vectors[] = {
327 {
328 .src = MSM_BUS_MASTER_MDP_PORT0,
329 .dst = MSM_BUS_SLAVE_EBI_CH0,
330 .ab = 0,
331 .ib = 0,
332 },
333};
334
335#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
336static struct msm_bus_vectors hdmi_as_primary_vectors[] = {
337 /* If HDMI is used as primary */
338 {
339 .src = MSM_BUS_MASTER_MDP_PORT0,
340 .dst = MSM_BUS_SLAVE_EBI_CH0,
341 .ab = 2000000000,
342 .ib = 2000000000,
343 },
344};
345static struct msm_bus_paths mdp_bus_scale_usecases[] = {
346 {
347 ARRAY_SIZE(mdp_init_vectors),
348 mdp_init_vectors,
349 },
350 {
351 ARRAY_SIZE(hdmi_as_primary_vectors),
352 hdmi_as_primary_vectors,
353 },
354 {
355 ARRAY_SIZE(hdmi_as_primary_vectors),
356 hdmi_as_primary_vectors,
357 },
358 {
359 ARRAY_SIZE(hdmi_as_primary_vectors),
360 hdmi_as_primary_vectors,
361 },
362 {
363 ARRAY_SIZE(hdmi_as_primary_vectors),
364 hdmi_as_primary_vectors,
365 },
366 {
367 ARRAY_SIZE(hdmi_as_primary_vectors),
368 hdmi_as_primary_vectors,
369 },
370};
371#else
372static struct msm_bus_vectors mdp_ui_vectors[] = {
373 {
374 .src = MSM_BUS_MASTER_MDP_PORT0,
375 .dst = MSM_BUS_SLAVE_EBI_CH0,
376 .ab = 216000000 * 2,
377 .ib = 270000000 * 2,
378 },
379};
380
381static struct msm_bus_vectors mdp_vga_vectors[] = {
382 /* VGA and less video */
383 {
384 .src = MSM_BUS_MASTER_MDP_PORT0,
385 .dst = MSM_BUS_SLAVE_EBI_CH0,
386 .ab = 216000000 * 2,
387 .ib = 270000000 * 2,
388 },
389};
390
391static struct msm_bus_vectors mdp_720p_vectors[] = {
392 /* 720p and less video */
393 {
394 .src = MSM_BUS_MASTER_MDP_PORT0,
395 .dst = MSM_BUS_SLAVE_EBI_CH0,
396 .ab = 230400000 * 2,
397 .ib = 288000000 * 2,
398 },
399};
400
401static struct msm_bus_vectors mdp_1080p_vectors[] = {
402 /* 1080p and less video */
403 {
404 .src = MSM_BUS_MASTER_MDP_PORT0,
405 .dst = MSM_BUS_SLAVE_EBI_CH0,
406 .ab = 334080000 * 2,
407 .ib = 417600000 * 2,
408 },
409};
410
411static struct msm_bus_paths mdp_bus_scale_usecases[] = {
412 {
413 ARRAY_SIZE(mdp_init_vectors),
414 mdp_init_vectors,
415 },
416 {
417 ARRAY_SIZE(mdp_ui_vectors),
418 mdp_ui_vectors,
419 },
420 {
421 ARRAY_SIZE(mdp_ui_vectors),
422 mdp_ui_vectors,
423 },
424 {
425 ARRAY_SIZE(mdp_vga_vectors),
426 mdp_vga_vectors,
427 },
428 {
429 ARRAY_SIZE(mdp_720p_vectors),
430 mdp_720p_vectors,
431 },
432 {
433 ARRAY_SIZE(mdp_1080p_vectors),
434 mdp_1080p_vectors,
435 },
436};
437#endif
438
439static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
440 mdp_bus_scale_usecases,
441 ARRAY_SIZE(mdp_bus_scale_usecases),
442 .name = "mdp",
443};
444
445#endif
446
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800447static struct msm_panel_common_pdata mdp_pdata = {
448 .gpio = MDP_VSYNC_GPIO,
Siddhartha Agrawal496f9282012-08-15 17:41:34 -0700449 .mdp_max_clk = 200000000,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800450#ifdef CONFIG_MSM_BUS_SCALING
451 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
452#endif
Carl Vanderlip37bbc552012-11-16 11:34:44 -0800453 .mdp_rev = MDP_REV_43,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -0800454#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Ravishangar Kalyanama3b168b2012-03-26 11:13:11 -0700455 .mem_hid = BIT(ION_CP_MM_HEAP_ID),
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -0800456#else
457 .mem_hid = MEMTYPE_EBI1,
458#endif
Olav Hauganef95ae32012-05-15 09:50:30 -0700459 .mdp_iommu_split_domain = 0,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800460};
461
Huaibin Yanga5419422011-12-08 23:52:10 -0800462void __init msm8930_mdp_writeback(struct memtype_reserve* reserve_table)
463{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -0800464 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
465 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
466#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
467 reserve_table[mdp_pdata.mem_hid].size +=
468 mdp_pdata.ov0_wb_size;
469 reserve_table[mdp_pdata.mem_hid].size +=
470 mdp_pdata.ov1_wb_size;
471#endif
Huaibin Yanga5419422011-12-08 23:52:10 -0800472}
473
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800474#define LPM_CHANNEL0 0
475static int toshiba_gpio[] = {LPM_CHANNEL0};
476
477static struct mipi_dsi_panel_platform_data toshiba_pdata = {
478 .gpio = toshiba_gpio,
479};
480
481static struct platform_device mipi_dsi_toshiba_panel_device = {
482 .name = "mipi_toshiba",
483 .id = 0,
484 .dev = {
485 .platform_data = &toshiba_pdata,
486 }
487};
488
489#define FPGA_3D_GPIO_CONFIG_ADDR 0xB5
490
491static struct mipi_dsi_phy_ctrl dsi_novatek_cmd_mode_phy_db = {
492
493/* DSI_BIT_CLK at 500MHz, 2 lane, RGB888 */
Chandan Uddaraju58d759e2012-07-16 16:20:30 -0700494 {0x09, 0x08, 0x05, 0x00, 0x20}, /* regulator */
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800495 /* timing */
496 {0xab, 0x8a, 0x18, 0x00, 0x92, 0x97, 0x1b, 0x8c,
497 0x0c, 0x03, 0x04, 0xa0},
498 {0x5f, 0x00, 0x00, 0x10}, /* phy ctrl */
499 {0xff, 0x00, 0x06, 0x00}, /* strength */
500 /* pll control */
Chandan Uddaraju58d759e2012-07-16 16:20:30 -0700501 {0x0, 0xe, 0x30, 0xda, 0x00, 0x10, 0x0f, 0x61,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800502 0x40, 0x07, 0x03,
Chandan Uddaraju58d759e2012-07-16 16:20:30 -0700503 0x00, 0x1a, 0x00, 0x00, 0x02, 0x00, 0x20, 0x00, 0x02},
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800504};
505
506static struct mipi_dsi_panel_platform_data novatek_pdata = {
507 .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR,
508 .fpga_ctrl_mode = FPGA_SPI_INTF,
509 .phy_ctrl_settings = &dsi_novatek_cmd_mode_phy_db,
Ravishangar Kalyanam903f65c2012-01-28 21:36:22 -0800510 .dlane_swap = 0x1,
Chandan Uddaraju194a4b52012-03-21 10:11:18 -0700511 .enable_wled_bl_ctrl = 0x1,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800512};
513
514static struct platform_device mipi_dsi_novatek_panel_device = {
515 .name = "mipi_novatek",
516 .id = 0,
517 .dev = {
518 .platform_data = &novatek_pdata,
519 }
520};
521
522#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
523static struct resource hdmi_msm_resources[] = {
524 {
525 .name = "hdmi_msm_qfprom_addr",
526 .start = 0x00700000,
527 .end = 0x007060FF,
528 .flags = IORESOURCE_MEM,
529 },
530 {
531 .name = "hdmi_msm_hdmi_addr",
532 .start = 0x04A00000,
533 .end = 0x04A00FFF,
534 .flags = IORESOURCE_MEM,
535 },
536 {
537 .name = "hdmi_msm_irq",
538 .start = HDMI_IRQ,
539 .end = HDMI_IRQ,
540 .flags = IORESOURCE_IRQ,
541 },
542};
543
544static int hdmi_enable_5v(int on);
545static int hdmi_core_power(int on, int show);
546static int hdmi_cec_power(int on);
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +0530547static int hdmi_gpio_config(int on);
548static int hdmi_panel_power(int on);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800549
550static struct msm_hdmi_platform_data hdmi_msm_data = {
551 .irq = HDMI_IRQ,
552 .enable_5v = hdmi_enable_5v,
553 .core_power = hdmi_core_power,
554 .cec_power = hdmi_cec_power,
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +0530555 .panel_power = hdmi_panel_power,
556 .gpio_config = hdmi_gpio_config,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800557};
558
559static struct platform_device hdmi_msm_device = {
560 .name = "hdmi_msm",
561 .id = 0,
562 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
563 .resource = hdmi_msm_resources,
564 .dev.platform_data = &hdmi_msm_data,
565};
566#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
567
568#ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL
569static struct platform_device wfd_panel_device = {
570 .name = "wfd_panel",
571 .id = 0,
572 .dev.platform_data = NULL,
573};
574
575static struct platform_device wfd_device = {
576 .name = "msm_wfd",
577 .id = -1,
578};
579#endif
580
581#ifdef CONFIG_MSM_BUS_SCALING
582static struct msm_bus_vectors dtv_bus_init_vectors[] = {
583 {
584 .src = MSM_BUS_MASTER_MDP_PORT0,
585 .dst = MSM_BUS_SLAVE_EBI_CH0,
586 .ab = 0,
587 .ib = 0,
588 },
589};
590
591#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
592static struct msm_bus_vectors dtv_bus_def_vectors[] = {
593 {
594 .src = MSM_BUS_MASTER_MDP_PORT0,
595 .dst = MSM_BUS_SLAVE_EBI_CH0,
596 .ab = 2000000000,
597 .ib = 2000000000,
598 },
599};
600#else
601static struct msm_bus_vectors dtv_bus_def_vectors[] = {
602 {
603 .src = MSM_BUS_MASTER_MDP_PORT0,
604 .dst = MSM_BUS_SLAVE_EBI_CH0,
605 .ab = 566092800 * 2,
606 .ib = 707616000 * 2,
607 },
608};
609#endif
610
611static struct msm_bus_paths dtv_bus_scale_usecases[] = {
612 {
613 ARRAY_SIZE(dtv_bus_init_vectors),
614 dtv_bus_init_vectors,
615 },
616 {
617 ARRAY_SIZE(dtv_bus_def_vectors),
618 dtv_bus_def_vectors,
619 },
620};
621static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
622 dtv_bus_scale_usecases,
623 ARRAY_SIZE(dtv_bus_scale_usecases),
624 .name = "dtv",
625};
626
627static struct lcdc_platform_data dtv_pdata = {
628 .bus_scale_table = &dtv_bus_scale_pdata,
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +0530629 .lcdc_power_save = hdmi_panel_power,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800630};
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +0530631
632static int hdmi_panel_power(int on)
633{
634 int rc;
635
636 pr_debug("%s: HDMI Core: %s\n", __func__, (on ? "ON" : "OFF"));
637 rc = hdmi_core_power(on, 1);
638 if (rc)
639 rc = hdmi_cec_power(on);
640
641 pr_debug("%s: HDMI Core: %s Success\n", __func__, (on ? "ON" : "OFF"));
642 return rc;
643}
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800644#endif
645
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800646#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800647static int hdmi_enable_5v(int on)
648{
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800649 static struct regulator *reg_ext_5v; /* HDMI_5V */
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800650 static int prev_on;
651 int rc;
652
653 if (on == prev_on)
654 return 0;
655
Ajay Singh Parmar07847642011-12-09 02:57:45 +0530656 if (!reg_ext_5v) {
657 reg_ext_5v = regulator_get(&hdmi_msm_device.dev, "hdmi_mvs");
658 if (IS_ERR(reg_ext_5v)) {
659 pr_err("'%s' regulator not found, rc=%ld\n",
660 "hdmi_mvs", IS_ERR(reg_ext_5v));
661 reg_ext_5v = NULL;
662 return -ENODEV;
663 }
664 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800665
666 if (on) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800667 rc = regulator_enable(reg_ext_5v);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800668 if (rc) {
669 pr_err("'%s' regulator enable failed, rc=%d\n",
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800670 "reg_ext_5v", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800671 return rc;
672 }
673 pr_debug("%s(on): success\n", __func__);
674 } else {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800675 rc = regulator_disable(reg_ext_5v);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800676 if (rc)
677 pr_warning("'%s' regulator disable failed, rc=%d\n",
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800678 "reg_ext_5v", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800679 pr_debug("%s(off): success\n", __func__);
680 }
681
682 prev_on = on;
683
684 return 0;
685}
686
687static int hdmi_core_power(int on, int show)
688{
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800689 /* Both HDMI "avdd" and "vcc" are powered by 8038_l23 regulator */
690 static struct regulator *reg_8038_l23;
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800691 static int prev_on;
692 int rc;
693
694 if (on == prev_on)
695 return 0;
696
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800697 if (!reg_8038_l23) {
698 reg_8038_l23 = regulator_get(&hdmi_msm_device.dev, "hdmi_avdd");
699 if (IS_ERR(reg_8038_l23)) {
700 pr_err("could not get reg_8038_l23, rc = %ld\n",
701 PTR_ERR(reg_8038_l23));
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800702 return -ENODEV;
703 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800704 rc = regulator_set_voltage(reg_8038_l23, 1800000, 1800000);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800705 if (rc) {
706 pr_err("set_voltage failed for 8921_l23, rc=%d\n", rc);
707 return -EINVAL;
708 }
709 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800710
711 if (on) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800712 rc = regulator_set_optimum_mode(reg_8038_l23, 100000);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800713 if (rc < 0) {
714 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
715 return -EINVAL;
716 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800717 rc = regulator_enable(reg_8038_l23);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800718 if (rc) {
719 pr_err("'%s' regulator enable failed, rc=%d\n",
720 "hdmi_avdd", rc);
721 return rc;
722 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800723 pr_debug("%s(on): success\n", __func__);
724 } else {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800725 rc = regulator_disable(reg_8038_l23);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800726 if (rc) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800727 pr_err("disable reg_8038_l23 failed, rc=%d\n", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800728 return -ENODEV;
729 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800730 rc = regulator_set_optimum_mode(reg_8038_l23, 100);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800731 if (rc < 0) {
732 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
733 return -EINVAL;
734 }
735 pr_debug("%s(off): success\n", __func__);
736 }
737
738 prev_on = on;
739
740 return 0;
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +0530741}
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800742
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +0530743static int hdmi_gpio_config(int on)
744{
745 int rc = 0;
746 static int prev_on;
747
748 if (on == prev_on)
749 return 0;
750
751 if (on) {
Manoj Rao908ad742012-08-08 15:03:39 -0700752 if (!(hdmi_msm_data.is_mhl_enabled)) {
753 rc = gpio_request(HDMI_MHL_MUX_GPIO, "MHL_HDMI_MUX");
754 if (rc < 0) {
755 pr_err("gpio hdmi_mhl mux req failed:%d\n",
756 rc);
757 return rc;
758 }
759 rc = gpio_direction_output(HDMI_MHL_MUX_GPIO, 1);
760 if (rc < 0) {
761 pr_err("set gpio hdmi_mhl dir failed:%d\n",
762 rc);
763 goto error0;
764 }
765 gpio_set_value(HDMI_MHL_MUX_GPIO, 1);
766 pr_debug("set gpio hdmi mhl mux %d to 1\n",
767 HDMI_MHL_MUX_GPIO);
768 }
769
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +0530770 rc = gpio_request(100, "HDMI_DDC_CLK");
771 if (rc) {
772 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
773 "HDMI_DDC_CLK", 100, rc);
Manoj Rao908ad742012-08-08 15:03:39 -0700774 goto error0;
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +0530775 }
776 rc = gpio_request(101, "HDMI_DDC_DATA");
777 if (rc) {
778 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
779 "HDMI_DDC_DATA", 101, rc);
780 goto error1;
781 }
782 rc = gpio_request(102, "HDMI_HPD");
783 if (rc) {
784 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
785 "HDMI_HPD", 102, rc);
786 goto error2;
787 }
788 pr_debug("%s(on): success\n", __func__);
789 } else {
Manoj Rao908ad742012-08-08 15:03:39 -0700790 if (!(hdmi_msm_data.is_mhl_enabled))
791 gpio_free(HDMI_MHL_MUX_GPIO);
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +0530792 gpio_free(100);
793 gpio_free(101);
794 gpio_free(102);
795 pr_debug("%s(off): success\n", __func__);
796 }
797
798 prev_on = on;
799 return 0;
800
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800801error2:
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +0530802 gpio_free(101);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800803error1:
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +0530804 gpio_free(100);
Manoj Rao908ad742012-08-08 15:03:39 -0700805error0:
806 if (!(hdmi_msm_data.is_mhl_enabled))
807 gpio_free(HDMI_MHL_MUX_GPIO);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800808 return rc;
809}
810
811static int hdmi_cec_power(int on)
812{
813 static int prev_on;
814 int rc;
815
816 if (on == prev_on)
817 return 0;
818
819 if (on) {
820 rc = gpio_request(99, "HDMI_CEC_VAR");
821 if (rc) {
822 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
823 "HDMI_CEC_VAR", 99, rc);
824 goto error;
825 }
826 pr_debug("%s(on): success\n", __func__);
827 } else {
828 gpio_free(99);
829 pr_debug("%s(off): success\n", __func__);
830 }
831
832 prev_on = on;
833
834 return 0;
835error:
836 return rc;
837}
838#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
839
840void __init msm8930_init_fb(void)
841{
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800842 platform_device_register(&msm_fb_device);
843
844#ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL
845 platform_device_register(&wfd_panel_device);
846 platform_device_register(&wfd_device);
847#endif
848
849 platform_device_register(&mipi_dsi_novatek_panel_device);
850
851#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Aravind Venkateswaranfff132d2012-03-07 13:22:30 -0800852 platform_device_register(&hdmi_msm_device);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800853#endif
854
855 platform_device_register(&mipi_dsi_toshiba_panel_device);
856
857 msm_fb_register_device("mdp", &mdp_pdata);
858 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
859#ifdef CONFIG_MSM_BUS_SCALING
860 msm_fb_register_device("dtv", &dtv_pdata);
861#endif
862}
863
864void __init msm8930_allocate_fb_region(void)
865{
866 void *addr;
867 unsigned long size;
868
869 size = MSM_FB_SIZE;
870 addr = alloc_bootmem_align(size, 0x1000);
871 msm_fb_resources[0].start = __pa(addr);
872 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
873 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
874 size, addr, __pa(addr));
875}
Aravind Venkateswaran06a46352012-08-16 14:52:39 -0700876
877void __init msm8930_set_display_params(char *prim_panel, char *ext_panel)
878{
879 if (strnlen(prim_panel, PANEL_NAME_MAX_LEN)) {
880 strlcpy(msm_fb_pdata.prim_panel_name, prim_panel,
881 PANEL_NAME_MAX_LEN);
882 pr_debug("msm_fb_pdata.prim_panel_name %s\n",
883 msm_fb_pdata.prim_panel_name);
884 }
885 if (strnlen(ext_panel, PANEL_NAME_MAX_LEN)) {
886 strlcpy(msm_fb_pdata.ext_panel_name, ext_panel,
887 PANEL_NAME_MAX_LEN);
888 pr_debug("msm_fb_pdata.ext_panel_name %s\n",
889 msm_fb_pdata.ext_panel_name);
890
891 if (!strncmp((char *)msm_fb_pdata.ext_panel_name,
892 MHL_PANEL_NAME, strnlen(MHL_PANEL_NAME,
893 PANEL_NAME_MAX_LEN))) {
894 pr_debug("MHL is external display by boot parameter\n");
895 mhl_display_enabled = 1;
896 }
897 }
898
899 hdmi_msm_data.is_mhl_enabled = mhl_display_enabled;
900}