video: tegra: host: Register devices in SoC files
[linux-2.6.git] / arch / arm / mach-tegra / board-kai-panel.c
1 /*
2  * arch/arm/mach-tegra/board-kai-panel.c
3  *
4  * Copyright (c) 2012, NVIDIA Corporation.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18  */
19
20 #include <linux/delay.h>
21 #include <linux/gpio.h>
22 #include <linux/regulator/consumer.h>
23 #include <linux/resource.h>
24 #include <asm/mach-types.h>
25 #include <linux/platform_device.h>
26 #ifdef CONFIG_HAS_EARLYSUSPEND
27 #include <linux/earlysuspend.h>
28 #endif
29 #include <linux/pwm_backlight.h>
30 #include <asm/atomic.h>
31 #include <linux/nvhost.h>
32 #include <linux/nvmap.h>
33 #include <mach/irqs.h>
34 #include <mach/iomap.h>
35 #include <mach/dc.h>
36 #include <mach/fb.h>
37 #include <mach/gpio-tegra.h>
38
39 #include "board.h"
40 #include "board-kai.h"
41 #include "devices.h"
42 #include "gpio-names.h"
43 #include "tegra3_host1x_devices.h"
44
45 /* kai default display board pins */
46 #define kai_lvds_avdd_en                TEGRA_GPIO_PH6
47 #define kai_lvds_stdby                  TEGRA_GPIO_PG5
48 #define kai_lvds_rst                    TEGRA_GPIO_PG7
49 #define kai_lvds_shutdown               TEGRA_GPIO_PN6
50 #define kai_lvds_rs                     TEGRA_GPIO_PV6
51 #define kai_lvds_lr                     TEGRA_GPIO_PG1
52
53 /* kai A00 display board pins */
54 #define kai_lvds_rs_a00         TEGRA_GPIO_PH1
55
56 /* common pins( backlight ) for all display boards */
57 #define kai_bl_enb                      TEGRA_GPIO_PH3
58 #define kai_bl_pwm                      TEGRA_GPIO_PH0
59 #define kai_hdmi_hpd                    TEGRA_GPIO_PN7
60
61 #ifdef CONFIG_TEGRA_DC
62 static struct regulator *kai_hdmi_reg;
63 static struct regulator *kai_hdmi_pll;
64 static struct regulator *kai_hdmi_vddio;
65 #endif
66
67 static atomic_t sd_brightness = ATOMIC_INIT(255);
68
69 static struct regulator *kai_lvds_reg;
70 static struct regulator *kai_lvds_vdd_panel;
71
72 static tegra_dc_bl_output kai_bl_output_measured = {
73         0, 1, 2, 3, 4, 5, 6, 7,
74         7, 8, 9, 10, 11, 12, 13, 14,
75         15, 16, 17, 18, 19, 20, 20, 21,
76         22, 23, 24, 25, 26, 27, 28, 29,
77         30, 31, 32, 32, 34, 34, 36, 36,
78         38, 39, 40, 40, 41, 42, 42, 43,
79         44, 44, 45, 46, 46, 47, 48, 48,
80         49, 50, 50, 51, 52, 53, 54, 54,
81         55, 56, 57, 58, 58, 59, 60, 61,
82         62, 63, 64, 65, 66, 67, 68, 69,
83         70, 71, 72, 72, 73, 74, 75, 76,
84         76, 77, 78, 79, 80, 81, 82, 83,
85         85, 86, 87, 89, 90, 91, 92, 92,
86         93, 94, 95, 96, 96, 97, 98, 99,
87         100, 100, 101, 102, 103, 104, 104, 105,
88         106, 107, 108, 108, 109, 110, 112, 114,
89         116, 118, 120, 121, 122, 123, 124, 125,
90         126, 127, 128, 129, 130, 131, 132, 133,
91         134, 135, 136, 137, 138, 139, 140, 141,
92         142, 143, 144, 145, 146, 147, 148, 149,
93         150, 151, 151, 152, 153, 153, 154, 155,
94         155, 156, 157, 157, 158, 159, 159, 160,
95         162, 164, 166, 168, 170, 172, 174, 176,
96         178, 180, 181, 181, 182, 183, 183, 184,
97         185, 185, 186, 187, 187, 188, 189, 189,
98         190, 191, 192, 193, 194, 195, 196, 197,
99         198, 199, 200, 201, 201, 202, 203, 203,
100         204, 205, 205, 206, 207, 207, 208, 209,
101         209, 210, 211, 211, 212, 212, 213, 213,
102         214, 215, 215, 216, 216, 217, 217, 218,
103         219, 219, 220, 222, 226, 230, 232, 234,
104         236, 238, 240, 244, 248, 251, 253, 255
105 };
106
107 static p_tegra_dc_bl_output bl_output;
108
109 static int kai_backlight_init(struct device *dev)
110 {
111         int ret;
112
113         bl_output = kai_bl_output_measured;
114
115         if (WARN_ON(ARRAY_SIZE(kai_bl_output_measured) != 256))
116                 pr_err("bl_output array does not have 256 elements\n");
117
118         ret = gpio_request(kai_bl_enb, "backlight_enb");
119         if (ret < 0)
120                 return ret;
121
122         ret = gpio_direction_output(kai_bl_enb, 1);
123         if (ret < 0)
124                 gpio_free(kai_bl_enb);
125
126         return ret;
127 };
128
129 static void kai_backlight_exit(struct device *dev)
130 {
131         /* int ret; */
132         /*ret = gpio_request(kai_bl_enb, "backlight_enb");*/
133         gpio_set_value(kai_bl_enb, 0);
134         gpio_free(kai_bl_enb);
135         return;
136 }
137
138 static int kai_backlight_notify(struct device *unused, int brightness)
139 {
140         int cur_sd_brightness = atomic_read(&sd_brightness);
141
142         /* Set the backlight GPIO pin mode to 'backlight_enable' */
143         gpio_set_value(kai_bl_enb, !!brightness);
144
145         /* SD brightness is a percentage, 8-bit value. */
146         brightness = (brightness * cur_sd_brightness) / 255;
147
148         /* Apply any backlight response curve */
149         if (brightness > 255)
150                 pr_info("Error: Brightness > 255!\n");
151         else
152                 brightness = bl_output[brightness];
153
154         return brightness;
155 }
156
157 static int kai_disp1_check_fb(struct device *dev, struct fb_info *info);
158
159 static struct platform_pwm_backlight_data kai_backlight_data = {
160         .pwm_id         = 0,
161         .max_brightness = 255,
162         .dft_brightness = 224,
163         .pwm_period_ns  = 100000,
164         .init           = kai_backlight_init,
165         .exit           = kai_backlight_exit,
166         .notify         = kai_backlight_notify,
167         /* Only toggle backlight on fb blank notifications for disp1 */
168         .check_fb       = kai_disp1_check_fb,
169 };
170
171 static struct platform_device kai_backlight_device = {
172         .name   = "pwm-backlight",
173         .id     = -1,
174         .dev    = {
175                 .platform_data = &kai_backlight_data,
176         },
177 };
178
179 static int kai_panel_enable(void)
180 {
181         if (kai_lvds_reg == NULL) {
182                 kai_lvds_reg = regulator_get(NULL, "vdd_lvds");
183                 if (WARN_ON(IS_ERR(kai_lvds_reg)))
184                         pr_err("%s: couldn't get regulator vdd_lvds: %ld\n",
185                                __func__, PTR_ERR(kai_lvds_reg));
186                 else
187                         regulator_enable(kai_lvds_reg);
188         }
189
190         if (kai_lvds_vdd_panel == NULL) {
191                 kai_lvds_vdd_panel = regulator_get(NULL, "vdd_lcd_panel");
192                 if (WARN_ON(IS_ERR(kai_lvds_vdd_panel)))
193                         pr_err("%s: couldn't get regulator vdd_lcd_panel: %ld\n",
194                                __func__, PTR_ERR(kai_lvds_vdd_panel));
195                 else
196                         regulator_enable(kai_lvds_vdd_panel);
197         }
198
199         mdelay(5);
200
201         gpio_set_value(kai_lvds_avdd_en, 1);
202         mdelay(5);
203
204         gpio_set_value(kai_lvds_stdby, 1);
205         gpio_set_value(kai_lvds_rst, 1);
206         gpio_set_value(kai_lvds_shutdown, 1);
207         gpio_set_value(kai_lvds_lr, 1);
208
209         mdelay(10);
210
211         return 0;
212 }
213
214 static int kai_panel_disable(void)
215 {
216         gpio_set_value(kai_lvds_lr, 0);
217         gpio_set_value(kai_lvds_shutdown, 0);
218         gpio_set_value(kai_lvds_rst, 0);
219         gpio_set_value(kai_lvds_stdby, 0);
220         mdelay(5);
221
222         gpio_set_value(kai_lvds_avdd_en, 0);
223         mdelay(5);
224
225         regulator_disable(kai_lvds_reg);
226         regulator_put(kai_lvds_reg);
227         kai_lvds_reg = NULL;
228
229         regulator_disable(kai_lvds_vdd_panel);
230         regulator_put(kai_lvds_vdd_panel);
231         kai_lvds_vdd_panel = NULL;
232
233         return 0;
234 }
235
236 #ifdef CONFIG_TEGRA_DC
237 static int kai_hdmi_vddio_enable(void)
238 {
239         int ret;
240         if (!kai_hdmi_vddio) {
241                 kai_hdmi_vddio = regulator_get(NULL, "vdd_hdmi_con");
242                 if (IS_ERR_OR_NULL(kai_hdmi_vddio)) {
243                         ret = PTR_ERR(kai_hdmi_vddio);
244                         pr_err("hdmi: couldn't get regulator vdd_hdmi_con\n");
245                         kai_hdmi_vddio = NULL;
246                         return ret;
247                 }
248         }
249         ret = regulator_enable(kai_hdmi_vddio);
250         if (ret < 0) {
251                 pr_err("hdmi: couldn't enable regulator vdd_hdmi_con\n");
252                 regulator_put(kai_hdmi_vddio);
253                 kai_hdmi_vddio = NULL;
254                 return ret;
255         }
256         return ret;
257 }
258
259 static int kai_hdmi_vddio_disable(void)
260 {
261         if (kai_hdmi_vddio) {
262                 regulator_disable(kai_hdmi_vddio);
263                 regulator_put(kai_hdmi_vddio);
264                 kai_hdmi_vddio = NULL;
265         }
266         return 0;
267 }
268
269 static int kai_hdmi_enable(void)
270 {
271         int ret;
272         if (!kai_hdmi_reg) {
273                 kai_hdmi_reg = regulator_get(NULL, "avdd_hdmi");
274                 if (IS_ERR_OR_NULL(kai_hdmi_reg)) {
275                         pr_err("hdmi: couldn't get regulator avdd_hdmi\n");
276                         kai_hdmi_reg = NULL;
277                         return PTR_ERR(kai_hdmi_reg);
278                 }
279         }
280         ret = regulator_enable(kai_hdmi_reg);
281         if (ret < 0) {
282                 pr_err("hdmi: couldn't enable regulator avdd_hdmi\n");
283                 return ret;
284         }
285         if (!kai_hdmi_pll) {
286                 kai_hdmi_pll = regulator_get(NULL, "avdd_hdmi_pll");
287                 if (IS_ERR_OR_NULL(kai_hdmi_pll)) {
288                         pr_err("hdmi: couldn't get regulator avdd_hdmi_pll\n");
289                         kai_hdmi_pll = NULL;
290                         regulator_put(kai_hdmi_reg);
291                         kai_hdmi_reg = NULL;
292                         return PTR_ERR(kai_hdmi_pll);
293                 }
294         }
295         ret = regulator_enable(kai_hdmi_pll);
296         if (ret < 0) {
297                 pr_err("hdmi: couldn't enable regulator avdd_hdmi_pll\n");
298                 return ret;
299         }
300         return 0;
301 }
302
303 static int kai_hdmi_disable(void)
304 {
305         regulator_disable(kai_hdmi_reg);
306         regulator_put(kai_hdmi_reg);
307         kai_hdmi_reg = NULL;
308
309         regulator_disable(kai_hdmi_pll);
310         regulator_put(kai_hdmi_pll);
311         kai_hdmi_pll = NULL;
312         return 0;
313 }
314
315 static struct resource kai_disp1_resources[] = {
316         {
317                 .name   = "irq",
318                 .start  = INT_DISPLAY_GENERAL,
319                 .end    = INT_DISPLAY_GENERAL,
320                 .flags  = IORESOURCE_IRQ,
321         },
322         {
323                 .name   = "regs",
324                 .start  = TEGRA_DISPLAY_BASE,
325                 .end    = TEGRA_DISPLAY_BASE + TEGRA_DISPLAY_SIZE-1,
326                 .flags  = IORESOURCE_MEM,
327         },
328         {
329                 .name   = "fbmem",
330                 .start  = 0,    /* Filled in by kai_panel_init() */
331                 .end    = 0,    /* Filled in by kai_panel_init() */
332                 .flags  = IORESOURCE_MEM,
333         },
334 };
335
336 static struct resource kai_disp2_resources[] = {
337         {
338                 .name   = "irq",
339                 .start  = INT_DISPLAY_B_GENERAL,
340                 .end    = INT_DISPLAY_B_GENERAL,
341                 .flags  = IORESOURCE_IRQ,
342         },
343         {
344                 .name   = "regs",
345                 .start  = TEGRA_DISPLAY2_BASE,
346                 .end    = TEGRA_DISPLAY2_BASE + TEGRA_DISPLAY2_SIZE - 1,
347                 .flags  = IORESOURCE_MEM,
348         },
349         {
350                 .name   = "fbmem",
351                 .flags  = IORESOURCE_MEM,
352                 .start  = 0,
353                 .end    = 0,
354         },
355         {
356                 .name   = "hdmi_regs",
357                 .start  = TEGRA_HDMI_BASE,
358                 .end    = TEGRA_HDMI_BASE + TEGRA_HDMI_SIZE - 1,
359                 .flags  = IORESOURCE_MEM,
360         },
361 };
362 #endif
363
364 static struct tegra_dc_mode kai_panel_modes[] = {
365         {
366                 /* 1024x600@60Hz */
367                 .pclk = 51206000,
368                 .h_ref_to_sync = 11,
369                 .v_ref_to_sync = 1,
370                 .h_sync_width = 10,
371                 .v_sync_width = 5,
372                 .h_back_porch = 10,
373                 .v_back_porch = 15,
374                 .h_active = 1024,
375                 .v_active = 600,
376                 .h_front_porch = 300,
377                 .v_front_porch = 15,
378         },
379 };
380
381 static struct tegra_dc_sd_settings kai_sd_settings = {
382         .enable = 1, /* enabled by default. */
383         .use_auto_pwm = false,
384         .hw_update_delay = 0,
385         .bin_width = -1,
386         .aggressiveness = 1,
387         .phase_in_adjustments = true,
388         .use_vid_luma = false,
389         /* Default video coefficients */
390         .coeff = {5, 9, 2},
391         .fc = {0, 0},
392         /* Immediate backlight changes */
393         .blp = {1024, 255},
394         /* Gammas: R: 2.2 G: 2.2 B: 2.2 */
395         /* Default BL TF */
396         .bltf = {
397                         {
398                                 {57, 65, 74, 83},
399                                 {93, 103, 114, 126},
400                                 {138, 151, 165, 179},
401                                 {194, 209, 225, 242},
402                         },
403                         {
404                                 {58, 66, 75, 84},
405                                 {94, 105, 116, 127},
406                                 {140, 153, 166, 181},
407                                 {196, 211, 227, 244},
408                         },
409                         {
410                                 {60, 68, 77, 87},
411                                 {97, 107, 119, 130},
412                                 {143, 156, 170, 184},
413                                 {199, 215, 231, 248},
414                         },
415                         {
416                                 {64, 73, 82, 91},
417                                 {102, 113, 124, 137},
418                                 {149, 163, 177, 192},
419                                 {207, 223, 240, 255},
420                         },
421                 },
422         /* Default LUT */
423         .lut = {
424                         {
425                                 {250, 250, 250},
426                                 {194, 194, 194},
427                                 {149, 149, 149},
428                                 {113, 113, 113},
429                                 {82, 82, 82},
430                                 {56, 56, 56},
431                                 {34, 34, 34},
432                                 {15, 15, 15},
433                                 {0, 0, 0},
434                         },
435                         {
436                                 {246, 246, 246},
437                                 {191, 191, 191},
438                                 {147, 147, 147},
439                                 {111, 111, 111},
440                                 {80, 80, 80},
441                                 {55, 55, 55},
442                                 {33, 33, 33},
443                                 {14, 14, 14},
444                                 {0, 0, 0},
445                         },
446                         {
447                                 {239, 239, 239},
448                                 {185, 185, 185},
449                                 {142, 142, 142},
450                                 {107, 107, 107},
451                                 {77, 77, 77},
452                                 {52, 52, 52},
453                                 {30, 30, 30},
454                                 {12, 12, 12},
455                                 {0, 0, 0},
456                         },
457                         {
458                                 {224, 224, 224},
459                                 {173, 173, 173},
460                                 {133, 133, 133},
461                                 {99, 99, 99},
462                                 {70, 70, 70},
463                                 {46, 46, 46},
464                                 {25, 25, 25},
465                                 {7, 7, 7},
466                                 {0, 0, 0},
467                         },
468                 },
469         .sd_brightness = &sd_brightness,
470         .bl_device = &kai_backlight_device,
471 };
472
473 #ifdef CONFIG_TEGRA_DC
474 static struct tegra_fb_data kai_fb_data = {
475         .win            = 0,
476         .xres           = 1024,
477         .yres           = 600,
478         .bits_per_pixel = 32,
479         .flags          = TEGRA_FB_FLIP_ON_PROBE,
480 };
481
482 static struct tegra_fb_data kai_hdmi_fb_data = {
483         .win            = 0,
484         .xres           = 1024,
485         .yres           = 600,
486         .bits_per_pixel = 32,
487         .flags          = TEGRA_FB_FLIP_ON_PROBE,
488 };
489
490 static struct tegra_dc_out kai_disp2_out = {
491         .type           = TEGRA_DC_OUT_HDMI,
492         .flags          = TEGRA_DC_OUT_HOTPLUG_HIGH,
493
494         .dcc_bus        = 3,
495         .hotplug_gpio   = kai_hdmi_hpd,
496
497         .max_pixclock   = KHZ2PICOS(148500),
498
499         .align          = TEGRA_DC_ALIGN_MSB,
500         .order          = TEGRA_DC_ORDER_RED_BLUE,
501
502         .enable         = kai_hdmi_enable,
503         .disable        = kai_hdmi_disable,
504
505         .postsuspend    = kai_hdmi_vddio_disable,
506         .hotplug_init   = kai_hdmi_vddio_enable,
507 };
508
509 static struct tegra_dc_platform_data kai_disp2_pdata = {
510         .flags          = 0,
511         .default_out    = &kai_disp2_out,
512         .fb             = &kai_hdmi_fb_data,
513         .emc_clk_rate   = 300000000,
514 };
515 #endif
516
517 static struct tegra_dc_out kai_disp1_out = {
518         .align          = TEGRA_DC_ALIGN_MSB,
519         .order          = TEGRA_DC_ORDER_RED_BLUE,
520         .sd_settings    = &kai_sd_settings,
521         .parent_clk     = "pll_p",
522         .parent_clk_backup = "pll_d2_out0",
523
524         .type           = TEGRA_DC_OUT_RGB,
525         .depth          = 18,
526         .dither         = TEGRA_DC_ORDERED_DITHER,
527
528         .modes          = kai_panel_modes,
529         .n_modes        = ARRAY_SIZE(kai_panel_modes),
530
531         .enable         = kai_panel_enable,
532         .disable        = kai_panel_disable,
533 };
534
535 #ifdef CONFIG_TEGRA_DC
536 static struct tegra_dc_platform_data kai_disp1_pdata = {
537         .flags          = TEGRA_DC_FLAG_ENABLED,
538         .default_out    = &kai_disp1_out,
539         .emc_clk_rate   = 300000000,
540         .fb             = &kai_fb_data,
541 };
542
543 static struct nvhost_device kai_disp1_device = {
544         .name           = "tegradc",
545         .id             = 0,
546         .resource       = kai_disp1_resources,
547         .num_resources  = ARRAY_SIZE(kai_disp1_resources),
548         .dev = {
549                 .platform_data = &kai_disp1_pdata,
550         },
551 };
552
553 static int kai_disp1_check_fb(struct device *dev, struct fb_info *info)
554 {
555         return info->device == &kai_disp1_device.dev;
556 }
557
558 static struct nvhost_device kai_disp2_device = {
559         .name           = "tegradc",
560         .id             = 1,
561         .resource       = kai_disp2_resources,
562         .num_resources  = ARRAY_SIZE(kai_disp2_resources),
563         .dev = {
564                 .platform_data = &kai_disp2_pdata,
565         },
566 };
567 #else
568 static int kai_disp1_check_fb(struct device *dev, struct fb_info *info)
569 {
570         return 0;
571 }
572 #endif
573
574 #if defined(CONFIG_TEGRA_NVMAP)
575 static struct nvmap_platform_carveout kai_carveouts[] = {
576         [0] = NVMAP_HEAP_CARVEOUT_IRAM_INIT,
577         [1] = {
578                 .name           = "generic-0",
579                 .usage_mask     = NVMAP_HEAP_CARVEOUT_GENERIC,
580                 .base           = 0,    /* Filled in by kai_panel_init() */
581                 .size           = 0,    /* Filled in by kai_panel_init() */
582                 .buddy_size     = SZ_32K,
583         },
584 };
585
586 static struct nvmap_platform_data kai_nvmap_data = {
587         .carveouts      = kai_carveouts,
588         .nr_carveouts   = ARRAY_SIZE(kai_carveouts),
589 };
590
591 static struct platform_device kai_nvmap_device = {
592         .name   = "tegra-nvmap",
593         .id     = -1,
594         .dev    = {
595                 .platform_data = &kai_nvmap_data,
596         },
597 };
598 #endif
599
600 static struct platform_device *kai_gfx_devices[] __initdata = {
601 #if defined(CONFIG_TEGRA_NVMAP)
602         &kai_nvmap_device,
603 #endif
604         &tegra_pwfm0_device,
605         &kai_backlight_device,
606 };
607
608
609 #ifdef CONFIG_HAS_EARLYSUSPEND
610 /* put early_suspend/late_resume handlers here for the display in order
611  * to keep the code out of the display driver, keeping it closer to upstream
612  */
613 struct early_suspend kai_panel_early_suspender;
614
615 static void kai_panel_early_suspend(struct early_suspend *h)
616 {
617         /* power down LCD, add use a black screen for HDMI */
618         if (num_registered_fb > 0)
619                 fb_blank(registered_fb[0], FB_BLANK_POWERDOWN);
620         if (num_registered_fb > 1)
621                 fb_blank(registered_fb[1], FB_BLANK_NORMAL);
622 #ifdef CONFIG_TEGRA_CONVSERVATIVE_GOV_ON_EARLYSUPSEND
623         cpufreq_store_default_gov();
624         if (cpufreq_change_gov(cpufreq_conservative_gov))
625                 pr_err("Early_suspend: Error changing governor to %s\n",
626                                 cpufreq_conservative_gov);
627 #endif
628 }
629
630 static void kai_panel_late_resume(struct early_suspend *h)
631 {
632         unsigned i;
633 #ifdef CONFIG_TEGRA_CONVSERVATIVE_GOV_ON_EARLYSUPSEND
634         if (cpufreq_restore_default_gov())
635                 pr_err("Early_suspend: Unable to restore governor\n");
636 #endif
637         for (i = 0; i < num_registered_fb; i++)
638                 fb_blank(registered_fb[i], FB_BLANK_UNBLANK);
639 }
640 #endif
641
642 int __init kai_panel_init(void)
643 {
644         int err;
645         struct resource __maybe_unused *res;
646         struct board_info board_info;
647
648         tegra_get_board_info(&board_info);
649
650 #if defined(CONFIG_TEGRA_NVMAP)
651         kai_carveouts[1].base = tegra_carveout_start;
652         kai_carveouts[1].size = tegra_carveout_size;
653 #endif
654         gpio_request(kai_lvds_avdd_en, "lvds_avdd_en");
655         gpio_direction_output(kai_lvds_avdd_en, 1);
656
657         gpio_request(kai_lvds_stdby, "lvds_stdby");
658         gpio_direction_output(kai_lvds_stdby, 1);
659
660         gpio_request(kai_lvds_rst, "lvds_rst");
661         gpio_direction_output(kai_lvds_rst, 1);
662
663         if (board_info.fab == BOARD_FAB_A00) {
664                 gpio_request(kai_lvds_rs_a00, "lvds_rs");
665                 gpio_direction_output(kai_lvds_rs_a00, 0);
666         } else {
667                 gpio_request(kai_lvds_rs, "lvds_rs");
668                 gpio_direction_output(kai_lvds_rs, 0);
669         }
670
671         gpio_request(kai_lvds_lr, "lvds_lr");
672         gpio_direction_output(kai_lvds_lr, 1);
673
674         gpio_request(kai_lvds_shutdown, "lvds_shutdown");
675         gpio_direction_output(kai_lvds_shutdown, 1);
676
677         gpio_request(kai_hdmi_hpd, "hdmi_hpd");
678         gpio_direction_input(kai_hdmi_hpd);
679
680 #ifdef CONFIG_HAS_EARLYSUSPEND
681         kai_panel_early_suspender.suspend = kai_panel_early_suspend;
682         kai_panel_early_suspender.resume = kai_panel_late_resume;
683         kai_panel_early_suspender.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
684         register_early_suspend(&kai_panel_early_suspender);
685 #endif
686
687 #ifdef CONFIG_TEGRA_GRHOST
688         err = tegra3_register_host1x_devices();
689         if (err)
690                 return err;
691 #endif
692
693         err = platform_add_devices(kai_gfx_devices,
694                                 ARRAY_SIZE(kai_gfx_devices));
695
696 #if defined(CONFIG_TEGRA_GRHOST) && defined(CONFIG_TEGRA_DC)
697         res = nvhost_get_resource_byname(&kai_disp1_device,
698                                          IORESOURCE_MEM, "fbmem");
699         res->start = tegra_fb_start;
700         res->end = tegra_fb_start + tegra_fb_size - 1;
701 #endif
702
703         /* Copy the bootloader fb to the fb. */
704         tegra_move_framebuffer(tegra_fb_start, tegra_bootloader_fb_start,
705                                 min(tegra_fb_size, tegra_bootloader_fb_size));
706
707 #if defined(CONFIG_TEGRA_GRHOST) && defined(CONFIG_TEGRA_DC)
708         if (!err)
709                 err = nvhost_device_register(&kai_disp1_device);
710
711         res = nvhost_get_resource_byname(&kai_disp2_device,
712                                          IORESOURCE_MEM, "fbmem");
713         res->start = tegra_fb2_start;
714         res->end = tegra_fb2_start + tegra_fb2_size - 1;
715         if (!err)
716                 err = nvhost_device_register(&kai_disp2_device);
717 #endif
718
719 #if defined(CONFIG_TEGRA_GRHOST) && defined(CONFIG_TEGRA_NVAVP)
720         if (!err)
721                 err = nvhost_device_register(&nvavp_device);
722 #endif
723         return err;
724 }