blob: aa8477e0a521efe16669516fb9c8c046841c186d [file] [log] [blame]
Nagamalleswararao Ganji70fac1e2011-12-29 19:06:37 -08001/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -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>
Huaibin Yang4a084e32011-12-15 15:25:52 -080018#include <linux/ion.h>
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -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 Moskovchenko24cd8642011-11-29 13:07:53 -080022#include <mach/board.h>
23#include <mach/gpio.h>
24#include <mach/gpiomux.h>
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -080025#include <mach/ion.h>
Amir Samuelov6f1e5002012-02-01 17:42:43 +020026#include <mach/socinfo.h>
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -080027
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080028#include "devices.h"
Stepan Moskovchenko5a83dba2011-12-05 17:30:17 -080029#include "board-8960.h"
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080030
31#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
Amir Samuelovd7621032011-12-25 12:24:04 +020032#define MSM_FB_PRIM_BUF_SIZE (1920 * 1200 * 4 * 3) /* 4 bpp x 3 pages */
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080033#else
Amir Samuelovd7621032011-12-25 12:24:04 +020034#define MSM_FB_PRIM_BUF_SIZE (1920 * 1200 * 4 * 2) /* 4 bpp x 2 pages */
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080035#endif
36
37#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
38#define MSM_FB_EXT_BUF_SIZE (1920 * 1088 * 2 * 1) /* 2 bpp x 1 page */
39#elif defined(CONFIG_FB_MSM_TVOUT)
40#define MSM_FB_EXT_BUF_SIZE (720 * 576 * 2 * 2) /* 2 bpp x 2 pages */
41#else
42#define MSM_FB_EXT_BUF_SIZE 0
43#endif
44
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080045#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
46/* 4 bpp x 2 page HDMI case */
47#define MSM_FB_SIZE roundup((1920 * 1088 * 4 * 2), 4096)
48#else
49/* Note: must be multiple of 4096 */
Huaibin Yang27634b82011-12-09 00:16:25 -080050#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE, 4096)
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080051#endif
52
Huaibin Yanga5419422011-12-08 23:52:10 -080053#ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK
Amir Samuelovd7621032011-12-25 12:24:04 +020054#define MSM_FB_OVERLAY0_WRITEBACK_SIZE roundup((1920 * 1200 * 3 * 2), 4096)
Huaibin Yanga5419422011-12-08 23:52:10 -080055#else
56#define MSM_FB_OVERLAY0_WRITEBACK_SIZE (0)
57#endif /* CONFIG_FB_MSM_OVERLAY0_WRITEBACK */
58
59#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
60#define MSM_FB_OVERLAY1_WRITEBACK_SIZE roundup((1920 * 1088 * 3 * 2), 4096)
61#else
62#define MSM_FB_OVERLAY1_WRITEBACK_SIZE (0)
63#endif /* CONFIG_FB_MSM_OVERLAY1_WRITEBACK */
64
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080065#define MDP_VSYNC_GPIO 0
66
67#define PANEL_NAME_MAX_LEN 30
68#define MIPI_CMD_NOVATEK_QHD_PANEL_NAME "mipi_cmd_novatek_qhd"
69#define MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME "mipi_video_novatek_qhd"
70#define MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME "mipi_video_toshiba_wsvga"
71#define MIPI_VIDEO_CHIMEI_WXGA_PANEL_NAME "mipi_video_chimei_wxga"
Amir Samuelov6f1e5002012-02-01 17:42:43 +020072#define MIPI_VIDEO_CHIMEI_WUXGA_PANEL_NAME "mipi_video_chimei_wuxga"
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080073#define MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME "mipi_video_simulator_vga"
74#define MIPI_CMD_RENESAS_FWVGA_PANEL_NAME "mipi_cmd_renesas_fwvga"
75#define HDMI_PANEL_NAME "hdmi_msm"
76#define TVOUT_PANEL_NAME "tvout_msm"
77
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080078static struct resource msm_fb_resources[] = {
79 {
80 .flags = IORESOURCE_DMA,
81 }
82};
83
Amir Samuelovf0d1f542012-02-06 12:50:42 +020084static void set_mdp_clocks_for_liquid_wuxga(void);
85
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080086static int msm_fb_detect_panel(const char *name)
87{
88 if (machine_is_msm8960_liquid()) {
Amir Samuelov6f1e5002012-02-01 17:42:43 +020089 u32 ver = socinfo_get_platform_version();
90 if (SOCINFO_VERSION_MAJOR(ver) == 3) {
91 if (!strncmp(name, MIPI_VIDEO_CHIMEI_WUXGA_PANEL_NAME,
92 strnlen(MIPI_VIDEO_CHIMEI_WUXGA_PANEL_NAME,
Amir Samuelovf0d1f542012-02-06 12:50:42 +020093 PANEL_NAME_MAX_LEN))) {
94 set_mdp_clocks_for_liquid_wuxga();
Amir Samuelov6f1e5002012-02-01 17:42:43 +020095 return 0;
Amir Samuelovf0d1f542012-02-06 12:50:42 +020096 }
Amir Samuelov6f1e5002012-02-01 17:42:43 +020097 } else {
98 if (!strncmp(name, MIPI_VIDEO_CHIMEI_WXGA_PANEL_NAME,
99 strnlen(MIPI_VIDEO_CHIMEI_WXGA_PANEL_NAME,
100 PANEL_NAME_MAX_LEN)))
101 return 0;
102 }
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800103 } else {
104 if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME,
105 strnlen(MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME,
106 PANEL_NAME_MAX_LEN)))
107 return 0;
108
109#ifndef CONFIG_FB_MSM_MIPI_PANEL_DETECT
110 if (!strncmp(name, MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
111 strnlen(MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
112 PANEL_NAME_MAX_LEN)))
113 return 0;
114
115 if (!strncmp(name, MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
116 strnlen(MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
117 PANEL_NAME_MAX_LEN)))
118 return 0;
119
120 if (!strncmp(name, MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME,
121 strnlen(MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME,
122 PANEL_NAME_MAX_LEN)))
123 return 0;
124
125 if (!strncmp(name, MIPI_CMD_RENESAS_FWVGA_PANEL_NAME,
126 strnlen(MIPI_CMD_RENESAS_FWVGA_PANEL_NAME,
127 PANEL_NAME_MAX_LEN)))
128 return 0;
129#endif
130 }
131
132 if (!strncmp(name, HDMI_PANEL_NAME,
133 strnlen(HDMI_PANEL_NAME,
134 PANEL_NAME_MAX_LEN)))
135 return 0;
136
137 if (!strncmp(name, TVOUT_PANEL_NAME,
138 strnlen(TVOUT_PANEL_NAME,
139 PANEL_NAME_MAX_LEN)))
140 return 0;
141
142 pr_warning("%s: not supported '%s'", __func__, name);
143 return -ENODEV;
144}
145
146static struct msm_fb_platform_data msm_fb_pdata = {
147 .detect_client = msm_fb_detect_panel,
148};
149
150static struct platform_device msm_fb_device = {
151 .name = "msm_fb",
152 .id = 0,
153 .num_resources = ARRAY_SIZE(msm_fb_resources),
154 .resource = msm_fb_resources,
155 .dev.platform_data = &msm_fb_pdata,
156};
157
158static bool dsi_power_on;
159
160/**
161 * LiQUID panel on/off
162 *
163 * @param on
164 *
165 * @return int
166 */
167static int mipi_dsi_liquid_panel_power(int on)
168{
169 static struct regulator *reg_l2, *reg_ext_3p3v;
170 static int gpio21, gpio24, gpio43;
171 int rc;
172
Jeff Ohlstein2cbe5ba2011-12-16 13:32:56 -0800173 pr_debug("%s: on=%d\n", __func__, on);
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800174
175 gpio21 = PM8921_GPIO_PM_TO_SYS(21); /* disp power enable_n */
176 gpio43 = PM8921_GPIO_PM_TO_SYS(43); /* Displays Enable (rst_n)*/
177 gpio24 = PM8921_GPIO_PM_TO_SYS(24); /* Backlight PWM */
178
179 if (!dsi_power_on) {
180
181 reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev,
182 "dsi_vdda");
183 if (IS_ERR(reg_l2)) {
184 pr_err("could not get 8921_l2, rc = %ld\n",
185 PTR_ERR(reg_l2));
186 return -ENODEV;
187 }
188
189 rc = regulator_set_voltage(reg_l2, 1200000, 1200000);
190 if (rc) {
191 pr_err("set_voltage l2 failed, rc=%d\n", rc);
192 return -EINVAL;
193 }
194
195 reg_ext_3p3v = regulator_get(&msm_mipi_dsi1_device.dev,
196 "vdd_lvds_3p3v");
197 if (IS_ERR(reg_ext_3p3v)) {
198 pr_err("could not get reg_ext_3p3v, rc = %ld\n",
199 PTR_ERR(reg_ext_3p3v));
200 return -ENODEV;
201 }
202
203 rc = gpio_request(gpio21, "disp_pwr_en_n");
204 if (rc) {
205 pr_err("request gpio 21 failed, rc=%d\n", rc);
206 return -ENODEV;
207 }
208
209 rc = gpio_request(gpio43, "disp_rst_n");
210 if (rc) {
211 pr_err("request gpio 43 failed, rc=%d\n", rc);
212 return -ENODEV;
213 }
214
215 rc = gpio_request(gpio24, "disp_backlight_pwm");
216 if (rc) {
217 pr_err("request gpio 24 failed, rc=%d\n", rc);
218 return -ENODEV;
219 }
220
221 dsi_power_on = true;
222 }
223
224 if (on) {
225 rc = regulator_set_optimum_mode(reg_l2, 100000);
226 if (rc < 0) {
227 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
228 return -EINVAL;
229 }
230 rc = regulator_enable(reg_l2);
231 if (rc) {
232 pr_err("enable l2 failed, rc=%d\n", rc);
233 return -ENODEV;
234 }
235
236 rc = regulator_enable(reg_ext_3p3v);
237 if (rc) {
238 pr_err("enable reg_ext_3p3v failed, rc=%d\n", rc);
239 return -ENODEV;
240 }
241
242 /* set reset pin before power enable */
243 gpio_set_value_cansleep(gpio43, 0); /* disp disable (resx=0) */
244
245 gpio_set_value_cansleep(gpio21, 0); /* disp power enable_n */
246 msleep(20);
247 gpio_set_value_cansleep(gpio43, 1); /* disp enable */
248 msleep(20);
249 gpio_set_value_cansleep(gpio43, 0); /* disp enable */
250 msleep(20);
251 gpio_set_value_cansleep(gpio43, 1); /* disp enable */
252 msleep(20);
253 } else {
254 gpio_set_value_cansleep(gpio43, 0);
255 gpio_set_value_cansleep(gpio21, 1);
256
257 rc = regulator_disable(reg_l2);
258 if (rc) {
259 pr_err("disable reg_l2 failed, rc=%d\n", rc);
260 return -ENODEV;
261 }
262 rc = regulator_disable(reg_ext_3p3v);
263 if (rc) {
264 pr_err("disable reg_ext_3p3v failed, rc=%d\n", rc);
265 return -ENODEV;
266 }
267 rc = regulator_set_optimum_mode(reg_l2, 100);
268 if (rc < 0) {
269 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
270 return -EINVAL;
271 }
272 }
273
274 return 0;
275}
276
277static int mipi_dsi_cdp_panel_power(int on)
278{
279 static struct regulator *reg_l8, *reg_l23, *reg_l2;
280 static int gpio43;
281 int rc;
282
Jeff Ohlstein2cbe5ba2011-12-16 13:32:56 -0800283 pr_debug("%s: state : %d\n", __func__, on);
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800284
285 if (!dsi_power_on) {
286
287 reg_l8 = regulator_get(&msm_mipi_dsi1_device.dev,
288 "dsi_vdc");
289 if (IS_ERR(reg_l8)) {
290 pr_err("could not get 8921_l8, rc = %ld\n",
291 PTR_ERR(reg_l8));
292 return -ENODEV;
293 }
294 reg_l23 = regulator_get(&msm_mipi_dsi1_device.dev,
295 "dsi_vddio");
296 if (IS_ERR(reg_l23)) {
297 pr_err("could not get 8921_l23, rc = %ld\n",
298 PTR_ERR(reg_l23));
299 return -ENODEV;
300 }
301 reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev,
302 "dsi_vdda");
303 if (IS_ERR(reg_l2)) {
304 pr_err("could not get 8921_l2, rc = %ld\n",
305 PTR_ERR(reg_l2));
306 return -ENODEV;
307 }
308 rc = regulator_set_voltage(reg_l8, 2800000, 3000000);
309 if (rc) {
310 pr_err("set_voltage l8 failed, rc=%d\n", rc);
311 return -EINVAL;
312 }
313 rc = regulator_set_voltage(reg_l23, 1800000, 1800000);
314 if (rc) {
315 pr_err("set_voltage l23 failed, rc=%d\n", rc);
316 return -EINVAL;
317 }
318 rc = regulator_set_voltage(reg_l2, 1200000, 1200000);
319 if (rc) {
320 pr_err("set_voltage l2 failed, rc=%d\n", rc);
321 return -EINVAL;
322 }
323 gpio43 = PM8921_GPIO_PM_TO_SYS(43);
324 rc = gpio_request(gpio43, "disp_rst_n");
325 if (rc) {
326 pr_err("request gpio 43 failed, rc=%d\n", rc);
327 return -ENODEV;
328 }
329 dsi_power_on = true;
330 }
331 if (on) {
332 rc = regulator_set_optimum_mode(reg_l8, 100000);
333 if (rc < 0) {
334 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
335 return -EINVAL;
336 }
337 rc = regulator_set_optimum_mode(reg_l23, 100000);
338 if (rc < 0) {
339 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
340 return -EINVAL;
341 }
342 rc = regulator_set_optimum_mode(reg_l2, 100000);
343 if (rc < 0) {
344 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
345 return -EINVAL;
346 }
347 rc = regulator_enable(reg_l8);
348 if (rc) {
349 pr_err("enable l8 failed, rc=%d\n", rc);
350 return -ENODEV;
351 }
352 rc = regulator_enable(reg_l23);
353 if (rc) {
354 pr_err("enable l8 failed, rc=%d\n", rc);
355 return -ENODEV;
356 }
357 rc = regulator_enable(reg_l2);
358 if (rc) {
359 pr_err("enable l2 failed, rc=%d\n", rc);
360 return -ENODEV;
361 }
362 gpio_set_value_cansleep(gpio43, 1);
363 } else {
364 rc = regulator_disable(reg_l2);
365 if (rc) {
366 pr_err("disable reg_l2 failed, rc=%d\n", rc);
367 return -ENODEV;
368 }
369 rc = regulator_disable(reg_l8);
370 if (rc) {
371 pr_err("disable reg_l8 failed, rc=%d\n", rc);
372 return -ENODEV;
373 }
374 rc = regulator_disable(reg_l23);
375 if (rc) {
376 pr_err("disable reg_l23 failed, rc=%d\n", rc);
377 return -ENODEV;
378 }
379 rc = regulator_set_optimum_mode(reg_l8, 100);
380 if (rc < 0) {
381 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
382 return -EINVAL;
383 }
384 rc = regulator_set_optimum_mode(reg_l23, 100);
385 if (rc < 0) {
386 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
387 return -EINVAL;
388 }
389 rc = regulator_set_optimum_mode(reg_l2, 100);
390 if (rc < 0) {
391 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
392 return -EINVAL;
393 }
394 gpio_set_value_cansleep(gpio43, 0);
395 }
396 return 0;
397}
398
399static int mipi_dsi_panel_power(int on)
400{
401 int ret;
402
Jeff Ohlstein2cbe5ba2011-12-16 13:32:56 -0800403 pr_debug("%s: on=%d\n", __func__, on);
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800404
405 if (machine_is_msm8960_liquid())
406 ret = mipi_dsi_liquid_panel_power(on);
407 else
408 ret = mipi_dsi_cdp_panel_power(on);
409
410 return ret;
411}
412
413static struct mipi_dsi_platform_data mipi_dsi_pdata = {
414 .vsync_gpio = MDP_VSYNC_GPIO,
415 .dsi_power_save = mipi_dsi_panel_power,
416};
417
418#ifdef CONFIG_MSM_BUS_SCALING
419
Nagamalleswararao Ganji5fabbd62011-11-06 23:10:43 -0800420static struct msm_bus_vectors rotator_init_vectors[] = {
421 {
422 .src = MSM_BUS_MASTER_ROTATOR,
423 .dst = MSM_BUS_SLAVE_EBI_CH0,
424 .ab = 0,
425 .ib = 0,
426 },
427};
428
429static struct msm_bus_vectors rotator_ui_vectors[] = {
430 {
431 .src = MSM_BUS_MASTER_ROTATOR,
432 .dst = MSM_BUS_SLAVE_EBI_CH0,
433 .ab = (1024 * 600 * 4 * 2 * 60),
434 .ib = (1024 * 600 * 4 * 2 * 60 * 1.5),
435 },
436};
437
438static struct msm_bus_vectors rotator_vga_vectors[] = {
439 {
440 .src = MSM_BUS_MASTER_ROTATOR,
441 .dst = MSM_BUS_SLAVE_EBI_CH0,
442 .ab = (640 * 480 * 2 * 2 * 30),
443 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
444 },
445};
446static struct msm_bus_vectors rotator_720p_vectors[] = {
447 {
448 .src = MSM_BUS_MASTER_ROTATOR,
449 .dst = MSM_BUS_SLAVE_EBI_CH0,
450 .ab = (1280 * 736 * 2 * 2 * 30),
451 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
452 },
453};
454
455static struct msm_bus_vectors rotator_1080p_vectors[] = {
456 {
457 .src = MSM_BUS_MASTER_ROTATOR,
458 .dst = MSM_BUS_SLAVE_EBI_CH0,
459 .ab = (1920 * 1088 * 2 * 2 * 30),
460 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
461 },
462};
463
464static struct msm_bus_paths rotator_bus_scale_usecases[] = {
465 {
466 ARRAY_SIZE(rotator_init_vectors),
467 rotator_init_vectors,
468 },
469 {
470 ARRAY_SIZE(rotator_ui_vectors),
471 rotator_ui_vectors,
472 },
473 {
474 ARRAY_SIZE(rotator_vga_vectors),
475 rotator_vga_vectors,
476 },
477 {
478 ARRAY_SIZE(rotator_720p_vectors),
479 rotator_720p_vectors,
480 },
481 {
482 ARRAY_SIZE(rotator_1080p_vectors),
483 rotator_1080p_vectors,
484 },
485};
486
487struct msm_bus_scale_pdata rotator_bus_scale_pdata = {
488 rotator_bus_scale_usecases,
489 ARRAY_SIZE(rotator_bus_scale_usecases),
490 .name = "rotator",
491};
492
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800493static struct msm_bus_vectors mdp_init_vectors[] = {
494 {
495 .src = MSM_BUS_MASTER_MDP_PORT0,
496 .dst = MSM_BUS_SLAVE_EBI_CH0,
497 .ab = 0,
498 .ib = 0,
499 },
500};
501
502#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
503static struct msm_bus_vectors hdmi_as_primary_vectors[] = {
504 /* If HDMI is used as primary */
505 {
506 .src = MSM_BUS_MASTER_MDP_PORT0,
507 .dst = MSM_BUS_SLAVE_EBI_CH0,
508 .ab = 2000000000,
509 .ib = 2000000000,
510 },
511};
512static struct msm_bus_paths mdp_bus_scale_usecases[] = {
513 {
514 ARRAY_SIZE(mdp_init_vectors),
515 mdp_init_vectors,
516 },
517 {
518 ARRAY_SIZE(hdmi_as_primary_vectors),
519 hdmi_as_primary_vectors,
520 },
521 {
522 ARRAY_SIZE(hdmi_as_primary_vectors),
523 hdmi_as_primary_vectors,
524 },
525 {
526 ARRAY_SIZE(hdmi_as_primary_vectors),
527 hdmi_as_primary_vectors,
528 },
529 {
530 ARRAY_SIZE(hdmi_as_primary_vectors),
531 hdmi_as_primary_vectors,
532 },
533 {
534 ARRAY_SIZE(hdmi_as_primary_vectors),
535 hdmi_as_primary_vectors,
536 },
537};
538#else
539static struct msm_bus_vectors mdp_ui_vectors[] = {
540 {
541 .src = MSM_BUS_MASTER_MDP_PORT0,
542 .dst = MSM_BUS_SLAVE_EBI_CH0,
543 .ab = 216000000 * 2,
544 .ib = 270000000 * 2,
545 },
546};
547
548static struct msm_bus_vectors mdp_vga_vectors[] = {
549 /* VGA and less video */
550 {
551 .src = MSM_BUS_MASTER_MDP_PORT0,
552 .dst = MSM_BUS_SLAVE_EBI_CH0,
553 .ab = 216000000 * 2,
554 .ib = 270000000 * 2,
555 },
556};
557
558static struct msm_bus_vectors mdp_720p_vectors[] = {
559 /* 720p and less video */
560 {
561 .src = MSM_BUS_MASTER_MDP_PORT0,
562 .dst = MSM_BUS_SLAVE_EBI_CH0,
563 .ab = 230400000 * 2,
564 .ib = 288000000 * 2,
565 },
566};
567
568static struct msm_bus_vectors mdp_1080p_vectors[] = {
569 /* 1080p and less video */
570 {
571 .src = MSM_BUS_MASTER_MDP_PORT0,
572 .dst = MSM_BUS_SLAVE_EBI_CH0,
573 .ab = 334080000 * 2,
574 .ib = 417600000 * 2,
575 },
576};
577
578static struct msm_bus_paths mdp_bus_scale_usecases[] = {
579 {
580 ARRAY_SIZE(mdp_init_vectors),
581 mdp_init_vectors,
582 },
583 {
584 ARRAY_SIZE(mdp_ui_vectors),
585 mdp_ui_vectors,
586 },
587 {
588 ARRAY_SIZE(mdp_ui_vectors),
589 mdp_ui_vectors,
590 },
591 {
592 ARRAY_SIZE(mdp_vga_vectors),
593 mdp_vga_vectors,
594 },
595 {
596 ARRAY_SIZE(mdp_720p_vectors),
597 mdp_720p_vectors,
598 },
599 {
600 ARRAY_SIZE(mdp_1080p_vectors),
601 mdp_1080p_vectors,
602 },
603};
604#endif
605
606static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
607 mdp_bus_scale_usecases,
608 ARRAY_SIZE(mdp_bus_scale_usecases),
609 .name = "mdp",
610};
611
612#endif
613
614#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -0800615static int mdp_core_clk_rate_table[] = {
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800616 200000000,
617 200000000,
618 200000000,
619 200000000,
620};
621#else
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -0800622static int mdp_core_clk_rate_table[] = {
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800623 85330000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -0800624 128000000,
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800625 160000000,
626 200000000,
627};
628#endif
629
630static struct msm_panel_common_pdata mdp_pdata = {
631 .gpio = MDP_VSYNC_GPIO,
632#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
633 .mdp_core_clk_rate = 200000000,
634#else
635 .mdp_core_clk_rate = 85330000,
636#endif
637 .mdp_core_clk_table = mdp_core_clk_rate_table,
638 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
639#ifdef CONFIG_MSM_BUS_SCALING
640 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
641#endif
642 .mdp_rev = MDP_REV_42,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -0800643#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
644 .mem_hid = ION_CP_MM_HEAP_ID,
645#else
646 .mem_hid = MEMTYPE_EBI1,
647#endif
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800648};
649
Amir Samuelovf0d1f542012-02-06 12:50:42 +0200650/**
651 * Set MDP clocks to high frequency to avoid DSI underflow
652 * when using high resolution 1200x1920 WUXGA panel.
653 */
654static void set_mdp_clocks_for_liquid_wuxga(void)
655{
656 int i;
657
658 mdp_ui_vectors[0].ab = 2000000000;
659 mdp_ui_vectors[0].ib = 2000000000;
660
661 mdp_pdata.mdp_core_clk_rate = 200000000;
662
663 for (i = 0; i < ARRAY_SIZE(mdp_core_clk_rate_table); i++)
664 mdp_core_clk_rate_table[i] = 200000000;
665
666}
667
Huaibin Yanga5419422011-12-08 23:52:10 -0800668void __init msm8960_mdp_writeback(struct memtype_reserve* reserve_table)
669{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -0800670 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
671 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
672#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
673 reserve_table[mdp_pdata.mem_hid].size +=
674 mdp_pdata.ov0_wb_size;
675 reserve_table[mdp_pdata.mem_hid].size +=
676 mdp_pdata.ov1_wb_size;
677#endif
Huaibin Yanga5419422011-12-08 23:52:10 -0800678}
679
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800680static struct platform_device mipi_dsi_renesas_panel_device = {
681 .name = "mipi_renesas",
682 .id = 0,
683};
684
685static struct platform_device mipi_dsi_simulator_panel_device = {
686 .name = "mipi_simulator",
687 .id = 0,
688};
689
690#define LPM_CHANNEL0 0
691static int toshiba_gpio[] = {LPM_CHANNEL0};
692
693static struct mipi_dsi_panel_platform_data toshiba_pdata = {
694 .gpio = toshiba_gpio,
695};
696
697static 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
705#define FPGA_3D_GPIO_CONFIG_ADDR 0xB5
Amir Samuelovca199b92012-01-31 14:50:04 +0200706static int dsi2lvds_gpio[4] = {
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800707 0,/* Backlight PWM-ID=0 for PMIC-GPIO#24 */
Amir Samuelovca199b92012-01-31 14:50:04 +0200708 0x1F08, /* DSI2LVDS Bridge GPIO Output, mask=0x1f, out=0x08 */
709 GPIO_LIQUID_EXPANDER_BASE+6, /* TN Enable */
710 GPIO_LIQUID_EXPANDER_BASE+7, /* TN Mode */
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800711 };
712
713static struct msm_panel_common_pdata mipi_dsi2lvds_pdata = {
714 .gpio_num = dsi2lvds_gpio,
715};
716
717static struct mipi_dsi_phy_ctrl dsi_novatek_cmd_mode_phy_db = {
718
719/* DSI_BIT_CLK at 500MHz, 2 lane, RGB888 */
720 {0x0F, 0x0a, 0x04, 0x00, 0x20}, /* regulator */
721 /* timing */
722 {0xab, 0x8a, 0x18, 0x00, 0x92, 0x97, 0x1b, 0x8c,
723 0x0c, 0x03, 0x04, 0xa0},
724 {0x5f, 0x00, 0x00, 0x10}, /* phy ctrl */
725 {0xff, 0x00, 0x06, 0x00}, /* strength */
726 /* pll control */
727 {0x40, 0xf9, 0x30, 0xda, 0x00, 0x40, 0x03, 0x62,
728 0x40, 0x07, 0x03,
729 0x00, 0x1a, 0x00, 0x00, 0x02, 0x00, 0x20, 0x00, 0x01},
730};
731
732static struct mipi_dsi_panel_platform_data novatek_pdata = {
733 .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR,
734 .fpga_ctrl_mode = FPGA_SPI_INTF,
735 .phy_ctrl_settings = &dsi_novatek_cmd_mode_phy_db,
736};
737
738static struct platform_device mipi_dsi_novatek_panel_device = {
739 .name = "mipi_novatek",
740 .id = 0,
741 .dev = {
742 .platform_data = &novatek_pdata,
743 }
744};
745
746static struct platform_device mipi_dsi2lvds_bridge_device = {
747 .name = "mipi_tc358764",
748 .id = 0,
749 .dev.platform_data = &mipi_dsi2lvds_pdata,
750};
751
752#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
753static struct resource hdmi_msm_resources[] = {
754 {
755 .name = "hdmi_msm_qfprom_addr",
756 .start = 0x00700000,
757 .end = 0x007060FF,
758 .flags = IORESOURCE_MEM,
759 },
760 {
761 .name = "hdmi_msm_hdmi_addr",
762 .start = 0x04A00000,
763 .end = 0x04A00FFF,
764 .flags = IORESOURCE_MEM,
765 },
766 {
767 .name = "hdmi_msm_irq",
768 .start = HDMI_IRQ,
769 .end = HDMI_IRQ,
770 .flags = IORESOURCE_IRQ,
771 },
772};
773
774static int hdmi_enable_5v(int on);
775static int hdmi_core_power(int on, int show);
776static int hdmi_cec_power(int on);
777
778static struct msm_hdmi_platform_data hdmi_msm_data = {
779 .irq = HDMI_IRQ,
780 .enable_5v = hdmi_enable_5v,
781 .core_power = hdmi_core_power,
782 .cec_power = hdmi_cec_power,
783};
784
785static struct platform_device hdmi_msm_device = {
786 .name = "hdmi_msm",
787 .id = 0,
788 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
789 .resource = hdmi_msm_resources,
790 .dev.platform_data = &hdmi_msm_data,
791};
792#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
793
794#ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL
795static struct platform_device wfd_panel_device = {
796 .name = "wfd_panel",
797 .id = 0,
798 .dev.platform_data = NULL,
799};
Stepan Moskovchenko270888d2011-11-30 12:19:11 -0800800
801static struct platform_device wfd_device = {
802 .name = "msm_wfd",
803 .id = -1,
804};
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800805#endif
806
807#ifdef CONFIG_MSM_BUS_SCALING
808static struct msm_bus_vectors dtv_bus_init_vectors[] = {
809 {
810 .src = MSM_BUS_MASTER_MDP_PORT0,
811 .dst = MSM_BUS_SLAVE_EBI_CH0,
812 .ab = 0,
813 .ib = 0,
814 },
815};
816
817#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
818static struct msm_bus_vectors dtv_bus_def_vectors[] = {
819 {
820 .src = MSM_BUS_MASTER_MDP_PORT0,
821 .dst = MSM_BUS_SLAVE_EBI_CH0,
822 .ab = 2000000000,
823 .ib = 2000000000,
824 },
825};
826#else
827static struct msm_bus_vectors dtv_bus_def_vectors[] = {
828 {
829 .src = MSM_BUS_MASTER_MDP_PORT0,
830 .dst = MSM_BUS_SLAVE_EBI_CH0,
831 .ab = 566092800 * 2,
832 .ib = 707616000 * 2,
833 },
834};
835#endif
836
837static struct msm_bus_paths dtv_bus_scale_usecases[] = {
838 {
839 ARRAY_SIZE(dtv_bus_init_vectors),
840 dtv_bus_init_vectors,
841 },
842 {
843 ARRAY_SIZE(dtv_bus_def_vectors),
844 dtv_bus_def_vectors,
845 },
846};
847static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
848 dtv_bus_scale_usecases,
849 ARRAY_SIZE(dtv_bus_scale_usecases),
850 .name = "dtv",
851};
852
853static struct lcdc_platform_data dtv_pdata = {
854 .bus_scale_table = &dtv_bus_scale_pdata,
855};
856#endif
857
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800858#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800859static int hdmi_enable_5v(int on)
860{
861 /* TBD: PM8921 regulator instead of 8901 */
862 static struct regulator *reg_8921_hdmi_mvs; /* HDMI_5V */
863 static int prev_on;
864 int rc;
865
866 if (on == prev_on)
867 return 0;
868
869 if (!reg_8921_hdmi_mvs)
870 reg_8921_hdmi_mvs = regulator_get(&hdmi_msm_device.dev,
871 "hdmi_mvs");
872
873 if (on) {
874 rc = regulator_enable(reg_8921_hdmi_mvs);
875 if (rc) {
876 pr_err("'%s' regulator enable failed, rc=%d\n",
877 "8921_hdmi_mvs", rc);
878 return rc;
879 }
880 pr_debug("%s(on): success\n", __func__);
881 } else {
882 rc = regulator_disable(reg_8921_hdmi_mvs);
883 if (rc)
884 pr_warning("'%s' regulator disable failed, rc=%d\n",
885 "8921_hdmi_mvs", rc);
886 pr_debug("%s(off): success\n", __func__);
887 }
888
889 prev_on = on;
890
891 return 0;
892}
893
894static int hdmi_core_power(int on, int show)
895{
896 static struct regulator *reg_8921_l23, *reg_8921_s4;
897 static int prev_on;
898 int rc;
899
900 if (on == prev_on)
901 return 0;
902
903 /* TBD: PM8921 regulator instead of 8901 */
904 if (!reg_8921_l23) {
905 reg_8921_l23 = regulator_get(&hdmi_msm_device.dev, "hdmi_avdd");
906 if (IS_ERR(reg_8921_l23)) {
907 pr_err("could not get reg_8921_l23, rc = %ld\n",
908 PTR_ERR(reg_8921_l23));
909 return -ENODEV;
910 }
911 rc = regulator_set_voltage(reg_8921_l23, 1800000, 1800000);
912 if (rc) {
913 pr_err("set_voltage failed for 8921_l23, rc=%d\n", rc);
914 return -EINVAL;
915 }
916 }
917 if (!reg_8921_s4) {
918 reg_8921_s4 = regulator_get(&hdmi_msm_device.dev, "hdmi_vcc");
919 if (IS_ERR(reg_8921_s4)) {
920 pr_err("could not get reg_8921_s4, rc = %ld\n",
921 PTR_ERR(reg_8921_s4));
922 return -ENODEV;
923 }
924 rc = regulator_set_voltage(reg_8921_s4, 1800000, 1800000);
925 if (rc) {
926 pr_err("set_voltage failed for 8921_s4, rc=%d\n", rc);
927 return -EINVAL;
928 }
929 }
930
931 if (on) {
932 rc = regulator_set_optimum_mode(reg_8921_l23, 100000);
933 if (rc < 0) {
934 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
935 return -EINVAL;
936 }
937 rc = regulator_enable(reg_8921_l23);
938 if (rc) {
939 pr_err("'%s' regulator enable failed, rc=%d\n",
940 "hdmi_avdd", rc);
941 return rc;
942 }
943 rc = regulator_enable(reg_8921_s4);
944 if (rc) {
945 pr_err("'%s' regulator enable failed, rc=%d\n",
946 "hdmi_vcc", rc);
947 return rc;
948 }
949 rc = gpio_request(100, "HDMI_DDC_CLK");
950 if (rc) {
951 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
952 "HDMI_DDC_CLK", 100, rc);
953 goto error1;
954 }
955 rc = gpio_request(101, "HDMI_DDC_DATA");
956 if (rc) {
957 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
958 "HDMI_DDC_DATA", 101, rc);
959 goto error2;
960 }
961 rc = gpio_request(102, "HDMI_HPD");
962 if (rc) {
963 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
964 "HDMI_HPD", 102, rc);
965 goto error3;
966 }
967 pr_debug("%s(on): success\n", __func__);
968 } else {
969 gpio_free(100);
970 gpio_free(101);
971 gpio_free(102);
972
973 rc = regulator_disable(reg_8921_l23);
974 if (rc) {
975 pr_err("disable reg_8921_l23 failed, rc=%d\n", rc);
976 return -ENODEV;
977 }
978 rc = regulator_disable(reg_8921_s4);
979 if (rc) {
980 pr_err("disable reg_8921_s4 failed, rc=%d\n", rc);
981 return -ENODEV;
982 }
983 rc = regulator_set_optimum_mode(reg_8921_l23, 100);
984 if (rc < 0) {
985 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
986 return -EINVAL;
987 }
988 pr_debug("%s(off): success\n", __func__);
989 }
990
991 prev_on = on;
992
993 return 0;
994
995error3:
996 gpio_free(101);
997error2:
998 gpio_free(100);
999error1:
1000 regulator_disable(reg_8921_l23);
1001 regulator_disable(reg_8921_s4);
1002 return rc;
1003}
1004
1005static int hdmi_cec_power(int on)
1006{
1007 static int prev_on;
1008 int rc;
1009
1010 if (on == prev_on)
1011 return 0;
1012
1013 if (on) {
1014 rc = gpio_request(99, "HDMI_CEC_VAR");
1015 if (rc) {
1016 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
1017 "HDMI_CEC_VAR", 99, rc);
1018 goto error;
1019 }
1020 pr_debug("%s(on): success\n", __func__);
1021 } else {
1022 gpio_free(99);
1023 pr_debug("%s(off): success\n", __func__);
1024 }
1025
1026 prev_on = on;
1027
1028 return 0;
1029error:
1030 return rc;
1031}
1032#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
1033
1034void __init msm8960_init_fb(void)
1035{
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -08001036 platform_device_register(&msm_fb_device);
1037
Stepan Moskovchenko270888d2011-11-30 12:19:11 -08001038#ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL
1039 platform_device_register(&wfd_panel_device);
1040 platform_device_register(&wfd_device);
1041#endif
1042
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -08001043 if (machine_is_msm8960_sim())
1044 platform_device_register(&mipi_dsi_simulator_panel_device);
1045
1046 if (machine_is_msm8960_rumi3())
1047 platform_device_register(&mipi_dsi_renesas_panel_device);
1048
1049 if (!machine_is_msm8960_sim() && !machine_is_msm8960_rumi3()) {
1050 platform_device_register(&mipi_dsi_novatek_panel_device);
1051
1052#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
1053 platform_device_register(&hdmi_msm_device);
1054#endif
1055 }
1056
1057 if (machine_is_msm8960_liquid())
1058 platform_device_register(&mipi_dsi2lvds_bridge_device);
1059 else
1060 platform_device_register(&mipi_dsi_toshiba_panel_device);
1061
1062 if (machine_is_msm8x60_rumi3()) {
1063 msm_fb_register_device("mdp", NULL);
1064 mipi_dsi_pdata.target_type = 1;
1065 } else
1066 msm_fb_register_device("mdp", &mdp_pdata);
1067 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
1068#ifdef CONFIG_MSM_BUS_SCALING
1069 msm_fb_register_device("dtv", &dtv_pdata);
1070#endif
1071}
1072
1073void __init msm8960_allocate_fb_region(void)
1074{
1075 void *addr;
1076 unsigned long size;
1077
1078 size = MSM_FB_SIZE;
1079 addr = alloc_bootmem_align(size, 0x1000);
1080 msm_fb_resources[0].start = __pa(addr);
1081 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
1082 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
1083 size, addr, __pa(addr));
1084}