summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Loeliger <jdl@freescale.com>2006-07-13 10:58:28 -0500
committerJon Loeliger <jdl@freescale.com>2006-07-13 10:58:28 -0500
commit0f2859689a283ecb0e3d29e23ff7e21dbb6abb70 (patch)
treea597adf57ec6ec95a650edbbb040d287ea2faaa4
parentde07a6a59c47fb83699f7bea715e25661957baa0 (diff)
parentbea3f28d285942bf3f7ab339ce85178ded544225 (diff)
downloadu-boot-imx-0f2859689a283ecb0e3d29e23ff7e21dbb6abb70.zip
u-boot-imx-0f2859689a283ecb0e3d29e23ff7e21dbb6abb70.tar.gz
u-boot-imx-0f2859689a283ecb0e3d29e23ff7e21dbb6abb70.tar.bz2
Merge branch 'mpc86xx'
-rw-r--r--board/mpc8641hpcn/Makefile2
-rw-r--r--board/mpc8641hpcn/sys_eeprom.c244
-rw-r--r--common/Makefile2
-rw-r--r--common/cmd_bootm.c1
-rw-r--r--common/cmd_mac.c66
-rw-r--r--include/common.h3
-rw-r--r--include/configs/MPC8641HPCN.h3
-rw-r--r--lib_ppc/board.c4
8 files changed, 322 insertions, 3 deletions
diff --git a/board/mpc8641hpcn/Makefile b/board/mpc8641hpcn/Makefile
index 060db84..0ebed87 100644
--- a/board/mpc8641hpcn/Makefile
+++ b/board/mpc8641hpcn/Makefile
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
LIB = lib$(BOARD).a
-OBJS := $(BOARD).o pixis.o oftree.o
+OBJS := $(BOARD).o pixis.o sys_eeprom.o oftree.o
SOBJS := init.o
$(LIB): $(OBJS) $(SOBJS)
diff --git a/board/mpc8641hpcn/sys_eeprom.c b/board/mpc8641hpcn/sys_eeprom.c
new file mode 100644
index 0000000..733a57f
--- /dev/null
+++ b/board/mpc8641hpcn/sys_eeprom.c
@@ -0,0 +1,244 @@
+/*
+ * Copyright 2006 Freescale Semiconductor
+ * York Sun (yorksun@freescale.com)
+ * Haiying Wang (haiying.wang@freescale.com)
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <command.h>
+#include <i2c.h>
+#include <linux/ctype.h>
+
+#ifdef CFG_ID_EEPROM
+typedef struct {
+ unsigned char id[4]; /* 0x0000 - 0x0003 */
+ unsigned char sn[12]; /* 0x0004 - 0x000F */
+ unsigned char errata[5];/* 0x0010 - 0x0014 */
+ unsigned char date[7]; /* 0x0015 - 0x001a */
+ unsigned char res_1[37];/* 0x001b - 0x003f */
+ unsigned char tab_size; /* 0x0040 */
+ unsigned char tab_flag; /* 0x0041 */
+ unsigned char mac[8][6];/* 0x0042 - 0x0071 */
+ unsigned char res_2[126];/* 0x0072 - 0x00ef */
+ unsigned int crc; /* 0x00f0 - 0x00f3 crc32 checksum */
+} EEPROM_data;
+
+static EEPROM_data mac_data;
+
+int mac_show(void)
+{
+ int i;
+ unsigned char ethaddr[8][18];
+
+ printf("ID %c%c%c%c\n", mac_data.id[0],\
+ mac_data.id[1],\
+ mac_data.id[2],\
+ mac_data.id[3]);
+ printf("Errata %c%c%c%c%c\n", mac_data.errata[0],\
+ mac_data.errata[1],\
+ mac_data.errata[2],\
+ mac_data.errata[3],\
+ mac_data.errata[4]);
+ printf("Date %c%c%c%c%c%c%c\n", mac_data.date[0],\
+ mac_data.date[1],\
+ mac_data.date[2],\
+ mac_data.date[3],\
+ mac_data.date[4],\
+ mac_data.date[5],\
+ mac_data.date[6]);
+ for (i = 0; i < 8; i++) {
+ sprintf(ethaddr[i],"%02x:%02x:%02x:%02x:%02x:%02x",\
+ mac_data.mac[i][0],\
+ mac_data.mac[i][1],\
+ mac_data.mac[i][2],\
+ mac_data.mac[i][3],\
+ mac_data.mac[i][4],\
+ mac_data.mac[i][5]);
+ printf("MAC %d %s\n", i, ethaddr[i]);
+ }
+
+ setenv("ethaddr", ethaddr[0]);
+ setenv("eth1addr", ethaddr[1]);
+ setenv("eth2addr", ethaddr[2]);
+ setenv("eth3addr", ethaddr[3]);
+
+ return 0;
+}
+
+int mac_read(void)
+{
+ int ret,length;
+ unsigned int crc = 0;
+ unsigned char dev = ID_EEPROM_ADDR, *data;
+
+ length = sizeof(EEPROM_data);
+ ret = i2c_read(dev, 0, 1, (unsigned char *)(&mac_data), length);
+ if (ret) {
+ printf("Read failed.\n");
+ return -1;
+ }
+
+ data = (unsigned char *)(&mac_data);
+ printf("Check CRC on reading ...");
+ crc = crc32(crc, data, length-4);
+ if (crc != mac_data.crc) {
+ printf("CRC checksum is invalid, in EEPROM CRC is %x, calculated CRC is %x\n",mac_data.crc,crc);
+ return -1;
+ }
+ else {
+ printf("CRC OK\n");
+ mac_show();
+ }
+ return 0;
+}
+
+int mac_prog(void)
+{
+ int ret, i, length;
+ unsigned int crc = 0;
+ unsigned char dev = ID_EEPROM_ADDR,*ptr;
+ unsigned char * eeprom_data = (unsigned char *)(&mac_data);
+
+ for (i = 0; i < sizeof(mac_data.res_1); i++)
+ mac_data.res_1[i] = 0;
+ for (i = 0;i < sizeof(mac_data.res_2); i++)
+ mac_data.res_2[i] = 0;
+ length = sizeof(EEPROM_data);
+ crc = crc32 (crc, eeprom_data, length-4);
+ mac_data.crc = crc;
+ for (i = 0, ptr = eeprom_data; i < length; i += 8, ptr += 8) {
+ ret = i2c_write(dev, i, 1, ptr, (length-i) <8 ? (length-i) : 8);
+ udelay(5000); /* 5ms write cycle timing */
+ if (ret)
+ break;
+ }
+ if (ret) {
+ printf("Programming failed.\n");
+ return -1;
+ }
+ else {
+ printf("Programming %d bytes. Reading back ...\n",length);
+ mac_read();
+ }
+ return 0;
+}
+
+int do_mac (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ int i;
+ char cmd = 's';
+ unsigned long long mac_val;
+
+ if(i2c_probe(ID_EEPROM_ADDR) != 0)
+ return -1;
+
+ if(argc>1) {
+ cmd = argv[1][0];
+ switch (cmd) {
+ case 'r': /* display */
+ mac_read();
+ break;
+ case 's': /* save */
+ mac_prog();
+ break;
+ case 'i': /* id */
+ for (i=0; i<4; i++) {
+ mac_data.id[i] = argv[2][i];
+ }
+ break;
+ case 'n': /* serial number */
+ for (i=0; i<12; i++) {
+ mac_data.sn[i] = argv[2][i];
+ }
+ break;
+ case 'e': /* errata */
+ for (i=0; i<5; i++) {
+ mac_data.errata[i] = argv[2][i];
+ }
+ break;
+ case 'd': /* date */
+ for (i=0; i<7; i++) {
+ mac_data.date[i] = argv[2][i];
+ }
+ break;
+ case 'p': /* number of ports */
+ mac_data.tab_size = (unsigned char)simple_strtoul(argv[2],NULL,16);
+ break;
+ case '0': /* mac 0 */
+ case '1': /* mac 1 */
+ case '2': /* mac 2 */
+ case '3': /* mac 3 */
+ case '4': /* mac 4 */
+ case '5': /* mac 5 */
+ case '6': /* mac 6 */
+ case '7': /* mac 7 */
+ mac_val = simple_strtoull(argv[2],NULL,16);
+ for (i=0; i<6; i++) {
+ mac_data.mac[cmd-'0'][i] = *((unsigned char *)(((unsigned int)(&mac_val))+i+2));
+ }
+ break;
+ case 'h': /* help */
+ default:
+ printf ("Usage:\n%s\n", cmdtp->usage);
+ break;
+ }
+ }
+ else {
+ mac_show();
+ }
+ return 0;
+}
+
+int mac_read_from_eeprom(void)
+{
+ int length,i;
+ unsigned char dev = ID_EEPROM_ADDR, *data, ethaddr[4][18], enetvar[32];
+ unsigned int crc = 0;
+
+ length = sizeof(EEPROM_data);
+ if(i2c_read (dev, 0, 1, (unsigned char *)(&mac_data), length)) {
+ printf("Read failed.\n");
+ return -1;
+ }
+
+ data = (unsigned char *)(&mac_data);
+ crc = crc32(crc, data, length-4);
+ if (crc != mac_data.crc) {
+ return -1;
+ }
+ else {
+ for(i=0; i<4; i++) {
+ if(memcmp(&mac_data.mac[i], "\0\0\0\0\0\0", 6)) {
+ sprintf(ethaddr[i], "%02x:%02x:%02x:%02x:%02x:%02x", \
+ mac_data.mac[i][0], \
+ mac_data.mac[i][1], \
+ mac_data.mac[i][2], \
+ mac_data.mac[i][3], \
+ mac_data.mac[i][4], \
+ mac_data.mac[i][5]);
+ sprintf(enetvar, i ? "eth%daddr" : "ethaddr", i);
+ setenv(enetvar, ethaddr[i]);
+ }
+ }
+ }
+ return 0;
+}
+#endif /* CFG_ID_EEPROM */
diff --git a/common/Makefile b/common/Makefile
index eb0b5da..a62bc16 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -51,7 +51,7 @@ COBJS = main.o ACEX1K.o altera.o bedbug.o circbuf.o \
memsize.o miiphybb.o miiphyutil.o \
s_record.o serial.o soft_i2c.o soft_spi.o spartan2.o spartan3.o \
usb.o usb_kbd.o usb_storage.o \
- virtex2.o xilinx.o crc16.o xyzModem.o
+ virtex2.o xilinx.o crc16.o xyzModem.o cmd_mac.o
OBJS = $(AOBJS) $(COBJS)
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c
index a78a16d..e5d70fa 100644
--- a/common/cmd_bootm.c
+++ b/common/cmd_bootm.c
@@ -538,7 +538,6 @@ do_bootm_linux (cmd_tbl_t *cmdtp, int flag,
initrd_copy_to_ram = 0;
} else { /* not set, no restrictions to load high */
initrd_high = ~0;
- initrd_copy_to_ram = 0;
}
#ifdef CONFIG_LOGBUFFER
diff --git a/common/cmd_mac.c b/common/cmd_mac.c
new file mode 100644
index 0000000..0add432
--- /dev/null
+++ b/common/cmd_mac.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2006 Freescale Semiconductor
+ * York Sun (yorksun@freescale.com)
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <command.h>
+
+#ifdef CFG_ID_EEPROM
+
+extern int do_mac(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
+
+U_BOOT_CMD(
+ mac, 3, 1, do_mac,
+ "mac - display and program the system ID and MAC addresses in EEPROM\n",
+ "[read|save|id|num|errata|date|ports|0|1|2|3|4|5|6|7]\n"
+ "read\n"
+ " - show content of mac\n"
+ "mac save\n"
+ " - save to the EEPROM\n"
+ "mac id\n"
+ " - program system id\n"
+ "mac num\n"
+ " - program system serial number\n"
+ "mac errata\n"
+ " - program errata data\n"
+ "mac date\n"
+ " - program data date\n"
+ "mac ports\n"
+ " - program the number of ports\n"
+ "mac 0\n"
+ " - program the MAC address for port 0\n"
+ "mac 1\n"
+ " - program the MAC address for port 1\n"
+ "mac 2\n"
+ " - program the MAC address for port 2\n"
+ "mac 3\n"
+ " - program the MAC address for port 3\n"
+ "mac 4\n"
+ " - program the MAC address for port 4\n"
+ "mac 5\n"
+ " - program the MAC address for port 5\n"
+ "mac 6\n"
+ " - program the MAC address for port 6\n"
+ "mac 7\n"
+ " - program the MAC address for port 7\n"
+);
+#endif /* CFG_ID_EEPROM */
diff --git a/include/common.h b/include/common.h
index 83ccf7c..7e54da9 100644
--- a/include/common.h
+++ b/include/common.h
@@ -197,6 +197,9 @@ int checkdram (void);
char * strmhz(char *buf, long hz);
int last_stage_init(void);
extern ulong monitor_flash_len;
+#ifdef CFG_ID_EEPROM
+int mac_read_from_eeprom(void);
+#endif
/* common/flash.c */
void flash_perror (int);
diff --git a/include/configs/MPC8641HPCN.h b/include/configs/MPC8641HPCN.h
index b089769..7e91e64 100644
--- a/include/configs/MPC8641HPCN.h
+++ b/include/configs/MPC8641HPCN.h
@@ -100,6 +100,7 @@
*/
#define CFG_DDR_SDRAM_BASE 0x00000000 /* DDR is system memory*/
#define CFG_SDRAM_BASE CFG_DDR_SDRAM_BASE
+#define CONFIG_VERY_BIG_RAM
#define MPC86xx_DDR_SDRAM_CLK_CNTL
@@ -145,6 +146,8 @@
#define CFG_DDR_CS5_BNDS 0x00000FFF /* Not done */
#endif
+#define CFG_ID_EEPROM 1
+#define ID_EEPROM_ADDR 0x57
/*
* In MPC8641HPCN, allocate 16MB flash spaces at fe000000 and ff000000.
diff --git a/lib_ppc/board.c b/lib_ppc/board.c
index c367b3e..2c29f46 100644
--- a/lib_ppc/board.c
+++ b/lib_ppc/board.c
@@ -862,6 +862,10 @@ void board_init_r (gd_t *id, ulong dest_addr)
}
#endif
+#ifdef CFG_ID_EEPROM
+ mac_read_from_eeprom();
+#endif
+
#if defined(CONFIG_TQM8xxL) || defined(CONFIG_TQM8260) || \
defined(CONFIG_CCM) || defined(CONFIG_KUP4K) || defined(CONFIG_KUP4X)
load_sernum_ethaddr ();