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