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