summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Miguel Sanchez Sanabria <jsanabria@iseebcn.com>2018-11-23 14:51:47 +0100
committerJose Miguel Sanchez Sanabria <jsanabria@iseebcn.com>2018-11-23 14:51:47 +0100
commit042a7cb1e4163b6811f3859af308ca13c1ec9390 (patch)
tree99fe2f0d2fa97fb79c40a4cb7aae1bd0bef9d746
parent5d3f554d5eb2b5dc27b28a8c84d1fdfb9cfb1ab8 (diff)
downloadu-boot-imx-042a7cb1e4163b6811f3859af308ca13c1ec9390.zip
u-boot-imx-042a7cb1e4163b6811f3859af308ca13c1ec9390.tar.gz
u-boot-imx-042a7cb1e4163b6811f3859af308ca13c1ec9390.tar.bz2
IGEP0046: igep eeprom struct + mac address management to linux
Signed-off-by: Jose Miguel Sanchez Sanabria <jsanabria@iseebcn.com>
-rw-r--r--board/isee/common/igep_common.h21
-rw-r--r--board/isee/igep0046/igep0046.c88
-rw-r--r--board/isee/igep0046/igep0046_eeprom.c9
-rw-r--r--board/isee/igep0046/igep0046_eeprom.h1
-rw-r--r--include/configs/igep0046.h16
5 files changed, 88 insertions, 47 deletions
diff --git a/board/isee/common/igep_common.h b/board/isee/common/igep_common.h
index 1e58c8a..17ec5dd 100644
--- a/board/isee/common/igep_common.h
+++ b/board/isee/common/igep_common.h
@@ -11,20 +11,19 @@
#ifndef __COMMON_HEADER__
#define __COMMON_HEADER__
+#define IGEP_MAGIC_ID 0x6D6A6DE4
+
struct __attribute__((packed)) igep_mf_setup {
u32 magic_id; /* eeprom magic id */
u32 crc32; /* eeprom crc32 */
- char board_uuid [37]; /* board identifier */
- char board_pid [20]; /* product identifier */
- char name [20]; /* board name */
- char model [10]; /* board model */
- char pcb_version [10]; /* board version */
- char assembly_rev[10]; /* board revision */
- char board_manufacturer[30]; /* board manufacturer */
- char manf_of[10]; /* manufacturer order of fabrication */
- char manf_timestamp[16]; /* manufacturer timestamp */
- uchar bmac0[6]; /* MAC 0 - default */
- uchar bmac1[6]; /* MAC 1 */
+ char board_uuid [36]; /* board identifier */
+ char board_pid [16]; /* product identifier */
+ char model [8]; /* board model */
+ char variant [9]; /* board version */
+ char manf_of[6]; /* manufacturer order of fabrication */
+ char manf_timestamp[19]; /* manufacturer timestamp */
+ uchar bmac0[17]; /* MAC 0 - default */
+ uchar bmac1[17]; /* MAC 1 */
};
#endif
diff --git a/board/isee/igep0046/igep0046.c b/board/isee/igep0046/igep0046.c
index 85c983e..2843de6 100644
--- a/board/isee/igep0046/igep0046.c
+++ b/board/isee/igep0046/igep0046.c
@@ -181,8 +181,9 @@ static iomux_v3_cfg_t const init_pads[] =
MX6_PAD_CSI0_DAT7__GPIO5_IO25 | MUX_PAD_CTRL(NO_PAD_CTRL),
#endif
};
-
-const uchar igep_mac0 [6] = { 0x02, 0x00, 0x00, 0x00, 0x00, 0xff };
+#define STATION 0x01
+const uchar igep_mac0 [6] = { 0x02, 0xBA, 0xD0, 0xBA, 0xD0, STATION };
+uchar enetaddr[6];
static int igep_eeprom_valid = 0;
static struct igep_mf_setup igep0046_eeprom_config;
@@ -375,17 +376,28 @@ int board_phy_config(struct phy_device *phydev)
return 0;
}
-const uchar* get_mac_address (void)
+
+static int get_mac_address (void)
{
- if(igep_eeprom_valid)
- return igep0046_eeprom_config.bmac0;
- return igep_mac0;
+ // MAC are 17 ASCII characters so we need to work it out a bit
+ int i = 0;
+ uchar ans[6];
+
+ if(igep_eeprom_valid){
+ for (i = 0; i < 6; i++){
+ ans[i] = parse_char(igep0046_eeprom_config.bmac0[(i*3)]) * 0x10 + parse_char(igep0046_eeprom_config.bmac0[((i*3)+1)]);
+ }
+ memcpy(enetaddr, ans, 6);
+ //memcpy(enetaddr, igep_mac0, 6);
+ }else{
+ memcpy(enetaddr, igep_mac0, 6);
+ }
+ return eth_setenv_enetaddr("ethaddr", enetaddr);
}
int board_eth_init(bd_t *bis)
{
-
- eth_setenv_enetaddr("ethaddr", get_mac_address());
+ get_mac_address();
setup_iomux_enet();
#ifdef CONFIG_FEC_MXC
cpu_eth_init(bis);
@@ -414,8 +426,6 @@ int board_early_init_f(void)
int board_init(void)
{
- u32 crc_value = 0;
- u32 crc_save_value = 0;
#ifdef CONFIG_BASE0040
reset_audio();
@@ -427,24 +437,6 @@ int board_init(void)
mdelay(1);
#endif
- if(check_eeprom() != 0){
- printf("EEPROM: not found\n");
- }else{
- /* Read configuration from eeprom */
- if(eeprom46_read_setup(0, (char*) &igep0046_eeprom_config, sizeof(struct igep_mf_setup)))
- printf("EEPROM: read fail\n");
- /* Verify crc32 */
- crc_save_value = igep0046_eeprom_config.crc32;
- igep0046_eeprom_config.crc32 = 0;
- crc_value = crc32(0, (const unsigned char*) &igep0046_eeprom_config, sizeof(struct igep_mf_setup));
- if(crc_save_value != crc_value){
- printf("EEPROM: CRC32 failed. Loading default MAC\n");
- }else{
- printf("EEPROM: CRC32 OK! Loading MAC from eeprom\n");
- igep_eeprom_valid = 1;
- }
- }
-
#ifdef CONFIG_BASE0040
reset_usb_hub();
#endif
@@ -488,8 +480,46 @@ static inline unsigned int pcb_version(void)
int board_late_init(void)
{
+
+ u32 crc_value = 0;
+ u32 crc_save_value;
+
+ if(check_eeprom() != 0){
+ printf("EEPROM: not found\n");
+ }else{
+ /* Read configuration from eeprom */
+ if(eeprom46_read_setup(0, (char*) &igep0046_eeprom_config, sizeof(struct igep_mf_setup)))
+ printf("EEPROM: read fail\n");
+ /* Verify crc32 */
+
+ printf("EEPROM: read %d bytes \n", sizeof(struct igep_mf_setup));
+ printf("---------------------------- |!| IGEP STRUCT |!| ----------------------------\n");
+ printf("magic_id: 0x%x \n", igep0046_eeprom_config.magic_id);
+ printf("crc32: 0x%x \n", igep0046_eeprom_config.crc32);
+ printf("board_uuid: %.36s \n", igep0046_eeprom_config.board_uuid);
+ printf("board_pid: %.16s \n", igep0046_eeprom_config.board_pid);
+ printf("model: %.8s \n", igep0046_eeprom_config.model);
+ printf("variant: %.9s \n", igep0046_eeprom_config.variant);
+ printf("manf_of: %.6s \n", igep0046_eeprom_config.manf_of);
+ printf("manf_timestamp: %.19s \n", igep0046_eeprom_config.manf_timestamp);
+ printf("bmac0: %.17s \n", igep0046_eeprom_config.bmac0);
+ printf("bmac1: %.17s \n", igep0046_eeprom_config.bmac1);
+ printf("-----------------------------------------------------------------------------\n");
+
+
+ crc_save_value = igep0046_eeprom_config.crc32;
+ igep0046_eeprom_config.crc32 = 0;
+ crc_value = crc32(0, (const unsigned char*) &igep0046_eeprom_config, sizeof(struct igep_mf_setup));
+ printf("crc32 calculated: 0x%x \n", crc_value);
+ if(crc_save_value != crc_value){
+ printf("EEPROM: CRC32 failed. Loading default MAC\n");
+ }else{
+ printf("EEPROM: CRC32 OK! Loading MAC from eeprom\n");
+ igep_eeprom_valid = 1;
+ }
+ }
+
checkboard();
- puts("\n");
switch (pcb_version()) {
case PCB_REV_A:
puts("Board: MX6-IGEP0046 Rev A\n");
diff --git a/board/isee/igep0046/igep0046_eeprom.c b/board/isee/igep0046/igep0046_eeprom.c
index 33bf1f3..d484d23 100644
--- a/board/isee/igep0046/igep0046_eeprom.c
+++ b/board/isee/igep0046/igep0046_eeprom.c
@@ -60,3 +60,12 @@ int check_eeprom (void)
}
return 0;
}
+
+unsigned int parse_char(char c)
+{
+ if ('0' <= c && c <= '9') return c - '0';
+ if ('a' <= c && c <= 'f') return 10 + c - 'a';
+ if ('A' <= c && c <= 'F') return 10 + c - 'A';
+
+ return 0;
+} \ No newline at end of file
diff --git a/board/isee/igep0046/igep0046_eeprom.h b/board/isee/igep0046/igep0046_eeprom.h
index 0ed4f37..df739e0 100644
--- a/board/isee/igep0046/igep0046_eeprom.h
+++ b/board/isee/igep0046/igep0046_eeprom.h
@@ -14,4 +14,5 @@
int eeprom46_write_setup (uint8_t s_addr, const char* data, u32 size);
int eeprom46_read_setup (uint8_t s_addr, char* data, u32 size);
int check_eeprom (void);
+unsigned int parse_char(char c);
#endif
diff --git a/include/configs/igep0046.h b/include/configs/igep0046.h
index 46f155c..21b68df 100644
--- a/include/configs/igep0046.h
+++ b/include/configs/igep0046.h
@@ -217,6 +217,7 @@ else
"fdt_addr=0x18000000\0" \
"boot_fdt=try\0" \
"bootdir=\0" \
+ "ethaddr=\0" \
"ip_dyn=no\0" \
"console=" CONSOLE_DEV "\0" \
"fdt_high=0xffffffff\0" \
@@ -254,7 +255,7 @@ else
"setexpr fb $fb + 1; " \
"done\0" \
"mmcargs=setenv bootargs console=${console},${baudrate} " \
- "root=${mmcroot} " \
+ "root=${mmcroot} fec.macaddr=${ethaddr} " \
VIDEO_ARGS "\0" \
"loadbootenv=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${bootdir}${bootenv}\0" \
"importbootenv=echo Importing environment from mmc ...; " \
@@ -278,7 +279,7 @@ else
"bootz; " \
"fi;\0" \
"sataargs=setenv bootargs console=${console},${baudrate} " \
- "root=${sataroot} " \
+ "root=${sataroot} fec.macaddr=${ethaddr} " \
VIDEO_ARGS "\0" \
"loadimagesata=fatload sata 0:1 ${loadaddr} ${bootdir}${image}\0" \
"loadfdtsata=fatload sata 0:1 ${fdt_addr} ${bootdir}${fdt_file}\0" \
@@ -303,9 +304,9 @@ else
"bootz; " \
"fi;\0" \
"netargs=setenv bootargs console=${console},${baudrate} " \
- "root=/dev/nfs " \
- "ip=dhcp nfsroot=${serverip}:${rootnfs},v3,tcp " \
+ "root=/dev/nfs fec.macaddr=${ethaddr} " \
VIDEO_ARGS "\0" \
+ "ip=dhcp nfsroot=${serverip}:${rootnfs},v3,tcp " \
"netboot=echo Booting from net ...; " \
VIDEO_ARGS_SCRIPT \
"run netargs; " \
@@ -362,6 +363,7 @@ else
#define CONFIG_EXTRA_ENV_SETTINGS \
"bootenv=uEnv.txt\0" \
"bootdir=\0" \
+ "ethaddr=\0" \
"image=zImage\0" \
"fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \
"fdt_addr=0x18000000\0" \
@@ -403,7 +405,7 @@ else
"setexpr fb $fb + 1; " \
"done\0" \
"mmcargs=setenv bootargs console=${console},${baudrate} " \
- "root=${mmcroot} " \
+ "root=${mmcroot} fec.macaddr=${ethaddr} " \
VIDEO_ARGS "\0" \
"loadbootenv=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${bootdir}${bootenv}\0" \
"importbootenv=echo Importing environment from mmc ...; " \
@@ -427,7 +429,7 @@ else
"bootz; " \
"fi;\0" \
"sataargs=setenv bootargs console=${console},${baudrate} " \
- "root=${sataroot} " \
+ "root=${sataroot} fec.macaddr=${ethaddr} " \
VIDEO_ARGS "\0" \
"loadimagesata=fatload sata 0:1 ${loadaddr} ${bootdir}${image}\0" \
"loadfdtsata=fatload sata 0:1 ${fdt_addr} ${bootdir}${fdt_file}\0" \
@@ -452,7 +454,7 @@ else
"bootz; " \
"fi;\0" \
"netargs=setenv bootargs console=${console},${baudrate} " \
- "root=/dev/nfs " \
+ "root=/dev/nfs fec.macaddr=${ethaddr} " \
"ip=dhcp nfsroot=${serverip}:${rootnfs},v3,tcp " \
VIDEO_ARGS "\0" \
"netboot=echo Booting from net ...; " \