2 * (C) Copyright 2010 DENX Software Engineering,
3 * Anatolij Gustschin, agust@denx.de.
5 * See file CREDITS for list of people who contributed to this
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.
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.
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,
25 * Co-Processor communication POST
32 * Actually the termination sequence of the coprocessor
33 * commands is "\r\n" (CR LF), but here we use a side effect of
34 * the putc() routine of the serial driver which checks for LF
35 * and sends CR before sending LF. Therefore the termination
36 * sequence in the command below is only "\n".
37 * "alive" string is the coprocessor response for ping command
38 * and not a command, therefore it is terminated with "\r\n".
40 char alive[] = "$AL;38\r\n";
41 char ping[] = "$PI;2C\n";
43 int coprocessor_post_test(int flags)
45 struct stdio_dev *cop_port;
49 /* Test IO Coprocessor communication */
50 cop_port = open_port(4, CONFIG_SYS_PDM360NG_COPROC_BAUDRATE);
54 write_port(cop_port, ping);
55 udelay(CONFIG_SYS_PDM360NG_COPROC_READ_DELAY);
57 memset(buf, 0, sizeof(buf));
58 ret = read_port(cop_port, buf, sizeof(buf));
61 post_log("Error: Can't read IO Coprocessor port.\n");
65 if (strcmp(buf, alive)) {
66 post_log("Error: IO-Cop. resp.: %s\n", buf);
70 /* Test WD Coprocessor communication */
71 cop_port = open_port(1, CONFIG_SYS_PDM360NG_COPROC_BAUDRATE);
73 post_log("Error: Can't open WD Coprocessor port.\n");
77 write_port(cop_port, ping);
78 udelay(CONFIG_SYS_PDM360NG_COPROC_READ_DELAY);
80 memset(buf, 0, sizeof(buf));
81 ret = read_port(cop_port, buf, sizeof(buf));
84 post_log("Error: Can't read WD Coprocessor port.\n");
88 if (strcmp(buf, alive)) {
89 post_log("Error: WD-Cop. resp.: %s\n", buf);