2 * Copyright 2008 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 "../freescale/common/pixis.h"
33 #include "../freescale/common/fsl_diu_fb.h"
35 #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
40 #ifdef CONFIG_FSL_DIU_LOGO_BMP
41 extern unsigned int FSL_Logo_BMP[];
43 #define FSL_Logo_BMP NULL
46 static int xres, yres;
48 void diu_set_pixel_clock(unsigned int pixclock)
50 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
51 volatile clk512x_t *clk = &immap->clk;
52 volatile unsigned int *clkdvdr = &clk->scfr[0];
53 unsigned long speed_ccb, temp, pixval;
55 speed_ccb = get_bus_freq(0) * 4;
56 temp = 1000000000/pixclock;
58 pixval = speed_ccb / temp;
59 debug("DIU pixval = %lu\n", pixval);
61 /* Modify PXCLK in GUTS CLKDVDR */
62 debug("DIU: Current value of CLKDVDR = 0x%08x\n", *clkdvdr);
63 temp = *clkdvdr & 0xFFFFFF00;
64 *clkdvdr = temp | (pixval & 0xFF);
65 debug("DIU: Modified value of CLKDVDR = 0x%08x\n", *clkdvdr);
68 char *valid_bmp(char *addr)
72 h_addr = simple_strtoul(addr, NULL, 16);
73 if (h_addr < CONFIG_SYS_FLASH_BASE ||
74 h_addr >= (CONFIG_SYS_FLASH_BASE + CONFIG_SYS_FLASH_SIZE - 1)) {
75 printf("bmp addr %lx is not a valid flash address\n", h_addr);
77 } else if ((*(char *)(h_addr) != 'B') || (*(char *)(h_addr+1) != 'M')) {
78 printf("bmp addr is not a bmp\n");
81 return (char *)h_addr;
84 int ads5121_diu_init(void)
86 unsigned int pixel_format;
92 pixel_format = 0x88883316;
94 debug("ads5121_diu_init\n");
95 bmp_env = getenv("diu_bmp_addr");
97 bmp = valid_bmp(bmp_env);
101 return fsl_diu_init(xres, pixel_format, 0, (unsigned char *)bmp);
104 int ads5121diu_init_show_bmp(cmd_tbl_t *cmdtp,
105 int flag, int argc, char *argv[])
114 if (!strncmp(argv[1], "init", 4)) {
115 #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
116 fsl_diu_clear_screen();
119 return ads5121_diu_init();
122 addr = simple_strtoul(argv[1], NULL, 16);
123 fsl_diu_clear_screen();
124 fsl_diu_display_bmp((unsigned char *)addr, 0, 0, 0);
131 diufb, CONFIG_SYS_MAXARGS, 1, ads5121diu_init_show_bmp,
132 "Init or Display BMP file",
133 "init\n - initialize DIU\n"
134 "addr\n - display bmp at address 'addr'"
138 #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
144 void *video_hw_init(void)
146 GraphicDevice *pGD = (GraphicDevice *) &ctfb;
147 struct fb_info *info;
149 if (ads5121_diu_init() < 0)
152 /* fill in Graphic device struct */
153 sprintf(pGD->modeIdent, "%dx%dx%d %ldkHz %ldHz",
154 xres, yres, 32, 64, 60);
156 pGD->frameAdrs = (unsigned int)fsl_fb_open(&info);
157 pGD->winSizeX = xres;
158 pGD->winSizeY = yres - info->logo_height;
159 pGD->plnSizeX = pGD->winSizeX;
160 pGD->plnSizeY = pGD->winSizeY;
163 pGD->gdfIndex = GDF_32BIT_X888RGB;
167 pGD->memSize = info->screen_size - info->logo_size;
169 /* Cursor Start Address */
180 * @index: color number
186 (unsigned int index, unsigned char r, unsigned char g, unsigned char b)
191 #endif /* defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) */
193 #endif /* CONFIG_FSL_DIU_FB */