blob: 4536c5c0e863ab2f4f6ebfd262cbf8bed7cb07b7 [file] [log] [blame]
Donghwa Lee0112fed2012-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 Leebc72aeb2012-07-02 01:16:08 +000031#include <asm/arch/dp_info.h>
Donghwa Lee0112fed2012-04-05 19:36:17 +000032#include <asm/arch/system.h>
33
34#include "exynos_fb.h"
35
36int lcd_line_length;
Donghwa Lee0112fed2012-04-05 19:36:17 +000037
38void *lcd_base;
39void *lcd_console_address;
40
41short console_col;
42short console_row;
43
44static unsigned int panel_width, panel_height;
45
Donghwa Lee0112fed2012-04-05 19:36:17 +000046static void exynos_lcd_init_mem(void *lcdbase, vidinfo_t *vid)
47{
48 unsigned long palette_size;
49 unsigned int fb_size;
50
Donghwa Lee2386f452012-04-23 15:37:05 +000051 fb_size = vid->vl_row * vid->vl_col * (NBITS(vid->vl_bpix) >> 3);
Donghwa Lee0112fed2012-04-05 19:36:17 +000052
53 lcd_base = lcdbase;
54
55 palette_size = NBITS(vid->vl_bpix) == 8 ? 256 : 16;
56
57 exynos_fimd_lcd_init_mem((unsigned long)lcd_base,
58 (unsigned long)fb_size, palette_size);
59}
60
61static void exynos_lcd_init(vidinfo_t *vid)
62{
63 exynos_fimd_lcd_init(vid);
Ɓukasz Majewski43905f42013-01-08 03:48:40 +000064
65 /* Enable flushing after LCD writes if requested */
66 lcd_set_flush_dcache(1);
Donghwa Lee0112fed2012-04-05 19:36:17 +000067}
68
Ajay Kumar6c6a8222013-01-13 23:32:16 +000069#ifdef CONFIG_CMD_BMP
Donghwa Lee37980dd2012-05-09 19:23:46 +000070static void draw_logo(void)
71{
72 int x, y;
73 ulong addr;
74
Piotr Wilczek79c40e62012-10-19 05:34:06 +000075 if (panel_width >= panel_info.logo_width) {
76 x = ((panel_width - panel_info.logo_width) >> 1);
77 } else {
78 x = 0;
79 printf("Warning: image width is bigger than display width\n");
80 }
81
82 if (panel_height >= panel_info.logo_height) {
83 y = ((panel_height - panel_info.logo_height) >> 1) - 4;
84 } else {
85 y = 0;
86 printf("Warning: image height is bigger than display height\n");
87 }
Donghwa Lee37980dd2012-05-09 19:23:46 +000088
89 addr = panel_info.logo_addr;
90 bmp_display(addr, x, y);
91}
Ajay Kumar6c6a8222013-01-13 23:32:16 +000092#endif
Donghwa Lee37980dd2012-05-09 19:23:46 +000093
Donghwa Lee0112fed2012-04-05 19:36:17 +000094static void lcd_panel_on(vidinfo_t *vid)
95{
96 udelay(vid->init_delay);
97
98 if (vid->backlight_reset)
99 vid->backlight_reset();
100
101 if (vid->cfg_gpio)
102 vid->cfg_gpio();
103
104 if (vid->lcd_power_on)
105 vid->lcd_power_on();
106
107 udelay(vid->power_on_delay);
108
Donghwa Leebc72aeb2012-07-02 01:16:08 +0000109 if (vid->dp_enabled)
110 exynos_init_dp();
111
Donghwa Lee0112fed2012-04-05 19:36:17 +0000112 if (vid->reset_lcd) {
113 vid->reset_lcd();
114 udelay(vid->reset_delay);
115 }
116
117 if (vid->backlight_on)
118 vid->backlight_on(1);
119
120 if (vid->cfg_ldo)
121 vid->cfg_ldo();
122
123 if (vid->enable_ldo)
124 vid->enable_ldo(1);
125
126 if (vid->mipi_enabled)
127 exynos_mipi_dsi_init();
128}
129
130void lcd_ctrl_init(void *lcdbase)
131{
132 set_system_display_ctrl();
133 set_lcd_clk();
134
135 /* initialize parameters which is specific to panel. */
136 init_panel_info(&panel_info);
137
138 panel_width = panel_info.vl_width;
139 panel_height = panel_info.vl_height;
140
141 exynos_lcd_init_mem(lcdbase, &panel_info);
142
143 exynos_lcd_init(&panel_info);
144}
145
146void lcd_enable(void)
147{
Donghwa Lee37980dd2012-05-09 19:23:46 +0000148 if (panel_info.logo_on) {
149 memset(lcd_base, 0, panel_width * panel_height *
150 (NBITS(panel_info.vl_bpix) >> 3));
Ajay Kumar6c6a8222013-01-13 23:32:16 +0000151#ifdef CONFIG_CMD_BMP
Donghwa Lee37980dd2012-05-09 19:23:46 +0000152 draw_logo();
Ajay Kumar6c6a8222013-01-13 23:32:16 +0000153#endif
Donghwa Lee37980dd2012-05-09 19:23:46 +0000154 }
155
Donghwa Lee0112fed2012-04-05 19:36:17 +0000156 lcd_panel_on(&panel_info);
157}
158
159/* dummy function */
160void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue)
161{
162 return;
163}