]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - common/cmd_iim.c
applied patches from Freescale and Ka-Ro
[karo-tx-uboot.git] / common / cmd_iim.c
1 /*
2  * (C) Copyright 2008-2010 Freescale Semiconductor, Inc.
3  *
4  * Copyright 2007, Freescale Semiconductor, Inc
5  * Andy Fleming
6  *
7  * Based vaguely on the pxa mmc code:
8  * (C) Copyright 2003
9  * Kyle Harris, Nexus Technologies, Inc. kharris@nexus-tech.net
10  *
11  * See file CREDITS for list of people who contributed to this
12  * project.
13  *
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License as
16  * published by the Free Software Foundation; either version 2 of
17  * the License, or (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27  * MA 02111-1307 USA
28  */
29
30 #include <linux/types.h>
31 #include <asm/io.h>
32 #include <command.h>
33 #include <common.h>
34 #include <asm/imx_iim.h>
35
36 int do_iimops(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
37 {
38         int bank = 0,
39                 row = 0,
40                 val = 0;
41
42         if (argc < 3 || argc > 5)
43                 goto err_rtn;
44
45         if (strcmp(argv[1], "read") == 0) {
46                 if (strcmp(argv[2], "fecmac") == 0) {
47                         if (3 == argc)
48                                 iim_blow_func(argv[2], NULL);
49                         else
50                                 goto err_rtn;
51                 } else {
52                         if (4 == argc) {
53                                 bank = simple_strtoul(argv[2], NULL, 16);
54                                 row = simple_strtoul(argv[3], NULL, 16);
55
56                                 iim_read(bank, row);
57                         } else
58                                 goto err_rtn;
59                 }
60         } else if (strcmp(argv[1], "blow") == 0) {
61                 if (strcmp(argv[2], "fecmac") == 0) {
62                         if (4 == argc)
63                                 iim_blow_func(argv[2], argv[3]);
64                         else
65                                 goto err_rtn;
66                 } else {
67                         if (5 == argc) {
68                                 bank = simple_strtoul(argv[2], NULL, 16);
69                                 row = simple_strtoul(argv[3], NULL, 16);
70                                 val = simple_strtoul(argv[4], NULL, 16);
71
72                                 iim_blow(bank, row, val);
73                         } else
74                                 goto err_rtn;
75                 }
76         } else
77                 goto err_rtn;
78
79         return 0;
80 err_rtn:
81         printf("Invalid parameters!\n");
82         printf("It is too dangeous for you to use iim command.\n");
83         return 1;
84 }
85
86 U_BOOT_CMD(
87         iim, 5, 1, do_iimops,
88         "IIM sub system",
89         "Warning: all numbers in parameter are in hex format!\n"
90         "iim read <bank> <row>  - Read some fuses\n"
91         "iim read fecmac        - Read FEC Mac address\n"
92         "iim blow <bank> <row> <value>  - Blow some fuses\n"
93         "iim blow fecmac <0x##:0x##:0x##:0x##:0x##:0x##>"
94         "- Blow FEC Mac address");
95