wdenk | a594888 | 2005-03-27 23:41:39 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 |
| 3 | * Stäubli Faverges - <www.staubli.com> |
| 4 | * Pierre AUBERT p.aubert@staubli.com |
| 5 | * |
| 6 | * (C) Copyright 2005 |
| 7 | * Martin Krause TQ-Systems GmbH martin.krause@tqs.de |
| 8 | * |
| 9 | * See file CREDITS for list of people who contributed to this |
| 10 | * project. |
| 11 | * |
| 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. |
| 16 | * |
| 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. |
| 21 | * |
| 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 |
| 26 | */ |
| 27 | |
| 28 | /* |
| 29 | * Basic video support for SMI SM501 "Voyager" graphic controller |
| 30 | */ |
| 31 | |
| 32 | #include <common.h> |
| 33 | |
wdenk | a594888 | 2005-03-27 23:41:39 +0000 | [diff] [blame] | 34 | #include <video_fb.h> |
| 35 | #include <sm501.h> |
| 36 | |
| 37 | #define read8(ptrReg) \ |
| 38 | *(volatile unsigned char *)(sm501.isaBase + ptrReg) |
| 39 | |
| 40 | #define write8(ptrReg,value) \ |
| 41 | *(volatile unsigned char *)(sm501.isaBase + ptrReg) = value |
| 42 | |
| 43 | #define read16(ptrReg) \ |
| 44 | (*(volatile unsigned short *)(sm501.isaBase + ptrReg)) |
| 45 | |
| 46 | #define write16(ptrReg,value) \ |
| 47 | (*(volatile unsigned short *)(sm501.isaBase + ptrReg) = value) |
| 48 | |
| 49 | #define read32(ptrReg) \ |
| 50 | (*(volatile unsigned int *)(sm501.isaBase + ptrReg)) |
| 51 | |
| 52 | #define write32(ptrReg, value) \ |
| 53 | (*(volatile unsigned int *)(sm501.isaBase + ptrReg) = value) |
| 54 | |
| 55 | GraphicDevice sm501; |
| 56 | |
| 57 | /*----------------------------------------------------------------------------- |
| 58 | * SmiSetRegs -- |
| 59 | *----------------------------------------------------------------------------- |
| 60 | */ |
| 61 | static void SmiSetRegs (void) |
| 62 | { |
| 63 | /* |
| 64 | * The content of the chipset register depends on the board (clocks, |
| 65 | * ...) |
| 66 | */ |
| 67 | const SMI_REGS *preg = board_get_regs (); |
| 68 | while (preg->Index) { |
| 69 | write32 (preg->Index, preg->Value); |
| 70 | /* |
| 71 | * Insert a delay between |
| 72 | */ |
| 73 | udelay (1000); |
| 74 | preg ++; |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | /*----------------------------------------------------------------------------- |
| 79 | * video_hw_init -- |
| 80 | *----------------------------------------------------------------------------- |
| 81 | */ |
| 82 | void *video_hw_init (void) |
| 83 | { |
| 84 | unsigned int *vm, i; |
| 85 | |
| 86 | memset (&sm501, 0, sizeof (GraphicDevice)); |
| 87 | |
| 88 | /* |
| 89 | * Initialization of the access to the graphic chipset Retreive base |
| 90 | * address of the chipset (see board/RPXClassic/eccx.c) |
| 91 | */ |
| 92 | if ((sm501.isaBase = board_video_init ()) == 0) { |
| 93 | return (NULL); |
| 94 | } |
| 95 | |
| 96 | if ((sm501.frameAdrs = board_video_get_fb ()) == 0) { |
| 97 | return (NULL); |
| 98 | } |
| 99 | |
| 100 | sm501.winSizeX = board_get_width (); |
| 101 | sm501.winSizeY = board_get_height (); |
| 102 | |
| 103 | #if defined(CONFIG_VIDEO_SM501_8BPP) |
| 104 | sm501.gdfIndex = GDF__8BIT_INDEX; |
| 105 | sm501.gdfBytesPP = 1; |
| 106 | |
| 107 | #elif defined(CONFIG_VIDEO_SM501_16BPP) |
| 108 | sm501.gdfIndex = GDF_16BIT_565RGB; |
| 109 | sm501.gdfBytesPP = 2; |
| 110 | |
| 111 | #elif defined(CONFIG_VIDEO_SM501_32BPP) |
| 112 | sm501.gdfIndex = GDF_32BIT_X888RGB; |
| 113 | sm501.gdfBytesPP = 4; |
| 114 | #else |
| 115 | #error Unsupported SM501 BPP |
| 116 | #endif |
| 117 | |
| 118 | sm501.memSize = sm501.winSizeX * sm501.winSizeY * sm501.gdfBytesPP; |
| 119 | |
| 120 | /* Load Smi registers */ |
| 121 | SmiSetRegs (); |
| 122 | |
| 123 | /* (see board/RPXClassic/RPXClassic.c) */ |
| 124 | board_validate_screen (sm501.isaBase); |
| 125 | |
| 126 | /* Clear video memory */ |
| 127 | i = sm501.memSize/4; |
| 128 | vm = (unsigned int *)sm501.frameAdrs; |
| 129 | while(i--) |
| 130 | *vm++ = 0; |
| 131 | |
| 132 | return (&sm501); |
| 133 | } |
| 134 | |
| 135 | /*----------------------------------------------------------------------------- |
| 136 | * video_set_lut -- |
| 137 | *----------------------------------------------------------------------------- |
| 138 | */ |
| 139 | void video_set_lut ( |
| 140 | unsigned int index, /* color number */ |
| 141 | unsigned char r, /* red */ |
| 142 | unsigned char g, /* green */ |
| 143 | unsigned char b /* blue */ |
| 144 | ) |
| 145 | { |
| 146 | } |