]>
git.ipfire.org Git - people/ms/u-boot.git/blob - arch/ppc/cpu/mpc512x/diu.c
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 #ifdef CONFIG_FSL_DIU_LOGO_BMP
38 extern unsigned int FSL_Logo_BMP
[];
40 #define FSL_Logo_BMP NULL
43 static int xres
, yres
;
45 void diu_set_pixel_clock(unsigned int pixclock
)
47 volatile immap_t
*immap
= (immap_t
*)CONFIG_SYS_IMMR
;
48 volatile clk512x_t
*clk
= &immap
->clk
;
49 volatile unsigned int *clkdvdr
= &clk
->scfr
[0];
50 unsigned long speed_ccb
, temp
, pixval
;
52 speed_ccb
= get_bus_freq(0) * 4;
53 temp
= 1000000000/pixclock
;
55 pixval
= speed_ccb
/ temp
;
56 debug("DIU pixval = %lu\n", pixval
);
58 /* Modify PXCLK in GUTS CLKDVDR */
59 debug("DIU: Current value of CLKDVDR = 0x%08x\n", in_be32(clkdvdr
));
60 temp
= in_be32(clkdvdr
) & 0xFFFFFF00;
61 out_be32(clkdvdr
, temp
| (pixval
& 0xFF));
62 debug("DIU: Modified value of CLKDVDR = 0x%08x\n", in_be32(clkdvdr
));
65 char *valid_bmp(char *addr
)
69 h_addr
= simple_strtoul(addr
, NULL
, 16);
70 if (h_addr
< CONFIG_SYS_FLASH_BASE
||
71 h_addr
>= (CONFIG_SYS_FLASH_BASE
+ CONFIG_SYS_FLASH_SIZE
- 1)) {
72 printf("bmp addr %lx is not a valid flash address\n", h_addr
);
74 } else if ((*(char *)(h_addr
) != 'B') || (*(char *)(h_addr
+1) != 'M')) {
75 printf("bmp addr is not a bmp\n");
78 return (char *)h_addr
;
81 int mpc5121_diu_init(void)
83 unsigned int pixel_format
;
89 pixel_format
= 0x88883316;
91 debug("mpc5121_diu_init\n");
92 bmp_env
= getenv("diu_bmp_addr");
94 bmp
= valid_bmp(bmp_env
);
97 bmp
= (char *)FSL_Logo_BMP
;
98 return fsl_diu_init(xres
, pixel_format
, 0, (unsigned char *)bmp
);
101 int mpc5121diu_init_show_bmp(cmd_tbl_t
*cmdtp
,
102 int flag
, int argc
, char *argv
[])
111 if (!strncmp(argv
[1], "init", 4)) {
112 #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
113 fsl_diu_clear_screen();
116 return mpc5121_diu_init();
119 addr
= simple_strtoul(argv
[1], NULL
, 16);
120 fsl_diu_clear_screen();
121 fsl_diu_display_bmp((unsigned char *)addr
, 0, 0, 0);
128 diufb
, CONFIG_SYS_MAXARGS
, 1, mpc5121diu_init_show_bmp
,
129 "Init or Display BMP file",
130 "init\n - initialize DIU\n"
131 "addr\n - display bmp at address 'addr'"
135 #if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
141 void *video_hw_init(void)
143 GraphicDevice
*pGD
= (GraphicDevice
*) &ctfb
;
144 struct fb_info
*info
;
146 if (mpc5121_diu_init() < 0)
149 /* fill in Graphic device struct */
150 sprintf(pGD
->modeIdent
, "%dx%dx%d %dkHz %dHz",
151 xres
, yres
, 32, 64, 60);
153 pGD
->frameAdrs
= (unsigned int)fsl_fb_open(&info
);
154 pGD
->winSizeX
= xres
;
155 pGD
->winSizeY
= yres
- info
->logo_height
;
156 pGD
->plnSizeX
= pGD
->winSizeX
;
157 pGD
->plnSizeY
= pGD
->winSizeY
;
160 pGD
->gdfIndex
= GDF_32BIT_X888RGB
;
164 pGD
->memSize
= info
->screen_size
- info
->logo_size
;
166 /* Cursor Start Address */
177 * @index: color number
183 (unsigned int index
, unsigned char r
, unsigned char g
, unsigned char b
)
188 #endif /* defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) */