blob: e6b342f67a428fb5da72f703148951714a322884 [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
71#define PANEL_NAME_MAX_LEN 30
72#define MIPI_CMD_NOVATEK_QHD_PANEL_NAME "mipi_cmd_novatek_qhd"
73#define MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME "mipi_video_novatek_qhd"
74#define MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME "mipi_video_toshiba_wsvga"
75#define MIPI_VIDEO_CHIMEI_WXGA_PANEL_NAME "mipi_video_chimei_wxga"
76#define MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME "mipi_video_simulator_vga"
77#define MIPI_CMD_RENESAS_FWVGA_PANEL_NAME "mipi_cmd_renesas_fwvga"
78#define HDMI_PANEL_NAME "hdmi_msm"
79#define TVOUT_PANEL_NAME "tvout_msm"
80
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080081static struct resource msm_fb_resources[] = {
82 {
83 .flags = IORESOURCE_DMA,
84 }
85};
86
87static int msm_fb_detect_panel(const char *name)
88{
Chandan Uddaraju59894ca2011-12-05 17:07:02 -080089 if (!strncmp(name, MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
90 strnlen(MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080091 PANEL_NAME_MAX_LEN)))
92 return 0;
93
Ravishangar Kalyanama4286d72012-02-15 16:09:58 -080094#if !defined(CONFIG_FB_MSM_LVDS_MIPI_PANEL_DETECT) && \
95 !defined(CONFIG_FB_MSM_MIPI_PANEL_DETECT)
Stepan Moskovchenko39236d72011-11-30 17:42:23 -080096 if (!strncmp(name, MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
97 strnlen(MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
98 PANEL_NAME_MAX_LEN)))
99 return 0;
100
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800101 if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME,
102 strnlen(MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800103 PANEL_NAME_MAX_LEN)))
104 return 0;
105
106 if (!strncmp(name, MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME,
107 strnlen(MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME,
108 PANEL_NAME_MAX_LEN)))
109 return 0;
110
111 if (!strncmp(name, MIPI_CMD_RENESAS_FWVGA_PANEL_NAME,
112 strnlen(MIPI_CMD_RENESAS_FWVGA_PANEL_NAME,
113 PANEL_NAME_MAX_LEN)))
114 return 0;
115#endif
116
117 if (!strncmp(name, HDMI_PANEL_NAME,
118 strnlen(HDMI_PANEL_NAME,
119 PANEL_NAME_MAX_LEN)))
120 return 0;
121
122 if (!strncmp(name, TVOUT_PANEL_NAME,
123 strnlen(TVOUT_PANEL_NAME,
124 PANEL_NAME_MAX_LEN)))
125 return 0;
126
127 pr_warning("%s: not supported '%s'", __func__, name);
128 return -ENODEV;
129}
130
131static struct msm_fb_platform_data msm_fb_pdata = {
132 .detect_client = msm_fb_detect_panel,
133};
134
135static struct platform_device msm_fb_device = {
136 .name = "msm_fb",
137 .id = 0,
138 .num_resources = ARRAY_SIZE(msm_fb_resources),
139 .resource = msm_fb_resources,
140 .dev.platform_data = &msm_fb_pdata,
141};
142
143static bool dsi_power_on;
144
Jay Chokshi06fa7542011-12-07 13:09:17 -0800145/*
146 * TODO: When physical 8930/PM8038 hardware becomes
147 * available, replace mipi_dsi_cdp_panel_power with
148 * appropriate function.
149 */
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800150#define DISP_RST_GPIO 58
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800151static int mipi_dsi_cdp_panel_power(int on)
152{
153 static struct regulator *reg_l8, *reg_l23, *reg_l2;
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800154 int rc;
155
Jeff Ohlstein2cbe5ba2011-12-16 13:32:56 -0800156 pr_debug("%s: state : %d\n", __func__, on);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800157
158 if (!dsi_power_on) {
159
160 reg_l8 = regulator_get(&msm_mipi_dsi1_device.dev,
161 "dsi_vdc");
162 if (IS_ERR(reg_l8)) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800163 pr_err("could not get 8038_l8, rc = %ld\n",
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800164 PTR_ERR(reg_l8));
165 return -ENODEV;
166 }
167 reg_l23 = regulator_get(&msm_mipi_dsi1_device.dev,
168 "dsi_vddio");
169 if (IS_ERR(reg_l23)) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800170 pr_err("could not get 8038_l23, rc = %ld\n",
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800171 PTR_ERR(reg_l23));
172 return -ENODEV;
173 }
174 reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev,
175 "dsi_vdda");
176 if (IS_ERR(reg_l2)) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800177 pr_err("could not get 8038_l2, rc = %ld\n",
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800178 PTR_ERR(reg_l2));
179 return -ENODEV;
180 }
181 rc = regulator_set_voltage(reg_l8, 2800000, 3000000);
182 if (rc) {
183 pr_err("set_voltage l8 failed, rc=%d\n", rc);
184 return -EINVAL;
185 }
186 rc = regulator_set_voltage(reg_l23, 1800000, 1800000);
187 if (rc) {
188 pr_err("set_voltage l23 failed, rc=%d\n", rc);
189 return -EINVAL;
190 }
191 rc = regulator_set_voltage(reg_l2, 1200000, 1200000);
192 if (rc) {
193 pr_err("set_voltage l2 failed, rc=%d\n", rc);
194 return -EINVAL;
195 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800196 rc = gpio_request(DISP_RST_GPIO, "disp_rst_n");
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800197 if (rc) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800198 pr_err("request gpio DISP_RST_GPIO failed, rc=%d\n",
199 rc);
200 gpio_free(DISP_RST_GPIO);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800201 return -ENODEV;
202 }
203 dsi_power_on = true;
204 }
205 if (on) {
206 rc = regulator_set_optimum_mode(reg_l8, 100000);
207 if (rc < 0) {
208 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
209 return -EINVAL;
210 }
211 rc = regulator_set_optimum_mode(reg_l23, 100000);
212 if (rc < 0) {
213 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
214 return -EINVAL;
215 }
216 rc = regulator_set_optimum_mode(reg_l2, 100000);
217 if (rc < 0) {
218 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
219 return -EINVAL;
220 }
221 rc = regulator_enable(reg_l8);
222 if (rc) {
223 pr_err("enable l8 failed, rc=%d\n", rc);
224 return -ENODEV;
225 }
226 rc = regulator_enable(reg_l23);
227 if (rc) {
228 pr_err("enable l8 failed, rc=%d\n", rc);
229 return -ENODEV;
230 }
231 rc = regulator_enable(reg_l2);
232 if (rc) {
233 pr_err("enable l2 failed, rc=%d\n", rc);
234 return -ENODEV;
235 }
Ravishangar Kalyanam87c5fb62012-01-28 21:24:58 -0800236 usleep(10000);
237 gpio_set_value(DISP_RST_GPIO, 1);
238 usleep(10);
239 gpio_set_value(DISP_RST_GPIO, 0);
240 usleep(20);
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800241 gpio_set_value(DISP_RST_GPIO, 1);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800242 } else {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800243
244 gpio_set_value(DISP_RST_GPIO, 0);
245
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800246 rc = regulator_disable(reg_l2);
247 if (rc) {
248 pr_err("disable reg_l2 failed, rc=%d\n", rc);
249 return -ENODEV;
250 }
251 rc = regulator_disable(reg_l8);
252 if (rc) {
253 pr_err("disable reg_l8 failed, rc=%d\n", rc);
254 return -ENODEV;
255 }
256 rc = regulator_disable(reg_l23);
257 if (rc) {
258 pr_err("disable reg_l23 failed, rc=%d\n", rc);
259 return -ENODEV;
260 }
261 rc = regulator_set_optimum_mode(reg_l8, 100);
262 if (rc < 0) {
263 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
264 return -EINVAL;
265 }
266 rc = regulator_set_optimum_mode(reg_l23, 100);
267 if (rc < 0) {
268 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
269 return -EINVAL;
270 }
271 rc = regulator_set_optimum_mode(reg_l2, 100);
272 if (rc < 0) {
273 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
274 return -EINVAL;
275 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800276 }
277 return 0;
278}
279
280static int mipi_dsi_panel_power(int on)
281{
Jeff Ohlstein2cbe5ba2011-12-16 13:32:56 -0800282 pr_debug("%s: on=%d\n", __func__, on);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800283
284 return mipi_dsi_cdp_panel_power(on);
285}
286
287static struct mipi_dsi_platform_data mipi_dsi_pdata = {
288 .vsync_gpio = MDP_VSYNC_GPIO,
289 .dsi_power_save = mipi_dsi_panel_power,
290};
291
292#ifdef CONFIG_MSM_BUS_SCALING
293
294static struct msm_bus_vectors mdp_init_vectors[] = {
295 {
296 .src = MSM_BUS_MASTER_MDP_PORT0,
297 .dst = MSM_BUS_SLAVE_EBI_CH0,
298 .ab = 0,
299 .ib = 0,
300 },
301};
302
303#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
304static struct msm_bus_vectors hdmi_as_primary_vectors[] = {
305 /* If HDMI is used as primary */
306 {
307 .src = MSM_BUS_MASTER_MDP_PORT0,
308 .dst = MSM_BUS_SLAVE_EBI_CH0,
309 .ab = 2000000000,
310 .ib = 2000000000,
311 },
312};
313static struct msm_bus_paths mdp_bus_scale_usecases[] = {
314 {
315 ARRAY_SIZE(mdp_init_vectors),
316 mdp_init_vectors,
317 },
318 {
319 ARRAY_SIZE(hdmi_as_primary_vectors),
320 hdmi_as_primary_vectors,
321 },
322 {
323 ARRAY_SIZE(hdmi_as_primary_vectors),
324 hdmi_as_primary_vectors,
325 },
326 {
327 ARRAY_SIZE(hdmi_as_primary_vectors),
328 hdmi_as_primary_vectors,
329 },
330 {
331 ARRAY_SIZE(hdmi_as_primary_vectors),
332 hdmi_as_primary_vectors,
333 },
334 {
335 ARRAY_SIZE(hdmi_as_primary_vectors),
336 hdmi_as_primary_vectors,
337 },
338};
339#else
340static struct msm_bus_vectors mdp_ui_vectors[] = {
341 {
342 .src = MSM_BUS_MASTER_MDP_PORT0,
343 .dst = MSM_BUS_SLAVE_EBI_CH0,
344 .ab = 216000000 * 2,
345 .ib = 270000000 * 2,
346 },
347};
348
349static struct msm_bus_vectors mdp_vga_vectors[] = {
350 /* VGA and less video */
351 {
352 .src = MSM_BUS_MASTER_MDP_PORT0,
353 .dst = MSM_BUS_SLAVE_EBI_CH0,
354 .ab = 216000000 * 2,
355 .ib = 270000000 * 2,
356 },
357};
358
359static struct msm_bus_vectors mdp_720p_vectors[] = {
360 /* 720p and less video */
361 {
362 .src = MSM_BUS_MASTER_MDP_PORT0,
363 .dst = MSM_BUS_SLAVE_EBI_CH0,
364 .ab = 230400000 * 2,
365 .ib = 288000000 * 2,
366 },
367};
368
369static struct msm_bus_vectors mdp_1080p_vectors[] = {
370 /* 1080p and less video */
371 {
372 .src = MSM_BUS_MASTER_MDP_PORT0,
373 .dst = MSM_BUS_SLAVE_EBI_CH0,
374 .ab = 334080000 * 2,
375 .ib = 417600000 * 2,
376 },
377};
378
379static struct msm_bus_paths mdp_bus_scale_usecases[] = {
380 {
381 ARRAY_SIZE(mdp_init_vectors),
382 mdp_init_vectors,
383 },
384 {
385 ARRAY_SIZE(mdp_ui_vectors),
386 mdp_ui_vectors,
387 },
388 {
389 ARRAY_SIZE(mdp_ui_vectors),
390 mdp_ui_vectors,
391 },
392 {
393 ARRAY_SIZE(mdp_vga_vectors),
394 mdp_vga_vectors,
395 },
396 {
397 ARRAY_SIZE(mdp_720p_vectors),
398 mdp_720p_vectors,
399 },
400 {
401 ARRAY_SIZE(mdp_1080p_vectors),
402 mdp_1080p_vectors,
403 },
404};
405#endif
406
407static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
408 mdp_bus_scale_usecases,
409 ARRAY_SIZE(mdp_bus_scale_usecases),
410 .name = "mdp",
411};
412
413#endif
414
415#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
416static int mdp_core_clk_rate_table[] = {
417 200000000,
418 200000000,
419 200000000,
420 200000000,
421};
422#else
423static int mdp_core_clk_rate_table[] = {
424 85330000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -0800425 128000000,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800426 160000000,
427 200000000,
428};
429#endif
430
431static struct msm_panel_common_pdata mdp_pdata = {
432 .gpio = MDP_VSYNC_GPIO,
433#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
434 .mdp_core_clk_rate = 200000000,
435#else
436 .mdp_core_clk_rate = 85330000,
437#endif
438 .mdp_core_clk_table = mdp_core_clk_rate_table,
439 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
440#ifdef CONFIG_MSM_BUS_SCALING
441 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
442#endif
443 .mdp_rev = MDP_REV_42,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -0800444#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
445 .mem_hid = ION_CP_MM_HEAP_ID,
446#else
447 .mem_hid = MEMTYPE_EBI1,
448#endif
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800449};
450
Huaibin Yanga5419422011-12-08 23:52:10 -0800451void __init msm8930_mdp_writeback(struct memtype_reserve* reserve_table)
452{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -0800453 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
454 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
455#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
456 reserve_table[mdp_pdata.mem_hid].size +=
457 mdp_pdata.ov0_wb_size;
458 reserve_table[mdp_pdata.mem_hid].size +=
459 mdp_pdata.ov1_wb_size;
460#endif
Huaibin Yanga5419422011-12-08 23:52:10 -0800461}
462
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800463#define LPM_CHANNEL0 0
464static int toshiba_gpio[] = {LPM_CHANNEL0};
465
466static struct mipi_dsi_panel_platform_data toshiba_pdata = {
467 .gpio = toshiba_gpio,
468};
469
470static struct platform_device mipi_dsi_toshiba_panel_device = {
471 .name = "mipi_toshiba",
472 .id = 0,
473 .dev = {
474 .platform_data = &toshiba_pdata,
475 }
476};
477
478#define FPGA_3D_GPIO_CONFIG_ADDR 0xB5
479
480static struct mipi_dsi_phy_ctrl dsi_novatek_cmd_mode_phy_db = {
481
482/* DSI_BIT_CLK at 500MHz, 2 lane, RGB888 */
483 {0x0F, 0x0a, 0x04, 0x00, 0x20}, /* regulator */
484 /* timing */
485 {0xab, 0x8a, 0x18, 0x00, 0x92, 0x97, 0x1b, 0x8c,
486 0x0c, 0x03, 0x04, 0xa0},
487 {0x5f, 0x00, 0x00, 0x10}, /* phy ctrl */
488 {0xff, 0x00, 0x06, 0x00}, /* strength */
489 /* pll control */
490 {0x40, 0xf9, 0x30, 0xda, 0x00, 0x40, 0x03, 0x62,
491 0x40, 0x07, 0x03,
492 0x00, 0x1a, 0x00, 0x00, 0x02, 0x00, 0x20, 0x00, 0x01},
493};
494
495static struct mipi_dsi_panel_platform_data novatek_pdata = {
496 .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR,
497 .fpga_ctrl_mode = FPGA_SPI_INTF,
498 .phy_ctrl_settings = &dsi_novatek_cmd_mode_phy_db,
Ravishangar Kalyanam903f65c2012-01-28 21:36:22 -0800499 .dlane_swap = 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
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800626 if (!reg_ext_5v)
627 reg_ext_5v = regulator_get(&hdmi_msm_device.dev,
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800628 "hdmi_mvs");
629
630 if (on) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800631 rc = regulator_enable(reg_ext_5v);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800632 if (rc) {
633 pr_err("'%s' regulator enable failed, rc=%d\n",
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800634 "reg_ext_5v", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800635 return rc;
636 }
637 pr_debug("%s(on): success\n", __func__);
638 } else {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800639 rc = regulator_disable(reg_ext_5v);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800640 if (rc)
641 pr_warning("'%s' regulator disable failed, rc=%d\n",
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800642 "reg_ext_5v", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800643 pr_debug("%s(off): success\n", __func__);
644 }
645
646 prev_on = on;
647
648 return 0;
649}
650
651static int hdmi_core_power(int on, int show)
652{
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800653 /* Both HDMI "avdd" and "vcc" are powered by 8038_l23 regulator */
654 static struct regulator *reg_8038_l23;
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800655 static int prev_on;
656 int rc;
657
658 if (on == prev_on)
659 return 0;
660
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800661 if (!reg_8038_l23) {
662 reg_8038_l23 = regulator_get(&hdmi_msm_device.dev, "hdmi_avdd");
663 if (IS_ERR(reg_8038_l23)) {
664 pr_err("could not get reg_8038_l23, rc = %ld\n",
665 PTR_ERR(reg_8038_l23));
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800666 return -ENODEV;
667 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800668 rc = regulator_set_voltage(reg_8038_l23, 1800000, 1800000);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800669 if (rc) {
670 pr_err("set_voltage failed for 8921_l23, rc=%d\n", rc);
671 return -EINVAL;
672 }
673 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800674
675 if (on) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800676 rc = regulator_set_optimum_mode(reg_8038_l23, 100000);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800677 if (rc < 0) {
678 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
679 return -EINVAL;
680 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800681 rc = regulator_enable(reg_8038_l23);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800682 if (rc) {
683 pr_err("'%s' regulator enable failed, rc=%d\n",
684 "hdmi_avdd", rc);
685 return rc;
686 }
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800687 rc = gpio_request(100, "HDMI_DDC_CLK");
688 if (rc) {
689 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
690 "HDMI_DDC_CLK", 100, rc);
691 goto error1;
692 }
693 rc = gpio_request(101, "HDMI_DDC_DATA");
694 if (rc) {
695 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
696 "HDMI_DDC_DATA", 101, rc);
697 goto error2;
698 }
699 rc = gpio_request(102, "HDMI_HPD");
700 if (rc) {
701 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
702 "HDMI_HPD", 102, rc);
703 goto error3;
704 }
705 pr_debug("%s(on): success\n", __func__);
706 } else {
707 gpio_free(100);
708 gpio_free(101);
709 gpio_free(102);
710
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800711 rc = regulator_disable(reg_8038_l23);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800712 if (rc) {
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800713 pr_err("disable reg_8038_l23 failed, rc=%d\n", rc);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800714 return -ENODEV;
715 }
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800716 rc = regulator_set_optimum_mode(reg_8038_l23, 100);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800717 if (rc < 0) {
718 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
719 return -EINVAL;
720 }
721 pr_debug("%s(off): success\n", __func__);
722 }
723
724 prev_on = on;
725
726 return 0;
727
728error3:
729 gpio_free(101);
730error2:
731 gpio_free(100);
732error1:
Chandan Uddaraju59894ca2011-12-05 17:07:02 -0800733 regulator_disable(reg_8038_l23);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800734 return rc;
735}
736
737static int hdmi_cec_power(int on)
738{
739 static int prev_on;
740 int rc;
741
742 if (on == prev_on)
743 return 0;
744
745 if (on) {
746 rc = gpio_request(99, "HDMI_CEC_VAR");
747 if (rc) {
748 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
749 "HDMI_CEC_VAR", 99, rc);
750 goto error;
751 }
752 pr_debug("%s(on): success\n", __func__);
753 } else {
754 gpio_free(99);
755 pr_debug("%s(off): success\n", __func__);
756 }
757
758 prev_on = on;
759
760 return 0;
761error:
762 return rc;
763}
764#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
765
766void __init msm8930_init_fb(void)
767{
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800768 platform_device_register(&msm_fb_device);
769
770#ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL
771 platform_device_register(&wfd_panel_device);
772 platform_device_register(&wfd_device);
773#endif
774
775 platform_device_register(&mipi_dsi_novatek_panel_device);
776
777#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Ajay Dudani52e88232011-12-13 13:33:10 -0800778 if (!cpu_is_msm8930())
Ajay Dudani9114be72011-12-03 07:46:35 -0800779 platform_device_register(&hdmi_msm_device);
Stepan Moskovchenko39236d72011-11-30 17:42:23 -0800780#endif
781
782 platform_device_register(&mipi_dsi_toshiba_panel_device);
783
784 msm_fb_register_device("mdp", &mdp_pdata);
785 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
786#ifdef CONFIG_MSM_BUS_SCALING
787 msm_fb_register_device("dtv", &dtv_pdata);
788#endif
789}
790
791void __init msm8930_allocate_fb_region(void)
792{
793 void *addr;
794 unsigned long size;
795
796 size = MSM_FB_SIZE;
797 addr = alloc_bootmem_align(size, 0x1000);
798 msm_fb_resources[0].start = __pa(addr);
799 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
800 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
801 size, addr, __pa(addr));
802}