2 * Copyright 2007 Freescale Semiconductor, Inc.
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 extern unsigned int FSL_Logo_BMP[];
41 static int xres, yres;
43 void diu_set_pixel_clock(unsigned int pixclock)
45 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
46 volatile ccsr_gur_t *gur = &immap->im_gur;
47 volatile unsigned int *guts_clkdvdr = &gur->clkdvdr;
48 unsigned long speed_ccb, temp, pixval;
50 speed_ccb = get_bus_freq(0);
51 temp = 1000000000/pixclock;
53 pixval = speed_ccb / temp;
54 debug("DIU pixval = %lu\n", pixval);
56 /* Modify PXCLK in GUTS CLKDVDR */
57 debug("DIU: Current value of CLKDVDR = 0x%08x\n", *guts_clkdvdr);
58 temp = *guts_clkdvdr & 0x2000FFFF;
59 *guts_clkdvdr = temp; /* turn off clock */
60 *guts_clkdvdr = temp | 0x80000000 | ((pixval & 0x1F) << 16);
61 debug("DIU: Modified value of CLKDVDR = 0x%08x\n", *guts_clkdvdr);
64 void mpc8610hpcd_diu_init(void)
68 unsigned int pixel_format;
69 unsigned char tmp_val;
70 unsigned char pixis_arch;
71 u8 *pixis_base = (u8 *)PIXIS_BASE;
73 tmp_val = in_8(pixis_base + PIXIS_BRDCFG0);
74 pixis_arch = in_8(pixis_base + PIXIS_VER);
76 monitor_port = getenv("monitor");
77 if (!strncmp(monitor_port, "0", 1)) { /* 0 - DVI */
80 if (pixis_arch == 0x01)
81 pixel_format = 0x88882317;
83 pixel_format = 0x88883316;
85 out_8(pixis_base + PIXIS_BRDCFG0, tmp_val | 0x08);
87 } else if (!strncmp(monitor_port, "1", 1)) { /* 1 - Single link LVDS */
90 pixel_format = 0x88883316;
92 out_8(pixis_base + PIXIS_BRDCFG0, (tmp_val & 0xf7) | 0x10);
94 } else if (!strncmp(monitor_port, "2", 1)) { /* 2 - Double link LVDS */
97 pixel_format = 0x88883316;
99 out_8(pixis_base + PIXIS_BRDCFG0, tmp_val & 0xe7);
104 pixel_format = 0x88882317;
106 out_8(pixis_base + PIXIS_BRDCFG0, tmp_val | 0x08);
109 fsl_diu_init(xres, pixel_format, gamma_fix,
110 (unsigned char *)FSL_Logo_BMP);
113 int mpc8610diu_init_show_bmp(cmd_tbl_t *cmdtp,
114 int flag, int argc, char * const argv[])
119 return cmd_usage(cmdtp);
121 if (!strncmp(argv[1],"init",4)) {
122 #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
123 fsl_diu_clear_screen();
126 mpc8610hpcd_diu_init();
129 addr = simple_strtoul(argv[1], NULL, 16);
130 fsl_diu_clear_screen();
131 fsl_diu_display_bmp((unsigned char *)addr, 0, 0, 0);
138 diufb, CONFIG_SYS_MAXARGS, 1, mpc8610diu_init_show_bmp,
139 "Init or Display BMP file",
140 "init\n - initialize DIU\n"
141 "addr\n - display bmp at address 'addr'"
145 #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
151 void *video_hw_init(void)
153 GraphicDevice *pGD = (GraphicDevice *) &ctfb;
154 struct fb_info *info;
156 mpc8610hpcd_diu_init();
158 /* fill in Graphic device struct */
159 sprintf(pGD->modeIdent,
160 "%dx%dx%d %ldkHz %ldHz",
161 xres, yres, 32, 64, 60);
163 pGD->frameAdrs = (unsigned int)fsl_fb_open(&info);
164 pGD->winSizeX = xres;
165 pGD->winSizeY = yres - info->logo_height;
166 pGD->plnSizeX = pGD->winSizeX;
167 pGD->plnSizeY = pGD->winSizeY;
170 pGD->gdfIndex = GDF_32BIT_X888RGB;
174 pGD->memSize = info->screen_size - info->logo_size;
176 /* Cursor Start Address */
184 #endif /* defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) */
186 #endif /* CONFIG_FSL_DIU_FB */