[U-Boot] [PATCH 2/3] arm: added support for display controller in Jade SoC

Matthias Weisser matthias.weisser at graf-syteco.de
Wed Jul 8 09:47:06 CEST 2009


This patch adds support for the display controller in
the MB86R01 'Jade' SoC.

Signed-off-by: Matthias Weisser <matthias.weisser at graf-syteco.de>
---
 drivers/video/Makefile      |    1 +
 drivers/video/cfb_console.c |    2 +-
 drivers/video/jadegdc.c     |  192 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 194 insertions(+), 1 deletions(-)
 create mode 100644 drivers/video/jadegdc.c

diff --git a/drivers/video/Makefile b/drivers/video/Makefile
old mode 100644
new mode 100755
index bc00852..145b23a
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -36,6 +36,7 @@ COBJS-$(CONFIG_VIDEO_SED13806) += sed13806.o
 COBJS-$(CONFIG_SED156X) += sed156x.o
 COBJS-$(CONFIG_VIDEO_SM501) += sm501.o
 COBJS-$(CONFIG_VIDEO_SMI_LYNXEM) += smiLynxEM.o
+COBJS-$(CONFIG_VIDEO_JADEGDC) += jadegdc.o
 COBJS-y += videomodes.o
 
 COBJS	:= $(COBJS-y)
diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c
old mode 100644
new mode 100755
index bcafb27..c34259f
--- a/drivers/video/cfb_console.c
+++ b/drivers/video/cfb_console.c
@@ -314,7 +314,7 @@ void	console_cursor (int state);
 #else
 #define SWAP16(x)	 (x)
 #define SWAP32(x)	 (x)
-#if defined(VIDEO_FB_16BPP_PIXEL_SWAP)
+#if defined(VIDEO_FB_16BPP_PIXEL_SWAP) || defined (CONFIG_VIDEO_JADEGDC)
 #define SHORTSWAP32(x)	 ( ((x) >> 16) | ((x) << 16) )
 #else
 #define SHORTSWAP32(x)	 (x)
diff --git a/drivers/video/jadegdc.c b/drivers/video/jadegdc.c
new file mode 100755
index 0000000..55d0a96
--- /dev/null
+++ b/drivers/video/jadegdc.c
@@ -0,0 +1,192 @@
+/*
+ * (C) Copyright 2007-2009
+ * Matthias Weisser <matthias.weisser at graf-syteco.de>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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
+ */
+
+/*
+ * jade.c - Graphic interface for Fujitsu Jade integrated graphic
+ * controller. Derived from mb862xx.c
+ */
+
+#include <common.h>
+
+#include <malloc.h>
+#include <mb862xx.h>
+#include <asm/io.h>
+#include <video_fb.h>
+#include "videomodes.h"
+
+/*
+ * 4MB (at the end of system RAM)
+ */
+#define VIDEO_MEM_SIZE		0x400000
+
+#define GDC_HOST_BASE		0xF1FC0000
+#define GDC_DSP0_BASE		0xF1FD0000
+#define GDC_DSP1_BASE		0xF1FD2000
+
+/*
+ * Graphic Device
+ */
+GraphicDevice jadegdc;
+
+void *video_hw_init(void)
+{
+	GraphicDevice *pGD = (GraphicDevice *) & jadegdc;
+	struct ctfb_res_modes var_mode[2];
+	unsigned long *vid;
+	unsigned long div;
+	unsigned long dspBase[2];
+	char *penv;
+	int bpp;
+	int i, j;
+
+	memset(pGD, 0, sizeof(GraphicDevice));
+
+	dspBase[0] = GDC_DSP0_BASE;
+	dspBase[1] = GDC_DSP1_BASE;
+
+	pGD->frameAdrs = GDC_HOST_BASE;
+	pGD->gdfIndex = GDF_15BIT_555RGB;
+	pGD->gdfBytesPP = 2;
+
+	pGD->memSize = VIDEO_MEM_SIZE;
+	pGD->frameAdrs = PHYS_SDRAM + PHYS_SDRAM_SIZE - VIDEO_MEM_SIZE;
+	vid = (unsigned long *)pGD->frameAdrs;
+
+	for (i = 0; i < 2; i++) {
+		char varName[32];
+		u32 dcm1, dcm2, dcm3;
+		u16 htp, hdp, hdb, hsp, vtr, vsp, vdp;
+		u8 hsw, vsw;
+		u32 l2m, l2em, l2oa0, l2da0, l2oa1, l2da1;
+		u16 l2dx, l2dy, l2wx, l2wy, l2ww, l2wh;
+
+		sprintf(varName, "gs_dsp_%d_param", i);
+
+		if (NULL == (penv = getenv(varName)))
+			if((i == 1) || (NULL == (penv = getenv("videomode"))))
+				continue;
+
+		bpp = 0;
+		bpp = video_get_params(&var_mode[i], penv);
+
+		if (bpp == 0) {
+			var_mode[i].xres = 640;
+			var_mode[i].yres = 480;
+			var_mode[i].pixclock = 39721;	/* 25MHz */
+			var_mode[i].left_margin = 48;
+			var_mode[i].right_margin = 16;
+			var_mode[i].upper_margin = 33;
+			var_mode[i].lower_margin = 10;
+			var_mode[i].hsync_len = 96;
+			var_mode[i].vsync_len = 2;
+			var_mode[i].sync = 0;
+			var_mode[i].vmode = 0;
+		}
+
+		for (j = 0; j < var_mode[i].xres * var_mode[i].yres / 2; j++)
+			*vid++ = 0xFFFFFFFF;
+
+		pGD->winSizeX = var_mode[i].xres;
+		pGD->winSizeY = var_mode[i].yres;
+
+		/* LCD base clock is ~ 660MHZ. We do calculations in kHz */
+		div = 660000 / (1000000000L / var_mode[i].pixclock);
+		if (div > 64)
+			div = 64;
+
+		dcm1 = div << 8;
+		dcm2 = 0x00000000;
+		dcm3 = 0x00000000;
+
+		htp = var_mode[i].left_margin + var_mode[i].xres +
+				var_mode[i].hsync_len + var_mode[i].right_margin;
+		hdp = var_mode[i].xres;
+		hdb = var_mode[i].xres;
+		hsp = var_mode[i].xres + var_mode[i].right_margin;
+		hsw = var_mode[i].hsync_len;
+
+		vsw = var_mode[i].vsync_len;
+		vtr = var_mode[i].upper_margin + var_mode[i].yres +
+				var_mode[i].vsync_len + var_mode[i].lower_margin;
+		vsp = var_mode[i].yres + var_mode[i].lower_margin;
+		vdp = var_mode[i].yres;
+
+		l2m =	(       (var_mode[i].yres - 1) << ( 0)) |
+				(((var_mode[i].xres * 2) / 64) << (16)) |
+				(                          (1) << (31));
+
+		l2em = (1 << 0) | (1 << 1);
+
+		l2oa0 = pGD->frameAdrs;
+		l2da0 = pGD->frameAdrs;
+		l2oa1 = pGD->frameAdrs;
+		l2da1 = pGD->frameAdrs;
+		l2dx = 0;
+		l2dy = 0;
+		l2wx = 0;
+		l2wy = 0;
+		l2ww = var_mode[i].xres;
+		l2wh = var_mode[i].yres - 1;
+
+		writel(dcm1, dspBase[i] + GC_DCM1);
+		writel(dcm2, dspBase[i] + GC_DCM2);
+		writel(dcm3, dspBase[i] + GC_DCM3);
+
+		writew(htp, dspBase[i] + GC_HTP);
+		writew(hdp, dspBase[i] + GC_HDP);
+		writew(hdb, dspBase[i] + GC_HDB);
+		writew(hsp, dspBase[i] + GC_HSP);
+		writeb(hsw, dspBase[i] + GC_HSW);
+
+		writeb(vsw, dspBase[i] + GC_VSW);
+		writew(vtr, dspBase[i] + GC_VTR);
+		writew(vsp, dspBase[i] + GC_VSP);
+		writew(vdp, dspBase[i] + GC_VDP);
+
+		writel(l2m, dspBase[i] + GC_L2M);
+		writel(l2em, dspBase[i] + GC_L2EM);
+		writel(l2oa0, dspBase[i] + GC_L2OA0);
+		writel(l2da0, dspBase[i] + GC_L2DA0);
+		writel(l2oa1, dspBase[i] + GC_L2OA1);
+		writel(l2da1, dspBase[i] + GC_L2DA1);
+		writew(l2dx, dspBase[i] + GC_L2DX);
+		writew(l2dy, dspBase[i] + GC_L2DY);
+		writew(l2wx, dspBase[i] + GC_L2WX);
+		writew(l2wy, dspBase[i] + GC_L2WY);
+		writew(l2ww, dspBase[i] + GC_L2WW);
+		writew(l2wh, dspBase[i] + GC_L2WH);
+
+		writel(dcm1 | (1 << 18) | (1 << 31), dspBase[i] + GC_DCM1);
+	}
+
+	return pGD;
+}
+
+/*
+ * Set a RGB color in the LUT
+ */
+void video_set_lut (unsigned int index, unsigned char r,
+					unsigned char g, unsigned char b)
+{
+
+}
-- 
1.5.6.3



More information about the U-Boot mailing list