blob: 42b20b2dbbbf041ebe71435ad3adfd012e6f3d53 [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
Ravishangar Kalyanama3b168b2012-03-26 11:13:11 -0700444 .mem_hid = BIT(ION_CP_MM_HEAP_ID),
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -0800445#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,
Chandan Uddaraju194a4b52012-03-21 10:11:18 -0700499 .enable_wled_bl_ctrl = 0x1,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800500};
501
502static struct platform_device mipi_dsi_novatek_panel_device = {
503 .name = "mipi_novatek",
504 .id = 0,
505 .dev = {
506 .platform_data = &novatek_pdata,
507 }
508};
509
510#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
511static struct resource hdmi_msm_resources[] = {
512 {
513 .name = "hdmi_msm_qfprom_addr",
514 .start = 0x00700000,
515 .end = 0x007060FF,
516 .flags = IORESOURCE_MEM,
517 },
518 {
519 .name = "hdmi_msm_hdmi_addr",
520 .start = 0x04A00000,
521 .end = 0x04A00FFF,
522 .flags = IORESOURCE_MEM,
523 },
524 {
525 .name = "hdmi_msm_irq",
526 .start = HDMI_IRQ,
527 .end = HDMI_IRQ,
528 .flags = IORESOURCE_IRQ,
529 },
530};
531
532static int hdmi_enable_5v(int on);
533static int hdmi_core_power(int on, int show);
534static int hdmi_cec_power(int on);
535
536static struct msm_hdmi_platform_data hdmi_msm_data = {
537 .irq = HDMI_IRQ,
538 .enable_5v = hdmi_enable_5v,
539 .core_power = hdmi_core_power,
540 .cec_power = hdmi_cec_power,
541};
542
543static struct platform_device hdmi_msm_device = {
544 .name = "hdmi_msm",
545 .id = 0,
546 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
547 .resource = hdmi_msm_resources,
548 .dev.platform_data = &hdmi_msm_data,
549};
550#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
551
552#ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL
553static struct platform_device wfd_panel_device = {
554 .name = "wfd_panel",
555 .id = 0,
556 .dev.platform_data = NULL,
557};
558
559static struct platform_device wfd_device = {
560 .name = "msm_wfd",
561 .id = -1,
562};
563#endif
564
565#ifdef CONFIG_MSM_BUS_SCALING
566static struct msm_bus_vectors dtv_bus_init_vectors[] = {
567 {
568 .src = MSM_BUS_MASTER_MDP_PORT0,
569 .dst = MSM_BUS_SLAVE_EBI_CH0,
570 .ab = 0,
571 .ib = 0,
572 },
573};
574
575#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
576static struct msm_bus_vectors dtv_bus_def_vectors[] = {
577 {
578 .src = MSM_BUS_MASTER_MDP_PORT0,
579 .dst = MSM_BUS_SLAVE_EBI_CH0,
580 .ab = 2000000000,
581 .ib = 2000000000,
582 },
583};
584#else
585static struct msm_bus_vectors dtv_bus_def_vectors[] = {
586 {
587 .src = MSM_BUS_MASTER_MDP_PORT0,
588 .dst = MSM_BUS_SLAVE_EBI_CH0,
589 .ab = 566092800 * 2,
590 .ib = 707616000 * 2,
591 },
592};
593#endif
594
595static struct msm_bus_paths dtv_bus_scale_usecases[] = {
596 {
597 ARRAY_SIZE(dtv_bus_init_vectors),
598 dtv_bus_init_vectors,
599 },
600 {
601 ARRAY_SIZE(dtv_bus_def_vectors),
602 dtv_bus_def_vectors,
603 },
604};
605static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
606 dtv_bus_scale_usecases,
607 ARRAY_SIZE(dtv_bus_scale_usecases),
608 .name = "dtv",
609};
610
611static struct lcdc_platform_data dtv_pdata = {
612 .bus_scale_table = &dtv_bus_scale_pdata,
613};
614#endif
615
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800616#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800617static int hdmi_enable_5v(int on)
618{
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800619 static struct regulator *reg_ext_5v; /* HDMI_5V */
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800620 static int prev_on;
621 int rc;
622
623 if (on == prev_on)
624 return 0;
625
Ajay Singh Parmar07847642011-12-09 02:57:45 +0530626 if (!reg_ext_5v) {
627 reg_ext_5v = regulator_get(&hdmi_msm_device.dev, "hdmi_mvs");
628 if (IS_ERR(reg_ext_5v)) {
629 pr_err("'%s' regulator not found, rc=%ld\n",
630 "hdmi_mvs", IS_ERR(reg_ext_5v));
631 reg_ext_5v = NULL;
632 return -ENODEV;
633 }
634 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800635
636 if (on) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800637 rc = regulator_enable(reg_ext_5v);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800638 if (rc) {
639 pr_err("'%s' regulator enable failed, rc=%d\n",
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800640 "reg_ext_5v", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800641 return rc;
642 }
643 pr_debug("%s(on): success\n", __func__);
644 } else {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800645 rc = regulator_disable(reg_ext_5v);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800646 if (rc)
647 pr_warning("'%s' regulator disable failed, rc=%d\n",
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800648 "reg_ext_5v", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800649 pr_debug("%s(off): success\n", __func__);
650 }
651
652 prev_on = on;
653
654 return 0;
655}
656
657static int hdmi_core_power(int on, int show)
658{
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800659 /* Both HDMI "avdd" and "vcc" are powered by 8038_l23 regulator */
660 static struct regulator *reg_8038_l23;
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800661 static int prev_on;
662 int rc;
663
664 if (on == prev_on)
665 return 0;
666
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800667 if (!reg_8038_l23) {
668 reg_8038_l23 = regulator_get(&hdmi_msm_device.dev, "hdmi_avdd");
669 if (IS_ERR(reg_8038_l23)) {
670 pr_err("could not get reg_8038_l23, rc = %ld\n",
671 PTR_ERR(reg_8038_l23));
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800672 return -ENODEV;
673 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800674 rc = regulator_set_voltage(reg_8038_l23, 1800000, 1800000);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800675 if (rc) {
676 pr_err("set_voltage failed for 8921_l23, rc=%d\n", rc);
677 return -EINVAL;
678 }
679 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800680
681 if (on) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800682 rc = regulator_set_optimum_mode(reg_8038_l23, 100000);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800683 if (rc < 0) {
684 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
685 return -EINVAL;
686 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800687 rc = regulator_enable(reg_8038_l23);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800688 if (rc) {
689 pr_err("'%s' regulator enable failed, rc=%d\n",
690 "hdmi_avdd", rc);
691 return rc;
692 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800693 rc = gpio_request(100, "HDMI_DDC_CLK");
694 if (rc) {
695 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
696 "HDMI_DDC_CLK", 100, rc);
697 goto error1;
698 }
699 rc = gpio_request(101, "HDMI_DDC_DATA");
700 if (rc) {
701 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
702 "HDMI_DDC_DATA", 101, rc);
703 goto error2;
704 }
705 rc = gpio_request(102, "HDMI_HPD");
706 if (rc) {
707 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
708 "HDMI_HPD", 102, rc);
709 goto error3;
710 }
711 pr_debug("%s(on): success\n", __func__);
712 } else {
713 gpio_free(100);
714 gpio_free(101);
715 gpio_free(102);
716
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800717 rc = regulator_disable(reg_8038_l23);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800718 if (rc) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800719 pr_err("disable reg_8038_l23 failed, rc=%d\n", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800720 return -ENODEV;
721 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800722 rc = regulator_set_optimum_mode(reg_8038_l23, 100);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800723 if (rc < 0) {
724 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
725 return -EINVAL;
726 }
727 pr_debug("%s(off): success\n", __func__);
728 }
729
730 prev_on = on;
731
732 return 0;
733
734error3:
735 gpio_free(101);
736error2:
737 gpio_free(100);
738error1:
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800739 regulator_disable(reg_8038_l23);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800740 return rc;
741}
742
743static int hdmi_cec_power(int on)
744{
745 static int prev_on;
746 int rc;
747
748 if (on == prev_on)
749 return 0;
750
751 if (on) {
752 rc = gpio_request(99, "HDMI_CEC_VAR");
753 if (rc) {
754 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
755 "HDMI_CEC_VAR", 99, rc);
756 goto error;
757 }
758 pr_debug("%s(on): success\n", __func__);
759 } else {
760 gpio_free(99);
761 pr_debug("%s(off): success\n", __func__);
762 }
763
764 prev_on = on;
765
766 return 0;
767error:
768 return rc;
769}
770#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
771
772void __init msm8930_init_fb(void)
773{
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800774 platform_device_register(&msm_fb_device);
775
776#ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL
777 platform_device_register(&wfd_panel_device);
778 platform_device_register(&wfd_device);
779#endif
780
781 platform_device_register(&mipi_dsi_novatek_panel_device);
782
783#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Aravind Venkateswaranfff132d2012-03-07 13:22:30 -0800784 platform_device_register(&hdmi_msm_device);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800785#endif
786
787 platform_device_register(&mipi_dsi_toshiba_panel_device);
788
789 msm_fb_register_device("mdp", &mdp_pdata);
790 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
791#ifdef CONFIG_MSM_BUS_SCALING
792 msm_fb_register_device("dtv", &dtv_pdata);
793#endif
794}
795
796void __init msm8930_allocate_fb_region(void)
797{
798 void *addr;
799 unsigned long size;
800
801 size = MSM_FB_SIZE;
802 addr = alloc_bootmem_align(size, 0x1000);
803 msm_fb_resources[0].start = __pa(addr);
804 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
805 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
806 size, addr, __pa(addr));
807}