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