blob: 0fc7db2012c9ba52d0ff12d5f10a948999a7b4a7 [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
Dirk Eibach6e9e6c32012-04-26 03:54:22 +000030#include "405ep.h"
Dirk Eibach2da0fc02011-01-21 09:31:21 +010031#include <gdsys_fpga.h>
Dirk Eibacha605ea72010-10-21 10:50:05 +020032
Dirk Eibach2da0fc02011-01-21 09:31:21 +010033#include "../common/osd.h"
Dirk Eibacha605ea72010-10-21 10:50:05 +020034
Dirk Eibach6e9e6c32012-04-26 03:54:22 +000035#define LATCH0_BASE (CONFIG_SYS_LATCH_BASE)
36#define LATCH1_BASE (CONFIG_SYS_LATCH_BASE + 0x100)
37#define LATCH2_BASE (CONFIG_SYS_LATCH_BASE + 0x200)
38
Dirk Eibacha605ea72010-10-21 10:50:05 +020039enum {
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{
Dirk Eibachb19bf832012-04-26 03:54:23 +000077 char *s = getenv("serial#");
78
79 puts("Board: ");
80
81 puts("IoCon");
82
83 if (s != NULL) {
84 puts(", serial# ");
85 puts(s);
86 }
87
88 puts("\n");
89
90 return 0;
91}
92
93static void print_fpga_info(void)
94{
Dirk Eibach0e60aa82012-04-27 10:33:46 +020095 struct ihs_fpga *fpga = (struct ihs_fpga *) CONFIG_SYS_FPGA_BASE(0);
Dirk Eibach2da0fc02011-01-21 09:31:21 +010096 u16 versions = in_le16(&fpga->versions);
97 u16 fpga_version = in_le16(&fpga->fpga_version);
98 u16 fpga_features = in_le16(&fpga->fpga_features);
Dirk Eibacha605ea72010-10-21 10:50:05 +020099 unsigned unit_type;
100 unsigned hardware_version;
101 unsigned feature_compression;
102 unsigned feature_osd;
103 unsigned feature_audio;
104 unsigned feature_sysclock;
105 unsigned feature_ramconfig;
106 unsigned feature_carriers;
107 unsigned feature_video_channels;
108
109 unit_type = (versions & 0xf000) >> 12;
110 hardware_version = versions & 0x000f;
111 feature_compression = (fpga_features & 0xe000) >> 13;
112 feature_osd = fpga_features & (1<<11);
113 feature_audio = (fpga_features & 0x0600) >> 9;
114 feature_sysclock = (fpga_features & 0x0180) >> 7;
115 feature_ramconfig = (fpga_features & 0x0060) >> 5;
116 feature_carriers = (fpga_features & 0x000c) >> 2;
117 feature_video_channels = fpga_features & 0x0003;
118
Dirk Eibacha605ea72010-10-21 10:50:05 +0200119 switch (unit_type) {
120 case UNITTYPE_MAIN_USER:
121 printf("Mainchannel");
122 break;
123
124 case UNITTYPE_VIDEO_USER:
125 printf("Videochannel");
126 break;
127
128 default:
129 printf("UnitType %d(not supported)", unit_type);
130 break;
131 }
132
133 switch (hardware_version) {
134 case HWVER_100:
135 printf(" HW-Ver 1.00\n");
136 break;
137
138 case HWVER_104:
139 printf(" HW-Ver 1.04\n");
140 break;
141
142 case HWVER_110:
143 printf(" HW-Ver 1.10\n");
144 break;
145
146 default:
147 printf(" HW-Ver %d(not supported)\n",
148 hardware_version);
149 break;
150 }
151
152 printf(" FPGA V %d.%02d, features:",
153 fpga_version / 100, fpga_version % 100);
154
155
156 switch (feature_compression) {
157 case COMPRESSION_NONE:
158 printf(" no compression");
159 break;
160
161 case COMPRESSION_TYPE1_DELTA:
162 printf(" type1-deltacompression");
163 break;
164
165 default:
166 printf(" compression %d(not supported)", feature_compression);
167 break;
168 }
169
170 printf(", %sosd", feature_osd ? "" : "no ");
171
172 switch (feature_audio) {
173 case AUDIO_NONE:
174 printf(", no audio");
175 break;
176
177 case AUDIO_TX:
178 printf(", audio tx");
179 break;
180
181 case AUDIO_RX:
182 printf(", audio rx");
183 break;
184
185 case AUDIO_RXTX:
186 printf(", audio rx+tx");
187 break;
188
189 default:
190 printf(", audio %d(not supported)", feature_audio);
191 break;
192 }
193
194 puts(",\n ");
195
196 switch (feature_sysclock) {
197 case SYSCLK_147456:
198 printf("clock 147.456 MHz");
199 break;
200
201 default:
202 printf("clock %d(not supported)", feature_sysclock);
203 break;
204 }
205
206 switch (feature_ramconfig) {
207 case RAM_DDR2_32:
208 printf(", RAM 32 bit DDR2");
209 break;
210
211 default:
212 printf(", RAM %d(not supported)", feature_ramconfig);
213 break;
214 }
215
216 printf(", %d carrier(s)", feature_carriers);
217
218 printf(", %d video channel(s)\n", feature_video_channels);
Dirk Eibacha605ea72010-10-21 10:50:05 +0200219}
220
221int last_stage_init(void)
222{
Dirk Eibachb19bf832012-04-26 03:54:23 +0000223 print_fpga_info();
224
Dirk Eibach2da0fc02011-01-21 09:31:21 +0100225 return osd_probe(0);
Dirk Eibacha605ea72010-10-21 10:50:05 +0200226}
227
228/*
229 * provide access to fpga gpios (for I2C bitbang)
230 */
231void fpga_gpio_set(int pin)
232{
Dirk Eibach2da0fc02011-01-21 09:31:21 +0100233 out_le16((void *)(CONFIG_SYS_FPGA0_BASE + 0x18), pin);
Dirk Eibacha605ea72010-10-21 10:50:05 +0200234}
235
236void fpga_gpio_clear(int pin)
237{
Dirk Eibach2da0fc02011-01-21 09:31:21 +0100238 out_le16((void *)(CONFIG_SYS_FPGA0_BASE + 0x16), pin);
Dirk Eibacha605ea72010-10-21 10:50:05 +0200239}
240
241int fpga_gpio_get(int pin)
242{
Dirk Eibach2da0fc02011-01-21 09:31:21 +0100243 return in_le16((void *)(CONFIG_SYS_FPGA0_BASE + 0x14)) & pin;
Dirk Eibacha605ea72010-10-21 10:50:05 +0200244}
Dirk Eibach6e9e6c32012-04-26 03:54:22 +0000245
246void gd405ep_init(void)
247{
248}
249
250void gd405ep_set_fpga_reset(unsigned state)
251{
252 if (state) {
253 out_le16((void *)LATCH0_BASE, CONFIG_SYS_LATCH0_RESET);
254 out_le16((void *)LATCH1_BASE, CONFIG_SYS_LATCH1_RESET);
255 } else {
256 out_le16((void *)LATCH0_BASE, CONFIG_SYS_LATCH0_BOOT);
257 out_le16((void *)LATCH1_BASE, CONFIG_SYS_LATCH1_BOOT);
258 }
259}
260
261void gd405ep_setup_hw(void)
262{
263 /*
264 * set "startup-finished"-gpios
265 */
266 gpio_write_bit(21, 0);
267 gpio_write_bit(22, 1);
268}
269
270int gd405ep_get_fpga_done(unsigned fpga)
271{
272 return in_le16((void *)LATCH2_BASE) & CONFIG_SYS_FPGA_DONE(fpga);
273}