blob: e4d44b42868187ca98bc25928839ca81708433c7 [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
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +053031#define MSM_FB_SIZE 0x261000
Chintan Pandya250c2e52012-01-19 17:15:49 +053032#define MSM7x25A_MSM_FB_SIZE 0xE1000
33#else
Padmanabhan Komanduruede0a632012-01-25 12:01:28 +053034#define MSM_FB_SIZE 0x196000
Chintan Pandya250c2e52012-01-19 17:15:49 +053035#define MSM7x25A_MSM_FB_SIZE 0x96000
36#endif
37
38static unsigned fb_size = MSM_FB_SIZE;
39static int __init fb_size_setup(char *p)
40{
41 fb_size = memparse(p, NULL);
42 return 0;
43}
44
45early_param("fb_size", fb_size_setup);
46
Jeevan Shriram901a15f2012-03-09 11:53:23 +053047static uint32_t lcdc_truly_gpio_initialized;
48static struct regulator_bulk_data regs_truly_lcdc[] = {
49 { .supply = "rfrx1", .min_uV = 1800000, .max_uV = 1800000 },
50};
51
52#define SKU3_LCDC_GPIO_DISPLAY_RESET 90
53#define SKU3_LCDC_GPIO_SPI_MOSI 19
54#define SKU3_LCDC_GPIO_SPI_CLK 20
55#define SKU3_LCDC_GPIO_SPI_CS0_N 21
56#define SKU3_LCDC_LCD_CAMERA_LDO_2V8 35 /*LCD_CAMERA_LDO_2V8*/
57#define SKU3_LCDC_LCD_CAMERA_LDO_1V8 34 /*LCD_CAMERA_LDO_1V8*/
58#define SKU3_1_LCDC_LCD_CAMERA_LDO_1V8 58 /*LCD_CAMERA_LDO_1V8*/
59
60static uint32_t lcdc_truly_gpio_table[] = {
61 19,
62 20,
63 21,
64 89,
65 90,
66};
67
68static char *lcdc_gpio_name_table[5] = {
69 "spi_mosi",
70 "spi_clk",
71 "spi_cs",
72 "gpio_bkl_en",
73 "gpio_disp_reset",
74};
75
76static int lcdc_truly_gpio_init(void)
77{
78 int i;
79 int rc = 0;
80
81 if (!lcdc_truly_gpio_initialized) {
82 for (i = 0; i < ARRAY_SIZE(lcdc_truly_gpio_table); i++) {
83 rc = gpio_request(lcdc_truly_gpio_table[i],
84 lcdc_gpio_name_table[i]);
85 if (rc < 0) {
86 pr_err("Error request gpio %s\n",
87 lcdc_gpio_name_table[i]);
88 goto truly_gpio_fail;
89 }
90 rc = gpio_tlmm_config(GPIO_CFG(lcdc_truly_gpio_table[i],
91 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
92 GPIO_CFG_2MA), GPIO_CFG_ENABLE);
93 if (rc < 0) {
94 pr_err("Error config lcdc gpio:%d\n",
95 lcdc_truly_gpio_table[i]);
96 goto truly_gpio_fail;
97 }
98 rc = gpio_direction_output(lcdc_truly_gpio_table[i], 0);
99 if (rc < 0) {
100 pr_err("Error direct lcdc gpio:%d\n",
101 lcdc_truly_gpio_table[i]);
102 goto truly_gpio_fail;
103 }
104 }
105
106 lcdc_truly_gpio_initialized = 1;
107 }
108
109 return rc;
110
111truly_gpio_fail:
112 for (; i >= 0; i--) {
113 pr_err("Freeing GPIO: %d", lcdc_truly_gpio_table[i]);
114 gpio_free(lcdc_truly_gpio_table[i]);
115 }
116
117 lcdc_truly_gpio_initialized = 0;
118 return rc;
119}
120
121
122void sku3_lcdc_lcd_camera_power_init(void)
123{
124 int rc = 0;
125 u32 socinfo = socinfo_get_platform_type();
126
127 /* LDO_EXT2V8 */
128 if (gpio_request(SKU3_LCDC_LCD_CAMERA_LDO_2V8, "lcd_camera_ldo_2v8")) {
129 pr_err("failed to request gpio lcd_camera_ldo_2v8\n");
130 return;
131 }
132
133 rc = gpio_tlmm_config(GPIO_CFG(SKU3_LCDC_LCD_CAMERA_LDO_2V8, 0,
134 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
135 GPIO_CFG_ENABLE);
136
137 if (rc < 0) {
138 pr_err("%s:unable to enable lcd_camera_ldo_2v8!\n", __func__);
139 goto fail_gpio2;
140 }
141
142 /* LDO_EVT1V8 */
143 if (socinfo == 0x0B) {
144 if (gpio_request(SKU3_LCDC_LCD_CAMERA_LDO_1V8,
145 "lcd_camera_ldo_1v8")) {
146 pr_err("failed to request gpio lcd_camera_ldo_1v8\n");
147 goto fail_gpio1;
148 }
149
150 rc = gpio_tlmm_config(GPIO_CFG(SKU3_LCDC_LCD_CAMERA_LDO_1V8, 0,
151 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
152 GPIO_CFG_ENABLE);
153
154 if (rc < 0) {
155 pr_err("%s: unable to enable lcdc_camera_ldo_1v8!\n",
156 __func__);
157 goto fail_gpio1;
158 }
Jeevan Shriram045cdc72012-03-27 07:04:15 +0530159 } else if (socinfo == 0x0F || machine_is_msm8625_qrd7()) {
Jeevan Shriram901a15f2012-03-09 11:53:23 +0530160 if (gpio_request(SKU3_1_LCDC_LCD_CAMERA_LDO_1V8,
161 "lcd_camera_ldo_1v8")) {
162 pr_err("failed to request gpio lcd_camera_ldo_1v8\n");
163 goto fail_gpio1;
164 }
165
166 rc = gpio_tlmm_config(GPIO_CFG(SKU3_1_LCDC_LCD_CAMERA_LDO_1V8,
167 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
168 GPIO_CFG_ENABLE);
169
170 if (rc < 0) {
171 pr_err("%s: unable to enable lcdc_camera_ldo_1v8!\n",
172 __func__);
173 goto fail_gpio1;
174 }
175 }
176
177 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_truly_lcdc),
178 regs_truly_lcdc);
179 if (rc)
180 pr_err("%s: could not get regulators: %d\n", __func__, rc);
181
182 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_truly_lcdc),
183 regs_truly_lcdc);
184 if (rc)
185 pr_err("%s: could not set voltages: %d\n", __func__, rc);
186
187 return;
188
189fail_gpio1:
190 if (socinfo == 0x0B)
191 gpio_free(SKU3_LCDC_LCD_CAMERA_LDO_1V8);
Jeevan Shriram045cdc72012-03-27 07:04:15 +0530192 else if (socinfo == 0x0F || machine_is_msm8625_qrd7())
Jeevan Shriram901a15f2012-03-09 11:53:23 +0530193 gpio_free(SKU3_1_LCDC_LCD_CAMERA_LDO_1V8);
194fail_gpio2:
195 gpio_free(SKU3_LCDC_LCD_CAMERA_LDO_2V8);
196 return;
197}
198
199int sku3_lcdc_lcd_camera_power_onoff(int on)
200{
201 int rc = 0;
202 u32 socinfo = socinfo_get_platform_type();
203
204 if (on) {
205 if (socinfo == 0x0B)
206 gpio_set_value_cansleep(SKU3_LCDC_LCD_CAMERA_LDO_1V8,
207 1);
Jeevan Shriram045cdc72012-03-27 07:04:15 +0530208 else if (socinfo == 0x0F || machine_is_msm8625_qrd7())
Jeevan Shriram901a15f2012-03-09 11:53:23 +0530209 gpio_set_value_cansleep(SKU3_1_LCDC_LCD_CAMERA_LDO_1V8,
210 1);
211
212 gpio_set_value_cansleep(SKU3_LCDC_LCD_CAMERA_LDO_2V8, 1);
213
214 rc = regulator_bulk_enable(ARRAY_SIZE(regs_truly_lcdc),
215 regs_truly_lcdc);
216 if (rc)
217 pr_err("%s: could not enable regulators: %d\n",
218 __func__, rc);
219 } else {
220 if (socinfo == 0x0B)
221 gpio_set_value_cansleep(SKU3_LCDC_LCD_CAMERA_LDO_1V8,
222 0);
Jeevan Shriram045cdc72012-03-27 07:04:15 +0530223 else if (socinfo == 0x0F || machine_is_msm8625_qrd7())
Jeevan Shriram901a15f2012-03-09 11:53:23 +0530224 gpio_set_value_cansleep(SKU3_1_LCDC_LCD_CAMERA_LDO_1V8,
225 0);
226
227 gpio_set_value_cansleep(SKU3_LCDC_LCD_CAMERA_LDO_2V8, 0);
228
229 rc = regulator_bulk_disable(ARRAY_SIZE(regs_truly_lcdc),
230 regs_truly_lcdc);
231 if (rc)
232 pr_err("%s: could not disable regulators: %d\n",
233 __func__, rc);
234 }
235
236 return rc;
237}
238
239static int sku3_lcdc_power_save(int on)
240{
241 int rc = 0;
242
243 if (on) {
244 sku3_lcdc_lcd_camera_power_onoff(1);
245 rc = lcdc_truly_gpio_init();
246 if (rc < 0) {
247 pr_err("%s(): Truly GPIO initializations failed",
248 __func__);
249 return rc;
250 }
251
252 if (lcdc_truly_gpio_initialized) {
253 /*LCD reset*/
254 gpio_set_value(SKU3_LCDC_GPIO_DISPLAY_RESET, 1);
255 msleep(20);
256 gpio_set_value(SKU3_LCDC_GPIO_DISPLAY_RESET, 0);
257 msleep(20);
258 gpio_set_value(SKU3_LCDC_GPIO_DISPLAY_RESET, 1);
259 msleep(20);
260 }
261 } else {
262 /* pull down LCD IO to avoid current leakage */
263 gpio_set_value(SKU3_LCDC_GPIO_SPI_MOSI, 0);
264 gpio_set_value(SKU3_LCDC_GPIO_SPI_CLK, 0);
265 gpio_set_value(SKU3_LCDC_GPIO_SPI_CS0_N, 0);
266 gpio_set_value(SKU3_LCDC_GPIO_DISPLAY_RESET, 0);
267
268 sku3_lcdc_lcd_camera_power_onoff(0);
269 }
270 return rc;
271}
272
273static struct msm_panel_common_pdata lcdc_truly_panel_data = {
274 .panel_config_gpio = NULL,
275 .gpio_num = lcdc_truly_gpio_table,
276};
277
278static struct platform_device lcdc_truly_panel_device = {
279 .name = "lcdc_truly_hvga_ips3p2335_pt",
280 .id = 0,
281 .dev = {
282 .platform_data = &lcdc_truly_panel_data,
283 }
284};
285
Chintan Pandya250c2e52012-01-19 17:15:49 +0530286static struct regulator_bulk_data regs_lcdc[] = {
287 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
288 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
289};
290static uint32_t lcdc_gpio_initialized;
291
292static void lcdc_toshiba_gpio_init(void)
293{
294 int rc = 0;
295 if (!lcdc_gpio_initialized) {
296 if (gpio_request(GPIO_SPI_CLK, "spi_clk")) {
297 pr_err("failed to request gpio spi_clk\n");
298 return;
299 }
300 if (gpio_request(GPIO_SPI_CS0_N, "spi_cs")) {
301 pr_err("failed to request gpio spi_cs0_N\n");
302 goto fail_gpio6;
303 }
304 if (gpio_request(GPIO_SPI_MOSI, "spi_mosi")) {
305 pr_err("failed to request gpio spi_mosi\n");
306 goto fail_gpio5;
307 }
308 if (gpio_request(GPIO_SPI_MISO, "spi_miso")) {
309 pr_err("failed to request gpio spi_miso\n");
310 goto fail_gpio4;
311 }
312 if (gpio_request(GPIO_DISPLAY_PWR_EN, "gpio_disp_pwr")) {
313 pr_err("failed to request gpio_disp_pwr\n");
314 goto fail_gpio3;
315 }
316 if (gpio_request(GPIO_BACKLIGHT_EN, "gpio_bkl_en")) {
317 pr_err("failed to request gpio_bkl_en\n");
318 goto fail_gpio2;
319 }
320 pmapp_disp_backlight_init();
321
322 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_lcdc),
323 regs_lcdc);
324 if (rc) {
325 pr_err("%s: could not get regulators: %d\n",
326 __func__, rc);
327 goto fail_gpio1;
328 }
329
330 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_lcdc),
331 regs_lcdc);
332 if (rc) {
333 pr_err("%s: could not set voltages: %d\n",
334 __func__, rc);
335 goto fail_vreg;
336 }
337 lcdc_gpio_initialized = 1;
338 }
339 return;
340fail_vreg:
341 regulator_bulk_free(ARRAY_SIZE(regs_lcdc), regs_lcdc);
342fail_gpio1:
343 gpio_free(GPIO_BACKLIGHT_EN);
344fail_gpio2:
345 gpio_free(GPIO_DISPLAY_PWR_EN);
346fail_gpio3:
347 gpio_free(GPIO_SPI_MISO);
348fail_gpio4:
349 gpio_free(GPIO_SPI_MOSI);
350fail_gpio5:
351 gpio_free(GPIO_SPI_CS0_N);
352fail_gpio6:
353 gpio_free(GPIO_SPI_CLK);
354 lcdc_gpio_initialized = 0;
355}
356
357static uint32_t lcdc_gpio_table[] = {
358 GPIO_SPI_CLK,
359 GPIO_SPI_CS0_N,
360 GPIO_SPI_MOSI,
361 GPIO_DISPLAY_PWR_EN,
362 GPIO_BACKLIGHT_EN,
363 GPIO_SPI_MISO,
364};
365
366static void config_lcdc_gpio_table(uint32_t *table, int len, unsigned enable)
367{
368 int n;
369
370 if (lcdc_gpio_initialized) {
371 /* All are IO Expander GPIOs */
372 for (n = 0; n < (len - 1); n++)
373 gpio_direction_output(table[n], 1);
374 }
375}
376
377static void lcdc_toshiba_config_gpios(int enable)
378{
379 config_lcdc_gpio_table(lcdc_gpio_table,
380 ARRAY_SIZE(lcdc_gpio_table), enable);
381}
382
383static int msm_fb_lcdc_power_save(int on)
384{
385 int rc = 0;
386 /* Doing the init of the LCDC GPIOs very late as they are from
387 an I2C-controlled IO Expander */
388 lcdc_toshiba_gpio_init();
389
390 if (lcdc_gpio_initialized) {
391 gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, on);
392 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, on);
393
394 rc = on ? regulator_bulk_enable(
395 ARRAY_SIZE(regs_lcdc), regs_lcdc) :
396 regulator_bulk_disable(
397 ARRAY_SIZE(regs_lcdc), regs_lcdc);
398
399 if (rc)
400 pr_err("%s: could not %sable regulators: %d\n",
401 __func__, on ? "en" : "dis", rc);
402 }
403
404 return rc;
405}
406
407static int lcdc_toshiba_set_bl(int level)
408{
409 int ret;
410
411 ret = pmapp_disp_backlight_set_brightness(level);
412 if (ret)
413 pr_err("%s: can't set lcd backlight!\n", __func__);
414
415 return ret;
416}
417
Jeevan Shriram901a15f2012-03-09 11:53:23 +0530418
419static int msm_lcdc_power_save(int on)
420{
421 int rc = 0;
Jeevan Shriram045cdc72012-03-27 07:04:15 +0530422 if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7())
Jeevan Shriram901a15f2012-03-09 11:53:23 +0530423 rc = sku3_lcdc_power_save(on);
424 else
425 rc = msm_fb_lcdc_power_save(on);
426
427 return rc;
428}
429
Chintan Pandya250c2e52012-01-19 17:15:49 +0530430static struct lcdc_platform_data lcdc_pdata = {
431 .lcdc_gpio_config = NULL,
Jeevan Shriram901a15f2012-03-09 11:53:23 +0530432 .lcdc_power_save = msm_lcdc_power_save,
Chintan Pandya250c2e52012-01-19 17:15:49 +0530433};
434
435static int lcd_panel_spi_gpio_num[] = {
436 GPIO_SPI_MOSI, /* spi_sdi */
437 GPIO_SPI_MISO, /* spi_sdoi */
438 GPIO_SPI_CLK, /* spi_clk */
439 GPIO_SPI_CS0_N, /* spi_cs */
440};
441
442static struct msm_panel_common_pdata lcdc_toshiba_panel_data = {
443 .panel_config_gpio = lcdc_toshiba_config_gpios,
444 .pmic_backlight = lcdc_toshiba_set_bl,
445 .gpio_num = lcd_panel_spi_gpio_num,
446};
447
448static struct platform_device lcdc_toshiba_panel_device = {
449 .name = "lcdc_toshiba_fwvga_pt",
450 .id = 0,
451 .dev = {
452 .platform_data = &lcdc_toshiba_panel_data,
453 }
454};
455
456static struct resource msm_fb_resources[] = {
457 {
458 .flags = IORESOURCE_DMA,
459 }
460};
461
Chintan Pandya250c2e52012-01-19 17:15:49 +0530462#define LCDC_TOSHIBA_FWVGA_PANEL_NAME "lcdc_toshiba_fwvga_pt"
463#define MIPI_CMD_RENESAS_FWVGA_PANEL_NAME "mipi_cmd_renesas_fwvga"
464
465static int msm_fb_detect_panel(const char *name)
466{
467 int ret = -ENODEV;
468
Taniya Dase3027e22012-02-27 16:32:27 +0530469 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf() ||
470 machine_is_msm8625_surf()) {
Chintan Pandya250c2e52012-01-19 17:15:49 +0530471 if (!strncmp(name, "lcdc_toshiba_fwvga_pt", 21) ||
472 !strncmp(name, "mipi_cmd_renesas_fwvga", 22))
473 ret = 0;
474 } else if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa()) {
475 if (!strncmp(name, "mipi_cmd_renesas_fwvga", 22))
476 ret = 0;
477 } else if (machine_is_msm7627a_qrd1()) {
478 if (!strncmp(name, "mipi_video_truly_wvga", 21))
479 ret = 0;
Jeevan Shriram045cdc72012-03-27 07:04:15 +0530480 } else if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7()) {
Jeevan Shriram901a15f2012-03-09 11:53:23 +0530481 if (!strncmp(name, "lcdc_truly_hvga_ips3p2335_pt", 28))
482 ret = 0;
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530483 } else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) {
Jeevan Shrirame941df42012-01-23 12:40:21 +0530484 if (!strncmp(name, "mipi_cmd_nt35510_wvga", 21))
485 ret = 0;
Chintan Pandya250c2e52012-01-19 17:15:49 +0530486 }
487
488#if !defined(CONFIG_FB_MSM_LCDC_AUTO_DETECT) && \
489 !defined(CONFIG_FB_MSM_MIPI_PANEL_AUTO_DETECT) && \
490 !defined(CONFIG_FB_MSM_LCDC_MIPI_PANEL_AUTO_DETECT)
491 if (machine_is_msm7x27a_surf() ||
Taniya Dase3027e22012-02-27 16:32:27 +0530492 machine_is_msm7625a_surf() ||
493 machine_is_msm8625_surf()) {
Chintan Pandya250c2e52012-01-19 17:15:49 +0530494 if (!strncmp(name, LCDC_TOSHIBA_FWVGA_PANEL_NAME,
495 strnlen(LCDC_TOSHIBA_FWVGA_PANEL_NAME,
496 PANEL_NAME_MAX_LEN)))
497 return 0;
498 }
499#endif
500
501 return ret;
502}
503
504static int mipi_truly_set_bl(int on)
505{
506 gpio_set_value_cansleep(QRD_GPIO_BACKLIGHT_EN, !!on);
507
508 return 1;
509}
510
511static struct msm_fb_platform_data msm_fb_pdata = {
512 .detect_client = msm_fb_detect_panel,
513};
514
515static struct platform_device msm_fb_device = {
516 .name = "msm_fb",
517 .id = 0,
518 .num_resources = ARRAY_SIZE(msm_fb_resources),
519 .resource = msm_fb_resources,
520 .dev = {
521 .platform_data = &msm_fb_pdata,
522 }
523};
524
525#ifdef CONFIG_FB_MSM_MIPI_DSI
526static int mipi_renesas_set_bl(int level)
527{
528 int ret;
529
530 ret = pmapp_disp_backlight_set_brightness(level);
531
532 if (ret)
533 pr_err("%s: can't set lcd backlight!\n", __func__);
534
535 return ret;
536}
537
538static struct msm_panel_common_pdata mipi_renesas_pdata = {
539 .pmic_backlight = mipi_renesas_set_bl,
540};
541
542
543static struct platform_device mipi_dsi_renesas_panel_device = {
544 .name = "mipi_renesas",
545 .id = 0,
546 .dev = {
547 .platform_data = &mipi_renesas_pdata,
548 }
549};
550#endif
551
Padmanabhan Komanduru224d5fa2012-03-06 18:23:50 +0530552static int evb_backlight_control(int level)
553{
554
555 int i = 0;
556 int remainder;
557 /* device address byte = 0x72 */
558 gpio_set_value_cansleep(96, 0);
559 udelay(67);
560 gpio_set_value_cansleep(96, 1);
561 udelay(33);
562 gpio_set_value_cansleep(96, 0);
563 udelay(33);
564 gpio_set_value_cansleep(96, 1);
565 udelay(67);
566 gpio_set_value_cansleep(96, 0);
567 udelay(33);
568 gpio_set_value_cansleep(96, 1);
569 udelay(67);
570 gpio_set_value_cansleep(96, 0);
571 udelay(33);
572 gpio_set_value_cansleep(96, 1);
573 udelay(67);
574 gpio_set_value_cansleep(96, 0);
575 udelay(67);
576 gpio_set_value_cansleep(96, 1);
577 udelay(33);
578 gpio_set_value_cansleep(96, 0);
579 udelay(67);
580 gpio_set_value_cansleep(96, 1);
581 udelay(33);
582 gpio_set_value_cansleep(96, 0);
583 udelay(33);
584 gpio_set_value_cansleep(96, 1);
585 udelay(67);
586 gpio_set_value_cansleep(96, 0);
587 udelay(67);
588 gpio_set_value_cansleep(96, 1);
589 udelay(33);
590
591 /* t-EOS and t-start */
592 gpio_set_value_cansleep(96, 0);
593 ndelay(4200);
594 gpio_set_value_cansleep(96, 1);
595 ndelay(9000);
596
597 /* data byte */
598 /* RFA = 0 */
599 gpio_set_value_cansleep(96, 0);
600 udelay(67);
601 gpio_set_value_cansleep(96, 1);
602 udelay(33);
603
604 /* Address bits */
605 gpio_set_value_cansleep(96, 0);
606 udelay(67);
607 gpio_set_value_cansleep(96, 1);
608 udelay(33);
609 gpio_set_value_cansleep(96, 0);
610 udelay(67);
611 gpio_set_value_cansleep(96, 1);
612 udelay(33);
613
614 /* Data bits */
615 for (i = 0; i < 5; i++) {
616 remainder = (level) & (16);
617 if (remainder) {
618 gpio_set_value_cansleep(96, 0);
619 udelay(33);
620 gpio_set_value_cansleep(96, 1);
621 udelay(67);
622 } else {
623 gpio_set_value_cansleep(96, 0);
624 udelay(67);
625 gpio_set_value_cansleep(96, 1);
626 udelay(33);
627 }
628 level = level << 1;
629 }
630
631 /* t-EOS */
632 gpio_set_value_cansleep(96, 0);
633 ndelay(12000);
634 gpio_set_value_cansleep(96, 1);
635 return 0;
636}
637
638
Chintan Pandya250c2e52012-01-19 17:15:49 +0530639static struct msm_panel_common_pdata mipi_truly_pdata = {
640 .pmic_backlight = mipi_truly_set_bl,
641};
642
643static struct platform_device mipi_dsi_truly_panel_device = {
644 .name = "mipi_truly",
645 .id = 0,
646 .dev = {
647 .platform_data = &mipi_truly_pdata,
648 }
649};
650
Jeevan Shrirame941df42012-01-23 12:40:21 +0530651static struct msm_panel_common_pdata mipi_NT35510_pdata = {
Padmanabhan Komanduru224d5fa2012-03-06 18:23:50 +0530652 .pmic_backlight = evb_backlight_control,
Jeevan Shrirame941df42012-01-23 12:40:21 +0530653};
654
655static struct platform_device mipi_dsi_NT35510_panel_device = {
656 .name = "mipi_NT35510",
657 .id = 0,
658 .dev = {
659 .platform_data = &mipi_NT35510_pdata,
660 }
661};
662
Chintan Pandya250c2e52012-01-19 17:15:49 +0530663static struct platform_device *msm_fb_devices[] __initdata = {
664 &msm_fb_device,
665 &lcdc_toshiba_panel_device,
666#ifdef CONFIG_FB_MSM_MIPI_DSI
667 &mipi_dsi_renesas_panel_device,
668#endif
669};
670
671static struct platform_device *qrd_fb_devices[] __initdata = {
672 &msm_fb_device,
673 &mipi_dsi_truly_panel_device,
674};
675
Jeevan Shriram901a15f2012-03-09 11:53:23 +0530676static struct platform_device *qrd3_fb_devices[] __initdata = {
677 &msm_fb_device,
678 &lcdc_truly_panel_device,
679};
680
Taniya Dasc868a2e2012-01-03 10:18:47 +0530681static struct platform_device *evb_fb_devices[] __initdata = {
Jeevan Shrirame941df42012-01-23 12:40:21 +0530682 &msm_fb_device,
683 &mipi_dsi_NT35510_panel_device,
Taniya Dasc868a2e2012-01-03 10:18:47 +0530684};
685
Chintan Pandya250c2e52012-01-19 17:15:49 +0530686void __init msm_msm7627a_allocate_memory_regions(void)
687{
688 void *addr;
689 unsigned long fb_size;
690
691 if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa())
692 fb_size = MSM7x25A_MSM_FB_SIZE;
693 else
694 fb_size = MSM_FB_SIZE;
695 addr = alloc_bootmem_align(fb_size, 0x1000);
696 msm_fb_resources[0].start = __pa(addr);
697 msm_fb_resources[0].end = msm_fb_resources[0].start + fb_size - 1;
698 pr_info("allocating %lu bytes at %p (%lx physical) for fb\n", fb_size,
699 addr, __pa(addr));
700}
701
702static struct msm_panel_common_pdata mdp_pdata = {
703 .gpio = 97,
704 .mdp_rev = MDP_REV_303,
705};
706
707#define GPIO_LCDC_BRDG_PD 128
708#define GPIO_LCDC_BRDG_RESET_N 129
709#define GPIO_LCD_DSI_SEL 125
710#define LCDC_RESET_PHYS 0x90008014
711
712static void __iomem *lcdc_reset_ptr;
713
714static unsigned mipi_dsi_gpio[] = {
715 GPIO_CFG(GPIO_LCDC_BRDG_RESET_N, 0, GPIO_CFG_OUTPUT,
716 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* LCDC_BRDG_RESET_N */
717 GPIO_CFG(GPIO_LCDC_BRDG_PD, 0, GPIO_CFG_OUTPUT,
718 GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* LCDC_BRDG_PD */
719};
720
721static unsigned lcd_dsi_sel_gpio[] = {
722 GPIO_CFG(GPIO_LCD_DSI_SEL, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP,
723 GPIO_CFG_2MA),
724};
725
726enum {
727 DSI_SINGLE_LANE = 1,
728 DSI_TWO_LANES,
729};
730
731static int msm_fb_get_lane_config(void)
732{
733 /* For MSM7627A SURF/FFA and QRD */
734 int rc = DSI_TWO_LANES;
735 if (machine_is_msm7625a_surf() || machine_is_msm7625a_ffa()) {
736 rc = DSI_SINGLE_LANE;
737 pr_info("DSI_SINGLE_LANES\n");
738 } else {
739 pr_info("DSI_TWO_LANES\n");
740 }
741 return rc;
742}
743
744static int msm_fb_dsi_client_msm_reset(void)
745{
746 int rc = 0;
747
748 rc = gpio_request(GPIO_LCDC_BRDG_RESET_N, "lcdc_brdg_reset_n");
749 if (rc < 0) {
750 pr_err("failed to request lcd brdg reset_n\n");
751 return rc;
752 }
753
754 rc = gpio_request(GPIO_LCDC_BRDG_PD, "lcdc_brdg_pd");
755 if (rc < 0) {
756 pr_err("failed to request lcd brdg pd\n");
757 return rc;
758 }
759
760 rc = gpio_tlmm_config(mipi_dsi_gpio[0], GPIO_CFG_ENABLE);
761 if (rc) {
762 pr_err("Failed to enable LCDC Bridge reset enable\n");
763 goto gpio_error;
764 }
765
766 rc = gpio_tlmm_config(mipi_dsi_gpio[1], GPIO_CFG_ENABLE);
767 if (rc) {
768 pr_err("Failed to enable LCDC Bridge pd enable\n");
769 goto gpio_error2;
770 }
771
772 rc = gpio_direction_output(GPIO_LCDC_BRDG_RESET_N, 1);
773 rc |= gpio_direction_output(GPIO_LCDC_BRDG_PD, 1);
774 gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 0);
775
776 if (!rc) {
Taniya Dase3027e22012-02-27 16:32:27 +0530777 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf()
778 || machine_is_msm8625_surf()) {
Chintan Pandya250c2e52012-01-19 17:15:49 +0530779 lcdc_reset_ptr = ioremap_nocache(LCDC_RESET_PHYS,
780 sizeof(uint32_t));
781
782 if (!lcdc_reset_ptr)
783 return 0;
784 }
785 return rc;
786 } else {
787 goto gpio_error;
788 }
789
790gpio_error2:
791 pr_err("Failed GPIO bridge pd\n");
792 gpio_free(GPIO_LCDC_BRDG_PD);
793
794gpio_error:
795 pr_err("Failed GPIO bridge reset\n");
796 gpio_free(GPIO_LCDC_BRDG_RESET_N);
797 return rc;
798}
799
800static int mipi_truly_sel_mode(int video_mode)
801{
802 int rc = 0;
803
804 rc = gpio_request(GPIO_LCD_DSI_SEL, "lcd_dsi_sel");
805 if (rc < 0)
806 goto gpio_error;
807
808 rc = gpio_tlmm_config(lcd_dsi_sel_gpio[0], GPIO_CFG_ENABLE);
809 if (rc)
810 goto gpio_error;
811
812 rc = gpio_direction_output(GPIO_LCD_DSI_SEL, 1);
813 if (!rc) {
814 gpio_set_value_cansleep(GPIO_LCD_DSI_SEL, video_mode);
815 return rc;
816 } else {
817 goto gpio_error;
818 }
819
820gpio_error:
821 pr_err("mipi_truly_sel_mode failed\n");
822 gpio_free(GPIO_LCD_DSI_SEL);
823 return rc;
824}
825
826static int msm_fb_dsi_client_qrd1_reset(void)
827{
828 int rc = 0;
829
830 rc = gpio_request(GPIO_LCDC_BRDG_RESET_N, "lcdc_brdg_reset_n");
831 if (rc < 0) {
832 pr_err("failed to request lcd brdg reset_n\n");
833 return rc;
834 }
835
836 rc = gpio_tlmm_config(mipi_dsi_gpio[0], GPIO_CFG_ENABLE);
837 if (rc < 0) {
838 pr_err("Failed to enable LCDC Bridge reset enable\n");
839 return rc;
840 }
841
842 rc = gpio_direction_output(GPIO_LCDC_BRDG_RESET_N, 1);
843 if (rc < 0) {
844 pr_err("Failed GPIO bridge pd\n");
845 gpio_free(GPIO_LCDC_BRDG_RESET_N);
846 return rc;
847 }
848
849 mipi_truly_sel_mode(1);
850
851 return rc;
852}
853
Jeevan Shrirame941df42012-01-23 12:40:21 +0530854#define GPIO_QRD3_LCD_BRDG_RESET_N 85
855#define GPIO_QRD3_LCD_BACKLIGHT_EN 96
856#define GPIO_QRD3_LCD_EXT_2V85_EN 35
857#define GPIO_QRD3_LCD_EXT_1V8_EN 40
858
859static unsigned qrd3_mipi_dsi_gpio[] = {
860 GPIO_CFG(GPIO_QRD3_LCD_BRDG_RESET_N, 0, GPIO_CFG_OUTPUT,
861 GPIO_CFG_NO_PULL,
862 GPIO_CFG_2MA), /* GPIO_QRD3_LCD_BRDG_RESET_N */
863 GPIO_CFG(GPIO_QRD3_LCD_BACKLIGHT_EN, 0, GPIO_CFG_OUTPUT,
864 GPIO_CFG_NO_PULL,
865 GPIO_CFG_2MA), /* GPIO_QRD3_LCD_BACKLIGHT_EN */
866 GPIO_CFG(GPIO_QRD3_LCD_EXT_2V85_EN, 0, GPIO_CFG_OUTPUT,
867 GPIO_CFG_NO_PULL,
868 GPIO_CFG_2MA), /* GPIO_QRD3_LCD_EXT_2V85_EN */
869 GPIO_CFG(GPIO_QRD3_LCD_EXT_1V8_EN, 0, GPIO_CFG_OUTPUT,
870 GPIO_CFG_NO_PULL,
871 GPIO_CFG_2MA), /* GPIO_QRD3_LCD_EXT_1V8_EN */
872};
873
874static int msm_fb_dsi_client_qrd3_reset(void)
875{
876 int rc = 0;
877
878 rc = gpio_request(GPIO_QRD3_LCD_BRDG_RESET_N, "qrd3_lcd_brdg_reset_n");
879 if (rc < 0) {
880 pr_err("failed to request qrd3 lcd brdg reset_n\n");
881 return rc;
882 }
883
Jeevan Shrirame941df42012-01-23 12:40:21 +0530884 return rc;
885}
886
Chintan Pandya250c2e52012-01-19 17:15:49 +0530887static int msm_fb_dsi_client_reset(void)
888{
889 int rc = 0;
890
891 if (machine_is_msm7627a_qrd1())
892 rc = msm_fb_dsi_client_qrd1_reset();
Chintan Pandyaf4ad4002012-02-28 19:49:03 +0530893 else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb())
Jeevan Shrirame941df42012-01-23 12:40:21 +0530894 rc = msm_fb_dsi_client_qrd3_reset();
Chintan Pandya250c2e52012-01-19 17:15:49 +0530895 else
896 rc = msm_fb_dsi_client_msm_reset();
897
898 return rc;
899
900}
901
902static struct regulator_bulk_data regs_dsi[] = {
903 { .supply = "gp2", .min_uV = 2850000, .max_uV = 2850000 },
904 { .supply = "msme1", .min_uV = 1800000, .max_uV = 1800000 },
905};
906
907static int dsi_gpio_initialized;
908
909static int mipi_dsi_panel_msm_power(int on)
910{
911 int rc = 0;
912 uint32_t lcdc_reset_cfg;
913
914 /* I2C-controlled GPIO Expander -init of the GPIOs very late */
915 if (unlikely(!dsi_gpio_initialized)) {
916 pmapp_disp_backlight_init();
917
918 rc = gpio_request(GPIO_DISPLAY_PWR_EN, "gpio_disp_pwr");
919 if (rc < 0) {
920 pr_err("failed to request gpio_disp_pwr\n");
921 return rc;
922 }
923
Taniya Dase3027e22012-02-27 16:32:27 +0530924 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf()
925 || machine_is_msm8625_surf()) {
Chintan Pandya250c2e52012-01-19 17:15:49 +0530926 rc = gpio_direction_output(GPIO_DISPLAY_PWR_EN, 1);
927 if (rc < 0) {
928 pr_err("failed to enable display pwr\n");
929 goto fail_gpio1;
930 }
931
932 rc = gpio_request(GPIO_BACKLIGHT_EN, "gpio_bkl_en");
933 if (rc < 0) {
934 pr_err("failed to request gpio_bkl_en\n");
935 goto fail_gpio1;
936 }
937
938 rc = gpio_direction_output(GPIO_BACKLIGHT_EN, 1);
939 if (rc < 0) {
940 pr_err("failed to enable backlight\n");
941 goto fail_gpio2;
942 }
943 }
944
945 rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_dsi), regs_dsi);
946 if (rc) {
947 pr_err("%s: could not get regulators: %d\n",
948 __func__, rc);
949 goto fail_gpio2;
950 }
951
952 rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_dsi),
953 regs_dsi);
954 if (rc) {
955 pr_err("%s: could not set voltages: %d\n",
956 __func__, rc);
957 goto fail_vreg;
958 }
959 if (pmapp_disp_backlight_set_brightness(100))
960 pr_err("backlight set brightness failed\n");
961
962 dsi_gpio_initialized = 1;
963 }
Taniya Dase3027e22012-02-27 16:32:27 +0530964 if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf() ||
965 machine_is_msm8625_surf()) {
Chintan Pandya250c2e52012-01-19 17:15:49 +0530966 gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, on);
967 gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, on);
968 } else if (machine_is_msm7x27a_ffa() ||
969 machine_is_msm7625a_ffa()) {
970 if (on) {
971 /* This line drives an active low pin on FFA */
972 rc = gpio_direction_output(GPIO_DISPLAY_PWR_EN, !on);
973 if (rc < 0)
974 pr_err("failed to set direction for "
975 "display pwr\n");
976 } else {
977 gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, !on);
978 rc = gpio_direction_input(GPIO_DISPLAY_PWR_EN);
979 if (rc < 0)
980 pr_err("failed to set direction for "
981 "display pwr\n");
982 }
983 }
984
985 if (on) {
986 gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 0);
987
988 if (machine_is_msm7x27a_surf() ||
Taniya Dase3027e22012-02-27 16:32:27 +0530989 machine_is_msm7625a_surf() ||
990 machine_is_msm8625_surf()) {
Chintan Pandya250c2e52012-01-19 17:15:49 +0530991 lcdc_reset_cfg = readl_relaxed(lcdc_reset_ptr);
992 rmb();
993 lcdc_reset_cfg &= ~1;
994
995 writel_relaxed(lcdc_reset_cfg, lcdc_reset_ptr);
996 msleep(20);
997 wmb();
998 lcdc_reset_cfg |= 1;
999 writel_relaxed(lcdc_reset_cfg, lcdc_reset_ptr);
1000 } else {
1001 gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 0);
1002 msleep(20);
1003 gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1);
1004 }
1005 } else {
1006 gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 1);
Chintan Pandya250c2e52012-01-19 17:15:49 +05301007 }
1008
1009 rc = on ? regulator_bulk_enable(ARRAY_SIZE(regs_dsi), regs_dsi) :
1010 regulator_bulk_disable(ARRAY_SIZE(regs_dsi), regs_dsi);
1011
1012 if (rc)
1013 pr_err("%s: could not %sable regulators: %d\n",
1014 __func__, on ? "en" : "dis", rc);
1015
1016 return rc;
1017fail_vreg:
1018 regulator_bulk_free(ARRAY_SIZE(regs_dsi), regs_dsi);
1019fail_gpio2:
1020 gpio_free(GPIO_BACKLIGHT_EN);
1021fail_gpio1:
1022 gpio_free(GPIO_DISPLAY_PWR_EN);
1023 dsi_gpio_initialized = 0;
1024 return rc;
1025}
1026
1027static int mipi_dsi_panel_qrd1_power(int on)
1028{
1029 int rc = 0;
1030
1031 if (!dsi_gpio_initialized) {
1032 rc = gpio_request(QRD_GPIO_BACKLIGHT_EN, "gpio_bkl_en");
1033 if (rc < 0)
1034 return rc;
1035
1036 rc = gpio_tlmm_config(GPIO_CFG(QRD_GPIO_BACKLIGHT_EN, 0,
1037 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1038 GPIO_CFG_ENABLE);
1039 if (rc < 0) {
1040 pr_err("failed GPIO_BACKLIGHT_EN tlmm config\n");
1041 return rc;
1042 }
1043
1044 rc = gpio_direction_output(QRD_GPIO_BACKLIGHT_EN, 1);
1045 if (rc < 0) {
1046 pr_err("failed to enable backlight\n");
1047 gpio_free(QRD_GPIO_BACKLIGHT_EN);
1048 return rc;
1049 }
1050 dsi_gpio_initialized = 1;
1051 }
1052
1053 gpio_set_value_cansleep(QRD_GPIO_BACKLIGHT_EN, !!on);
1054
Jeevan Shrirame941df42012-01-23 12:40:21 +05301055 if (on) {
Chintan Pandya250c2e52012-01-19 17:15:49 +05301056 gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1);
1057 msleep(20);
1058 gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 0);
1059 msleep(20);
1060 gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1);
1061
1062 }
1063
1064 return rc;
1065}
1066
Jeevan Shrirame941df42012-01-23 12:40:21 +05301067static int qrd3_dsi_gpio_initialized;
1068
1069static int mipi_dsi_panel_qrd3_power(int on)
1070{
1071 int rc = 0;
1072
1073 if (!qrd3_dsi_gpio_initialized) {
1074 rc = gpio_request(GPIO_QRD3_LCD_BACKLIGHT_EN,
1075 "qrd3_gpio_bkl_en");
1076 if (rc < 0)
1077 return rc;
1078
1079 rc = gpio_tlmm_config(GPIO_CFG(GPIO_QRD3_LCD_BACKLIGHT_EN, 0,
Padmanabhan Komanduru224d5fa2012-03-06 18:23:50 +05301080 GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA),
Jeevan Shrirame941df42012-01-23 12:40:21 +05301081 GPIO_CFG_ENABLE);
1082 if (rc < 0) {
1083 pr_err("failed QRD3 GPIO_BACKLIGHT_EN tlmm config\n");
1084 return rc;
1085 }
1086 rc = gpio_direction_output(GPIO_QRD3_LCD_BACKLIGHT_EN, 1);
1087 if (rc < 0) {
1088 pr_err("failed to enable backlight\n");
1089 gpio_free(GPIO_QRD3_LCD_BACKLIGHT_EN);
1090 return rc;
1091 }
1092
1093 rc = gpio_request(GPIO_QRD3_LCD_EXT_2V85_EN,
1094 "qrd3_gpio_ext_2v85_en");
1095 if (rc < 0)
1096 return rc;
1097
1098 rc = gpio_tlmm_config(GPIO_CFG(GPIO_QRD3_LCD_EXT_2V85_EN, 0,
1099 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1100 GPIO_CFG_ENABLE);
1101 if (rc < 0) {
1102 pr_err("failed QRD3 GPIO_QRD3_LCD_EXT_2V85_EN tlmm config\n");
1103 return rc;
1104 }
1105
1106 rc = gpio_direction_output(GPIO_QRD3_LCD_EXT_2V85_EN, 1);
1107 if (rc < 0) {
1108 pr_err("failed to enable external 2V85\n");
1109 gpio_free(GPIO_QRD3_LCD_EXT_2V85_EN);
1110 return rc;
1111 }
1112
1113 rc = gpio_request(GPIO_QRD3_LCD_EXT_1V8_EN,
1114 "qrd3_gpio_ext_1v8_en");
1115 if (rc < 0)
1116 return rc;
1117
1118 rc = gpio_tlmm_config(GPIO_CFG(GPIO_QRD3_LCD_EXT_1V8_EN, 0,
1119 GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1120 GPIO_CFG_ENABLE);
1121 if (rc < 0) {
1122 pr_err("failed QRD3 GPIO_QRD3_LCD_EXT_1V8_EN tlmm config\n");
1123 return rc;
1124 }
1125
1126 rc = gpio_direction_output(GPIO_QRD3_LCD_EXT_1V8_EN, 1);
1127 if (rc < 0) {
1128 pr_err("failed to enable external 1v8\n");
1129 gpio_free(GPIO_QRD3_LCD_EXT_1V8_EN);
1130 return rc;
1131 }
1132
1133 qrd3_dsi_gpio_initialized = 1;
1134 }
1135
Padmanabhan Komanduru224d5fa2012-03-06 18:23:50 +05301136 if (on) {
1137 gpio_set_value_cansleep(GPIO_QRD3_LCD_BACKLIGHT_EN, 1);
1138 udelay(190);
1139 gpio_set_value_cansleep(GPIO_QRD3_LCD_BACKLIGHT_EN, 0);
1140 udelay(286);
1141 gpio_set_value_cansleep(GPIO_QRD3_LCD_BACKLIGHT_EN, 1);
1142 /* 1 wire mode starts from this low to high transition */
1143 udelay(50);
1144 } else
1145 gpio_set_value_cansleep(GPIO_QRD3_LCD_BACKLIGHT_EN, !!on);
1146
Jeevan Shrirame941df42012-01-23 12:40:21 +05301147 gpio_set_value_cansleep(GPIO_QRD3_LCD_EXT_2V85_EN, !!on);
1148 gpio_set_value_cansleep(GPIO_QRD3_LCD_EXT_1V8_EN, !!on);
1149
1150 if (on) {
Padmanabhan Komanduru599d3552012-02-21 16:53:05 +05301151 rc = gpio_tlmm_config(qrd3_mipi_dsi_gpio[0], GPIO_CFG_ENABLE);
1152
1153 if (rc < 0) {
1154 pr_err("Failed to enable LCD Bridge reset enable\n");
1155 return rc;
1156 }
1157
1158 rc = gpio_direction_output(GPIO_QRD3_LCD_BRDG_RESET_N, 1);
1159
1160 if (rc < 0) {
1161 pr_err("Failed GPIO bridge Reset\n");
1162 gpio_free(GPIO_QRD3_LCD_BRDG_RESET_N);
1163 return rc;
1164 }
1165
Jeevan Shrirame941df42012-01-23 12:40:21 +05301166 msleep(20);
1167 gpio_set_value_cansleep(GPIO_QRD3_LCD_BRDG_RESET_N, 0);
1168 msleep(20);
1169 gpio_set_value_cansleep(GPIO_QRD3_LCD_BRDG_RESET_N, 1);
1170 msleep(20);
Padmanabhan Komanduru599d3552012-02-21 16:53:05 +05301171 } else {
1172 gpio_tlmm_config(GPIO_CFG(GPIO_QRD3_LCD_BRDG_RESET_N, 0,
1173 GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
1174 GPIO_CFG_DISABLE);
Jeevan Shrirame941df42012-01-23 12:40:21 +05301175 }
1176
1177 return rc;
1178}
1179
Chintan Pandya250c2e52012-01-19 17:15:49 +05301180static int mipi_dsi_panel_power(int on)
1181{
1182 int rc = 0;
1183
1184 if (machine_is_msm7627a_qrd1())
1185 rc = mipi_dsi_panel_qrd1_power(on);
Chintan Pandyaf4ad4002012-02-28 19:49:03 +05301186 else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb())
Jeevan Shrirame941df42012-01-23 12:40:21 +05301187 rc = mipi_dsi_panel_qrd3_power(on);
Chintan Pandya250c2e52012-01-19 17:15:49 +05301188 else
1189 rc = mipi_dsi_panel_msm_power(on);
1190 return rc;
1191}
1192
1193#define MDP_303_VSYNC_GPIO 97
1194
Jeevan Shriram901a15f2012-03-09 11:53:23 +05301195#ifdef CONFIG_FB_MSM_MIPI_DSI
Chintan Pandya250c2e52012-01-19 17:15:49 +05301196static struct mipi_dsi_platform_data mipi_dsi_pdata = {
1197 .vsync_gpio = MDP_303_VSYNC_GPIO,
1198 .dsi_power_save = mipi_dsi_panel_power,
1199 .dsi_client_reset = msm_fb_dsi_client_reset,
1200 .get_lane_config = msm_fb_get_lane_config,
1201};
1202#endif
1203
1204void __init msm_fb_add_devices(void)
1205{
1206 if (machine_is_msm7627a_qrd1())
1207 platform_add_devices(qrd_fb_devices,
1208 ARRAY_SIZE(qrd_fb_devices));
Padmanabhan Komanduru224d5fa2012-03-06 18:23:50 +05301209 else if (machine_is_msm7627a_evb() || machine_is_msm8625_evb()) {
1210 mipi_NT35510_pdata.bl_lock = 1;
Taniya Dasc868a2e2012-01-03 10:18:47 +05301211 platform_add_devices(evb_fb_devices,
1212 ARRAY_SIZE(evb_fb_devices));
Padmanabhan Komanduru224d5fa2012-03-06 18:23:50 +05301213 } else if (machine_is_msm7627a_qrd3() || machine_is_msm8625_qrd7()) {
Jeevan Shriram901a15f2012-03-09 11:53:23 +05301214 sku3_lcdc_lcd_camera_power_init();
1215 platform_add_devices(qrd3_fb_devices,
1216 ARRAY_SIZE(qrd3_fb_devices));
1217 } else
Chintan Pandya250c2e52012-01-19 17:15:49 +05301218 platform_add_devices(msm_fb_devices,
1219 ARRAY_SIZE(msm_fb_devices));
1220
1221 msm_fb_register_device("mdp", &mdp_pdata);
Taniya Dase3027e22012-02-27 16:32:27 +05301222 if (machine_is_msm7625a_surf() || machine_is_msm7x27a_surf() ||
Jeevan Shriram045cdc72012-03-27 07:04:15 +05301223 machine_is_msm8625_surf() || machine_is_msm7627a_qrd3()
1224 || machine_is_msm8625_qrd7())
Chintan Pandya250c2e52012-01-19 17:15:49 +05301225 msm_fb_register_device("lcdc", &lcdc_pdata);
Jeevan Shriram901a15f2012-03-09 11:53:23 +05301226#ifdef CONFIG_FB_MSM_MIPI_DSI
Chintan Pandya250c2e52012-01-19 17:15:49 +05301227 msm_fb_register_device("mipi_dsi", &mipi_dsi_pdata);
1228#endif
1229}