Skip to contentSkip to conversation

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

PATCH Superseded Heiko Schocher 2 participants 2 messages Nov 19, 2008

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 4/5 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 v1:

- rebased against current HEAD
commit e0b0ec843085f96f4fe0738424835ee90e58bc00

- use board_eth_init () for the Piggy Test

 board/keymile/common/common.c   |   24 ++++++++++++++++++++++--
 board/keymile/kmeter1/Makefile  |    6 ++++--
 board/keymile/kmeter1/kmeter1.c |   11 ++++++++++-
 board/keymile/mgcoge/mgcoge.c   |   12 ++++++++++--
 board/keymile/mgsuvd/mgsuvd.c   |   11 ++++++++++-
 include/configs/kmeter1.h       |   10 ++++++++++
 include/configs/mgcoge.h        |   11 +++++++++++
 include/configs/mgsuvd.h        |   10 ++++++++++
 8 files changed, 87 insertions(+), 8 deletions(-)
board/keymile/common/common.c +22 -2
index a4cf24c..4990f00 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,20 @@ int fdt_set_node_and_value (void *blob,
 	return ret;
 }
 #endif
+
+#if defined(CONFIG_CHECK_ETHERNET_PRESENT)
+int ethernet_present (int index)
+{
+	int	ret;
+	ret = in_8((u8 *)CONFIG_SYS_PIGGY_BASE + CONFIG_SYS_SLOT_ID_OFF) & 0x80;
+	return ret;
+}
+
+int board_eth_init(bd_t *bis)
+{
+	if (ethernet_present (0)) {
+		return -1;
+	}
+	return 0;
+}
+#endif
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 +10 -1
index f9a59a6..0c4dbe7 100644
@@ -27,6 +27,10 @@
 #include <pci.h>
 #include <libfdt.h>
 
+#if defined(CONFIG_CHECK_ETHERNET_PRESENT)
+extern int ethernet_present (int index);
+#endif
+
 const qe_iop_conf_t qe_iop_conf_tab[] = {
 	/* port pin dir open_drain assign */
 
@@ -141,7 +145,12 @@ phys_size_t initdram (int board_type)
 
 int checkboard (void)
 {
-	puts ("Board: Keymile kmeter1\n");
+	puts ("Board: Keymile kmeter1");
+#if defined(CONFIG_CHECK_ETHERNET_PRESENT)
+	if (ethernet_present (0))
+		puts (" with PIGGY.");
+#endif
+	puts ("\n");
 	return 0;
 }
 
board/keymile/mgcoge/mgcoge.c +10 -2
index 3683417..e39e15e 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,6 +36,9 @@
 #include <i2c.h>
 #endif
 
+#if defined(CONFIG_CHECK_ETHERNET_PRESENT)
+extern int ethernet_present (int index);
+#endif
 extern int ivm_read_eeprom (void);
 /*
  * I/O Port configuration table
@@ -285,8 +289,12 @@ phys_size_t initdram (int board_type)
 
 int checkboard(void)
 {
-	puts ("Board: mgcoge\n");
-
+	puts ("Board: Keymile mgcoge");
+#if defined(CONFIG_CHECK_ETHERNET_PRESENT)
+	if (ethernet_present (0))
+		puts (" with PIGGY.");
+#endif
+	puts ("\n");
 	return 0;
 }
 
board/keymile/mgsuvd/mgsuvd.c +10 -1
index 3726acf..8549ad9 100644
@@ -22,12 +22,16 @@
  */
 #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
 
+#if defined(CONFIG_CHECK_ETHERNET_PRESENT)
+extern int ethernet_present (int index);
+#endif
 extern int ivm_read_eeprom (void);
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -60,7 +64,12 @@ const uint sdram_table[] =
 
 int checkboard (void)
 {
-	puts ("Board: Keymile mgsuvd\n");
+	puts ("Board: Keymile mgsuvd");
+#if defined(CONFIG_CHECK_ETHERNET_PRESENT)
+	if (ethernet_present (0))
+		puts (" with PIGGY.");
+#endif
+	puts ("\n");
 	return (0);
 }
 
include/configs/kmeter1.h +10 -0
index d0fe6a3..e443086 100644
@@ -314,6 +314,16 @@
 #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_CHECK_ETHERNET_PRESENT	1
+#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 +11 -0
index dc9b311..bfac3b0 100644
@@ -400,4 +400,15 @@
 #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_CHECK_ETHERNET_PRESENT	1
+#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 +10 -0
index fca2e55..0bd2f40 100644
@@ -211,6 +211,16 @@
 #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_CHECK_ETHERNET_PRESENT	1
+#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 v2 4/5 powerpc: keymile: Add a check for the PIGGY debug board

Hi Heiko,

Quoted 62 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.

---

changes since v1:

- rebased against current HEAD
commit e0b0ec843085f96f4fe0738424835ee90e58bc00

- use board_eth_init () for the Piggy Test

 board/keymile/common/common.c   |   24 ++++++++++++++++++++++--
 board/keymile/kmeter1/Makefile  |    6 ++++--
 board/keymile/kmeter1/kmeter1.c |   11 ++++++++++-
 board/keymile/mgcoge/mgcoge.c   |   12 ++++++++++--
 board/keymile/mgsuvd/mgsuvd.c   |   11 ++++++++++-
 include/configs/kmeter1.h       |   10 ++++++++++
 include/configs/mgcoge.h        |   11 +++++++++++
 include/configs/mgsuvd.h        |   10 ++++++++++
 8 files changed, 87 insertions(+), 8 deletions(-)
board/keymile/common/common.c +5 -2
index a4cf24c..4990f00 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,

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

Quoted 10 lines
board/keymile/common/common.c +7 -0
@@ -521,3 +524,20 @@ int fdt_set_node_and_value (void *blob,
 	return ret;
 }
 #endif
+
+#if defined(CONFIG_CHECK_ETHERNET_PRESENT)
+int ethernet_present (int index)
+{
+	int	ret;
+	ret = in_8((u8 *)CONFIG_SYS_PIGGY_BASE + CONFIG_SYS_SLOT_ID_OFF) & 0x80;
+	return ret;

A nit, but this could be a one liner (ret isn't really needed). Also, you don't use index...

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

Quoted 10 lines
board/keymile/common/common.c +9 -0
+}
+
+int board_eth_init(bd_t *bis)
+{
+	if (ethernet_present (0)) {
+		return -1;
+	}
+	return 0;
+}

As mentioned above, do you need to pass a parameter?

Quoted 27 lines
board/keymile/common/common.c +1 -0
+#endif
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 +0 -0
index f9a59a6..0c4dbe7 100644

board/keymile/kmeter1/kmeter1.c line 34

Quoted 8 lines
board/keymile/kmeter1/kmeter1.c +4 -0
@@ -27,6 +27,10 @@
 #include <pci.h>
 #include <libfdt.h>
 
+#if defined(CONFIG_CHECK_ETHERNET_PRESENT)
+extern int ethernet_present (int index);
+#endif
+
 

I'd prefer to see the function prototype in a header file. Even if you just 'extern' it here, I'm not sure you need to wrap it in an #ifdef. This comment applies to other places in this patch.

A bigger question: do you really need CONFIG_CHECK_ETHERNET_PRESENT, since all the logic is in your board code?

<snip>

regards,
Ben