blob: b5317866530683f49ccb331b8387ead46412377f [file] [log] [blame]
Dirk Eibach81b37932011-01-21 09:31:21 +01001/*
2 * (C) Copyright 2010
3 * Dirk Eibach, Guntermann & Drunck GmbH, eibach@gdsys.de
4 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Dirk Eibach81b37932011-01-21 09:31:21 +01006 */
7
8#include <common.h>
9#include <command.h>
10#include <asm/processor.h>
11#include <asm/io.h>
12#include <asm/ppc4xx-gpio.h>
13
Dirk Eibach9a659572012-04-26 03:54:22 +000014#include "405ep.h"
Dirk Eibach81b37932011-01-21 09:31:21 +010015#include <gdsys_fpga.h>
16
17#include "../common/osd.h"
18
Dirk Eibach9a659572012-04-26 03:54:22 +000019#define LATCH0_BASE (CONFIG_SYS_LATCH_BASE)
20#define LATCH1_BASE (CONFIG_SYS_LATCH_BASE + 0x100)
Dirk Eibachcf868222011-04-06 13:53:44 +020021#define LATCH2_BASE (CONFIG_SYS_LATCH_BASE + 0x200)
Dirk Eibacha46eb6e2011-04-06 13:53:46 +020022#define LATCH3_BASE (CONFIG_SYS_LATCH_BASE + 0x300)
23
Dirk Eibach9a659572012-04-26 03:54:22 +000024#define LATCH2_MC2_PRESENT_N 0x0080
25
Dirk Eibach81b37932011-01-21 09:31:21 +010026enum {
Dirk Eibachfbb4e532015-10-28 11:46:28 +010027 UNITTYPE_MAIN = 1<<0,
28 UNITTYPE_SERVER = 1<<1,
29 UNITTYPE_DISPLAYPORT = 1<<2,
Dirk Eibach81b37932011-01-21 09:31:21 +010030};
31
32enum {
33 HWVER_101 = 0,
34 HWVER_110 = 1,
Dirk Eibachfbb4e532015-10-28 11:46:28 +010035 HWVER_130 = 2,
36 HWVER_140 = 3,
37 HWVER_150 = 4,
38 HWVER_160 = 5,
39 HWVER_170 = 6,
Dirk Eibach81b37932011-01-21 09:31:21 +010040};
41
42enum {
43 AUDIO_NONE = 0,
44 AUDIO_TX = 1,
45 AUDIO_RX = 2,
46 AUDIO_RXTX = 3,
47};
48
49enum {
50 SYSCLK_156250 = 2,
51};
52
53enum {
54 RAM_NONE = 0,
55 RAM_DDR2_32 = 1,
56 RAM_DDR2_64 = 2,
57};
58
Dirk Eibach20614a22013-06-26 16:04:26 +020059struct ihs_fpga *fpga_ptr[] = CONFIG_SYS_FPGA_PTR;
60
Dirk Eibach6b4b92f2012-04-26 03:54:23 +000061int misc_init_r(void)
62{
Simon Glassb6fadad2017-05-17 03:25:05 -060063 /*
64 * Note: DTT has been removed. Please use UCLASS_THERMAL.
65 *
66 * startup fans
67 *
68 * dtt_init();
69 */
Dirk Eibach6b4b92f2012-04-26 03:54:23 +000070
71 return 0;
72}
73
Dirk Eibacha46eb6e2011-04-06 13:53:46 +020074static unsigned int get_hwver(void)
75{
76 u16 latch3 = in_le16((void *)LATCH3_BASE);
77
78 return latch3 & 0x0003;
79}
80
81static unsigned int get_mc2_present(void)
82{
83 u16 latch2 = in_le16((void *)LATCH2_BASE);
84
85 return !(latch2 & LATCH2_MC2_PRESENT_N);
86}
87
Dirk Eibach81b37932011-01-21 09:31:21 +010088static void print_fpga_info(unsigned dev)
89{
Dirk Eibach20614a22013-06-26 16:04:26 +020090 u16 versions;
91 u16 fpga_version;
92 u16 fpga_features;
Dirk Eibach81b37932011-01-21 09:31:21 +010093 unsigned unit_type;
94 unsigned hardware_version;
Dirk Eibach81b37932011-01-21 09:31:21 +010095 unsigned feature_rs232;
96 unsigned feature_audio;
97 unsigned feature_sysclock;
98 unsigned feature_ramconfig;
99 unsigned feature_carrier_speed;
100 unsigned feature_carriers;
101 unsigned feature_video_channels;
102 int fpga_state = get_fpga_state(dev);
103
104 printf("FPGA%d: ", dev);
105
Dirk Eibach20614a22013-06-26 16:04:26 +0200106 FPGA_GET_REG(dev, versions, &versions);
107 FPGA_GET_REG(dev, fpga_version, &fpga_version);
108 FPGA_GET_REG(dev, fpga_features, &fpga_features);
109
Dirk Eibach81b37932011-01-21 09:31:21 +0100110 hardware_version = versions & 0x000f;
111
112 if (fpga_state
113 && !((hardware_version == HWVER_101)
114 && (fpga_state == FPGA_STATE_DONE_FAILED))) {
115 puts("not available\n");
Tom Rini98003f82016-07-15 15:51:40 -0400116 if (fpga_state & FPGA_STATE_DONE_FAILED)
117 puts(" Waiting for FPGA-DONE timed out.\n");
118 if (fpga_state & FPGA_STATE_REFLECTION_FAILED)
119 puts(" FPGA reflection test failed.\n");
Dirk Eibach81b37932011-01-21 09:31:21 +0100120 return;
121 }
122
123 unit_type = (versions >> 4) & 0x000f;
124 hardware_version = versions & 0x000f;
Dirk Eibach81b37932011-01-21 09:31:21 +0100125 feature_rs232 = fpga_features & (1<<11);
126 feature_audio = (fpga_features >> 9) & 0x0003;
127 feature_sysclock = (fpga_features >> 7) & 0x0003;
128 feature_ramconfig = (fpga_features >> 5) & 0x0003;
129 feature_carrier_speed = fpga_features & (1<<4);
130 feature_carriers = (fpga_features >> 2) & 0x0003;
131 feature_video_channels = fpga_features & 0x0003;
132
Dirk Eibachfbb4e532015-10-28 11:46:28 +0100133 if (unit_type & UNITTYPE_MAIN)
134 printf("Mainchannel ");
135 else
136 printf("Videochannel ");
Dirk Eibach81b37932011-01-21 09:31:21 +0100137
Dirk Eibachfbb4e532015-10-28 11:46:28 +0100138 if (unit_type & UNITTYPE_SERVER)
139 printf("Serverside ");
140 else
141 printf("Userside ");
Dirk Eibach81b37932011-01-21 09:31:21 +0100142
Dirk Eibachfbb4e532015-10-28 11:46:28 +0100143 if (unit_type & UNITTYPE_DISPLAYPORT)
144 printf("DisplayPort");
145 else
146 printf("DVI-DL");
147
148 switch (hardware_version) {
149 case HWVER_101:
150 printf(" HW-Ver 1.01\n");
Dirk Eibach81b37932011-01-21 09:31:21 +0100151 break;
152
Dirk Eibachfbb4e532015-10-28 11:46:28 +0100153 case HWVER_110:
154 printf(" HW-Ver 1.10-1.20\n");
Dirk Eibach81b37932011-01-21 09:31:21 +0100155 break;
156
Dirk Eibachfbb4e532015-10-28 11:46:28 +0100157 case HWVER_130:
158 printf(" HW-Ver 1.30\n");
Dirk Eibach81b37932011-01-21 09:31:21 +0100159 break;
Dirk Eibach81b37932011-01-21 09:31:21 +0100160
Dirk Eibachfbb4e532015-10-28 11:46:28 +0100161 case HWVER_140:
162 printf(" HW-Ver 1.40-1.43\n");
Dirk Eibach81b37932011-01-21 09:31:21 +0100163 break;
164
Dirk Eibachfbb4e532015-10-28 11:46:28 +0100165 case HWVER_150:
166 printf(" HW-Ver 1.50\n");
Dirk Eibach50477bf2012-04-26 03:54:24 +0000167 break;
168
Dirk Eibachfbb4e532015-10-28 11:46:28 +0100169 case HWVER_160:
170 printf(" HW-Ver 1.60-1.61\n");
Dirk Eibach50477bf2012-04-26 03:54:24 +0000171 break;
172
Dirk Eibachfbb4e532015-10-28 11:46:28 +0100173 case HWVER_170:
174 printf(" HW-Ver 1.70\n");
Dirk Eibach81b37932011-01-21 09:31:21 +0100175 break;
176
177 default:
178 printf(" HW-Ver %d(not supported)\n",
179 hardware_version);
180 break;
181 }
182
183 printf(" FPGA V %d.%02d, features:",
184 fpga_version / 100, fpga_version % 100);
185
186 printf(" %sRS232", feature_rs232 ? "" : "no ");
187
188 switch (feature_audio) {
189 case AUDIO_NONE:
190 printf(", no audio");
191 break;
192
193 case AUDIO_TX:
194 printf(", audio tx");
195 break;
196
197 case AUDIO_RX:
198 printf(", audio rx");
199 break;
200
201 case AUDIO_RXTX:
202 printf(", audio rx+tx");
203 break;
204
205 default:
206 printf(", audio %d(not supported)", feature_audio);
207 break;
208 }
209
210 switch (feature_sysclock) {
211 case SYSCLK_156250:
212 printf(", clock 156.25 MHz");
213 break;
214
215 default:
216 printf(", clock %d(not supported)", feature_sysclock);
217 break;
218 }
219
220 puts(",\n ");
221
222 switch (feature_ramconfig) {
223 case RAM_NONE:
224 printf("no RAM");
225 break;
226
227 case RAM_DDR2_32:
228 printf("RAM 32 bit DDR2");
229 break;
230
231 case RAM_DDR2_64:
232 printf("RAM 64 bit DDR2");
233 break;
234
235 default:
236 printf("RAM %d(not supported)", feature_ramconfig);
237 break;
238 }
239
240 printf(", %d carrier(s) %s", feature_carriers,
241 feature_carrier_speed ? "10 Gbit/s" : "of unknown speed");
242
243 printf(", %d video channel(s)\n", feature_video_channels);
244}
245
246/*
247 * Check Board Identity:
248 */
249int checkboard(void)
250{
Dirk Eibach6b4b92f2012-04-26 03:54:23 +0000251 char *s = getenv("serial#");
Dirk Eibach81b37932011-01-21 09:31:21 +0100252
Dirk Eibach6b4b92f2012-04-26 03:54:23 +0000253 puts("Board: ");
Dirk Eibach81b37932011-01-21 09:31:21 +0100254
Dirk Eibach6b4b92f2012-04-26 03:54:23 +0000255 puts("DLVision 10G");
Dirk Eibach81b37932011-01-21 09:31:21 +0100256
Dirk Eibach6b4b92f2012-04-26 03:54:23 +0000257 if (s != NULL) {
Dirk Eibach81b37932011-01-21 09:31:21 +0100258 puts(", serial# ");
Dirk Eibach6b4b92f2012-04-26 03:54:23 +0000259 puts(s);
Dirk Eibach81b37932011-01-21 09:31:21 +0100260 }
261
262 puts("\n");
263
Dirk Eibach81b37932011-01-21 09:31:21 +0100264 return 0;
265}
266
267int last_stage_init(void)
268{
Dirk Eibach20614a22013-06-26 16:04:26 +0200269 u16 versions;
270
271 FPGA_GET_REG(0, versions, &versions);
Dirk Eibachcf868222011-04-06 13:53:44 +0200272
Dirk Eibach6b4b92f2012-04-26 03:54:23 +0000273 print_fpga_info(0);
274 if (get_mc2_present())
275 print_fpga_info(1);
276
Dirk Eibachfbb4e532015-10-28 11:46:28 +0100277 if (((versions >> 4) & 0x000f) & UNITTYPE_SERVER)
Dirk Eibachcf868222011-04-06 13:53:44 +0200278 return 0;
279
Dirk Eibacha46eb6e2011-04-06 13:53:46 +0200280 if (!get_fpga_state(0) || (get_hwver() == HWVER_101))
Dirk Eibachcf868222011-04-06 13:53:44 +0200281 osd_probe(0);
Dirk Eibach81b37932011-01-21 09:31:21 +0100282
Dirk Eibacha46eb6e2011-04-06 13:53:46 +0200283 if (get_mc2_present() &&
284 (!get_fpga_state(1) || (get_hwver() == HWVER_101)))
Dirk Eibachcf868222011-04-06 13:53:44 +0200285 osd_probe(1);
Dirk Eibach81b37932011-01-21 09:31:21 +0100286
287 return 0;
288}
Dirk Eibach9a659572012-04-26 03:54:22 +0000289
290void gd405ep_init(void)
291{
292}
293
294void gd405ep_set_fpga_reset(unsigned state)
295{
296 if (state) {
297 out_le16((void *)LATCH0_BASE, CONFIG_SYS_LATCH0_RESET);
298 out_le16((void *)LATCH1_BASE, CONFIG_SYS_LATCH1_RESET);
299 } else {
300 out_le16((void *)LATCH0_BASE, CONFIG_SYS_LATCH0_BOOT);
301 out_le16((void *)LATCH1_BASE, CONFIG_SYS_LATCH1_BOOT);
302 }
303}
304
305void gd405ep_setup_hw(void)
306{
307 /*
308 * set "startup-finished"-gpios
309 */
310 gpio_write_bit(21, 0);
311 gpio_write_bit(22, 1);
312}
313
314int gd405ep_get_fpga_done(unsigned fpga)
315{
316 return in_le16((void *)LATCH2_BASE) & CONFIG_SYS_FPGA_DONE(fpga);
317}