3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 #undef SWAPPED_LCD /* For the previous h/w version */
30 * The name of the device used for communication
33 #define PSOC_PSC MPC5XXX_PSC2
34 #define PSOC_BAUD 230400UL
42 * Dimensions in pixels
45 #define LCD_HEIGHT 100
50 #define LCD_BUF_SIZE ((LCD_WIDTH*LCD_HEIGHT)>>3)
52 #if LCD_BPP != LCD_MONOCHROME
53 #error "MCC200 support only monochrome displays (1 bpp)!"
56 #define PSOC_RETRIES 10 /* each of PSOC_WAIT_TIME */
57 #define PSOC_WAIT_TIME 10 /* usec */
59 #include <video_font.h>
60 #define FONT_WIDTH VIDEO_FONT_WIDTH
62 DECLARE_GLOBAL_DATA_PTR;
67 vidinfo_t panel_info = {
68 LCD_WIDTH, LCD_HEIGHT, LCD_BPP
77 * Frame buffer memory information
79 void *lcd_base; /* Start of framebuffer memory */
80 void *lcd_console_address; /* Start of console buffer */
82 short console_col = 0;
83 short console_row = 0;
86 * The device we use to communicate with PSoC
88 int serial_inited = 0;
93 void lcd_initcolregs (void);
94 void lcd_ctrl_init (void *lcdbase);
95 void lcd_enable (void);
98 * Imported functions to support the PSoC protocol
100 extern int serial_init_dev (unsigned long dev_base);
101 extern void serial_setrts_dev (unsigned long dev_base, int s);
102 extern int serial_getcts_dev (unsigned long dev_base);
103 extern void serial_putc_raw_dev(unsigned long dev_base, const char c);
106 * Just stubs for our driver, needed for compiling compabilty with
107 * the common LCD driver code.
109 void lcd_initcolregs (void)
113 void lcd_ctrl_init (void *lcdbase)
118 * Function sends the contents of the frame-buffer to the LCD
120 void lcd_enable (void)
122 int i, retries, fb_size;
124 if (!serial_inited) {
128 gd->baudrate = PSOC_BAUD;
129 serial_init_dev(PSOC_PSC);
131 serial_setrts_dev (PSOC_PSC, RTS_ASSERT);
136 * Implement PSoC communication protocol:
137 * 1. Assert RTS, wait CTS assertion
139 * 3. Negate RTS, wait CTS negation
143 serial_setrts_dev (PSOC_PSC, RTS_ASSERT);
144 for (retries = PSOC_RETRIES; retries; retries--) {
145 if (serial_getcts_dev(PSOC_PSC) == CTS_ASSERT)
147 udelay (PSOC_WAIT_TIME);
150 printf ("%s Error: PSoC doesn't respond on "
151 "RTS ASSERT\n", __FUNCTION__);
155 fb_size = panel_info.vl_row * (panel_info.vl_col >> 3);
157 #if !defined(SWAPPED_LCD)
158 for (i=0; i<fb_size; i++) {
159 serial_putc_raw_dev (PSOC_PSC, ((char *)lcd_base)[i]);
164 char *p = (char *)lcd_base;
166 pwidth = ((panel_info.vl_col+7) >> 3);
167 for (y=0; y<panel_info.vl_row; y++) {
169 for (x=0; x<pwidth; x+=5) {
170 serial_putc_raw_dev (PSOC_PSC, (p[i+x+2]<<4 & 0xF0) | (p[i+x+3]>>4 & 0x0F));
171 serial_putc_raw_dev (PSOC_PSC, (p[i+x+3]<<4 & 0xF0) | (p[i+x+4]>>4 & 0x0F));
172 serial_putc_raw_dev (PSOC_PSC, (p[i+x+4]<<4 & 0xF0) | (p[i+x]>>4 & 0x0F));
173 serial_putc_raw_dev (PSOC_PSC, (p[i+x]<<4 & 0xF0) | (p[i+x+1]>>4 & 0x0F));
174 serial_putc_raw_dev (PSOC_PSC, (p[i+x+1]<<4 & 0xF0) | (p[i+x+2]>>4 & 0x0F));
181 serial_setrts_dev (PSOC_PSC, RTS_NEGATE);
182 for (retries = PSOC_RETRIES; retries; retries--) {
183 if (serial_getcts_dev(PSOC_PSC) == CTS_NEGATE)
185 udelay (PSOC_WAIT_TIME);
190 #ifdef CONFIG_PROGRESSBAR
192 void show_progress (int size, int tot)
200 cnt = ((LCD_WIDTH/FONT_WIDTH) * rc) / tot;
202 rc -= (cnt * tot) / (LCD_WIDTH/FONT_WIDTH);
204 for (i = 0; i < cnt; i++) {
209 lcd_enable(); /* MCC200-specific - send the framebuffer to PSoC */
215 int bmp_display(ulong addr, int x, int y)
218 bmp_image_t *bmp = (bmp_image_t *)addr;
221 printf("There is no valid bmp file at the given address\n");
225 ret = lcd_display_bitmap((ulong)bmp, x, y);
227 if ((unsigned long)bmp != addr)
233 #endif /* CONFIG_LCD */