2 * Copyright 2008 Freescale Semiconductor, Inc.
3 * York Sun <yorksun@freescale.com>
5 * FSL DIU Framebuffer driver
7 * See file CREDITS for list of people who contributed to this
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30 #include "../../../../board/freescale/common/fsl_diu_fb.h"
32 #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
33 #include <stdio_dev.h>
37 DECLARE_GLOBAL_DATA_PTR;
39 static int xres, yres;
41 void diu_set_pixel_clock(unsigned int pixclock)
43 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
44 volatile clk512x_t *clk = &immap->clk;
45 volatile unsigned int *clkdvdr = &clk->scfr[0];
46 unsigned long speed_ccb, temp, pixval;
48 speed_ccb = get_bus_freq(0) * 4;
49 temp = 1000000000/pixclock;
51 pixval = speed_ccb / temp;
52 debug("DIU pixval = %lu\n", pixval);
54 /* Modify PXCLK in GUTS CLKDVDR */
55 debug("DIU: Current value of CLKDVDR = 0x%08x\n", in_be32(clkdvdr));
56 temp = in_be32(clkdvdr) & 0xFFFFFF00;
57 out_be32(clkdvdr, temp | (pixval & 0xFF));
58 debug("DIU: Modified value of CLKDVDR = 0x%08x\n", in_be32(clkdvdr));
61 int mpc5121_diu_init(void)
63 unsigned int pixel_format;
65 #if defined(CONFIG_VIDEO_XRES) & defined(CONFIG_VIDEO_YRES)
66 xres = CONFIG_VIDEO_XRES;
67 yres = CONFIG_VIDEO_YRES;
72 pixel_format = 0x88883316;
74 debug("mpc5121_diu_init\n");
76 return fsl_diu_init(xres, pixel_format, 0);
79 #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
85 void *video_hw_init(void)
87 GraphicDevice *pGD = (GraphicDevice *) &ctfb;
90 if (mpc5121_diu_init() < 0)
93 /* fill in Graphic device struct */
94 sprintf(pGD->modeIdent, "%dx%dx%d %dkHz %dHz",
95 xres, yres, 32, 64, 60);
97 pGD->frameAdrs = (unsigned int)fsl_fb_open(&info);
100 pGD->plnSizeX = pGD->winSizeX;
101 pGD->plnSizeY = pGD->winSizeY;
104 pGD->gdfIndex = GDF_32BIT_X888RGB;
108 pGD->memSize = info->screen_size;
110 /* Cursor Start Address */
118 #endif /* defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) */