blob: d871e048e650a760bcb001b2226040b3e0ec818d [file] [log] [blame]
Nagamalleswararao Ganji70fac1e2011-12-29 19:06:37 -08001/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
Stepan Moskovchenko39236d72011-11-30 17:42:23 -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 Moskovchenko39236d72011-11-30 17:42:23 -080021#include <mach/board.h>
22#include <mach/gpio.h>
23#include <mach/gpiomux.h>
Ajay Dudani9114be72011-12-03 07:46:35 -080024#include <mach/socinfo.h>
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -080025#include <linux/ion.h>
26#include <mach/ion.h>
27
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080028#include "devices.h"
Stepan Moskovchenko5a83dba2011-12-05 17:30:17 -080029#include "board-8930.h"
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080030
31#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
32#define MSM_FB_PRIM_BUF_SIZE (1376 * 768 * 4 * 3) /* 4 bpp x 3 pages */
33#else
34#define MSM_FB_PRIM_BUF_SIZE (1376 * 768 * 4 * 2) /* 4 bpp x 2 pages */
35#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 Moskovchenko39236d72011-11-30 17:42:23 -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 Moskovchenko39236d72011-11-30 17:42:23 -080051#endif
52
Huaibin Yanga5419422011-12-08 23:52:10 -080053#ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK
54#define MSM_FB_OVERLAY0_WRITEBACK_SIZE roundup((1376 * 768 * 3 * 2), 4096)
55#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 Moskovchenko39236d72011-11-30 17:42:23 -080065#define MDP_VSYNC_GPIO 0
66
67#define PANEL_NAME_MAX_LEN 30
68#define MIPI_CMD_NOVATEK_QHD_PANEL_NAME "mipi_cmd_novatek_qhd"
69#define MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME "mipi_video_novatek_qhd"
70#define MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME "mipi_video_toshiba_wsvga"
71#define MIPI_VIDEO_CHIMEI_WXGA_PANEL_NAME "mipi_video_chimei_wxga"
72#define MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME "mipi_video_simulator_vga"
73#define MIPI_CMD_RENESAS_FWVGA_PANEL_NAME "mipi_cmd_renesas_fwvga"
74#define HDMI_PANEL_NAME "hdmi_msm"
75#define TVOUT_PANEL_NAME "tvout_msm"
76
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080077static struct resource msm_fb_resources[] = {
78 {
79 .flags = IORESOURCE_DMA,
80 }
81};
82
83static int msm_fb_detect_panel(const char *name)
84{
Chandan Uddaraju59894ca2011-12-05 17:07:02 -080085 if (!strncmp(name, MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
86 strnlen(MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080087 PANEL_NAME_MAX_LEN)))
88 return 0;
89
90#ifndef CONFIG_FB_MSM_MIPI_PANEL_DETECT
91 if (!strncmp(name, MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
92 strnlen(MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
93 PANEL_NAME_MAX_LEN)))
94 return 0;
95
Chandan Uddaraju59894ca2011-12-05 17:07:02 -080096 if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME,
97 strnlen(MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080098 PANEL_NAME_MAX_LEN)))
99 return 0;
100
101 if (!strncmp(name, MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME,
102 strnlen(MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME,
103 PANEL_NAME_MAX_LEN)))
104 return 0;
105
106 if (!strncmp(name, MIPI_CMD_RENESAS_FWVGA_PANEL_NAME,
107 strnlen(MIPI_CMD_RENESAS_FWVGA_PANEL_NAME,
108 PANEL_NAME_MAX_LEN)))
109 return 0;
110#endif
111
112 if (!strncmp(name, HDMI_PANEL_NAME,
113 strnlen(HDMI_PANEL_NAME,
114 PANEL_NAME_MAX_LEN)))
115 return 0;
116
117 if (!strncmp(name, TVOUT_PANEL_NAME,
118 strnlen(TVOUT_PANEL_NAME,
119 PANEL_NAME_MAX_LEN)))
120 return 0;
121
122 pr_warning("%s: not supported '%s'", __func__, name);
123 return -ENODEV;
124}
125
126static struct msm_fb_platform_data msm_fb_pdata = {
127 .detect_client = msm_fb_detect_panel,
128};
129
130static struct platform_device msm_fb_device = {
131 .name = "msm_fb",
132 .id = 0,
133 .num_resources = ARRAY_SIZE(msm_fb_resources),
134 .resource = msm_fb_resources,
135 .dev.platform_data = &msm_fb_pdata,
136};
137
138static bool dsi_power_on;
139
Jay Chokshi06fa7542011-12-07 13:09:17 -0800140/*
141 * TODO: When physical 8930/PM8038 hardware becomes
142 * available, replace mipi_dsi_cdp_panel_power with
143 * appropriate function.
144 */
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800145#define DISP_RST_GPIO 58
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800146static int mipi_dsi_cdp_panel_power(int on)
147{
148 static struct regulator *reg_l8, *reg_l23, *reg_l2;
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800149 int rc;
150
Jeff Ohlstein2cbe5ba2011-12-16 13:32:56 -0800151 pr_debug("%s: state : %d\n", __func__, on);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800152
153 if (!dsi_power_on) {
154
155 reg_l8 = regulator_get(&msm_mipi_dsi1_device.dev,
156 "dsi_vdc");
157 if (IS_ERR(reg_l8)) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800158 pr_err("could not get 8038_l8, rc = %ld\n",
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800159 PTR_ERR(reg_l8));
160 return -ENODEV;
161 }
162 reg_l23 = regulator_get(&msm_mipi_dsi1_device.dev,
163 "dsi_vddio");
164 if (IS_ERR(reg_l23)) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800165 pr_err("could not get 8038_l23, rc = %ld\n",
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800166 PTR_ERR(reg_l23));
167 return -ENODEV;
168 }
169 reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev,
170 "dsi_vdda");
171 if (IS_ERR(reg_l2)) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800172 pr_err("could not get 8038_l2, rc = %ld\n",
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800173 PTR_ERR(reg_l2));
174 return -ENODEV;
175 }
176 rc = regulator_set_voltage(reg_l8, 2800000, 3000000);
177 if (rc) {
178 pr_err("set_voltage l8 failed, rc=%d\n", rc);
179 return -EINVAL;
180 }
181 rc = regulator_set_voltage(reg_l23, 1800000, 1800000);
182 if (rc) {
183 pr_err("set_voltage l23 failed, rc=%d\n", rc);
184 return -EINVAL;
185 }
186 rc = regulator_set_voltage(reg_l2, 1200000, 1200000);
187 if (rc) {
188 pr_err("set_voltage l2 failed, rc=%d\n", rc);
189 return -EINVAL;
190 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800191 rc = gpio_request(DISP_RST_GPIO, "disp_rst_n");
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800192 if (rc) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800193 pr_err("request gpio DISP_RST_GPIO failed, rc=%d\n",
194 rc);
195 gpio_free(DISP_RST_GPIO);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800196 return -ENODEV;
197 }
198 dsi_power_on = true;
199 }
200 if (on) {
201 rc = regulator_set_optimum_mode(reg_l8, 100000);
202 if (rc < 0) {
203 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
204 return -EINVAL;
205 }
206 rc = regulator_set_optimum_mode(reg_l23, 100000);
207 if (rc < 0) {
208 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
209 return -EINVAL;
210 }
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_l8);
217 if (rc) {
218 pr_err("enable l8 failed, rc=%d\n", rc);
219 return -ENODEV;
220 }
221 rc = regulator_enable(reg_l23);
222 if (rc) {
223 pr_err("enable l8 failed, rc=%d\n", rc);
224 return -ENODEV;
225 }
226 rc = regulator_enable(reg_l2);
227 if (rc) {
228 pr_err("enable l2 failed, rc=%d\n", rc);
229 return -ENODEV;
230 }
Ravishangar Kalyanam87c5fb62012-01-28 21:24:58 -0800231 usleep(10000);
232 gpio_set_value(DISP_RST_GPIO, 1);
233 usleep(10);
234 gpio_set_value(DISP_RST_GPIO, 0);
235 usleep(20);
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800236 gpio_set_value(DISP_RST_GPIO, 1);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800237 } else {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800238
239 gpio_set_value(DISP_RST_GPIO, 0);
240
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800241 rc = regulator_disable(reg_l2);
242 if (rc) {
243 pr_err("disable reg_l2 failed, rc=%d\n", rc);
244 return -ENODEV;
245 }
246 rc = regulator_disable(reg_l8);
247 if (rc) {
248 pr_err("disable reg_l8 failed, rc=%d\n", rc);
249 return -ENODEV;
250 }
251 rc = regulator_disable(reg_l23);
252 if (rc) {
253 pr_err("disable reg_l23 failed, rc=%d\n", rc);
254 return -ENODEV;
255 }
256 rc = regulator_set_optimum_mode(reg_l8, 100);
257 if (rc < 0) {
258 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
259 return -EINVAL;
260 }
261 rc = regulator_set_optimum_mode(reg_l23, 100);
262 if (rc < 0) {
263 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
264 return -EINVAL;
265 }
266 rc = regulator_set_optimum_mode(reg_l2, 100);
267 if (rc < 0) {
268 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
269 return -EINVAL;
270 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800271 }
272 return 0;
273}
274
275static int mipi_dsi_panel_power(int on)
276{
Jeff Ohlstein2cbe5ba2011-12-16 13:32:56 -0800277 pr_debug("%s: on=%d\n", __func__, on);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800278
279 return mipi_dsi_cdp_panel_power(on);
280}
281
282static struct mipi_dsi_platform_data mipi_dsi_pdata = {
283 .vsync_gpio = MDP_VSYNC_GPIO,
284 .dsi_power_save = mipi_dsi_panel_power,
285};
286
287#ifdef CONFIG_MSM_BUS_SCALING
288
289static struct msm_bus_vectors mdp_init_vectors[] = {
290 {
291 .src = MSM_BUS_MASTER_MDP_PORT0,
292 .dst = MSM_BUS_SLAVE_EBI_CH0,
293 .ab = 0,
294 .ib = 0,
295 },
296};
297
298#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
299static struct msm_bus_vectors hdmi_as_primary_vectors[] = {
300 /* If HDMI is used as primary */
301 {
302 .src = MSM_BUS_MASTER_MDP_PORT0,
303 .dst = MSM_BUS_SLAVE_EBI_CH0,
304 .ab = 2000000000,
305 .ib = 2000000000,
306 },
307};
308static struct msm_bus_paths mdp_bus_scale_usecases[] = {
309 {
310 ARRAY_SIZE(mdp_init_vectors),
311 mdp_init_vectors,
312 },
313 {
314 ARRAY_SIZE(hdmi_as_primary_vectors),
315 hdmi_as_primary_vectors,
316 },
317 {
318 ARRAY_SIZE(hdmi_as_primary_vectors),
319 hdmi_as_primary_vectors,
320 },
321 {
322 ARRAY_SIZE(hdmi_as_primary_vectors),
323 hdmi_as_primary_vectors,
324 },
325 {
326 ARRAY_SIZE(hdmi_as_primary_vectors),
327 hdmi_as_primary_vectors,
328 },
329 {
330 ARRAY_SIZE(hdmi_as_primary_vectors),
331 hdmi_as_primary_vectors,
332 },
333};
334#else
335static struct msm_bus_vectors mdp_ui_vectors[] = {
336 {
337 .src = MSM_BUS_MASTER_MDP_PORT0,
338 .dst = MSM_BUS_SLAVE_EBI_CH0,
339 .ab = 216000000 * 2,
340 .ib = 270000000 * 2,
341 },
342};
343
344static struct msm_bus_vectors mdp_vga_vectors[] = {
345 /* VGA and less video */
346 {
347 .src = MSM_BUS_MASTER_MDP_PORT0,
348 .dst = MSM_BUS_SLAVE_EBI_CH0,
349 .ab = 216000000 * 2,
350 .ib = 270000000 * 2,
351 },
352};
353
354static struct msm_bus_vectors mdp_720p_vectors[] = {
355 /* 720p and less video */
356 {
357 .src = MSM_BUS_MASTER_MDP_PORT0,
358 .dst = MSM_BUS_SLAVE_EBI_CH0,
359 .ab = 230400000 * 2,
360 .ib = 288000000 * 2,
361 },
362};
363
364static struct msm_bus_vectors mdp_1080p_vectors[] = {
365 /* 1080p and less video */
366 {
367 .src = MSM_BUS_MASTER_MDP_PORT0,
368 .dst = MSM_BUS_SLAVE_EBI_CH0,
369 .ab = 334080000 * 2,
370 .ib = 417600000 * 2,
371 },
372};
373
374static struct msm_bus_paths mdp_bus_scale_usecases[] = {
375 {
376 ARRAY_SIZE(mdp_init_vectors),
377 mdp_init_vectors,
378 },
379 {
380 ARRAY_SIZE(mdp_ui_vectors),
381 mdp_ui_vectors,
382 },
383 {
384 ARRAY_SIZE(mdp_ui_vectors),
385 mdp_ui_vectors,
386 },
387 {
388 ARRAY_SIZE(mdp_vga_vectors),
389 mdp_vga_vectors,
390 },
391 {
392 ARRAY_SIZE(mdp_720p_vectors),
393 mdp_720p_vectors,
394 },
395 {
396 ARRAY_SIZE(mdp_1080p_vectors),
397 mdp_1080p_vectors,
398 },
399};
400#endif
401
402static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
403 mdp_bus_scale_usecases,
404 ARRAY_SIZE(mdp_bus_scale_usecases),
405 .name = "mdp",
406};
407
408#endif
409
410#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
411static int mdp_core_clk_rate_table[] = {
412 200000000,
413 200000000,
414 200000000,
415 200000000,
416};
417#else
418static int mdp_core_clk_rate_table[] = {
419 85330000,
420 85330000,
421 160000000,
422 200000000,
423};
424#endif
425
426static struct msm_panel_common_pdata mdp_pdata = {
427 .gpio = MDP_VSYNC_GPIO,
428#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
429 .mdp_core_clk_rate = 200000000,
430#else
431 .mdp_core_clk_rate = 85330000,
432#endif
433 .mdp_core_clk_table = mdp_core_clk_rate_table,
434 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
435#ifdef CONFIG_MSM_BUS_SCALING
436 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
437#endif
438 .mdp_rev = MDP_REV_42,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -0800439#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
440 .mem_hid = ION_CP_MM_HEAP_ID,
441#else
442 .mem_hid = MEMTYPE_EBI1,
443#endif
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800444};
445
Huaibin Yanga5419422011-12-08 23:52:10 -0800446void __init msm8930_mdp_writeback(struct memtype_reserve* reserve_table)
447{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -0800448 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
449 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
450#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
451 reserve_table[mdp_pdata.mem_hid].size +=
452 mdp_pdata.ov0_wb_size;
453 reserve_table[mdp_pdata.mem_hid].size +=
454 mdp_pdata.ov1_wb_size;
455#endif
Huaibin Yanga5419422011-12-08 23:52:10 -0800456}
457
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800458#define LPM_CHANNEL0 0
459static int toshiba_gpio[] = {LPM_CHANNEL0};
460
461static struct mipi_dsi_panel_platform_data toshiba_pdata = {
462 .gpio = toshiba_gpio,
463};
464
465static struct platform_device mipi_dsi_toshiba_panel_device = {
466 .name = "mipi_toshiba",
467 .id = 0,
468 .dev = {
469 .platform_data = &toshiba_pdata,
470 }
471};
472
473#define FPGA_3D_GPIO_CONFIG_ADDR 0xB5
474
475static struct mipi_dsi_phy_ctrl dsi_novatek_cmd_mode_phy_db = {
476
477/* DSI_BIT_CLK at 500MHz, 2 lane, RGB888 */
478 {0x0F, 0x0a, 0x04, 0x00, 0x20}, /* regulator */
479 /* timing */
480 {0xab, 0x8a, 0x18, 0x00, 0x92, 0x97, 0x1b, 0x8c,
481 0x0c, 0x03, 0x04, 0xa0},
482 {0x5f, 0x00, 0x00, 0x10}, /* phy ctrl */
483 {0xff, 0x00, 0x06, 0x00}, /* strength */
484 /* pll control */
485 {0x40, 0xf9, 0x30, 0xda, 0x00, 0x40, 0x03, 0x62,
486 0x40, 0x07, 0x03,
487 0x00, 0x1a, 0x00, 0x00, 0x02, 0x00, 0x20, 0x00, 0x01},
488};
489
490static struct mipi_dsi_panel_platform_data novatek_pdata = {
491 .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR,
492 .fpga_ctrl_mode = FPGA_SPI_INTF,
493 .phy_ctrl_settings = &dsi_novatek_cmd_mode_phy_db,
Ravishangar Kalyanam903f65c2012-01-28 21:36:22 -0800494 .dlane_swap = 0x1,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800495};
496
497static struct platform_device mipi_dsi_novatek_panel_device = {
498 .name = "mipi_novatek",
499 .id = 0,
500 .dev = {
501 .platform_data = &novatek_pdata,
502 }
503};
504
505#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
506static struct resource hdmi_msm_resources[] = {
507 {
508 .name = "hdmi_msm_qfprom_addr",
509 .start = 0x00700000,
510 .end = 0x007060FF,
511 .flags = IORESOURCE_MEM,
512 },
513 {
514 .name = "hdmi_msm_hdmi_addr",
515 .start = 0x04A00000,
516 .end = 0x04A00FFF,
517 .flags = IORESOURCE_MEM,
518 },
519 {
520 .name = "hdmi_msm_irq",
521 .start = HDMI_IRQ,
522 .end = HDMI_IRQ,
523 .flags = IORESOURCE_IRQ,
524 },
525};
526
527static int hdmi_enable_5v(int on);
528static int hdmi_core_power(int on, int show);
529static int hdmi_cec_power(int on);
530
531static struct msm_hdmi_platform_data hdmi_msm_data = {
532 .irq = HDMI_IRQ,
533 .enable_5v = hdmi_enable_5v,
534 .core_power = hdmi_core_power,
535 .cec_power = hdmi_cec_power,
536};
537
538static struct platform_device hdmi_msm_device = {
539 .name = "hdmi_msm",
540 .id = 0,
541 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
542 .resource = hdmi_msm_resources,
543 .dev.platform_data = &hdmi_msm_data,
544};
545#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
546
547#ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL
548static struct platform_device wfd_panel_device = {
549 .name = "wfd_panel",
550 .id = 0,
551 .dev.platform_data = NULL,
552};
553
554static struct platform_device wfd_device = {
555 .name = "msm_wfd",
556 .id = -1,
557};
558#endif
559
560#ifdef CONFIG_MSM_BUS_SCALING
561static struct msm_bus_vectors dtv_bus_init_vectors[] = {
562 {
563 .src = MSM_BUS_MASTER_MDP_PORT0,
564 .dst = MSM_BUS_SLAVE_EBI_CH0,
565 .ab = 0,
566 .ib = 0,
567 },
568};
569
570#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
571static struct msm_bus_vectors dtv_bus_def_vectors[] = {
572 {
573 .src = MSM_BUS_MASTER_MDP_PORT0,
574 .dst = MSM_BUS_SLAVE_EBI_CH0,
575 .ab = 2000000000,
576 .ib = 2000000000,
577 },
578};
579#else
580static struct msm_bus_vectors dtv_bus_def_vectors[] = {
581 {
582 .src = MSM_BUS_MASTER_MDP_PORT0,
583 .dst = MSM_BUS_SLAVE_EBI_CH0,
584 .ab = 566092800 * 2,
585 .ib = 707616000 * 2,
586 },
587};
588#endif
589
590static struct msm_bus_paths dtv_bus_scale_usecases[] = {
591 {
592 ARRAY_SIZE(dtv_bus_init_vectors),
593 dtv_bus_init_vectors,
594 },
595 {
596 ARRAY_SIZE(dtv_bus_def_vectors),
597 dtv_bus_def_vectors,
598 },
599};
600static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
601 dtv_bus_scale_usecases,
602 ARRAY_SIZE(dtv_bus_scale_usecases),
603 .name = "dtv",
604};
605
606static struct lcdc_platform_data dtv_pdata = {
607 .bus_scale_table = &dtv_bus_scale_pdata,
608};
609#endif
610
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800611#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800612static int hdmi_enable_5v(int on)
613{
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800614 static struct regulator *reg_ext_5v; /* HDMI_5V */
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800615 static int prev_on;
616 int rc;
617
618 if (on == prev_on)
619 return 0;
620
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800621 if (!reg_ext_5v)
622 reg_ext_5v = regulator_get(&hdmi_msm_device.dev,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800623 "hdmi_mvs");
624
625 if (on) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800626 rc = regulator_enable(reg_ext_5v);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800627 if (rc) {
628 pr_err("'%s' regulator enable failed, rc=%d\n",
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800629 "reg_ext_5v", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800630 return rc;
631 }
632 pr_debug("%s(on): success\n", __func__);
633 } else {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800634 rc = regulator_disable(reg_ext_5v);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800635 if (rc)
636 pr_warning("'%s' regulator disable failed, rc=%d\n",
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800637 "reg_ext_5v", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800638 pr_debug("%s(off): success\n", __func__);
639 }
640
641 prev_on = on;
642
643 return 0;
644}
645
646static int hdmi_core_power(int on, int show)
647{
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800648 /* Both HDMI "avdd" and "vcc" are powered by 8038_l23 regulator */
649 static struct regulator *reg_8038_l23;
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800650 static int prev_on;
651 int rc;
652
653 if (on == prev_on)
654 return 0;
655
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800656 if (!reg_8038_l23) {
657 reg_8038_l23 = regulator_get(&hdmi_msm_device.dev, "hdmi_avdd");
658 if (IS_ERR(reg_8038_l23)) {
659 pr_err("could not get reg_8038_l23, rc = %ld\n",
660 PTR_ERR(reg_8038_l23));
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800661 return -ENODEV;
662 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800663 rc = regulator_set_voltage(reg_8038_l23, 1800000, 1800000);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800664 if (rc) {
665 pr_err("set_voltage failed for 8921_l23, rc=%d\n", rc);
666 return -EINVAL;
667 }
668 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800669
670 if (on) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800671 rc = regulator_set_optimum_mode(reg_8038_l23, 100000);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800672 if (rc < 0) {
673 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
674 return -EINVAL;
675 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800676 rc = regulator_enable(reg_8038_l23);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800677 if (rc) {
678 pr_err("'%s' regulator enable failed, rc=%d\n",
679 "hdmi_avdd", rc);
680 return rc;
681 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800682 rc = gpio_request(100, "HDMI_DDC_CLK");
683 if (rc) {
684 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
685 "HDMI_DDC_CLK", 100, rc);
686 goto error1;
687 }
688 rc = gpio_request(101, "HDMI_DDC_DATA");
689 if (rc) {
690 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
691 "HDMI_DDC_DATA", 101, rc);
692 goto error2;
693 }
694 rc = gpio_request(102, "HDMI_HPD");
695 if (rc) {
696 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
697 "HDMI_HPD", 102, rc);
698 goto error3;
699 }
700 pr_debug("%s(on): success\n", __func__);
701 } else {
702 gpio_free(100);
703 gpio_free(101);
704 gpio_free(102);
705
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800706 rc = regulator_disable(reg_8038_l23);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800707 if (rc) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800708 pr_err("disable reg_8038_l23 failed, rc=%d\n", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800709 return -ENODEV;
710 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800711 rc = regulator_set_optimum_mode(reg_8038_l23, 100);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800712 if (rc < 0) {
713 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
714 return -EINVAL;
715 }
716 pr_debug("%s(off): success\n", __func__);
717 }
718
719 prev_on = on;
720
721 return 0;
722
723error3:
724 gpio_free(101);
725error2:
726 gpio_free(100);
727error1:
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800728 regulator_disable(reg_8038_l23);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800729 return rc;
730}
731
732static int hdmi_cec_power(int on)
733{
734 static int prev_on;
735 int rc;
736
737 if (on == prev_on)
738 return 0;
739
740 if (on) {
741 rc = gpio_request(99, "HDMI_CEC_VAR");
742 if (rc) {
743 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
744 "HDMI_CEC_VAR", 99, rc);
745 goto error;
746 }
747 pr_debug("%s(on): success\n", __func__);
748 } else {
749 gpio_free(99);
750 pr_debug("%s(off): success\n", __func__);
751 }
752
753 prev_on = on;
754
755 return 0;
756error:
757 return rc;
758}
759#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
760
761void __init msm8930_init_fb(void)
762{
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800763 platform_device_register(&msm_fb_device);
764
765#ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL
766 platform_device_register(&wfd_panel_device);
767 platform_device_register(&wfd_device);
768#endif
769
770 platform_device_register(&mipi_dsi_novatek_panel_device);
771
772#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Ajay Dudani52e88232011-12-13 13:33:10 -0800773 if (!cpu_is_msm8930())
Ajay Dudani9114be72011-12-03 07:46:35 -0800774 platform_device_register(&hdmi_msm_device);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800775#endif
776
777 platform_device_register(&mipi_dsi_toshiba_panel_device);
778
779 msm_fb_register_device("mdp", &mdp_pdata);
780 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
781#ifdef CONFIG_MSM_BUS_SCALING
782 msm_fb_register_device("dtv", &dtv_pdata);
783#endif
784}
785
786void __init msm8930_allocate_fb_region(void)
787{
788 void *addr;
789 unsigned long size;
790
791 size = MSM_FB_SIZE;
792 addr = alloc_bootmem_align(size, 0x1000);
793 msm_fb_resources[0].start = __pa(addr);
794 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
795 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
796 size, addr, __pa(addr));
797}