2 * S5PC100 and S5PC110 LCD Controller driver.
4 * Author: InKi Dae <inki.dae@samsung.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
26 #include <linux/types.h>
28 #include <asm/arch/cpu.h>
32 #include "opening_wvga_32.h"
34 #define PANEL_WIDTH 480
35 #define PANEL_HEIGHT 800
36 #define S5P_LCD_BPP 32
39 #define SCREEN_WIDTH (480 * 2)
40 #define SCREEN_HEIGHT 800
42 extern void tl2796_panel_power_on(void);
43 extern void tl2796_panel_enable(void);
44 extern void tl2796_panel_init(void);
53 void *lcd_console_address;
58 static unsigned short makepixel565(char r, char g, char b)
60 return (unsigned short)(((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3));
63 static unsigned int makepixel8888(char a, char r, char g, char b)
65 return (unsigned int)((a << 24) | (r << 16) | (g << 8) | b);
68 static void read_image16(char* pImg, int x1pos, int y1pos, int x2pos,
69 int y2pos, unsigned short pixel)
71 unsigned short *pDst = (unsigned short *)pImg;
72 unsigned int offset_s;
75 for(i = y1pos; i < y2pos; i++) {
76 for(j = x1pos; j < x2pos; j++) {
77 offset_s = i * SCREEN_WIDTH + j;
78 *(pDst + offset_s) = pixel;
83 static void read_image32(char* pImg, int x1pos, int y1pos, int x2pos,
84 int y2pos, unsigned int pixel)
86 unsigned int *pDst = (unsigned int *)pImg;
87 unsigned int offset_s;
90 for(i = y1pos; i < y2pos; i++) {
91 for(j = x1pos; j < x2pos; j++) {
92 offset_s = i * SCREEN_WIDTH + j;
93 *(pDst+offset_s) = pixel;
99 vidinfo_t panel_info = {
100 .vl_col = SCREEN_WIDTH,
101 .vl_row = SCREEN_HEIGHT,
102 .vl_width = PANEL_WIDTH,
103 .vl_height = PANEL_HEIGHT,
104 .vl_clkp = CONFIG_SYS_HIGH,
105 .vl_hsp = CONFIG_SYS_LOW,
106 .vl_vsp = CONFIG_SYS_LOW,
107 .vl_dp = CONFIG_SYS_HIGH,
108 .vl_bpix = S5P_LCD_BPP,
123 static void s5pc_lcd_init_mem(void *lcdbase, vidinfo_t *vid)
125 unsigned long palette_size, palette_mem_size;
126 unsigned int fb_size;
128 fb_size = vid->vl_row * vid->vl_col * (vid->vl_bpix / 8);
132 palette_size = NBITS(vid->vl_bpix) == 8 ? 256 : 16;
133 palette_mem_size = palette_size * sizeof(u32);
135 s5pc_fimd_lcd_init_mem((unsigned long)lcd_base, (unsigned long)fb_size, palette_size);
137 udebug("fb_size=%d, screen_base=%x, palette_size=%d, palettle_mem_size=%d\n",
138 fb_size, (unsigned int)lcd_base, (int)palette_size, (int)palette_mem_size);
141 static void s5pc_gpio_setup(void)
143 s5pc_c110_gpio_setup();
146 static void s5pc_lcd_init(vidinfo_t *vid)
148 s5pc_fimd_lcd_init(vid);
151 static void dual_lcd_test(void)
153 int x1 = 100, y1 = 50, x2 = 100, y2 = 50, i;
155 read_image32((char *)lcd_base, 0+x1, 0+y1, 960-x2, 200,
156 makepixel8888(0, 255, 0, 0));
158 read_image32((char *)lcd_base, 0+x1, 200, 960-x2, 400,
159 makepixel8888(0, 0, 255, 0));
161 read_image32((char *)lcd_base, 0+x1, 400, 960-x2, 600,
162 makepixel8888(0, 0, 0, 255));
164 read_image32((char *)lcd_base, 0+x1, 600, 960-x2, 800-y2,
165 makepixel8888(0, 255, 255, 255));
168 static void repeat_test(void)
172 for (i = 100; i < 200; i++) {
173 read_image32((char *)lcd_base, 0, 0, 960, 800,
174 makepixel8888(0, (0x1234 * i) & 255, (0x5421 * i) & 255, (0x6789 * i) & 255));
178 void draw_bitmap(void *lcdbase, int x, int y, int w, int h, unsigned long *bmp)
181 unsigned long *fb = (unsigned long*)lcdbase;
183 for (j = y; j < (y + h); j++) {
184 for (i = x; i < (w + x); i++) {
185 *(fb + (j * SCREEN_WIDTH) + i) =
186 *(unsigned long *)(bmp + k);
192 static void draw_samsung_logo(void* lcdbase)
196 x = (SCREEN_WIDTH - 138) / 2;
197 y = (SCREEN_HEIGHT - 28) / 2 - 5;
199 draw_bitmap(lcdbase, x, y, 138, 28, (unsigned long *)opening_32);
202 static void lcd_panel_on(void)
204 tl2796_c110_panel_init();
205 tl2796_c110_panel_power_on();
207 tl2796_panel_enable();
210 void lcd_ctrl_init(void *lcdbase)
212 s5pc_lcd_init_mem(lcdbase, &panel_info);
214 memset(lcd_base, 0, panel_info.vl_col * panel_info.vl_row * S5P_LCD_BPP >> 3);
218 s5pc_lcd_init(&panel_info);
221 void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blud)
226 void lcd_enable(void)
232 option = getenv("lcd");
233 if (strcmp(option, "test") == 0)
235 else if (strcmp(option, "on") == 0)
236 draw_samsung_logo(lcd_base);
237 else if (strcmp(option, "repeat") == 0)
240 draw_samsung_logo(lcd_base);
243 ulong calc_fbsize(void)
245 return s5pc_fimd_calc_fbsize();
248 void s5pc1xxfb_test(void *lcdbase)
250 lcd_ctrl_init(lcdbase);