2 * (C) Copyright 2010 DENX Software Engineering,
3 * Anatolij Gustschin, agust@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
9 * Co-Processor communication POST
16 * Actually the termination sequence of the coprocessor
17 * commands is "\r\n" (CR LF), but here we use a side effect of
18 * the putc() routine of the serial driver which checks for LF
19 * and sends CR before sending LF. Therefore the termination
20 * sequence in the command below is only "\n".
21 * "alive" string is the coprocessor response for ping command
22 * and not a command, therefore it is terminated with "\r\n".
24 char alive[] = "$AL;38\r\n";
25 char ping[] = "$PI;2C\n";
27 int coprocessor_post_test(int flags)
29 struct stdio_dev *cop_port;
33 /* Test IO Coprocessor communication */
34 cop_port = open_port(4, CONFIG_SYS_PDM360NG_COPROC_BAUDRATE);
38 write_port(cop_port, ping);
39 udelay(CONFIG_SYS_PDM360NG_COPROC_READ_DELAY);
41 memset(buf, 0, sizeof(buf));
42 ret = read_port(cop_port, buf, sizeof(buf));
45 post_log("Error: Can't read IO Coprocessor port.\n");
49 if (strcmp(buf, alive)) {
50 post_log("Error: IO-Cop. resp.: %s\n", buf);
54 /* Test WD Coprocessor communication */
55 cop_port = open_port(1, CONFIG_SYS_PDM360NG_COPROC_BAUDRATE);
57 post_log("Error: Can't open WD Coprocessor port.\n");
61 write_port(cop_port, ping);
62 udelay(CONFIG_SYS_PDM360NG_COPROC_READ_DELAY);
64 memset(buf, 0, sizeof(buf));
65 ret = read_port(cop_port, buf, sizeof(buf));
68 post_log("Error: Can't read WD Coprocessor port.\n");
72 if (strcmp(buf, alive)) {
73 post_log("Error: WD-Cop. resp.: %s\n", buf);