linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Ebony's UBoot awareness
@ 2005-02-23 18:39 Shawn Jin
  2005-02-23 19:01 ` Tom Rini
  2005-02-23 21:24 ` Matt Porter
  0 siblings, 2 replies; 8+ messages in thread
From: Shawn Jin @ 2005-02-23 18:39 UTC (permalink / raw)
  To: ppcembed

[-- Attachment #1: Type: text/plain, Size: 155 bytes --]

Hi,

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

Regards,
-Shawn.

[-- Attachment #2: ebony-emac.diff --]
[-- Type: text/plain, Size: 3192 bytes --]

diff -Nur orig/linux-2.6.10/arch/ppc/platforms/4xx/ebony.c code/linux-2.6.10/arch/ppc/platforms/4xx/ebony.c
--- orig/linux-2.6.10/arch/ppc/platforms/4xx/ebony.c	2004-12-24 13:35:40.000000000 -0800
+++ code/linux-2.6.10/arch/ppc/platforms/4xx/ebony.c	2005-02-23 10:05:32.043954000 -0800
@@ -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();
 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Ebony's UBoot awareness
  2005-02-23 18:39 [PATCH] Ebony's UBoot awareness Shawn Jin
@ 2005-02-23 19:01 ` Tom Rini
  2005-02-23 19:12   ` Eugene Surovegin
  2005-02-23 21:24 ` Matt Porter
  1 sibling, 1 reply; 8+ messages in thread
From: Tom Rini @ 2005-02-23 19:01 UTC (permalink / raw)
  To: Shawn Jin; +Cc: ppcembed

On Wed, Feb 23, 2005 at 10:39:34AM -0800, Shawn Jin wrote:

> This adds UBoot support on Ebony board and also sets emac's PHY mode
> explicitly during initialization as Eugene Surovegin provided.
[snip]
> +#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

-- 
Tom Rini
http://gate.crashing.org/~trini/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Ebony's UBoot awareness
  2005-02-23 19:01 ` Tom Rini
@ 2005-02-23 19:12   ` Eugene Surovegin
  2005-02-23 21:20     ` Matt Porter
  0 siblings, 1 reply; 8+ messages in thread
From: Eugene Surovegin @ 2005-02-23 19:12 UTC (permalink / raw)
  To: Tom Rini; +Cc: ppcembed

On Wed, Feb 23, 2005 at 12:01:23PM -0700, Tom Rini wrote:
> > +#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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Ebony's UBoot awareness
  2005-02-23 19:12   ` Eugene Surovegin
@ 2005-02-23 21:20     ` Matt Porter
  0 siblings, 0 replies; 8+ messages in thread
From: Matt Porter @ 2005-02-23 21:20 UTC (permalink / raw)
  To: Tom Rini, Shawn Jin, ppcembed

On Wed, Feb 23, 2005 at 11:12:47AM -0800, Eugene Surovegin wrote:
> On Wed, Feb 23, 2005 at 12:01:23PM -0700, Tom Rini wrote:
> > > +#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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Ebony's UBoot awareness
  2005-02-23 18:39 [PATCH] Ebony's UBoot awareness Shawn Jin
  2005-02-23 19:01 ` Tom Rini
@ 2005-02-23 21:24 ` Matt Porter
  2005-02-24 21:43   ` Shawn Jin
  1 sibling, 1 reply; 8+ messages in thread
From: Matt Porter @ 2005-02-23 21:24 UTC (permalink / raw)
  To: Shawn Jin; +Cc: ppcembed

On Wed, Feb 23, 2005 at 10:39:34AM -0800, Shawn Jin wrote:
> Hi,
> 
> This adds UBoot support on Ebony board and also sets emac's PHY mode
> explicitly during initialization as Eugene Surovegin provided.

<snip>

> +	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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Ebony's UBoot awareness
  2005-02-23 21:24 ` Matt Porter
@ 2005-02-24 21:43   ` Shawn Jin
  2005-02-24 22:27     ` Matt Porter
  2005-03-01 21:02     ` Matt Porter
  0 siblings, 2 replies; 8+ messages in thread
From: Shawn Jin @ 2005-02-24 21:43 UTC (permalink / raw)
  To: Matt Porter; +Cc: ppcembed

Hi Matt,

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Ebony's UBoot awareness
  2005-02-24 21:43   ` Shawn Jin
@ 2005-02-24 22:27     ` Matt Porter
  2005-03-01 21:02     ` Matt Porter
  1 sibling, 0 replies; 8+ messages in thread
From: Matt Porter @ 2005-02-24 22:27 UTC (permalink / raw)
  To: Shawn Jin; +Cc: ppcembed

On Thu, Feb 24, 2005 at 01:43:57PM -0800, Shawn Jin wrote:
> Hi Matt,
> 
> > 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Ebony's UBoot awareness
  2005-02-24 21:43   ` Shawn Jin
  2005-02-24 22:27     ` Matt Porter
@ 2005-03-01 21:02     ` Matt Porter
  1 sibling, 0 replies; 8+ messages in thread
From: Matt Porter @ 2005-03-01 21:02 UTC (permalink / raw)
  To: Shawn Jin; +Cc: ppcembed

On Thu, Feb 24, 2005 at 01:43:57PM -0800, Shawn Jin wrote:
> Hi Matt,
> 
> > 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-03-01 21:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-23 18:39 [PATCH] Ebony's UBoot awareness Shawn Jin
2005-02-23 19:01 ` Tom Rini
2005-02-23 19:12   ` Eugene Surovegin
2005-02-23 21:20     ` Matt Porter
2005-02-23 21:24 ` Matt Porter
2005-02-24 21:43   ` Shawn Jin
2005-02-24 22:27     ` Matt Porter
2005-03-01 21:02     ` Matt Porter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).