blob: 8a837d632175f2c59878b34cb828288b9b447cb5 [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>
Steve Mucklef132c6c2012-06-06 18:30:57 -070018#include <linux/gpio.h>
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080019#include <asm/mach-types.h>
20#include <mach/msm_bus_board.h>
Huaibin Yanga5419422011-12-08 23:52:10 -080021#include <mach/msm_memtypes.h>
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080022#include <mach/board.h>
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080023#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
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +053032#define MSM_FB_PRIM_BUF_SIZE \
Huaibin Yangc8946d42012-05-04 17:22:02 -070033 (roundup((1920 * 1088 * 4), 4096) * 3) /* 4 bpp x 3 pages */
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080034#else
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +053035#define MSM_FB_PRIM_BUF_SIZE \
Huaibin Yangc8946d42012-05-04 17:22:02 -070036 (roundup((1920 * 1088 * 4), 4096) * 2) /* 4 bpp x 2 pages */
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080037#endif
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080038/* Note: must be multiple of 4096 */
Huaibin Yangc8946d42012-05-04 17:22:02 -070039#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE, 4096)
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080040
Huaibin Yanga5419422011-12-08 23:52:10 -080041#ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK
42#define MSM_FB_OVERLAY0_WRITEBACK_SIZE roundup((1376 * 768 * 3 * 2), 4096)
43#else
44#define MSM_FB_OVERLAY0_WRITEBACK_SIZE (0)
45#endif /* CONFIG_FB_MSM_OVERLAY0_WRITEBACK */
46
47#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
48#define MSM_FB_OVERLAY1_WRITEBACK_SIZE roundup((1920 * 1088 * 3 * 2), 4096)
49#else
50#define MSM_FB_OVERLAY1_WRITEBACK_SIZE (0)
51#endif /* CONFIG_FB_MSM_OVERLAY1_WRITEBACK */
52
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080053#define MDP_VSYNC_GPIO 0
54
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080055#define MIPI_CMD_NOVATEK_QHD_PANEL_NAME "mipi_cmd_novatek_qhd"
56#define MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME "mipi_video_novatek_qhd"
57#define MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME "mipi_video_toshiba_wsvga"
58#define MIPI_VIDEO_CHIMEI_WXGA_PANEL_NAME "mipi_video_chimei_wxga"
59#define MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME "mipi_video_simulator_vga"
60#define MIPI_CMD_RENESAS_FWVGA_PANEL_NAME "mipi_cmd_renesas_fwvga"
61#define HDMI_PANEL_NAME "hdmi_msm"
62#define TVOUT_PANEL_NAME "tvout_msm"
63
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080064static struct resource msm_fb_resources[] = {
65 {
66 .flags = IORESOURCE_DMA,
67 }
68};
69
70static int msm_fb_detect_panel(const char *name)
71{
Chandan Uddaraju59894ca2011-12-05 17:07:02 -080072 if (!strncmp(name, MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
73 strnlen(MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080074 PANEL_NAME_MAX_LEN)))
75 return 0;
76
Ravishangar Kalyanama4286d72012-02-15 16:09:58 -080077#if !defined(CONFIG_FB_MSM_LVDS_MIPI_PANEL_DETECT) && \
78 !defined(CONFIG_FB_MSM_MIPI_PANEL_DETECT)
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080079 if (!strncmp(name, MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
80 strnlen(MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
81 PANEL_NAME_MAX_LEN)))
82 return 0;
83
Chandan Uddaraju59894ca2011-12-05 17:07:02 -080084 if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME,
85 strnlen(MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080086 PANEL_NAME_MAX_LEN)))
87 return 0;
88
89 if (!strncmp(name, MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME,
90 strnlen(MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME,
91 PANEL_NAME_MAX_LEN)))
92 return 0;
93
94 if (!strncmp(name, MIPI_CMD_RENESAS_FWVGA_PANEL_NAME,
95 strnlen(MIPI_CMD_RENESAS_FWVGA_PANEL_NAME,
96 PANEL_NAME_MAX_LEN)))
97 return 0;
98#endif
99
100 if (!strncmp(name, HDMI_PANEL_NAME,
101 strnlen(HDMI_PANEL_NAME,
102 PANEL_NAME_MAX_LEN)))
103 return 0;
104
105 if (!strncmp(name, TVOUT_PANEL_NAME,
106 strnlen(TVOUT_PANEL_NAME,
107 PANEL_NAME_MAX_LEN)))
108 return 0;
109
110 pr_warning("%s: not supported '%s'", __func__, name);
111 return -ENODEV;
112}
113
114static struct msm_fb_platform_data msm_fb_pdata = {
115 .detect_client = msm_fb_detect_panel,
116};
117
118static struct platform_device msm_fb_device = {
119 .name = "msm_fb",
120 .id = 0,
121 .num_resources = ARRAY_SIZE(msm_fb_resources),
122 .resource = msm_fb_resources,
123 .dev.platform_data = &msm_fb_pdata,
124};
125
126static bool dsi_power_on;
127
Jay Chokshi06fa7542011-12-07 13:09:17 -0800128/*
129 * TODO: When physical 8930/PM8038 hardware becomes
130 * available, replace mipi_dsi_cdp_panel_power with
131 * appropriate function.
132 */
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800133#define DISP_RST_GPIO 58
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800134static int mipi_dsi_cdp_panel_power(int on)
135{
136 static struct regulator *reg_l8, *reg_l23, *reg_l2;
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800137 int rc;
138
Jeff Ohlstein2cbe5ba2011-12-16 13:32:56 -0800139 pr_debug("%s: state : %d\n", __func__, on);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800140
141 if (!dsi_power_on) {
142
143 reg_l8 = regulator_get(&msm_mipi_dsi1_device.dev,
144 "dsi_vdc");
145 if (IS_ERR(reg_l8)) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800146 pr_err("could not get 8038_l8, rc = %ld\n",
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800147 PTR_ERR(reg_l8));
148 return -ENODEV;
149 }
150 reg_l23 = regulator_get(&msm_mipi_dsi1_device.dev,
151 "dsi_vddio");
152 if (IS_ERR(reg_l23)) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800153 pr_err("could not get 8038_l23, rc = %ld\n",
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800154 PTR_ERR(reg_l23));
155 return -ENODEV;
156 }
157 reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev,
158 "dsi_vdda");
159 if (IS_ERR(reg_l2)) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800160 pr_err("could not get 8038_l2, rc = %ld\n",
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800161 PTR_ERR(reg_l2));
162 return -ENODEV;
163 }
164 rc = regulator_set_voltage(reg_l8, 2800000, 3000000);
165 if (rc) {
166 pr_err("set_voltage l8 failed, rc=%d\n", rc);
167 return -EINVAL;
168 }
169 rc = regulator_set_voltage(reg_l23, 1800000, 1800000);
170 if (rc) {
171 pr_err("set_voltage l23 failed, rc=%d\n", rc);
172 return -EINVAL;
173 }
174 rc = regulator_set_voltage(reg_l2, 1200000, 1200000);
175 if (rc) {
176 pr_err("set_voltage l2 failed, rc=%d\n", rc);
177 return -EINVAL;
178 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800179 rc = gpio_request(DISP_RST_GPIO, "disp_rst_n");
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800180 if (rc) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800181 pr_err("request gpio DISP_RST_GPIO failed, rc=%d\n",
182 rc);
183 gpio_free(DISP_RST_GPIO);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800184 return -ENODEV;
185 }
186 dsi_power_on = true;
187 }
188 if (on) {
189 rc = regulator_set_optimum_mode(reg_l8, 100000);
190 if (rc < 0) {
191 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
192 return -EINVAL;
193 }
194 rc = regulator_set_optimum_mode(reg_l23, 100000);
195 if (rc < 0) {
196 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
197 return -EINVAL;
198 }
199 rc = regulator_set_optimum_mode(reg_l2, 100000);
200 if (rc < 0) {
201 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
202 return -EINVAL;
203 }
204 rc = regulator_enable(reg_l8);
205 if (rc) {
206 pr_err("enable l8 failed, rc=%d\n", rc);
207 return -ENODEV;
208 }
209 rc = regulator_enable(reg_l23);
210 if (rc) {
211 pr_err("enable l8 failed, rc=%d\n", rc);
212 return -ENODEV;
213 }
214 rc = regulator_enable(reg_l2);
215 if (rc) {
216 pr_err("enable l2 failed, rc=%d\n", rc);
217 return -ENODEV;
218 }
Ravishangar Kalyanam87c5fb62012-01-28 21:24:58 -0800219 usleep(10000);
220 gpio_set_value(DISP_RST_GPIO, 1);
221 usleep(10);
222 gpio_set_value(DISP_RST_GPIO, 0);
223 usleep(20);
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800224 gpio_set_value(DISP_RST_GPIO, 1);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800225 } else {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800226
227 gpio_set_value(DISP_RST_GPIO, 0);
228
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800229 rc = regulator_disable(reg_l2);
230 if (rc) {
231 pr_err("disable reg_l2 failed, rc=%d\n", rc);
232 return -ENODEV;
233 }
234 rc = regulator_disable(reg_l8);
235 if (rc) {
236 pr_err("disable reg_l8 failed, rc=%d\n", rc);
237 return -ENODEV;
238 }
239 rc = regulator_disable(reg_l23);
240 if (rc) {
241 pr_err("disable reg_l23 failed, rc=%d\n", rc);
242 return -ENODEV;
243 }
244 rc = regulator_set_optimum_mode(reg_l8, 100);
245 if (rc < 0) {
246 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
247 return -EINVAL;
248 }
249 rc = regulator_set_optimum_mode(reg_l23, 100);
250 if (rc < 0) {
251 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
252 return -EINVAL;
253 }
254 rc = regulator_set_optimum_mode(reg_l2, 100);
255 if (rc < 0) {
256 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
257 return -EINVAL;
258 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800259 }
260 return 0;
261}
262
263static int mipi_dsi_panel_power(int on)
264{
Jeff Ohlstein2cbe5ba2011-12-16 13:32:56 -0800265 pr_debug("%s: on=%d\n", __func__, on);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800266
267 return mipi_dsi_cdp_panel_power(on);
268}
269
270static struct mipi_dsi_platform_data mipi_dsi_pdata = {
271 .vsync_gpio = MDP_VSYNC_GPIO,
272 .dsi_power_save = mipi_dsi_panel_power,
273};
274
275#ifdef CONFIG_MSM_BUS_SCALING
276
277static struct msm_bus_vectors mdp_init_vectors[] = {
278 {
279 .src = MSM_BUS_MASTER_MDP_PORT0,
280 .dst = MSM_BUS_SLAVE_EBI_CH0,
281 .ab = 0,
282 .ib = 0,
283 },
284};
285
286#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
287static struct msm_bus_vectors hdmi_as_primary_vectors[] = {
288 /* If HDMI is used as primary */
289 {
290 .src = MSM_BUS_MASTER_MDP_PORT0,
291 .dst = MSM_BUS_SLAVE_EBI_CH0,
292 .ab = 2000000000,
293 .ib = 2000000000,
294 },
295};
296static struct msm_bus_paths mdp_bus_scale_usecases[] = {
297 {
298 ARRAY_SIZE(mdp_init_vectors),
299 mdp_init_vectors,
300 },
301 {
302 ARRAY_SIZE(hdmi_as_primary_vectors),
303 hdmi_as_primary_vectors,
304 },
305 {
306 ARRAY_SIZE(hdmi_as_primary_vectors),
307 hdmi_as_primary_vectors,
308 },
309 {
310 ARRAY_SIZE(hdmi_as_primary_vectors),
311 hdmi_as_primary_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#else
323static struct msm_bus_vectors mdp_ui_vectors[] = {
324 {
325 .src = MSM_BUS_MASTER_MDP_PORT0,
326 .dst = MSM_BUS_SLAVE_EBI_CH0,
327 .ab = 216000000 * 2,
328 .ib = 270000000 * 2,
329 },
330};
331
332static struct msm_bus_vectors mdp_vga_vectors[] = {
333 /* VGA and less video */
334 {
335 .src = MSM_BUS_MASTER_MDP_PORT0,
336 .dst = MSM_BUS_SLAVE_EBI_CH0,
337 .ab = 216000000 * 2,
338 .ib = 270000000 * 2,
339 },
340};
341
342static struct msm_bus_vectors mdp_720p_vectors[] = {
343 /* 720p and less video */
344 {
345 .src = MSM_BUS_MASTER_MDP_PORT0,
346 .dst = MSM_BUS_SLAVE_EBI_CH0,
347 .ab = 230400000 * 2,
348 .ib = 288000000 * 2,
349 },
350};
351
352static struct msm_bus_vectors mdp_1080p_vectors[] = {
353 /* 1080p and less video */
354 {
355 .src = MSM_BUS_MASTER_MDP_PORT0,
356 .dst = MSM_BUS_SLAVE_EBI_CH0,
357 .ab = 334080000 * 2,
358 .ib = 417600000 * 2,
359 },
360};
361
362static struct msm_bus_paths mdp_bus_scale_usecases[] = {
363 {
364 ARRAY_SIZE(mdp_init_vectors),
365 mdp_init_vectors,
366 },
367 {
368 ARRAY_SIZE(mdp_ui_vectors),
369 mdp_ui_vectors,
370 },
371 {
372 ARRAY_SIZE(mdp_ui_vectors),
373 mdp_ui_vectors,
374 },
375 {
376 ARRAY_SIZE(mdp_vga_vectors),
377 mdp_vga_vectors,
378 },
379 {
380 ARRAY_SIZE(mdp_720p_vectors),
381 mdp_720p_vectors,
382 },
383 {
384 ARRAY_SIZE(mdp_1080p_vectors),
385 mdp_1080p_vectors,
386 },
387};
388#endif
389
390static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
391 mdp_bus_scale_usecases,
392 ARRAY_SIZE(mdp_bus_scale_usecases),
393 .name = "mdp",
394};
395
396#endif
397
398#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
399static int mdp_core_clk_rate_table[] = {
400 200000000,
401 200000000,
402 200000000,
403 200000000,
404};
405#else
406static int mdp_core_clk_rate_table[] = {
407 85330000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -0800408 128000000,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800409 160000000,
410 200000000,
411};
412#endif
413
414static struct msm_panel_common_pdata mdp_pdata = {
415 .gpio = MDP_VSYNC_GPIO,
416#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
417 .mdp_core_clk_rate = 200000000,
418#else
419 .mdp_core_clk_rate = 85330000,
420#endif
421 .mdp_core_clk_table = mdp_core_clk_rate_table,
422 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
423#ifdef CONFIG_MSM_BUS_SCALING
424 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
425#endif
426 .mdp_rev = MDP_REV_42,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -0800427#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Ravishangar Kalyanama3b168b2012-03-26 11:13:11 -0700428 .mem_hid = BIT(ION_CP_MM_HEAP_ID),
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -0800429#else
430 .mem_hid = MEMTYPE_EBI1,
431#endif
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800432};
433
Huaibin Yanga5419422011-12-08 23:52:10 -0800434void __init msm8930_mdp_writeback(struct memtype_reserve* reserve_table)
435{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -0800436 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
437 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
438#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
439 reserve_table[mdp_pdata.mem_hid].size +=
440 mdp_pdata.ov0_wb_size;
441 reserve_table[mdp_pdata.mem_hid].size +=
442 mdp_pdata.ov1_wb_size;
443#endif
Huaibin Yanga5419422011-12-08 23:52:10 -0800444}
445
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800446#define LPM_CHANNEL0 0
447static int toshiba_gpio[] = {LPM_CHANNEL0};
448
449static struct mipi_dsi_panel_platform_data toshiba_pdata = {
450 .gpio = toshiba_gpio,
451};
452
453static struct platform_device mipi_dsi_toshiba_panel_device = {
454 .name = "mipi_toshiba",
455 .id = 0,
456 .dev = {
457 .platform_data = &toshiba_pdata,
458 }
459};
460
461#define FPGA_3D_GPIO_CONFIG_ADDR 0xB5
462
463static struct mipi_dsi_phy_ctrl dsi_novatek_cmd_mode_phy_db = {
464
465/* DSI_BIT_CLK at 500MHz, 2 lane, RGB888 */
466 {0x0F, 0x0a, 0x04, 0x00, 0x20}, /* regulator */
467 /* timing */
468 {0xab, 0x8a, 0x18, 0x00, 0x92, 0x97, 0x1b, 0x8c,
469 0x0c, 0x03, 0x04, 0xa0},
470 {0x5f, 0x00, 0x00, 0x10}, /* phy ctrl */
471 {0xff, 0x00, 0x06, 0x00}, /* strength */
472 /* pll control */
473 {0x40, 0xf9, 0x30, 0xda, 0x00, 0x40, 0x03, 0x62,
474 0x40, 0x07, 0x03,
475 0x00, 0x1a, 0x00, 0x00, 0x02, 0x00, 0x20, 0x00, 0x01},
476};
477
478static struct mipi_dsi_panel_platform_data novatek_pdata = {
479 .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR,
480 .fpga_ctrl_mode = FPGA_SPI_INTF,
481 .phy_ctrl_settings = &dsi_novatek_cmd_mode_phy_db,
Ravishangar Kalyanam903f65c2012-01-28 21:36:22 -0800482 .dlane_swap = 0x1,
Chandan Uddaraju194a4b52012-03-21 10:11:18 -0700483 .enable_wled_bl_ctrl = 0x1,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800484};
485
486static struct platform_device mipi_dsi_novatek_panel_device = {
487 .name = "mipi_novatek",
488 .id = 0,
489 .dev = {
490 .platform_data = &novatek_pdata,
491 }
492};
493
494#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
495static struct resource hdmi_msm_resources[] = {
496 {
497 .name = "hdmi_msm_qfprom_addr",
498 .start = 0x00700000,
499 .end = 0x007060FF,
500 .flags = IORESOURCE_MEM,
501 },
502 {
503 .name = "hdmi_msm_hdmi_addr",
504 .start = 0x04A00000,
505 .end = 0x04A00FFF,
506 .flags = IORESOURCE_MEM,
507 },
508 {
509 .name = "hdmi_msm_irq",
510 .start = HDMI_IRQ,
511 .end = HDMI_IRQ,
512 .flags = IORESOURCE_IRQ,
513 },
514};
515
516static int hdmi_enable_5v(int on);
517static int hdmi_core_power(int on, int show);
518static int hdmi_cec_power(int on);
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +0530519static int hdmi_gpio_config(int on);
520static int hdmi_panel_power(int on);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800521
522static struct msm_hdmi_platform_data hdmi_msm_data = {
523 .irq = HDMI_IRQ,
524 .enable_5v = hdmi_enable_5v,
525 .core_power = hdmi_core_power,
526 .cec_power = hdmi_cec_power,
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +0530527 .panel_power = hdmi_panel_power,
528 .gpio_config = hdmi_gpio_config,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800529};
530
531static struct platform_device hdmi_msm_device = {
532 .name = "hdmi_msm",
533 .id = 0,
534 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
535 .resource = hdmi_msm_resources,
536 .dev.platform_data = &hdmi_msm_data,
537};
538#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
539
540#ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL
541static struct platform_device wfd_panel_device = {
542 .name = "wfd_panel",
543 .id = 0,
544 .dev.platform_data = NULL,
545};
546
547static struct platform_device wfd_device = {
548 .name = "msm_wfd",
549 .id = -1,
550};
551#endif
552
553#ifdef CONFIG_MSM_BUS_SCALING
554static struct msm_bus_vectors dtv_bus_init_vectors[] = {
555 {
556 .src = MSM_BUS_MASTER_MDP_PORT0,
557 .dst = MSM_BUS_SLAVE_EBI_CH0,
558 .ab = 0,
559 .ib = 0,
560 },
561};
562
563#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
564static struct msm_bus_vectors dtv_bus_def_vectors[] = {
565 {
566 .src = MSM_BUS_MASTER_MDP_PORT0,
567 .dst = MSM_BUS_SLAVE_EBI_CH0,
568 .ab = 2000000000,
569 .ib = 2000000000,
570 },
571};
572#else
573static struct msm_bus_vectors dtv_bus_def_vectors[] = {
574 {
575 .src = MSM_BUS_MASTER_MDP_PORT0,
576 .dst = MSM_BUS_SLAVE_EBI_CH0,
577 .ab = 566092800 * 2,
578 .ib = 707616000 * 2,
579 },
580};
581#endif
582
583static struct msm_bus_paths dtv_bus_scale_usecases[] = {
584 {
585 ARRAY_SIZE(dtv_bus_init_vectors),
586 dtv_bus_init_vectors,
587 },
588 {
589 ARRAY_SIZE(dtv_bus_def_vectors),
590 dtv_bus_def_vectors,
591 },
592};
593static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
594 dtv_bus_scale_usecases,
595 ARRAY_SIZE(dtv_bus_scale_usecases),
596 .name = "dtv",
597};
598
599static struct lcdc_platform_data dtv_pdata = {
600 .bus_scale_table = &dtv_bus_scale_pdata,
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +0530601 .lcdc_power_save = hdmi_panel_power,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800602};
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +0530603
604static int hdmi_panel_power(int on)
605{
606 int rc;
607
608 pr_debug("%s: HDMI Core: %s\n", __func__, (on ? "ON" : "OFF"));
609 rc = hdmi_core_power(on, 1);
610 if (rc)
611 rc = hdmi_cec_power(on);
612
613 pr_debug("%s: HDMI Core: %s Success\n", __func__, (on ? "ON" : "OFF"));
614 return rc;
615}
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800616#endif
617
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800618#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800619static int hdmi_enable_5v(int on)
620{
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800621 static struct regulator *reg_ext_5v; /* HDMI_5V */
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800622 static int prev_on;
623 int rc;
624
625 if (on == prev_on)
626 return 0;
627
Ajay Singh Parmar07847642011-12-09 02:57:45 +0530628 if (!reg_ext_5v) {
629 reg_ext_5v = regulator_get(&hdmi_msm_device.dev, "hdmi_mvs");
630 if (IS_ERR(reg_ext_5v)) {
631 pr_err("'%s' regulator not found, rc=%ld\n",
632 "hdmi_mvs", IS_ERR(reg_ext_5v));
633 reg_ext_5v = NULL;
634 return -ENODEV;
635 }
636 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800637
638 if (on) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800639 rc = regulator_enable(reg_ext_5v);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800640 if (rc) {
641 pr_err("'%s' regulator enable failed, rc=%d\n",
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800642 "reg_ext_5v", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800643 return rc;
644 }
645 pr_debug("%s(on): success\n", __func__);
646 } else {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800647 rc = regulator_disable(reg_ext_5v);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800648 if (rc)
649 pr_warning("'%s' regulator disable failed, rc=%d\n",
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800650 "reg_ext_5v", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800651 pr_debug("%s(off): success\n", __func__);
652 }
653
654 prev_on = on;
655
656 return 0;
657}
658
659static int hdmi_core_power(int on, int show)
660{
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800661 /* Both HDMI "avdd" and "vcc" are powered by 8038_l23 regulator */
662 static struct regulator *reg_8038_l23;
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800663 static int prev_on;
664 int rc;
665
666 if (on == prev_on)
667 return 0;
668
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800669 if (!reg_8038_l23) {
670 reg_8038_l23 = regulator_get(&hdmi_msm_device.dev, "hdmi_avdd");
671 if (IS_ERR(reg_8038_l23)) {
672 pr_err("could not get reg_8038_l23, rc = %ld\n",
673 PTR_ERR(reg_8038_l23));
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800674 return -ENODEV;
675 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800676 rc = regulator_set_voltage(reg_8038_l23, 1800000, 1800000);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800677 if (rc) {
678 pr_err("set_voltage failed for 8921_l23, rc=%d\n", rc);
679 return -EINVAL;
680 }
681 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800682
683 if (on) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800684 rc = regulator_set_optimum_mode(reg_8038_l23, 100000);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800685 if (rc < 0) {
686 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
687 return -EINVAL;
688 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800689 rc = regulator_enable(reg_8038_l23);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800690 if (rc) {
691 pr_err("'%s' regulator enable failed, rc=%d\n",
692 "hdmi_avdd", rc);
693 return rc;
694 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800695 pr_debug("%s(on): success\n", __func__);
696 } else {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800697 rc = regulator_disable(reg_8038_l23);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800698 if (rc) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800699 pr_err("disable reg_8038_l23 failed, rc=%d\n", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800700 return -ENODEV;
701 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800702 rc = regulator_set_optimum_mode(reg_8038_l23, 100);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800703 if (rc < 0) {
704 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
705 return -EINVAL;
706 }
707 pr_debug("%s(off): success\n", __func__);
708 }
709
710 prev_on = on;
711
712 return 0;
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +0530713}
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800714
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +0530715static int hdmi_gpio_config(int on)
716{
717 int rc = 0;
718 static int prev_on;
719
720 if (on == prev_on)
721 return 0;
722
723 if (on) {
724 rc = gpio_request(100, "HDMI_DDC_CLK");
725 if (rc) {
726 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
727 "HDMI_DDC_CLK", 100, rc);
728 return rc;
729 }
730 rc = gpio_request(101, "HDMI_DDC_DATA");
731 if (rc) {
732 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
733 "HDMI_DDC_DATA", 101, rc);
734 goto error1;
735 }
736 rc = gpio_request(102, "HDMI_HPD");
737 if (rc) {
738 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
739 "HDMI_HPD", 102, rc);
740 goto error2;
741 }
742 pr_debug("%s(on): success\n", __func__);
743 } else {
744 gpio_free(100);
745 gpio_free(101);
746 gpio_free(102);
747 pr_debug("%s(off): success\n", __func__);
748 }
749
750 prev_on = on;
751 return 0;
752
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800753error2:
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +0530754 gpio_free(101);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800755error1:
Ajay Singh Parmar7d11c272012-06-07 12:25:31 +0530756 gpio_free(100);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800757 return rc;
758}
759
760static int hdmi_cec_power(int on)
761{
762 static int prev_on;
763 int rc;
764
765 if (on == prev_on)
766 return 0;
767
768 if (on) {
769 rc = gpio_request(99, "HDMI_CEC_VAR");
770 if (rc) {
771 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
772 "HDMI_CEC_VAR", 99, rc);
773 goto error;
774 }
775 pr_debug("%s(on): success\n", __func__);
776 } else {
777 gpio_free(99);
778 pr_debug("%s(off): success\n", __func__);
779 }
780
781 prev_on = on;
782
783 return 0;
784error:
785 return rc;
786}
787#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
788
789void __init msm8930_init_fb(void)
790{
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800791 platform_device_register(&msm_fb_device);
792
793#ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL
794 platform_device_register(&wfd_panel_device);
795 platform_device_register(&wfd_device);
796#endif
797
798 platform_device_register(&mipi_dsi_novatek_panel_device);
799
800#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Aravind Venkateswaranfff132d2012-03-07 13:22:30 -0800801 platform_device_register(&hdmi_msm_device);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800802#endif
803
804 platform_device_register(&mipi_dsi_toshiba_panel_device);
805
806 msm_fb_register_device("mdp", &mdp_pdata);
807 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
808#ifdef CONFIG_MSM_BUS_SCALING
809 msm_fb_register_device("dtv", &dtv_pdata);
810#endif
811}
812
813void __init msm8930_allocate_fb_region(void)
814{
815 void *addr;
816 unsigned long size;
817
818 size = MSM_FB_SIZE;
819 addr = alloc_bootmem_align(size, 0x1000);
820 msm_fb_resources[0].start = __pa(addr);
821 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
822 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
823 size, addr, __pa(addr));
824}