]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Add splashscreen support for MCC200 board.
authorWolfgang Denk <wd@pollux.denx.de>
Wed, 30 Aug 2006 21:09:00 +0000 (23:09 +0200)
committerWolfgang Denk <wd@pollux.denx.de>
Wed, 30 Aug 2006 21:09:00 +0000 (23:09 +0200)
CHANGELOG
board/mcc200/Makefile
board/mcc200/lcd.c [new file with mode: 0644]
common/lcd.c
cpu/mpc5xxx/serial.c
include/configs/mcc200.h
include/lcd.h

index 87341755e27404bf86e466564ce0eafe62ded5e7..7df923c047d8b860aef22efb8cf7d7b6fb166d6f 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,8 @@
 Changes since U-Boot 1.1.4:
 ======================================================================
 
+* Add splashscreen support for MCC200 board.
+
 * Make the serial driver framework work with CONFIG_SERIAL_MULTI
   enabled
 
index 7fdc088e9c178724169c71dcc4f892d7305fd047..bd75859f61553b2f9d88fa4847f1462e2008391b 100644 (file)
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB    = lib$(BOARD).a
 
-OBJS   := $(BOARD).o
+OBJS   := $(BOARD).o lcd.o
 
 $(LIB):        $(OBJS) $(SOBJS)
        $(AR) crv $@ $(OBJS)
diff --git a/board/mcc200/lcd.c b/board/mcc200/lcd.c
new file mode 100644 (file)
index 0000000..b262516
--- /dev/null
@@ -0,0 +1,190 @@
+/*
+ * (C) Copyright 2006
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <lcd.h>
+#include <mpc5xxx.h>
+
+#ifdef CONFIG_LCD
+
+#define SWAPPED_LCD
+/*
+ *  The name of the device used for communication
+ * with the PSoC.
+ */
+#define PSOC_PSC       MPC5XXX_PSC2
+#define PSOC_BAUD      500000UL
+
+#define RTS_ASSERT     1
+#define RTS_NEGATE     0
+#define CTS_ASSERT     1
+#define CTS_NEGATE     0
+
+/*
+ * Dimensions in pixels
+ */
+#define LCD_WIDTH      160
+#define LCD_HEIGHT     100
+
+/*
+ * Dimensions in bytes
+ */
+#define LCD_BUF_SIZE   ((LCD_WIDTH*LCD_HEIGHT)>>3)
+
+#if LCD_BPP != LCD_MONOCHROME
+#error "MCC200 support only monochrome displays (1 bpp)!"
+#endif
+
+#define PSOC_RETRIES   10      /* each of PSOC_WAIT_TIME */
+#define PSOC_WAIT_TIME 10      /* usec */
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * LCD information
+ */
+vidinfo_t panel_info = {
+       LCD_WIDTH, LCD_HEIGHT, LCD_BPP
+};
+
+int lcd_line_length;
+
+int lcd_color_fg;
+int lcd_color_bg;
+
+/*
+ * Frame buffer memory information
+ */
+void *lcd_base;                        /* Start of framebuffer memory  */
+void *lcd_console_address;     /* Start of console buffer      */
+
+short console_col = 0;
+short console_row = 0;
+
+/*
+ *  The device we use to communicate with PSoC
+ */
+int serial_inited = 0;
+
+/*
+ * Exported functions
+ */
+void lcd_initcolregs (void);
+void lcd_ctrl_init (void *lcdbase);
+void lcd_enable (void);
+
+/*
+ *  Imported functions to support the PSoC protocol
+ */
+extern int serial_init_dev (unsigned long dev_base);
+extern void serial_setrts_dev (unsigned long dev_base, int s);
+extern int serial_getcts_dev (unsigned long dev_base);
+extern void serial_putc_raw_dev(unsigned long dev_base, const char c);
+
+/*
+ *  Just stubs for our driver, needed for compiling compabilty with
+ * the common LCD driver code.
+ */
+void lcd_initcolregs (void)
+{
+}
+
+void lcd_ctrl_init (void *lcdbase)
+{
+}
+
+/*
+ * Function sends the contents of the frame-buffer to the LCD
+ */
+void lcd_enable (void)
+{
+       int i, retries, fb_size;
+
+       if (!serial_inited) {
+               unsigned long baud;
+
+               baud = gd->baudrate;
+               gd->baudrate = PSOC_BAUD;
+               serial_init_dev(PSOC_PSC);
+               gd->baudrate = baud;
+               serial_setrts_dev (PSOC_PSC, RTS_ASSERT);
+               serial_inited = 1;
+       }
+
+       /*
+        *  Implement PSoC communication protocol:
+        * 1. Assert RTS, wait CTS assertion
+        * 2. Transmit data
+        * 3. Negate RTS, wait CTS negation
+        */
+
+       /* 1 */
+       serial_setrts_dev (PSOC_PSC, RTS_ASSERT);
+       for (retries = PSOC_RETRIES; retries; retries--) {
+               if (serial_getcts_dev(PSOC_PSC) == CTS_ASSERT)
+                       break;
+               udelay (PSOC_WAIT_TIME);
+       }
+       if (!retries) {
+               printf ("%s Error: PSoC doesn't respond on "
+                       "RTS ASSERT\n", __FUNCTION__);
+       }
+
+       /* 2 */
+       fb_size = panel_info.vl_row * (panel_info.vl_col >> 3);
+
+#if !defined(SWAPPED_LCD)
+       for (i=0; i<fb_size; i++) {
+               serial_putc_raw_dev (PSOC_PSC, ((char *)lcd_base)[i]);
+       }
+#else
+    {
+       int x, y, pwidth;
+       char *p = (char *)lcd_base;
+
+       pwidth = ((panel_info.vl_col+7) >> 3);
+       for (y=0; y<panel_info.vl_row; y++) {
+               i = y * pwidth;
+               for (x=0; x<pwidth; x+=5) {
+                       serial_putc_raw_dev (PSOC_PSC, (p[i+x+2]<<4 & 0xF0) | (p[i+x+3]>>4 & 0x0F));
+                       serial_putc_raw_dev (PSOC_PSC, (p[i+x+3]<<4 & 0xF0) | (p[i+x+4]>>4 & 0x0F));
+                       serial_putc_raw_dev (PSOC_PSC, (p[i+x+4]<<4 & 0xF0) | (p[i+x]>>4 & 0x0F));
+                       serial_putc_raw_dev (PSOC_PSC, (p[i+x]<<4 & 0xF0) | (p[i+x+1]>>4 & 0x0F));
+                       serial_putc_raw_dev (PSOC_PSC, (p[i+x+1]<<4 & 0xF0) | (p[i+x+2]>>4 & 0x0F));
+               }
+       }
+    }
+#endif
+
+       /* 3 */
+       serial_setrts_dev (PSOC_PSC, RTS_NEGATE);
+       for (retries = PSOC_RETRIES; retries; retries--) {
+               if (serial_getcts_dev(PSOC_PSC) == CTS_NEGATE)
+                       break;
+               udelay (PSOC_WAIT_TIME);
+       }
+       if (!retries) {
+               printf ("%s Error: PSoC doesn't respond on "
+                       "RTS NEGATE\n", __FUNCTION__);
+       }
+
+       return;
+}
+#endif /* CONFIG_LCD */
index 0be1912a359e56dfb1b1f63139e8633764793902..d79350f2347c709b0f78bbcb60e5877c737f583a 100644 (file)
@@ -585,6 +585,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
        uchar *bmap;
        ushort padded_line;
        unsigned long width, height;
+       unsigned long pwidth = panel_info.vl_col;
        unsigned colors,bpix;
        unsigned long compression;
 #if defined(CONFIG_PXA250)
@@ -628,6 +629,8 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
                cmap = (ushort *)fbi->palette;
 #elif defined(CONFIG_MPC823)
                cmap = (ushort *)&(cp->lcd_cmap[255*sizeof(ushort)]);
+#elif defined(CONFIG_MCC200)
+               /* MCC200 LCD doesn't need CMAP, supports 1bpp b&w only */
 #else
 # error "Don't know location of color map"
 #endif
@@ -652,9 +655,28 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
                }
        }
 
+       /*
+        *  BMP format for Monochrome assumes that the state of a
+        * pixel is described on a per Bit basis, not per Byte.
+        *  So, in case of Monochrome BMP we should align widths
+        * on a byte boundary and convert them from Bit to Byte
+        * units.
+        *  Probably, PXA250 and MPC823 process 1bpp BMP images in 
+        * their own ways, so make the converting to be MCC200 
+        * specific.
+        */
+#if defined(CONFIG_MCC200)
+       if (bpix==1)
+       {
+               width = ((width + 7) & ~7) >> 3;
+               x     = ((x + 7) & ~7) >> 3;
+               pwidth= ((pwidth + 7) & ~7) >> 3;
+       }
+#endif
+
        padded_line = (width&0x3) ? ((width&~0x3)+4) : (width);
-       if ((x + width)>panel_info.vl_col)
-               width = panel_info.vl_col - x;
+       if ((x + width)>pwidth)
+               width = pwidth - x;
        if ((y + height)>panel_info.vl_row)
                height = panel_info.vl_row - y;
 
@@ -666,7 +688,7 @@ int lcd_display_bitmap(ulong bmp_image, int x, int y)
                for (j = 0; j < width ; j++)
 #if defined(CONFIG_PXA250)
                        *(fb++)=*(bmap++);
-#elif defined(CONFIG_MPC823)
+#elif defined(CONFIG_MPC823) || defined(CONFIG_MCC200)
                        *(fb++)=255-*(bmap++);
 #endif
                bmap += (width - padded_line);
index 6cb523d3c7bf5428d03497341d11906e93d50bcf..430d63f7464f4b3cf6fcfa57dccf7a1a1b648b6f 100644 (file)
@@ -165,6 +165,25 @@ void serial_putc(const char c)
        psc->psc_buffer_8 = c;
 }
 
+#if defined(CONFIG_SERIAL_MULTI)
+void serial_putc_raw_dev(unsigned long dev_base, const char c)
+#else
+void serial_putc_raw(const char c)
+#endif
+{
+#if defined(CONFIG_SERIAL_MULTI)
+       volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)dev_base;
+#else
+       volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)PSC_BASE;
+#endif
+       /* Wait for last character to go. */
+       while (!(psc->psc_status & PSC_SR_TXEMP))
+               ;
+
+       psc->psc_buffer_8 = c;
+}
+
+
 #if defined(CONFIG_SERIAL_MULTI)
 void serial_puts_dev (unsigned long dev_base, const char *s)
 #else
@@ -239,6 +258,43 @@ void serial_setbrg(void)
        psc->ctlr =  div & 0xff;
 }
 
+#if defined(CONFIG_SERIAL_MULTI)
+void serial_setrts_dev (unsigned long dev_base, int s)
+#else
+void serial_setrts(int s)
+#endif
+{
+#if defined(CONFIG_SERIAL_MULTI)
+       volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)dev_base;
+#else
+       volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)PSC_BASE;
+#endif
+
+       if (s) {
+               /* Assert RTS (become LOW) */
+               psc->op1 = 0x1;
+       }
+       else {
+               /* Negate RTS (become HIGH) */
+               psc->op0 = 0x1;
+       }
+}
+
+#if defined(CONFIG_SERIAL_MULTI)
+int serial_getcts_dev (unsigned long dev_base)
+#else
+int serial_getcts(void)
+#endif
+{
+#if defined(CONFIG_SERIAL_MULTI)
+       volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)dev_base;
+#else
+       volatile struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)PSC_BASE;
+#endif
+
+       return (psc->ip & 0x1) ? 0 : 1;
+}
+
 #if defined(CONFIG_SERIAL_MULTI)
 int serial0_init(void)
 {
index 61014ecd1f2ad1ad3453dc4089799efce5dfb685..e95d68bfb8889c591f613d05a54e3357de1acfd0 100644 (file)
 /* #define CONFIG_FEC_10MBIT 1 */
 #define CONFIG_PHY_ADDR                1
 
+/*
+ * LCD Splash Screen
+ */
+#define CONFIG_LCD             1
+#if defined(CONFIG_LCD)
+#define CONFIG_SPLASH_SCREEN   1
+#define CFG_CONSOLE_IS_IN_ENV  1
+#define LCD_BPP                LCD_MONOCHROME
+#endif
+
 /*
  * GPIO configuration
  */
 /* 0x10000004 = 32MB SDRAM */
 /* 0x90000004 = 64MB SDRAM */
+#if defined(CONFIG_LCD)
+/* set PSC2 in UART mode */
+#define CFG_GPS_PORT_CONFIG    0x00000044
+#else
 #define CFG_GPS_PORT_CONFIG    0x00000004
+#endif
 
 /*
  * Miscellaneous configurable options
index 7e23736bca957a3340c10b3e072342f694d86f38..b688583828b1c82f90c9ea4a0a670d0eb7fb03a5 100644 (file)
@@ -148,7 +148,14 @@ typedef struct vidinfo {
 
 extern vidinfo_t panel_info;
 
-#endif /* CONFIG_MPC823 or CONFIG_PXA250 */
+#elif defined(CONFIG_MCC200)
+typedef struct vidinfo {
+       ushort  vl_col;         /* Number of columns (i.e. 160) */
+       ushort  vl_row;         /* Number of rows (i.e. 100) */
+
+       u_char  vl_bpix;        /* Bits per pixel, 0 = 1 */
+} vidinfo_t;
+#endif /* CONFIG_MPC823, CONFIG_PXA250 or CONFIG_MCC200 */
 
 /* Video functions */