blob: e18e40d8481de527483e9c4ec048917eca38ff5f [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);
519
520static struct msm_hdmi_platform_data hdmi_msm_data = {
521 .irq = HDMI_IRQ,
522 .enable_5v = hdmi_enable_5v,
523 .core_power = hdmi_core_power,
524 .cec_power = hdmi_cec_power,
525};
526
527static struct platform_device hdmi_msm_device = {
528 .name = "hdmi_msm",
529 .id = 0,
530 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
531 .resource = hdmi_msm_resources,
532 .dev.platform_data = &hdmi_msm_data,
533};
534#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
535
536#ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL
537static struct platform_device wfd_panel_device = {
538 .name = "wfd_panel",
539 .id = 0,
540 .dev.platform_data = NULL,
541};
542
543static struct platform_device wfd_device = {
544 .name = "msm_wfd",
545 .id = -1,
546};
547#endif
548
549#ifdef CONFIG_MSM_BUS_SCALING
550static struct msm_bus_vectors dtv_bus_init_vectors[] = {
551 {
552 .src = MSM_BUS_MASTER_MDP_PORT0,
553 .dst = MSM_BUS_SLAVE_EBI_CH0,
554 .ab = 0,
555 .ib = 0,
556 },
557};
558
559#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
560static struct msm_bus_vectors dtv_bus_def_vectors[] = {
561 {
562 .src = MSM_BUS_MASTER_MDP_PORT0,
563 .dst = MSM_BUS_SLAVE_EBI_CH0,
564 .ab = 2000000000,
565 .ib = 2000000000,
566 },
567};
568#else
569static struct msm_bus_vectors dtv_bus_def_vectors[] = {
570 {
571 .src = MSM_BUS_MASTER_MDP_PORT0,
572 .dst = MSM_BUS_SLAVE_EBI_CH0,
573 .ab = 566092800 * 2,
574 .ib = 707616000 * 2,
575 },
576};
577#endif
578
579static struct msm_bus_paths dtv_bus_scale_usecases[] = {
580 {
581 ARRAY_SIZE(dtv_bus_init_vectors),
582 dtv_bus_init_vectors,
583 },
584 {
585 ARRAY_SIZE(dtv_bus_def_vectors),
586 dtv_bus_def_vectors,
587 },
588};
589static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
590 dtv_bus_scale_usecases,
591 ARRAY_SIZE(dtv_bus_scale_usecases),
592 .name = "dtv",
593};
594
595static struct lcdc_platform_data dtv_pdata = {
596 .bus_scale_table = &dtv_bus_scale_pdata,
597};
598#endif
599
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800600#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800601static int hdmi_enable_5v(int on)
602{
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800603 static struct regulator *reg_ext_5v; /* HDMI_5V */
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800604 static int prev_on;
605 int rc;
606
607 if (on == prev_on)
608 return 0;
609
Ajay Singh Parmar07847642011-12-09 02:57:45 +0530610 if (!reg_ext_5v) {
611 reg_ext_5v = regulator_get(&hdmi_msm_device.dev, "hdmi_mvs");
612 if (IS_ERR(reg_ext_5v)) {
613 pr_err("'%s' regulator not found, rc=%ld\n",
614 "hdmi_mvs", IS_ERR(reg_ext_5v));
615 reg_ext_5v = NULL;
616 return -ENODEV;
617 }
618 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800619
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
Aravind Venkateswaranfff132d2012-03-07 13:22:30 -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}