blob: ecd6cb2396c08883fbd65297cf2d868c621dd088 [file] [log] [blame]
Dirk Eibacha605ea72010-10-21 10:50:05 +02001/*
2 * (C) Copyright 2010
3 * Dirk Eibach, Guntermann & Drunck GmbH, eibach@gdsys.de
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24#include <common.h>
25#include <command.h>
26#include <asm/processor.h>
27#include <asm/io.h>
28#include <asm/ppc4xx-gpio.h>
29
30#include "../common/fpga.h"
31#include "../common/osd.h"
32
33enum {
34 REG_VERSIONS = 0x0002,
35 REG_FPGA_VERSION = 0x0004,
36 REG_FPGA_FEATURES = 0x0006,
37};
38
39enum {
40 UNITTYPE_MAIN_SERVER = 0,
41 UNITTYPE_MAIN_USER = 1,
42 UNITTYPE_VIDEO_SERVER = 2,
43 UNITTYPE_VIDEO_USER = 3,
44};
45
46enum {
47 HWVER_100 = 0,
48 HWVER_104 = 1,
49 HWVER_110 = 2,
50};
51
52enum {
53 COMPRESSION_NONE = 0,
54 COMPRESSION_TYPE1_DELTA,
55};
56
57enum {
58 AUDIO_NONE = 0,
59 AUDIO_TX = 1,
60 AUDIO_RX = 2,
61 AUDIO_RXTX = 3,
62};
63
64enum {
65 SYSCLK_147456 = 0,
66};
67
68enum {
69 RAM_DDR2_32 = 0,
70};
71
72/*
73 * Check Board Identity:
74 */
75int checkboard(void)
76{
77 char *s = getenv("serial#");
78 u16 versions = fpga_get_reg(REG_VERSIONS);
79 u16 fpga_version = fpga_get_reg(REG_FPGA_VERSION);
80 u16 fpga_features = fpga_get_reg(REG_FPGA_FEATURES);
81 unsigned unit_type;
82 unsigned hardware_version;
83 unsigned feature_compression;
84 unsigned feature_osd;
85 unsigned feature_audio;
86 unsigned feature_sysclock;
87 unsigned feature_ramconfig;
88 unsigned feature_carriers;
89 unsigned feature_video_channels;
90
91 unit_type = (versions & 0xf000) >> 12;
92 hardware_version = versions & 0x000f;
93 feature_compression = (fpga_features & 0xe000) >> 13;
94 feature_osd = fpga_features & (1<<11);
95 feature_audio = (fpga_features & 0x0600) >> 9;
96 feature_sysclock = (fpga_features & 0x0180) >> 7;
97 feature_ramconfig = (fpga_features & 0x0060) >> 5;
98 feature_carriers = (fpga_features & 0x000c) >> 2;
99 feature_video_channels = fpga_features & 0x0003;
100
101 printf("Board: ");
102
103 printf("IoCon");
104
105 if (s != NULL) {
106 puts(", serial# ");
107 puts(s);
108 }
109 puts("\n ");
110
111 switch (unit_type) {
112 case UNITTYPE_MAIN_USER:
113 printf("Mainchannel");
114 break;
115
116 case UNITTYPE_VIDEO_USER:
117 printf("Videochannel");
118 break;
119
120 default:
121 printf("UnitType %d(not supported)", unit_type);
122 break;
123 }
124
125 switch (hardware_version) {
126 case HWVER_100:
127 printf(" HW-Ver 1.00\n");
128 break;
129
130 case HWVER_104:
131 printf(" HW-Ver 1.04\n");
132 break;
133
134 case HWVER_110:
135 printf(" HW-Ver 1.10\n");
136 break;
137
138 default:
139 printf(" HW-Ver %d(not supported)\n",
140 hardware_version);
141 break;
142 }
143
144 printf(" FPGA V %d.%02d, features:",
145 fpga_version / 100, fpga_version % 100);
146
147
148 switch (feature_compression) {
149 case COMPRESSION_NONE:
150 printf(" no compression");
151 break;
152
153 case COMPRESSION_TYPE1_DELTA:
154 printf(" type1-deltacompression");
155 break;
156
157 default:
158 printf(" compression %d(not supported)", feature_compression);
159 break;
160 }
161
162 printf(", %sosd", feature_osd ? "" : "no ");
163
164 switch (feature_audio) {
165 case AUDIO_NONE:
166 printf(", no audio");
167 break;
168
169 case AUDIO_TX:
170 printf(", audio tx");
171 break;
172
173 case AUDIO_RX:
174 printf(", audio rx");
175 break;
176
177 case AUDIO_RXTX:
178 printf(", audio rx+tx");
179 break;
180
181 default:
182 printf(", audio %d(not supported)", feature_audio);
183 break;
184 }
185
186 puts(",\n ");
187
188 switch (feature_sysclock) {
189 case SYSCLK_147456:
190 printf("clock 147.456 MHz");
191 break;
192
193 default:
194 printf("clock %d(not supported)", feature_sysclock);
195 break;
196 }
197
198 switch (feature_ramconfig) {
199 case RAM_DDR2_32:
200 printf(", RAM 32 bit DDR2");
201 break;
202
203 default:
204 printf(", RAM %d(not supported)", feature_ramconfig);
205 break;
206 }
207
208 printf(", %d carrier(s)", feature_carriers);
209
210 printf(", %d video channel(s)\n", feature_video_channels);
211
212 return 0;
213}
214
215int last_stage_init(void)
216{
217 return osd_probe();
218}
219
220/*
221 * provide access to fpga gpios (for I2C bitbang)
222 */
223void fpga_gpio_set(int pin)
224{
225 out_le16((void *)(CONFIG_SYS_FPGA_BASE + 0x18), pin);
226}
227
228void fpga_gpio_clear(int pin)
229{
230 out_le16((void *)(CONFIG_SYS_FPGA_BASE + 0x16), pin);
231}
232
233int fpga_gpio_get(int pin)
234{
235 return in_le16((void *)(CONFIG_SYS_FPGA_BASE + 0x14)) & pin;
236}