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