]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Added IIM support
authorLothar Waßmann <LW@KARO-electronics.de>
Tue, 19 Jun 2012 14:54:50 +0000 (16:54 +0200)
committerLothar Waßmann <LW@KARO-electronics.de>
Tue, 19 Jun 2012 14:54:50 +0000 (16:54 +0200)
arch/arm/include/asm/arch-mx5/imx-regs.h
common/cmd_iim.c
drivers/misc/imx_iim.c
drivers/net/fec_mxc.h
include/configs/tx51.h

index 972f68bd9e98a5baa5d3e3f30f5f42d1beed255a..fb5af6d909c5a6a8c00005ee8728e9a46e9274c4 100644 (file)
@@ -506,6 +506,8 @@ struct fuse_bank1_regs {
        u32     fuse15_31[0x11];
 };
 
+extern void imx_get_mac_from_fuse(int dev_id, unsigned char *mac);
+
 #endif /* __ASSEMBLER__*/
 
 #endif                         /* __ASM_ARCH_MX5_IMX_REGS_H__ */
index 56e38048a9c093f35d1ed6bff8bb3c0fed56faa8..cebe9b762245b69c6727185b717af79010982cdd 100644 (file)
@@ -8,6 +8,8 @@
  * (C) Copyright 2003
  * Kyle Harris, Nexus Technologies, Inc. kharris@nexus-tech.net
  *
+ * Adapted for U-Boot version 2012-04-01 by Lothar Waßmann <LW@KARO-electronics.de>
+ *
  * See file CREDITS for list of people who contributed to this
  * project.
  *
  * MA 02111-1307 USA
  */
 
+#include <common.h>
+#include <command.h>
 #include <linux/types.h>
 #include <asm/io.h>
-#include <command.h>
-#include <common.h>
-#include <asm/imx_iim.h>
+#include <asm/arch/imx_iim.h>
 
-int do_iimops(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+int do_iimops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        int bank = 0,
                row = 0,
index 4bbd4ca416b447d99bcd29f95f29b9c65e094fc8..0438ec7effad12282f65e989e3a188d10fef2922 100644 (file)
@@ -9,6 +9,8 @@
  * (C) Copyright 2003
  * Kyle Harris, Nexus Technologies, Inc. kharris@nexus-tech.net
  *
+ * Adapted for U-Boot version 2012-04-01 by Lothar Waßmann <LW@KARO-electronics.de>
+ *
  * See file CREDITS for list of people who contributed to this
  * project.
  *
  * MA 02111-1307 USA
  */
 
-#include <linux/types.h>
-#include <asm/io.h>
-#include <asm/imx_iim.h>
 #include <common.h>
 #include <net.h>
+#include <linux/types.h>
+#include <asm/io.h>
+#include <asm/arch/imx-regs.h>
+#include <asm/arch/imx_iim.h>
 
-static const struct iim_regs *imx_iim =
-               (struct iim_regs *)IMX_IIM_BASE;
+static struct iim_regs *imx_iim = (void *)IMX_IIM_BASE;
 
-static void quick_itoa(u32 num, char *a)
-{
-       int i, j, k;
-       for (i = 0; i <= 7; i++) {
-               j = (num >> (4 * i)) & 0xf;
-               k = (j < 10) ? '0' : ('a' - 0xa);
-               a[i] = j + k;
-       }
-}
-
-/* slen - streng length, e.g.: 23 -> slen=2; abcd -> slen=4 */
+/* slen - string length, e.g.: 23 -> slen=2; abcd -> slen=4 */
 /* only convert hex value as string input. so "12" is 0x12. */
 static u32 quick_atoi(char *a, u32 slen)
 {
@@ -73,10 +65,10 @@ static u32 quick_atoi(char *a, u32 slen)
 static void fuse_op_start(void)
 {
        /* Do not generate interrupt */
-       writel(0, &(imx_iim->statm));
+       writel(0, &imx_iim->statm);
        /* clear the status bits and error bits */
-       writel(0x3, &(imx_iim->stat));
-       writel(0xfe, &(imx_iim->err));
+       writel(0x3, &imx_iim->stat);
+       writel(0xfe, &imx_iim->err);
 }
 
 /*
@@ -95,12 +87,12 @@ static s32 poll_fuse_op_done(s32 action)
        }
 
        /* Poll busy bit till it is NOT set */
-       while ((readl(&(imx_iim->stat)) & IIM_STAT_BUSY) != 0)
+       while ((readl(&imx_iim->stat) & IIM_STAT_BUSY) != 0)
                ;
 
        /* Test for successful write */
-       status = readl(&(imx_iim->stat));
-       error = readl(&(imx_iim->err));
+       status = readl(&imx_iim->stat);
+       error = readl(&imx_iim->err);
 
        if ((status & action) != 0 && \
                        (error & (action >> IIM_ERR_SHIFT)) == 0) {
@@ -108,22 +100,23 @@ static s32 poll_fuse_op_done(s32 action)
                        printf("Even though the operation"
                                "seems successful...\n");
                        printf("There are some error(s) "
-                               "at addr=0x%x: 0x%x\n",
-                               (u32)&(imx_iim->err), error);
+                               "at addr=%p: 0x%x\n",
+                               &imx_iim->err, error);
                }
                return 0;
        }
        printf("%s(%d) failed\n", __func__, action);
-       printf("status address=0x%x, value=0x%x\n",
-               (u32)&(imx_iim->stat), status);
-       printf("There are some error(s) at addr=0x%x: 0x%x\n",
-               (u32)&(imx_iim->err), error);
+       printf("status address=%p, value=0x%x\n",
+               &imx_iim->stat, status);
+       printf("There are some error(s) at addr=%p: 0x%x\n",
+               &imx_iim->err, error);
        return -1;
 }
 
 static u32 sense_fuse(s32 bank, s32 row, s32 bit)
 {
-       s32 addr, addr_l, addr_h, reg_addr;
+       s32 addr, addr_l, addr_h;
+       void *reg_addr;
 
        fuse_op_start();
 
@@ -137,16 +130,16 @@ static u32 sense_fuse(s32 bank, s32 row, s32 bit)
        printf("%s: addr_h=0x%x, addr_l=0x%x\n",
                        __func__, addr_h, addr_l);
 #endif
-       writel(addr_h, &(imx_iim->ua));
-       writel(addr_l, &(imx_iim->la));
+       writel(addr_h, &imx_iim->ua);
+       writel(addr_l, &imx_iim->la);
 
        /* Start sensing */
-       writel(0x8, &(imx_iim->fctl));
+       writel(0x8, &imx_iim->fctl);
        if (poll_fuse_op_done(POLL_FUSE_SNSD) != 0) {
                printf("%s(bank: %d, row: %d, bit: %d failed\n",
                        __func__, bank, row, bit);
        }
-       reg_addr = &(imx_iim->sdat);
+       reg_addr = &imx_iim->sdat;
 
        return readl(reg_addr);
 }
@@ -172,7 +165,7 @@ static s32 fuse_blow_bit(s32 bank, s32 row, s32 bit)
        fuse_op_start();
 
        /* Disable IIM Program Protect */
-       writel(0xaa, &(imx_iim->preg_p));
+       writel(0xaa, &imx_iim->preg_p);
 
        addr = ((bank << 11) | (row << 3) | (bit & 0x7));
        /* Set IIM Program Upper Address */
@@ -184,16 +177,16 @@ static s32 fuse_blow_bit(s32 bank, s32 row, s32 bit)
        printf("blowing addr_h=0x%x, addr_l=0x%x\n", addr_h, addr_l);
 #endif
 
-       writel(addr_h, &(imx_iim->ua));
-       writel(addr_l, &(imx_iim->la));
+       writel(addr_h, &imx_iim->ua);
+       writel(addr_l, &imx_iim->la);
 
        /* Start Programming */
-       writel(0x31, &(imx_iim->fctl));
+       writel(0x31, &imx_iim->fctl);
        if (poll_fuse_op_done(POLL_FUSE_PRGD) == 0)
                ret = 0;
 
        /* Enable IIM Program Protect */
-       writel(0x0, &(imx_iim->preg_p));
+       writel(0x0, &imx_iim->preg_p);
 
        return ret;
 }
@@ -233,24 +226,6 @@ int iim_blow(int bank, int row, int val)
        return err;
 }
 
-static int iim_read_mac_addr(u8 *data)
-{
-       s32 bank = CONFIG_IIM_MAC_BANK;
-       s32 row  = CONFIG_IIM_MAC_ROW;
-
-       data[0] = sense_fuse(bank, row, 0) ;
-       data[1] = sense_fuse(bank, row + 1, 0) ;
-       data[2] = sense_fuse(bank, row + 2, 0) ;
-       data[3] = sense_fuse(bank, row + 3, 0) ;
-       data[4] = sense_fuse(bank, row + 4, 0) ;
-       data[5] = sense_fuse(bank, row + 5, 0) ;
-
-       if (!memcmp(data, "\0\0\0\0\0\0", 6))
-               return 0;
-       else
-               return 1;
-}
-
 int iim_blow_func(char *func_name, char *func_val)
 {
        u32 value, i;
@@ -258,7 +233,7 @@ int iim_blow_func(char *func_name, char *func_val)
        char val[3];
        s32 err = 0;
 
-       if (0 == strcmp(func_name, "scc")) {
+       if (strcmp(func_name, "scc") == 0) {
                /* fuse_blow scc
        C3D153EDFD2EA9982226EF5047D3B9A0B9C7138EA87C028401D28C2C2C0B9AA2 */
                printf("Ready to burn SCC fuses\n");
@@ -271,17 +246,17 @@ int iim_blow_func(char *func_name, char *func_val)
                                        i, value); */
                        fuse_blow_row(2, i, value);
 
-                       if ((++s)[0] == '\0') {
+                       if (*(++s) == '\0') {
                                printf("ERROR: Odd string input\n");
                                err = -1;
                                break;
                        }
-                       if ((++s)[0] == '\0') {
+                       if (*(++s) == '\0') {
                                printf("Successful\n");
                                break;
                        }
                }
-       } else if (0 == strcmp(func_name, "srk")) {
+       } else if (strcmp(func_name, "srk") == 0) {
                /* fuse_blow srk
        418bccd09b53bee1ab59e2662b3c7877bc0094caee201052add49be8780dff95 */
                printf("Ready to burn SRK key fuses\n");
@@ -300,23 +275,23 @@ int iim_blow_func(char *func_name, char *func_val)
                                /* ... */
                                fuse_blow_row(3, i, value);
 
-                               if ((++s)[0] == '\0') {
+                               if (*(++s) == '\0') {
                                        printf("ERROR: Odd string input\n");
                                        err = -1;
                                        break;
                                }
-                               if ((++s)[0] == '\0') {
+                               if (*(++s) == '\0') {
                                        printf("Successful\n");
                                        break;
                                }
                        }
                }
-       } else if (0 == strcmp(func_name, "fecmac")) {
+       } else if (strcmp(func_name, "fecmac") == 0) {
                u8 ea[6] = { 0 };
 
-               if (NULL == func_val) {
+               if (func_val == NULL) {
                        /* Read the Mac address and print it */
-                       iim_read_mac_addr(ea);
+                       imx_get_mac_from_fuse(0, ea);
 
                        printf("FEC MAC address: ");
                        printf("0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n\n",
index 852b2e07e715a830c6348d4cf49f0757212edf36..c81247336487f971556c661c1bd7da5b845f4fb7 100644 (file)
@@ -32,8 +32,6 @@
 #ifndef __FEC_MXC_H
 #define __FEC_MXC_H
 
-void imx_get_mac_from_fuse(int dev_id, unsigned char *mac);
-
 /**
  * Layout description of the FEC
  */
index 319b96d5082094b5a083bdc0d488bbadd56b4c8a..91dfa2dec1434f1204fed18938fedccb9edd4e1d 100644 (file)
  */
 #include <config_cmd_default.h>
 #define CONFIG_CMD_CACHE
+#define CONFIG_CMD_IIM
 #define CONFIG_CMD_MMC
 #define CONFIG_CMD_NAND
 #define CONFIG_CMD_MTDPARTS
 #define CONFIG_SYS_INIT_SP_ADDR                (CONFIG_SYS_SDRAM_BASE + 0x1000 - /* Fix this */ \
                                        GENERATED_GBL_DATA_SIZE)
 
+#ifdef CONFIG_CMD_IIM
+#define CONFIG_IMX_IIM
+#endif
+
 #endif /* __CONFIG_H */