blob: 5f6c54bf4738e1af2164646e87919280d8227681 [file] [log] [blame]
Chintan Pandya250c2e52012-01-19 17:15:49 +05301/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
2 *
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#include <linux/init.h>
14#include <linux/ioport.h>
15#include <linux/platform_device.h>
16#include <linux/bootmem.h>
17#include <linux/regulator/consumer.h>
18#include <asm/mach-types.h>
19#include <asm/io.h>
20#include <mach/msm_bus_board.h>
21#include <mach/msm_memtypes.h>
22#include <mach/board.h>
23#include <mach/gpio.h>
24#include <mach/gpiomux.h>
25#include <mach/socinfo.h>
26#include <mach/rpc_pmapp.h>
27#include "devices.h"
28#include "board-msm7627a.h"
29
30#ifdef CONFIG_FB_MSM_TRIPLE_BUFFER
Jeevan Shriram8c23e072012-03-14 11:35:49 +053031#define MSM_FB_SIZE 0x4BF000
32#define MSM7x25A_MSM_FB_SIZE 0x1C2000
33#define MSM8x25_MSM_FB_SIZE 0x5FA000
Chintan Pandya250c2e52012-01-19 17:15:49 +053034#else
Jeevan Shriram8c23e072012-03-14 11:35:49 +053035#define MSM_FB_SIZE 0x32A000
36#define MSM7x25A_MSM_FB_SIZE 0x12C000
37#define MSM8x25_MSM_FB_SIZE 0x3FC000
Chintan Pandya250c2e52012-01-19 17:15:49 +053038#endif
39
Alhad Purnapatrec55856c2012-02-28 13:24:57 -080040/*
41 * Reserve enough v4l2 space for a double buffered full screen
42 * res image (864x480x1.5x2)
43 */
44#define MSM_V4L2_VIDEO_OVERLAY_BUF_SIZE 1244160
45
Chintan Pandya250c2e52012-01-19 17:15:49 +053046static unsigned fb_size = MSM_FB_SIZE;
47static int __init fb_size_setup(char *p)
48{
49 fb_size = memparse(p, NULL);
50 return 0;
51}
52
53early_param("fb_size", fb_size_setup);
54
Jeevan Shriram901a15f2012-03-09 11:53:23 +053055static uint32_t lcdc_truly_gpio_initialized;
56static struct regulator_bulk_data regs_truly_lcdc[] = {
57 { .supply = "rfrx1", .min_uV = 1800000, .max_uV = 1800000 },
58};
59
60#define SKU3_LCDC_GPIO_DISPLAY_RESET 90
61#define SKU3_LCDC_GPIO_SPI_MOSI 19
62#define SKU3_LCDC_GPIO_SPI_CLK 20
63#define SKU3_LCDC_GPIO_SPI_CS0_N 21
64#define SKU3_LCDC_LCD_CAMERA_LDO_2V8 35 /*LCD_CAMERA_LDO_2V8*/
65#define SKU3_LCDC_LCD_CAMERA_LDO_1V8 34 /*LCD_CAMERA_LDO_1V8*/
66#define SKU3_1_LCDC_LCD_CAMERA_LDO_1V8 58 /*LCD_CAMERA_LDO_1V8*/
67
68static uint32_t lcdc_truly_gpio_table[] = {
69 19,
70 20,
71 21,
72 89,
73 90,
74};
75
76static char *lcdc_gpio_name_table[5] = {
77 "spi_mosi",
78 "spi_clk",
79 "spi_cs",
80 "gpio_bkl_en",
81 "gpio_disp_reset",
82};
83
84static int lcdc_truly_gpio_init(void)
85{
86 int i;
87 int rc = 0;
88
89 if (!lcdc_truly_gpio_initialized) {
90 for (i = 0; i < ARRAY_SIZE(lcdc_truly_gpio_table); i++) {
91 rc = gpio_request(lcdc_truly_gpio_table[i],
92 lcdc_gpio_name_table[i]);
93 if (rc < 0) {
94 pr_err("Error request gpio %s\n",
95 lcdc_gpio_name_table[i]);
96 goto truly_gpio_fail;
97 }
98 rc = gpio_tlmm_config(GPIO_CFG(lcdc_truly_gpio_table[i],
99 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
100 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
101 if (rc < 0) {
102 pr_err("Error config lcdc gpio:%d\n",
103 lcdc_truly_gpio_table[i]);
104 goto truly_gpio_fail;
105 }
106 rc = gpio_direction_output(lcdc_truly_gpio_table[i], 0);
107 if (rc < 0) {
108 pr_err("Error direct lcdc gpio:%d\n",
109 lcdc_truly_gpio_table[i]);
110 goto truly_gpio_fail;
111 }
112 }
113
114 lcdc_truly_gpio_initialized = 1;
115 }
116
117 return rc;
118
119truly_gpio_fail:
120 for (; i >= 0; i--) {
121 pr_err("Freeing GPIO: %d", lcdc_truly_gpio_table[i]);
122 gpio_free(lcdc_truly_gpio_table[i]);
123 }
124
125 lcdc_truly_gpio_initialized = 0;
126 return rc;
127}
128
129
130void sku3_lcdc_lcd_camera_power_init(void)
131{
132 int rc = 0;
133 u32 socinfo = socinfo_get_platform_type();
134
135 /* LDO_EXT2V8 */
136 if (gpio_request(SKU3_LCDC_LCD_CAMERA_LDO_2V8, "lcd_camera_ldo_2v8")) {
137 pr_err("failed to request gpio lcd_camera_ldo_2v8\n");
138 return;
139 }
140
141 rc = gpio_tlmm_config(GPIO_CFG(SKU3_LCDC_LCD_CAMERA_LDO_2V8, 0,
142 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
143 GPIO_CFG_ENABLE);
144
145 if (rc < 0) {
146 pr_err("%s:unable to enable lcd_camera_ldo_2v8!\n", __func__);
147 goto fail_gpio2;
148 }
149
150 /* LDO_EVT1V8 */
151 if (socinfo == 0x0B) {
152 if (gpio_request(SKU3_LCDC_LCD_CAMERA_LDO_1V8,
153 "lcd_camera_ldo_1v8")) {
154 pr_err("failed to request gpio lcd_camera_ldo_1v8\n");
155 goto fail_gpio1;
156 }
157
158 rc = gpio_tlmm_config(GPIO_CFG(SKU3_LCDC_LCD_CAMERA_LDO_1V8, 0,
159 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
160 GPIO_CFG_ENABLE);
161
162 if (rc < 0) {
163 pr_err("%s: unable to enable lcdc_camera_ldo_1v8!\n",
164 __func__);
165 goto fail_gpio1;
166 }
Jeevan Shriram045cdc72012-03-27 07:04:15 +0530167 } else if (socinfo == 0x0F || machine_is_msm8625_qrd7()) {
Jeevan Shriram901a15f2012-03-09 11:53:23 +0530168 if (gpio_request(SKU3_1_LCDC_LCD_CAMERA_LDO_1V8,
169 "lcd_camera_ldo_1v8")) {
170 pr_err("failed to request gpio lcd_camera_ldo_1v8\n");
171 goto fail_gpio1;
172 }
173
174 rc = gpio_tlmm_config(GPIO_CFG(SKU3_1_LCDC_LCD_CAMERA_LDO_1V8,
175 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
176 GPIO_CFG_ENABLE);
177
178 if (rc < 0) {
179 pr_err("%s: unable to enable lcdc_camera_ldo_1v8!\n",
180 __func__);
181 goto fail_gpio1;
182 }
183 }
184
185 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_truly_lcdc),
186 regs_truly_lcdc);
187 if (rc)
188 pr_err("%s: could not get regulators: %d\n", __func__, rc);
189
190 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_truly_lcdc),
191 regs_truly_lcdc);
192 if (rc)
193 pr_err("%s: could not set voltages: %d\n", __func__, rc);
194
195 return;
196
197fail_gpio1:
198 if (socinfo == 0x0B)
199 gpio_free(SKU3_LCDC_LCD_CAMERA_LDO_1V8);
Jeevan Shriram045cdc72012-03-27 07:04:15 +0530200 else if (socinfo == 0x0F || machine_is_msm8625_qrd7())
Jeevan Shriram901a15f2012-03-09 11:53:23 +0530201 gpio_free(SKU3_1_LCDC_LCD_CAMERA_LDO_1V8);
202fail_gpio2:
203 gpio_free(SKU3_LCDC_LCD_CAMERA_LDO_2V8);
204 return;
205}
206
207int sku3_lcdc_lcd_camera_power_onoff(int on)
208{
209 int rc = 0;
210 u32 socinfo = socinfo_get_platform_type();
211
212 if (on) {
213 if (socinfo == 0x0B)
214 gpio_set_value_cansleep(SKU3_LCDC_LCD_CAMERA_LDO_1V8,
215 1);
Jeevan Shriram045cdc72012-03-27 07:04:15 +0530216 else if (socinfo == 0x0F || machine_is_msm8625_qrd7())
Jeevan Shriram901a15f2012-03-09 11:53:23 +0530217 gpio_set_value_cansleep(SKU3_1_LCDC_LCD_CAMERA_LDO_1V8,
218 1);
219
220 gpio_set_value_cansleep(SKU3_LCDC_LCD_CAMERA_LDO_2V8, 1);
221
222 rc = regulator_bulk_enable(ARRAY_SIZE(regs_truly_lcdc),
223 regs_truly_lcdc);
224 if (rc)
225 pr_err("%s: could not enable regulators: %d\n",
226 __func__, rc);
227 } else {
228 if (socinfo == 0x0B)
229 gpio_set_value_cansleep(SKU3_LCDC_LCD_CAMERA_LDO_1V8,
230 0);
Jeevan Shriram045cdc72012-03-27 07:04:15 +0530231 else if (socinfo == 0x0F || machine_is_msm8625_qrd7())
Jeevan Shriram901a15f2012-03-09 11:53:23 +0530232 gpio_set_value_cansleep(SKU3_1_LCDC_LCD_CAMERA_LDO_1V8,
233 0);
234
235 gpio_set_value_cansleep(SKU3_LCDC_LCD_CAMERA_LDO_2V8, 0);
236
237 rc = regulator_bulk_disable(ARRAY_SIZE(regs_truly_lcdc),
238 regs_truly_lcdc);
239 if (rc)
240 pr_err("%s: could not disable regulators: %d\n",
241 __func__, rc);
242 }
243
244 return rc;
245}
246
247static int sku3_lcdc_power_save(int on)
248{
249 int rc = 0;
250
251 if (on) {
252 sku3_lcdc_lcd_camera_power_onoff(1);
253 rc = lcdc_truly_gpio_init();
254 if (rc < 0) {
255 pr_err("%s(): Truly GPIO initializations failed",
256 __func__);
257 return rc;
258 }
259
260 if (lcdc_truly_gpio_initialized) {
261 /*LCD reset*/
262 gpio_set_value(SKU3_LCDC_GPIO_DISPLAY_RESET, 1);
263 msleep(20);
264 gpio_set_value(SKU3_LCDC_GPIO_DISPLAY_RESET, 0);
265 msleep(20);
266 gpio_set_value(SKU3_LCDC_GPIO_DISPLAY_RESET, 1);
267 msleep(20);
268 }
269 } else {
270 /* pull down LCD IO to avoid current leakage */
271 gpio_set_value(SKU3_LCDC_GPIO_SPI_MOSI, 0);
272 gpio_set_value(SKU3_LCDC_GPIO_SPI_CLK, 0);
273 gpio_set_value(SKU3_LCDC_GPIO_SPI_CS0_N, 0);
274 gpio_set_value(SKU3_LCDC_GPIO_DISPLAY_RESET, 0);
275
276 sku3_lcdc_lcd_camera_power_onoff(0);
277 }
278 return rc;
279}
280
281static struct msm_panel_common_pdata lcdc_truly_panel_data = {
282 .panel_config_gpio = NULL,
283 .gpio_num = lcdc_truly_gpio_table,
284};
285
286static struct platform_device lcdc_truly_panel_device = {
287 .name = "lcdc_truly_hvga_ips3p2335_pt",
288 .id = 0,
289 .dev = {
290 .platform_data = &lcdc_truly_panel_data,
291 }
292};
293
Chintan Pandya250c2e52012-01-19 17:15:49 +0530294static struct regulator_bulk_data regs_lcdc[] = {
295 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
296 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
297};
298static uint32_t lcdc_gpio_initialized;
299
300static void lcdc_toshiba_gpio_init(void)
301{
302 int rc = 0;
303 if (!lcdc_gpio_initialized) {
304 if (gpio_request(GPIO_SPI_CLK, "spi_clk")) {
305 pr_err("failed to request gpio spi_clk\n");
306 return;
307 }
308 if (gpio_request(GPIO_SPI_CS0_N, "spi_cs")) {
309 pr_err("failed to request gpio spi_cs0_N\n");
310 goto fail_gpio6;
311 }
312 if (gpio_request(GPIO_SPI_MOSI, "spi_mosi")) {
313 pr_err("failed to request gpio spi_mosi\n");
314 goto fail_gpio5;
315 }
316 if (gpio_request(GPIO_SPI_MISO, "spi_miso")) {
317 pr_err("failed to request gpio spi_miso\n");
318 goto fail_gpio4;
319 }
320 if (gpio_request(GPIO_DISPLAY_PWR_EN, "gpio_disp_pwr")) {
321 pr_err("failed to request gpio_disp_pwr\n");
322 goto fail_gpio3;
323 }
324 if (gpio_request(GPIO_BACKLIGHT_EN, "gpio_bkl_en")) {
325 pr_err("failed to request gpio_bkl_en\n");
326 goto fail_gpio2;
327 }
328 pmapp_disp_backlight_init();
329
330 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_lcdc),
331 regs_lcdc);
332 if (rc) {
333 pr_err("%s: could not get regulators: %d\n",
334 __func__, rc);
335 goto fail_gpio1;
336 }
337
338 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_lcdc),
339 regs_lcdc);
340 if (rc) {
341 pr_err("%s: could not set voltages: %d\n",
342 __func__, rc);
343 goto fail_vreg;
344 }
345 lcdc_gpio_initialized = 1;
346 }
347 return;
348fail_vreg:
349 regulator_bulk_free(ARRAY_SIZE(regs_lcdc), regs_lcdc);
350fail_gpio1:
351 gpio_free(GPIO_BACKLIGHT_EN);
352fail_gpio2:
353 gpio_free(GPIO_DISPLAY_PWR_EN);
354fail_gpio3:
355 gpio_free(GPIO_SPI_MISO);
356fail_gpio4:
357 gpio_free(GPIO_SPI_MOSI);
358fail_gpio5:
359 gpio_free(GPIO_SPI_CS0_N);
360fail_gpio6:
361 gpio_free(GPIO_SPI_CLK);
362 lcdc_gpio_initialized = 0;
363}
364
365static uint32_t lcdc_gpio_table[] = {
366 GPIO_SPI_CLK,
367 GPIO_SPI_CS0_N,
368 GPIO_SPI_MOSI,
369 GPIO_DISPLAY_PWR_EN,
370 GPIO_BACKLIGHT_EN,
371 GPIO_SPI_MISO,
372};
373
374static void config_lcdc_gpio_table(uint32_t *table, int len, unsigned enable)
375{
376 int n;
377
378 if (lcdc_gpio_initialized) {
379 /* All are IO Expander GPIOs */
380 for (n = 0; n < (len - 1); n++)
381 gpio_direction_output(table[n], 1);
382 }
383}
384
385static void lcdc_toshiba_config_gpios(int enable)
386{
387 config_lcdc_gpio_table(lcdc_gpio_table,
388 ARRAY_SIZE(lcdc_gpio_table), enable);
389}
390
391static int msm_fb_lcdc_power_save(int on)
392{
393 int rc = 0;
394 /* Doing the init of the LCDC GPIOs very late as they are from
395 an I2C-controlled IO Expander */
396 lcdc_toshiba_gpio_init();
397
398 if (lcdc_gpio_initialized) {
399 gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, on);
400 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, on);
401
402 rc = on ? regulator_bulk_enable(
403 ARRAY_SIZE(regs_lcdc), regs_lcdc) :
404 regulator_bulk_disable(
405 ARRAY_SIZE(regs_lcdc), regs_lcdc);
406
407 if (rc)
408 pr_err("%s: could not %sable regulators: %d\n",
409 __func__, on ? "en" : "dis", rc);
410 }
411
412 return rc;
413}
414
415static int lcdc_toshiba_set_bl(int level)
416{
417 int ret;
418
419 ret = pmapp_disp_backlight_set_brightness(level);
420 if (ret)
421 pr_err("%s: can't set lcd backlight!\n", __func__);
422
423 return ret;
424}
425
Jeevan Shriram901a15f2012-03-09 11:53:23 +0530426
427static int msm_lcdc_power_save(int on)
428{
429 int rc = 0;
Jeevan Shriram045cdc72012-03-27 07:04:15 +0530430 if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7())
Jeevan Shriram901a15f2012-03-09 11:53:23 +0530431 rc = sku3_lcdc_power_save(on);
432 else
433 rc = msm_fb_lcdc_power_save(on);
434
435 return rc;
436}
437
Chintan Pandya250c2e52012-01-19 17:15:49 +0530438static struct lcdc_platform_data lcdc_pdata = {
439 .lcdc_gpio_config = NULL,
Jeevan Shriram901a15f2012-03-09 11:53:23 +0530440 .lcdc_power_save = msm_lcdc_power_save,
Chintan Pandya250c2e52012-01-19 17:15:49 +0530441};
442
443static int lcd_panel_spi_gpio_num[] = {
444 GPIO_SPI_MOSI, /* spi_sdi */
445 GPIO_SPI_MISO, /* spi_sdoi */
446 GPIO_SPI_CLK, /* spi_clk */
447 GPIO_SPI_CS0_N, /* spi_cs */
448};
449
450static struct msm_panel_common_pdata lcdc_toshiba_panel_data = {
451 .panel_config_gpio = lcdc_toshiba_config_gpios,
452 .pmic_backlight = lcdc_toshiba_set_bl,
453 .gpio_num = lcd_panel_spi_gpio_num,
454};
455
456static struct platform_device lcdc_toshiba_panel_device = {
457 .name = "lcdc_toshiba_fwvga_pt",
458 .id = 0,
459 .dev = {
460 .platform_data = &lcdc_toshiba_panel_data,
461 }
462};
463
464static struct resource msm_fb_resources[] = {
465 {
466 .flags = IORESOURCE_DMA,
467 }
468};
469
Alhad Purnapatrec55856c2012-02-28 13:24:57 -0800470#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
471static struct resource msm_v4l2_video_overlay_resources[] = {
472 {
473 .flags = IORESOURCE_DMA,
474 }
475};
476#endif
477
Chintan Pandya250c2e52012-01-19 17:15:49 +0530478#define LCDC_TOSHIBA_FWVGA_PANEL_NAME "lcdc_toshiba_fwvga_pt"
479#define MIPI_CMD_RENESAS_FWVGA_PANEL_NAME "mipi_cmd_renesas_fwvga"
480
481static int msm_fb_detect_panel(const char *name)
482{
483 int ret = -ENODEV;
484
Taniya Dase3027e22012-02-27 16:32:27 +0530485 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf() ||
486 machine_is_msm8625_surf()) {
Chintan Pandya250c2e52012-01-19 17:15:49 +0530487 if (!strncmp(name, "lcdc_toshiba_fwvga_pt", 21) ||
488 !strncmp(name, "mipi_cmd_renesas_fwvga", 22))
489 ret = 0;
490 } else if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()) {
491 if (!strncmp(name, "mipi_cmd_renesas_fwvga", 22))
492 ret = 0;
493 } else if (machine_is_msm7627a_qrd1()) {
494 if (!strncmp(name, "mipi_video_truly_wvga", 21))
495 ret = 0;
Jeevan Shriram045cdc72012-03-27 07:04:15 +0530496 } else if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7()) {
Jeevan Shriram901a15f2012-03-09 11:53:23 +0530497 if (!strncmp(name, "lcdc_truly_hvga_ips3p2335_pt", 28))
498 ret = 0;
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530499 } else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) {
Jeevan Shrirame941df42012-01-23 12:40:21 +0530500 if (!strncmp(name, "mipi_cmd_nt35510_wvga", 21))
501 ret = 0;
Chintan Pandya250c2e52012-01-19 17:15:49 +0530502 }
503
504#if !defined(CONFIG_FB_MSM_LCDC_AUTO_DETECT) && \
505 !defined(CONFIG_FB_MSM_MIPI_PANEL_AUTO_DETECT) && \
506 !defined(CONFIG_FB_MSM_LCDC_MIPI_PANEL_AUTO_DETECT)
507 if (machine_is_msm7x27a_surf() ||
Taniya Dase3027e22012-02-27 16:32:27 +0530508 machine_is_msm7625a_surf() ||
509 machine_is_msm8625_surf()) {
Chintan Pandya250c2e52012-01-19 17:15:49 +0530510 if (!strncmp(name, LCDC_TOSHIBA_FWVGA_PANEL_NAME,
511 strnlen(LCDC_TOSHIBA_FWVGA_PANEL_NAME,
512 PANEL_NAME_MAX_LEN)))
513 return 0;
514 }
515#endif
516
517 return ret;
518}
519
520static int mipi_truly_set_bl(int on)
521{
522 gpio_set_value_cansleep(QRD_GPIO_BACKLIGHT_EN, !!on);
523
524 return 1;
525}
526
527static struct msm_fb_platform_data msm_fb_pdata = {
528 .detect_client = msm_fb_detect_panel,
529};
530
531static struct platform_device msm_fb_device = {
532 .name = "msm_fb",
533 .id = 0,
534 .num_resources = ARRAY_SIZE(msm_fb_resources),
535 .resource = msm_fb_resources,
536 .dev = {
537 .platform_data = &msm_fb_pdata,
538 }
539};
540
Alhad Purnapatrec55856c2012-02-28 13:24:57 -0800541#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
542static struct platform_device msm_v4l2_video_overlay_device = {
543 .name = "msm_v4l2_overlay_pd",
544 .id = 0,
545 .num_resources = ARRAY_SIZE(msm_v4l2_video_overlay_resources),
546 .resource = msm_v4l2_video_overlay_resources,
547 };
548#endif
549
550
Chintan Pandya250c2e52012-01-19 17:15:49 +0530551#ifdef CONFIG_FB_MSM_MIPI_DSI
552static int mipi_renesas_set_bl(int level)
553{
554 int ret;
555
556 ret = pmapp_disp_backlight_set_brightness(level);
557
558 if (ret)
559 pr_err("%s: can't set lcd backlight!\n", __func__);
560
561 return ret;
562}
563
564static struct msm_panel_common_pdata mipi_renesas_pdata = {
565 .pmic_backlight = mipi_renesas_set_bl,
566};
567
568
569static struct platform_device mipi_dsi_renesas_panel_device = {
570 .name = "mipi_renesas",
571 .id = 0,
572 .dev = {
573 .platform_data = &mipi_renesas_pdata,
574 }
575};
576#endif
577
Padmanabhan Komandurubea9c062012-04-09 10:33:48 +0530578static int evb_backlight_control(int level)
579{
580
581 int i = 0;
582 int remainder;
583 /* device address byte = 0x72 */
584 gpio_set_value_cansleep(96, 0);
585 udelay(67);
586 gpio_set_value_cansleep(96, 1);
587 udelay(33);
588 gpio_set_value_cansleep(96, 0);
589 udelay(33);
590 gpio_set_value_cansleep(96, 1);
591 udelay(67);
592 gpio_set_value_cansleep(96, 0);
593 udelay(33);
594 gpio_set_value_cansleep(96, 1);
595 udelay(67);
596 gpio_set_value_cansleep(96, 0);
597 udelay(33);
598 gpio_set_value_cansleep(96, 1);
599 udelay(67);
600 gpio_set_value_cansleep(96, 0);
601 udelay(67);
602 gpio_set_value_cansleep(96, 1);
603 udelay(33);
604 gpio_set_value_cansleep(96, 0);
605 udelay(67);
606 gpio_set_value_cansleep(96, 1);
607 udelay(33);
608 gpio_set_value_cansleep(96, 0);
609 udelay(33);
610 gpio_set_value_cansleep(96, 1);
611 udelay(67);
612 gpio_set_value_cansleep(96, 0);
613 udelay(67);
614 gpio_set_value_cansleep(96, 1);
615 udelay(33);
616
617 /* t-EOS and t-start */
618 gpio_set_value_cansleep(96, 0);
619 ndelay(4200);
620 gpio_set_value_cansleep(96, 1);
621 ndelay(9000);
622
623 /* data byte */
624 /* RFA = 0 */
625 gpio_set_value_cansleep(96, 0);
626 udelay(67);
627 gpio_set_value_cansleep(96, 1);
628 udelay(33);
629
630 /* Address bits */
631 gpio_set_value_cansleep(96, 0);
632 udelay(67);
633 gpio_set_value_cansleep(96, 1);
634 udelay(33);
635 gpio_set_value_cansleep(96, 0);
636 udelay(67);
637 gpio_set_value_cansleep(96, 1);
638 udelay(33);
639
640 /* Data bits */
641 for (i = 0; i < 5; i++) {
642 remainder = (level) & (16);
643 if (remainder) {
644 gpio_set_value_cansleep(96, 0);
645 udelay(33);
646 gpio_set_value_cansleep(96, 1);
647 udelay(67);
648 } else {
649 gpio_set_value_cansleep(96, 0);
650 udelay(67);
651 gpio_set_value_cansleep(96, 1);
652 udelay(33);
653 }
654 level = level << 1;
655 }
656
657 /* t-EOS */
658 gpio_set_value_cansleep(96, 0);
659 ndelay(12000);
660 gpio_set_value_cansleep(96, 1);
661 return 0;
662}
663
664
Chintan Pandya250c2e52012-01-19 17:15:49 +0530665static struct msm_panel_common_pdata mipi_truly_pdata = {
666 .pmic_backlight = mipi_truly_set_bl,
667};
668
669static struct platform_device mipi_dsi_truly_panel_device = {
670 .name = "mipi_truly",
671 .id = 0,
672 .dev = {
673 .platform_data = &mipi_truly_pdata,
674 }
675};
676
Jeevan Shrirame941df42012-01-23 12:40:21 +0530677static struct msm_panel_common_pdata mipi_NT35510_pdata = {
Padmanabhan Komandurubea9c062012-04-09 10:33:48 +0530678 .pmic_backlight = evb_backlight_control,
Jeevan Shrirame941df42012-01-23 12:40:21 +0530679};
680
681static struct platform_device mipi_dsi_NT35510_panel_device = {
682 .name = "mipi_NT35510",
683 .id = 0,
684 .dev = {
685 .platform_data = &mipi_NT35510_pdata,
686 }
687};
688
Pradeep Jilagam1b0a5df2012-02-23 08:00:24 +0530689static struct msm_panel_common_pdata mipi_NT35516_pdata = {
690 .pmic_backlight = NULL,
691};
692
693static struct platform_device mipi_dsi_NT35516_panel_device = {
694 .name = "mipi_truly_tft540960_1_e",
695 .id = 0,
696 .dev = {
697 .platform_data = &mipi_NT35516_pdata,
698 }
699};
700
Chintan Pandya250c2e52012-01-19 17:15:49 +0530701static struct platform_device *msm_fb_devices[] __initdata = {
702 &msm_fb_device,
703 &lcdc_toshiba_panel_device,
704#ifdef CONFIG_FB_MSM_MIPI_DSI
705 &mipi_dsi_renesas_panel_device,
706#endif
Alhad Purnapatrec55856c2012-02-28 13:24:57 -0800707#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
708 &msm_v4l2_video_overlay_device,
709#endif
Chintan Pandya250c2e52012-01-19 17:15:49 +0530710};
711
712static struct platform_device *qrd_fb_devices[] __initdata = {
713 &msm_fb_device,
714 &mipi_dsi_truly_panel_device,
715};
716
Jeevan Shriram901a15f2012-03-09 11:53:23 +0530717static struct platform_device *qrd3_fb_devices[] __initdata = {
718 &msm_fb_device,
719 &lcdc_truly_panel_device,
720};
721
Taniya Dasc868a2e2012-01-03 10:18:47 +0530722static struct platform_device *evb_fb_devices[] __initdata = {
Jeevan Shrirame941df42012-01-23 12:40:21 +0530723 &msm_fb_device,
724 &mipi_dsi_NT35510_panel_device,
Pradeep Jilagam1b0a5df2012-02-23 08:00:24 +0530725 &mipi_dsi_NT35516_panel_device,
Taniya Dasc868a2e2012-01-03 10:18:47 +0530726};
727
Chintan Pandya250c2e52012-01-19 17:15:49 +0530728void __init msm_msm7627a_allocate_memory_regions(void)
729{
730 void *addr;
731 unsigned long fb_size;
732
733 if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa())
734 fb_size = MSM7x25A_MSM_FB_SIZE;
Jeevan Shriram8c23e072012-03-14 11:35:49 +0530735 else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb())
736 fb_size = MSM8x25_MSM_FB_SIZE;
Chintan Pandya250c2e52012-01-19 17:15:49 +0530737 else
738 fb_size = MSM_FB_SIZE;
Jeevan Shriram8c23e072012-03-14 11:35:49 +0530739
Chintan Pandya250c2e52012-01-19 17:15:49 +0530740 addr = alloc_bootmem_align(fb_size, 0x1000);
741 msm_fb_resources[0].start = __pa(addr);
742 msm_fb_resources[0].end = msm_fb_resources[0].start + fb_size - 1;
743 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n", fb_size,
744 addr, __pa(addr));
Alhad Purnapatrec55856c2012-02-28 13:24:57 -0800745
746#ifdef CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE
747 fb_size = MSM_V4L2_VIDEO_OVERLAY_BUF_SIZE;
748 addr = alloc_bootmem_align(fb_size, 0x1000);
749 msm_v4l2_video_overlay_resources[0].start = __pa(addr);
750 msm_v4l2_video_overlay_resources[0].end =
751 msm_v4l2_video_overlay_resources[0].start + fb_size - 1;
752 pr_debug("allocating %lu bytes at %p (%lx physical) for v4l2\n",
753 fb_size, addr, __pa(addr));
754#endif
755
Chintan Pandya250c2e52012-01-19 17:15:49 +0530756}
757
758static struct msm_panel_common_pdata mdp_pdata = {
759 .gpio = 97,
760 .mdp_rev = MDP_REV_303,
761};
762
763#define GPIO_LCDC_BRDG_PD 128
764#define GPIO_LCDC_BRDG_RESET_N 129
765#define GPIO_LCD_DSI_SEL 125
766#define LCDC_RESET_PHYS 0x90008014
767
768static void __iomem *lcdc_reset_ptr;
769
770static unsigned mipi_dsi_gpio[] = {
771 GPIO_CFG(GPIO_LCDC_BRDG_RESET_N, 0, GPIO_CFG_OUTPUT,
772 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* LCDC_BRDG_RESET_N */
773 GPIO_CFG(GPIO_LCDC_BRDG_PD, 0, GPIO_CFG_OUTPUT,
774 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* LCDC_BRDG_PD */
775};
776
777static unsigned lcd_dsi_sel_gpio[] = {
778 GPIO_CFG(GPIO_LCD_DSI_SEL, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
779 GPIO_CFG_2MA),
780};
781
782enum {
783 DSI_SINGLE_LANE = 1,
784 DSI_TWO_LANES,
785};
786
787static int msm_fb_get_lane_config(void)
788{
789 /* For MSM7627A SURF/FFA and QRD */
790 int rc = DSI_TWO_LANES;
791 if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) {
792 rc = DSI_SINGLE_LANE;
793 pr_info("DSI_SINGLE_LANES\n");
794 } else {
795 pr_info("DSI_TWO_LANES\n");
796 }
797 return rc;
798}
799
800static int msm_fb_dsi_client_msm_reset(void)
801{
802 int rc = 0;
803
804 rc = gpio_request(GPIO_LCDC_BRDG_RESET_N, "lcdc_brdg_reset_n");
805 if (rc < 0) {
806 pr_err("failed to request lcd brdg reset_n\n");
807 return rc;
808 }
809
810 rc = gpio_request(GPIO_LCDC_BRDG_PD, "lcdc_brdg_pd");
811 if (rc < 0) {
812 pr_err("failed to request lcd brdg pd\n");
813 return rc;
814 }
815
816 rc = gpio_tlmm_config(mipi_dsi_gpio[0], GPIO_CFG_ENABLE);
817 if (rc) {
818 pr_err("Failed to enable LCDC Bridge reset enable\n");
819 goto gpio_error;
820 }
821
822 rc = gpio_tlmm_config(mipi_dsi_gpio[1], GPIO_CFG_ENABLE);
823 if (rc) {
824 pr_err("Failed to enable LCDC Bridge pd enable\n");
825 goto gpio_error2;
826 }
827
828 rc = gpio_direction_output(GPIO_LCDC_BRDG_RESET_N, 1);
829 rc |= gpio_direction_output(GPIO_LCDC_BRDG_PD, 1);
830 gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 0);
831
832 if (!rc) {
Taniya Dase3027e22012-02-27 16:32:27 +0530833 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf()
834 || machine_is_msm8625_surf()) {
Chintan Pandya250c2e52012-01-19 17:15:49 +0530835 lcdc_reset_ptr = ioremap_nocache(LCDC_RESET_PHYS,
836 sizeof(uint32_t));
837
838 if (!lcdc_reset_ptr)
839 return 0;
840 }
841 return rc;
842 } else {
843 goto gpio_error;
844 }
845
846gpio_error2:
847 pr_err("Failed GPIO bridge pd\n");
848 gpio_free(GPIO_LCDC_BRDG_PD);
849
850gpio_error:
851 pr_err("Failed GPIO bridge reset\n");
852 gpio_free(GPIO_LCDC_BRDG_RESET_N);
853 return rc;
854}
855
856static int mipi_truly_sel_mode(int video_mode)
857{
858 int rc = 0;
859
860 rc = gpio_request(GPIO_LCD_DSI_SEL, "lcd_dsi_sel");
861 if (rc < 0)
862 goto gpio_error;
863
864 rc = gpio_tlmm_config(lcd_dsi_sel_gpio[0], GPIO_CFG_ENABLE);
865 if (rc)
866 goto gpio_error;
867
868 rc = gpio_direction_output(GPIO_LCD_DSI_SEL, 1);
869 if (!rc) {
870 gpio_set_value_cansleep(GPIO_LCD_DSI_SEL, video_mode);
871 return rc;
872 } else {
873 goto gpio_error;
874 }
875
876gpio_error:
877 pr_err("mipi_truly_sel_mode failed\n");
878 gpio_free(GPIO_LCD_DSI_SEL);
879 return rc;
880}
881
882static int msm_fb_dsi_client_qrd1_reset(void)
883{
884 int rc = 0;
885
886 rc = gpio_request(GPIO_LCDC_BRDG_RESET_N, "lcdc_brdg_reset_n");
887 if (rc < 0) {
888 pr_err("failed to request lcd brdg reset_n\n");
889 return rc;
890 }
891
892 rc = gpio_tlmm_config(mipi_dsi_gpio[0], GPIO_CFG_ENABLE);
893 if (rc < 0) {
894 pr_err("Failed to enable LCDC Bridge reset enable\n");
895 return rc;
896 }
897
898 rc = gpio_direction_output(GPIO_LCDC_BRDG_RESET_N, 1);
899 if (rc < 0) {
900 pr_err("Failed GPIO bridge pd\n");
901 gpio_free(GPIO_LCDC_BRDG_RESET_N);
902 return rc;
903 }
904
905 mipi_truly_sel_mode(1);
906
907 return rc;
908}
909
Jeevan Shrirame941df42012-01-23 12:40:21 +0530910#define GPIO_QRD3_LCD_BRDG_RESET_N 85
911#define GPIO_QRD3_LCD_BACKLIGHT_EN 96
912#define GPIO_QRD3_LCD_EXT_2V85_EN 35
913#define GPIO_QRD3_LCD_EXT_1V8_EN 40
914
915static unsigned qrd3_mipi_dsi_gpio[] = {
916 GPIO_CFG(GPIO_QRD3_LCD_BRDG_RESET_N, 0, GPIO_CFG_OUTPUT,
917 GPIO_CFG_NO_PULL,
918 GPIO_CFG_2MA), /* GPIO_QRD3_LCD_BRDG_RESET_N */
919 GPIO_CFG(GPIO_QRD3_LCD_BACKLIGHT_EN, 0, GPIO_CFG_OUTPUT,
920 GPIO_CFG_NO_PULL,
921 GPIO_CFG_2MA), /* GPIO_QRD3_LCD_BACKLIGHT_EN */
922 GPIO_CFG(GPIO_QRD3_LCD_EXT_2V85_EN, 0, GPIO_CFG_OUTPUT,
923 GPIO_CFG_NO_PULL,
924 GPIO_CFG_2MA), /* GPIO_QRD3_LCD_EXT_2V85_EN */
925 GPIO_CFG(GPIO_QRD3_LCD_EXT_1V8_EN, 0, GPIO_CFG_OUTPUT,
926 GPIO_CFG_NO_PULL,
927 GPIO_CFG_2MA), /* GPIO_QRD3_LCD_EXT_1V8_EN */
928};
929
930static int msm_fb_dsi_client_qrd3_reset(void)
931{
932 int rc = 0;
933
934 rc = gpio_request(GPIO_QRD3_LCD_BRDG_RESET_N, "qrd3_lcd_brdg_reset_n");
935 if (rc < 0) {
936 pr_err("failed to request qrd3 lcd brdg reset_n\n");
937 return rc;
938 }
939
Jeevan Shrirame941df42012-01-23 12:40:21 +0530940 return rc;
941}
942
Chintan Pandya250c2e52012-01-19 17:15:49 +0530943static int msm_fb_dsi_client_reset(void)
944{
945 int rc = 0;
946
947 if (machine_is_msm7627a_qrd1())
948 rc = msm_fb_dsi_client_qrd1_reset();
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530949 else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb())
Jeevan Shrirame941df42012-01-23 12:40:21 +0530950 rc = msm_fb_dsi_client_qrd3_reset();
Chintan Pandya250c2e52012-01-19 17:15:49 +0530951 else
952 rc = msm_fb_dsi_client_msm_reset();
953
954 return rc;
955
956}
957
958static struct regulator_bulk_data regs_dsi[] = {
959 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
960 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
961};
962
963static int dsi_gpio_initialized;
964
965static int mipi_dsi_panel_msm_power(int on)
966{
967 int rc = 0;
968 uint32_t lcdc_reset_cfg;
969
970 /* I2C-controlled GPIO Expander -init of the GPIOs very late */
971 if (unlikely(!dsi_gpio_initialized)) {
972 pmapp_disp_backlight_init();
973
974 rc = gpio_request(GPIO_DISPLAY_PWR_EN, "gpio_disp_pwr");
975 if (rc < 0) {
976 pr_err("failed to request gpio_disp_pwr\n");
977 return rc;
978 }
979
Taniya Dase3027e22012-02-27 16:32:27 +0530980 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf()
981 || machine_is_msm8625_surf()) {
Chintan Pandya250c2e52012-01-19 17:15:49 +0530982 rc = gpio_direction_output(GPIO_DISPLAY_PWR_EN, 1);
983 if (rc < 0) {
984 pr_err("failed to enable display pwr\n");
985 goto fail_gpio1;
986 }
987
988 rc = gpio_request(GPIO_BACKLIGHT_EN, "gpio_bkl_en");
989 if (rc < 0) {
990 pr_err("failed to request gpio_bkl_en\n");
991 goto fail_gpio1;
992 }
993
994 rc = gpio_direction_output(GPIO_BACKLIGHT_EN, 1);
995 if (rc < 0) {
996 pr_err("failed to enable backlight\n");
997 goto fail_gpio2;
998 }
999 }
1000
1001 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_dsi), regs_dsi);
1002 if (rc) {
1003 pr_err("%s: could not get regulators: %d\n",
1004 __func__, rc);
1005 goto fail_gpio2;
1006 }
1007
1008 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_dsi),
1009 regs_dsi);
1010 if (rc) {
1011 pr_err("%s: could not set voltages: %d\n",
1012 __func__, rc);
1013 goto fail_vreg;
1014 }
1015 if (pmapp_disp_backlight_set_brightness(100))
1016 pr_err("backlight set brightness failed\n");
1017
1018 dsi_gpio_initialized = 1;
1019 }
Taniya Dase3027e22012-02-27 16:32:27 +05301020 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf() ||
1021 machine_is_msm8625_surf()) {
Chintan Pandya250c2e52012-01-19 17:15:49 +05301022 gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, on);
1023 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, on);
1024 } else if (machine_is_msm7x27a_ffa() ||
1025 machine_is_msm7625a_ffa()) {
1026 if (on) {
1027 /* This line drives an active low pin on FFA */
1028 rc = gpio_direction_output(GPIO_DISPLAY_PWR_EN, !on);
1029 if (rc < 0)
1030 pr_err("failed to set direction for "
1031 "display pwr\n");
1032 } else {
1033 gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, !on);
1034 rc = gpio_direction_input(GPIO_DISPLAY_PWR_EN);
1035 if (rc < 0)
1036 pr_err("failed to set direction for "
1037 "display pwr\n");
1038 }
1039 }
1040
1041 if (on) {
1042 gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 0);
1043
1044 if (machine_is_msm7x27a_surf() ||
Taniya Dase3027e22012-02-27 16:32:27 +05301045 machine_is_msm7625a_surf() ||
1046 machine_is_msm8625_surf()) {
Chintan Pandya250c2e52012-01-19 17:15:49 +05301047 lcdc_reset_cfg = readl_relaxed(lcdc_reset_ptr);
1048 rmb();
1049 lcdc_reset_cfg &= ~1;
1050
1051 writel_relaxed(lcdc_reset_cfg, lcdc_reset_ptr);
1052 msleep(20);
1053 wmb();
1054 lcdc_reset_cfg |= 1;
1055 writel_relaxed(lcdc_reset_cfg, lcdc_reset_ptr);
1056 } else {
1057 gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 0);
1058 msleep(20);
1059 gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1);
1060 }
1061 } else {
1062 gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 1);
Chintan Pandya250c2e52012-01-19 17:15:49 +05301063 }
1064
1065 rc = on ? regulator_bulk_enable(ARRAY_SIZE(regs_dsi), regs_dsi) :
1066 regulator_bulk_disable(ARRAY_SIZE(regs_dsi), regs_dsi);
1067
1068 if (rc)
1069 pr_err("%s: could not %sable regulators: %d\n",
1070 __func__, on ? "en" : "dis", rc);
1071
1072 return rc;
1073fail_vreg:
1074 regulator_bulk_free(ARRAY_SIZE(regs_dsi), regs_dsi);
1075fail_gpio2:
1076 gpio_free(GPIO_BACKLIGHT_EN);
1077fail_gpio1:
1078 gpio_free(GPIO_DISPLAY_PWR_EN);
1079 dsi_gpio_initialized = 0;
1080 return rc;
1081}
1082
1083static int mipi_dsi_panel_qrd1_power(int on)
1084{
1085 int rc = 0;
1086
1087 if (!dsi_gpio_initialized) {
1088 rc = gpio_request(QRD_GPIO_BACKLIGHT_EN, "gpio_bkl_en");
1089 if (rc < 0)
1090 return rc;
1091
1092 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_BACKLIGHT_EN, 0,
1093 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1094 GPIO_CFG_ENABLE);
1095 if (rc < 0) {
1096 pr_err("failed GPIO_BACKLIGHT_EN tlmm config\n");
1097 return rc;
1098 }
1099
1100 rc = gpio_direction_output(QRD_GPIO_BACKLIGHT_EN, 1);
1101 if (rc < 0) {
1102 pr_err("failed to enable backlight\n");
1103 gpio_free(QRD_GPIO_BACKLIGHT_EN);
1104 return rc;
1105 }
1106 dsi_gpio_initialized = 1;
1107 }
1108
1109 gpio_set_value_cansleep(QRD_GPIO_BACKLIGHT_EN, !!on);
1110
Jeevan Shrirame941df42012-01-23 12:40:21 +05301111 if (on) {
Chintan Pandya250c2e52012-01-19 17:15:49 +05301112 gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1);
1113 msleep(20);
1114 gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 0);
1115 msleep(20);
1116 gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1);
1117
1118 }
1119
1120 return rc;
1121}
1122
Jeevan Shrirame941df42012-01-23 12:40:21 +05301123static int qrd3_dsi_gpio_initialized;
1124
1125static int mipi_dsi_panel_qrd3_power(int on)
1126{
1127 int rc = 0;
1128
1129 if (!qrd3_dsi_gpio_initialized) {
1130 rc = gpio_request(GPIO_QRD3_LCD_BACKLIGHT_EN,
1131 "qrd3_gpio_bkl_en");
1132 if (rc < 0)
1133 return rc;
1134
1135 rc = gpio_tlmm_config(GPIO_CFG(GPIO_QRD3_LCD_BACKLIGHT_EN, 0,
Padmanabhan Komandurubea9c062012-04-09 10:33:48 +05301136 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA),
Jeevan Shrirame941df42012-01-23 12:40:21 +05301137 GPIO_CFG_ENABLE);
1138 if (rc < 0) {
1139 pr_err("failed QRD3 GPIO_BACKLIGHT_EN tlmm config\n");
1140 return rc;
1141 }
1142 rc = gpio_direction_output(GPIO_QRD3_LCD_BACKLIGHT_EN, 1);
1143 if (rc < 0) {
1144 pr_err("failed to enable backlight\n");
1145 gpio_free(GPIO_QRD3_LCD_BACKLIGHT_EN);
1146 return rc;
1147 }
1148
1149 rc = gpio_request(GPIO_QRD3_LCD_EXT_2V85_EN,
1150 "qrd3_gpio_ext_2v85_en");
1151 if (rc < 0)
1152 return rc;
1153
1154 rc = gpio_tlmm_config(GPIO_CFG(GPIO_QRD3_LCD_EXT_2V85_EN, 0,
1155 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1156 GPIO_CFG_ENABLE);
1157 if (rc < 0) {
1158 pr_err("failed QRD3 GPIO_QRD3_LCD_EXT_2V85_EN tlmm config\n");
1159 return rc;
1160 }
1161
1162 rc = gpio_direction_output(GPIO_QRD3_LCD_EXT_2V85_EN, 1);
1163 if (rc < 0) {
1164 pr_err("failed to enable external 2V85\n");
1165 gpio_free(GPIO_QRD3_LCD_EXT_2V85_EN);
1166 return rc;
1167 }
1168
1169 rc = gpio_request(GPIO_QRD3_LCD_EXT_1V8_EN,
1170 "qrd3_gpio_ext_1v8_en");
1171 if (rc < 0)
1172 return rc;
1173
1174 rc = gpio_tlmm_config(GPIO_CFG(GPIO_QRD3_LCD_EXT_1V8_EN, 0,
1175 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1176 GPIO_CFG_ENABLE);
1177 if (rc < 0) {
1178 pr_err("failed QRD3 GPIO_QRD3_LCD_EXT_1V8_EN tlmm config\n");
1179 return rc;
1180 }
1181
1182 rc = gpio_direction_output(GPIO_QRD3_LCD_EXT_1V8_EN, 1);
1183 if (rc < 0) {
1184 pr_err("failed to enable external 1v8\n");
1185 gpio_free(GPIO_QRD3_LCD_EXT_1V8_EN);
1186 return rc;
1187 }
1188
1189 qrd3_dsi_gpio_initialized = 1;
1190 }
1191
Padmanabhan Komandurubea9c062012-04-09 10:33:48 +05301192 if (on) {
1193 gpio_set_value_cansleep(GPIO_QRD3_LCD_BACKLIGHT_EN, 1);
1194 udelay(190);
1195 gpio_set_value_cansleep(GPIO_QRD3_LCD_BACKLIGHT_EN, 0);
1196 udelay(286);
1197 gpio_set_value_cansleep(GPIO_QRD3_LCD_BACKLIGHT_EN, 1);
1198 /* 1 wire mode starts from this low to high transition */
1199 udelay(50);
1200 } else
1201 gpio_set_value_cansleep(GPIO_QRD3_LCD_BACKLIGHT_EN, !!on);
1202
Jeevan Shrirame941df42012-01-23 12:40:21 +05301203 gpio_set_value_cansleep(GPIO_QRD3_LCD_EXT_2V85_EN, !!on);
1204 gpio_set_value_cansleep(GPIO_QRD3_LCD_EXT_1V8_EN, !!on);
1205
1206 if (on) {
Padmanabhan Komanduru599d3552012-02-21 16:53:05 +05301207 rc = gpio_tlmm_config(qrd3_mipi_dsi_gpio[0], GPIO_CFG_ENABLE);
1208
1209 if (rc < 0) {
1210 pr_err("Failed to enable LCD Bridge reset enable\n");
1211 return rc;
1212 }
1213
1214 rc = gpio_direction_output(GPIO_QRD3_LCD_BRDG_RESET_N, 1);
1215
1216 if (rc < 0) {
1217 pr_err("Failed GPIO bridge Reset\n");
1218 gpio_free(GPIO_QRD3_LCD_BRDG_RESET_N);
1219 return rc;
1220 }
1221
Jeevan Shrirame941df42012-01-23 12:40:21 +05301222 msleep(20);
1223 gpio_set_value_cansleep(GPIO_QRD3_LCD_BRDG_RESET_N, 0);
1224 msleep(20);
1225 gpio_set_value_cansleep(GPIO_QRD3_LCD_BRDG_RESET_N, 1);
1226 msleep(20);
Padmanabhan Komanduru599d3552012-02-21 16:53:05 +05301227 } else {
1228 gpio_tlmm_config(GPIO_CFG(GPIO_QRD3_LCD_BRDG_RESET_N, 0,
1229 GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1230 GPIO_CFG_DISABLE);
Jeevan Shrirame941df42012-01-23 12:40:21 +05301231 }
1232
1233 return rc;
1234}
1235
Chintan Pandya250c2e52012-01-19 17:15:49 +05301236static int mipi_dsi_panel_power(int on)
1237{
1238 int rc = 0;
1239
1240 if (machine_is_msm7627a_qrd1())
1241 rc = mipi_dsi_panel_qrd1_power(on);
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301242 else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb())
Jeevan Shrirame941df42012-01-23 12:40:21 +05301243 rc = mipi_dsi_panel_qrd3_power(on);
Chintan Pandya250c2e52012-01-19 17:15:49 +05301244 else
1245 rc = mipi_dsi_panel_msm_power(on);
1246 return rc;
1247}
1248
1249#define MDP_303_VSYNC_GPIO 97
1250
Jeevan Shriram901a15f2012-03-09 11:53:23 +05301251#ifdef CONFIG_FB_MSM_MIPI_DSI
Chintan Pandya250c2e52012-01-19 17:15:49 +05301252static struct mipi_dsi_platform_data mipi_dsi_pdata = {
1253 .vsync_gpio = MDP_303_VSYNC_GPIO,
1254 .dsi_power_save = mipi_dsi_panel_power,
1255 .dsi_client_reset = msm_fb_dsi_client_reset,
1256 .get_lane_config = msm_fb_get_lane_config,
1257};
1258#endif
1259
Padmanabhan Komanduru92f9a722012-04-04 19:28:02 +05301260static char prim_panel_name[PANEL_NAME_MAX_LEN];
1261static int __init prim_display_setup(char *param)
1262{
1263 if (strnlen(param, PANEL_NAME_MAX_LEN))
1264 strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
1265 return 0;
1266}
1267early_param("prim_display", prim_display_setup);
1268
1269void msm7x27a_set_display_params(char *prim_panel)
1270{
1271 if (strnlen(prim_panel, PANEL_NAME_MAX_LEN)) {
1272 strlcpy(msm_fb_pdata.prim_panel_name, prim_panel,
1273 PANEL_NAME_MAX_LEN);
1274 pr_debug("msm_fb_pdata.prim_panel_name %s\n",
1275 msm_fb_pdata.prim_panel_name);
1276 }
1277}
1278
Chintan Pandya250c2e52012-01-19 17:15:49 +05301279void __init msm_fb_add_devices(void)
1280{
Padmanabhan Komanduru92f9a722012-04-04 19:28:02 +05301281 msm7x27a_set_display_params(prim_panel_name);
Chintan Pandya250c2e52012-01-19 17:15:49 +05301282 if (machine_is_msm7627a_qrd1())
1283 platform_add_devices(qrd_fb_devices,
1284 ARRAY_SIZE(qrd_fb_devices));
Padmanabhan Komandurubea9c062012-04-09 10:33:48 +05301285 else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) {
1286 mipi_NT35510_pdata.bl_lock = 1;
Taniya Dasc868a2e2012-01-03 10:18:47 +05301287 platform_add_devices(evb_fb_devices,
1288 ARRAY_SIZE(evb_fb_devices));
Padmanabhan Komandurubea9c062012-04-09 10:33:48 +05301289 } else if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7()) {
Jeevan Shriram901a15f2012-03-09 11:53:23 +05301290 sku3_lcdc_lcd_camera_power_init();
1291 platform_add_devices(qrd3_fb_devices,
1292 ARRAY_SIZE(qrd3_fb_devices));
1293 } else
Chintan Pandya250c2e52012-01-19 17:15:49 +05301294 platform_add_devices(msm_fb_devices,
1295 ARRAY_SIZE(msm_fb_devices));
1296
1297 msm_fb_register_device("mdp", &mdp_pdata);
Taniya Dase3027e22012-02-27 16:32:27 +05301298 if (machine_is_msm7625a_surf() || machine_is_msm7x27a_surf() ||
Jeevan Shriram045cdc72012-03-27 07:04:15 +05301299 machine_is_msm8625_surf() || machine_is_msm7627a_qrd3()
1300 || machine_is_msm8625_qrd7())
Chintan Pandya250c2e52012-01-19 17:15:49 +05301301 msm_fb_register_device("lcdc", &lcdc_pdata);
Jeevan Shriram901a15f2012-03-09 11:53:23 +05301302#ifdef CONFIG_FB_MSM_MIPI_DSI
Chintan Pandya250c2e52012-01-19 17:15:49 +05301303 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
1304#endif
1305}