]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - drivers/video/exynos_fb.c
common/lcd.c: cleanup use of global variables
[karo-tx-uboot.git] / drivers / video / exynos_fb.c
1 /*
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/dp_info.h>
32 #include <asm/arch/system.h>
33
34 #include "exynos_fb.h"
35
36 void *lcd_base;
37
38 static unsigned int panel_width, panel_height;
39
40 static void exynos_lcd_init_mem(void *lcdbase, vidinfo_t *vid)
41 {
42         unsigned long palette_size;
43         unsigned int fb_size;
44
45         fb_size = vid->vl_row * vid->vl_col * (NBITS(vid->vl_bpix) >> 3);
46
47         lcd_base = lcdbase;
48
49         palette_size = NBITS(vid->vl_bpix) == 8 ? 256 : 16;
50
51         exynos_fimd_lcd_init_mem((unsigned long)lcd_base,
52                         (unsigned long)fb_size, palette_size);
53 }
54
55 static void exynos_lcd_init(vidinfo_t *vid)
56 {
57         exynos_fimd_lcd_init(vid);
58
59         /* Enable flushing after LCD writes if requested */
60         lcd_set_flush_dcache(1);
61 }
62
63 #ifdef CONFIG_CMD_BMP
64 static void draw_logo(void)
65 {
66         int x, y;
67         ulong addr;
68
69         if (panel_width >= panel_info.logo_width) {
70                 x = ((panel_width - panel_info.logo_width) >> 1);
71         } else {
72                 x = 0;
73                 printf("Warning: image width is bigger than display width\n");
74         }
75
76         if (panel_height >= panel_info.logo_height) {
77                 y = ((panel_height - panel_info.logo_height) >> 1) - 4;
78         } else {
79                 y = 0;
80                 printf("Warning: image height is bigger than display height\n");
81         }
82
83         addr = panel_info.logo_addr;
84         bmp_display(addr, x, y);
85 }
86 #endif
87
88 static void lcd_panel_on(vidinfo_t *vid)
89 {
90         udelay(vid->init_delay);
91
92         if (vid->backlight_reset)
93                 vid->backlight_reset();
94
95         if (vid->cfg_gpio)
96                 vid->cfg_gpio();
97
98         if (vid->lcd_power_on)
99                 vid->lcd_power_on();
100
101         udelay(vid->power_on_delay);
102
103         if (vid->dp_enabled)
104                 exynos_init_dp();
105
106         if (vid->reset_lcd) {
107                 vid->reset_lcd();
108                 udelay(vid->reset_delay);
109         }
110
111         if (vid->backlight_on)
112                 vid->backlight_on(1);
113
114         if (vid->cfg_ldo)
115                 vid->cfg_ldo();
116
117         if (vid->enable_ldo)
118                 vid->enable_ldo(1);
119
120         if (vid->mipi_enabled)
121                 exynos_mipi_dsi_init();
122 }
123
124 void lcd_ctrl_init(void *lcdbase)
125 {
126         set_system_display_ctrl();
127         set_lcd_clk();
128
129         /* initialize parameters which is specific to panel. */
130         init_panel_info(&panel_info);
131
132         panel_width = panel_info.vl_width;
133         panel_height = panel_info.vl_height;
134
135         exynos_lcd_init_mem(lcdbase, &panel_info);
136
137         exynos_lcd_init(&panel_info);
138 }
139
140 void lcd_enable(void)
141 {
142         if (panel_info.logo_on) {
143                 memset(lcd_base, 0, panel_width * panel_height *
144                                 (NBITS(panel_info.vl_bpix) >> 3));
145 #ifdef CONFIG_CMD_BMP
146                 draw_logo();
147 #endif
148         }
149
150         lcd_panel_on(&panel_info);
151 }
152
153 /* dummy function */
154 void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue)
155 {
156         return;
157 }