blob: 49fdfec763b43a889fdce217a29347687375f09a [file] [log] [blame]
Donghwa Lee6d4339f2012-04-05 19:36:17 +00001/*
2 * Copyright (C) 2012 Samsung Electronics
3 *
4 * Author: InKi Dae <inki.dae@samsung.com>
5 * Author: Donghwa Lee <dh09.lee@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * MA 02111-1307 USA
21 */
22
23#include <config.h>
24#include <common.h>
25#include <lcd.h>
26#include <asm/io.h>
27#include <asm/arch/cpu.h>
28#include <asm/arch/clock.h>
29#include <asm/arch/clk.h>
30#include <asm/arch/mipi_dsim.h>
31#include <asm/arch/system.h>
32
33#include "exynos_fb.h"
34
35int lcd_line_length;
36int lcd_color_fg;
37int lcd_color_bg;
38
39void *lcd_base;
40void *lcd_console_address;
41
42short console_col;
43short console_row;
44
45static unsigned int panel_width, panel_height;
46
Donghwa Lee6d4339f2012-04-05 19:36:17 +000047static void exynos_lcd_init_mem(void *lcdbase, vidinfo_t *vid)
48{
49 unsigned long palette_size;
50 unsigned int fb_size;
51
Donghwa Leef78095e2012-04-23 15:37:05 +000052 fb_size = vid->vl_row * vid->vl_col * (NBITS(vid->vl_bpix) >> 3);
Donghwa Lee6d4339f2012-04-05 19:36:17 +000053
54 lcd_base = lcdbase;
55
56 palette_size = NBITS(vid->vl_bpix) == 8 ? 256 : 16;
57
58 exynos_fimd_lcd_init_mem((unsigned long)lcd_base,
59 (unsigned long)fb_size, palette_size);
60}
61
62static void exynos_lcd_init(vidinfo_t *vid)
63{
64 exynos_fimd_lcd_init(vid);
65}
66
Donghwa Lee90464972012-05-09 19:23:46 +000067static void draw_logo(void)
68{
69 int x, y;
70 ulong addr;
71
72 x = ((panel_width - panel_info.logo_width) >> 1);
73 y = ((panel_height - panel_info.logo_height) >> 1) - 4;
74
75 addr = panel_info.logo_addr;
76 bmp_display(addr, x, y);
77}
78
Donghwa Lee6d4339f2012-04-05 19:36:17 +000079static void lcd_panel_on(vidinfo_t *vid)
80{
81 udelay(vid->init_delay);
82
83 if (vid->backlight_reset)
84 vid->backlight_reset();
85
86 if (vid->cfg_gpio)
87 vid->cfg_gpio();
88
89 if (vid->lcd_power_on)
90 vid->lcd_power_on();
91
92 udelay(vid->power_on_delay);
93
94 if (vid->reset_lcd) {
95 vid->reset_lcd();
96 udelay(vid->reset_delay);
97 }
98
99 if (vid->backlight_on)
100 vid->backlight_on(1);
101
102 if (vid->cfg_ldo)
103 vid->cfg_ldo();
104
105 if (vid->enable_ldo)
106 vid->enable_ldo(1);
107
108 if (vid->mipi_enabled)
109 exynos_mipi_dsi_init();
110}
111
112void lcd_ctrl_init(void *lcdbase)
113{
114 set_system_display_ctrl();
115 set_lcd_clk();
116
117 /* initialize parameters which is specific to panel. */
118 init_panel_info(&panel_info);
119
120 panel_width = panel_info.vl_width;
121 panel_height = panel_info.vl_height;
122
123 exynos_lcd_init_mem(lcdbase, &panel_info);
124
125 exynos_lcd_init(&panel_info);
126}
127
128void lcd_enable(void)
129{
Donghwa Lee90464972012-05-09 19:23:46 +0000130 if (panel_info.logo_on) {
131 memset(lcd_base, 0, panel_width * panel_height *
132 (NBITS(panel_info.vl_bpix) >> 3));
133
134 draw_logo();
135 }
136
Donghwa Lee6d4339f2012-04-05 19:36:17 +0000137 lcd_panel_on(&panel_info);
138}
139
140/* dummy function */
141void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue)
142{
143 return;
144}