Skip to contentSkip to conversation

powerpc: keymile: Add a check for the PIGGY debug board

PATCH New Heiko Schocher 4 participants 5 messages Nov 20, 2008 – Jan 23, 2009

lore
Share & tools
lore
#0 lore raw

PATCH v3 3/4 powerpc: keymile: Add a check for the PIGGY debug board

Check the presence of the PIGGY on the keymile boards mgcoge, mgsuvd and kmeter1. If the PIGGY is not present, dont register this Ethernet device.

---

changes since v2:

- added comments from Ben Warren

 board/keymile/common/common.c   |   20 ++++++++++++++++++--
 board/keymile/common/common.h   |   16 ++++++++++++++++
 board/keymile/kmeter1/Makefile  |    6 ++++--
 board/keymile/kmeter1/kmeter1.c |    7 ++++++-
 board/keymile/mgcoge/mgcoge.c   |   10 +++++++---
 board/keymile/mgsuvd/mgsuvd.c   |    8 ++++++--
 include/configs/kmeter1.h       |    9 +++++++++
 include/configs/mgcoge.h        |   10 ++++++++++
 include/configs/mgsuvd.h        |    9 +++++++++
 9 files changed, 85 insertions(+), 10 deletions(-)
 create mode 100644 board/keymile/common/common.h
board/keymile/common/common.c +18 -2
index a4cf24c..cc30b36 100644
@@ -22,10 +22,14 @@
  */
 
 #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>
@@ -33,8 +37,6 @@
 
 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
 #include <i2c.h>
-#endif
-#include <asm/io.h>
 
 extern int i2c_soft_read_pin (void);
 
@@ -495,6 +497,7 @@ void i2c_init_board(void)
 #endif
 }
 #endif
+#endif
 
 #if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
 int fdt_set_node_and_value (void *blob,
@@ -521,3 +524,16 @@ 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)
+{
+	if (ethernet_present ()) {
+		return -1;
+	}
+	return 0;
+}
board/keymile/common/common.h new file +16 -0
new file mode 100644
index 0000000..4b9c650
@@ -0,0 +1,16 @@
+/*
+ * (C) Copyright 2008
+ * Heiko Schocher, DENX Software Engineering, hs at 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);
+#endif /* __KEYMILE_COMMON_H */
board/keymile/kmeter1/Makefile +4 -2
index 88b79f3..12a1518 100644
@@ -22,12 +22,14 @@
 #
 
 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))
board/keymile/kmeter1/kmeter1.c +6 -1
index f9a59a6..d6b9c8f 100644
@@ -27,6 +27,8 @@
 #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 */
 
@@ -141,7 +143,10 @@ phys_size_t initdram (int board_type)
 
 int checkboard (void)
 {
-	puts ("Board: Keymile kmeter1\n");
+	puts ("Board: Keymile kmeter1");
+	if (ethernet_present ())
+		puts (" with PIGGY.");
+	puts ("\n");
 	return 0;
 }
 
board/keymile/mgcoge/mgcoge.c +7 -3
index 3683417..d2678db 100644
@@ -25,6 +25,7 @@
 #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)
@@ -35,7 +36,8 @@
 #include <i2c.h>
 #endif
 
-extern int ivm_read_eeprom (void);
+#include "../common/common.h"
+
 /*
  * I/O Port configuration table
  *
@@ -285,8 +287,10 @@ phys_size_t initdram (int board_type)
 
 int checkboard(void)
 {
-	puts ("Board: mgcoge\n");
-
+	puts ("Board: Keymile mgcoge");
+	if (ethernet_present ())
+		puts (" with PIGGY.");
+	puts ("\n");
 	return 0;
 }
 
board/keymile/mgsuvd/mgsuvd.c +6 -2
index 3726acf..20431ee 100644
@@ -22,13 +22,14 @@
  */
 #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;
 
@@ -60,7 +61,10 @@ const uint sdram_table[] =
 
 int checkboard (void)
 {
-	puts ("Board: Keymile mgsuvd\n");
+	puts ("Board: Keymile mgsuvd");
+	if (ethernet_present ())
+		puts (" with PIGGY.");
+	puts ("\n");
 	return (0);
 }
 
include/configs/kmeter1.h +9 -0
index bca1b9b..c345d21 100644
@@ -314,6 +314,15 @@
 #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 CONFIG_BOOTP_BOOTFILESIZE
include/configs/mgcoge.h +10 -0
index dc9b311..31428ea 100644
@@ -400,4 +400,14 @@
 #define OF_TBCLK		(bd->bi_busfreq / 4)
 #define OF_STDOUT_PATH		"/soc/cpm/serial at 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 */
include/configs/mgsuvd.h +9 -0
index fca2e55..b862130 100644
@@ -211,6 +211,15 @@
 #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
  */
Signature · 5 lines
1.5.6.1

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#1 lore raw

PATCH v3 3/4 powerpc: keymile: Add a check for the PIGGY debug board

Quoted 61 lines · On Thu, 20 Nov 2008 09:58:39 +0100 Heiko Schocher <[email protected]> wrote:

Check the presence of the PIGGY on the keymile boards mgcoge, mgsuvd and kmeter1. If the PIGGY is not present, dont register this Ethernet device.

---

changes since v2:

- added comments from Ben Warren

 board/keymile/common/common.c   |   20 ++++++++++++++++++--
 board/keymile/common/common.h   |   16 ++++++++++++++++
 board/keymile/kmeter1/Makefile  |    6 ++++--
 board/keymile/kmeter1/kmeter1.c |    7 ++++++-
 board/keymile/mgcoge/mgcoge.c   |   10 +++++++---
 board/keymile/mgsuvd/mgsuvd.c   |    8 ++++++--
 include/configs/kmeter1.h       |    9 +++++++++
 include/configs/mgcoge.h        |   10 ++++++++++
 include/configs/mgsuvd.h        |    9 +++++++++
 9 files changed, 85 insertions(+), 10 deletions(-)
 create mode 100644 board/keymile/common/common.h
board/keymile/common/common.c +5 -2
index a4cf24c..cc30b36 100644
@@ -22,10 +22,14 @@
  */
 
 #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>
@@ -33,8 +37,6 @@
 
 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
 #include <i2c.h>
-#endif
-#include <asm/io.h>
 
 extern int i2c_soft_read_pin (void);
 
@@ -495,6 +497,7 @@ void i2c_init_board(void)
 #endif
 }
 #endif
+#endif
 
 #if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
 int fdt_set_node_and_value (void *blob,
@@ -521,3 +524,16 @@ int fdt_set_node_and_value (void *blob,
 	return ret;

board/keymile/common/common.c int fdt_set_node_and_value (void *blob, · line 534

Quoted 10 lines
board/keymile/common/common.c +8 -0
 }
 #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

board/keymile/common/common.c int fdt_set_node_and_value (void *blob, · line 539

Quoted 5 lines
board/keymile/common/common.c +5 -0
+	if (ethernet_present ()) {
+		return -1;
+	}
+	return 0;
+}

If it looked like this it would be perfect!

---
Gary Jennejohn
*********************************************************************
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
*********************************************************************

#2 lore raw

PATCH v4 3/4 powerpc: keymile: Add a check for the PIGGY debug board

Check the presence of the PIGGY on the keymile boards mgcoge, mgsuvd and kmeter1. If the PIGGY is not present, dont register this Ethernet device.

---

changes since v3 patch:
- add comment from Gary Jeenejohn
calling keymile_hdlc_enet_initialize () in board_eth_init ()

 board/keymile/common/common.c   |   23 +++++++++++++++++++++--
 board/keymile/common/common.h   |   20 ++++++++++++++++++++
 board/keymile/kmeter1/Makefile  |    6 ++++--
 board/keymile/kmeter1/kmeter1.c |    7 ++++++-
 board/keymile/mgcoge/mgcoge.c   |   10 +++++++---
 board/keymile/mgsuvd/mgsuvd.c   |    8 ++++++--
 include/configs/kmeter1.h       |    9 +++++++++
 include/configs/mgcoge.h        |   10 ++++++++++
 include/configs/mgsuvd.h        |    9 +++++++++
 9 files changed, 92 insertions(+), 10 deletions(-)
 create mode 100644 board/keymile/common/common.h
board/keymile/common/common.c +21 -2
index a4cf24c..1338950 100644
@@ -22,10 +22,14 @@
  */
 
 #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>
@@ -33,8 +37,6 @@
 
 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
 #include <i2c.h>
-#endif
-#include <asm/io.h>
 
 extern int i2c_soft_read_pin (void);
 
@@ -495,6 +497,7 @@ void i2c_init_board(void)
 #endif
 }
 #endif
+#endif
 
 #if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
 int fdt_set_node_and_value (void *blob,
@@ -521,3 +524,19 @@ 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;
+}
board/keymile/common/common.h new file +20 -0
new file mode 100644
index 0000000..d3d6814
@@ -0,0 +1,20 @@
+/*
+ * (C) Copyright 2008
+ * Heiko Schocher, DENX Software Engineering, hs at 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 */
board/keymile/kmeter1/Makefile +4 -2
index 88b79f3..12a1518 100644
@@ -22,12 +22,14 @@
 #
 
 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))
board/keymile/kmeter1/kmeter1.c +6 -1
index f9a59a6..f04a57a 100644
@@ -27,6 +27,8 @@
 #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 */
 
@@ -141,7 +143,10 @@ phys_size_t initdram (int board_type)
 
 int checkboard (void)
 {
-	puts ("Board: Keymile kmeter1\n");
+	puts ("Board: Keymile kmeter1");
+	if (ethernet_present ())
+		puts (" with PIGGY.");
+	puts ("\n");
 	return 0;
 }
 
board/keymile/mgcoge/mgcoge.c +7 -3
index 3683417..5c50739 100644
@@ -25,6 +25,7 @@
 #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)
@@ -35,7 +36,8 @@
 #include <i2c.h>
 #endif
 
-extern int ivm_read_eeprom (void);
+#include "../common/common.h"
+
 /*
  * I/O Port configuration table
  *
@@ -285,8 +287,10 @@ phys_size_t initdram (int board_type)
 
 int checkboard(void)
 {
-	puts ("Board: mgcoge\n");
-
+	puts ("Board: Keymile mgcoge");
+	if (ethernet_present ())
+		puts (" with PIGGY.");
+	puts ("\n");
 	return 0;
 }
 
board/keymile/mgsuvd/mgsuvd.c +6 -2
index 3726acf..02baf62 100644
@@ -22,13 +22,14 @@
  */
 #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;
 
@@ -60,7 +61,10 @@ const uint sdram_table[] =
 
 int checkboard (void)
 {
-	puts ("Board: Keymile mgsuvd\n");
+	puts ("Board: Keymile mgsuvd");
+	if (ethernet_present ())
+		puts (" with PIGGY.");
+	puts ("\n");
 	return (0);
 }
 
include/configs/kmeter1.h +9 -0
index bca1b9b..c345d21 100644
@@ -314,6 +314,15 @@
 #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 CONFIG_BOOTP_BOOTFILESIZE
include/configs/mgcoge.h +10 -0
index dc9b311..31428ea 100644
@@ -400,4 +400,14 @@
 #define OF_TBCLK		(bd->bi_busfreq / 4)
 #define OF_STDOUT_PATH		"/soc/cpm/serial at 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 */
include/configs/mgsuvd.h +9 -0
index fca2e55..b862130 100644
@@ -211,6 +211,15 @@
 #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
  */
Signature · 5 lines
1.5.6.1

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#3 lore raw

PATCH v4 3/4 powerpc: keymile: Add a check for the PIGGY debug board

Quoted 6 lines · Heiko Schocher

Check the presence of the PIGGY on the keymile boards mgcoge, mgsuvd and kmeter1. If the PIGGY is not present, dont register this Ethernet device.

Quoted 273 lines

---

changes since v3 patch:
- add comment from Gary Jeenejohn
calling keymile_hdlc_enet_initialize () in board_eth_init ()

 board/keymile/common/common.c   |   23 +++++++++++++++++++++--
 board/keymile/common/common.h   |   20 ++++++++++++++++++++
 board/keymile/kmeter1/Makefile  |    6 ++++--
 board/keymile/kmeter1/kmeter1.c |    7 ++++++-
 board/keymile/mgcoge/mgcoge.c   |   10 +++++++---
 board/keymile/mgsuvd/mgsuvd.c   |    8 ++++++--
 include/configs/kmeter1.h       |    9 +++++++++
 include/configs/mgcoge.h        |   10 ++++++++++
 include/configs/mgsuvd.h        |    9 +++++++++
 9 files changed, 92 insertions(+), 10 deletions(-)
 create mode 100644 board/keymile/common/common.h
board/keymile/common/common.c +21 -2
index a4cf24c..1338950 100644
@@ -22,10 +22,14 @@
  */
 
 #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>
@@ -33,8 +37,6 @@
 
 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
 #include <i2c.h>
-#endif
-#include <asm/io.h>
 
 extern int i2c_soft_read_pin (void);
 
@@ -495,6 +497,7 @@ void i2c_init_board(void)
 #endif
 }
 #endif
+#endif
 
 #if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
 int fdt_set_node_and_value (void *blob,
@@ -521,3 +524,19 @@ 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;
+}
board/keymile/common/common.h new file +20 -0
new file mode 100644
index 0000000..d3d6814
@@ -0,0 +1,20 @@
+/*
+ * (C) Copyright 2008
+ * Heiko Schocher, DENX Software Engineering, hs at 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 */
board/keymile/kmeter1/Makefile +4 -2
index 88b79f3..12a1518 100644
@@ -22,12 +22,14 @@
 #
 
 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))
board/keymile/kmeter1/kmeter1.c +6 -1
index f9a59a6..f04a57a 100644
@@ -27,6 +27,8 @@
 #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 */
 
@@ -141,7 +143,10 @@ phys_size_t initdram (int board_type)
 
 int checkboard (void)
 {
-	puts ("Board: Keymile kmeter1\n");
+	puts ("Board: Keymile kmeter1");
+	if (ethernet_present ())
+		puts (" with PIGGY.");
+	puts ("\n");
 	return 0;
 }
 
board/keymile/mgcoge/mgcoge.c +7 -3
index 3683417..5c50739 100644
@@ -25,6 +25,7 @@
 #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)
@@ -35,7 +36,8 @@
 #include <i2c.h>
 #endif
 
-extern int ivm_read_eeprom (void);
+#include "../common/common.h"
+
 /*
  * I/O Port configuration table
  *
@@ -285,8 +287,10 @@ phys_size_t initdram (int board_type)
 
 int checkboard(void)
 {
-	puts ("Board: mgcoge\n");
-
+	puts ("Board: Keymile mgcoge");
+	if (ethernet_present ())
+		puts (" with PIGGY.");
+	puts ("\n");
 	return 0;
 }
 
board/keymile/mgsuvd/mgsuvd.c +6 -2
index 3726acf..02baf62 100644
@@ -22,13 +22,14 @@
  */
 #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;
 
@@ -60,7 +61,10 @@ const uint sdram_table[] =
 
 int checkboard (void)
 {
-	puts ("Board: Keymile mgsuvd\n");
+	puts ("Board: Keymile mgsuvd");
+	if (ethernet_present ())
+		puts (" with PIGGY.");
+	puts ("\n");
 	return (0);
 }
 
include/configs/kmeter1.h +9 -0
index bca1b9b..c345d21 100644
@@ -314,6 +314,15 @@
 #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 CONFIG_BOOTP_BOOTFILESIZE
include/configs/mgcoge.h +10 -0
index dc9b311..31428ea 100644
@@ -400,4 +400,14 @@
 #define OF_TBCLK		(bd->bi_busfreq / 4)
 #define OF_STDOUT_PATH		"/soc/cpm/serial at 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 */
include/configs/mgsuvd.h +9 -0
index fca2e55..b862130 100644
@@ -211,6 +211,15 @@
 #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
  */
#4 lore raw

PATCH v4 3/4 powerpc: keymile: Add a check for the PIGGY debug board

Dear Ben Warren,

Quoted 25 lines · In message <[email protected]> you wrote:
Quoted 6 lines · Heiko Schocher

Check the presence of the PIGGY on the keymile boards mgcoge, mgsuvd and kmeter1. If the PIGGY is not present, dont register this Ethernet device.

Quoted 17 lines

---

changes since v3 patch:
- add comment from Gary Jeenejohn
calling keymile_hdlc_enet_initialize () in board_eth_init ()

 board/keymile/common/common.c   |   23 +++++++++++++++++++++--
 board/keymile/common/common.h   |   20 ++++++++++++++++++++
 board/keymile/kmeter1/Makefile  |    6 ++++--
 board/keymile/kmeter1/kmeter1.c |    7 ++++++-
 board/keymile/mgcoge/mgcoge.c   |   10 +++++++---
 board/keymile/mgsuvd/mgsuvd.c   |    8 ++++++--
 include/configs/kmeter1.h       |    9 +++++++++
 include/configs/mgcoge.h        |   10 ++++++++++
 include/configs/mgsuvd.h        |    9 +++++++++
 9 files changed, 92 insertions(+), 10 deletions(-)
 create mode 100644 board/keymile/common/common.h

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 9 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Q:  How do you tell if you're making  love  to  a  nurse,  a  school-
    teacher, or an airline stewardess?
A:  A nurse says: "This won't hurt  a  bit."  A  schoolteacher  says:
    "We're  going to have to do this over and over again until we get
    it right." An airline stewardess says: "Just hold this over  your
    mouth and nose, and breath normally."