Simon Glass | 3ef2a72 | 2015-04-14 21:03:42 -0600 | [diff] [blame] | 1 | /* |
| 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 | |
| 18 | DECLARE_GLOBAL_DATA_PTR; |
| 19 | |
| 20 | enum { |
| 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 | |
| 27 | vidinfo_t panel_info = { |
| 28 | /* Insert a value here so that we don't end up in the BSS */ |
| 29 | .vl_col = -1, |
| 30 | }; |
| 31 | |
| 32 | int tegra_lcd_check_next_stage(const void *blob, int wait) |
| 33 | { |
| 34 | return 0; |
| 35 | } |
| 36 | |
| 37 | void 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 | |
| 48 | static int tegra124_lcd_init(void *lcdbase) |
| 49 | { |
| 50 | struct display_timing timing; |
| 51 | int ret; |
| 52 | |
| 53 | clock_set_up_plldp(); |
Simon Glass | a660342 | 2015-06-05 14:39:41 -0600 | [diff] [blame] | 54 | clock_start_periph_pll(PERIPH_ID_HOST1X, CLOCK_ID_PERIPH, 408000000); |
Simon Glass | 3ef2a72 | 2015-04-14 21:03:42 -0600 | [diff] [blame] | 55 | |
| 56 | clock_enable(PERIPH_ID_HOST1X); |
| 57 | clock_enable(PERIPH_ID_DISP1); |
| 58 | clock_enable(PERIPH_ID_PWM); |
| 59 | clock_enable(PERIPH_ID_DPAUX); |
| 60 | clock_enable(PERIPH_ID_SOR0); |
Simon Glass | 3ef2a72 | 2015-04-14 21:03:42 -0600 | [diff] [blame] | 61 | udelay(2); |
| 62 | |
| 63 | reset_set_enable(PERIPH_ID_HOST1X, 0); |
| 64 | reset_set_enable(PERIPH_ID_DISP1, 0); |
| 65 | reset_set_enable(PERIPH_ID_PWM, 0); |
| 66 | reset_set_enable(PERIPH_ID_DPAUX, 0); |
| 67 | reset_set_enable(PERIPH_ID_SOR0, 0); |
| 68 | |
| 69 | ret = display_init(lcdbase, 1 << LCD_BPP, &timing); |
| 70 | if (ret) |
| 71 | return ret; |
| 72 | |
| 73 | panel_info.vl_col = roundup(timing.hactive.typ, 16); |
| 74 | panel_info.vl_row = timing.vactive.typ; |
| 75 | |
| 76 | lcd_set_flush_dcache(1); |
| 77 | |
| 78 | return 0; |
| 79 | } |
| 80 | |
| 81 | void lcd_ctrl_init(void *lcdbase) |
| 82 | { |
| 83 | ulong start; |
| 84 | int ret; |
| 85 | |
| 86 | start = get_timer(0); |
| 87 | ret = tegra124_lcd_init(lcdbase); |
| 88 | debug("LCD init took %lu ms\n", get_timer(start)); |
| 89 | if (ret) |
| 90 | printf("%s: Error %d\n", __func__, ret); |
| 91 | } |
| 92 | |
| 93 | void lcd_enable(void) |
| 94 | { |
| 95 | } |