blob: 2f188970c93d76f883e3a69d94b5b63a2867a588 [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
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +053032#define MSM_FB_PRIM_BUF_SIZE \
33 (roundup((1376 * 768 * 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 \
36 (roundup((1376 * 768 * 4), 4096) * 2) /* 4 bpp x 2 pages */
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080037#endif
38
39#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +053040#define MSM_FB_EXT_BUF_SIZE \
41 (roundup((1920 * 1088 * 2), 4096) * 1) /* 2 bpp x 1 page */
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080042#elif defined(CONFIG_FB_MSM_TVOUT)
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +053043#define MSM_FB_EXT_BUF_SIZE \
44 (roundup((720 * 576 * 2), 4096) * 2) /* 2 bpp x 2 pages */
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080045#else
46#define MSM_FB_EXT_BUF_SIZE 0
47#endif
48
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080049#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
50/* 4 bpp x 2 page HDMI case */
51#define MSM_FB_SIZE roundup((1920 * 1088 * 4 * 2), 4096)
52#else
53/* Note: must be multiple of 4096 */
Huaibin Yang27634b82011-12-09 00:16:25 -080054#define MSM_FB_SIZE roundup(MSM_FB_PRIM_BUF_SIZE + MSM_FB_EXT_BUF_SIZE, 4096)
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080055#endif
56
Huaibin Yanga5419422011-12-08 23:52:10 -080057#ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK
58#define MSM_FB_OVERLAY0_WRITEBACK_SIZE roundup((1376 * 768 * 3 * 2), 4096)
59#else
60#define MSM_FB_OVERLAY0_WRITEBACK_SIZE (0)
61#endif /* CONFIG_FB_MSM_OVERLAY0_WRITEBACK */
62
63#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
64#define MSM_FB_OVERLAY1_WRITEBACK_SIZE roundup((1920 * 1088 * 3 * 2), 4096)
65#else
66#define MSM_FB_OVERLAY1_WRITEBACK_SIZE (0)
67#endif /* CONFIG_FB_MSM_OVERLAY1_WRITEBACK */
68
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080069#define MDP_VSYNC_GPIO 0
70
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080071#define MIPI_CMD_NOVATEK_QHD_PANEL_NAME "mipi_cmd_novatek_qhd"
72#define MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME "mipi_video_novatek_qhd"
73#define MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME "mipi_video_toshiba_wsvga"
74#define MIPI_VIDEO_CHIMEI_WXGA_PANEL_NAME "mipi_video_chimei_wxga"
75#define MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME "mipi_video_simulator_vga"
76#define MIPI_CMD_RENESAS_FWVGA_PANEL_NAME "mipi_cmd_renesas_fwvga"
77#define HDMI_PANEL_NAME "hdmi_msm"
78#define TVOUT_PANEL_NAME "tvout_msm"
79
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080080static struct resource msm_fb_resources[] = {
81 {
82 .flags = IORESOURCE_DMA,
83 }
84};
85
86static int msm_fb_detect_panel(const char *name)
87{
Chandan Uddaraju59894ca2011-12-05 17:07:02 -080088 if (!strncmp(name, MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
89 strnlen(MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080090 PANEL_NAME_MAX_LEN)))
91 return 0;
92
Ravishangar Kalyanama4286d72012-02-15 16:09:58 -080093#if !defined(CONFIG_FB_MSM_LVDS_MIPI_PANEL_DETECT) && \
94 !defined(CONFIG_FB_MSM_MIPI_PANEL_DETECT)
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080095 if (!strncmp(name, MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
96 strnlen(MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
97 PANEL_NAME_MAX_LEN)))
98 return 0;
99
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800100 if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME,
101 strnlen(MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800102 PANEL_NAME_MAX_LEN)))
103 return 0;
104
105 if (!strncmp(name, MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME,
106 strnlen(MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME,
107 PANEL_NAME_MAX_LEN)))
108 return 0;
109
110 if (!strncmp(name, MIPI_CMD_RENESAS_FWVGA_PANEL_NAME,
111 strnlen(MIPI_CMD_RENESAS_FWVGA_PANEL_NAME,
112 PANEL_NAME_MAX_LEN)))
113 return 0;
114#endif
115
116 if (!strncmp(name, HDMI_PANEL_NAME,
117 strnlen(HDMI_PANEL_NAME,
118 PANEL_NAME_MAX_LEN)))
119 return 0;
120
121 if (!strncmp(name, TVOUT_PANEL_NAME,
122 strnlen(TVOUT_PANEL_NAME,
123 PANEL_NAME_MAX_LEN)))
124 return 0;
125
126 pr_warning("%s: not supported '%s'", __func__, name);
127 return -ENODEV;
128}
129
130static struct msm_fb_platform_data msm_fb_pdata = {
131 .detect_client = msm_fb_detect_panel,
132};
133
134static struct platform_device msm_fb_device = {
135 .name = "msm_fb",
136 .id = 0,
137 .num_resources = ARRAY_SIZE(msm_fb_resources),
138 .resource = msm_fb_resources,
139 .dev.platform_data = &msm_fb_pdata,
140};
141
142static bool dsi_power_on;
143
Jay Chokshi06fa7542011-12-07 13:09:17 -0800144/*
145 * TODO: When physical 8930/PM8038 hardware becomes
146 * available, replace mipi_dsi_cdp_panel_power with
147 * appropriate function.
148 */
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800149#define DISP_RST_GPIO 58
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800150static int mipi_dsi_cdp_panel_power(int on)
151{
152 static struct regulator *reg_l8, *reg_l23, *reg_l2;
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800153 int rc;
154
Jeff Ohlstein2cbe5ba2011-12-16 13:32:56 -0800155 pr_debug("%s: state : %d\n", __func__, on);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800156
157 if (!dsi_power_on) {
158
159 reg_l8 = regulator_get(&msm_mipi_dsi1_device.dev,
160 "dsi_vdc");
161 if (IS_ERR(reg_l8)) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800162 pr_err("could not get 8038_l8, rc = %ld\n",
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800163 PTR_ERR(reg_l8));
164 return -ENODEV;
165 }
166 reg_l23 = regulator_get(&msm_mipi_dsi1_device.dev,
167 "dsi_vddio");
168 if (IS_ERR(reg_l23)) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800169 pr_err("could not get 8038_l23, rc = %ld\n",
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800170 PTR_ERR(reg_l23));
171 return -ENODEV;
172 }
173 reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev,
174 "dsi_vdda");
175 if (IS_ERR(reg_l2)) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800176 pr_err("could not get 8038_l2, rc = %ld\n",
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800177 PTR_ERR(reg_l2));
178 return -ENODEV;
179 }
180 rc = regulator_set_voltage(reg_l8, 2800000, 3000000);
181 if (rc) {
182 pr_err("set_voltage l8 failed, rc=%d\n", rc);
183 return -EINVAL;
184 }
185 rc = regulator_set_voltage(reg_l23, 1800000, 1800000);
186 if (rc) {
187 pr_err("set_voltage l23 failed, rc=%d\n", rc);
188 return -EINVAL;
189 }
190 rc = regulator_set_voltage(reg_l2, 1200000, 1200000);
191 if (rc) {
192 pr_err("set_voltage l2 failed, rc=%d\n", rc);
193 return -EINVAL;
194 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800195 rc = gpio_request(DISP_RST_GPIO, "disp_rst_n");
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800196 if (rc) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800197 pr_err("request gpio DISP_RST_GPIO failed, rc=%d\n",
198 rc);
199 gpio_free(DISP_RST_GPIO);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800200 return -ENODEV;
201 }
202 dsi_power_on = true;
203 }
204 if (on) {
205 rc = regulator_set_optimum_mode(reg_l8, 100000);
206 if (rc < 0) {
207 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
208 return -EINVAL;
209 }
210 rc = regulator_set_optimum_mode(reg_l23, 100000);
211 if (rc < 0) {
212 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
213 return -EINVAL;
214 }
215 rc = regulator_set_optimum_mode(reg_l2, 100000);
216 if (rc < 0) {
217 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
218 return -EINVAL;
219 }
220 rc = regulator_enable(reg_l8);
221 if (rc) {
222 pr_err("enable l8 failed, rc=%d\n", rc);
223 return -ENODEV;
224 }
225 rc = regulator_enable(reg_l23);
226 if (rc) {
227 pr_err("enable l8 failed, rc=%d\n", rc);
228 return -ENODEV;
229 }
230 rc = regulator_enable(reg_l2);
231 if (rc) {
232 pr_err("enable l2 failed, rc=%d\n", rc);
233 return -ENODEV;
234 }
Ravishangar Kalyanam87c5fb62012-01-28 21:24:58 -0800235 usleep(10000);
236 gpio_set_value(DISP_RST_GPIO, 1);
237 usleep(10);
238 gpio_set_value(DISP_RST_GPIO, 0);
239 usleep(20);
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800240 gpio_set_value(DISP_RST_GPIO, 1);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800241 } else {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800242
243 gpio_set_value(DISP_RST_GPIO, 0);
244
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800245 rc = regulator_disable(reg_l2);
246 if (rc) {
247 pr_err("disable reg_l2 failed, rc=%d\n", rc);
248 return -ENODEV;
249 }
250 rc = regulator_disable(reg_l8);
251 if (rc) {
252 pr_err("disable reg_l8 failed, rc=%d\n", rc);
253 return -ENODEV;
254 }
255 rc = regulator_disable(reg_l23);
256 if (rc) {
257 pr_err("disable reg_l23 failed, rc=%d\n", rc);
258 return -ENODEV;
259 }
260 rc = regulator_set_optimum_mode(reg_l8, 100);
261 if (rc < 0) {
262 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
263 return -EINVAL;
264 }
265 rc = regulator_set_optimum_mode(reg_l23, 100);
266 if (rc < 0) {
267 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
268 return -EINVAL;
269 }
270 rc = regulator_set_optimum_mode(reg_l2, 100);
271 if (rc < 0) {
272 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
273 return -EINVAL;
274 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800275 }
276 return 0;
277}
278
279static int mipi_dsi_panel_power(int on)
280{
Jeff Ohlstein2cbe5ba2011-12-16 13:32:56 -0800281 pr_debug("%s: on=%d\n", __func__, on);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800282
283 return mipi_dsi_cdp_panel_power(on);
284}
285
286static struct mipi_dsi_platform_data mipi_dsi_pdata = {
287 .vsync_gpio = MDP_VSYNC_GPIO,
288 .dsi_power_save = mipi_dsi_panel_power,
289};
290
291#ifdef CONFIG_MSM_BUS_SCALING
292
293static struct msm_bus_vectors mdp_init_vectors[] = {
294 {
295 .src = MSM_BUS_MASTER_MDP_PORT0,
296 .dst = MSM_BUS_SLAVE_EBI_CH0,
297 .ab = 0,
298 .ib = 0,
299 },
300};
301
302#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
303static struct msm_bus_vectors hdmi_as_primary_vectors[] = {
304 /* If HDMI is used as primary */
305 {
306 .src = MSM_BUS_MASTER_MDP_PORT0,
307 .dst = MSM_BUS_SLAVE_EBI_CH0,
308 .ab = 2000000000,
309 .ib = 2000000000,
310 },
311};
312static struct msm_bus_paths mdp_bus_scale_usecases[] = {
313 {
314 ARRAY_SIZE(mdp_init_vectors),
315 mdp_init_vectors,
316 },
317 {
318 ARRAY_SIZE(hdmi_as_primary_vectors),
319 hdmi_as_primary_vectors,
320 },
321 {
322 ARRAY_SIZE(hdmi_as_primary_vectors),
323 hdmi_as_primary_vectors,
324 },
325 {
326 ARRAY_SIZE(hdmi_as_primary_vectors),
327 hdmi_as_primary_vectors,
328 },
329 {
330 ARRAY_SIZE(hdmi_as_primary_vectors),
331 hdmi_as_primary_vectors,
332 },
333 {
334 ARRAY_SIZE(hdmi_as_primary_vectors),
335 hdmi_as_primary_vectors,
336 },
337};
338#else
339static struct msm_bus_vectors mdp_ui_vectors[] = {
340 {
341 .src = MSM_BUS_MASTER_MDP_PORT0,
342 .dst = MSM_BUS_SLAVE_EBI_CH0,
343 .ab = 216000000 * 2,
344 .ib = 270000000 * 2,
345 },
346};
347
348static struct msm_bus_vectors mdp_vga_vectors[] = {
349 /* VGA and less video */
350 {
351 .src = MSM_BUS_MASTER_MDP_PORT0,
352 .dst = MSM_BUS_SLAVE_EBI_CH0,
353 .ab = 216000000 * 2,
354 .ib = 270000000 * 2,
355 },
356};
357
358static struct msm_bus_vectors mdp_720p_vectors[] = {
359 /* 720p and less video */
360 {
361 .src = MSM_BUS_MASTER_MDP_PORT0,
362 .dst = MSM_BUS_SLAVE_EBI_CH0,
363 .ab = 230400000 * 2,
364 .ib = 288000000 * 2,
365 },
366};
367
368static struct msm_bus_vectors mdp_1080p_vectors[] = {
369 /* 1080p and less video */
370 {
371 .src = MSM_BUS_MASTER_MDP_PORT0,
372 .dst = MSM_BUS_SLAVE_EBI_CH0,
373 .ab = 334080000 * 2,
374 .ib = 417600000 * 2,
375 },
376};
377
378static struct msm_bus_paths mdp_bus_scale_usecases[] = {
379 {
380 ARRAY_SIZE(mdp_init_vectors),
381 mdp_init_vectors,
382 },
383 {
384 ARRAY_SIZE(mdp_ui_vectors),
385 mdp_ui_vectors,
386 },
387 {
388 ARRAY_SIZE(mdp_ui_vectors),
389 mdp_ui_vectors,
390 },
391 {
392 ARRAY_SIZE(mdp_vga_vectors),
393 mdp_vga_vectors,
394 },
395 {
396 ARRAY_SIZE(mdp_720p_vectors),
397 mdp_720p_vectors,
398 },
399 {
400 ARRAY_SIZE(mdp_1080p_vectors),
401 mdp_1080p_vectors,
402 },
403};
404#endif
405
406static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
407 mdp_bus_scale_usecases,
408 ARRAY_SIZE(mdp_bus_scale_usecases),
409 .name = "mdp",
410};
411
412#endif
413
414#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
415static int mdp_core_clk_rate_table[] = {
416 200000000,
417 200000000,
418 200000000,
419 200000000,
420};
421#else
422static int mdp_core_clk_rate_table[] = {
423 85330000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -0800424 128000000,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800425 160000000,
426 200000000,
427};
428#endif
429
430static struct msm_panel_common_pdata mdp_pdata = {
431 .gpio = MDP_VSYNC_GPIO,
432#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
433 .mdp_core_clk_rate = 200000000,
434#else
435 .mdp_core_clk_rate = 85330000,
436#endif
437 .mdp_core_clk_table = mdp_core_clk_rate_table,
438 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
439#ifdef CONFIG_MSM_BUS_SCALING
440 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
441#endif
442 .mdp_rev = MDP_REV_42,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -0800443#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
444 .mem_hid = ION_CP_MM_HEAP_ID,
445#else
446 .mem_hid = MEMTYPE_EBI1,
447#endif
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800448};
449
Huaibin Yanga5419422011-12-08 23:52:10 -0800450void __init msm8930_mdp_writeback(struct memtype_reserve* reserve_table)
451{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -0800452 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
453 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
454#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
455 reserve_table[mdp_pdata.mem_hid].size +=
456 mdp_pdata.ov0_wb_size;
457 reserve_table[mdp_pdata.mem_hid].size +=
458 mdp_pdata.ov1_wb_size;
459#endif
Huaibin Yanga5419422011-12-08 23:52:10 -0800460}
461
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800462#define LPM_CHANNEL0 0
463static int toshiba_gpio[] = {LPM_CHANNEL0};
464
465static struct mipi_dsi_panel_platform_data toshiba_pdata = {
466 .gpio = toshiba_gpio,
467};
468
469static struct platform_device mipi_dsi_toshiba_panel_device = {
470 .name = "mipi_toshiba",
471 .id = 0,
472 .dev = {
473 .platform_data = &toshiba_pdata,
474 }
475};
476
477#define FPGA_3D_GPIO_CONFIG_ADDR 0xB5
478
479static struct mipi_dsi_phy_ctrl dsi_novatek_cmd_mode_phy_db = {
480
481/* DSI_BIT_CLK at 500MHz, 2 lane, RGB888 */
482 {0x0F, 0x0a, 0x04, 0x00, 0x20}, /* regulator */
483 /* timing */
484 {0xab, 0x8a, 0x18, 0x00, 0x92, 0x97, 0x1b, 0x8c,
485 0x0c, 0x03, 0x04, 0xa0},
486 {0x5f, 0x00, 0x00, 0x10}, /* phy ctrl */
487 {0xff, 0x00, 0x06, 0x00}, /* strength */
488 /* pll control */
489 {0x40, 0xf9, 0x30, 0xda, 0x00, 0x40, 0x03, 0x62,
490 0x40, 0x07, 0x03,
491 0x00, 0x1a, 0x00, 0x00, 0x02, 0x00, 0x20, 0x00, 0x01},
492};
493
494static struct mipi_dsi_panel_platform_data novatek_pdata = {
495 .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR,
496 .fpga_ctrl_mode = FPGA_SPI_INTF,
497 .phy_ctrl_settings = &dsi_novatek_cmd_mode_phy_db,
Ravishangar Kalyanam903f65c2012-01-28 21:36:22 -0800498 .dlane_swap = 0x1,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800499};
500
501static struct platform_device mipi_dsi_novatek_panel_device = {
502 .name = "mipi_novatek",
503 .id = 0,
504 .dev = {
505 .platform_data = &novatek_pdata,
506 }
507};
508
509#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
510static struct resource hdmi_msm_resources[] = {
511 {
512 .name = "hdmi_msm_qfprom_addr",
513 .start = 0x00700000,
514 .end = 0x007060FF,
515 .flags = IORESOURCE_MEM,
516 },
517 {
518 .name = "hdmi_msm_hdmi_addr",
519 .start = 0x04A00000,
520 .end = 0x04A00FFF,
521 .flags = IORESOURCE_MEM,
522 },
523 {
524 .name = "hdmi_msm_irq",
525 .start = HDMI_IRQ,
526 .end = HDMI_IRQ,
527 .flags = IORESOURCE_IRQ,
528 },
529};
530
531static int hdmi_enable_5v(int on);
532static int hdmi_core_power(int on, int show);
533static int hdmi_cec_power(int on);
534
535static struct msm_hdmi_platform_data hdmi_msm_data = {
536 .irq = HDMI_IRQ,
537 .enable_5v = hdmi_enable_5v,
538 .core_power = hdmi_core_power,
539 .cec_power = hdmi_cec_power,
540};
541
542static struct platform_device hdmi_msm_device = {
543 .name = "hdmi_msm",
544 .id = 0,
545 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
546 .resource = hdmi_msm_resources,
547 .dev.platform_data = &hdmi_msm_data,
548};
549#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
550
551#ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL
552static struct platform_device wfd_panel_device = {
553 .name = "wfd_panel",
554 .id = 0,
555 .dev.platform_data = NULL,
556};
557
558static struct platform_device wfd_device = {
559 .name = "msm_wfd",
560 .id = -1,
561};
562#endif
563
564#ifdef CONFIG_MSM_BUS_SCALING
565static struct msm_bus_vectors dtv_bus_init_vectors[] = {
566 {
567 .src = MSM_BUS_MASTER_MDP_PORT0,
568 .dst = MSM_BUS_SLAVE_EBI_CH0,
569 .ab = 0,
570 .ib = 0,
571 },
572};
573
574#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
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 = 2000000000,
580 .ib = 2000000000,
581 },
582};
583#else
584static struct msm_bus_vectors dtv_bus_def_vectors[] = {
585 {
586 .src = MSM_BUS_MASTER_MDP_PORT0,
587 .dst = MSM_BUS_SLAVE_EBI_CH0,
588 .ab = 566092800 * 2,
589 .ib = 707616000 * 2,
590 },
591};
592#endif
593
594static struct msm_bus_paths dtv_bus_scale_usecases[] = {
595 {
596 ARRAY_SIZE(dtv_bus_init_vectors),
597 dtv_bus_init_vectors,
598 },
599 {
600 ARRAY_SIZE(dtv_bus_def_vectors),
601 dtv_bus_def_vectors,
602 },
603};
604static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
605 dtv_bus_scale_usecases,
606 ARRAY_SIZE(dtv_bus_scale_usecases),
607 .name = "dtv",
608};
609
610static struct lcdc_platform_data dtv_pdata = {
611 .bus_scale_table = &dtv_bus_scale_pdata,
612};
613#endif
614
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800615#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800616static int hdmi_enable_5v(int on)
617{
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800618 static struct regulator *reg_ext_5v; /* HDMI_5V */
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800619 static int prev_on;
620 int rc;
621
622 if (on == prev_on)
623 return 0;
624
Ajay Singh Parmar07847642011-12-09 02:57:45 +0530625 if (!reg_ext_5v) {
626 reg_ext_5v = regulator_get(&hdmi_msm_device.dev, "hdmi_mvs");
627 if (IS_ERR(reg_ext_5v)) {
628 pr_err("'%s' regulator not found, rc=%ld\n",
629 "hdmi_mvs", IS_ERR(reg_ext_5v));
630 reg_ext_5v = NULL;
631 return -ENODEV;
632 }
633 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800634
635 if (on) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800636 rc = regulator_enable(reg_ext_5v);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800637 if (rc) {
638 pr_err("'%s' regulator enable failed, rc=%d\n",
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800639 "reg_ext_5v", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800640 return rc;
641 }
642 pr_debug("%s(on): success\n", __func__);
643 } else {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800644 rc = regulator_disable(reg_ext_5v);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800645 if (rc)
646 pr_warning("'%s' regulator disable failed, rc=%d\n",
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800647 "reg_ext_5v", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800648 pr_debug("%s(off): success\n", __func__);
649 }
650
651 prev_on = on;
652
653 return 0;
654}
655
656static int hdmi_core_power(int on, int show)
657{
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800658 /* Both HDMI "avdd" and "vcc" are powered by 8038_l23 regulator */
659 static struct regulator *reg_8038_l23;
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800660 static int prev_on;
661 int rc;
662
663 if (on == prev_on)
664 return 0;
665
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800666 if (!reg_8038_l23) {
667 reg_8038_l23 = regulator_get(&hdmi_msm_device.dev, "hdmi_avdd");
668 if (IS_ERR(reg_8038_l23)) {
669 pr_err("could not get reg_8038_l23, rc = %ld\n",
670 PTR_ERR(reg_8038_l23));
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800671 return -ENODEV;
672 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800673 rc = regulator_set_voltage(reg_8038_l23, 1800000, 1800000);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800674 if (rc) {
675 pr_err("set_voltage failed for 8921_l23, rc=%d\n", rc);
676 return -EINVAL;
677 }
678 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800679
680 if (on) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800681 rc = regulator_set_optimum_mode(reg_8038_l23, 100000);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800682 if (rc < 0) {
683 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
684 return -EINVAL;
685 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800686 rc = regulator_enable(reg_8038_l23);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800687 if (rc) {
688 pr_err("'%s' regulator enable failed, rc=%d\n",
689 "hdmi_avdd", rc);
690 return rc;
691 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800692 rc = gpio_request(100, "HDMI_DDC_CLK");
693 if (rc) {
694 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
695 "HDMI_DDC_CLK", 100, rc);
696 goto error1;
697 }
698 rc = gpio_request(101, "HDMI_DDC_DATA");
699 if (rc) {
700 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
701 "HDMI_DDC_DATA", 101, rc);
702 goto error2;
703 }
704 rc = gpio_request(102, "HDMI_HPD");
705 if (rc) {
706 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
707 "HDMI_HPD", 102, rc);
708 goto error3;
709 }
710 pr_debug("%s(on): success\n", __func__);
711 } else {
712 gpio_free(100);
713 gpio_free(101);
714 gpio_free(102);
715
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800716 rc = regulator_disable(reg_8038_l23);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800717 if (rc) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800718 pr_err("disable reg_8038_l23 failed, rc=%d\n", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800719 return -ENODEV;
720 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800721 rc = regulator_set_optimum_mode(reg_8038_l23, 100);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800722 if (rc < 0) {
723 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
724 return -EINVAL;
725 }
726 pr_debug("%s(off): success\n", __func__);
727 }
728
729 prev_on = on;
730
731 return 0;
732
733error3:
734 gpio_free(101);
735error2:
736 gpio_free(100);
737error1:
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800738 regulator_disable(reg_8038_l23);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800739 return rc;
740}
741
742static int hdmi_cec_power(int on)
743{
744 static int prev_on;
745 int rc;
746
747 if (on == prev_on)
748 return 0;
749
750 if (on) {
751 rc = gpio_request(99, "HDMI_CEC_VAR");
752 if (rc) {
753 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
754 "HDMI_CEC_VAR", 99, rc);
755 goto error;
756 }
757 pr_debug("%s(on): success\n", __func__);
758 } else {
759 gpio_free(99);
760 pr_debug("%s(off): success\n", __func__);
761 }
762
763 prev_on = on;
764
765 return 0;
766error:
767 return rc;
768}
769#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
770
771void __init msm8930_init_fb(void)
772{
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800773 platform_device_register(&msm_fb_device);
774
775#ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL
776 platform_device_register(&wfd_panel_device);
777 platform_device_register(&wfd_device);
778#endif
779
780 platform_device_register(&mipi_dsi_novatek_panel_device);
781
782#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Aravind Venkateswaranfff132d2012-03-07 13:22:30 -0800783 platform_device_register(&hdmi_msm_device);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800784#endif
785
786 platform_device_register(&mipi_dsi_toshiba_panel_device);
787
788 msm_fb_register_device("mdp", &mdp_pdata);
789 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
790#ifdef CONFIG_MSM_BUS_SCALING
791 msm_fb_register_device("dtv", &dtv_pdata);
792#endif
793}
794
795void __init msm8930_allocate_fb_region(void)
796{
797 void *addr;
798 unsigned long size;
799
800 size = MSM_FB_SIZE;
801 addr = alloc_bootmem_align(size, 0x1000);
802 msm_fb_resources[0].start = __pa(addr);
803 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
804 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
805 size, addr, __pa(addr));
806}