1
2
3
4
5
6
7
8
9
10
11#include <common.h>
12#include <post.h>
13#include <serial.h>
14
15
16
17
18
19
20
21
22
23
24char alive[] = "$AL;38\r\n";
25char ping[] = "$PI;2C\n";
26
27int coprocessor_post_test(int flags)
28{
29 struct stdio_dev *cop_port;
30 int ret;
31 char buf[10];
32
33
34 cop_port = open_port(4, CONFIG_SYS_PDM360NG_COPROC_BAUDRATE);
35 if (!cop_port)
36 return -1;
37
38 write_port(cop_port, ping);
39 udelay(CONFIG_SYS_PDM360NG_COPROC_READ_DELAY);
40
41 memset(buf, 0, sizeof(buf));
42 ret = read_port(cop_port, buf, sizeof(buf));
43 close_port(4);
44 if (ret <= 0) {
45 post_log("Error: Can't read IO Coprocessor port.\n");
46 return -1;
47 }
48
49 if (strcmp(buf, alive)) {
50 post_log("Error: IO-Cop. resp.: %s\n", buf);
51 return -1;
52 }
53
54
55 cop_port = open_port(1, CONFIG_SYS_PDM360NG_COPROC_BAUDRATE);
56 if (!cop_port) {
57 post_log("Error: Can't open WD Coprocessor port.\n");
58 return -1;
59 }
60
61 write_port(cop_port, ping);
62 udelay(CONFIG_SYS_PDM360NG_COPROC_READ_DELAY);
63
64 memset(buf, 0, sizeof(buf));
65 ret = read_port(cop_port, buf, sizeof(buf));
66 close_port(1);
67 if (ret <= 0) {
68 post_log("Error: Can't read WD Coprocessor port.\n");
69 return -1;
70 }
71
72 if (strcmp(buf, alive)) {
73 post_log("Error: WD-Cop. resp.: %s\n", buf);
74 return -1;
75 }
76
77 return 0;
78}
79