blob: e31a0fd500abef1bc46c9e0518e7bc2e8639db3d [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>
Donghwa Leea29c8322012-07-02 01:16:08 +000031#include <asm/arch/dp_info.h>
Donghwa Lee6d4339f2012-04-05 19:36:17 +000032#include <asm/arch/system.h>
33
34#include "exynos_fb.h"
35
36int lcd_line_length;
37int lcd_color_fg;
38int lcd_color_bg;
39
40void *lcd_base;
41void *lcd_console_address;
42
43short console_col;
44short console_row;
45
46static unsigned int panel_width, panel_height;
47
Donghwa Lee6d4339f2012-04-05 19:36:17 +000048static void exynos_lcd_init_mem(void *lcdbase, vidinfo_t *vid)
49{
50 unsigned long palette_size;
51 unsigned int fb_size;
52
Donghwa Leef78095e2012-04-23 15:37:05 +000053 fb_size = vid->vl_row * vid->vl_col * (NBITS(vid->vl_bpix) >> 3);
Donghwa Lee6d4339f2012-04-05 19:36:17 +000054
55 lcd_base = lcdbase;
56
57 palette_size = NBITS(vid->vl_bpix) == 8 ? 256 : 16;
58
59 exynos_fimd_lcd_init_mem((unsigned long)lcd_base,
60 (unsigned long)fb_size, palette_size);
61}
62
63static void exynos_lcd_init(vidinfo_t *vid)
64{
65 exynos_fimd_lcd_init(vid);
66}
67
Donghwa Lee90464972012-05-09 19:23:46 +000068static void draw_logo(void)
69{
70 int x, y;
71 ulong addr;
72
73 x = ((panel_width - panel_info.logo_width) >> 1);
74 y = ((panel_height - panel_info.logo_height) >> 1) - 4;
75
76 addr = panel_info.logo_addr;
77 bmp_display(addr, x, y);
78}
79
Donghwa Lee6d4339f2012-04-05 19:36:17 +000080static void lcd_panel_on(vidinfo_t *vid)
81{
82 udelay(vid->init_delay);
83
84 if (vid->backlight_reset)
85 vid->backlight_reset();
86
87 if (vid->cfg_gpio)
88 vid->cfg_gpio();
89
90 if (vid->lcd_power_on)
91 vid->lcd_power_on();
92
93 udelay(vid->power_on_delay);
94
Donghwa Leea29c8322012-07-02 01:16:08 +000095 if (vid->dp_enabled)
96 exynos_init_dp();
97
Donghwa Lee6d4339f2012-04-05 19:36:17 +000098 if (vid->reset_lcd) {
99 vid->reset_lcd();
100 udelay(vid->reset_delay);
101 }
102
103 if (vid->backlight_on)
104 vid->backlight_on(1);
105
106 if (vid->cfg_ldo)
107 vid->cfg_ldo();
108
109 if (vid->enable_ldo)
110 vid->enable_ldo(1);
111
112 if (vid->mipi_enabled)
113 exynos_mipi_dsi_init();
114}
115
116void lcd_ctrl_init(void *lcdbase)
117{
118 set_system_display_ctrl();
119 set_lcd_clk();
120
121 /* initialize parameters which is specific to panel. */
122 init_panel_info(&panel_info);
123
124 panel_width = panel_info.vl_width;
125 panel_height = panel_info.vl_height;
126
127 exynos_lcd_init_mem(lcdbase, &panel_info);
128
129 exynos_lcd_init(&panel_info);
130}
131
132void lcd_enable(void)
133{
Donghwa Lee90464972012-05-09 19:23:46 +0000134 if (panel_info.logo_on) {
135 memset(lcd_base, 0, panel_width * panel_height *
136 (NBITS(panel_info.vl_bpix) >> 3));
Donghwa Lee90464972012-05-09 19:23:46 +0000137 draw_logo();
138 }
139
Donghwa Lee6d4339f2012-04-05 19:36:17 +0000140 lcd_panel_on(&panel_info);
141}
142
143/* dummy function */
144void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue)
145{
146 return;
147}