3 * Dirk Eibach, Guntermann & Drunck GmbH, eibach@gdsys.de
5 * SPDX-License-Identifier: GPL-2.0+
10 #include <asm/processor.h>
12 #include <asm/ppc4xx-gpio.h>
16 #include <gdsys_fpga.h>
18 #include "../common/osd.h"
20 #define LATCH0_BASE (CONFIG_SYS_LATCH_BASE)
21 #define LATCH1_BASE (CONFIG_SYS_LATCH_BASE + 0x100)
22 #define LATCH2_BASE (CONFIG_SYS_LATCH_BASE + 0x200)
23 #define LATCH3_BASE (CONFIG_SYS_LATCH_BASE + 0x300)
25 #define LATCH2_MC2_PRESENT_N 0x0080
29 UNITTYPE_SERVER
= 1<<1,
30 UNITTYPE_DISPLAYPORT
= 1<<2,
60 struct ihs_fpga
*fpga_ptr
[] = CONFIG_SYS_FPGA_PTR
;
70 static unsigned int get_hwver(void)
72 u16 latch3
= in_le16((void *)LATCH3_BASE
);
74 return latch3
& 0x0003;
77 static unsigned int get_mc2_present(void)
79 u16 latch2
= in_le16((void *)LATCH2_BASE
);
81 return !(latch2
& LATCH2_MC2_PRESENT_N
);
84 static void print_fpga_info(unsigned dev
)
90 unsigned hardware_version
;
91 unsigned feature_rs232
;
92 unsigned feature_audio
;
93 unsigned feature_sysclock
;
94 unsigned feature_ramconfig
;
95 unsigned feature_carrier_speed
;
96 unsigned feature_carriers
;
97 unsigned feature_video_channels
;
98 int fpga_state
= get_fpga_state(dev
);
100 printf("FPGA%d: ", dev
);
102 FPGA_GET_REG(dev
, versions
, &versions
);
103 FPGA_GET_REG(dev
, fpga_version
, &fpga_version
);
104 FPGA_GET_REG(dev
, fpga_features
, &fpga_features
);
106 hardware_version
= versions
& 0x000f;
109 && !((hardware_version
== HWVER_101
)
110 && (fpga_state
== FPGA_STATE_DONE_FAILED
))) {
111 puts("not available\n");
112 if (fpga_state
& FPGA_STATE_DONE_FAILED
)
113 puts(" Waiting for FPGA-DONE timed out.\n");
114 if (fpga_state
& FPGA_STATE_REFLECTION_FAILED
)
115 puts(" FPGA reflection test failed.\n");
119 unit_type
= (versions
>> 4) & 0x000f;
120 hardware_version
= versions
& 0x000f;
121 feature_rs232
= fpga_features
& (1<<11);
122 feature_audio
= (fpga_features
>> 9) & 0x0003;
123 feature_sysclock
= (fpga_features
>> 7) & 0x0003;
124 feature_ramconfig
= (fpga_features
>> 5) & 0x0003;
125 feature_carrier_speed
= fpga_features
& (1<<4);
126 feature_carriers
= (fpga_features
>> 2) & 0x0003;
127 feature_video_channels
= fpga_features
& 0x0003;
129 if (unit_type
& UNITTYPE_MAIN
)
130 printf("Mainchannel ");
132 printf("Videochannel ");
134 if (unit_type
& UNITTYPE_SERVER
)
135 printf("Serverside ");
139 if (unit_type
& UNITTYPE_DISPLAYPORT
)
140 printf("DisplayPort");
144 switch (hardware_version
) {
146 printf(" HW-Ver 1.01\n");
150 printf(" HW-Ver 1.10-1.20\n");
154 printf(" HW-Ver 1.30\n");
158 printf(" HW-Ver 1.40-1.43\n");
162 printf(" HW-Ver 1.50\n");
166 printf(" HW-Ver 1.60-1.61\n");
170 printf(" HW-Ver 1.70\n");
174 printf(" HW-Ver %d(not supported)\n",
179 printf(" FPGA V %d.%02d, features:",
180 fpga_version
/ 100, fpga_version
% 100);
182 printf(" %sRS232", feature_rs232
? "" : "no ");
184 switch (feature_audio
) {
186 printf(", no audio");
190 printf(", audio tx");
194 printf(", audio rx");
198 printf(", audio rx+tx");
202 printf(", audio %d(not supported)", feature_audio
);
206 switch (feature_sysclock
) {
208 printf(", clock 156.25 MHz");
212 printf(", clock %d(not supported)", feature_sysclock
);
218 switch (feature_ramconfig
) {
224 printf("RAM 32 bit DDR2");
228 printf("RAM 64 bit DDR2");
232 printf("RAM %d(not supported)", feature_ramconfig
);
236 printf(", %d carrier(s) %s", feature_carriers
,
237 feature_carrier_speed
? "10 Gbit/s" : "of unknown speed");
239 printf(", %d video channel(s)\n", feature_video_channels
);
243 * Check Board Identity:
247 char *s
= getenv("serial#");
251 puts("DLVision 10G");
263 int last_stage_init(void)
267 FPGA_GET_REG(0, versions
, &versions
);
270 if (get_mc2_present())
273 if (((versions
>> 4) & 0x000f) & UNITTYPE_SERVER
)
276 if (!get_fpga_state(0) || (get_hwver() == HWVER_101
))
279 if (get_mc2_present() &&
280 (!get_fpga_state(1) || (get_hwver() == HWVER_101
)))
286 void gd405ep_init(void)
290 void gd405ep_set_fpga_reset(unsigned state
)
293 out_le16((void *)LATCH0_BASE
, CONFIG_SYS_LATCH0_RESET
);
294 out_le16((void *)LATCH1_BASE
, CONFIG_SYS_LATCH1_RESET
);
296 out_le16((void *)LATCH0_BASE
, CONFIG_SYS_LATCH0_BOOT
);
297 out_le16((void *)LATCH1_BASE
, CONFIG_SYS_LATCH1_BOOT
);
301 void gd405ep_setup_hw(void)
304 * set "startup-finished"-gpios
306 gpio_write_bit(21, 0);
307 gpio_write_bit(22, 1);
310 int gd405ep_get_fpga_done(unsigned fpga
)
312 return in_le16((void *)LATCH2_BASE
) & CONFIG_SYS_FPGA_DONE(fpga
);