*/
 
 #include <common.h>
+#if defined(CONFIG_MGCOGE)
 #include <mpc8260.h>
+#endif
 #include <ioports.h>
 #include <malloc.h>
 #include <hush.h>
+#include <net.h>
+#include <asm/io.h>
 
 #if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
 #include <libfdt.h>
 
 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
 #include <i2c.h>
-#endif
-#include <asm/io.h>
 
 extern int i2c_soft_read_pin (void);
 
 #endif
 }
 #endif
+#endif
 
 #if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
 int fdt_set_node_and_value (void *blob,
        return ret;
 }
 #endif
+
+int ethernet_present (void)
+{
+       return (in_8((u8 *)CONFIG_SYS_PIGGY_BASE + CONFIG_SYS_SLOT_ID_OFF) & 0x80);
+}
+
+int board_eth_init (bd_t *bis)
+{
+#ifdef CONFIG_KEYMILE_HDLC_ENET
+       (void)keymile_hdlc_enet_initialize (bis);
+#endif
+       if (ethernet_present ()) {
+               return -1;
+       }
+       return 0;
+}
 
--- /dev/null
+/*
+ * (C) Copyright 2008
+ * Heiko Schocher, DENX Software Engineering, hs@denx.de.
+ *
+ * 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.
+ */
+
+#ifndef __KEYMILE_COMMON_H
+#define __KEYMILE_COMMON_H
+
+int ethernet_present (void);
+int ivm_read_eeprom (void);
+
+#ifdef CONFIG_KEYMILE_HDLC_ENET
+int keymile_hdlc_enet_initialize (bd_t *bis);
+#endif
+#endif /* __KEYMILE_COMMON_H */
 
 #
 
 include $(TOPDIR)/config.mk
+ifneq ($(OBJTREE),$(SRCTREE))
+$(shell mkdir -p $(obj)../common)
+endif
 
 LIB    = $(obj)lib$(BOARD).a
 
-COBJS-y += $(BOARD).o
+COBJS  += $(BOARD).o ../common/common.o
 
-COBJS  := $(COBJS-y)
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
 SOBJS  := $(addprefix $(obj),$(SOBJS))
 
 #include <pci.h>
 #include <libfdt.h>
 
+#include "../common/common.h"
+
 const qe_iop_conf_t qe_iop_conf_tab[] = {
        /* port pin dir open_drain assign */
 
 
 int checkboard (void)
 {
-       puts ("Board: Keymile kmeter1\n");
+       puts ("Board: Keymile kmeter1");
+       if (ethernet_present ())
+               puts (" with PIGGY.");
+       puts ("\n");
        return 0;
 }
 
 
 #include <mpc8260.h>
 #include <ioports.h>
 #include <malloc.h>
+#include <net.h>
 #include <asm/io.h>
 
 #if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
 #include <i2c.h>
 #endif
 
-extern int ivm_read_eeprom (void);
+#include "../common/common.h"
+
 /*
  * I/O Port configuration table
  *
 
 int checkboard(void)
 {
-       puts ("Board: mgcoge\n");
-
+       puts ("Board: Keymile mgcoge");
+       if (ethernet_present ())
+               puts (" with PIGGY.");
+       puts ("\n");
        return 0;
 }
 
 
  */
 #include <common.h>
 #include <mpc8xx.h>
+#include <net.h>
 #include <asm/io.h>
 
 #if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
 #include <libfdt.h>
 #endif
 
-extern int ivm_read_eeprom (void);
+#include "../common/common.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
 
 int checkboard (void)
 {
-       puts ("Board: Keymile mgsuvd\n");
+       puts ("Board: Keymile mgsuvd");
+       if (ethernet_present ())
+               puts (" with PIGGY.");
+       puts ("\n");
        return (0);
 }
 
 
 #define CONFIG_LOADS_ECHO      1       /* echo on for serial download */
 #define CONFIG_SYS_LOADS_BAUD_CHANGE   1       /* allow baudrate change */
 
+/*
+ * How to get access to the slot ID.  Put this here to make it easy
+ * to modify in a centralized location.  This is used in the HDLC
+ * driver to set the MAC.
+*/
+#define CONFIG_SYS_SLOT_ID_BASE                CONFIG_SYS_PIGGY_BASE
+#define CONFIG_SYS_SLOT_ID_OFF         (0x07)  /* register offset */
+#define CONFIG_SYS_SLOT_ID_MASK                (0x3f)  /* mask for slot ID bits */
+
 /*
  * BOOTP options
  */
 
 #define OF_TBCLK               (bd->bi_busfreq / 4)
 #define OF_STDOUT_PATH         "/soc/cpm/serial@11a90"
 
+/*
+ * How to get access to the slot ID.  Put this here to make it easy
+ * to modify in a centralized location.  This is used in the HDLC
+ * driver to set the MAC.
+*/
+#define CONFIG_SYS_SLOT_ID_BASE                CONFIG_SYS_PIGGY_BASE
+#define CONFIG_SYS_SLOT_ID_OFF         (0x07)  /* register offset */
+#define CONFIG_SYS_SLOT_ID_MASK                (0x3f)  /* mask for slot ID bits */
+
+
 #endif /* __CONFIG_H */
 
 #define CONFIG_ENV_OFFSET_REDUND       (CONFIG_ENV_OFFSET+CONFIG_ENV_SECT_SIZE)
 #define CONFIG_ENV_SIZE_REDUND (CONFIG_ENV_SIZE)
 
+/*
+ * How to get access to the slot ID.  Put this here to make it easy
+ * to modify in a centralized location.  This is used in the HDLC
+ * driver to set the MAC.
+*/
+#define CONFIG_SYS_SLOT_ID_BASE                CONFIG_SYS_PIGGY_BASE
+#define CONFIG_SYS_SLOT_ID_OFF         (0x07)  /* register offset */
+#define CONFIG_SYS_SLOT_ID_MASK                (0x3f)  /* mask for slot ID bits */
+
 /*-----------------------------------------------------------------------
  * Cache Configuration
  */