1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#include <common.h>
27#include <command.h>
28#include <asm/io.h>
29
30#ifdef CONFIG_FSL_DIU_FB
31
32#include "../common/fsl_diu_fb.h"
33
34#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
35#include <stdio_dev.h>
36#include <video_fb.h>
37#endif
38
39extern unsigned int FSL_Logo_BMP[];
40
41static int xres, yres;
42
43void diu_set_pixel_clock(unsigned int pixclock)
44{
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;
49
50 speed_ccb = get_bus_freq(0);
51 temp = 1000000000/pixclock;
52 temp *= 1000;
53 pixval = speed_ccb / temp;
54 debug("DIU pixval = %lu\n", pixval);
55
56
57 debug("DIU: Current value of CLKDVDR = 0x%08x\n", *guts_clkdvdr);
58 temp = *guts_clkdvdr & 0x2000FFFF;
59 *guts_clkdvdr = temp;
60 *guts_clkdvdr = temp | 0x80000000 | ((pixval & 0x1F) << 16);
61 debug("DIU: Modified value of CLKDVDR = 0x%08x\n", *guts_clkdvdr);
62}
63
64void mpc8610hpcd_diu_init(void)
65{
66 char *monitor_port;
67 int gamma_fix;
68 unsigned int pixel_format;
69 unsigned char tmp_val;
70 unsigned char pixis_arch;
71 u8 *pixis_base = (u8 *)PIXIS_BASE;
72
73 tmp_val = in_8(pixis_base + PIXIS_BRDCFG0);
74 pixis_arch = in_8(pixis_base + PIXIS_VER);
75
76 monitor_port = getenv("monitor");
77 if (!strncmp(monitor_port, "0", 1)) {
78 xres = 1280;
79 yres = 1024;
80 if (pixis_arch == 0x01)
81 pixel_format = 0x88882317;
82 else
83 pixel_format = 0x88883316;
84 gamma_fix = 0;
85 out_8(pixis_base + PIXIS_BRDCFG0, tmp_val | 0x08);
86
87 } else if (!strncmp(monitor_port, "1", 1)) {
88 xres = 1024;
89 yres = 768;
90 pixel_format = 0x88883316;
91 gamma_fix = 0;
92 out_8(pixis_base + PIXIS_BRDCFG0, (tmp_val & 0xf7) | 0x10);
93
94 } else if (!strncmp(monitor_port, "2", 1)) {
95 xres = 1280;
96 yres = 1024;
97 pixel_format = 0x88883316;
98 gamma_fix = 1;
99 out_8(pixis_base + PIXIS_BRDCFG0, tmp_val & 0xe7);
100
101 } else {
102 xres = 1280;
103 yres = 1024;
104 pixel_format = 0x88882317;
105 gamma_fix = 0;
106 out_8(pixis_base + PIXIS_BRDCFG0, tmp_val | 0x08);
107 }
108
109 fsl_diu_init(xres, pixel_format, gamma_fix,
110 (unsigned char *)FSL_Logo_BMP);
111}
112
113int mpc8610diu_init_show_bmp(cmd_tbl_t *cmdtp,
114 int flag, int argc, char *argv[])
115{
116 unsigned int addr;
117
118 if (argc < 2) {
119 cmd_usage(cmdtp);
120 return 1;
121 }
122
123 if (!strncmp(argv[1],"init",4)) {
124#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
125 fsl_diu_clear_screen();
126 drv_video_init();
127#else
128 mpc8610hpcd_diu_init();
129#endif
130 } else {
131 addr = simple_strtoul(argv[1], NULL, 16);
132 fsl_diu_clear_screen();
133 fsl_diu_display_bmp((unsigned char *)addr, 0, 0, 0);
134 }
135
136 return 0;
137}
138
139U_BOOT_CMD(
140 diufb, CONFIG_SYS_MAXARGS, 1, mpc8610diu_init_show_bmp,
141 "Init or Display BMP file",
142 "init\n - initialize DIU\n"
143 "addr\n - display bmp at address 'addr'"
144);
145
146
147#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
148
149
150
151
152GraphicDevice ctfb;
153void *video_hw_init(void)
154{
155 GraphicDevice *pGD = (GraphicDevice *) &ctfb;
156 struct fb_info *info;
157
158 mpc8610hpcd_diu_init();
159
160
161 sprintf(pGD->modeIdent,
162 "%dx%dx%d %ldkHz %ldHz",
163 xres, yres, 32, 64, 60);
164
165 pGD->frameAdrs = (unsigned int)fsl_fb_open(&info);
166 pGD->winSizeX = xres;
167 pGD->winSizeY = yres - info->logo_height;
168 pGD->plnSizeX = pGD->winSizeX;
169 pGD->plnSizeY = pGD->winSizeY;
170
171 pGD->gdfBytesPP = 4;
172 pGD->gdfIndex = GDF_32BIT_X888RGB;
173
174 pGD->isaBase = 0;
175 pGD->pciBase = 0;
176 pGD->memSize = info->screen_size - info->logo_size;
177
178
179 pGD->dprBase = 0;
180 pGD->vprBase = 0;
181 pGD->cprBase = 0;
182
183 return (void *)pGD;
184}
185
186void video_set_lut (unsigned int index,
187 unsigned char r,
188 unsigned char g,
189 unsigned char b
190 )
191{
192 return;
193}
194
195#endif
196
197#endif
198