blob: 27335907544985487c507e56072c38a8b1d2d978 [file] [log] [blame]
Simon Glasse7e88232015-04-14 21:03:42 -06001/*
2 * Copyright 2014 Google Inc.
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 *
6 */
7
8#include <common.h>
9#include <errno.h>
10#include <fdtdec.h>
11#include <lcd.h>
12#include <asm/gpio.h>
13#include <asm/arch-tegra/clk_rst.h>
14#include <asm/arch/clock.h>
15#include <asm/arch-tegra/dc.h>
16#include <asm/io.h>
17
18DECLARE_GLOBAL_DATA_PTR;
19
20enum {
21 /* Maximum LCD size we support */
22 LCD_MAX_WIDTH = 1920,
23 LCD_MAX_HEIGHT = 1200,
24 LCD_MAX_LOG2_BPP = 4, /* 2^4 = 16 bpp */
25};
26
27vidinfo_t panel_info = {
28 /* Insert a value here so that we don't end up in the BSS */
29 .vl_col = -1,
30};
31
32int tegra_lcd_check_next_stage(const void *blob, int wait)
33{
34 return 0;
35}
36
37void tegra_lcd_early_init(const void *blob)
38{
39 /*
40 * Go with the maximum size for now. We will fix this up after
41 * relocation. These values are only used for memory alocation.
42 */
43 panel_info.vl_col = LCD_MAX_WIDTH;
44 panel_info.vl_row = LCD_MAX_HEIGHT;
45 panel_info.vl_bpix = LCD_MAX_LOG2_BPP;
46}
47
48static int tegra124_lcd_init(void *lcdbase)
49{
50 struct display_timing timing;
51 int ret;
52
53 clock_set_up_plldp();
54 clock_adjust_periph_pll_div(PERIPH_ID_HOST1X, CLOCK_ID_PERIPH,
55 408000000, NULL);
56
57 clock_enable(PERIPH_ID_HOST1X);
58 clock_enable(PERIPH_ID_DISP1);
59 clock_enable(PERIPH_ID_PWM);
60 clock_enable(PERIPH_ID_DPAUX);
61 clock_enable(PERIPH_ID_SOR0);
62
63 udelay(2);
64
65 reset_set_enable(PERIPH_ID_HOST1X, 0);
66 reset_set_enable(PERIPH_ID_DISP1, 0);
67 reset_set_enable(PERIPH_ID_PWM, 0);
68 reset_set_enable(PERIPH_ID_DPAUX, 0);
69 reset_set_enable(PERIPH_ID_SOR0, 0);
70
71 ret = display_init(lcdbase, 1 << LCD_BPP, &timing);
72 if (ret)
73 return ret;
74
75 panel_info.vl_col = roundup(timing.hactive.typ, 16);
76 panel_info.vl_row = timing.vactive.typ;
77
78 lcd_set_flush_dcache(1);
79
80 return 0;
81}
82
83void lcd_ctrl_init(void *lcdbase)
84{
85 ulong start;
86 int ret;
87
88 start = get_timer(0);
89 ret = tegra124_lcd_init(lcdbase);
90 debug("LCD init took %lu ms\n", get_timer(start));
91 if (ret)
92 printf("%s: Error %d\n", __func__, ret);
93}
94
95void lcd_enable(void)
96{
97}