blob: f55125c0797a971b2dcd12ca876d5339fc12272f [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 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800231 gpio_set_value(DISP_RST_GPIO, 1);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800232 } else {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800233
234 gpio_set_value(DISP_RST_GPIO, 0);
235
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800236 rc = regulator_disable(reg_l2);
237 if (rc) {
238 pr_err("disable reg_l2 failed, rc=%d\n", rc);
239 return -ENODEV;
240 }
241 rc = regulator_disable(reg_l8);
242 if (rc) {
243 pr_err("disable reg_l8 failed, rc=%d\n", rc);
244 return -ENODEV;
245 }
246 rc = regulator_disable(reg_l23);
247 if (rc) {
248 pr_err("disable reg_l23 failed, rc=%d\n", rc);
249 return -ENODEV;
250 }
251 rc = regulator_set_optimum_mode(reg_l8, 100);
252 if (rc < 0) {
253 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
254 return -EINVAL;
255 }
256 rc = regulator_set_optimum_mode(reg_l23, 100);
257 if (rc < 0) {
258 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
259 return -EINVAL;
260 }
261 rc = regulator_set_optimum_mode(reg_l2, 100);
262 if (rc < 0) {
263 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
264 return -EINVAL;
265 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800266 }
267 return 0;
268}
269
270static int mipi_dsi_panel_power(int on)
271{
Jeff Ohlstein2cbe5ba2011-12-16 13:32:56 -0800272 pr_debug("%s: on=%d\n", __func__, on);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800273
274 return mipi_dsi_cdp_panel_power(on);
275}
276
277static struct mipi_dsi_platform_data mipi_dsi_pdata = {
278 .vsync_gpio = MDP_VSYNC_GPIO,
279 .dsi_power_save = mipi_dsi_panel_power,
280};
281
282#ifdef CONFIG_MSM_BUS_SCALING
283
284static struct msm_bus_vectors mdp_init_vectors[] = {
285 {
286 .src = MSM_BUS_MASTER_MDP_PORT0,
287 .dst = MSM_BUS_SLAVE_EBI_CH0,
288 .ab = 0,
289 .ib = 0,
290 },
291};
292
293#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
294static struct msm_bus_vectors hdmi_as_primary_vectors[] = {
295 /* If HDMI is used as primary */
296 {
297 .src = MSM_BUS_MASTER_MDP_PORT0,
298 .dst = MSM_BUS_SLAVE_EBI_CH0,
299 .ab = 2000000000,
300 .ib = 2000000000,
301 },
302};
303static struct msm_bus_paths mdp_bus_scale_usecases[] = {
304 {
305 ARRAY_SIZE(mdp_init_vectors),
306 mdp_init_vectors,
307 },
308 {
309 ARRAY_SIZE(hdmi_as_primary_vectors),
310 hdmi_as_primary_vectors,
311 },
312 {
313 ARRAY_SIZE(hdmi_as_primary_vectors),
314 hdmi_as_primary_vectors,
315 },
316 {
317 ARRAY_SIZE(hdmi_as_primary_vectors),
318 hdmi_as_primary_vectors,
319 },
320 {
321 ARRAY_SIZE(hdmi_as_primary_vectors),
322 hdmi_as_primary_vectors,
323 },
324 {
325 ARRAY_SIZE(hdmi_as_primary_vectors),
326 hdmi_as_primary_vectors,
327 },
328};
329#else
330static struct msm_bus_vectors mdp_ui_vectors[] = {
331 {
332 .src = MSM_BUS_MASTER_MDP_PORT0,
333 .dst = MSM_BUS_SLAVE_EBI_CH0,
334 .ab = 216000000 * 2,
335 .ib = 270000000 * 2,
336 },
337};
338
339static struct msm_bus_vectors mdp_vga_vectors[] = {
340 /* VGA and less video */
341 {
342 .src = MSM_BUS_MASTER_MDP_PORT0,
343 .dst = MSM_BUS_SLAVE_EBI_CH0,
344 .ab = 216000000 * 2,
345 .ib = 270000000 * 2,
346 },
347};
348
349static struct msm_bus_vectors mdp_720p_vectors[] = {
350 /* 720p and less video */
351 {
352 .src = MSM_BUS_MASTER_MDP_PORT0,
353 .dst = MSM_BUS_SLAVE_EBI_CH0,
354 .ab = 230400000 * 2,
355 .ib = 288000000 * 2,
356 },
357};
358
359static struct msm_bus_vectors mdp_1080p_vectors[] = {
360 /* 1080p and less video */
361 {
362 .src = MSM_BUS_MASTER_MDP_PORT0,
363 .dst = MSM_BUS_SLAVE_EBI_CH0,
364 .ab = 334080000 * 2,
365 .ib = 417600000 * 2,
366 },
367};
368
369static struct msm_bus_paths mdp_bus_scale_usecases[] = {
370 {
371 ARRAY_SIZE(mdp_init_vectors),
372 mdp_init_vectors,
373 },
374 {
375 ARRAY_SIZE(mdp_ui_vectors),
376 mdp_ui_vectors,
377 },
378 {
379 ARRAY_SIZE(mdp_ui_vectors),
380 mdp_ui_vectors,
381 },
382 {
383 ARRAY_SIZE(mdp_vga_vectors),
384 mdp_vga_vectors,
385 },
386 {
387 ARRAY_SIZE(mdp_720p_vectors),
388 mdp_720p_vectors,
389 },
390 {
391 ARRAY_SIZE(mdp_1080p_vectors),
392 mdp_1080p_vectors,
393 },
394};
395#endif
396
397static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
398 mdp_bus_scale_usecases,
399 ARRAY_SIZE(mdp_bus_scale_usecases),
400 .name = "mdp",
401};
402
403#endif
404
405#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
406static int mdp_core_clk_rate_table[] = {
407 200000000,
408 200000000,
409 200000000,
410 200000000,
411};
412#else
413static int mdp_core_clk_rate_table[] = {
414 85330000,
415 85330000,
416 160000000,
417 200000000,
418};
419#endif
420
421static struct msm_panel_common_pdata mdp_pdata = {
422 .gpio = MDP_VSYNC_GPIO,
423#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
424 .mdp_core_clk_rate = 200000000,
425#else
426 .mdp_core_clk_rate = 85330000,
427#endif
428 .mdp_core_clk_table = mdp_core_clk_rate_table,
429 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
430#ifdef CONFIG_MSM_BUS_SCALING
431 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
432#endif
433 .mdp_rev = MDP_REV_42,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -0800434#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
435 .mem_hid = ION_CP_MM_HEAP_ID,
436#else
437 .mem_hid = MEMTYPE_EBI1,
438#endif
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800439};
440
Huaibin Yanga5419422011-12-08 23:52:10 -0800441void __init msm8930_mdp_writeback(struct memtype_reserve* reserve_table)
442{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -0800443 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
444 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
445#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
446 reserve_table[mdp_pdata.mem_hid].size +=
447 mdp_pdata.ov0_wb_size;
448 reserve_table[mdp_pdata.mem_hid].size +=
449 mdp_pdata.ov1_wb_size;
450#endif
Huaibin Yanga5419422011-12-08 23:52:10 -0800451}
452
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800453#define LPM_CHANNEL0 0
454static int toshiba_gpio[] = {LPM_CHANNEL0};
455
456static struct mipi_dsi_panel_platform_data toshiba_pdata = {
457 .gpio = toshiba_gpio,
458};
459
460static struct platform_device mipi_dsi_toshiba_panel_device = {
461 .name = "mipi_toshiba",
462 .id = 0,
463 .dev = {
464 .platform_data = &toshiba_pdata,
465 }
466};
467
468#define FPGA_3D_GPIO_CONFIG_ADDR 0xB5
469
470static struct mipi_dsi_phy_ctrl dsi_novatek_cmd_mode_phy_db = {
471
472/* DSI_BIT_CLK at 500MHz, 2 lane, RGB888 */
473 {0x0F, 0x0a, 0x04, 0x00, 0x20}, /* regulator */
474 /* timing */
475 {0xab, 0x8a, 0x18, 0x00, 0x92, 0x97, 0x1b, 0x8c,
476 0x0c, 0x03, 0x04, 0xa0},
477 {0x5f, 0x00, 0x00, 0x10}, /* phy ctrl */
478 {0xff, 0x00, 0x06, 0x00}, /* strength */
479 /* pll control */
480 {0x40, 0xf9, 0x30, 0xda, 0x00, 0x40, 0x03, 0x62,
481 0x40, 0x07, 0x03,
482 0x00, 0x1a, 0x00, 0x00, 0x02, 0x00, 0x20, 0x00, 0x01},
483};
484
485static struct mipi_dsi_panel_platform_data novatek_pdata = {
486 .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR,
487 .fpga_ctrl_mode = FPGA_SPI_INTF,
488 .phy_ctrl_settings = &dsi_novatek_cmd_mode_phy_db,
489};
490
491static struct platform_device mipi_dsi_novatek_panel_device = {
492 .name = "mipi_novatek",
493 .id = 0,
494 .dev = {
495 .platform_data = &novatek_pdata,
496 }
497};
498
499#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
500static struct resource hdmi_msm_resources[] = {
501 {
502 .name = "hdmi_msm_qfprom_addr",
503 .start = 0x00700000,
504 .end = 0x007060FF,
505 .flags = IORESOURCE_MEM,
506 },
507 {
508 .name = "hdmi_msm_hdmi_addr",
509 .start = 0x04A00000,
510 .end = 0x04A00FFF,
511 .flags = IORESOURCE_MEM,
512 },
513 {
514 .name = "hdmi_msm_irq",
515 .start = HDMI_IRQ,
516 .end = HDMI_IRQ,
517 .flags = IORESOURCE_IRQ,
518 },
519};
520
521static int hdmi_enable_5v(int on);
522static int hdmi_core_power(int on, int show);
523static int hdmi_cec_power(int on);
524
525static struct msm_hdmi_platform_data hdmi_msm_data = {
526 .irq = HDMI_IRQ,
527 .enable_5v = hdmi_enable_5v,
528 .core_power = hdmi_core_power,
529 .cec_power = hdmi_cec_power,
530};
531
532static struct platform_device hdmi_msm_device = {
533 .name = "hdmi_msm",
534 .id = 0,
535 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
536 .resource = hdmi_msm_resources,
537 .dev.platform_data = &hdmi_msm_data,
538};
539#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
540
541#ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL
542static struct platform_device wfd_panel_device = {
543 .name = "wfd_panel",
544 .id = 0,
545 .dev.platform_data = NULL,
546};
547
548static struct platform_device wfd_device = {
549 .name = "msm_wfd",
550 .id = -1,
551};
552#endif
553
554#ifdef CONFIG_MSM_BUS_SCALING
555static struct msm_bus_vectors dtv_bus_init_vectors[] = {
556 {
557 .src = MSM_BUS_MASTER_MDP_PORT0,
558 .dst = MSM_BUS_SLAVE_EBI_CH0,
559 .ab = 0,
560 .ib = 0,
561 },
562};
563
564#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
565static struct msm_bus_vectors dtv_bus_def_vectors[] = {
566 {
567 .src = MSM_BUS_MASTER_MDP_PORT0,
568 .dst = MSM_BUS_SLAVE_EBI_CH0,
569 .ab = 2000000000,
570 .ib = 2000000000,
571 },
572};
573#else
574static struct msm_bus_vectors dtv_bus_def_vectors[] = {
575 {
576 .src = MSM_BUS_MASTER_MDP_PORT0,
577 .dst = MSM_BUS_SLAVE_EBI_CH0,
578 .ab = 566092800 * 2,
579 .ib = 707616000 * 2,
580 },
581};
582#endif
583
584static struct msm_bus_paths dtv_bus_scale_usecases[] = {
585 {
586 ARRAY_SIZE(dtv_bus_init_vectors),
587 dtv_bus_init_vectors,
588 },
589 {
590 ARRAY_SIZE(dtv_bus_def_vectors),
591 dtv_bus_def_vectors,
592 },
593};
594static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
595 dtv_bus_scale_usecases,
596 ARRAY_SIZE(dtv_bus_scale_usecases),
597 .name = "dtv",
598};
599
600static struct lcdc_platform_data dtv_pdata = {
601 .bus_scale_table = &dtv_bus_scale_pdata,
602};
603#endif
604
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800605#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800606static int hdmi_enable_5v(int on)
607{
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800608 static struct regulator *reg_ext_5v; /* HDMI_5V */
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800609 static int prev_on;
610 int rc;
611
612 if (on == prev_on)
613 return 0;
614
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800615 if (!reg_ext_5v)
616 reg_ext_5v = regulator_get(&hdmi_msm_device.dev,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800617 "hdmi_mvs");
618
619 if (on) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800620 rc = regulator_enable(reg_ext_5v);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800621 if (rc) {
622 pr_err("'%s' regulator enable failed, rc=%d\n",
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800623 "reg_ext_5v", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800624 return rc;
625 }
626 pr_debug("%s(on): success\n", __func__);
627 } else {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800628 rc = regulator_disable(reg_ext_5v);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800629 if (rc)
630 pr_warning("'%s' regulator disable failed, rc=%d\n",
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800631 "reg_ext_5v", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800632 pr_debug("%s(off): success\n", __func__);
633 }
634
635 prev_on = on;
636
637 return 0;
638}
639
640static int hdmi_core_power(int on, int show)
641{
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800642 /* Both HDMI "avdd" and "vcc" are powered by 8038_l23 regulator */
643 static struct regulator *reg_8038_l23;
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800644 static int prev_on;
645 int rc;
646
647 if (on == prev_on)
648 return 0;
649
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800650 if (!reg_8038_l23) {
651 reg_8038_l23 = regulator_get(&hdmi_msm_device.dev, "hdmi_avdd");
652 if (IS_ERR(reg_8038_l23)) {
653 pr_err("could not get reg_8038_l23, rc = %ld\n",
654 PTR_ERR(reg_8038_l23));
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800655 return -ENODEV;
656 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800657 rc = regulator_set_voltage(reg_8038_l23, 1800000, 1800000);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800658 if (rc) {
659 pr_err("set_voltage failed for 8921_l23, rc=%d\n", rc);
660 return -EINVAL;
661 }
662 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800663
664 if (on) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800665 rc = regulator_set_optimum_mode(reg_8038_l23, 100000);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800666 if (rc < 0) {
667 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
668 return -EINVAL;
669 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800670 rc = regulator_enable(reg_8038_l23);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800671 if (rc) {
672 pr_err("'%s' regulator enable failed, rc=%d\n",
673 "hdmi_avdd", rc);
674 return rc;
675 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800676 rc = gpio_request(100, "HDMI_DDC_CLK");
677 if (rc) {
678 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
679 "HDMI_DDC_CLK", 100, rc);
680 goto error1;
681 }
682 rc = gpio_request(101, "HDMI_DDC_DATA");
683 if (rc) {
684 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
685 "HDMI_DDC_DATA", 101, rc);
686 goto error2;
687 }
688 rc = gpio_request(102, "HDMI_HPD");
689 if (rc) {
690 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
691 "HDMI_HPD", 102, rc);
692 goto error3;
693 }
694 pr_debug("%s(on): success\n", __func__);
695 } else {
696 gpio_free(100);
697 gpio_free(101);
698 gpio_free(102);
699
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800700 rc = regulator_disable(reg_8038_l23);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800701 if (rc) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800702 pr_err("disable reg_8038_l23 failed, rc=%d\n", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800703 return -ENODEV;
704 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800705 rc = regulator_set_optimum_mode(reg_8038_l23, 100);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800706 if (rc < 0) {
707 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
708 return -EINVAL;
709 }
710 pr_debug("%s(off): success\n", __func__);
711 }
712
713 prev_on = on;
714
715 return 0;
716
717error3:
718 gpio_free(101);
719error2:
720 gpio_free(100);
721error1:
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800722 regulator_disable(reg_8038_l23);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800723 return rc;
724}
725
726static int hdmi_cec_power(int on)
727{
728 static int prev_on;
729 int rc;
730
731 if (on == prev_on)
732 return 0;
733
734 if (on) {
735 rc = gpio_request(99, "HDMI_CEC_VAR");
736 if (rc) {
737 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
738 "HDMI_CEC_VAR", 99, rc);
739 goto error;
740 }
741 pr_debug("%s(on): success\n", __func__);
742 } else {
743 gpio_free(99);
744 pr_debug("%s(off): success\n", __func__);
745 }
746
747 prev_on = on;
748
749 return 0;
750error:
751 return rc;
752}
753#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
754
755void __init msm8930_init_fb(void)
756{
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800757 platform_device_register(&msm_fb_device);
758
759#ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL
760 platform_device_register(&wfd_panel_device);
761 platform_device_register(&wfd_device);
762#endif
763
764 platform_device_register(&mipi_dsi_novatek_panel_device);
765
766#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Ajay Dudani52e88232011-12-13 13:33:10 -0800767 if (!cpu_is_msm8930())
Ajay Dudani9114be72011-12-03 07:46:35 -0800768 platform_device_register(&hdmi_msm_device);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800769#endif
770
771 platform_device_register(&mipi_dsi_toshiba_panel_device);
772
773 msm_fb_register_device("mdp", &mdp_pdata);
774 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
775#ifdef CONFIG_MSM_BUS_SCALING
776 msm_fb_register_device("dtv", &dtv_pdata);
777#endif
778}
779
780void __init msm8930_allocate_fb_region(void)
781{
782 void *addr;
783 unsigned long size;
784
785 size = MSM_FB_SIZE;
786 addr = alloc_bootmem_align(size, 0x1000);
787 msm_fb_resources[0].start = __pa(addr);
788 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
789 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
790 size, addr, __pa(addr));
791}