blob: 262616f71f37fc139678e31579c82cc99007a436 [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,
Ravishangar Kalyanam903f65c2012-01-28 21:36:22 -0800489 .dlane_swap = 0x1,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800490};
491
492static struct platform_device mipi_dsi_novatek_panel_device = {
493 .name = "mipi_novatek",
494 .id = 0,
495 .dev = {
496 .platform_data = &novatek_pdata,
497 }
498};
499
500#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
501static struct resource hdmi_msm_resources[] = {
502 {
503 .name = "hdmi_msm_qfprom_addr",
504 .start = 0x00700000,
505 .end = 0x007060FF,
506 .flags = IORESOURCE_MEM,
507 },
508 {
509 .name = "hdmi_msm_hdmi_addr",
510 .start = 0x04A00000,
511 .end = 0x04A00FFF,
512 .flags = IORESOURCE_MEM,
513 },
514 {
515 .name = "hdmi_msm_irq",
516 .start = HDMI_IRQ,
517 .end = HDMI_IRQ,
518 .flags = IORESOURCE_IRQ,
519 },
520};
521
522static int hdmi_enable_5v(int on);
523static int hdmi_core_power(int on, int show);
524static int hdmi_cec_power(int on);
525
526static struct msm_hdmi_platform_data hdmi_msm_data = {
527 .irq = HDMI_IRQ,
528 .enable_5v = hdmi_enable_5v,
529 .core_power = hdmi_core_power,
530 .cec_power = hdmi_cec_power,
531};
532
533static struct platform_device hdmi_msm_device = {
534 .name = "hdmi_msm",
535 .id = 0,
536 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
537 .resource = hdmi_msm_resources,
538 .dev.platform_data = &hdmi_msm_data,
539};
540#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
541
542#ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL
543static struct platform_device wfd_panel_device = {
544 .name = "wfd_panel",
545 .id = 0,
546 .dev.platform_data = NULL,
547};
548
549static struct platform_device wfd_device = {
550 .name = "msm_wfd",
551 .id = -1,
552};
553#endif
554
555#ifdef CONFIG_MSM_BUS_SCALING
556static struct msm_bus_vectors dtv_bus_init_vectors[] = {
557 {
558 .src = MSM_BUS_MASTER_MDP_PORT0,
559 .dst = MSM_BUS_SLAVE_EBI_CH0,
560 .ab = 0,
561 .ib = 0,
562 },
563};
564
565#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
566static struct msm_bus_vectors dtv_bus_def_vectors[] = {
567 {
568 .src = MSM_BUS_MASTER_MDP_PORT0,
569 .dst = MSM_BUS_SLAVE_EBI_CH0,
570 .ab = 2000000000,
571 .ib = 2000000000,
572 },
573};
574#else
575static struct msm_bus_vectors dtv_bus_def_vectors[] = {
576 {
577 .src = MSM_BUS_MASTER_MDP_PORT0,
578 .dst = MSM_BUS_SLAVE_EBI_CH0,
579 .ab = 566092800 * 2,
580 .ib = 707616000 * 2,
581 },
582};
583#endif
584
585static struct msm_bus_paths dtv_bus_scale_usecases[] = {
586 {
587 ARRAY_SIZE(dtv_bus_init_vectors),
588 dtv_bus_init_vectors,
589 },
590 {
591 ARRAY_SIZE(dtv_bus_def_vectors),
592 dtv_bus_def_vectors,
593 },
594};
595static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
596 dtv_bus_scale_usecases,
597 ARRAY_SIZE(dtv_bus_scale_usecases),
598 .name = "dtv",
599};
600
601static struct lcdc_platform_data dtv_pdata = {
602 .bus_scale_table = &dtv_bus_scale_pdata,
603};
604#endif
605
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800606#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800607static int hdmi_enable_5v(int on)
608{
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800609 static struct regulator *reg_ext_5v; /* HDMI_5V */
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800610 static int prev_on;
611 int rc;
612
613 if (on == prev_on)
614 return 0;
615
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800616 if (!reg_ext_5v)
617 reg_ext_5v = regulator_get(&hdmi_msm_device.dev,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800618 "hdmi_mvs");
619
620 if (on) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800621 rc = regulator_enable(reg_ext_5v);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800622 if (rc) {
623 pr_err("'%s' regulator enable failed, rc=%d\n",
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800624 "reg_ext_5v", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800625 return rc;
626 }
627 pr_debug("%s(on): success\n", __func__);
628 } else {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800629 rc = regulator_disable(reg_ext_5v);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800630 if (rc)
631 pr_warning("'%s' regulator disable failed, rc=%d\n",
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800632 "reg_ext_5v", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800633 pr_debug("%s(off): success\n", __func__);
634 }
635
636 prev_on = on;
637
638 return 0;
639}
640
641static int hdmi_core_power(int on, int show)
642{
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800643 /* Both HDMI "avdd" and "vcc" are powered by 8038_l23 regulator */
644 static struct regulator *reg_8038_l23;
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800645 static int prev_on;
646 int rc;
647
648 if (on == prev_on)
649 return 0;
650
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800651 if (!reg_8038_l23) {
652 reg_8038_l23 = regulator_get(&hdmi_msm_device.dev, "hdmi_avdd");
653 if (IS_ERR(reg_8038_l23)) {
654 pr_err("could not get reg_8038_l23, rc = %ld\n",
655 PTR_ERR(reg_8038_l23));
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800656 return -ENODEV;
657 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800658 rc = regulator_set_voltage(reg_8038_l23, 1800000, 1800000);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800659 if (rc) {
660 pr_err("set_voltage failed for 8921_l23, rc=%d\n", rc);
661 return -EINVAL;
662 }
663 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800664
665 if (on) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800666 rc = regulator_set_optimum_mode(reg_8038_l23, 100000);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800667 if (rc < 0) {
668 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
669 return -EINVAL;
670 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800671 rc = regulator_enable(reg_8038_l23);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800672 if (rc) {
673 pr_err("'%s' regulator enable failed, rc=%d\n",
674 "hdmi_avdd", rc);
675 return rc;
676 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800677 rc = gpio_request(100, "HDMI_DDC_CLK");
678 if (rc) {
679 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
680 "HDMI_DDC_CLK", 100, rc);
681 goto error1;
682 }
683 rc = gpio_request(101, "HDMI_DDC_DATA");
684 if (rc) {
685 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
686 "HDMI_DDC_DATA", 101, rc);
687 goto error2;
688 }
689 rc = gpio_request(102, "HDMI_HPD");
690 if (rc) {
691 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
692 "HDMI_HPD", 102, rc);
693 goto error3;
694 }
695 pr_debug("%s(on): success\n", __func__);
696 } else {
697 gpio_free(100);
698 gpio_free(101);
699 gpio_free(102);
700
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800701 rc = regulator_disable(reg_8038_l23);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800702 if (rc) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800703 pr_err("disable reg_8038_l23 failed, rc=%d\n", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800704 return -ENODEV;
705 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800706 rc = regulator_set_optimum_mode(reg_8038_l23, 100);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800707 if (rc < 0) {
708 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
709 return -EINVAL;
710 }
711 pr_debug("%s(off): success\n", __func__);
712 }
713
714 prev_on = on;
715
716 return 0;
717
718error3:
719 gpio_free(101);
720error2:
721 gpio_free(100);
722error1:
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800723 regulator_disable(reg_8038_l23);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800724 return rc;
725}
726
727static int hdmi_cec_power(int on)
728{
729 static int prev_on;
730 int rc;
731
732 if (on == prev_on)
733 return 0;
734
735 if (on) {
736 rc = gpio_request(99, "HDMI_CEC_VAR");
737 if (rc) {
738 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
739 "HDMI_CEC_VAR", 99, rc);
740 goto error;
741 }
742 pr_debug("%s(on): success\n", __func__);
743 } else {
744 gpio_free(99);
745 pr_debug("%s(off): success\n", __func__);
746 }
747
748 prev_on = on;
749
750 return 0;
751error:
752 return rc;
753}
754#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
755
756void __init msm8930_init_fb(void)
757{
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800758 platform_device_register(&msm_fb_device);
759
760#ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL
761 platform_device_register(&wfd_panel_device);
762 platform_device_register(&wfd_device);
763#endif
764
765 platform_device_register(&mipi_dsi_novatek_panel_device);
766
767#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Ajay Dudani52e88232011-12-13 13:33:10 -0800768 if (!cpu_is_msm8930())
Ajay Dudani9114be72011-12-03 07:46:35 -0800769 platform_device_register(&hdmi_msm_device);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800770#endif
771
772 platform_device_register(&mipi_dsi_toshiba_panel_device);
773
774 msm_fb_register_device("mdp", &mdp_pdata);
775 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
776#ifdef CONFIG_MSM_BUS_SCALING
777 msm_fb_register_device("dtv", &dtv_pdata);
778#endif
779}
780
781void __init msm8930_allocate_fb_region(void)
782{
783 void *addr;
784 unsigned long size;
785
786 size = MSM_FB_SIZE;
787 addr = alloc_bootmem_align(size, 0x1000);
788 msm_fb_resources[0].start = __pa(addr);
789 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
790 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
791 size, addr, __pa(addr));
792}