3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
15 #undef SWAPPED_LCD /* For the previous h/w version */
17 * The name of the device used for communication
20 #define PSOC_PSC MPC5XXX_PSC2
21 #define PSOC_BAUD 230400UL
29 * Dimensions in pixels
32 #define LCD_HEIGHT 100
37 #define LCD_BUF_SIZE ((LCD_WIDTH*LCD_HEIGHT)>>3)
39 #if LCD_BPP != LCD_MONOCHROME
40 #error "MCC200 support only monochrome displays (1 bpp)!"
43 #define PSOC_RETRIES 10 /* each of PSOC_WAIT_TIME */
44 #define PSOC_WAIT_TIME 10 /* usec */
46 #include <video_font.h>
47 #define FONT_WIDTH VIDEO_FONT_WIDTH
49 DECLARE_GLOBAL_DATA_PTR;
54 vidinfo_t panel_info = {
55 LCD_WIDTH, LCD_HEIGHT, LCD_BPP
60 * The device we use to communicate with PSoC
62 int serial_inited = 0;
65 * Imported functions to support the PSoC protocol
67 extern int serial_init_dev (unsigned long dev_base);
68 extern void serial_setrts_dev (unsigned long dev_base, int s);
69 extern int serial_getcts_dev (unsigned long dev_base);
70 extern void serial_putc_raw_dev(unsigned long dev_base, const char c);
73 * Just stubs for our driver, needed for compiling compabilty with
74 * the common LCD driver code.
76 void lcd_initcolregs (void)
80 void lcd_ctrl_init (void *lcdbase)
85 * Function sends the contents of the frame-buffer to the LCD
87 void lcd_enable (void)
89 int i, retries, fb_size;
95 gd->baudrate = PSOC_BAUD;
96 serial_init_dev(PSOC_PSC);
98 serial_setrts_dev (PSOC_PSC, RTS_ASSERT);
103 * Implement PSoC communication protocol:
104 * 1. Assert RTS, wait CTS assertion
106 * 3. Negate RTS, wait CTS negation
110 serial_setrts_dev (PSOC_PSC, RTS_ASSERT);
111 for (retries = PSOC_RETRIES; retries; retries--) {
112 if (serial_getcts_dev(PSOC_PSC) == CTS_ASSERT)
114 udelay (PSOC_WAIT_TIME);
117 printf ("%s Error: PSoC doesn't respond on "
118 "RTS ASSERT\n", __FUNCTION__);
122 fb_size = panel_info.vl_row * (panel_info.vl_col >> 3);
124 #if !defined(SWAPPED_LCD)
125 for (i=0; i<fb_size; i++) {
126 serial_putc_raw_dev(PSOC_PSC, ((char *)gd->fb_base)[i]);
131 char *p = (char *)gd->fb_base;
133 pwidth = ((panel_info.vl_col+7) >> 3);
134 for (y=0; y<panel_info.vl_row; y++) {
136 for (x=0; x<pwidth; x+=5) {
137 serial_putc_raw_dev (PSOC_PSC, (p[i+x+2]<<4 & 0xF0) | (p[i+x+3]>>4 & 0x0F));
138 serial_putc_raw_dev (PSOC_PSC, (p[i+x+3]<<4 & 0xF0) | (p[i+x+4]>>4 & 0x0F));
139 serial_putc_raw_dev (PSOC_PSC, (p[i+x+4]<<4 & 0xF0) | (p[i+x]>>4 & 0x0F));
140 serial_putc_raw_dev (PSOC_PSC, (p[i+x]<<4 & 0xF0) | (p[i+x+1]>>4 & 0x0F));
141 serial_putc_raw_dev (PSOC_PSC, (p[i+x+1]<<4 & 0xF0) | (p[i+x+2]>>4 & 0x0F));
148 serial_setrts_dev (PSOC_PSC, RTS_NEGATE);
149 for (retries = PSOC_RETRIES; retries; retries--) {
150 if (serial_getcts_dev(PSOC_PSC) == CTS_NEGATE)
152 udelay (PSOC_WAIT_TIME);
157 #ifdef CONFIG_PROGRESSBAR
159 void show_progress (int size, int tot)
167 cnt = ((LCD_WIDTH/FONT_WIDTH) * rc) / tot;
169 rc -= (cnt * tot) / (LCD_WIDTH/FONT_WIDTH);
171 for (i = 0; i < cnt; i++) {
176 lcd_enable(); /* MCC200-specific - send the framebuffer to PSoC */
182 int bmp_display(ulong addr, int x, int y)
185 bmp_image_t *bmp = (bmp_image_t *)addr;
188 printf("There is no valid bmp file at the given address\n");
192 ret = lcd_display_bitmap((ulong)bmp, x, y);
194 if ((unsigned long)bmp != addr)
200 #endif /* CONFIG_LCD */