blob: aef957a9647146266d774ab76fcb74716c784067 [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
Ravishangar Kalyanama4286d72012-02-15 16:09:58 -080090#if !defined(CONFIG_FB_MSM_LVDS_MIPI_PANEL_DETECT) && \
91 !defined(CONFIG_FB_MSM_MIPI_PANEL_DETECT)
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080092 if (!strncmp(name, MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
93 strnlen(MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
94 PANEL_NAME_MAX_LEN)))
95 return 0;
96
Chandan Uddaraju59894ca2011-12-05 17:07:02 -080097 if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME,
98 strnlen(MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080099 PANEL_NAME_MAX_LEN)))
100 return 0;
101
102 if (!strncmp(name, MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME,
103 strnlen(MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME,
104 PANEL_NAME_MAX_LEN)))
105 return 0;
106
107 if (!strncmp(name, MIPI_CMD_RENESAS_FWVGA_PANEL_NAME,
108 strnlen(MIPI_CMD_RENESAS_FWVGA_PANEL_NAME,
109 PANEL_NAME_MAX_LEN)))
110 return 0;
111#endif
112
113 if (!strncmp(name, HDMI_PANEL_NAME,
114 strnlen(HDMI_PANEL_NAME,
115 PANEL_NAME_MAX_LEN)))
116 return 0;
117
118 if (!strncmp(name, TVOUT_PANEL_NAME,
119 strnlen(TVOUT_PANEL_NAME,
120 PANEL_NAME_MAX_LEN)))
121 return 0;
122
123 pr_warning("%s: not supported '%s'", __func__, name);
124 return -ENODEV;
125}
126
127static struct msm_fb_platform_data msm_fb_pdata = {
128 .detect_client = msm_fb_detect_panel,
129};
130
131static struct platform_device msm_fb_device = {
132 .name = "msm_fb",
133 .id = 0,
134 .num_resources = ARRAY_SIZE(msm_fb_resources),
135 .resource = msm_fb_resources,
136 .dev.platform_data = &msm_fb_pdata,
137};
138
139static bool dsi_power_on;
140
Jay Chokshi06fa7542011-12-07 13:09:17 -0800141/*
142 * TODO: When physical 8930/PM8038 hardware becomes
143 * available, replace mipi_dsi_cdp_panel_power with
144 * appropriate function.
145 */
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800146#define DISP_RST_GPIO 58
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800147static int mipi_dsi_cdp_panel_power(int on)
148{
149 static struct regulator *reg_l8, *reg_l23, *reg_l2;
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800150 int rc;
151
Jeff Ohlstein2cbe5ba2011-12-16 13:32:56 -0800152 pr_debug("%s: state : %d\n", __func__, on);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800153
154 if (!dsi_power_on) {
155
156 reg_l8 = regulator_get(&msm_mipi_dsi1_device.dev,
157 "dsi_vdc");
158 if (IS_ERR(reg_l8)) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800159 pr_err("could not get 8038_l8, rc = %ld\n",
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800160 PTR_ERR(reg_l8));
161 return -ENODEV;
162 }
163 reg_l23 = regulator_get(&msm_mipi_dsi1_device.dev,
164 "dsi_vddio");
165 if (IS_ERR(reg_l23)) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800166 pr_err("could not get 8038_l23, rc = %ld\n",
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800167 PTR_ERR(reg_l23));
168 return -ENODEV;
169 }
170 reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev,
171 "dsi_vdda");
172 if (IS_ERR(reg_l2)) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800173 pr_err("could not get 8038_l2, rc = %ld\n",
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800174 PTR_ERR(reg_l2));
175 return -ENODEV;
176 }
177 rc = regulator_set_voltage(reg_l8, 2800000, 3000000);
178 if (rc) {
179 pr_err("set_voltage l8 failed, rc=%d\n", rc);
180 return -EINVAL;
181 }
182 rc = regulator_set_voltage(reg_l23, 1800000, 1800000);
183 if (rc) {
184 pr_err("set_voltage l23 failed, rc=%d\n", rc);
185 return -EINVAL;
186 }
187 rc = regulator_set_voltage(reg_l2, 1200000, 1200000);
188 if (rc) {
189 pr_err("set_voltage l2 failed, rc=%d\n", rc);
190 return -EINVAL;
191 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800192 rc = gpio_request(DISP_RST_GPIO, "disp_rst_n");
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800193 if (rc) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800194 pr_err("request gpio DISP_RST_GPIO failed, rc=%d\n",
195 rc);
196 gpio_free(DISP_RST_GPIO);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800197 return -ENODEV;
198 }
199 dsi_power_on = true;
200 }
201 if (on) {
202 rc = regulator_set_optimum_mode(reg_l8, 100000);
203 if (rc < 0) {
204 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
205 return -EINVAL;
206 }
207 rc = regulator_set_optimum_mode(reg_l23, 100000);
208 if (rc < 0) {
209 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
210 return -EINVAL;
211 }
212 rc = regulator_set_optimum_mode(reg_l2, 100000);
213 if (rc < 0) {
214 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
215 return -EINVAL;
216 }
217 rc = regulator_enable(reg_l8);
218 if (rc) {
219 pr_err("enable l8 failed, rc=%d\n", rc);
220 return -ENODEV;
221 }
222 rc = regulator_enable(reg_l23);
223 if (rc) {
224 pr_err("enable l8 failed, rc=%d\n", rc);
225 return -ENODEV;
226 }
227 rc = regulator_enable(reg_l2);
228 if (rc) {
229 pr_err("enable l2 failed, rc=%d\n", rc);
230 return -ENODEV;
231 }
Ravishangar Kalyanam87c5fb62012-01-28 21:24:58 -0800232 usleep(10000);
233 gpio_set_value(DISP_RST_GPIO, 1);
234 usleep(10);
235 gpio_set_value(DISP_RST_GPIO, 0);
236 usleep(20);
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800237 gpio_set_value(DISP_RST_GPIO, 1);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800238 } else {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800239
240 gpio_set_value(DISP_RST_GPIO, 0);
241
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800242 rc = regulator_disable(reg_l2);
243 if (rc) {
244 pr_err("disable reg_l2 failed, rc=%d\n", rc);
245 return -ENODEV;
246 }
247 rc = regulator_disable(reg_l8);
248 if (rc) {
249 pr_err("disable reg_l8 failed, rc=%d\n", rc);
250 return -ENODEV;
251 }
252 rc = regulator_disable(reg_l23);
253 if (rc) {
254 pr_err("disable reg_l23 failed, rc=%d\n", rc);
255 return -ENODEV;
256 }
257 rc = regulator_set_optimum_mode(reg_l8, 100);
258 if (rc < 0) {
259 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
260 return -EINVAL;
261 }
262 rc = regulator_set_optimum_mode(reg_l23, 100);
263 if (rc < 0) {
264 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
265 return -EINVAL;
266 }
267 rc = regulator_set_optimum_mode(reg_l2, 100);
268 if (rc < 0) {
269 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
270 return -EINVAL;
271 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800272 }
273 return 0;
274}
275
276static int mipi_dsi_panel_power(int on)
277{
Jeff Ohlstein2cbe5ba2011-12-16 13:32:56 -0800278 pr_debug("%s: on=%d\n", __func__, on);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800279
280 return mipi_dsi_cdp_panel_power(on);
281}
282
283static struct mipi_dsi_platform_data mipi_dsi_pdata = {
284 .vsync_gpio = MDP_VSYNC_GPIO,
285 .dsi_power_save = mipi_dsi_panel_power,
286};
287
288#ifdef CONFIG_MSM_BUS_SCALING
289
290static struct msm_bus_vectors mdp_init_vectors[] = {
291 {
292 .src = MSM_BUS_MASTER_MDP_PORT0,
293 .dst = MSM_BUS_SLAVE_EBI_CH0,
294 .ab = 0,
295 .ib = 0,
296 },
297};
298
299#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
300static struct msm_bus_vectors hdmi_as_primary_vectors[] = {
301 /* If HDMI is used as primary */
302 {
303 .src = MSM_BUS_MASTER_MDP_PORT0,
304 .dst = MSM_BUS_SLAVE_EBI_CH0,
305 .ab = 2000000000,
306 .ib = 2000000000,
307 },
308};
309static struct msm_bus_paths mdp_bus_scale_usecases[] = {
310 {
311 ARRAY_SIZE(mdp_init_vectors),
312 mdp_init_vectors,
313 },
314 {
315 ARRAY_SIZE(hdmi_as_primary_vectors),
316 hdmi_as_primary_vectors,
317 },
318 {
319 ARRAY_SIZE(hdmi_as_primary_vectors),
320 hdmi_as_primary_vectors,
321 },
322 {
323 ARRAY_SIZE(hdmi_as_primary_vectors),
324 hdmi_as_primary_vectors,
325 },
326 {
327 ARRAY_SIZE(hdmi_as_primary_vectors),
328 hdmi_as_primary_vectors,
329 },
330 {
331 ARRAY_SIZE(hdmi_as_primary_vectors),
332 hdmi_as_primary_vectors,
333 },
334};
335#else
336static struct msm_bus_vectors mdp_ui_vectors[] = {
337 {
338 .src = MSM_BUS_MASTER_MDP_PORT0,
339 .dst = MSM_BUS_SLAVE_EBI_CH0,
340 .ab = 216000000 * 2,
341 .ib = 270000000 * 2,
342 },
343};
344
345static struct msm_bus_vectors mdp_vga_vectors[] = {
346 /* VGA and less video */
347 {
348 .src = MSM_BUS_MASTER_MDP_PORT0,
349 .dst = MSM_BUS_SLAVE_EBI_CH0,
350 .ab = 216000000 * 2,
351 .ib = 270000000 * 2,
352 },
353};
354
355static struct msm_bus_vectors mdp_720p_vectors[] = {
356 /* 720p and less video */
357 {
358 .src = MSM_BUS_MASTER_MDP_PORT0,
359 .dst = MSM_BUS_SLAVE_EBI_CH0,
360 .ab = 230400000 * 2,
361 .ib = 288000000 * 2,
362 },
363};
364
365static struct msm_bus_vectors mdp_1080p_vectors[] = {
366 /* 1080p and less video */
367 {
368 .src = MSM_BUS_MASTER_MDP_PORT0,
369 .dst = MSM_BUS_SLAVE_EBI_CH0,
370 .ab = 334080000 * 2,
371 .ib = 417600000 * 2,
372 },
373};
374
375static struct msm_bus_paths mdp_bus_scale_usecases[] = {
376 {
377 ARRAY_SIZE(mdp_init_vectors),
378 mdp_init_vectors,
379 },
380 {
381 ARRAY_SIZE(mdp_ui_vectors),
382 mdp_ui_vectors,
383 },
384 {
385 ARRAY_SIZE(mdp_ui_vectors),
386 mdp_ui_vectors,
387 },
388 {
389 ARRAY_SIZE(mdp_vga_vectors),
390 mdp_vga_vectors,
391 },
392 {
393 ARRAY_SIZE(mdp_720p_vectors),
394 mdp_720p_vectors,
395 },
396 {
397 ARRAY_SIZE(mdp_1080p_vectors),
398 mdp_1080p_vectors,
399 },
400};
401#endif
402
403static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
404 mdp_bus_scale_usecases,
405 ARRAY_SIZE(mdp_bus_scale_usecases),
406 .name = "mdp",
407};
408
409#endif
410
411#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
412static int mdp_core_clk_rate_table[] = {
413 200000000,
414 200000000,
415 200000000,
416 200000000,
417};
418#else
419static int mdp_core_clk_rate_table[] = {
420 85330000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -0800421 128000000,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800422 160000000,
423 200000000,
424};
425#endif
426
427static struct msm_panel_common_pdata mdp_pdata = {
428 .gpio = MDP_VSYNC_GPIO,
429#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
430 .mdp_core_clk_rate = 200000000,
431#else
432 .mdp_core_clk_rate = 85330000,
433#endif
434 .mdp_core_clk_table = mdp_core_clk_rate_table,
435 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
436#ifdef CONFIG_MSM_BUS_SCALING
437 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
438#endif
439 .mdp_rev = MDP_REV_42,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -0800440#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
441 .mem_hid = ION_CP_MM_HEAP_ID,
442#else
443 .mem_hid = MEMTYPE_EBI1,
444#endif
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800445};
446
Huaibin Yanga5419422011-12-08 23:52:10 -0800447void __init msm8930_mdp_writeback(struct memtype_reserve* reserve_table)
448{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -0800449 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
450 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
451#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
452 reserve_table[mdp_pdata.mem_hid].size +=
453 mdp_pdata.ov0_wb_size;
454 reserve_table[mdp_pdata.mem_hid].size +=
455 mdp_pdata.ov1_wb_size;
456#endif
Huaibin Yanga5419422011-12-08 23:52:10 -0800457}
458
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800459#define LPM_CHANNEL0 0
460static int toshiba_gpio[] = {LPM_CHANNEL0};
461
462static struct mipi_dsi_panel_platform_data toshiba_pdata = {
463 .gpio = toshiba_gpio,
464};
465
466static struct platform_device mipi_dsi_toshiba_panel_device = {
467 .name = "mipi_toshiba",
468 .id = 0,
469 .dev = {
470 .platform_data = &toshiba_pdata,
471 }
472};
473
474#define FPGA_3D_GPIO_CONFIG_ADDR 0xB5
475
476static struct mipi_dsi_phy_ctrl dsi_novatek_cmd_mode_phy_db = {
477
478/* DSI_BIT_CLK at 500MHz, 2 lane, RGB888 */
479 {0x0F, 0x0a, 0x04, 0x00, 0x20}, /* regulator */
480 /* timing */
481 {0xab, 0x8a, 0x18, 0x00, 0x92, 0x97, 0x1b, 0x8c,
482 0x0c, 0x03, 0x04, 0xa0},
483 {0x5f, 0x00, 0x00, 0x10}, /* phy ctrl */
484 {0xff, 0x00, 0x06, 0x00}, /* strength */
485 /* pll control */
486 {0x40, 0xf9, 0x30, 0xda, 0x00, 0x40, 0x03, 0x62,
487 0x40, 0x07, 0x03,
488 0x00, 0x1a, 0x00, 0x00, 0x02, 0x00, 0x20, 0x00, 0x01},
489};
490
491static struct mipi_dsi_panel_platform_data novatek_pdata = {
492 .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR,
493 .fpga_ctrl_mode = FPGA_SPI_INTF,
494 .phy_ctrl_settings = &dsi_novatek_cmd_mode_phy_db,
Ravishangar Kalyanam903f65c2012-01-28 21:36:22 -0800495 .dlane_swap = 0x1,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800496};
497
498static struct platform_device mipi_dsi_novatek_panel_device = {
499 .name = "mipi_novatek",
500 .id = 0,
501 .dev = {
502 .platform_data = &novatek_pdata,
503 }
504};
505
506#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
507static struct resource hdmi_msm_resources[] = {
508 {
509 .name = "hdmi_msm_qfprom_addr",
510 .start = 0x00700000,
511 .end = 0x007060FF,
512 .flags = IORESOURCE_MEM,
513 },
514 {
515 .name = "hdmi_msm_hdmi_addr",
516 .start = 0x04A00000,
517 .end = 0x04A00FFF,
518 .flags = IORESOURCE_MEM,
519 },
520 {
521 .name = "hdmi_msm_irq",
522 .start = HDMI_IRQ,
523 .end = HDMI_IRQ,
524 .flags = IORESOURCE_IRQ,
525 },
526};
527
528static int hdmi_enable_5v(int on);
529static int hdmi_core_power(int on, int show);
530static int hdmi_cec_power(int on);
531
532static struct msm_hdmi_platform_data hdmi_msm_data = {
533 .irq = HDMI_IRQ,
534 .enable_5v = hdmi_enable_5v,
535 .core_power = hdmi_core_power,
536 .cec_power = hdmi_cec_power,
537};
538
539static struct platform_device hdmi_msm_device = {
540 .name = "hdmi_msm",
541 .id = 0,
542 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
543 .resource = hdmi_msm_resources,
544 .dev.platform_data = &hdmi_msm_data,
545};
546#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
547
548#ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL
549static struct platform_device wfd_panel_device = {
550 .name = "wfd_panel",
551 .id = 0,
552 .dev.platform_data = NULL,
553};
554
555static struct platform_device wfd_device = {
556 .name = "msm_wfd",
557 .id = -1,
558};
559#endif
560
561#ifdef CONFIG_MSM_BUS_SCALING
562static struct msm_bus_vectors dtv_bus_init_vectors[] = {
563 {
564 .src = MSM_BUS_MASTER_MDP_PORT0,
565 .dst = MSM_BUS_SLAVE_EBI_CH0,
566 .ab = 0,
567 .ib = 0,
568 },
569};
570
571#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
572static struct msm_bus_vectors dtv_bus_def_vectors[] = {
573 {
574 .src = MSM_BUS_MASTER_MDP_PORT0,
575 .dst = MSM_BUS_SLAVE_EBI_CH0,
576 .ab = 2000000000,
577 .ib = 2000000000,
578 },
579};
580#else
581static struct msm_bus_vectors dtv_bus_def_vectors[] = {
582 {
583 .src = MSM_BUS_MASTER_MDP_PORT0,
584 .dst = MSM_BUS_SLAVE_EBI_CH0,
585 .ab = 566092800 * 2,
586 .ib = 707616000 * 2,
587 },
588};
589#endif
590
591static struct msm_bus_paths dtv_bus_scale_usecases[] = {
592 {
593 ARRAY_SIZE(dtv_bus_init_vectors),
594 dtv_bus_init_vectors,
595 },
596 {
597 ARRAY_SIZE(dtv_bus_def_vectors),
598 dtv_bus_def_vectors,
599 },
600};
601static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
602 dtv_bus_scale_usecases,
603 ARRAY_SIZE(dtv_bus_scale_usecases),
604 .name = "dtv",
605};
606
607static struct lcdc_platform_data dtv_pdata = {
608 .bus_scale_table = &dtv_bus_scale_pdata,
609};
610#endif
611
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800612#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800613static int hdmi_enable_5v(int on)
614{
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800615 static struct regulator *reg_ext_5v; /* HDMI_5V */
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800616 static int prev_on;
617 int rc;
618
619 if (on == prev_on)
620 return 0;
621
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800622 if (!reg_ext_5v)
623 reg_ext_5v = regulator_get(&hdmi_msm_device.dev,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800624 "hdmi_mvs");
625
626 if (on) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800627 rc = regulator_enable(reg_ext_5v);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800628 if (rc) {
629 pr_err("'%s' regulator enable failed, rc=%d\n",
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800630 "reg_ext_5v", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800631 return rc;
632 }
633 pr_debug("%s(on): success\n", __func__);
634 } else {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800635 rc = regulator_disable(reg_ext_5v);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800636 if (rc)
637 pr_warning("'%s' regulator disable failed, rc=%d\n",
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800638 "reg_ext_5v", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800639 pr_debug("%s(off): success\n", __func__);
640 }
641
642 prev_on = on;
643
644 return 0;
645}
646
647static int hdmi_core_power(int on, int show)
648{
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800649 /* Both HDMI "avdd" and "vcc" are powered by 8038_l23 regulator */
650 static struct regulator *reg_8038_l23;
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800651 static int prev_on;
652 int rc;
653
654 if (on == prev_on)
655 return 0;
656
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800657 if (!reg_8038_l23) {
658 reg_8038_l23 = regulator_get(&hdmi_msm_device.dev, "hdmi_avdd");
659 if (IS_ERR(reg_8038_l23)) {
660 pr_err("could not get reg_8038_l23, rc = %ld\n",
661 PTR_ERR(reg_8038_l23));
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800662 return -ENODEV;
663 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800664 rc = regulator_set_voltage(reg_8038_l23, 1800000, 1800000);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800665 if (rc) {
666 pr_err("set_voltage failed for 8921_l23, rc=%d\n", rc);
667 return -EINVAL;
668 }
669 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800670
671 if (on) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800672 rc = regulator_set_optimum_mode(reg_8038_l23, 100000);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800673 if (rc < 0) {
674 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
675 return -EINVAL;
676 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800677 rc = regulator_enable(reg_8038_l23);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800678 if (rc) {
679 pr_err("'%s' regulator enable failed, rc=%d\n",
680 "hdmi_avdd", rc);
681 return rc;
682 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800683 rc = gpio_request(100, "HDMI_DDC_CLK");
684 if (rc) {
685 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
686 "HDMI_DDC_CLK", 100, rc);
687 goto error1;
688 }
689 rc = gpio_request(101, "HDMI_DDC_DATA");
690 if (rc) {
691 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
692 "HDMI_DDC_DATA", 101, rc);
693 goto error2;
694 }
695 rc = gpio_request(102, "HDMI_HPD");
696 if (rc) {
697 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
698 "HDMI_HPD", 102, rc);
699 goto error3;
700 }
701 pr_debug("%s(on): success\n", __func__);
702 } else {
703 gpio_free(100);
704 gpio_free(101);
705 gpio_free(102);
706
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800707 rc = regulator_disable(reg_8038_l23);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800708 if (rc) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800709 pr_err("disable reg_8038_l23 failed, rc=%d\n", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800710 return -ENODEV;
711 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800712 rc = regulator_set_optimum_mode(reg_8038_l23, 100);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800713 if (rc < 0) {
714 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
715 return -EINVAL;
716 }
717 pr_debug("%s(off): success\n", __func__);
718 }
719
720 prev_on = on;
721
722 return 0;
723
724error3:
725 gpio_free(101);
726error2:
727 gpio_free(100);
728error1:
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800729 regulator_disable(reg_8038_l23);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800730 return rc;
731}
732
733static int hdmi_cec_power(int on)
734{
735 static int prev_on;
736 int rc;
737
738 if (on == prev_on)
739 return 0;
740
741 if (on) {
742 rc = gpio_request(99, "HDMI_CEC_VAR");
743 if (rc) {
744 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
745 "HDMI_CEC_VAR", 99, rc);
746 goto error;
747 }
748 pr_debug("%s(on): success\n", __func__);
749 } else {
750 gpio_free(99);
751 pr_debug("%s(off): success\n", __func__);
752 }
753
754 prev_on = on;
755
756 return 0;
757error:
758 return rc;
759}
760#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
761
762void __init msm8930_init_fb(void)
763{
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800764 platform_device_register(&msm_fb_device);
765
766#ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL
767 platform_device_register(&wfd_panel_device);
768 platform_device_register(&wfd_device);
769#endif
770
771 platform_device_register(&mipi_dsi_novatek_panel_device);
772
773#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Ajay Dudani52e88232011-12-13 13:33:10 -0800774 if (!cpu_is_msm8930())
Ajay Dudani9114be72011-12-03 07:46:35 -0800775 platform_device_register(&hdmi_msm_device);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800776#endif
777
778 platform_device_register(&mipi_dsi_toshiba_panel_device);
779
780 msm_fb_register_device("mdp", &mdp_pdata);
781 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
782#ifdef CONFIG_MSM_BUS_SCALING
783 msm_fb_register_device("dtv", &dtv_pdata);
784#endif
785}
786
787void __init msm8930_allocate_fb_region(void)
788{
789 void *addr;
790 unsigned long size;
791
792 size = MSM_FB_SIZE;
793 addr = alloc_bootmem_align(size, 0x1000);
794 msm_fb_resources[0].start = __pa(addr);
795 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
796 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
797 size, addr, __pa(addr));
798}