to make u-boot work for fat32 filesystem
[jz_uboot.git] / drivers / sm501.c
blob23db02cd10a83374b077de8eb2a9aa0b87af3df5
1 /*
2 * (C) Copyright 2002
3 * Stäubli Faverges - <www.staubli.com>
4 * Pierre AUBERT p.aubert@staubli.com
6 * (C) Copyright 2005
7 * Martin Krause TQ-Systems GmbH martin.krause@tqs.de
9 * See file CREDITS for list of people who contributed to this
10 * project.
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 * MA 02111-1307 USA
29 * Basic video support for SMI SM501 "Voyager" graphic controller
32 #include <common.h>
34 #ifdef CONFIG_VIDEO_SM501
36 #include <video_fb.h>
37 #include <sm501.h>
39 #define read8(ptrReg) \
40 *(volatile unsigned char *)(sm501.isaBase + ptrReg)
42 #define write8(ptrReg,value) \
43 *(volatile unsigned char *)(sm501.isaBase + ptrReg) = value
45 #define read16(ptrReg) \
46 (*(volatile unsigned short *)(sm501.isaBase + ptrReg))
48 #define write16(ptrReg,value) \
49 (*(volatile unsigned short *)(sm501.isaBase + ptrReg) = value)
51 #define read32(ptrReg) \
52 (*(volatile unsigned int *)(sm501.isaBase + ptrReg))
54 #define write32(ptrReg, value) \
55 (*(volatile unsigned int *)(sm501.isaBase + ptrReg) = value)
57 GraphicDevice sm501;
59 /*-----------------------------------------------------------------------------
60 * SmiSetRegs --
61 *-----------------------------------------------------------------------------
63 static void SmiSetRegs (void)
66 * The content of the chipset register depends on the board (clocks,
67 * ...)
69 const SMI_REGS *preg = board_get_regs ();
70 while (preg->Index) {
71 write32 (preg->Index, preg->Value);
73 * Insert a delay between
75 udelay (1000);
76 preg ++;
80 /*-----------------------------------------------------------------------------
81 * video_hw_init --
82 *-----------------------------------------------------------------------------
84 void *video_hw_init (void)
86 unsigned int *vm, i;
88 memset (&sm501, 0, sizeof (GraphicDevice));
91 * Initialization of the access to the graphic chipset Retreive base
92 * address of the chipset (see board/RPXClassic/eccx.c)
94 if ((sm501.isaBase = board_video_init ()) == 0) {
95 return (NULL);
98 if ((sm501.frameAdrs = board_video_get_fb ()) == 0) {
99 return (NULL);
102 sm501.winSizeX = board_get_width ();
103 sm501.winSizeY = board_get_height ();
105 #if defined(CONFIG_VIDEO_SM501_8BPP)
106 sm501.gdfIndex = GDF__8BIT_INDEX;
107 sm501.gdfBytesPP = 1;
109 #elif defined(CONFIG_VIDEO_SM501_16BPP)
110 sm501.gdfIndex = GDF_16BIT_565RGB;
111 sm501.gdfBytesPP = 2;
113 #elif defined(CONFIG_VIDEO_SM501_32BPP)
114 sm501.gdfIndex = GDF_32BIT_X888RGB;
115 sm501.gdfBytesPP = 4;
116 #else
117 #error Unsupported SM501 BPP
118 #endif
120 sm501.memSize = sm501.winSizeX * sm501.winSizeY * sm501.gdfBytesPP;
122 /* Load Smi registers */
123 SmiSetRegs ();
125 /* (see board/RPXClassic/RPXClassic.c) */
126 board_validate_screen (sm501.isaBase);
128 /* Clear video memory */
129 i = sm501.memSize/4;
130 vm = (unsigned int *)sm501.frameAdrs;
131 while(i--)
132 *vm++ = 0;
134 return (&sm501);
137 /*-----------------------------------------------------------------------------
138 * video_set_lut --
139 *-----------------------------------------------------------------------------
141 void video_set_lut (
142 unsigned int index, /* color number */
143 unsigned char r, /* red */
144 unsigned char g, /* green */
145 unsigned char b /* blue */
150 #endif /* CONFIG_VIDEO_SM501 */