blob: 94fb1ebf8f8604c4f1d7fc5fd3ae7183451d3d98 [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
York Suna8778802007-10-29 13:58:39 -050032#include "../common/fsl_diu_fb.h"
33
York Sun070ba562007-10-31 14:59:04 -050034#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
Jean-Christophe PLAGNIOL-VILLARD52cb4d42009-05-16 12:14:54 +020035#include <stdio_dev.h>
York Sun070ba562007-10-31 14:59:04 -050036#include <video_fb.h>
37#endif
York Suna8778802007-10-29 13:58:39 -050038
39extern unsigned int FSL_Logo_BMP[];
40
York Sun070ba562007-10-31 14:59:04 -050041static int xres, yres;
42
York Sun3b80c5f2008-05-05 10:19:59 -050043void diu_set_pixel_clock(unsigned int pixclock)
44{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020045 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
York Sun3b80c5f2008-05-05 10:19:59 -050046 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 /* 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);
62}
York Suna8778802007-10-29 13:58:39 -050063
64void mpc8610hpcd_diu_init(void)
65{
66 char *monitor_port;
York Sun070ba562007-10-31 14:59:04 -050067 int gamma_fix;
York Suna8778802007-10-29 13:58:39 -050068 unsigned int pixel_format;
69 unsigned char tmp_val;
York Sun070ba562007-10-31 14:59:04 -050070 unsigned char pixis_arch;
Kumar Gala048e7ef2009-07-22 10:12:39 -050071 u8 *pixis_base = (u8 *)PIXIS_BASE;
York Suna8778802007-10-29 13:58:39 -050072
Kumar Gala048e7ef2009-07-22 10:12:39 -050073 tmp_val = in_8(pixis_base + PIXIS_BRDCFG0);
74 pixis_arch = in_8(pixis_base + PIXIS_VER);
York Suna8778802007-10-29 13:58:39 -050075
York Sun070ba562007-10-31 14:59:04 -050076 monitor_port = getenv("monitor");
York Suna8778802007-10-29 13:58:39 -050077 if (!strncmp(monitor_port, "0", 1)) { /* 0 - DVI */
78 xres = 1280;
York Sun070ba562007-10-31 14:59:04 -050079 yres = 1024;
80 if (pixis_arch == 0x01)
81 pixel_format = 0x88882317;
82 else
83 pixel_format = 0x88883316;
York Suna8778802007-10-29 13:58:39 -050084 gamma_fix = 0;
Kumar Gala048e7ef2009-07-22 10:12:39 -050085 out_8(pixis_base + PIXIS_BRDCFG0, tmp_val | 0x08);
York Suna8778802007-10-29 13:58:39 -050086
87 } else if (!strncmp(monitor_port, "1", 1)) { /* 1 - Single link LVDS */
88 xres = 1024;
York Sun070ba562007-10-31 14:59:04 -050089 yres = 768;
York Suna8778802007-10-29 13:58:39 -050090 pixel_format = 0x88883316;
91 gamma_fix = 0;
Kumar Gala048e7ef2009-07-22 10:12:39 -050092 out_8(pixis_base + PIXIS_BRDCFG0, (tmp_val & 0xf7) | 0x10);
York Suna8778802007-10-29 13:58:39 -050093
94 } else if (!strncmp(monitor_port, "2", 1)) { /* 2 - Double link LVDS */
95 xres = 1280;
York Sun070ba562007-10-31 14:59:04 -050096 yres = 1024;
York Suna8778802007-10-29 13:58:39 -050097 pixel_format = 0x88883316;
98 gamma_fix = 1;
Kumar Gala048e7ef2009-07-22 10:12:39 -050099 out_8(pixis_base + PIXIS_BRDCFG0, tmp_val & 0xe7);
York Suna8778802007-10-29 13:58:39 -0500100
101 } else { /* DVI */
102 xres = 1280;
York Sun070ba562007-10-31 14:59:04 -0500103 yres = 1024;
York Suna8778802007-10-29 13:58:39 -0500104 pixel_format = 0x88882317;
105 gamma_fix = 0;
Kumar Gala048e7ef2009-07-22 10:12:39 -0500106 out_8(pixis_base + PIXIS_BRDCFG0, tmp_val | 0x08);
York Suna8778802007-10-29 13:58:39 -0500107 }
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) {
Peter Tyser62c3ae72009-01-27 18:03:10 -0600119 cmd_usage(cmdtp);
York Suna8778802007-10-29 13:58:39 -0500120 return 1;
121 }
122
123 if (!strncmp(argv[1],"init",4)) {
York Sun070ba562007-10-31 14:59:04 -0500124#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
125 fsl_diu_clear_screen();
126 drv_video_init();
127#else
York Suna8778802007-10-29 13:58:39 -0500128 mpc8610hpcd_diu_init();
York Sun070ba562007-10-31 14:59:04 -0500129#endif
York Suna8778802007-10-29 13:58:39 -0500130 } 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(
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200140 diufb, CONFIG_SYS_MAXARGS, 1, mpc8610diu_init_show_bmp,
Peter Tyser2fb26042009-01-27 18:03:12 -0600141 "Init or Display BMP file",
York Suna8778802007-10-29 13:58:39 -0500142 "init\n - initialize DIU\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +0200143 "addr\n - display bmp at address 'addr'"
144);
York Sun070ba562007-10-31 14:59:04 -0500145
146
147#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
148
149/*
150 * The Graphic Device
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 /* fill in Graphic device struct */
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 /* Cursor Start Address */
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, /* color number */
187 unsigned char r, /* red */
188 unsigned char g, /* green */
189 unsigned char b /* blue */
190 )
191{
192 return;
193}
194
195#endif /* defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE) */
196
York Suna8778802007-10-29 13:58:39 -0500197#endif /* CONFIG_FSL_DIU_FB */