blob: 69519f08f77bb9f4aa8e745db0c485f78f535145 [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>
18#include <asm/mach-types.h>
19#include <mach/msm_bus_board.h>
Huaibin Yanga5419422011-12-08 23:52:10 -080020#include <mach/msm_memtypes.h>
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080021#include <mach/board.h>
22#include <mach/gpio.h>
23#include <mach/gpiomux.h>
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -080024#include <linux/ion.h>
25#include <mach/ion.h>
26
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080027#include "devices.h"
Stepan Moskovchenko5a83dba2011-12-05 17:30:17 -080028#include "board-8960.h"
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080029
30#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
Amir Samuelovd7621032011-12-25 12:24:04 +020031#define MSM_FB_PRIM_BUF_SIZE (1920 * 1200 * 4 * 3) /* 4 bpp x 3 pages */
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080032#else
Amir Samuelovd7621032011-12-25 12:24:04 +020033#define MSM_FB_PRIM_BUF_SIZE (1920 * 1200 * 4 * 2) /* 4 bpp x 2 pages */
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080034#endif
35
36#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
37#define MSM_FB_EXT_BUF_SIZE (1920 * 1088 * 2 * 1) /* 2 bpp x 1 page */
38#elif defined(CONFIG_FB_MSM_TVOUT)
39#define MSM_FB_EXT_BUF_SIZE (720 * 576 * 2 * 2) /* 2 bpp x 2 pages */
40#else
41#define MSM_FB_EXT_BUF_SIZE 0
42#endif
43
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080044#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
45/* 4 bpp x 2 page HDMI case */
46#define MSM_FB_SIZE roundup((1920 * 1088 * 4 * 2), 4096)
47#else
48/* Note: must be multiple of 4096 */
Huaibin Yang27634b82011-12-09 00:16:25 -080049#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE, 4096)
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080050#endif
51
Huaibin Yanga5419422011-12-08 23:52:10 -080052#ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK
Amir Samuelovd7621032011-12-25 12:24:04 +020053#define MSM_FB_OVERLAY0_WRITEBACK_SIZE roundup((1920 * 1200 * 3 * 2), 4096)
Huaibin Yanga5419422011-12-08 23:52:10 -080054#else
55#define MSM_FB_OVERLAY0_WRITEBACK_SIZE (0)
56#endif /* CONFIG_FB_MSM_OVERLAY0_WRITEBACK */
57
58#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
59#define MSM_FB_OVERLAY1_WRITEBACK_SIZE roundup((1920 * 1088 * 3 * 2), 4096)
60#else
61#define MSM_FB_OVERLAY1_WRITEBACK_SIZE (0)
62#endif /* CONFIG_FB_MSM_OVERLAY1_WRITEBACK */
63
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080064#define MDP_VSYNC_GPIO 0
65
66#define PANEL_NAME_MAX_LEN 30
67#define MIPI_CMD_NOVATEK_QHD_PANEL_NAME "mipi_cmd_novatek_qhd"
68#define MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME "mipi_video_novatek_qhd"
69#define MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME "mipi_video_toshiba_wsvga"
70#define MIPI_VIDEO_CHIMEI_WXGA_PANEL_NAME "mipi_video_chimei_wxga"
71#define MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME "mipi_video_simulator_vga"
72#define MIPI_CMD_RENESAS_FWVGA_PANEL_NAME "mipi_cmd_renesas_fwvga"
73#define HDMI_PANEL_NAME "hdmi_msm"
74#define TVOUT_PANEL_NAME "tvout_msm"
75
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080076static struct resource msm_fb_resources[] = {
77 {
78 .flags = IORESOURCE_DMA,
79 }
80};
81
82static int msm_fb_detect_panel(const char *name)
83{
84 if (machine_is_msm8960_liquid()) {
85 if (!strncmp(name, MIPI_VIDEO_CHIMEI_WXGA_PANEL_NAME,
86 strnlen(MIPI_VIDEO_CHIMEI_WXGA_PANEL_NAME,
87 PANEL_NAME_MAX_LEN)))
88 return 0;
89 } else {
90 if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME,
91 strnlen(MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME,
92 PANEL_NAME_MAX_LEN)))
93 return 0;
94
95#ifndef CONFIG_FB_MSM_MIPI_PANEL_DETECT
96 if (!strncmp(name, MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
97 strnlen(MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
98 PANEL_NAME_MAX_LEN)))
99 return 0;
100
101 if (!strncmp(name, MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
102 strnlen(MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
103 PANEL_NAME_MAX_LEN)))
104 return 0;
105
106 if (!strncmp(name, MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME,
107 strnlen(MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME,
108 PANEL_NAME_MAX_LEN)))
109 return 0;
110
111 if (!strncmp(name, MIPI_CMD_RENESAS_FWVGA_PANEL_NAME,
112 strnlen(MIPI_CMD_RENESAS_FWVGA_PANEL_NAME,
113 PANEL_NAME_MAX_LEN)))
114 return 0;
115#endif
116 }
117
118 if (!strncmp(name, HDMI_PANEL_NAME,
119 strnlen(HDMI_PANEL_NAME,
120 PANEL_NAME_MAX_LEN)))
121 return 0;
122
123 if (!strncmp(name, TVOUT_PANEL_NAME,
124 strnlen(TVOUT_PANEL_NAME,
125 PANEL_NAME_MAX_LEN)))
126 return 0;
127
128 pr_warning("%s: not supported '%s'", __func__, name);
129 return -ENODEV;
130}
131
132static struct msm_fb_platform_data msm_fb_pdata = {
133 .detect_client = msm_fb_detect_panel,
134};
135
136static struct platform_device msm_fb_device = {
137 .name = "msm_fb",
138 .id = 0,
139 .num_resources = ARRAY_SIZE(msm_fb_resources),
140 .resource = msm_fb_resources,
141 .dev.platform_data = &msm_fb_pdata,
142};
143
144static bool dsi_power_on;
145
146/**
147 * LiQUID panel on/off
148 *
149 * @param on
150 *
151 * @return int
152 */
153static int mipi_dsi_liquid_panel_power(int on)
154{
155 static struct regulator *reg_l2, *reg_ext_3p3v;
156 static int gpio21, gpio24, gpio43;
157 int rc;
158
159 pr_info("%s: on=%d\n", __func__, on);
160
161 gpio21 = PM8921_GPIO_PM_TO_SYS(21); /* disp power enable_n */
162 gpio43 = PM8921_GPIO_PM_TO_SYS(43); /* Displays Enable (rst_n)*/
163 gpio24 = PM8921_GPIO_PM_TO_SYS(24); /* Backlight PWM */
164
165 if (!dsi_power_on) {
166
167 reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev,
168 "dsi_vdda");
169 if (IS_ERR(reg_l2)) {
170 pr_err("could not get 8921_l2, rc = %ld\n",
171 PTR_ERR(reg_l2));
172 return -ENODEV;
173 }
174
175 rc = regulator_set_voltage(reg_l2, 1200000, 1200000);
176 if (rc) {
177 pr_err("set_voltage l2 failed, rc=%d\n", rc);
178 return -EINVAL;
179 }
180
181 reg_ext_3p3v = regulator_get(&msm_mipi_dsi1_device.dev,
182 "vdd_lvds_3p3v");
183 if (IS_ERR(reg_ext_3p3v)) {
184 pr_err("could not get reg_ext_3p3v, rc = %ld\n",
185 PTR_ERR(reg_ext_3p3v));
186 return -ENODEV;
187 }
188
189 rc = gpio_request(gpio21, "disp_pwr_en_n");
190 if (rc) {
191 pr_err("request gpio 21 failed, rc=%d\n", rc);
192 return -ENODEV;
193 }
194
195 rc = gpio_request(gpio43, "disp_rst_n");
196 if (rc) {
197 pr_err("request gpio 43 failed, rc=%d\n", rc);
198 return -ENODEV;
199 }
200
201 rc = gpio_request(gpio24, "disp_backlight_pwm");
202 if (rc) {
203 pr_err("request gpio 24 failed, rc=%d\n", rc);
204 return -ENODEV;
205 }
206
207 dsi_power_on = true;
208 }
209
210 if (on) {
211 rc = regulator_set_optimum_mode(reg_l2, 100000);
212 if (rc < 0) {
213 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
214 return -EINVAL;
215 }
216 rc = regulator_enable(reg_l2);
217 if (rc) {
218 pr_err("enable l2 failed, rc=%d\n", rc);
219 return -ENODEV;
220 }
221
222 rc = regulator_enable(reg_ext_3p3v);
223 if (rc) {
224 pr_err("enable reg_ext_3p3v failed, rc=%d\n", rc);
225 return -ENODEV;
226 }
227
228 /* set reset pin before power enable */
229 gpio_set_value_cansleep(gpio43, 0); /* disp disable (resx=0) */
230
231 gpio_set_value_cansleep(gpio21, 0); /* disp power enable_n */
232 msleep(20);
233 gpio_set_value_cansleep(gpio43, 1); /* disp enable */
234 msleep(20);
235 gpio_set_value_cansleep(gpio43, 0); /* disp enable */
236 msleep(20);
237 gpio_set_value_cansleep(gpio43, 1); /* disp enable */
238 msleep(20);
239 } else {
240 gpio_set_value_cansleep(gpio43, 0);
241 gpio_set_value_cansleep(gpio21, 1);
242
243 rc = regulator_disable(reg_l2);
244 if (rc) {
245 pr_err("disable reg_l2 failed, rc=%d\n", rc);
246 return -ENODEV;
247 }
248 rc = regulator_disable(reg_ext_3p3v);
249 if (rc) {
250 pr_err("disable reg_ext_3p3v failed, rc=%d\n", rc);
251 return -ENODEV;
252 }
253 rc = regulator_set_optimum_mode(reg_l2, 100);
254 if (rc < 0) {
255 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
256 return -EINVAL;
257 }
258 }
259
260 return 0;
261}
262
263static int mipi_dsi_cdp_panel_power(int on)
264{
265 static struct regulator *reg_l8, *reg_l23, *reg_l2;
266 static int gpio43;
267 int rc;
268
269 pr_info("%s: state : %d\n", __func__, on);
270
271 if (!dsi_power_on) {
272
273 reg_l8 = regulator_get(&msm_mipi_dsi1_device.dev,
274 "dsi_vdc");
275 if (IS_ERR(reg_l8)) {
276 pr_err("could not get 8921_l8, rc = %ld\n",
277 PTR_ERR(reg_l8));
278 return -ENODEV;
279 }
280 reg_l23 = regulator_get(&msm_mipi_dsi1_device.dev,
281 "dsi_vddio");
282 if (IS_ERR(reg_l23)) {
283 pr_err("could not get 8921_l23, rc = %ld\n",
284 PTR_ERR(reg_l23));
285 return -ENODEV;
286 }
287 reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev,
288 "dsi_vdda");
289 if (IS_ERR(reg_l2)) {
290 pr_err("could not get 8921_l2, rc = %ld\n",
291 PTR_ERR(reg_l2));
292 return -ENODEV;
293 }
294 rc = regulator_set_voltage(reg_l8, 2800000, 3000000);
295 if (rc) {
296 pr_err("set_voltage l8 failed, rc=%d\n", rc);
297 return -EINVAL;
298 }
299 rc = regulator_set_voltage(reg_l23, 1800000, 1800000);
300 if (rc) {
301 pr_err("set_voltage l23 failed, rc=%d\n", rc);
302 return -EINVAL;
303 }
304 rc = regulator_set_voltage(reg_l2, 1200000, 1200000);
305 if (rc) {
306 pr_err("set_voltage l2 failed, rc=%d\n", rc);
307 return -EINVAL;
308 }
309 gpio43 = PM8921_GPIO_PM_TO_SYS(43);
310 rc = gpio_request(gpio43, "disp_rst_n");
311 if (rc) {
312 pr_err("request gpio 43 failed, rc=%d\n", rc);
313 return -ENODEV;
314 }
315 dsi_power_on = true;
316 }
317 if (on) {
318 rc = regulator_set_optimum_mode(reg_l8, 100000);
319 if (rc < 0) {
320 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
321 return -EINVAL;
322 }
323 rc = regulator_set_optimum_mode(reg_l23, 100000);
324 if (rc < 0) {
325 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
326 return -EINVAL;
327 }
328 rc = regulator_set_optimum_mode(reg_l2, 100000);
329 if (rc < 0) {
330 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
331 return -EINVAL;
332 }
333 rc = regulator_enable(reg_l8);
334 if (rc) {
335 pr_err("enable l8 failed, rc=%d\n", rc);
336 return -ENODEV;
337 }
338 rc = regulator_enable(reg_l23);
339 if (rc) {
340 pr_err("enable l8 failed, rc=%d\n", rc);
341 return -ENODEV;
342 }
343 rc = regulator_enable(reg_l2);
344 if (rc) {
345 pr_err("enable l2 failed, rc=%d\n", rc);
346 return -ENODEV;
347 }
348 gpio_set_value_cansleep(gpio43, 1);
349 } else {
350 rc = regulator_disable(reg_l2);
351 if (rc) {
352 pr_err("disable reg_l2 failed, rc=%d\n", rc);
353 return -ENODEV;
354 }
355 rc = regulator_disable(reg_l8);
356 if (rc) {
357 pr_err("disable reg_l8 failed, rc=%d\n", rc);
358 return -ENODEV;
359 }
360 rc = regulator_disable(reg_l23);
361 if (rc) {
362 pr_err("disable reg_l23 failed, rc=%d\n", rc);
363 return -ENODEV;
364 }
365 rc = regulator_set_optimum_mode(reg_l8, 100);
366 if (rc < 0) {
367 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
368 return -EINVAL;
369 }
370 rc = regulator_set_optimum_mode(reg_l23, 100);
371 if (rc < 0) {
372 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
373 return -EINVAL;
374 }
375 rc = regulator_set_optimum_mode(reg_l2, 100);
376 if (rc < 0) {
377 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
378 return -EINVAL;
379 }
380 gpio_set_value_cansleep(gpio43, 0);
381 }
382 return 0;
383}
384
385static int mipi_dsi_panel_power(int on)
386{
387 int ret;
388
389 pr_info("%s: on=%d\n", __func__, on);
390
391 if (machine_is_msm8960_liquid())
392 ret = mipi_dsi_liquid_panel_power(on);
393 else
394 ret = mipi_dsi_cdp_panel_power(on);
395
396 return ret;
397}
398
399static struct mipi_dsi_platform_data mipi_dsi_pdata = {
400 .vsync_gpio = MDP_VSYNC_GPIO,
401 .dsi_power_save = mipi_dsi_panel_power,
402};
403
404#ifdef CONFIG_MSM_BUS_SCALING
405
406static struct msm_bus_vectors mdp_init_vectors[] = {
407 {
408 .src = MSM_BUS_MASTER_MDP_PORT0,
409 .dst = MSM_BUS_SLAVE_EBI_CH0,
410 .ab = 0,
411 .ib = 0,
412 },
413};
414
415#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
416static struct msm_bus_vectors hdmi_as_primary_vectors[] = {
417 /* If HDMI is used as primary */
418 {
419 .src = MSM_BUS_MASTER_MDP_PORT0,
420 .dst = MSM_BUS_SLAVE_EBI_CH0,
421 .ab = 2000000000,
422 .ib = 2000000000,
423 },
424};
425static struct msm_bus_paths mdp_bus_scale_usecases[] = {
426 {
427 ARRAY_SIZE(mdp_init_vectors),
428 mdp_init_vectors,
429 },
430 {
431 ARRAY_SIZE(hdmi_as_primary_vectors),
432 hdmi_as_primary_vectors,
433 },
434 {
435 ARRAY_SIZE(hdmi_as_primary_vectors),
436 hdmi_as_primary_vectors,
437 },
438 {
439 ARRAY_SIZE(hdmi_as_primary_vectors),
440 hdmi_as_primary_vectors,
441 },
442 {
443 ARRAY_SIZE(hdmi_as_primary_vectors),
444 hdmi_as_primary_vectors,
445 },
446 {
447 ARRAY_SIZE(hdmi_as_primary_vectors),
448 hdmi_as_primary_vectors,
449 },
450};
451#else
452static struct msm_bus_vectors mdp_ui_vectors[] = {
453 {
454 .src = MSM_BUS_MASTER_MDP_PORT0,
455 .dst = MSM_BUS_SLAVE_EBI_CH0,
456 .ab = 216000000 * 2,
457 .ib = 270000000 * 2,
458 },
459};
460
461static struct msm_bus_vectors mdp_vga_vectors[] = {
462 /* VGA and less video */
463 {
464 .src = MSM_BUS_MASTER_MDP_PORT0,
465 .dst = MSM_BUS_SLAVE_EBI_CH0,
466 .ab = 216000000 * 2,
467 .ib = 270000000 * 2,
468 },
469};
470
471static struct msm_bus_vectors mdp_720p_vectors[] = {
472 /* 720p and less video */
473 {
474 .src = MSM_BUS_MASTER_MDP_PORT0,
475 .dst = MSM_BUS_SLAVE_EBI_CH0,
476 .ab = 230400000 * 2,
477 .ib = 288000000 * 2,
478 },
479};
480
481static struct msm_bus_vectors mdp_1080p_vectors[] = {
482 /* 1080p and less video */
483 {
484 .src = MSM_BUS_MASTER_MDP_PORT0,
485 .dst = MSM_BUS_SLAVE_EBI_CH0,
486 .ab = 334080000 * 2,
487 .ib = 417600000 * 2,
488 },
489};
490
491static struct msm_bus_paths mdp_bus_scale_usecases[] = {
492 {
493 ARRAY_SIZE(mdp_init_vectors),
494 mdp_init_vectors,
495 },
496 {
497 ARRAY_SIZE(mdp_ui_vectors),
498 mdp_ui_vectors,
499 },
500 {
501 ARRAY_SIZE(mdp_ui_vectors),
502 mdp_ui_vectors,
503 },
504 {
505 ARRAY_SIZE(mdp_vga_vectors),
506 mdp_vga_vectors,
507 },
508 {
509 ARRAY_SIZE(mdp_720p_vectors),
510 mdp_720p_vectors,
511 },
512 {
513 ARRAY_SIZE(mdp_1080p_vectors),
514 mdp_1080p_vectors,
515 },
516};
517#endif
518
519static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
520 mdp_bus_scale_usecases,
521 ARRAY_SIZE(mdp_bus_scale_usecases),
522 .name = "mdp",
523};
524
525#endif
526
527#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -0800528static int mdp_core_clk_rate_table[] = {
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800529 200000000,
530 200000000,
531 200000000,
532 200000000,
533};
534#else
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -0800535static int mdp_core_clk_rate_table[] = {
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800536 85330000,
537 85330000,
538 160000000,
539 200000000,
540};
541#endif
542
543static struct msm_panel_common_pdata mdp_pdata = {
544 .gpio = MDP_VSYNC_GPIO,
545#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
546 .mdp_core_clk_rate = 200000000,
547#else
548 .mdp_core_clk_rate = 85330000,
549#endif
550 .mdp_core_clk_table = mdp_core_clk_rate_table,
551 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
552#ifdef CONFIG_MSM_BUS_SCALING
553 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
554#endif
555 .mdp_rev = MDP_REV_42,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -0800556#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
557 .mem_hid = ION_CP_MM_HEAP_ID,
558#else
559 .mem_hid = MEMTYPE_EBI1,
560#endif
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800561};
562
Huaibin Yanga5419422011-12-08 23:52:10 -0800563void __init msm8960_mdp_writeback(struct memtype_reserve* reserve_table)
564{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -0800565 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
566 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
567#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
568 reserve_table[mdp_pdata.mem_hid].size +=
569 mdp_pdata.ov0_wb_size;
570 reserve_table[mdp_pdata.mem_hid].size +=
571 mdp_pdata.ov1_wb_size;
572#endif
Huaibin Yanga5419422011-12-08 23:52:10 -0800573}
574
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800575static struct platform_device mipi_dsi_renesas_panel_device = {
576 .name = "mipi_renesas",
577 .id = 0,
578};
579
580static struct platform_device mipi_dsi_simulator_panel_device = {
581 .name = "mipi_simulator",
582 .id = 0,
583};
584
585#define LPM_CHANNEL0 0
586static int toshiba_gpio[] = {LPM_CHANNEL0};
587
588static struct mipi_dsi_panel_platform_data toshiba_pdata = {
589 .gpio = toshiba_gpio,
590};
591
592static struct platform_device mipi_dsi_toshiba_panel_device = {
593 .name = "mipi_toshiba",
594 .id = 0,
595 .dev = {
596 .platform_data = &toshiba_pdata,
597 }
598};
599
600#define FPGA_3D_GPIO_CONFIG_ADDR 0xB5
601static int dsi2lvds_gpio[2] = {
602 0,/* Backlight PWM-ID=0 for PMIC-GPIO#24 */
603 0x1F08 /* DSI2LVDS Bridge GPIO Output, mask=0x1f, out=0x08 */
604 };
605
606static struct msm_panel_common_pdata mipi_dsi2lvds_pdata = {
607 .gpio_num = dsi2lvds_gpio,
608};
609
610static struct mipi_dsi_phy_ctrl dsi_novatek_cmd_mode_phy_db = {
611
612/* DSI_BIT_CLK at 500MHz, 2 lane, RGB888 */
613 {0x0F, 0x0a, 0x04, 0x00, 0x20}, /* regulator */
614 /* timing */
615 {0xab, 0x8a, 0x18, 0x00, 0x92, 0x97, 0x1b, 0x8c,
616 0x0c, 0x03, 0x04, 0xa0},
617 {0x5f, 0x00, 0x00, 0x10}, /* phy ctrl */
618 {0xff, 0x00, 0x06, 0x00}, /* strength */
619 /* pll control */
620 {0x40, 0xf9, 0x30, 0xda, 0x00, 0x40, 0x03, 0x62,
621 0x40, 0x07, 0x03,
622 0x00, 0x1a, 0x00, 0x00, 0x02, 0x00, 0x20, 0x00, 0x01},
623};
624
625static struct mipi_dsi_panel_platform_data novatek_pdata = {
626 .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR,
627 .fpga_ctrl_mode = FPGA_SPI_INTF,
628 .phy_ctrl_settings = &dsi_novatek_cmd_mode_phy_db,
629};
630
631static struct platform_device mipi_dsi_novatek_panel_device = {
632 .name = "mipi_novatek",
633 .id = 0,
634 .dev = {
635 .platform_data = &novatek_pdata,
636 }
637};
638
639static struct platform_device mipi_dsi2lvds_bridge_device = {
640 .name = "mipi_tc358764",
641 .id = 0,
642 .dev.platform_data = &mipi_dsi2lvds_pdata,
643};
644
645#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
646static struct resource hdmi_msm_resources[] = {
647 {
648 .name = "hdmi_msm_qfprom_addr",
649 .start = 0x00700000,
650 .end = 0x007060FF,
651 .flags = IORESOURCE_MEM,
652 },
653 {
654 .name = "hdmi_msm_hdmi_addr",
655 .start = 0x04A00000,
656 .end = 0x04A00FFF,
657 .flags = IORESOURCE_MEM,
658 },
659 {
660 .name = "hdmi_msm_irq",
661 .start = HDMI_IRQ,
662 .end = HDMI_IRQ,
663 .flags = IORESOURCE_IRQ,
664 },
665};
666
667static int hdmi_enable_5v(int on);
668static int hdmi_core_power(int on, int show);
669static int hdmi_cec_power(int on);
670
671static struct msm_hdmi_platform_data hdmi_msm_data = {
672 .irq = HDMI_IRQ,
673 .enable_5v = hdmi_enable_5v,
674 .core_power = hdmi_core_power,
675 .cec_power = hdmi_cec_power,
676};
677
678static struct platform_device hdmi_msm_device = {
679 .name = "hdmi_msm",
680 .id = 0,
681 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
682 .resource = hdmi_msm_resources,
683 .dev.platform_data = &hdmi_msm_data,
684};
685#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
686
687#ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL
688static struct platform_device wfd_panel_device = {
689 .name = "wfd_panel",
690 .id = 0,
691 .dev.platform_data = NULL,
692};
Stepan Moskovchenko270888d2011-11-30 12:19:11 -0800693
694static struct platform_device wfd_device = {
695 .name = "msm_wfd",
696 .id = -1,
697};
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800698#endif
699
700#ifdef CONFIG_MSM_BUS_SCALING
701static struct msm_bus_vectors dtv_bus_init_vectors[] = {
702 {
703 .src = MSM_BUS_MASTER_MDP_PORT0,
704 .dst = MSM_BUS_SLAVE_EBI_CH0,
705 .ab = 0,
706 .ib = 0,
707 },
708};
709
710#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
711static struct msm_bus_vectors dtv_bus_def_vectors[] = {
712 {
713 .src = MSM_BUS_MASTER_MDP_PORT0,
714 .dst = MSM_BUS_SLAVE_EBI_CH0,
715 .ab = 2000000000,
716 .ib = 2000000000,
717 },
718};
719#else
720static struct msm_bus_vectors dtv_bus_def_vectors[] = {
721 {
722 .src = MSM_BUS_MASTER_MDP_PORT0,
723 .dst = MSM_BUS_SLAVE_EBI_CH0,
724 .ab = 566092800 * 2,
725 .ib = 707616000 * 2,
726 },
727};
728#endif
729
730static struct msm_bus_paths dtv_bus_scale_usecases[] = {
731 {
732 ARRAY_SIZE(dtv_bus_init_vectors),
733 dtv_bus_init_vectors,
734 },
735 {
736 ARRAY_SIZE(dtv_bus_def_vectors),
737 dtv_bus_def_vectors,
738 },
739};
740static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
741 dtv_bus_scale_usecases,
742 ARRAY_SIZE(dtv_bus_scale_usecases),
743 .name = "dtv",
744};
745
746static struct lcdc_platform_data dtv_pdata = {
747 .bus_scale_table = &dtv_bus_scale_pdata,
748};
749#endif
750
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800751#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800752static int hdmi_enable_5v(int on)
753{
754 /* TBD: PM8921 regulator instead of 8901 */
755 static struct regulator *reg_8921_hdmi_mvs; /* HDMI_5V */
756 static int prev_on;
757 int rc;
758
759 if (on == prev_on)
760 return 0;
761
762 if (!reg_8921_hdmi_mvs)
763 reg_8921_hdmi_mvs = regulator_get(&hdmi_msm_device.dev,
764 "hdmi_mvs");
765
766 if (on) {
767 rc = regulator_enable(reg_8921_hdmi_mvs);
768 if (rc) {
769 pr_err("'%s' regulator enable failed, rc=%d\n",
770 "8921_hdmi_mvs", rc);
771 return rc;
772 }
773 pr_debug("%s(on): success\n", __func__);
774 } else {
775 rc = regulator_disable(reg_8921_hdmi_mvs);
776 if (rc)
777 pr_warning("'%s' regulator disable failed, rc=%d\n",
778 "8921_hdmi_mvs", rc);
779 pr_debug("%s(off): success\n", __func__);
780 }
781
782 prev_on = on;
783
784 return 0;
785}
786
787static int hdmi_core_power(int on, int show)
788{
789 static struct regulator *reg_8921_l23, *reg_8921_s4;
790 static int prev_on;
791 int rc;
792
793 if (on == prev_on)
794 return 0;
795
796 /* TBD: PM8921 regulator instead of 8901 */
797 if (!reg_8921_l23) {
798 reg_8921_l23 = regulator_get(&hdmi_msm_device.dev, "hdmi_avdd");
799 if (IS_ERR(reg_8921_l23)) {
800 pr_err("could not get reg_8921_l23, rc = %ld\n",
801 PTR_ERR(reg_8921_l23));
802 return -ENODEV;
803 }
804 rc = regulator_set_voltage(reg_8921_l23, 1800000, 1800000);
805 if (rc) {
806 pr_err("set_voltage failed for 8921_l23, rc=%d\n", rc);
807 return -EINVAL;
808 }
809 }
810 if (!reg_8921_s4) {
811 reg_8921_s4 = regulator_get(&hdmi_msm_device.dev, "hdmi_vcc");
812 if (IS_ERR(reg_8921_s4)) {
813 pr_err("could not get reg_8921_s4, rc = %ld\n",
814 PTR_ERR(reg_8921_s4));
815 return -ENODEV;
816 }
817 rc = regulator_set_voltage(reg_8921_s4, 1800000, 1800000);
818 if (rc) {
819 pr_err("set_voltage failed for 8921_s4, rc=%d\n", rc);
820 return -EINVAL;
821 }
822 }
823
824 if (on) {
825 rc = regulator_set_optimum_mode(reg_8921_l23, 100000);
826 if (rc < 0) {
827 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
828 return -EINVAL;
829 }
830 rc = regulator_enable(reg_8921_l23);
831 if (rc) {
832 pr_err("'%s' regulator enable failed, rc=%d\n",
833 "hdmi_avdd", rc);
834 return rc;
835 }
836 rc = regulator_enable(reg_8921_s4);
837 if (rc) {
838 pr_err("'%s' regulator enable failed, rc=%d\n",
839 "hdmi_vcc", rc);
840 return rc;
841 }
842 rc = gpio_request(100, "HDMI_DDC_CLK");
843 if (rc) {
844 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
845 "HDMI_DDC_CLK", 100, rc);
846 goto error1;
847 }
848 rc = gpio_request(101, "HDMI_DDC_DATA");
849 if (rc) {
850 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
851 "HDMI_DDC_DATA", 101, rc);
852 goto error2;
853 }
854 rc = gpio_request(102, "HDMI_HPD");
855 if (rc) {
856 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
857 "HDMI_HPD", 102, rc);
858 goto error3;
859 }
860 pr_debug("%s(on): success\n", __func__);
861 } else {
862 gpio_free(100);
863 gpio_free(101);
864 gpio_free(102);
865
866 rc = regulator_disable(reg_8921_l23);
867 if (rc) {
868 pr_err("disable reg_8921_l23 failed, rc=%d\n", rc);
869 return -ENODEV;
870 }
871 rc = regulator_disable(reg_8921_s4);
872 if (rc) {
873 pr_err("disable reg_8921_s4 failed, rc=%d\n", rc);
874 return -ENODEV;
875 }
876 rc = regulator_set_optimum_mode(reg_8921_l23, 100);
877 if (rc < 0) {
878 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
879 return -EINVAL;
880 }
881 pr_debug("%s(off): success\n", __func__);
882 }
883
884 prev_on = on;
885
886 return 0;
887
888error3:
889 gpio_free(101);
890error2:
891 gpio_free(100);
892error1:
893 regulator_disable(reg_8921_l23);
894 regulator_disable(reg_8921_s4);
895 return rc;
896}
897
898static int hdmi_cec_power(int on)
899{
900 static int prev_on;
901 int rc;
902
903 if (on == prev_on)
904 return 0;
905
906 if (on) {
907 rc = gpio_request(99, "HDMI_CEC_VAR");
908 if (rc) {
909 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
910 "HDMI_CEC_VAR", 99, rc);
911 goto error;
912 }
913 pr_debug("%s(on): success\n", __func__);
914 } else {
915 gpio_free(99);
916 pr_debug("%s(off): success\n", __func__);
917 }
918
919 prev_on = on;
920
921 return 0;
922error:
923 return rc;
924}
925#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
926
927void __init msm8960_init_fb(void)
928{
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800929 platform_device_register(&msm_fb_device);
930
Stepan Moskovchenko270888d2011-11-30 12:19:11 -0800931#ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL
932 platform_device_register(&wfd_panel_device);
933 platform_device_register(&wfd_device);
934#endif
935
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800936 if (machine_is_msm8960_sim())
937 platform_device_register(&mipi_dsi_simulator_panel_device);
938
939 if (machine_is_msm8960_rumi3())
940 platform_device_register(&mipi_dsi_renesas_panel_device);
941
942 if (!machine_is_msm8960_sim() && !machine_is_msm8960_rumi3()) {
943 platform_device_register(&mipi_dsi_novatek_panel_device);
944
945#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
946 platform_device_register(&hdmi_msm_device);
947#endif
948 }
949
950 if (machine_is_msm8960_liquid())
951 platform_device_register(&mipi_dsi2lvds_bridge_device);
952 else
953 platform_device_register(&mipi_dsi_toshiba_panel_device);
954
955 if (machine_is_msm8x60_rumi3()) {
956 msm_fb_register_device("mdp", NULL);
957 mipi_dsi_pdata.target_type = 1;
958 } else
959 msm_fb_register_device("mdp", &mdp_pdata);
960 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
961#ifdef CONFIG_MSM_BUS_SCALING
962 msm_fb_register_device("dtv", &dtv_pdata);
963#endif
964}
965
966void __init msm8960_allocate_fb_region(void)
967{
968 void *addr;
969 unsigned long size;
970
971 size = MSM_FB_SIZE;
972 addr = alloc_bootmem_align(size, 0x1000);
973 msm_fb_resources[0].start = __pa(addr);
974 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
975 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
976 size, addr, __pa(addr));
977}