浏览代码

boards: get mac address from env and move load_sernum_ethaddr() to board init

The environment is the canonical storage location of the mac address, so
we're killing off the global data location and moving everything to
querying the env directly.

Rather than have common ppc code call a board-specific function like
load_sernum_ethaddr(), have each board call it in its own board-specific
misc_init_r() function.

The boards that get converted here are:
	- kup4k/kup4x
	- pcs440ep
	- tqm8xx

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
CC: Ben Warren <biggerbadderben@gmail.com>
CC: Stefan Roese <sr@denx.de>
Mike Frysinger 16 年之前
父节点
当前提交
9c150102bc
共有 8 个文件被更改,包括 21 次插入31 次删除
  1. 2 0
      board/kup/common/kup.h
  2. 1 0
      board/kup/kup4k/kup4k.c
  3. 1 1
      board/kup/kup4x/kup4x.c
  4. 0 5
      board/m501sk/m501sk.c
  5. 14 17
      board/pcs440ep/pcs440ep.c
  6. 3 0
      board/tqc/tqm8xx/tqm8xx.c
  7. 0 2
      include/common.h
  8. 0 6
      lib_ppc/board.c

+ 2 - 0
board/kup/common/kup.h

@@ -41,4 +41,6 @@
 
 
 extern void poweron_key (void);
 extern void poweron_key (void);
 
 
+extern void load_sernum_ethaddr(void);
+
 #endif	/* __KUP_H */
 #endif	/* __KUP_H */

+ 1 - 0
board/kup/kup4k/kup4k.c

@@ -250,6 +250,7 @@ int misc_init_r (void)
 	immap->im_ioport.iop_papar &= ~0x80;
 	immap->im_ioport.iop_papar &= ~0x80;
 	immap->im_ioport.iop_padat |= 0x80;	/* turn it off */
 	immap->im_ioport.iop_padat |= 0x80;	/* turn it off */
 #endif
 #endif
+	load_sernum_ethaddr();
 	setenv("hw","4k");
 	setenv("hw","4k");
 	poweron_key();
 	poweron_key();
 	return (0);
 	return (0);

+ 1 - 1
board/kup/kup4x/kup4x.c

@@ -295,7 +295,6 @@ static long int dram_size (long int mamr_value, long int *base,
 int misc_init_r (void)
 int misc_init_r (void)
 {
 {
 	volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
 	volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
-
 #ifdef CONFIG_IDE_LED
 #ifdef CONFIG_IDE_LED
 	/* Configure PA8 as output port */
 	/* Configure PA8 as output port */
 	immap->im_ioport.iop_padir |= 0x80;
 	immap->im_ioport.iop_padir |= 0x80;
@@ -306,6 +305,7 @@ int misc_init_r (void)
 #ifdef KUP4X_USB
 #ifdef KUP4X_USB
 	usb_init_kup4x ();
 	usb_init_kup4x ();
 #endif
 #endif
+	load_sernum_ethaddr();
 	setenv ("hw", "4x");
 	setenv ("hw", "4x");
 	poweron_key ();
 	poweron_key ();
 	return (0);
 	return (0);

+ 0 - 5
board/m501sk/m501sk.c

@@ -105,11 +105,6 @@ uchar m501sk_gpio_clear(M501SK_PIO io)
 	return status;
 	return status;
 }
 }
 
 
-void load_sernum_ethaddr(void)
-{
-	return;
-}
-
 /*
 /*
  * Miscelaneous platform dependent initialisations
  * Miscelaneous platform dependent initialisations
  */
  */

+ 14 - 17
board/pcs440ep/pcs440ep.c

@@ -182,14 +182,21 @@ int board_early_init_f(void)
 }
 }
 
 
 #define EEPROM_LEN	256
 #define EEPROM_LEN	256
-void load_sernum_ethaddr (void)
+static void load_ethaddr(void)
 {
 {
+	int	ok_ethaddr, ok_eth1addr;
 	int	ret;
 	int	ret;
 	char	buf[EEPROM_LEN];
 	char	buf[EEPROM_LEN];
 	char	mac[32];
 	char	mac[32];
 	char	*use_eeprom;
 	char	*use_eeprom;
 	u16	checksumcrc16 = 0;
 	u16	checksumcrc16 = 0;
 
 
+	/* If the env is sane, then nothing for us to do */
+	ok_ethaddr = eth_getenv_enetaddr("ethaddr", buf);
+	ok_eth1addr = eth_getenv_enetaddr("eth1addr", buf);
+	if (ok_ethaddr && ok_eth1addr)
+		return;
+
 	/* read the MACs from EEprom */
 	/* read the MACs from EEprom */
 	status_led_set (0, STATUS_LED_ON);
 	status_led_set (0, STATUS_LED_ON);
 	status_led_set (1, STATUS_LED_ON);
 	status_led_set (1, STATUS_LED_ON);
@@ -207,22 +214,10 @@ void load_sernum_ethaddr (void)
 			printf("%s: EEPROM Checksum not OK\n", __FUNCTION__);
 			printf("%s: EEPROM Checksum not OK\n", __FUNCTION__);
 		} else {
 		} else {
 			/* get the MACs */
 			/* get the MACs */
-			sprintf (mac, "%02x:%02x:%02x:%02x:%02x:%02x",
-				buf[3],
-				buf[4],
-				buf[5],
-				buf[6],
-				buf[7],
-				buf[8]);
-			setenv ("ethaddr", (char *) mac);
-			sprintf (mac, "%02x:%02x:%02x:%02x:%02x:%02x",
-				buf[9],
-				buf[10],
-				buf[11],
-				buf[12],
-				buf[13],
-				buf[14]);
-			setenv ("eth1addr", (char *) mac);
+			if (!ok_ethaddr)
+				eth_setenv_enetaddr("ethaddr", &buf[3]);
+			if (!ok_eth1addr)
+				eth_setenv_enetaddr("eth1addr", &buf[9]);
 			return;
 			return;
 		}
 		}
 	}
 	}
@@ -446,6 +441,8 @@ int misc_init_r (void)
 	uint pbcr;
 	uint pbcr;
 	int size_val = 0;
 	int size_val = 0;
 
 
+	load_ethaddr();
+
 	/* Re-do sizing to get full correct info */
 	/* Re-do sizing to get full correct info */
 	mtdcr(ebccfga, pb0cr);
 	mtdcr(ebccfga, pb0cr);
 	pbcr = mfdcr(ebccfgd);
 	pbcr = mfdcr(ebccfgd);

+ 3 - 0
board/tqc/tqm8xx/tqm8xx.c

@@ -449,11 +449,14 @@ int board_early_init_r (void)
 
 
 
 
 #ifdef CONFIG_MISC_INIT_R
 #ifdef CONFIG_MISC_INIT_R
+extern void load_sernum_ethaddr(void);
 int misc_init_r (void)
 int misc_init_r (void)
 {
 {
 	volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
 	volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
 	volatile memctl8xx_t *memctl = &immap->im_memctl;
 	volatile memctl8xx_t *memctl = &immap->im_memctl;
 
 
+	load_sernum_ethaddr();
+
 #ifdef	CONFIG_SYS_OR_TIMING_FLASH_AT_50MHZ
 #ifdef	CONFIG_SYS_OR_TIMING_FLASH_AT_50MHZ
 	int scy, trlx, flash_or_timing, clk_diff;
 	int scy, trlx, flash_or_timing, clk_diff;
 
 

+ 0 - 2
include/common.h

@@ -364,8 +364,6 @@ void  display_mem_map(void);
 void  perform_soft_reset(void);
 void  perform_soft_reset(void);
 #endif
 #endif
 
 
-void	load_sernum_ethaddr (void);
-
 /* $(BOARD)/$(BOARD).c */
 /* $(BOARD)/$(BOARD).c */
 int board_early_init_f (void);
 int board_early_init_f (void);
 int board_late_init (void);
 int board_late_init (void);

+ 0 - 6
lib_ppc/board.c

@@ -943,12 +943,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
 	}
 	}
 #endif
 #endif
 
 
-#if defined(CONFIG_TQM8xxL) || defined(CONFIG_TQM8260) || \
-    defined(CONFIG_TQM8272) || \
-    defined(CONFIG_CCM) || defined(CONFIG_KUP4K) || \
-    defined(CONFIG_KUP4X) || defined(CONFIG_PCS440EP)
-	load_sernum_ethaddr ();
-#endif
 	/* IP Address */
 	/* IP Address */
 	bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
 	bd->bi_ip_addr = getenv_IPaddr ("ipaddr");