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,
27 #undef SWAPPED_LCD /* For the previous h/w version */
29 * The name of the device used for communication
32 #define PSOC_PSC MPC5XXX_PSC2
33 #define PSOC_BAUD 230400UL
41 * Dimensions in pixels
44 #define LCD_HEIGHT 100
49 #define LCD_BUF_SIZE ((LCD_WIDTH*LCD_HEIGHT)>>3)
51 #if LCD_BPP != LCD_MONOCHROME
52 #error "MCC200 support only monochrome displays (1 bpp)!"
55 #define PSOC_RETRIES 10 /* each of PSOC_WAIT_TIME */
56 #define PSOC_WAIT_TIME 10 /* usec */
58 DECLARE_GLOBAL_DATA_PTR;
63 vidinfo_t panel_info = {
64 LCD_WIDTH, LCD_HEIGHT, LCD_BPP
73 * Frame buffer memory information
75 void *lcd_base; /* Start of framebuffer memory */
76 void *lcd_console_address; /* Start of console buffer */
78 short console_col = 0;
79 short console_row = 0;
82 * The device we use to communicate with PSoC
84 int serial_inited = 0;
89 void lcd_initcolregs (void);
90 void lcd_ctrl_init (void *lcdbase);
91 void lcd_enable (void);
94 * Imported functions to support the PSoC protocol
96 extern int serial_init_dev (unsigned long dev_base);
97 extern void serial_setrts_dev (unsigned long dev_base, int s);
98 extern int serial_getcts_dev (unsigned long dev_base);
99 extern void serial_putc_raw_dev(unsigned long dev_base, const char c);
102 * Just stubs for our driver, needed for compiling compabilty with
103 * the common LCD driver code.
105 void lcd_initcolregs (void)
109 void lcd_ctrl_init (void *lcdbase)
114 * Function sends the contents of the frame-buffer to the LCD
116 void lcd_enable (void)
118 int i, retries, fb_size;
120 if (!serial_inited) {
124 gd->baudrate = PSOC_BAUD;
125 serial_init_dev(PSOC_PSC);
127 serial_setrts_dev (PSOC_PSC, RTS_ASSERT);
132 * Implement PSoC communication protocol:
133 * 1. Assert RTS, wait CTS assertion
135 * 3. Negate RTS, wait CTS negation
139 serial_setrts_dev (PSOC_PSC, RTS_ASSERT);
140 for (retries = PSOC_RETRIES; retries; retries--) {
141 if (serial_getcts_dev(PSOC_PSC) == CTS_ASSERT)
143 udelay (PSOC_WAIT_TIME);
146 printf ("%s Error: PSoC doesn't respond on "
147 "RTS ASSERT\n", __FUNCTION__);
151 fb_size = panel_info.vl_row * (panel_info.vl_col >> 3);
153 #if !defined(SWAPPED_LCD)
154 for (i=0; i<fb_size; i++) {
155 serial_putc_raw_dev (PSOC_PSC, ((char *)lcd_base)[i]);
160 char *p = (char *)lcd_base;
162 pwidth = ((panel_info.vl_col+7) >> 3);
163 for (y=0; y<panel_info.vl_row; y++) {
165 for (x=0; x<pwidth; x+=5) {
166 serial_putc_raw_dev (PSOC_PSC, (p[i+x+2]<<4 & 0xF0) | (p[i+x+3]>>4 & 0x0F));
167 serial_putc_raw_dev (PSOC_PSC, (p[i+x+3]<<4 & 0xF0) | (p[i+x+4]>>4 & 0x0F));
168 serial_putc_raw_dev (PSOC_PSC, (p[i+x+4]<<4 & 0xF0) | (p[i+x]>>4 & 0x0F));
169 serial_putc_raw_dev (PSOC_PSC, (p[i+x]<<4 & 0xF0) | (p[i+x+1]>>4 & 0x0F));
170 serial_putc_raw_dev (PSOC_PSC, (p[i+x+1]<<4 & 0xF0) | (p[i+x+2]>>4 & 0x0F));
177 serial_setrts_dev (PSOC_PSC, RTS_NEGATE);
178 for (retries = PSOC_RETRIES; retries; retries--) {
179 if (serial_getcts_dev(PSOC_PSC) == CTS_NEGATE)
181 udelay (PSOC_WAIT_TIME);
186 #ifdef CONFIG_PROGRESSBAR
188 #define FONT_WIDTH 8 /* the same as VIDEO_FONT_WIDTH in video_font.h */
189 void show_progress (int size, int tot)
197 cnt = ((LCD_WIDTH/FONT_WIDTH) * rc) / tot;
199 rc -= (cnt * tot) / (LCD_WIDTH/FONT_WIDTH);
201 for (i = 0; i < cnt; i++) {
206 lcd_enable(); /* MCC200-specific - send the framebuffer to PSoC */
211 #endif /* CONFIG_LCD */