blob: b70637f940280aa1803de45dec230e793113195f [file] [log] [blame]
York Suna8778802007-10-29 13:58:39 -05001/*
2 * Copyright 2007 Freescale Semiconductor, Inc.
3 * York Sun <yorksun@freescale.com>
4 *
5 * FSL DIU Framebuffer driver
6 *
7 * See file CREDITS for list of people who contributed to this
8 * project.
9 *
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.
14 *
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.
19 *
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,
23 * MA 02111-1307 USA
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/pixis.h"
33#include "../common/fsl_diu_fb.h"
34
York Sun070ba562007-10-31 14:59:04 -050035#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
36#include <devices.h>
37#include <video_fb.h>
38#endif
York Suna8778802007-10-29 13:58:39 -050039
40extern unsigned int FSL_Logo_BMP[];
41
York Sun070ba562007-10-31 14:59:04 -050042static int xres, yres;
43
York Suna8778802007-10-29 13:58:39 -050044
45void mpc8610hpcd_diu_init(void)
46{
47 char *monitor_port;
York Sun070ba562007-10-31 14:59:04 -050048 int gamma_fix;
York Suna8778802007-10-29 13:58:39 -050049 unsigned int pixel_format;
50 unsigned char tmp_val;
York Sun070ba562007-10-31 14:59:04 -050051 unsigned char pixis_arch;
York Suna8778802007-10-29 13:58:39 -050052
53 tmp_val = in8(PIXIS_BASE + PIXIS_BRDCFG0);
York Sun070ba562007-10-31 14:59:04 -050054 pixis_arch = in8(PIXIS_BASE + PIXIS_VER);
York Suna8778802007-10-29 13:58:39 -050055
York Sun070ba562007-10-31 14:59:04 -050056 monitor_port = getenv("monitor");
York Suna8778802007-10-29 13:58:39 -050057 if (!strncmp(monitor_port, "0", 1)) { /* 0 - DVI */
58 xres = 1280;
York Sun070ba562007-10-31 14:59:04 -050059 yres = 1024;
60 if (pixis_arch == 0x01)
61 pixel_format = 0x88882317;
62 else
63 pixel_format = 0x88883316;
York Suna8778802007-10-29 13:58:39 -050064 gamma_fix = 0;
65 out8(PIXIS_BASE + PIXIS_BRDCFG0, tmp_val | 0x08);
66
67 } else if (!strncmp(monitor_port, "1", 1)) { /* 1 - Single link LVDS */
68 xres = 1024;
York Sun070ba562007-10-31 14:59:04 -050069 yres = 768;
York Suna8778802007-10-29 13:58:39 -050070 pixel_format = 0x88883316;
71 gamma_fix = 0;
72 out8(PIXIS_BASE + PIXIS_BRDCFG0, (tmp_val & 0xf7) | 0x10);
73
74 } else if (!strncmp(monitor_port, "2", 1)) { /* 2 - Double link LVDS */
75 xres = 1280;
York Sun070ba562007-10-31 14:59:04 -050076 yres = 1024;
York Suna8778802007-10-29 13:58:39 -050077 pixel_format = 0x88883316;
78 gamma_fix = 1;
79 out8(PIXIS_BASE + PIXIS_BRDCFG0, tmp_val & 0xe7);
80
81 } else { /* DVI */
82 xres = 1280;
York Sun070ba562007-10-31 14:59:04 -050083 yres = 1024;
York Suna8778802007-10-29 13:58:39 -050084 pixel_format = 0x88882317;
85 gamma_fix = 0;
86 out8(PIXIS_BASE + PIXIS_BRDCFG0, tmp_val | 0x08);
87 }
88
89 fsl_diu_init(xres, pixel_format, gamma_fix,
90 (unsigned char *)FSL_Logo_BMP);
91}
92
93int mpc8610diu_init_show_bmp(cmd_tbl_t *cmdtp,
94 int flag, int argc, char *argv[])
95{
96 unsigned int addr;
97
98 if (argc < 2) {
99 printf ("Usage:\n%s\n", cmdtp->usage);
100 return 1;
101 }
102
103 if (!strncmp(argv[1],"init",4)) {
York Sun070ba562007-10-31 14:59:04 -0500104#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
105 fsl_diu_clear_screen();
106 drv_video_init();
107#else
York Suna8778802007-10-29 13:58:39 -0500108 mpc8610hpcd_diu_init();
York Sun070ba562007-10-31 14:59:04 -0500109#endif
York Suna8778802007-10-29 13:58:39 -0500110 } else {
111 addr = simple_strtoul(argv[1], NULL, 16);
112 fsl_diu_clear_screen();
113 fsl_diu_display_bmp((unsigned char *)addr, 0, 0, 0);
114 }
115
116 return 0;
117}
118
119U_BOOT_CMD(
120 diufb, CFG_MAXARGS, 1, mpc8610diu_init_show_bmp,
121 "diufb init | addr - Init or Display BMP file\n",
122 "init\n - initialize DIU\n"
123 "addr\n - display bmp at address 'addr'\n"
124 );
York Sun070ba562007-10-31 14:59:04 -0500125
126
127#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
128
129/*
130 * The Graphic Device
131 */
132GraphicDevice ctfb;
133void *video_hw_init(void)
134{
135 GraphicDevice *pGD = (GraphicDevice *) &ctfb;
136 struct fb_info *info;
137
138 mpc8610hpcd_diu_init();
139
140 /* fill in Graphic device struct */
141 sprintf(pGD->modeIdent,
142 "%dx%dx%d %ldkHz %ldHz",
143 xres, yres, 32, 64, 60);
144
145 pGD->frameAdrs = (unsigned int)fsl_fb_open(&info);
146 pGD->winSizeX = xres;
147 pGD->winSizeY = yres - info->logo_height;
148 pGD->plnSizeX = pGD->winSizeX;
149 pGD->plnSizeY = pGD->winSizeY;
150
151 pGD->gdfBytesPP = 4;
152 pGD->gdfIndex = GDF_32BIT_X888RGB;
153
154 pGD->isaBase = 0;
155 pGD->pciBase = 0;
156 pGD->memSize = info->screen_size - info->logo_size;
157
158 /* Cursor Start Address */
159 pGD->dprBase = 0;
160 pGD->vprBase = 0;
161 pGD->cprBase = 0;
162
163 return (void *)pGD;
164}
165
166void video_set_lut (unsigned int index, /* color number */
167 unsigned char r, /* red */
168 unsigned char g, /* green */
169 unsigned char b /* blue */
170 )
171{
172 return;
173}
174
175#endif /* defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) */
176
York Suna8778802007-10-29 13:58:39 -0500177#endif /* CONFIG_FSL_DIU_FB */