unsik Kim | f0b1bdd | 2009-02-25 11:31:24 +0900 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2009 mGine co. |
| 3 | * unsik Kim <donari75@gmail.com> |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 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. |
| 12 | * |
| 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. |
| 17 | * |
| 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, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #include <common.h> |
| 25 | #include <command.h> |
| 26 | |
unsik Kim | f0b1bdd | 2009-02-25 11:31:24 +0900 | [diff] [blame] | 27 | #include <mg_disk.h> |
| 28 | |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 29 | int do_mg_disk_cmd (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
unsik Kim | f0b1bdd | 2009-02-25 11:31:24 +0900 | [diff] [blame] | 30 | { |
| 31 | u32 from, to, size; |
| 32 | |
| 33 | switch (argc) { |
| 34 | case 2: |
| 35 | if (!strcmp(argv[1], "init")) |
| 36 | mg_disk_init(); |
| 37 | else |
| 38 | return 1; |
| 39 | break; |
| 40 | case 5: |
| 41 | from = simple_strtoul(argv[2], NULL, 0); |
| 42 | to = simple_strtoul(argv[3], NULL, 0); |
| 43 | size = simple_strtoul(argv[4], NULL, 0); |
| 44 | |
| 45 | if (!strcmp(argv[1], "read")) |
| 46 | mg_disk_read(from, (u8 *)to, size); |
| 47 | else if (!strcmp(argv[1], "write")) |
| 48 | mg_disk_write(to, (u8 *)from, size); |
| 49 | else if (!strcmp(argv[1], "readsec")) |
| 50 | mg_disk_read_sects((void *)to, from, size); |
| 51 | else if (!strcmp(argv[1], "writesec")) |
| 52 | mg_disk_write_sects((void *)from, to, size); |
| 53 | else |
| 54 | return 1; |
| 55 | break; |
| 56 | default: |
Mike Frysinger | e799e98 | 2010-07-29 13:42:29 -0400 | [diff] [blame] | 57 | return cmd_usage(cmdtp); |
unsik Kim | f0b1bdd | 2009-02-25 11:31:24 +0900 | [diff] [blame] | 58 | } |
| 59 | return 0; |
| 60 | } |
| 61 | |
| 62 | U_BOOT_CMD( |
| 63 | mgd, 5, 0, do_mg_disk_cmd, |
Frans Meulenbroeks | 0dddc00 | 2010-07-31 15:01:52 +0200 | [diff] [blame] | 64 | "mgine m[g]flash command\n", |
unsik Kim | f0b1bdd | 2009-02-25 11:31:24 +0900 | [diff] [blame] | 65 | ": mgine mflash IO mode (disk) command\n" |
| 66 | " - initialize : mgd init\n" |
| 67 | " - random read : mgd read [from] [to] [size]\n" |
| 68 | " - random write : mgd write [from] [to] [size]\n" |
| 69 | " - sector read : mgd readsec [sector] [to] [counts]\n" |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 70 | " - sector write : mgd writesec [from] [sector] [counts]" |
unsik Kim | f0b1bdd | 2009-02-25 11:31:24 +0900 | [diff] [blame] | 71 | ); |