Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2009 |
| 3 | * Werner Pfister <Pfister_Werner@intercontrol.de> |
| 4 | * |
| 5 | * (C) Copyright 2009 Semihalf, Grzegorz Bernacki |
| 6 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 7 | * SPDX-License-Identifier: GPL-2.0+ |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <common.h> |
| 11 | #include <command.h> |
| 12 | #include <mpc5xxx.h> |
| 13 | #include "spi.h" |
| 14 | #include "cmd_mtc.h" |
| 15 | |
| 16 | DECLARE_GLOBAL_DATA_PTR; |
| 17 | |
Anatolij Gustschin | ceb3970 | 2011-05-29 21:18:51 +0000 | [diff] [blame] | 18 | static uchar user_out; |
| 19 | |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 20 | static const char *led_names[] = { |
| 21 | "diag", |
| 22 | "can1", |
| 23 | "can2", |
| 24 | "can3", |
| 25 | "can4", |
| 26 | "usbpwr", |
| 27 | "usbbusy", |
| 28 | "user1", |
| 29 | "user2", |
| 30 | "" |
| 31 | }; |
| 32 | |
Detlev Zundel | 0b40bd4 | 2009-08-05 18:37:44 +0200 | [diff] [blame] | 33 | static int msp430_xfer(const void *dout, void *din) |
| 34 | { |
| 35 | int err; |
| 36 | |
| 37 | err = spi_xfer(NULL, MTC_TRANSFER_SIZE, dout, din, |
| 38 | SPI_XFER_BEGIN | SPI_XFER_END); |
| 39 | |
| 40 | /* The MSP chip needs time to ready itself for the next command */ |
| 41 | udelay(1000); |
| 42 | |
| 43 | return err; |
| 44 | } |
| 45 | |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 46 | static void mtc_calculate_checksum(tx_msp_cmd *packet) |
| 47 | { |
| 48 | int i; |
| 49 | uchar *buff; |
| 50 | |
| 51 | buff = (uchar *) packet; |
| 52 | |
| 53 | for (i = 0; i < 6; i++) |
| 54 | packet->cks += buff[i]; |
| 55 | } |
| 56 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 57 | static int do_mtc_led(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 58 | { |
| 59 | tx_msp_cmd pcmd; |
| 60 | rx_msp_cmd prx; |
Detlev Zundel | 0b40bd4 | 2009-08-05 18:37:44 +0200 | [diff] [blame] | 61 | int err; |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 62 | int i; |
| 63 | |
Wolfgang Denk | 47e26b1 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 64 | if (argc < 2) |
| 65 | return cmd_usage(cmdtp); |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 66 | |
| 67 | memset(&pcmd, 0, sizeof(pcmd)); |
| 68 | memset(&prx, 0, sizeof(prx)); |
| 69 | |
| 70 | pcmd.cmd = CMD_SET_LED; |
| 71 | |
| 72 | pcmd.cmd_val0 = 0xff; |
| 73 | for (i = 0; strlen(led_names[i]) != 0; i++) { |
| 74 | if (strncmp(argv[1], led_names[i], strlen(led_names[i])) == 0) { |
| 75 | pcmd.cmd_val0 = i; |
| 76 | break; |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | if (pcmd.cmd_val0 == 0xff) { |
| 81 | printf("Usage:\n%s\n", cmdtp->help); |
| 82 | return -1; |
| 83 | } |
| 84 | |
| 85 | if (argc >= 3) { |
| 86 | if (strncmp(argv[2], "red", 3) == 0) |
| 87 | pcmd.cmd_val1 = 1; |
| 88 | else if (strncmp(argv[2], "green", 5) == 0) |
| 89 | pcmd.cmd_val1 = 2; |
| 90 | else if (strncmp(argv[2], "orange", 6) == 0) |
| 91 | pcmd.cmd_val1 = 3; |
| 92 | else |
| 93 | pcmd.cmd_val1 = 0; |
| 94 | } |
| 95 | |
| 96 | if (argc >= 4) |
| 97 | pcmd.cmd_val2 = simple_strtol(argv[3], NULL, 10); |
| 98 | else |
| 99 | pcmd.cmd_val2 = 0; |
| 100 | |
Anatolij Gustschin | ceb3970 | 2011-05-29 21:18:51 +0000 | [diff] [blame] | 101 | pcmd.user_out = user_out; |
| 102 | |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 103 | mtc_calculate_checksum(&pcmd); |
Detlev Zundel | 0b40bd4 | 2009-08-05 18:37:44 +0200 | [diff] [blame] | 104 | err = msp430_xfer(&pcmd, &prx); |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 105 | |
| 106 | return err; |
| 107 | } |
| 108 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 109 | static int do_mtc_key(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 110 | { |
| 111 | tx_msp_cmd pcmd; |
| 112 | rx_msp_cmd prx; |
Detlev Zundel | 0b40bd4 | 2009-08-05 18:37:44 +0200 | [diff] [blame] | 113 | int err; |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 114 | |
| 115 | memset(&pcmd, 0, sizeof(pcmd)); |
| 116 | memset(&prx, 0, sizeof(prx)); |
| 117 | |
| 118 | pcmd.cmd = CMD_GET_VIM; |
Anatolij Gustschin | ceb3970 | 2011-05-29 21:18:51 +0000 | [diff] [blame] | 119 | pcmd.user_out = user_out; |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 120 | |
| 121 | mtc_calculate_checksum(&pcmd); |
Detlev Zundel | 0b40bd4 | 2009-08-05 18:37:44 +0200 | [diff] [blame] | 122 | err = msp430_xfer(&pcmd, &prx); |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 123 | |
| 124 | if (!err) { |
| 125 | /* function returns '0' if key is pressed */ |
| 126 | err = (prx.input & 0x80) ? 0 : 1; |
| 127 | } |
| 128 | |
| 129 | return err; |
| 130 | } |
| 131 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 132 | static int do_mtc_digout(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 133 | { |
| 134 | tx_msp_cmd pcmd; |
| 135 | rx_msp_cmd prx; |
Detlev Zundel | 0b40bd4 | 2009-08-05 18:37:44 +0200 | [diff] [blame] | 136 | int err; |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 137 | uchar channel_mask = 0; |
| 138 | |
Wolfgang Denk | 47e26b1 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 139 | if (argc < 3) |
| 140 | return cmd_usage(cmdtp); |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 141 | |
| 142 | if (strncmp(argv[1], "on", 2) == 0) |
| 143 | channel_mask |= 1; |
| 144 | if (strncmp(argv[2], "on", 2) == 0) |
| 145 | channel_mask |= 2; |
| 146 | |
| 147 | memset(&pcmd, 0, sizeof(pcmd)); |
| 148 | memset(&prx, 0, sizeof(prx)); |
| 149 | |
| 150 | pcmd.cmd = CMD_GET_VIM; |
| 151 | pcmd.user_out = channel_mask; |
Anatolij Gustschin | ceb3970 | 2011-05-29 21:18:51 +0000 | [diff] [blame] | 152 | user_out = channel_mask; |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 153 | |
| 154 | mtc_calculate_checksum(&pcmd); |
Detlev Zundel | 0b40bd4 | 2009-08-05 18:37:44 +0200 | [diff] [blame] | 155 | err = msp430_xfer(&pcmd, &prx); |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 156 | |
| 157 | return err; |
| 158 | } |
| 159 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 160 | static int do_mtc_digin(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 161 | { |
| 162 | tx_msp_cmd pcmd; |
| 163 | rx_msp_cmd prx; |
Detlev Zundel | 0b40bd4 | 2009-08-05 18:37:44 +0200 | [diff] [blame] | 164 | int err; |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 165 | uchar channel_num = 0; |
| 166 | |
Wolfgang Denk | 47e26b1 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 167 | if (argc < 2) |
| 168 | return cmd_usage(cmdtp); |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 169 | |
| 170 | channel_num = simple_strtol(argv[1], NULL, 10); |
| 171 | if ((channel_num != 1) && (channel_num != 2)) { |
| 172 | printf("mtc digin: invalid parameter - must be '1' or '2'\n"); |
| 173 | return -1; |
| 174 | } |
| 175 | |
| 176 | memset(&pcmd, 0, sizeof(pcmd)); |
| 177 | memset(&prx, 0, sizeof(prx)); |
| 178 | |
| 179 | pcmd.cmd = CMD_GET_VIM; |
Anatolij Gustschin | ceb3970 | 2011-05-29 21:18:51 +0000 | [diff] [blame] | 180 | pcmd.user_out = user_out; |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 181 | |
| 182 | mtc_calculate_checksum(&pcmd); |
Detlev Zundel | 0b40bd4 | 2009-08-05 18:37:44 +0200 | [diff] [blame] | 183 | err = msp430_xfer(&pcmd, &prx); |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 184 | |
| 185 | if (!err) { |
| 186 | /* function returns '0' when digin is on */ |
| 187 | err = (prx.input & channel_num) ? 0 : 1; |
| 188 | } |
| 189 | |
| 190 | return err; |
| 191 | } |
| 192 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 193 | static int do_mtc_appreg(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 194 | { |
| 195 | tx_msp_cmd pcmd; |
| 196 | rx_msp_cmd prx; |
| 197 | int err; |
| 198 | char buf[5]; |
Anatolij Gustschin | ceb3970 | 2011-05-29 21:18:51 +0000 | [diff] [blame] | 199 | uchar appreg; |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 200 | |
| 201 | /* read appreg */ |
| 202 | memset(&pcmd, 0, sizeof(pcmd)); |
| 203 | memset(&prx, 0, sizeof(prx)); |
| 204 | |
| 205 | pcmd.cmd = CMD_WD_PARA; |
| 206 | pcmd.cmd_val0 = 5; /* max. Count */ |
| 207 | pcmd.cmd_val1 = 5; /* max. Time */ |
| 208 | pcmd.cmd_val2 = 0; /* =0 means read appreg */ |
Anatolij Gustschin | ceb3970 | 2011-05-29 21:18:51 +0000 | [diff] [blame] | 209 | pcmd.user_out = user_out; |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 210 | |
| 211 | mtc_calculate_checksum(&pcmd); |
Detlev Zundel | 0b40bd4 | 2009-08-05 18:37:44 +0200 | [diff] [blame] | 212 | err = msp430_xfer(&pcmd, &prx); |
| 213 | |
Anatolij Gustschin | ceb3970 | 2011-05-29 21:18:51 +0000 | [diff] [blame] | 214 | /* on success decide between read or write */ |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 215 | if (!err) { |
Anatolij Gustschin | ceb3970 | 2011-05-29 21:18:51 +0000 | [diff] [blame] | 216 | if (argc == 2) { |
| 217 | appreg = simple_strtol(argv[1], NULL, 10); |
| 218 | if (appreg == 0) { |
| 219 | printf("mtc appreg: invalid parameter - " |
| 220 | "must be between 1 and 255\n"); |
| 221 | return -1; |
| 222 | } |
| 223 | memset(&pcmd, 0, sizeof(pcmd)); |
| 224 | pcmd.cmd = CMD_WD_PARA; |
| 225 | pcmd.cmd_val0 = prx.ack3; /* max. Count */ |
| 226 | pcmd.cmd_val1 = prx.ack0; /* max. Time */ |
| 227 | pcmd.cmd_val2 = appreg; /* !=0 means write appreg */ |
| 228 | pcmd.user_out = user_out; |
| 229 | memset(&prx, 0, sizeof(prx)); |
| 230 | |
| 231 | mtc_calculate_checksum(&pcmd); |
| 232 | err = msp430_xfer(&pcmd, &prx); |
| 233 | } else { |
| 234 | sprintf(buf, "%d", prx.ack2); |
| 235 | setenv("appreg", buf); |
| 236 | } |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | return err; |
| 240 | } |
| 241 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 242 | static int do_mtc_version(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 243 | { |
| 244 | tx_msp_cmd pcmd; |
| 245 | rx_msp_cmd prx; |
Detlev Zundel | 0b40bd4 | 2009-08-05 18:37:44 +0200 | [diff] [blame] | 246 | int err; |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 247 | |
| 248 | memset(&pcmd, 0, sizeof(pcmd)); |
| 249 | memset(&prx, 0, sizeof(prx)); |
| 250 | |
| 251 | pcmd.cmd = CMD_FW_VERSION; |
Anatolij Gustschin | ceb3970 | 2011-05-29 21:18:51 +0000 | [diff] [blame] | 252 | pcmd.user_out = user_out; |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 253 | |
| 254 | mtc_calculate_checksum(&pcmd); |
Detlev Zundel | 0b40bd4 | 2009-08-05 18:37:44 +0200 | [diff] [blame] | 255 | err = msp430_xfer(&pcmd, &prx); |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 256 | |
| 257 | if (!err) { |
| 258 | printf("FW V%d.%d.%d / HW %d\n", |
| 259 | prx.ack0, prx.ack1, prx.ack3, prx.ack2); |
| 260 | } |
| 261 | |
| 262 | return err; |
| 263 | } |
| 264 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 265 | static int do_mtc_state(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Grzegorz Bernacki | 5cc6908 | 2009-08-05 18:37:42 +0200 | [diff] [blame] | 266 | { |
| 267 | tx_msp_cmd pcmd; |
| 268 | rx_msp_cmd prx; |
Detlev Zundel | 0b40bd4 | 2009-08-05 18:37:44 +0200 | [diff] [blame] | 269 | int err; |
Grzegorz Bernacki | 5cc6908 | 2009-08-05 18:37:42 +0200 | [diff] [blame] | 270 | |
| 271 | memset(&pcmd, 0, sizeof(pcmd)); |
| 272 | memset(&prx, 0, sizeof(prx)); |
| 273 | |
| 274 | pcmd.cmd = CMD_WD_WDSTATE; |
| 275 | pcmd.cmd_val2 = 1; |
Anatolij Gustschin | ceb3970 | 2011-05-29 21:18:51 +0000 | [diff] [blame] | 276 | pcmd.user_out = user_out; |
Grzegorz Bernacki | 5cc6908 | 2009-08-05 18:37:42 +0200 | [diff] [blame] | 277 | |
| 278 | mtc_calculate_checksum(&pcmd); |
Detlev Zundel | 0b40bd4 | 2009-08-05 18:37:44 +0200 | [diff] [blame] | 279 | err = msp430_xfer(&pcmd, &prx); |
Grzegorz Bernacki | 5cc6908 | 2009-08-05 18:37:42 +0200 | [diff] [blame] | 280 | |
| 281 | if (!err) { |
| 282 | printf("State %02Xh\n", prx.state); |
| 283 | printf("Input %02Xh\n", prx.input); |
| 284 | printf("UserWD %02Xh\n", prx.ack2); |
| 285 | printf("Sys WD %02Xh\n", prx.ack3); |
| 286 | printf("WD Timout %02Xh\n", prx.ack0); |
| 287 | printf("eSysState %02Xh\n", prx.ack1); |
| 288 | } |
| 289 | |
| 290 | return err; |
| 291 | } |
| 292 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 293 | static int do_mtc_help(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 294 | |
| 295 | cmd_tbl_t cmd_mtc_sub[] = { |
| 296 | U_BOOT_CMD_MKENT(led, 3, 1, do_mtc_led, |
| 297 | "set state of leds", |
| 298 | "[ledname] [state] [blink]\n" |
| 299 | " - lednames: diag can1 can2 can3 can4 usbpwr usbbusy user1 user2\n" |
| 300 | " - state: off red green orange\n" |
| 301 | " - blink: blink interval in 100ms steps (1 - 10; 0 = static)\n"), |
| 302 | U_BOOT_CMD_MKENT(key, 0, 1, do_mtc_key, |
Anatolij Gustschin | 0bf0075 | 2009-08-05 18:37:43 +0200 | [diff] [blame] | 303 | "returns state of user key", ""), |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 304 | U_BOOT_CMD_MKENT(version, 0, 1, do_mtc_version, |
Anatolij Gustschin | 0bf0075 | 2009-08-05 18:37:43 +0200 | [diff] [blame] | 305 | "returns firmware version of supervisor uC", ""), |
Anatolij Gustschin | ceb3970 | 2011-05-29 21:18:51 +0000 | [diff] [blame] | 306 | U_BOOT_CMD_MKENT(appreg, 1, 1, do_mtc_appreg, |
| 307 | "reads or writes appreg value and stores in environment " |
| 308 | "variable 'appreg'", |
| 309 | "[value] - value (1 - 255) to write to appreg"), |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 310 | U_BOOT_CMD_MKENT(digin, 1, 1, do_mtc_digin, |
| 311 | "returns state of digital input", |
| 312 | "<channel_num> - get state of digital input (1 or 2)\n"), |
| 313 | U_BOOT_CMD_MKENT(digout, 2, 1, do_mtc_digout, |
| 314 | "sets digital outputs", |
| 315 | "<on|off> <on|off>- set state of digital output 1 and 2\n"), |
Grzegorz Bernacki | 5cc6908 | 2009-08-05 18:37:42 +0200 | [diff] [blame] | 316 | U_BOOT_CMD_MKENT(state, 0, 1, do_mtc_state, |
Anatolij Gustschin | 0bf0075 | 2009-08-05 18:37:43 +0200 | [diff] [blame] | 317 | "displays state", ""), |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 318 | U_BOOT_CMD_MKENT(help, 4, 1, do_mtc_help, "get help", |
| 319 | "[command] - get help for command\n"), |
| 320 | }; |
| 321 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 322 | static int do_mtc_help(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 323 | { |
| 324 | extern int _do_help(cmd_tbl_t *cmd_start, int cmd_items, |
| 325 | cmd_tbl_t *cmdtp, int flag, |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 326 | int argc, char * const argv[]); |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 327 | #ifdef CONFIG_SYS_LONGHELP |
| 328 | puts("mtc "); |
| 329 | #endif |
| 330 | return _do_help(&cmd_mtc_sub[0], |
| 331 | ARRAY_SIZE(cmd_mtc_sub), cmdtp, flag, argc, argv); |
| 332 | } |
| 333 | |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 334 | int cmd_mtc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 335 | { |
| 336 | cmd_tbl_t *c; |
| 337 | int err = 0; |
| 338 | |
| 339 | c = find_cmd_tbl(argv[1], &cmd_mtc_sub[0], ARRAY_SIZE(cmd_mtc_sub)); |
| 340 | if (c) { |
| 341 | argc--; |
| 342 | argv++; |
| 343 | return c->cmd(c, flag, argc, argv); |
| 344 | } else { |
| 345 | /* Unrecognized command */ |
Wolfgang Denk | 47e26b1 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 346 | return cmd_usage(cmdtp); |
Grzegorz Bernacki | 1230487 | 2009-06-12 11:33:54 +0200 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | return err; |
| 350 | } |
| 351 | |
| 352 | U_BOOT_CMD(mtc, 5, 1, cmd_mtc, |
Anatolij Gustschin | 0bf0075 | 2009-08-05 18:37:43 +0200 | [diff] [blame] | 353 | "special commands for digsyMTC", |
Wolfgang Denk | 8e5e9b9 | 2009-07-07 22:35:02 +0200 | [diff] [blame] | 354 | "[subcommand] [args...]\n" |
| 355 | "Subcommands list:\n" |
| 356 | "led [ledname] [state] [blink] - set state of leds\n" |
| 357 | " [ledname]: diag can1 can2 can3 can4 usbpwr usbbusy user1 user2\n" |
| 358 | " [state]: off red green orange\n" |
| 359 | " [blink]: blink interval in 100ms steps (1 - 10; 0 = static)\n" |
| 360 | "key - returns state of user key\n" |
| 361 | "version - returns firmware version of supervisor uC\n" |
Anatolij Gustschin | ceb3970 | 2011-05-29 21:18:51 +0000 | [diff] [blame] | 362 | "appreg [value] - reads (in environment variable 'appreg') or writes" |
| 363 | " appreg value\n" |
| 364 | " [value]: value (1 - 255) to write to appreg\n" |
Wolfgang Denk | 8e5e9b9 | 2009-07-07 22:35:02 +0200 | [diff] [blame] | 365 | "digin [channel] - returns state of digital input (1 or 2)\n" |
| 366 | "digout <on|off> <on|off> - sets state of two digital outputs\n" |
Anatolij Gustschin | 0bf0075 | 2009-08-05 18:37:43 +0200 | [diff] [blame] | 367 | "state - displays state\n" |
Wolfgang Denk | 8e5e9b9 | 2009-07-07 22:35:02 +0200 | [diff] [blame] | 368 | "help [subcommand] - get help for subcommand\n" |
| 369 | ); |