From: Lothar Waßmann Date: Tue, 19 Jun 2012 14:54:50 +0000 (+0200) Subject: Added IIM support X-Git-Tag: KARO-2012-06-19~1 X-Git-Url: https://git.kernelconcepts.de/?p=karo-tx-uboot.git;a=commitdiff_plain;h=03f633147e176157d366596e8f17fda3982f7600 Added IIM support --- diff --git a/arch/arm/include/asm/arch-mx5/imx-regs.h b/arch/arm/include/asm/arch-mx5/imx-regs.h index 972f68bd9e..fb5af6d909 100644 --- a/arch/arm/include/asm/arch-mx5/imx-regs.h +++ b/arch/arm/include/asm/arch-mx5/imx-regs.h @@ -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__ */ diff --git a/common/cmd_iim.c b/common/cmd_iim.c index 56e38048a9..cebe9b7622 100644 --- a/common/cmd_iim.c +++ b/common/cmd_iim.c @@ -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 + * * See file CREDITS for list of people who contributed to this * project. * @@ -27,13 +29,13 @@ * MA 02111-1307 USA */ +#include +#include #include #include -#include -#include -#include +#include -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, diff --git a/drivers/misc/imx_iim.c b/drivers/misc/imx_iim.c index 4bbd4ca416..0438ec7eff 100644 --- a/drivers/misc/imx_iim.c +++ b/drivers/misc/imx_iim.c @@ -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 + * * See file CREDITS for list of people who contributed to this * project. * @@ -28,26 +30,16 @@ * MA 02111-1307 USA */ -#include -#include -#include #include #include +#include +#include +#include +#include -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", diff --git a/drivers/net/fec_mxc.h b/drivers/net/fec_mxc.h index 852b2e07e7..c812473364 100644 --- a/drivers/net/fec_mxc.h +++ b/drivers/net/fec_mxc.h @@ -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 */ diff --git a/include/configs/tx51.h b/include/configs/tx51.h index 319b96d508..91dfa2dec1 100644 --- a/include/configs/tx51.h +++ b/include/configs/tx51.h @@ -161,6 +161,7 @@ */ #include #define CONFIG_CMD_CACHE +#define CONFIG_CMD_IIM #define CONFIG_CMD_MMC #define CONFIG_CMD_NAND #define CONFIG_CMD_MTDPARTS @@ -286,4 +287,8 @@ #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 */