2 * Copyright 2007 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 #ifdef CONFIG_FSL_DIU_FB
32 #include "../common/fsl_diu_fb.h"
34 #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
35 #include <stdio_dev.h>
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 ccsr_gur_t *gur = &immap->im_gur;
45 volatile unsigned int *guts_clkdvdr = &gur->clkdvdr;
46 unsigned long speed_ccb, temp, pixval;
48 speed_ccb = get_bus_freq(0);
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", *guts_clkdvdr);
56 temp = *guts_clkdvdr & 0x2000FFFF;
57 *guts_clkdvdr = temp; /* turn off clock */
58 *guts_clkdvdr = temp | 0x80000000 | ((pixval & 0x1F) << 16);
59 debug("DIU: Modified value of CLKDVDR = 0x%08x\n", *guts_clkdvdr);
62 int mpc8610hpcd_diu_init(void)
66 unsigned int pixel_format;
67 unsigned char tmp_val;
68 unsigned char pixis_arch;
69 u8 *pixis_base = (u8 *)PIXIS_BASE;
71 tmp_val = in_8(pixis_base + PIXIS_BRDCFG0);
72 pixis_arch = in_8(pixis_base + PIXIS_VER);
74 monitor_port = getenv("monitor");
75 if (!strncmp(monitor_port, "0", 1)) { /* 0 - DVI */
78 if (pixis_arch == 0x01)
79 pixel_format = 0x88882317;
81 pixel_format = 0x88883316;
83 out_8(pixis_base + PIXIS_BRDCFG0, tmp_val | 0x08);
85 } else if (!strncmp(monitor_port, "1", 1)) { /* 1 - Single link LVDS */
88 pixel_format = 0x88883316;
90 out_8(pixis_base + PIXIS_BRDCFG0, (tmp_val & 0xf7) | 0x10);
92 } else if (!strncmp(monitor_port, "2", 1)) { /* 2 - Double link LVDS */
95 pixel_format = 0x88883316;
97 out_8(pixis_base + PIXIS_BRDCFG0, tmp_val & 0xe7);
102 pixel_format = 0x88882317;
104 out_8(pixis_base + PIXIS_BRDCFG0, tmp_val | 0x08);
107 return fsl_diu_init(xres, pixel_format, gamma_fix);
110 #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
115 static GraphicDevice ctfb;
117 void *video_hw_init(void)
119 struct fb_info *info;
121 if (mpc8610hpcd_diu_init() < 0)
124 /* fill in Graphic device struct */
125 sprintf(ctfb.modeIdent, "%ix%ix%i %ikHz %iHz", xres, yres, 32, 64, 60);
127 ctfb.frameAdrs = (unsigned int)fsl_fb_open(&info);
128 ctfb.winSizeX = xres;
129 ctfb.winSizeY = yres;
130 ctfb.plnSizeX = ctfb.winSizeX;
131 ctfb.plnSizeY = ctfb.winSizeY;
134 ctfb.gdfIndex = GDF_32BIT_X888RGB;
138 ctfb.memSize = info->screen_size;
140 /* Cursor Start Address */
148 #endif /* defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) */
150 #endif /* CONFIG_FSL_DIU_FB */