]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
fsl_diu_fb: further refactoring of FSL DIU code
authorAnatolij Gustschin <agust@denx.de>
Thu, 23 Sep 2010 23:06:37 +0000 (01:06 +0200)
committerAnatolij Gustschin <agust@denx.de>
Sat, 25 Sep 2010 11:10:03 +0000 (13:10 +0200)
Move common code to the fsl_diu_fb.c file and remove obsolete
code from board files (aria, mpc8610hpcd and pdm360ng).
Move fsl_diu_fb.h file to the include directory.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
arch/powerpc/cpu/mpc512x/diu.c
board/davedenx/aria/aria.c
board/freescale/common/fsl_diu_fb.c
board/freescale/mpc8610hpcd/mpc8610hpcd_diu.c
board/pdm360ng/pdm360ng.c
include/fsl_diu_fb.h [moved from board/freescale/common/fsl_diu_fb.h with 97% similarity]

index fa4a0bc971db95d7b14530830c2496888b190bae..c4108af33673689f16c73143cb1ad66a2a3b87a5 100644 (file)
 #include <command.h>
 #include <asm/io.h>
 
-#include "../../../../board/freescale/common/fsl_diu_fb.h"
-
-#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
-#include <stdio_dev.h>
-#include <video_fb.h>
-#endif
+#include <fsl_diu_fb.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static int xres, yres;
-
 void diu_set_pixel_clock(unsigned int pixclock)
 {
        volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
@@ -58,61 +51,20 @@ void diu_set_pixel_clock(unsigned int pixclock)
        debug("DIU: Modified value of CLKDVDR = 0x%08x\n", in_be32(clkdvdr));
 }
 
-int mpc5121_diu_init(void)
+int platform_diu_init(unsigned int *xres, unsigned int *yres)
 {
        unsigned int pixel_format;
 
 #if defined(CONFIG_VIDEO_XRES) & defined(CONFIG_VIDEO_YRES)
-       xres = CONFIG_VIDEO_XRES;
-       yres = CONFIG_VIDEO_YRES;
+       *xres = CONFIG_VIDEO_XRES;
+       *yres = CONFIG_VIDEO_YRES;
 #else
-       xres = 1024;
-       yres = 768;
+       *xres = 1024;
+       *yres = 768;
 #endif
        pixel_format = 0x88883316;
 
        debug("mpc5121_diu_init\n");
 
-       return fsl_diu_init(xres, pixel_format, 0);
+       return fsl_diu_init(*xres, pixel_format, 0);
 }
-
-#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
-
-/*
- * The Graphic Device
- */
-GraphicDevice ctfb;
-void *video_hw_init(void)
-{
-       GraphicDevice *pGD = (GraphicDevice *) &ctfb;
-       struct fb_info *info;
-
-       if (mpc5121_diu_init() < 0)
-               return NULL;
-
-       /* fill in Graphic device struct */
-       sprintf(pGD->modeIdent, "%dx%dx%d %dkHz %dHz",
-               xres, yres, 32, 64, 60);
-
-       pGD->frameAdrs = (unsigned int)fsl_fb_open(&info);
-       pGD->winSizeX = xres;
-       pGD->winSizeY = yres;
-       pGD->plnSizeX = pGD->winSizeX;
-       pGD->plnSizeY = pGD->winSizeY;
-
-       pGD->gdfBytesPP = 4;
-       pGD->gdfIndex = GDF_32BIT_X888RGB;
-
-       pGD->isaBase = 0;
-       pGD->pciBase = 0;
-       pGD->memSize = info->screen_size;
-
-       /* Cursor Start Address */
-       pGD->dprBase = 0;
-       pGD->vprBase = 0;
-       pGD->cprBase = 0;
-
-       return (void *)pGD;
-}
-
-#endif /* defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) */
index f17df60c20d3f0e0cfd4223e939b1d531b21065f..31b079b1c38105d65a22ebb42df20d3fc576d6c8 100644 (file)
@@ -119,11 +119,6 @@ int misc_init_r(void)
                 tmp & 0x000000FF
        );
 
-#ifdef CONFIG_FSL_DIU_FB
-# if   !(defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE))
-       mpc5121_diu_init();
-# endif
-#endif
        return 0;
 }
 
index 394b71f32f114a77441920e779d629e2cfc81f4a..35ed938befb5e30d28d40172fe1e176931a26cff 100644 (file)
@@ -28,7 +28,7 @@
 #include <malloc.h>
 #include <asm/io.h>
 
-#include "fsl_diu_fb.h"
+#include <fsl_diu_fb.h>
 
 struct fb_videomode {
        const char *name;       /* optional */
@@ -472,3 +472,42 @@ static int allocate_buf(struct diu_addr *buf, u32 size, u32 bytes_align)
                buf->offset = 0;
        return 0;
 }
+
+#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
+#include <stdio_dev.h>
+#include <video_fb.h>
+/*
+ * The Graphic Device
+ */
+static GraphicDevice ctfb;
+
+void *video_hw_init(void)
+{
+       struct fb_info *info;
+
+       if (platform_diu_init(&ctfb.winSizeX, &ctfb.winSizeY) < 0)
+               return NULL;
+
+       /* fill in Graphic device struct */
+       sprintf(ctfb.modeIdent, "%ix%ix%i %ikHz %iHz",
+               ctfb.winSizeX, ctfb.winSizeY, 32, 64, 60);
+
+       ctfb.frameAdrs = (unsigned int)fsl_fb_open(&info);
+       ctfb.plnSizeX = ctfb.winSizeX;
+       ctfb.plnSizeY = ctfb.winSizeY;
+
+       ctfb.gdfBytesPP = 4;
+       ctfb.gdfIndex = GDF_32BIT_X888RGB;
+
+       ctfb.isaBase = 0;
+       ctfb.pciBase = 0;
+       ctfb.memSize = info->screen_size;
+
+       /* Cursor Start Address */
+       ctfb.dprBase = 0;
+       ctfb.vprBase = 0;
+       ctfb.cprBase = 0;
+
+       return &ctfb;
+}
+#endif /* defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) */
index 960c8eda7d4556d3e74af84744aae5d3db9d419e..81e53e734ffbfbb4d1cb28b98b7b0726246fcaee 100644 (file)
 #include <common.h>
 #include <command.h>
 #include <asm/io.h>
-
-#ifdef CONFIG_FSL_DIU_FB
-
-#include "../common/fsl_diu_fb.h"
-
-#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
-#include <stdio_dev.h>
-#include <video_fb.h>
-#endif
-
-static int xres, yres;
+#include <fsl_diu_fb.h>
 
 void diu_set_pixel_clock(unsigned int pixclock)
 {
@@ -59,7 +49,7 @@ void diu_set_pixel_clock(unsigned int pixclock)
        debug("DIU: Modified value of CLKDVDR = 0x%08x\n", *guts_clkdvdr);
 }
 
-int mpc8610hpcd_diu_init(void)
+int platform_diu_init(unsigned int *xres, unsigned int *yres)
 {
        char *monitor_port;
        int gamma_fix;
@@ -73,8 +63,8 @@ int mpc8610hpcd_diu_init(void)
 
        monitor_port = getenv("monitor");
        if (!strncmp(monitor_port, "0", 1)) {   /* 0 - DVI */
-               xres = 1280;
-               yres = 1024;
+               *xres = 1280;
+               *yres = 1024;
                if (pixis_arch == 0x01)
                        pixel_format = 0x88882317;
                else
@@ -83,68 +73,26 @@ int mpc8610hpcd_diu_init(void)
                out_8(pixis_base + PIXIS_BRDCFG0, tmp_val | 0x08);
 
        } else if (!strncmp(monitor_port, "1", 1)) { /* 1 - Single link LVDS */
-               xres = 1024;
-               yres = 768;
+               *xres = 1024;
+               *yres = 768;
                pixel_format = 0x88883316;
                gamma_fix = 0;
                out_8(pixis_base + PIXIS_BRDCFG0, (tmp_val & 0xf7) | 0x10);
 
        } else if (!strncmp(monitor_port, "2", 1)) { /* 2 - Double link LVDS */
-               xres = 1280;
-               yres = 1024;
+               *xres = 1280;
+               *yres = 1024;
                pixel_format = 0x88883316;
                gamma_fix = 1;
                out_8(pixis_base + PIXIS_BRDCFG0, tmp_val & 0xe7);
 
        } else {        /* DVI */
-               xres = 1280;
-               yres = 1024;
+               *xres = 1280;
+               *yres = 1024;
                pixel_format = 0x88882317;
                gamma_fix = 0;
                out_8(pixis_base + PIXIS_BRDCFG0, tmp_val | 0x08);
        }
 
-       return fsl_diu_init(xres, pixel_format, gamma_fix);
-}
-
-#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
-
-/*
- * The Graphic Device
- */
-static GraphicDevice ctfb;
-
-void *video_hw_init(void)
-{
-       struct fb_info *info;
-
-       if (mpc8610hpcd_diu_init() < 0)
-               return NULL;
-
-       /* fill in Graphic device struct */
-       sprintf(ctfb.modeIdent, "%ix%ix%i %ikHz %iHz", xres, yres, 32, 64, 60);
-
-       ctfb.frameAdrs = (unsigned int)fsl_fb_open(&info);
-       ctfb.winSizeX = xres;
-       ctfb.winSizeY = yres;
-       ctfb.plnSizeX = ctfb.winSizeX;
-       ctfb.plnSizeY = ctfb.winSizeY;
-
-       ctfb.gdfBytesPP = 4;
-       ctfb.gdfIndex = GDF_32BIT_X888RGB;
-
-       ctfb.isaBase = 0;
-       ctfb.pciBase = 0;
-       ctfb.memSize = info->screen_size;
-
-       /* Cursor Start Address */
-       ctfb.dprBase = 0;
-       ctfb.vprBase = 0;
-       ctfb.cprBase = 0;
-
-       return &ctfb;
+       return fsl_diu_init(*xres, pixel_format, gamma_fix);
 }
-
-#endif /* defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) */
-
-#endif /* CONFIG_FSL_DIU_FB */
index e3abeb8ef1e732f357e9846acc97d6e9bed1d5fd..e8714e3a796063dc0d093bc5e82845c31f659d41 100644 (file)
@@ -237,9 +237,6 @@ int misc_init_r(void)
 #endif
 
 #ifdef CONFIG_FSL_DIU_FB
-# if   !(defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE))
-       mpc5121_diu_init();
-#endif
 #if defined(CONFIG_SERIAL_MULTI)
        set_lcd_brightness(0);
 #endif
similarity index 97%
rename from board/freescale/common/fsl_diu_fb.h
rename to include/fsl_diu_fb.h
index 3a5fc9ff821dcd1c82e049c84293946a61bd830d..87443e10c26bf835ae29175a4145eafb0edd00bb 100644 (file)
@@ -57,3 +57,4 @@ struct fb_info {
 
 extern char *fsl_fb_open(struct fb_info **info);
 int fsl_diu_init(int xres, unsigned int pixel_format, int gamma_fix);
+int platform_diu_init(unsigned int *xres, unsigned int *yres);