Skip to contentSkip to conversation

Ebony's UBoot awareness

PATCH In review Shawn Jin 4 participants 8 messages Feb 23, 2005 – Mar 1, 2005

lore
Share & tools
lore

Shawn Jin

author
#0 lore raw

PATCH 1/1 Ebony's UBoot awareness

Hi,

This adds UBoot support on Ebony board and also sets emac's PHY mode explicitly during initialization as Eugene Surovegin provided.

Regards,
-Shawn.

linux-2.6.10/arch/ppc/platforms/4xx/ebony.c +54 -14
diff -Nur orig/linux-2.6.10/arch/ppc/platforms/4xx/ebony.c code/linux-2.6.10/arch/ppc/platforms/4xx/ebony.c
@@ -49,10 +49,14 @@
 #include <asm/todc.h>
 #include <asm/bootinfo.h>
 #include <asm/ppc4xx_pic.h>
+#include <asm/ppcboot.h>
 
 #include <syslib/gen550.h>
 
+#include "../../../../drivers/net/ibm_emac/ibm_emac_phy.h"
+
 static struct ibm44x_clocks clocks __initdata;
+bd_t __res;
 
 /*
  * Ebony IRQ triggering/polarity settings
@@ -182,6 +186,41 @@
 	(writel(value, (u32)pcix_reg_base+offset))
 
 /*
+ * Set mac address for each EMAC
+ * If uboot sets MAC addresses for each EMAC, use them.
+ * Otherwise fetch from Ebony VPD.
+ *
+ */
+static void __init
+ebony_set_emacdata(void)
+{
+	unsigned char * vpd_base;
+	struct ocp_def *def;
+	struct ocp_func_emac_data *emacdata;
+
+	vpd_base = ioremap64(EBONY_VPD_BASE, EBONY_VPD_SIZE);
+
+	def = ocp_get_one_device(OCP_VENDOR_IBM, OCP_FUNC_EMAC, 0);
+	emacdata = def->additions;
+	emacdata->phy_mode = PHY_MODE_RMII;
+	if (!strncmp(__res.bi_enetaddr, "\0xFF\0xFF\0xFF\0xFF\0xFF\0xFF", 6))
+	  	memcpy(emacdata->mac_addr, __res.bi_enetaddr, 6);
+	else
+		memcpy(emacdata->mac_addr, EBONY_NA0_ADDR(vpd_base), 6);
+
+	def = ocp_get_one_device(OCP_VENDOR_IBM, OCP_FUNC_EMAC, 1);
+	emacdata = def->additions;
+	emacdata->phy_mode = PHY_MODE_RMII;
+	if (!strncmp(__res.bi_enet1addr, "\0xFF\0xFF\0xFF\0xFF\0xFF\0xFF", 6))
+	  	memcpy(emacdata->mac_addr, __res.bi_enet1addr, 6);
+	else
+		memcpy(emacdata->mac_addr, EBONY_NA1_ADDR(vpd_base), 6);
+
+	iounmap(vpd_base);
+
+}
+
+/*
  * FIXME: This is only here to "make it work".  This will move
  * to a ibm_pcix.c which will contain a generic IBM PCIX bridge
  * configuration library. -Matt
@@ -309,19 +348,7 @@
 static void __init
 ebony_setup_arch(void)
 {
-	unsigned char * vpd_base;
-	struct ocp_def *def;
-	struct ocp_func_emac_data *emacdata;
-
-	/* Set mac_addr for each EMAC */
-	vpd_base = ioremap64(EBONY_VPD_BASE, EBONY_VPD_SIZE);
-	def = ocp_get_one_device(OCP_VENDOR_IBM, OCP_FUNC_EMAC, 0);
-	emacdata = def->additions;
-	memcpy(emacdata->mac_addr, EBONY_NA0_ADDR(vpd_base), 6);
-	def = ocp_get_one_device(OCP_VENDOR_IBM, OCP_FUNC_EMAC, 1);
-	emacdata = def->additions;
-	memcpy(emacdata->mac_addr, EBONY_NA1_ADDR(vpd_base), 6);
-	iounmap(vpd_base);
+  	ebony_set_emacdata();
 
 	/*
 	 * Determine various clocks.
@@ -368,7 +395,20 @@
 void __init platform_init(unsigned long r3, unsigned long r4,
 		unsigned long r5, unsigned long r6, unsigned long r7)
 {
-	parse_bootinfo((struct bi_record *) (r3 + KERNELBASE));
+	parse_bootinfo(find_bootinfo());
+
+	/*
+	 * If we were passed in a board information, copy it into the
+	 * residual data area.
+	 */
+	if (r3)
+		__res = *(bd_t *)(r3 + KERNELBASE);
+
+	/* Copy the kernel command line arguments to a safe place. */
+	if (r6) {
+		*(char *) (r7 + KERNELBASE) = 0;
+		strcpy(cmd_line, (char *) (r6 + KERNELBASE));
+	}
 
 	ibm44x_platform_init();
 
#1 lore raw
Quoted 2 lines · Shawn Jin

This adds UBoot support on Ebony board and also sets emac's PHY mode explicitly during initialization as Eugene Surovegin provided.

[snip]

Quoted 1 line

+#include "../../../../drivers/net/ibm_emac/ibm_emac_phy.h"

This will not work with O= for example. The correct method is to modify the Makefile with a CFLAGS_foo.o += -Idrivers/net/ibm_emac

Signature · 2 lines
Tom Rini
http://gate.crashing.org/~trini/
#2 lore raw
Quoted 4 lines · Tom Rini
Quoted 1 line

+#include "../../../../drivers/net/ibm_emac/ibm_emac_phy.h"

This will not work with O= for example. The correct method is to modify the Makefile with a CFLAGS_foo.o += -Idrivers/net/ibm_emac

I just tested and it does work even with O= :).

OTOH, I agree this is ugly hack (it was copied from ocotea.c, so blame Matt for it :) and should be fixed correctly by moving those PHY defines to some common include.

--
Eugene

#3 lore raw
Quoted 11 lines · Eugene Surovegin
Quoted 4 lines · Tom Rini
Quoted 1 line

+#include "../../../../drivers/net/ibm_emac/ibm_emac_phy.h"

This will not work with O= for example. The correct method is to modify the Makefile with a CFLAGS_foo.o += -Idrivers/net/ibm_emac

I just tested and it does work even with O= :).

OTOH, I agree this is ugly hack (it was copied from ocotea.c, so blame Matt for it :) and should be fixed correctly by moving those PHY defines to some common include.

Ugh, yes...in my defense I clearly stated it was an "ugly hack". :)

-Matt

#4 lore raw
In reply to Shawn Jin
Quoted 4 lines · Shawn Jin

Hi,

This adds UBoot support on Ebony board and also sets emac's PHY mode explicitly during initialization as Eugene Surovegin provided.

<snip>

linux-2.6.10/arch/ppc/platforms/4xx/ebony.c line 209

Quoted 4 lines
linux-2.6.10/arch/ppc/platforms/4xx/ebony.c +4 -0
+	if (!strncmp(__res.bi_enetaddr, "\0xFF\0xFF\0xFF\0xFF\0xFF\0xFF", 6))
+	  	memcpy(emacdata->mac_addr, __res.bi_enetaddr, 6);
+	else
+		memcpy(emacdata->mac_addr, EBONY_NA0_ADDR(vpd_base), 6);

Can you use the ocotea/luan approach and create an openbios stub in arch/ppc/boot to create the bi_enetaddr infos? The PIBS stub in arch/ppc/boot does this so we can have one path in the platform file that parses the bootinfos.

-Matt

author
#5 lore raw

Hi Matt,

Quoted 4 lines

Can you use the ocotea/luan approach and create an openbios stub in arch/ppc/boot to create the bi_enetaddr infos? The PIBS stub in arch/ppc/boot does this so we can have one path in the platform file that parses the bootinfos.

I'd like to help if I can follow you. What does PIBS stand for? What is the ocotea/luan approach you were talking about? I thought I followed the ocotea approach to set up mac addresses.

Thanks,
-Shawn.

#6 lore raw
Quoted 10 lines · Shawn Jin

Hi Matt,

Quoted 4 lines

Can you use the ocotea/luan approach and create an openbios stub in arch/ppc/boot to create the bi_enetaddr infos? The PIBS stub in arch/ppc/boot does this so we can have one path in the platform file that parses the bootinfos.

I'd like to help if I can follow you. What does PIBS stand for? What is the ocotea/luan approach you were talking about? I thought I followed the ocotea approach to set up mac addresses.

PIBS is the firmware on all post 440GP ref brds from IBM/AMCC. Take a look at how both the stock PIBS f/w and U-Boot are supported on Ocotea by reviewing arch/ppc/boot/simple/pibs.c and arch/ppc/platforms/4xx/ocotea.c

In this implementation, ocotea.c always expects the enetaddrs in a birec. Whether they come direct from U-Boot or from some massaging by the arch/ppc/boot/simple/pibs.c shim doesn't matter. I suggest following that model which requires creating something like arch/ppc/boot/simple/openbios.c with a strong symboled load_kernel() routine that builds the bi-rec for the stock firmware case.

This hides the ugliness in the boot wrapper glue.

-Matt

#7 lore raw
In reply to Shawn Jin
Quoted 10 lines · Shawn Jin

Hi Matt,

Quoted 4 lines

Can you use the ocotea/luan approach and create an openbios stub in arch/ppc/boot to create the bi_enetaddr infos? The PIBS stub in arch/ppc/boot does this so we can have one path in the platform file that parses the bootinfos.

I'd like to help if I can follow you. What does PIBS stand for? What is the ocotea/luan approach you were talking about? I thought I followed the ocotea approach to set up mac addresses.

FYI, the implementation by Gerhard Jaeger for OpenBIOS/U-Boot Ebony support was sent upstream.

-Matt