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