blob: eae3ebcfb70b61c8f57a8bb26cfdd7971c0a726e [file] [log] [blame]
Nagamalleswararao Ganji70fac1e2011-12-29 19:06:37 -08001/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -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>
Huaibin Yang4a084e32011-12-15 15:25:52 -080018#include <linux/ion.h>
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -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 Moskovchenko24cd8642011-11-29 13:07:53 -080022#include <mach/board.h>
23#include <mach/gpio.h>
24#include <mach/gpiomux.h>
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -080025#include <mach/ion.h>
Amir Samuelov6f1e5002012-02-01 17:42:43 +020026#include <mach/socinfo.h>
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -080027
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080028#include "devices.h"
Stepan Moskovchenko5a83dba2011-12-05 17:30:17 -080029#include "board-8960.h"
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080030
31#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +053032#define MSM_FB_PRIM_BUF_SIZE \
Eugene Yasman7052e132012-03-11 16:16:06 +020033 (roundup((roundup(1920, 32) * roundup(1200, 32) * 4), 4096) * 3)
34 /* 4 bpp x 3 pages */
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080035#else
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +053036#define MSM_FB_PRIM_BUF_SIZE \
Eugene Yasman7052e132012-03-11 16:16:06 +020037 (roundup((roundup(1920, 32) * roundup(1200, 32) * 4), 4096) * 2)
38 /* 4 bpp x 2 pages */
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080039#endif
40
41#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +053042#define MSM_FB_EXT_BUF_SIZE \
Eugene Yasman7052e132012-03-11 16:16:06 +020043 (roundup((roundup(1920, 32) * roundup(1080, 32) * 2), 4096) * 1)
44 /* 2 bpp x 1 page */
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080045#elif defined(CONFIG_FB_MSM_TVOUT)
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +053046#define MSM_FB_EXT_BUF_SIZE \
Eugene Yasman7052e132012-03-11 16:16:06 +020047 (roundup((roundup(720, 32) * roundup(576, 32) * 2), 4096) * 2)
48 /* 2 bpp x 2 pages */
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080049#else
50#define MSM_FB_EXT_BUF_SIZE 0
51#endif
52
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080053/* 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 Moskovchenko24cd8642011-11-29 13:07:53 -080055
Huaibin Yanga5419422011-12-08 23:52:10 -080056#ifdef CONFIG_FB_MSM_OVERLAY0_WRITEBACK
Eugene Yasman7052e132012-03-11 16:16:06 +020057#define MSM_FB_OVERLAY0_WRITEBACK_SIZE \
58 roundup((roundup(1920, 32) * roundup(1200, 32) * 3 * 2), 4096)
Huaibin Yanga5419422011-12-08 23:52:10 -080059#else
60#define MSM_FB_OVERLAY0_WRITEBACK_SIZE (0)
61#endif /* CONFIG_FB_MSM_OVERLAY0_WRITEBACK */
62
63#ifdef CONFIG_FB_MSM_OVERLAY1_WRITEBACK
Eugene Yasman7052e132012-03-11 16:16:06 +020064#define MSM_FB_OVERLAY1_WRITEBACK_SIZE \
65 roundup((roundup(1920, 32) * roundup(1080, 32) * 3 * 2), 4096)
Huaibin Yanga5419422011-12-08 23:52:10 -080066#else
67#define MSM_FB_OVERLAY1_WRITEBACK_SIZE (0)
68#endif /* CONFIG_FB_MSM_OVERLAY1_WRITEBACK */
69
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080070#define MDP_VSYNC_GPIO 0
71
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080072#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"
Ravishangar Kalyanamda07f662012-02-16 13:29:43 -080075#define MIPI_VIDEO_TOSHIBA_WUXGA_PANEL_NAME "mipi_video_toshiba_wuxga"
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080076#define MIPI_VIDEO_CHIMEI_WXGA_PANEL_NAME "mipi_video_chimei_wxga"
Amir Samuelov6f1e5002012-02-01 17:42:43 +020077#define MIPI_VIDEO_CHIMEI_WUXGA_PANEL_NAME "mipi_video_chimei_wuxga"
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080078#define MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME "mipi_video_simulator_vga"
79#define MIPI_CMD_RENESAS_FWVGA_PANEL_NAME "mipi_cmd_renesas_fwvga"
Ravishangar Kalyaname2d015c2012-01-26 14:47:14 -080080#define MIPI_VIDEO_ORISE_720P_PANEL_NAME "mipi_video_orise_720p"
81#define MIPI_CMD_ORISE_720P_PANEL_NAME "mipi_cmd_orise_720p"
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080082#define HDMI_PANEL_NAME "hdmi_msm"
83#define TVOUT_PANEL_NAME "tvout_msm"
84
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -080085#ifdef CONFIG_FB_MSM_HDMI_AS_PRIMARY
Ravishangar Kalyanamfda36c42012-03-26 16:28:19 -070086static unsigned char hdmi_is_primary = 1;
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -080087#else
Ravishangar Kalyanamfda36c42012-03-26 16:28:19 -070088static unsigned char hdmi_is_primary;
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -080089#endif
90
Ravishangar Kalyanamfda36c42012-03-26 16:28:19 -070091unsigned char msm8960_hdmi_as_primary_selected(void)
92{
93 return hdmi_is_primary;
94}
95
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -080096static struct resource msm_fb_resources[] = {
97 {
98 .flags = IORESOURCE_DMA,
99 }
100};
101
Ravishangar Kalyanam8e784252012-02-10 16:27:51 -0800102static void set_mdp_clocks_for_wuxga(void);
Amir Samuelovf0d1f542012-02-06 12:50:42 +0200103
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800104static int msm_fb_detect_panel(const char *name)
105{
106 if (machine_is_msm8960_liquid()) {
Amir Samuelov6f1e5002012-02-01 17:42:43 +0200107 u32 ver = socinfo_get_platform_version();
108 if (SOCINFO_VERSION_MAJOR(ver) == 3) {
109 if (!strncmp(name, MIPI_VIDEO_CHIMEI_WUXGA_PANEL_NAME,
110 strnlen(MIPI_VIDEO_CHIMEI_WUXGA_PANEL_NAME,
Amir Samuelovf0d1f542012-02-06 12:50:42 +0200111 PANEL_NAME_MAX_LEN))) {
Ravishangar Kalyanam8e784252012-02-10 16:27:51 -0800112 set_mdp_clocks_for_wuxga();
Amir Samuelov6f1e5002012-02-01 17:42:43 +0200113 return 0;
Amir Samuelovf0d1f542012-02-06 12:50:42 +0200114 }
Amir Samuelov6f1e5002012-02-01 17:42:43 +0200115 } else {
116 if (!strncmp(name, MIPI_VIDEO_CHIMEI_WXGA_PANEL_NAME,
117 strnlen(MIPI_VIDEO_CHIMEI_WXGA_PANEL_NAME,
118 PANEL_NAME_MAX_LEN)))
119 return 0;
120 }
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800121 } else {
122 if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME,
123 strnlen(MIPI_VIDEO_TOSHIBA_WSVGA_PANEL_NAME,
124 PANEL_NAME_MAX_LEN)))
125 return 0;
126
Ravishangar Kalyanama4286d72012-02-15 16:09:58 -0800127#if !defined(CONFIG_FB_MSM_LVDS_MIPI_PANEL_DETECT) && \
128 !defined(CONFIG_FB_MSM_MIPI_PANEL_DETECT)
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800129 if (!strncmp(name, MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
130 strnlen(MIPI_VIDEO_NOVATEK_QHD_PANEL_NAME,
131 PANEL_NAME_MAX_LEN)))
132 return 0;
133
134 if (!strncmp(name, MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
135 strnlen(MIPI_CMD_NOVATEK_QHD_PANEL_NAME,
136 PANEL_NAME_MAX_LEN)))
137 return 0;
138
139 if (!strncmp(name, MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME,
140 strnlen(MIPI_VIDEO_SIMULATOR_VGA_PANEL_NAME,
141 PANEL_NAME_MAX_LEN)))
142 return 0;
143
144 if (!strncmp(name, MIPI_CMD_RENESAS_FWVGA_PANEL_NAME,
145 strnlen(MIPI_CMD_RENESAS_FWVGA_PANEL_NAME,
146 PANEL_NAME_MAX_LEN)))
147 return 0;
Ravishangar Kalyanam8e784252012-02-10 16:27:51 -0800148
Ravishangar Kalyanamda07f662012-02-16 13:29:43 -0800149 if (!strncmp(name, MIPI_VIDEO_TOSHIBA_WUXGA_PANEL_NAME,
150 strnlen(MIPI_VIDEO_TOSHIBA_WUXGA_PANEL_NAME,
Ravishangar Kalyanam8e784252012-02-10 16:27:51 -0800151 PANEL_NAME_MAX_LEN))) {
152 set_mdp_clocks_for_wuxga();
153 return 0;
154 }
Ravishangar Kalyaname2d015c2012-01-26 14:47:14 -0800155
156 if (!strncmp(name, MIPI_VIDEO_ORISE_720P_PANEL_NAME,
157 strnlen(MIPI_VIDEO_ORISE_720P_PANEL_NAME,
158 PANEL_NAME_MAX_LEN)))
159 return 0;
160
161 if (!strncmp(name, MIPI_CMD_ORISE_720P_PANEL_NAME,
162 strnlen(MIPI_CMD_ORISE_720P_PANEL_NAME,
163 PANEL_NAME_MAX_LEN)))
164 return 0;
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800165#endif
166 }
167
168 if (!strncmp(name, HDMI_PANEL_NAME,
169 strnlen(HDMI_PANEL_NAME,
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -0700170 PANEL_NAME_MAX_LEN))) {
171 if (hdmi_is_primary)
172 set_mdp_clocks_for_wuxga();
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800173 return 0;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -0700174 }
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800175
176 if (!strncmp(name, TVOUT_PANEL_NAME,
177 strnlen(TVOUT_PANEL_NAME,
178 PANEL_NAME_MAX_LEN)))
179 return 0;
180
181 pr_warning("%s: not supported '%s'", __func__, name);
182 return -ENODEV;
183}
184
185static struct msm_fb_platform_data msm_fb_pdata = {
186 .detect_client = msm_fb_detect_panel,
187};
188
189static struct platform_device msm_fb_device = {
190 .name = "msm_fb",
191 .id = 0,
192 .num_resources = ARRAY_SIZE(msm_fb_resources),
193 .resource = msm_fb_resources,
194 .dev.platform_data = &msm_fb_pdata,
195};
196
Chandan Uddaraju2679f092012-03-09 15:48:04 -0800197static void mipi_dsi_panel_pwm_cfg(void)
198{
199 int rc;
200 static int mipi_dsi_panel_gpio_configured;
201 static struct pm_gpio pwm_enable = {
202 .direction = PM_GPIO_DIR_OUT,
203 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
204 .output_value = 1,
205 .pull = PM_GPIO_PULL_NO,
206 .vin_sel = PM_GPIO_VIN_VPH,
207 .out_strength = PM_GPIO_STRENGTH_HIGH,
208 .function = PM_GPIO_FUNC_NORMAL,
209 .inv_int_pol = 0,
210 .disable_pin = 0,
211 };
212 static struct pm_gpio pwm_mode = {
213 .direction = PM_GPIO_DIR_OUT,
214 .output_buffer = PM_GPIO_OUT_BUF_CMOS,
215 .output_value = 0,
216 .pull = PM_GPIO_PULL_NO,
217 .vin_sel = PM_GPIO_VIN_S4,
218 .out_strength = PM_GPIO_STRENGTH_HIGH,
219 .function = PM_GPIO_FUNC_2,
220 .inv_int_pol = 0,
221 .disable_pin = 0,
222 };
223
224 if (mipi_dsi_panel_gpio_configured == 0) {
225 /* pm8xxx: gpio-21, Backlight Enable */
226 rc = pm8xxx_gpio_config(PM8921_GPIO_PM_TO_SYS(21),
227 &pwm_enable);
228 if (rc != 0)
229 pr_err("%s: pwm_enabled failed\n", __func__);
230
231 /* pm8xxx: gpio-24, Bl: Off, PWM mode */
232 rc = pm8xxx_gpio_config(PM8921_GPIO_PM_TO_SYS(24),
233 &pwm_mode);
234 if (rc != 0)
235 pr_err("%s: pwm_mode failed\n", __func__);
236
237 mipi_dsi_panel_gpio_configured++;
238 }
239}
240
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800241static bool dsi_power_on;
242
243/**
244 * LiQUID panel on/off
245 *
246 * @param on
247 *
248 * @return int
249 */
250static int mipi_dsi_liquid_panel_power(int on)
251{
252 static struct regulator *reg_l2, *reg_ext_3p3v;
253 static int gpio21, gpio24, gpio43;
254 int rc;
255
Chandan Uddaraju2679f092012-03-09 15:48:04 -0800256 mipi_dsi_panel_pwm_cfg();
Jeff Ohlstein2cbe5ba2011-12-16 13:32:56 -0800257 pr_debug("%s: on=%d\n", __func__, on);
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800258
259 gpio21 = PM8921_GPIO_PM_TO_SYS(21); /* disp power enable_n */
260 gpio43 = PM8921_GPIO_PM_TO_SYS(43); /* Displays Enable (rst_n)*/
261 gpio24 = PM8921_GPIO_PM_TO_SYS(24); /* Backlight PWM */
262
263 if (!dsi_power_on) {
264
265 reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev,
266 "dsi_vdda");
267 if (IS_ERR(reg_l2)) {
268 pr_err("could not get 8921_l2, rc = %ld\n",
269 PTR_ERR(reg_l2));
270 return -ENODEV;
271 }
272
273 rc = regulator_set_voltage(reg_l2, 1200000, 1200000);
274 if (rc) {
275 pr_err("set_voltage l2 failed, rc=%d\n", rc);
276 return -EINVAL;
277 }
278
279 reg_ext_3p3v = regulator_get(&msm_mipi_dsi1_device.dev,
280 "vdd_lvds_3p3v");
281 if (IS_ERR(reg_ext_3p3v)) {
282 pr_err("could not get reg_ext_3p3v, rc = %ld\n",
283 PTR_ERR(reg_ext_3p3v));
284 return -ENODEV;
285 }
286
287 rc = gpio_request(gpio21, "disp_pwr_en_n");
288 if (rc) {
289 pr_err("request gpio 21 failed, rc=%d\n", rc);
290 return -ENODEV;
291 }
292
293 rc = gpio_request(gpio43, "disp_rst_n");
294 if (rc) {
295 pr_err("request gpio 43 failed, rc=%d\n", rc);
296 return -ENODEV;
297 }
298
299 rc = gpio_request(gpio24, "disp_backlight_pwm");
300 if (rc) {
301 pr_err("request gpio 24 failed, rc=%d\n", rc);
302 return -ENODEV;
303 }
304
305 dsi_power_on = true;
306 }
307
308 if (on) {
309 rc = regulator_set_optimum_mode(reg_l2, 100000);
310 if (rc < 0) {
311 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
312 return -EINVAL;
313 }
314 rc = regulator_enable(reg_l2);
315 if (rc) {
316 pr_err("enable l2 failed, rc=%d\n", rc);
317 return -ENODEV;
318 }
319
320 rc = regulator_enable(reg_ext_3p3v);
321 if (rc) {
322 pr_err("enable reg_ext_3p3v failed, rc=%d\n", rc);
323 return -ENODEV;
324 }
325
326 /* set reset pin before power enable */
327 gpio_set_value_cansleep(gpio43, 0); /* disp disable (resx=0) */
328
329 gpio_set_value_cansleep(gpio21, 0); /* disp power enable_n */
330 msleep(20);
331 gpio_set_value_cansleep(gpio43, 1); /* disp enable */
332 msleep(20);
333 gpio_set_value_cansleep(gpio43, 0); /* disp enable */
334 msleep(20);
335 gpio_set_value_cansleep(gpio43, 1); /* disp enable */
336 msleep(20);
337 } else {
338 gpio_set_value_cansleep(gpio43, 0);
339 gpio_set_value_cansleep(gpio21, 1);
340
341 rc = regulator_disable(reg_l2);
342 if (rc) {
343 pr_err("disable reg_l2 failed, rc=%d\n", rc);
344 return -ENODEV;
345 }
346 rc = regulator_disable(reg_ext_3p3v);
347 if (rc) {
348 pr_err("disable reg_ext_3p3v failed, rc=%d\n", rc);
349 return -ENODEV;
350 }
351 rc = regulator_set_optimum_mode(reg_l2, 100);
352 if (rc < 0) {
353 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
354 return -EINVAL;
355 }
356 }
357
358 return 0;
359}
360
361static int mipi_dsi_cdp_panel_power(int on)
362{
363 static struct regulator *reg_l8, *reg_l23, *reg_l2;
364 static int gpio43;
365 int rc;
366
Jeff Ohlstein2cbe5ba2011-12-16 13:32:56 -0800367 pr_debug("%s: state : %d\n", __func__, on);
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800368
369 if (!dsi_power_on) {
370
371 reg_l8 = regulator_get(&msm_mipi_dsi1_device.dev,
372 "dsi_vdc");
373 if (IS_ERR(reg_l8)) {
374 pr_err("could not get 8921_l8, rc = %ld\n",
375 PTR_ERR(reg_l8));
376 return -ENODEV;
377 }
378 reg_l23 = regulator_get(&msm_mipi_dsi1_device.dev,
379 "dsi_vddio");
380 if (IS_ERR(reg_l23)) {
381 pr_err("could not get 8921_l23, rc = %ld\n",
382 PTR_ERR(reg_l23));
383 return -ENODEV;
384 }
385 reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev,
386 "dsi_vdda");
387 if (IS_ERR(reg_l2)) {
388 pr_err("could not get 8921_l2, rc = %ld\n",
389 PTR_ERR(reg_l2));
390 return -ENODEV;
391 }
392 rc = regulator_set_voltage(reg_l8, 2800000, 3000000);
393 if (rc) {
394 pr_err("set_voltage l8 failed, rc=%d\n", rc);
395 return -EINVAL;
396 }
397 rc = regulator_set_voltage(reg_l23, 1800000, 1800000);
398 if (rc) {
399 pr_err("set_voltage l23 failed, rc=%d\n", rc);
400 return -EINVAL;
401 }
402 rc = regulator_set_voltage(reg_l2, 1200000, 1200000);
403 if (rc) {
404 pr_err("set_voltage l2 failed, rc=%d\n", rc);
405 return -EINVAL;
406 }
407 gpio43 = PM8921_GPIO_PM_TO_SYS(43);
408 rc = gpio_request(gpio43, "disp_rst_n");
409 if (rc) {
410 pr_err("request gpio 43 failed, rc=%d\n", rc);
411 return -ENODEV;
412 }
413 dsi_power_on = true;
414 }
415 if (on) {
416 rc = regulator_set_optimum_mode(reg_l8, 100000);
417 if (rc < 0) {
418 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
419 return -EINVAL;
420 }
421 rc = regulator_set_optimum_mode(reg_l23, 100000);
422 if (rc < 0) {
423 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
424 return -EINVAL;
425 }
426 rc = regulator_set_optimum_mode(reg_l2, 100000);
427 if (rc < 0) {
428 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
429 return -EINVAL;
430 }
431 rc = regulator_enable(reg_l8);
432 if (rc) {
433 pr_err("enable l8 failed, rc=%d\n", rc);
434 return -ENODEV;
435 }
436 rc = regulator_enable(reg_l23);
437 if (rc) {
438 pr_err("enable l8 failed, rc=%d\n", rc);
439 return -ENODEV;
440 }
441 rc = regulator_enable(reg_l2);
442 if (rc) {
443 pr_err("enable l2 failed, rc=%d\n", rc);
444 return -ENODEV;
445 }
446 gpio_set_value_cansleep(gpio43, 1);
447 } else {
448 rc = regulator_disable(reg_l2);
449 if (rc) {
450 pr_err("disable reg_l2 failed, rc=%d\n", rc);
451 return -ENODEV;
452 }
453 rc = regulator_disable(reg_l8);
454 if (rc) {
455 pr_err("disable reg_l8 failed, rc=%d\n", rc);
456 return -ENODEV;
457 }
458 rc = regulator_disable(reg_l23);
459 if (rc) {
460 pr_err("disable reg_l23 failed, rc=%d\n", rc);
461 return -ENODEV;
462 }
463 rc = regulator_set_optimum_mode(reg_l8, 100);
464 if (rc < 0) {
465 pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
466 return -EINVAL;
467 }
468 rc = regulator_set_optimum_mode(reg_l23, 100);
469 if (rc < 0) {
470 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
471 return -EINVAL;
472 }
473 rc = regulator_set_optimum_mode(reg_l2, 100);
474 if (rc < 0) {
475 pr_err("set_optimum_mode l2 failed, rc=%d\n", rc);
476 return -EINVAL;
477 }
478 gpio_set_value_cansleep(gpio43, 0);
479 }
480 return 0;
481}
482
483static int mipi_dsi_panel_power(int on)
484{
485 int ret;
486
Jeff Ohlstein2cbe5ba2011-12-16 13:32:56 -0800487 pr_debug("%s: on=%d\n", __func__, on);
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800488
489 if (machine_is_msm8960_liquid())
490 ret = mipi_dsi_liquid_panel_power(on);
491 else
492 ret = mipi_dsi_cdp_panel_power(on);
493
494 return ret;
495}
496
497static struct mipi_dsi_platform_data mipi_dsi_pdata = {
498 .vsync_gpio = MDP_VSYNC_GPIO,
499 .dsi_power_save = mipi_dsi_panel_power,
500};
501
502#ifdef CONFIG_MSM_BUS_SCALING
503
Nagamalleswararao Ganji5fabbd62011-11-06 23:10:43 -0800504static struct msm_bus_vectors rotator_init_vectors[] = {
505 {
506 .src = MSM_BUS_MASTER_ROTATOR,
507 .dst = MSM_BUS_SLAVE_EBI_CH0,
508 .ab = 0,
509 .ib = 0,
510 },
511};
512
513static struct msm_bus_vectors rotator_ui_vectors[] = {
514 {
515 .src = MSM_BUS_MASTER_ROTATOR,
516 .dst = MSM_BUS_SLAVE_EBI_CH0,
517 .ab = (1024 * 600 * 4 * 2 * 60),
518 .ib = (1024 * 600 * 4 * 2 * 60 * 1.5),
519 },
520};
521
522static struct msm_bus_vectors rotator_vga_vectors[] = {
523 {
524 .src = MSM_BUS_MASTER_ROTATOR,
525 .dst = MSM_BUS_SLAVE_EBI_CH0,
526 .ab = (640 * 480 * 2 * 2 * 30),
527 .ib = (640 * 480 * 2 * 2 * 30 * 1.5),
528 },
529};
530static struct msm_bus_vectors rotator_720p_vectors[] = {
531 {
532 .src = MSM_BUS_MASTER_ROTATOR,
533 .dst = MSM_BUS_SLAVE_EBI_CH0,
534 .ab = (1280 * 736 * 2 * 2 * 30),
535 .ib = (1280 * 736 * 2 * 2 * 30 * 1.5),
536 },
537};
538
539static struct msm_bus_vectors rotator_1080p_vectors[] = {
540 {
541 .src = MSM_BUS_MASTER_ROTATOR,
542 .dst = MSM_BUS_SLAVE_EBI_CH0,
543 .ab = (1920 * 1088 * 2 * 2 * 30),
544 .ib = (1920 * 1088 * 2 * 2 * 30 * 1.5),
545 },
546};
547
548static struct msm_bus_paths rotator_bus_scale_usecases[] = {
549 {
550 ARRAY_SIZE(rotator_init_vectors),
551 rotator_init_vectors,
552 },
553 {
554 ARRAY_SIZE(rotator_ui_vectors),
555 rotator_ui_vectors,
556 },
557 {
558 ARRAY_SIZE(rotator_vga_vectors),
559 rotator_vga_vectors,
560 },
561 {
562 ARRAY_SIZE(rotator_720p_vectors),
563 rotator_720p_vectors,
564 },
565 {
566 ARRAY_SIZE(rotator_1080p_vectors),
567 rotator_1080p_vectors,
568 },
569};
570
571struct msm_bus_scale_pdata rotator_bus_scale_pdata = {
572 rotator_bus_scale_usecases,
573 ARRAY_SIZE(rotator_bus_scale_usecases),
574 .name = "rotator",
575};
576
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800577static struct msm_bus_vectors mdp_init_vectors[] = {
578 {
579 .src = MSM_BUS_MASTER_MDP_PORT0,
580 .dst = MSM_BUS_SLAVE_EBI_CH0,
581 .ab = 0,
582 .ib = 0,
583 },
584};
585
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800586static struct msm_bus_vectors mdp_ui_vectors[] = {
587 {
588 .src = MSM_BUS_MASTER_MDP_PORT0,
589 .dst = MSM_BUS_SLAVE_EBI_CH0,
590 .ab = 216000000 * 2,
591 .ib = 270000000 * 2,
592 },
593};
594
595static struct msm_bus_vectors mdp_vga_vectors[] = {
596 /* VGA and less video */
597 {
598 .src = MSM_BUS_MASTER_MDP_PORT0,
599 .dst = MSM_BUS_SLAVE_EBI_CH0,
600 .ab = 216000000 * 2,
601 .ib = 270000000 * 2,
602 },
603};
604
605static struct msm_bus_vectors mdp_720p_vectors[] = {
606 /* 720p and less video */
607 {
608 .src = MSM_BUS_MASTER_MDP_PORT0,
609 .dst = MSM_BUS_SLAVE_EBI_CH0,
610 .ab = 230400000 * 2,
611 .ib = 288000000 * 2,
612 },
613};
614
615static struct msm_bus_vectors mdp_1080p_vectors[] = {
616 /* 1080p and less video */
617 {
618 .src = MSM_BUS_MASTER_MDP_PORT0,
619 .dst = MSM_BUS_SLAVE_EBI_CH0,
620 .ab = 334080000 * 2,
621 .ib = 417600000 * 2,
622 },
623};
624
625static struct msm_bus_paths mdp_bus_scale_usecases[] = {
626 {
627 ARRAY_SIZE(mdp_init_vectors),
628 mdp_init_vectors,
629 },
630 {
631 ARRAY_SIZE(mdp_ui_vectors),
632 mdp_ui_vectors,
633 },
634 {
635 ARRAY_SIZE(mdp_ui_vectors),
636 mdp_ui_vectors,
637 },
638 {
639 ARRAY_SIZE(mdp_vga_vectors),
640 mdp_vga_vectors,
641 },
642 {
643 ARRAY_SIZE(mdp_720p_vectors),
644 mdp_720p_vectors,
645 },
646 {
647 ARRAY_SIZE(mdp_1080p_vectors),
648 mdp_1080p_vectors,
649 },
650};
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800651
652static struct msm_bus_scale_pdata mdp_bus_scale_pdata = {
653 mdp_bus_scale_usecases,
654 ARRAY_SIZE(mdp_bus_scale_usecases),
655 .name = "mdp",
656};
657
658#endif
659
Stepan Moskovchenkofc70d902011-11-30 12:39:36 -0800660static int mdp_core_clk_rate_table[] = {
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800661 85330000,
Huaibin Yang1f180ee2012-01-30 16:23:06 -0800662 128000000,
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800663 160000000,
664 200000000,
665};
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800666
667static struct msm_panel_common_pdata mdp_pdata = {
668 .gpio = MDP_VSYNC_GPIO,
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800669 .mdp_core_clk_rate = 85330000,
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800670 .mdp_core_clk_table = mdp_core_clk_rate_table,
671 .num_mdp_clk = ARRAY_SIZE(mdp_core_clk_rate_table),
672#ifdef CONFIG_MSM_BUS_SCALING
673 .mdp_bus_scale_table = &mdp_bus_scale_pdata,
674#endif
675 .mdp_rev = MDP_REV_42,
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -0800676#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
Ravishangar Kalyanama3b168b2012-03-26 11:13:11 -0700677 .mem_hid = BIT(ION_CP_MM_HEAP_ID),
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -0800678#else
679 .mem_hid = MEMTYPE_EBI1,
680#endif
Chandan Uddaraju2679f092012-03-09 15:48:04 -0800681 .cont_splash_enabled = 0x01,
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800682};
683
Huaibin Yanga5419422011-12-08 23:52:10 -0800684void __init msm8960_mdp_writeback(struct memtype_reserve* reserve_table)
685{
Nagamalleswararao Ganji937a1192011-12-07 19:00:52 -0800686 mdp_pdata.ov0_wb_size = MSM_FB_OVERLAY0_WRITEBACK_SIZE;
687 mdp_pdata.ov1_wb_size = MSM_FB_OVERLAY1_WRITEBACK_SIZE;
688#if defined(CONFIG_ANDROID_PMEM) && !defined(CONFIG_MSM_MULTIMEDIA_USE_ION)
689 reserve_table[mdp_pdata.mem_hid].size +=
690 mdp_pdata.ov0_wb_size;
691 reserve_table[mdp_pdata.mem_hid].size +=
692 mdp_pdata.ov1_wb_size;
693#endif
Huaibin Yanga5419422011-12-08 23:52:10 -0800694}
695
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800696static struct platform_device mipi_dsi_renesas_panel_device = {
697 .name = "mipi_renesas",
698 .id = 0,
699};
700
701static struct platform_device mipi_dsi_simulator_panel_device = {
702 .name = "mipi_simulator",
703 .id = 0,
704};
705
706#define LPM_CHANNEL0 0
707static int toshiba_gpio[] = {LPM_CHANNEL0};
708
709static struct mipi_dsi_panel_platform_data toshiba_pdata = {
710 .gpio = toshiba_gpio,
Chandan Uddaraju2679f092012-03-09 15:48:04 -0800711 .dsi_pwm_cfg = mipi_dsi_panel_pwm_cfg,
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800712};
713
714static struct platform_device mipi_dsi_toshiba_panel_device = {
715 .name = "mipi_toshiba",
716 .id = 0,
717 .dev = {
718 .platform_data = &toshiba_pdata,
719 }
720};
721
722#define FPGA_3D_GPIO_CONFIG_ADDR 0xB5
Amir Samuelovca199b92012-01-31 14:50:04 +0200723static int dsi2lvds_gpio[4] = {
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800724 0,/* Backlight PWM-ID=0 for PMIC-GPIO#24 */
Amir Samuelovca199b92012-01-31 14:50:04 +0200725 0x1F08, /* DSI2LVDS Bridge GPIO Output, mask=0x1f, out=0x08 */
726 GPIO_LIQUID_EXPANDER_BASE+6, /* TN Enable */
727 GPIO_LIQUID_EXPANDER_BASE+7, /* TN Mode */
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800728 };
729
730static struct msm_panel_common_pdata mipi_dsi2lvds_pdata = {
731 .gpio_num = dsi2lvds_gpio,
732};
733
734static struct mipi_dsi_phy_ctrl dsi_novatek_cmd_mode_phy_db = {
735
736/* DSI_BIT_CLK at 500MHz, 2 lane, RGB888 */
737 {0x0F, 0x0a, 0x04, 0x00, 0x20}, /* regulator */
738 /* timing */
739 {0xab, 0x8a, 0x18, 0x00, 0x92, 0x97, 0x1b, 0x8c,
740 0x0c, 0x03, 0x04, 0xa0},
741 {0x5f, 0x00, 0x00, 0x10}, /* phy ctrl */
742 {0xff, 0x00, 0x06, 0x00}, /* strength */
743 /* pll control */
744 {0x40, 0xf9, 0x30, 0xda, 0x00, 0x40, 0x03, 0x62,
745 0x40, 0x07, 0x03,
746 0x00, 0x1a, 0x00, 0x00, 0x02, 0x00, 0x20, 0x00, 0x01},
747};
748
749static struct mipi_dsi_panel_platform_data novatek_pdata = {
750 .fpga_3d_config_addr = FPGA_3D_GPIO_CONFIG_ADDR,
751 .fpga_ctrl_mode = FPGA_SPI_INTF,
752 .phy_ctrl_settings = &dsi_novatek_cmd_mode_phy_db,
753};
754
755static struct platform_device mipi_dsi_novatek_panel_device = {
756 .name = "mipi_novatek",
757 .id = 0,
758 .dev = {
759 .platform_data = &novatek_pdata,
760 }
761};
762
763static struct platform_device mipi_dsi2lvds_bridge_device = {
764 .name = "mipi_tc358764",
765 .id = 0,
766 .dev.platform_data = &mipi_dsi2lvds_pdata,
767};
768
Ravishangar Kalyaname2d015c2012-01-26 14:47:14 -0800769static struct platform_device mipi_dsi_orise_panel_device = {
770 .name = "mipi_orise",
771 .id = 0,
772};
773
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800774#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
775static struct resource hdmi_msm_resources[] = {
776 {
777 .name = "hdmi_msm_qfprom_addr",
778 .start = 0x00700000,
779 .end = 0x007060FF,
780 .flags = IORESOURCE_MEM,
781 },
782 {
783 .name = "hdmi_msm_hdmi_addr",
784 .start = 0x04A00000,
785 .end = 0x04A00FFF,
786 .flags = IORESOURCE_MEM,
787 },
788 {
789 .name = "hdmi_msm_irq",
790 .start = HDMI_IRQ,
791 .end = HDMI_IRQ,
792 .flags = IORESOURCE_IRQ,
793 },
794};
795
796static int hdmi_enable_5v(int on);
797static int hdmi_core_power(int on, int show);
798static int hdmi_cec_power(int on);
799
800static struct msm_hdmi_platform_data hdmi_msm_data = {
801 .irq = HDMI_IRQ,
802 .enable_5v = hdmi_enable_5v,
803 .core_power = hdmi_core_power,
804 .cec_power = hdmi_cec_power,
805};
806
807static struct platform_device hdmi_msm_device = {
808 .name = "hdmi_msm",
809 .id = 0,
810 .num_resources = ARRAY_SIZE(hdmi_msm_resources),
811 .resource = hdmi_msm_resources,
812 .dev.platform_data = &hdmi_msm_data,
813};
814#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
815
816#ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL
817static struct platform_device wfd_panel_device = {
818 .name = "wfd_panel",
819 .id = 0,
820 .dev.platform_data = NULL,
821};
Stepan Moskovchenko270888d2011-11-30 12:19:11 -0800822
823static struct platform_device wfd_device = {
824 .name = "msm_wfd",
825 .id = -1,
826};
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800827#endif
828
829#ifdef CONFIG_MSM_BUS_SCALING
830static struct msm_bus_vectors dtv_bus_init_vectors[] = {
831 {
832 .src = MSM_BUS_MASTER_MDP_PORT0,
833 .dst = MSM_BUS_SLAVE_EBI_CH0,
834 .ab = 0,
835 .ib = 0,
836 },
837};
838
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800839static struct msm_bus_vectors dtv_bus_def_vectors[] = {
840 {
841 .src = MSM_BUS_MASTER_MDP_PORT0,
842 .dst = MSM_BUS_SLAVE_EBI_CH0,
843 .ab = 566092800 * 2,
844 .ib = 707616000 * 2,
845 },
846};
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800847
848static struct msm_bus_paths dtv_bus_scale_usecases[] = {
849 {
850 ARRAY_SIZE(dtv_bus_init_vectors),
851 dtv_bus_init_vectors,
852 },
853 {
854 ARRAY_SIZE(dtv_bus_def_vectors),
855 dtv_bus_def_vectors,
856 },
857};
858static struct msm_bus_scale_pdata dtv_bus_scale_pdata = {
859 dtv_bus_scale_usecases,
860 ARRAY_SIZE(dtv_bus_scale_usecases),
861 .name = "dtv",
862};
863
864static struct lcdc_platform_data dtv_pdata = {
865 .bus_scale_table = &dtv_bus_scale_pdata,
866};
867#endif
868
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800869#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800870static int hdmi_enable_5v(int on)
871{
872 /* TBD: PM8921 regulator instead of 8901 */
873 static struct regulator *reg_8921_hdmi_mvs; /* HDMI_5V */
874 static int prev_on;
875 int rc;
876
877 if (on == prev_on)
878 return 0;
879
Ajay Singh Parmar07847642011-12-09 02:57:45 +0530880 if (!reg_8921_hdmi_mvs) {
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800881 reg_8921_hdmi_mvs = regulator_get(&hdmi_msm_device.dev,
Ajay Singh Parmar07847642011-12-09 02:57:45 +0530882 "hdmi_mvs");
883 if (IS_ERR(reg_8921_hdmi_mvs)) {
884 pr_err("'%s' regulator not found, rc=%ld\n",
885 "hdmi_mvs", IS_ERR(reg_8921_hdmi_mvs));
886 reg_8921_hdmi_mvs = NULL;
887 return -ENODEV;
888 }
889 }
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -0800890
891 if (on) {
892 rc = regulator_enable(reg_8921_hdmi_mvs);
893 if (rc) {
894 pr_err("'%s' regulator enable failed, rc=%d\n",
895 "8921_hdmi_mvs", rc);
896 return rc;
897 }
898 pr_debug("%s(on): success\n", __func__);
899 } else {
900 rc = regulator_disable(reg_8921_hdmi_mvs);
901 if (rc)
902 pr_warning("'%s' regulator disable failed, rc=%d\n",
903 "8921_hdmi_mvs", rc);
904 pr_debug("%s(off): success\n", __func__);
905 }
906
907 prev_on = on;
908
909 return 0;
910}
911
912static int hdmi_core_power(int on, int show)
913{
914 static struct regulator *reg_8921_l23, *reg_8921_s4;
915 static int prev_on;
916 int rc;
917
918 if (on == prev_on)
919 return 0;
920
921 /* TBD: PM8921 regulator instead of 8901 */
922 if (!reg_8921_l23) {
923 reg_8921_l23 = regulator_get(&hdmi_msm_device.dev, "hdmi_avdd");
924 if (IS_ERR(reg_8921_l23)) {
925 pr_err("could not get reg_8921_l23, rc = %ld\n",
926 PTR_ERR(reg_8921_l23));
927 return -ENODEV;
928 }
929 rc = regulator_set_voltage(reg_8921_l23, 1800000, 1800000);
930 if (rc) {
931 pr_err("set_voltage failed for 8921_l23, rc=%d\n", rc);
932 return -EINVAL;
933 }
934 }
935 if (!reg_8921_s4) {
936 reg_8921_s4 = regulator_get(&hdmi_msm_device.dev, "hdmi_vcc");
937 if (IS_ERR(reg_8921_s4)) {
938 pr_err("could not get reg_8921_s4, rc = %ld\n",
939 PTR_ERR(reg_8921_s4));
940 return -ENODEV;
941 }
942 rc = regulator_set_voltage(reg_8921_s4, 1800000, 1800000);
943 if (rc) {
944 pr_err("set_voltage failed for 8921_s4, rc=%d\n", rc);
945 return -EINVAL;
946 }
947 }
948
949 if (on) {
950 rc = regulator_set_optimum_mode(reg_8921_l23, 100000);
951 if (rc < 0) {
952 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
953 return -EINVAL;
954 }
955 rc = regulator_enable(reg_8921_l23);
956 if (rc) {
957 pr_err("'%s' regulator enable failed, rc=%d\n",
958 "hdmi_avdd", rc);
959 return rc;
960 }
961 rc = regulator_enable(reg_8921_s4);
962 if (rc) {
963 pr_err("'%s' regulator enable failed, rc=%d\n",
964 "hdmi_vcc", rc);
965 return rc;
966 }
967 rc = gpio_request(100, "HDMI_DDC_CLK");
968 if (rc) {
969 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
970 "HDMI_DDC_CLK", 100, rc);
971 goto error1;
972 }
973 rc = gpio_request(101, "HDMI_DDC_DATA");
974 if (rc) {
975 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
976 "HDMI_DDC_DATA", 101, rc);
977 goto error2;
978 }
979 rc = gpio_request(102, "HDMI_HPD");
980 if (rc) {
981 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
982 "HDMI_HPD", 102, rc);
983 goto error3;
984 }
985 pr_debug("%s(on): success\n", __func__);
986 } else {
987 gpio_free(100);
988 gpio_free(101);
989 gpio_free(102);
990
991 rc = regulator_disable(reg_8921_l23);
992 if (rc) {
993 pr_err("disable reg_8921_l23 failed, rc=%d\n", rc);
994 return -ENODEV;
995 }
996 rc = regulator_disable(reg_8921_s4);
997 if (rc) {
998 pr_err("disable reg_8921_s4 failed, rc=%d\n", rc);
999 return -ENODEV;
1000 }
1001 rc = regulator_set_optimum_mode(reg_8921_l23, 100);
1002 if (rc < 0) {
1003 pr_err("set_optimum_mode l23 failed, rc=%d\n", rc);
1004 return -EINVAL;
1005 }
1006 pr_debug("%s(off): success\n", __func__);
1007 }
1008
1009 prev_on = on;
1010
1011 return 0;
1012
1013error3:
1014 gpio_free(101);
1015error2:
1016 gpio_free(100);
1017error1:
1018 regulator_disable(reg_8921_l23);
1019 regulator_disable(reg_8921_s4);
1020 return rc;
1021}
1022
1023static int hdmi_cec_power(int on)
1024{
1025 static int prev_on;
1026 int rc;
1027
1028 if (on == prev_on)
1029 return 0;
1030
1031 if (on) {
1032 rc = gpio_request(99, "HDMI_CEC_VAR");
1033 if (rc) {
1034 pr_err("'%s'(%d) gpio_request failed, rc=%d\n",
1035 "HDMI_CEC_VAR", 99, rc);
1036 goto error;
1037 }
1038 pr_debug("%s(on): success\n", __func__);
1039 } else {
1040 gpio_free(99);
1041 pr_debug("%s(off): success\n", __func__);
1042 }
1043
1044 prev_on = on;
1045
1046 return 0;
1047error:
1048 return rc;
1049}
1050#endif /* CONFIG_FB_MSM_HDMI_MSM_PANEL */
1051
1052void __init msm8960_init_fb(void)
1053{
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -08001054 platform_device_register(&msm_fb_device);
1055
Stepan Moskovchenko270888d2011-11-30 12:19:11 -08001056#ifdef CONFIG_FB_MSM_WRITEBACK_MSM_PANEL
1057 platform_device_register(&wfd_panel_device);
1058 platform_device_register(&wfd_device);
1059#endif
1060
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -08001061 if (machine_is_msm8960_sim())
1062 platform_device_register(&mipi_dsi_simulator_panel_device);
1063
1064 if (machine_is_msm8960_rumi3())
1065 platform_device_register(&mipi_dsi_renesas_panel_device);
1066
1067 if (!machine_is_msm8960_sim() && !machine_is_msm8960_rumi3()) {
1068 platform_device_register(&mipi_dsi_novatek_panel_device);
Ravishangar Kalyaname2d015c2012-01-26 14:47:14 -08001069 platform_device_register(&mipi_dsi_orise_panel_device);
Stepan Moskovchenko24cd8642011-11-29 13:07:53 -08001070
1071#ifdef CONFIG_FB_MSM_HDMI_MSM_PANEL
1072 platform_device_register(&hdmi_msm_device);
1073#endif
1074 }
1075
1076 if (machine_is_msm8960_liquid())
1077 platform_device_register(&mipi_dsi2lvds_bridge_device);
1078 else
1079 platform_device_register(&mipi_dsi_toshiba_panel_device);
1080
1081 if (machine_is_msm8x60_rumi3()) {
1082 msm_fb_register_device("mdp", NULL);
1083 mipi_dsi_pdata.target_type = 1;
1084 } else
1085 msm_fb_register_device("mdp", &mdp_pdata);
1086 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
1087#ifdef CONFIG_MSM_BUS_SCALING
1088 msm_fb_register_device("dtv", &dtv_pdata);
1089#endif
1090}
1091
1092void __init msm8960_allocate_fb_region(void)
1093{
1094 void *addr;
1095 unsigned long size;
1096
1097 size = MSM_FB_SIZE;
1098 addr = alloc_bootmem_align(size, 0x1000);
1099 msm_fb_resources[0].start = __pa(addr);
1100 msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
1101 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
1102 size, addr, __pa(addr));
1103}
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08001104
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07001105/**
1106 * Set MDP clocks to high frequency to avoid DSI underflow
1107 * when using high resolution 1200x1920 WUXGA panels
1108 */
1109static void set_mdp_clocks_for_wuxga(void)
1110{
1111 int i;
1112
1113 mdp_ui_vectors[0].ab = 2000000000;
1114 mdp_ui_vectors[0].ib = 2000000000;
1115 mdp_vga_vectors[0].ab = 2000000000;
1116 mdp_vga_vectors[0].ib = 2000000000;
1117 mdp_720p_vectors[0].ab = 2000000000;
1118 mdp_720p_vectors[0].ib = 2000000000;
1119 mdp_1080p_vectors[0].ab = 2000000000;
1120 mdp_1080p_vectors[0].ib = 2000000000;
1121
1122 mdp_pdata.mdp_core_clk_rate = 200000000;
1123
1124 for (i = 0; i < ARRAY_SIZE(mdp_core_clk_rate_table); i++)
1125 mdp_core_clk_rate_table[i] = 200000000;
1126
1127 if (hdmi_is_primary) {
1128 dtv_bus_def_vectors[0].ab = 2000000000;
1129 dtv_bus_def_vectors[0].ib = 2000000000;
1130 }
1131}
1132
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08001133void __init msm8960_set_display_params(char *prim_panel, char *ext_panel)
1134{
1135 if (strnlen(prim_panel, PANEL_NAME_MAX_LEN)) {
1136 strlcpy(msm_fb_pdata.prim_panel_name, prim_panel,
1137 PANEL_NAME_MAX_LEN);
1138 pr_debug("msm_fb_pdata.prim_panel_name %s\n",
1139 msm_fb_pdata.prim_panel_name);
1140
1141 if (!strncmp((char *)msm_fb_pdata.prim_panel_name,
1142 HDMI_PANEL_NAME, strnlen(HDMI_PANEL_NAME,
1143 PANEL_NAME_MAX_LEN))) {
1144 pr_debug("HDMI is the primary display by"
1145 " boot parameter\n");
1146 hdmi_is_primary = 1;
Ravishangar Kalyanam5f0c6412012-03-15 17:24:11 -07001147 set_mdp_clocks_for_wuxga();
1148 }
1149 if (!strncmp((char *)msm_fb_pdata.prim_panel_name,
1150 MIPI_VIDEO_TOSHIBA_WUXGA_PANEL_NAME,
1151 strnlen(MIPI_VIDEO_TOSHIBA_WUXGA_PANEL_NAME,
1152 PANEL_NAME_MAX_LEN))) {
1153 set_mdp_clocks_for_wuxga();
Ravishangar Kalyanam8c79ead2011-12-02 21:05:01 -08001154 }
1155 }
1156 if (strnlen(ext_panel, PANEL_NAME_MAX_LEN)) {
1157 strlcpy(msm_fb_pdata.ext_panel_name, ext_panel,
1158 PANEL_NAME_MAX_LEN);
1159 pr_debug("msm_fb_pdata.ext_panel_name %s\n",
1160 msm_fb_pdata.ext_panel_name);
1161 }
1162}