public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] mgcoge make ether_scc.c work with CONFIG_NET_MULTI
@ 2008-11-09 10:58 Gary Jennejohn
  2008-11-10  6:09 ` Ben Warren
  2008-11-11 16:07 ` [U-Boot] [PATCH v2] " Gary Jennejohn
  0 siblings, 2 replies; 10+ messages in thread
From: Gary Jennejohn @ 2008-11-09 10:58 UTC (permalink / raw)
  To: u-boot

This change is needed for mgcoge because it uses two ethernet drivers.

Add a check for the presence of the PIGGY board on mgcoge.  Without this
board networking cannot work and the initialization must be aborted.

Only allocate rtx once to prevent DPRAM exhaustion.

Initialize ether_scc.c and the keymile-specific HDLC driver (to be added
soon) in eth.c.

Signed-off-by: Gary Jennejohn <garyj@denx.de>
---

I ran "MAKEALL ppc" and no errors were caused by this patch.

 cpu/mpc8260/ether_scc.c |   56 +++++++++++++++++++++++++++++++++++++++++------
 net/eth.c               |    8 ++++++
 2 files changed, 57 insertions(+), 7 deletions(-)

diff --git a/cpu/mpc8260/ether_scc.c b/cpu/mpc8260/ether_scc.c
index c65f0e0..537cd39 100644
--- a/cpu/mpc8260/ether_scc.c
+++ b/cpu/mpc8260/ether_scc.c
@@ -10,6 +10,12 @@
  * Advent Networks, Inc. <http://www.adventnetworks.com>
  * Jay Monkman <jtm@smoothsmoothie.com>
  *
+ * Modified so that it plays nicely when more than one ETHERNET interface
+ * is in use a la ether_fcc.c.
+ * (C) Copyright 2008
+ * DENX Software Engineerin GmbH
+ * Gary Jennejohn <garyj@denx.de>
+ *
  * See file CREDITS for list of people who contributed to this
  * project.
  *
@@ -32,12 +38,17 @@
 #include <common.h>
 #include <asm/cpm_8260.h>
 #include <mpc8260.h>
+#include <malloc.h>
 #include <net.h>
 #include <command.h>
 #include <config.h>
 
 #if defined(CONFIG_ETHER_ON_SCC) && defined(CONFIG_CMD_NET)
 
+#ifndef CONFIG_NET_MULTI
+#error "CONFIG_NET_MULTI must be defined."
+#endif
+
 #if (CONFIG_ETHER_INDEX == 1)
 #  define PROFF_ENET            PROFF_SCC1
 #  define CPM_CR_ENET_PAGE      CPM_CR_SCC1_PAGE
@@ -100,7 +111,7 @@ typedef volatile struct CommonBufferDescriptor {
 static RTXBD *rtx;
 
 
-int eth_send(volatile void *packet, int length)
+int sec_send(struct eth_device *dev, volatile void *packet, int length)
 {
     int i;
     int result = 0;
@@ -137,7 +148,7 @@ int eth_send(volatile void *packet, int length)
 }
 
 
-int eth_rx(void)
+int sec_rx(struct eth_device *dev)
 {
     int length;
 
@@ -184,19 +195,32 @@ int eth_rx(void)
  *
  *************************************************************/
 
-int eth_init(bd_t *bis)
+int sec_init(struct eth_device *dev, bd_t *bis)
 {
     int i;
     volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
     scc_enet_t *pram_ptr;
     uint dpaddr;
 
+#if defined(CONFIG_CHECK_ETHERNET_PRESENT)
+	if (ethernet_present (CONFIG_ETHER_INDEX) == 0) {
+		printf("Ethernet index: %d not present.\n",
+		       CONFIG_ETHER_INDEX);
+		return -1;
+	}
+#endif
+
     rxIdx = 0;
     txIdx = 0;
 
-    /* assign static pointer to BD area */
-    dpaddr = m8260_cpm_dpalloc(sizeof(RTXBD) + 2, 16);
-    rtx = (RTXBD *)&immr->im_dprambase[dpaddr];
+    /*
+     * Assign static pointer to BD area.
+     * Avoid exhausting DPRAM, which would cause a panic.
+     */
+    if (rtx == NULL) {
+	    dpaddr = m8260_cpm_dpalloc(sizeof(RTXBD) + 2, 16);
+	    rtx = (RTXBD *)&immr->im_dprambase[dpaddr];
+    }
 
     /* 24.21 - (1-3): ioports have been set up already */
 
@@ -338,7 +362,7 @@ int eth_init(bd_t *bis)
 }
 
 
-void eth_halt(void)
+void sec_halt(struct eth_device *dev)
 {
     volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
     immr->im_scc[CONFIG_ETHER_INDEX-1].scc_gsmrl &= ~(SCC_GSMRL_ENR |
@@ -354,4 +378,22 @@ void restart(void)
 }
 #endif
 
+int sec_initialize(bd_t *bis)
+{
+	struct eth_device *dev;
+
+	dev = (struct eth_device *) malloc(sizeof *dev);
+	memset(dev, 0, sizeof *dev);
+
+	sprintf(dev->name, "SCC ETHERNET");
+	dev->init   = sec_init;
+	dev->halt   = sec_halt;
+	dev->send   = sec_send;
+	dev->recv   = sec_rx;
+
+	eth_register(dev);
+
+	return 1;
+}
+
 #endif
diff --git a/net/eth.c b/net/eth.c
index ccd871a..5fe8b83 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -48,6 +48,8 @@ extern int ppc_4xx_eth_initialize(bd_t *);
 extern int scc_initialize(bd_t*);
 extern int npe_initialize(bd_t *);
 extern int uec_initialize(int);
+extern int sec_initialize(bd_t *);
+extern int keymile_hdlc_enet_initialize(bd_t *);
 
 #ifdef CONFIG_API
 extern void (*push_packet)(volatile void *, int);
@@ -196,6 +198,12 @@ int eth_initialize(bd_t *bis)
 #if defined(CONFIG_IXP4XX_NPE)
 	npe_initialize(bis);
 #endif
+#if defined(CONFIG_ETHER_ON_SCC) && defined(CONFIG_MPC8260)
+	sec_initialize(bis);
+#endif
+#if defined(CONFIG_KEYMILE_HDLC_ENET)
+	keymile_hdlc_enet_initialize(bis);
+#endif
 	if (!eth_devices) {
 		puts ("No ethernet found.\n");
 		show_boot_progress (-64);
-- 
1.5.4.3

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

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

* [U-Boot] [PATCH] mgcoge make ether_scc.c work with CONFIG_NET_MULTI
  2008-11-09 10:58 [U-Boot] [PATCH] mgcoge make ether_scc.c work with CONFIG_NET_MULTI Gary Jennejohn
@ 2008-11-10  6:09 ` Ben Warren
  2008-11-10 17:27   ` Gary Jennejohn
  2008-11-11 16:07 ` [U-Boot] [PATCH v2] " Gary Jennejohn
  1 sibling, 1 reply; 10+ messages in thread
From: Ben Warren @ 2008-11-10  6:09 UTC (permalink / raw)
  To: u-boot

Hi Gary,

Gary Jennejohn wrote:
> This change is needed for mgcoge because it uses two ethernet drivers.
>
>   
I like the idea of moving drivers to use CONFIG_NET_MULTI, particularly 
so that we can get rid of it as an option...  There are a few more 
things you need to think about, though.
> Add a check for the presence of the PIGGY board on mgcoge.  Without this
> board networking cannot work and the initialization must be aborted.
>
> Only allocate rtx once to prevent DPRAM exhaustion.
>
> Initialize ether_scc.c and the keymile-specific HDLC driver (to be added
> soon) in eth.c.
>
> Signed-off-by: Gary Jennejohn <garyj@denx.de>
> ---
>
> I ran "MAKEALL ppc" and no errors were caused by this patch.
>
>  cpu/mpc8260/ether_scc.c |   56 +++++++++++++++++++++++++++++++++++++++++------
>  net/eth.c               |    8 ++++++
>  2 files changed, 57 insertions(+), 7 deletions(-)
>
> diff --git a/cpu/mpc8260/ether_scc.c b/cpu/mpc8260/ether_scc.c
> index c65f0e0..537cd39 100644
> --- a/cpu/mpc8260/ether_scc.c
> +++ b/cpu/mpc8260/ether_scc.c
> @@ -10,6 +10,12 @@
>   * Advent Networks, Inc. <http://www.adventnetworks.com>
>   * Jay Monkman <jtm@smoothsmoothie.com>
>   *
> + * Modified so that it plays nicely when more than one ETHERNET interface
> + * is in use a la ether_fcc.c.
> + * (C) Copyright 2008
> + * DENX Software Engineerin GmbH
> + * Gary Jennejohn <garyj@denx.de>
> + *
>   * See file CREDITS for list of people who contributed to this
>   * project.
>   *
> @@ -32,12 +38,17 @@
>  #include <common.h>
>  #include <asm/cpm_8260.h>
>  #include <mpc8260.h>
> +#include <malloc.h>
>  #include <net.h>
>  #include <command.h>
>  #include <config.h>
>  
>  #if defined(CONFIG_ETHER_ON_SCC) && defined(CONFIG_CMD_NET)
>   
While you're mucking around with this file, please settle on a single 
CONFIG that can allow conditional compilation from the Makefile, then 
get rid of this stuff.
>  
> +#ifndef CONFIG_NET_MULTI
> +#error "CONFIG_NET_MULTI must be defined."
> +#endif
> +
>  #if (CONFIG_ETHER_INDEX == 1)
>  #  define PROFF_ENET            PROFF_SCC1
>  #  define CPM_CR_ENET_PAGE      CPM_CR_SCC1_PAGE
> @@ -100,7 +111,7 @@ typedef volatile struct CommonBufferDescriptor {
>  static RTXBD *rtx;
>  
>  
> -int eth_send(volatile void *packet, int length)
> +int sec_send(struct eth_device *dev, volatile void *packet, int length)
>   
Please give all these functions, except initialize(), file scope (i.e. 
make them static).  I'm not crazy about the name 'sec', but if it's 
static the objection doesn't carry much weight.  I also can't think of a 
better name.
>  {
>      int i;
>      int result = 0;
> @@ -137,7 +148,7 @@ int eth_send(volatile void *packet, int length)
>  }
>  
>  
> -int eth_rx(void)
> +int sec_rx(struct eth_device *dev)
>  {
>      int length;
>  
> @@ -184,19 +195,32 @@ int eth_rx(void)
>   *
>   *************************************************************/
>  
> -int eth_init(bd_t *bis)
> +int sec_init(struct eth_device *dev, bd_t *bis)
>  {
>      int i;
>      volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
>      scc_enet_t *pram_ptr;
>      uint dpaddr;
>  
> +#if defined(CONFIG_CHECK_ETHERNET_PRESENT)
> +	if (ethernet_present (CONFIG_ETHER_INDEX) == 0) {
> +		printf("Ethernet index: %d not present.\n",
> +		       CONFIG_ETHER_INDEX);
> +		return -1;
> +	}
> +#endif
> +
>      rxIdx = 0;
>      txIdx = 0;
>  
> -    /* assign static pointer to BD area */
> -    dpaddr = m8260_cpm_dpalloc(sizeof(RTXBD) + 2, 16);
> -    rtx = (RTXBD *)&immr->im_dprambase[dpaddr];
> +    /*
> +     * Assign static pointer to BD area.
> +     * Avoid exhausting DPRAM, which would cause a panic.
> +     */
> +    if (rtx == NULL) {
> +	    dpaddr = m8260_cpm_dpalloc(sizeof(RTXBD) + 2, 16);
> +	    rtx = (RTXBD *)&immr->im_dprambase[dpaddr];
> +    }
>  
>      /* 24.21 - (1-3): ioports have been set up already */
>  
> @@ -338,7 +362,7 @@ int eth_init(bd_t *bis)
>  }
>  
>  
> -void eth_halt(void)
> +void sec_halt(struct eth_device *dev)
>  {
>      volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
>      immr->im_scc[CONFIG_ETHER_INDEX-1].scc_gsmrl &= ~(SCC_GSMRL_ENR |
> @@ -354,4 +378,22 @@ void restart(void)
>  }
>  #endif
>  
> +int sec_initialize(bd_t *bis)
>   
For this function with global namespace, please pick a more descriptive 
name.  Maybe 82xx_scc_initialize() or something?
> +{
> +	struct eth_device *dev;
> +
> +	dev = (struct eth_device *) malloc(sizeof *dev);
> +	memset(dev, 0, sizeof *dev);
> +
> +	sprintf(dev->name, "SCC ETHERNET");
> +	dev->init   = sec_init;
> +	dev->halt   = sec_halt;
> +	dev->send   = sec_send;
> +	dev->recv   = sec_rx;
> +
> +	eth_register(dev);
> +
> +	return 1;
> +}
> +
>  #endif
> diff --git a/net/eth.c b/net/eth.c
> index ccd871a..5fe8b83 100644
> --- a/net/eth.c
> +++ b/net/eth.c
> @@ -48,6 +48,8 @@ extern int ppc_4xx_eth_initialize(bd_t *);
>  extern int scc_initialize(bd_t*);
>  extern int npe_initialize(bd_t *);
>  extern int uec_initialize(int);
> +extern int sec_initialize(bd_t *);
> +extern int keymile_hdlc_enet_initialize(bd_t *);
>  
>  #ifdef CONFIG_API
>  extern void (*push_packet)(volatile void *, int);
> @@ -196,6 +198,12 @@ int eth_initialize(bd_t *bis)
>  #if defined(CONFIG_IXP4XX_NPE)
>  	npe_initialize(bis);
>  #endif
> +#if defined(CONFIG_ETHER_ON_SCC) && defined(CONFIG_MPC8260)
> +	sec_initialize(bis);
> +#endif
> +#if defined(CONFIG_KEYMILE_HDLC_ENET)
> +	keymile_hdlc_enet_initialize(bis);
> +#endif
>  	if (!eth_devices) {
>  		puts ("No ethernet found.\n");
>  		show_boot_progress (-64);
>   
Please don't add anything to this file.  All initializations now go in 
cpu_eth_init()/board_eth_init().  There are plenty of examples you can 
draw from.  Don't forget to add your initializer function to 
include/netdev.h

You get bonus points if you move this driver to drivers/net

regards,
Ben

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

* [U-Boot] [PATCH] mgcoge make ether_scc.c work with CONFIG_NET_MULTI
  2008-11-10  6:09 ` Ben Warren
@ 2008-11-10 17:27   ` Gary Jennejohn
  2008-11-10 17:53     ` Ben Warren
  0 siblings, 1 reply; 10+ messages in thread
From: Gary Jennejohn @ 2008-11-10 17:27 UTC (permalink / raw)
  To: u-boot


Hi Ben,

Ben Warren <biggerbadderben@gmail.com> wrote:
> Gary Jennejohn wrote:
[snip]
> >  #if defined(CONFIG_ETHER_ON_SCC) && defined(CONFIG_CMD_NET)
> >   
> While you're mucking around with this file, please settle on a single 
> CONFIG that can allow conditional compilation from the Makefile, then 
> get rid of this stuff.
>

You mean get rid of CONFIG_ETHER_ON_SCC and CONFIG_CMD_NET?  But isn't at
least CONFIG_CMD_NET required to get networking support in other parts of
U-Boot, which would make it a prerequisite for compiling this?

And eliminating or supplementing CONFIG_ETHER_ON_SCC with a new CONFIG
would mean changing a whole slew of configuration files, not to mention
include/net.h.

> > -int eth_send(volatile void *packet, int length)
> > +int sec_send(struct eth_device *dev, volatile void *packet, int length)
> >   
> Please give all these functions, except initialize(), file scope (i.e. 
> make them static).  I'm not crazy about the name 'sec', but if it's 
> static the objection doesn't carry much weight.  I also can't think of a 
> better name.
>

Yeah, I should have thought of this when I did the mods.

[snip]
> > +int sec_initialize(bd_t *bis)
> >   
> For this function with global namespace, please pick a more descriptive 
> name.  Maybe 82xx_scc_initialize() or something?
>

I called it 82xx_scc_enet_initialize() to make its function clear.

> > --- a/net/eth.c
> > +++ b/net/eth.c
> > @@ -48,6 +48,8 @@ extern int ppc_4xx_eth_initialize(bd_t *);
> >  extern int scc_initialize(bd_t*);
> >  extern int npe_initialize(bd_t *);
> >  extern int uec_initialize(int);
> > +extern int sec_initialize(bd_t *);
> > +extern int keymile_hdlc_enet_initialize(bd_t *);
> >  
> >  #ifdef CONFIG_API
> >  extern void (*push_packet)(volatile void *, int);
> > @@ -196,6 +198,12 @@ int eth_initialize(bd_t *bis)
> >  #if defined(CONFIG_IXP4XX_NPE)
> >  	npe_initialize(bis);
> >  #endif
> > +#if defined(CONFIG_ETHER_ON_SCC) && defined(CONFIG_MPC8260)
> > +	sec_initialize(bis);
> > +#endif
> > +#if defined(CONFIG_KEYMILE_HDLC_ENET)
> > +	keymile_hdlc_enet_initialize(bis);
> > +#endif
> >  	if (!eth_devices) {
> >  		puts ("No ethernet found.\n");
> >  		show_boot_progress (-64);
> >   
> Please don't add anything to this file.  All initializations now go in 
> cpu_eth_init()/board_eth_init().  There are plenty of examples you can 
> draw from.  Don't forget to add your initializer function to 
> include/netdev.h
> 

OK, that should be easy enough.  I've now done it for keymile.

> You get bonus points if you move this driver to drivers/net
> 

I'll look into it but make no promises.

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

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

* [U-Boot] [PATCH] mgcoge make ether_scc.c work with CONFIG_NET_MULTI
  2008-11-10 17:27   ` Gary Jennejohn
@ 2008-11-10 17:53     ` Ben Warren
  2008-11-11 10:41       ` Gary Jennejohn
  0 siblings, 1 reply; 10+ messages in thread
From: Ben Warren @ 2008-11-10 17:53 UTC (permalink / raw)
  To: u-boot

Hi Gary,

Gary Jennejohn wrote:
> Hi Ben,
>
> Ben Warren <biggerbadderben@gmail.com> wrote:
>   
>> Gary Jennejohn wrote:
>>     
> [snip]
>   
>>>  #if defined(CONFIG_ETHER_ON_SCC) && defined(CONFIG_CMD_NET)
>>>   
>>>       
>> While you're mucking around with this file, please settle on a single 
>> CONFIG that can allow conditional compilation from the Makefile, then 
>> get rid of this stuff.
>>
>>     
>
> You mean get rid of CONFIG_ETHER_ON_SCC and CONFIG_CMD_NET?  But isn't at
> least CONFIG_CMD_NET required to get networking support in other parts of
> U-Boot, which would make it a prerequisite for compiling this?
>
> And eliminating or supplementing CONFIG_ETHER_ON_SCC with a new CONFIG
> would mean changing a whole slew of configuration files, not to mention
> include/net.h.
>
>   
I don't mean get rid of them completely, just move the conditionality to 
the Makefile.  IMHO the CONFIG_ETHER_ON_SCC conditional is enough, you 
don't need to check for CONFIG_CMD_NET.  It the user doesn' t have it 
set, problems will show up all over the place, and very quickly.  I'd 
prefer to change the name of CONFIG_ETHER_ON_SCC to something indicating 
82xx-ness, since this driver is specific to the 82xx family of SOCs, but 
SCCs have been around longer than PowerPC.  One thing you'll notice is 
that most of the config files that mention this option are #undef'ing it 
only.
>>> -int eth_send(volatile void *packet, int length)
>>> +int sec_send(struct eth_device *dev, volatile void *packet, int length)
>>>   
>>>       
>> Please give all these functions, except initialize(), file scope (i.e. 
>> make them static).  I'm not crazy about the name 'sec', but if it's 
>> static the objection doesn't carry much weight.  I also can't think of a 
>> better name.
>>
>>     
>
> Yeah, I should have thought of this when I did the mods.
>
> [snip]
>   
>>> +int sec_initialize(bd_t *bis)
>>>   
>>>       
>> For this function with global namespace, please pick a more descriptive 
>> name.  Maybe 82xx_scc_initialize() or something?
>>
>>     
>
> I called it 82xx_scc_enet_initialize() to make its function clear.
>
>   
Perfect.
>>> --- a/net/eth.c
>>> +++ b/net/eth.c
>>> @@ -48,6 +48,8 @@ extern int ppc_4xx_eth_initialize(bd_t *);
>>>  extern int scc_initialize(bd_t*);
>>>  extern int npe_initialize(bd_t *);
>>>  extern int uec_initialize(int);
>>> +extern int sec_initialize(bd_t *);
>>> +extern int keymile_hdlc_enet_initialize(bd_t *);
>>>  
>>>  #ifdef CONFIG_API
>>>  extern void (*push_packet)(volatile void *, int);
>>> @@ -196,6 +198,12 @@ int eth_initialize(bd_t *bis)
>>>  #if defined(CONFIG_IXP4XX_NPE)
>>>  	npe_initialize(bis);
>>>  #endif
>>> +#if defined(CONFIG_ETHER_ON_SCC) && defined(CONFIG_MPC8260)
>>> +	sec_initialize(bis);
>>> +#endif
>>> +#if defined(CONFIG_KEYMILE_HDLC_ENET)
>>> +	keymile_hdlc_enet_initialize(bis);
>>> +#endif
>>>  	if (!eth_devices) {
>>>  		puts ("No ethernet found.\n");
>>>  		show_boot_progress (-64);
>>>   
>>>       
>> Please don't add anything to this file.  All initializations now go in 
>> cpu_eth_init()/board_eth_init().  There are plenty of examples you can 
>> draw from.  Don't forget to add your initializer function to 
>> include/netdev.h
>>
>>     
>
> OK, that should be easy enough.  I've now done it for keymile.
>
>   
>> You get bonus points if you move this driver to drivers/net
>>
>>     
>
> I'll look into it but make no promises.
>   
That's OK, do what you can.  We all have priorities.

regards,
Ben

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

* [U-Boot] [PATCH] mgcoge make ether_scc.c work with CONFIG_NET_MULTI
  2008-11-10 17:53     ` Ben Warren
@ 2008-11-11 10:41       ` Gary Jennejohn
  0 siblings, 0 replies; 10+ messages in thread
From: Gary Jennejohn @ 2008-11-11 10:41 UTC (permalink / raw)
  To: u-boot

Hi Ben,

Ben Warren <biggerbadderben@gmail.com> wrote:
> Gary Jennejohn wrote:
> > Ben Warren <biggerbadderben@gmail.com> wrote:
> >   
> >> Gary Jennejohn wrote:
> >>     
> > [snip]
> >   
> >>>  #if defined(CONFIG_ETHER_ON_SCC) && defined(CONFIG_CMD_NET)
> >>>   
> >>>       
> >> While you're mucking around with this file, please settle on a single 
> >> CONFIG that can allow conditional compilation from the Makefile, then 
> >> get rid of this stuff.
> >>
> >>     
> >
> > You mean get rid of CONFIG_ETHER_ON_SCC and CONFIG_CMD_NET?  But isn't at
> > least CONFIG_CMD_NET required to get networking support in other parts of
> > U-Boot, which would make it a prerequisite for compiling this?
> >
> > And eliminating or supplementing CONFIG_ETHER_ON_SCC with a new CONFIG
> > would mean changing a whole slew of configuration files, not to mention
> > include/net.h.
> >
> >   
> I don't mean get rid of them completely, just move the conditionality to 
> the Makefile.  IMHO the CONFIG_ETHER_ON_SCC conditional is enough, you 
> don't need to check for CONFIG_CMD_NET.  It the user doesn' t have it 
> set, problems will show up all over the place, and very quickly.  I'd 
> prefer to change the name of CONFIG_ETHER_ON_SCC to something indicating 
> 82xx-ness, since this driver is specific to the 82xx family of SOCs, but 
> SCCs have been around longer than PowerPC.  One thing you'll notice is 
> that most of the config files that mention this option are #undef'ing it 
> only.
>

OK, I think I'll keep CONFIG_ETHER_ON_SCC because
a) there's less repo churn and less work for me :-)
b) it's also used in board/pm826/pm826.c and board/pm828/pm828.c to
   control setup of port pins and I hesitate to touch board-specific
   code.

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

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

* [U-Boot] [PATCH v2] mgcoge make ether_scc.c work with CONFIG_NET_MULTI
  2008-11-09 10:58 [U-Boot] [PATCH] mgcoge make ether_scc.c work with CONFIG_NET_MULTI Gary Jennejohn
  2008-11-10  6:09 ` Ben Warren
@ 2008-11-11 16:07 ` Gary Jennejohn
  2008-12-08 20:50   ` Wolfgang Denk
  1 sibling, 1 reply; 10+ messages in thread
From: Gary Jennejohn @ 2008-11-11 16:07 UTC (permalink / raw)
  To: u-boot

This change is needed for mgcoge because it uses two ethernet drivers.

Add a check for the presence of the PIGGY board on mgcoge.  Without this
board networking cannot work and the initialization must be aborted.

Only allocate rtx once to prevent DPRAM exhaustion.

Initialize ether_scc.c and the keymile-specific HDLC driver (to be added
soon) in eth.c.

Signed-off-by: Gary Jennejohn <garyj@denx.de>
---

I ran "MAKEALL ppc" and no errors were caused by this patch.

v2
 - handle comments from Ben Warren
   1) set local routines in ether_scc.c static; renamed sec_initialize() to
      mpc82xx_scc_enet_initialize(); eliminated the dependency on CONFIG_ETHER_ON_SCC
      and CONFIG_CMD_NET
   2) made compilation of ether_scc.c conditional on CONFIG_ETHER_ON_SCC in
      cpu/mpc8260/Makefile
   3) moved the initialization of ether_scc.c from net/eth.c to
      cpu/mpc8260/cpu.c
   4) added mpc82xx_scc_enet_initialize() to include/netdev.h
   5) Changes to net/eth.c are no longer required and this part of the
      old patch has now disappeared

 cpu/mpc8260/Makefile    |    8 +++++-
 cpu/mpc8260/cpu.c       |   11 ++++++++-
 cpu/mpc8260/ether_scc.c |   58 ++++++++++++++++++++++++++++++++++++++--------
 include/netdev.h        |    1 +
 4 files changed, 65 insertions(+), 13 deletions(-)

diff --git a/cpu/mpc8260/Makefile b/cpu/mpc8260/Makefile
index 80d7852..9f0c2dd 100644
--- a/cpu/mpc8260/Makefile
+++ b/cpu/mpc8260/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2000-2006
+# (C) Copyright 2000-2008
 # Wolfgang Denk, DENX Software Engineering, wd at denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -27,9 +27,13 @@ LIB	= $(obj)lib$(CPU).a
 
 START	= start.o kgdb.o
 COBJS	= traps.o serial_smc.o serial_scc.o cpu.o cpu_init.o speed.o \
-	  interrupts.o ether_scc.o ether_fcc.o i2c.o commproc.o \
+	  interrupts.o ether_fcc.o i2c.o commproc.o \
 	  bedbug_603e.o pci.o spi.o
 
+COBJS-$(CONFIG_ETHER_ON_SCC) = ether_scc.o
+
+COBJS	+= $(COBJS-y)
+
 SRCS	:= $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
 START	:= $(addprefix $(obj),$(START))
diff --git a/cpu/mpc8260/cpu.c b/cpu/mpc8260/cpu.c
index 9f834d3..f9b9bed 100644
--- a/cpu/mpc8260/cpu.c
+++ b/cpu/mpc8260/cpu.c
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2000-2006
+ * (C) Copyright 2000-2008
  * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
  *
  * See file CREDITS for list of people who contributed to this
@@ -44,6 +44,7 @@
 #include <watchdog.h>
 #include <command.h>
 #include <mpc8260.h>
+#include <netdev.h>
 #include <asm/processor.h>
 #include <asm/cpm_8260.h>
 
@@ -315,3 +316,11 @@ void ft_cpu_setup (void *blob, bd_t *bd)
 	do_fixup_by_path_u32(blob, cpu_path, "clock-frequency", bd->bi_intfreq, 1);
 }
 #endif /* CONFIG_OF_LIBFDT */
+
+/* ------------------------------------------------------------------------- */
+#if defined(CONFIG_ETHER_ON_SCC)
+int cpu_eth_init(bd_t *bd)
+{
+	return mpc82xx_scc_enet_initialize(bd);
+}
+#endif /* CONFIG_ETHER_ON_SCC */
diff --git a/cpu/mpc8260/ether_scc.c b/cpu/mpc8260/ether_scc.c
index c65f0e0..8e8e6bb 100644
--- a/cpu/mpc8260/ether_scc.c
+++ b/cpu/mpc8260/ether_scc.c
@@ -10,6 +10,12 @@
  * Advent Networks, Inc. <http://www.adventnetworks.com>
  * Jay Monkman <jtm@smoothsmoothie.com>
  *
+ * Modified so that it plays nicely when more than one ETHERNET interface
+ * is in use a la ether_fcc.c.
+ * (C) Copyright 2008
+ * DENX Software Engineerin GmbH
+ * Gary Jennejohn <garyj@denx.de>
+ *
  * See file CREDITS for list of people who contributed to this
  * project.
  *
@@ -32,11 +38,14 @@
 #include <common.h>
 #include <asm/cpm_8260.h>
 #include <mpc8260.h>
+#include <malloc.h>
 #include <net.h>
 #include <command.h>
 #include <config.h>
 
-#if defined(CONFIG_ETHER_ON_SCC) && defined(CONFIG_CMD_NET)
+#ifndef CONFIG_NET_MULTI
+#error "CONFIG_NET_MULTI must be defined."
+#endif
 
 #if (CONFIG_ETHER_INDEX == 1)
 #  define PROFF_ENET            PROFF_SCC1
@@ -100,7 +109,7 @@ typedef volatile struct CommonBufferDescriptor {
 static RTXBD *rtx;
 
 
-int eth_send(volatile void *packet, int length)
+static int sec_send(struct eth_device *dev, volatile void *packet, int length)
 {
     int i;
     int result = 0;
@@ -137,7 +146,7 @@ int eth_send(volatile void *packet, int length)
 }
 
 
-int eth_rx(void)
+static int sec_rx(struct eth_device *dev)
 {
     int length;
 
@@ -184,19 +193,32 @@ int eth_rx(void)
  *
  *************************************************************/
 
-int eth_init(bd_t *bis)
+static int sec_init(struct eth_device *dev, bd_t *bis)
 {
     int i;
     volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
     scc_enet_t *pram_ptr;
     uint dpaddr;
 
+#if defined(CONFIG_CHECK_ETHERNET_PRESENT)
+	if (ethernet_present(CONFIG_ETHER_INDEX) == 0) {
+		printf("Ethernet index: %d not present.\n",
+		       CONFIG_ETHER_INDEX);
+		return -1;
+	}
+#endif
+
     rxIdx = 0;
     txIdx = 0;
 
-    /* assign static pointer to BD area */
-    dpaddr = m8260_cpm_dpalloc(sizeof(RTXBD) + 2, 16);
-    rtx = (RTXBD *)&immr->im_dprambase[dpaddr];
+    /*
+     * Assign static pointer to BD area.
+     * Avoid exhausting DPRAM, which would cause a panic.
+     */
+    if (rtx == NULL) {
+	    dpaddr = m8260_cpm_dpalloc(sizeof(RTXBD) + 2, 16);
+	    rtx = (RTXBD *)&immr->im_dprambase[dpaddr];
+    }
 
     /* 24.21 - (1-3): ioports have been set up already */
 
@@ -338,7 +360,7 @@ int eth_init(bd_t *bis)
 }
 
 
-void eth_halt(void)
+static void sec_halt(struct eth_device *dev)
 {
     volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
     immr->im_scc[CONFIG_ETHER_INDEX-1].scc_gsmrl &= ~(SCC_GSMRL_ENR |
@@ -346,7 +368,7 @@ void eth_halt(void)
 }
 
 #if 0
-void restart(void)
+static void sec_restart(void)
 {
     volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
     immr->im_cpm.cp_scc[CONFIG_ETHER_INDEX-1].scc_gsmrl |= (SCC_GSMRL_ENR |
@@ -354,4 +376,20 @@ void restart(void)
 }
 #endif
 
-#endif
+int mpc82xx_scc_enet_initialize(bd_t *bis)
+{
+	struct eth_device *dev;
+
+	dev = (struct eth_device *) malloc(sizeof *dev);
+	memset(dev, 0, sizeof *dev);
+
+	sprintf(dev->name, "SCC ETHERNET");
+	dev->init   = sec_init;
+	dev->halt   = sec_halt;
+	dev->send   = sec_send;
+	dev->recv   = sec_rx;
+
+	eth_register(dev);
+
+	return 1;
+}
diff --git a/include/netdev.h b/include/netdev.h
index 87d578c..461d5c5 100644
--- a/include/netdev.h
+++ b/include/netdev.h
@@ -54,6 +54,7 @@ int mcdmafec_initialize(bd_t *bis);
 int mcffec_initialize(bd_t *bis);
 int mpc512x_fec_initialize(bd_t *bis);
 int mpc5xxx_fec_initialize(bd_t *bis);
+int mpc82xx_scc_enet_initialize(bd_t *bis);
 int natsemi_initialize(bd_t *bis);
 int ns8382x_initialize(bd_t *bis);
 int pcnet_initialize(bd_t *bis);
-- 
1.5.4.3

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

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

* [U-Boot] [PATCH v2] mgcoge make ether_scc.c work with CONFIG_NET_MULTI
  2008-11-11 16:07 ` [U-Boot] [PATCH v2] " Gary Jennejohn
@ 2008-12-08 20:50   ` Wolfgang Denk
  2008-12-08 21:00     ` Wolfgang Denk
  2008-12-08 22:05     ` Ben Warren
  0 siblings, 2 replies; 10+ messages in thread
From: Wolfgang Denk @ 2008-12-08 20:50 UTC (permalink / raw)
  To: u-boot

Dear Ben,

In message <20081111170728.73ca9b7a@ernst.jennejohn.org> Gary Jennejohn wrote:
> This change is needed for mgcoge because it uses two ethernet drivers.
> 
> Add a check for the presence of the PIGGY board on mgcoge.  Without this
> board networking cannot work and the initialization must be aborted.
> 
> Only allocate rtx once to prevent DPRAM exhaustion.
> 
> Initialize ether_scc.c and the keymile-specific HDLC driver (to be added
> soon) in eth.c.
> 
> Signed-off-by: Gary Jennejohn <garyj@denx.de>

Any comments on this?

Best regards,

Wolfgang Denk

-- 
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
One does not thank logic.
	-- Sarek, "Journey to Babel", stardate 3842.4

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

* [U-Boot] [PATCH v2] mgcoge make ether_scc.c work with CONFIG_NET_MULTI
  2008-12-08 20:50   ` Wolfgang Denk
@ 2008-12-08 21:00     ` Wolfgang Denk
  2008-12-08 22:05     ` Ben Warren
  1 sibling, 0 replies; 10+ messages in thread
From: Wolfgang Denk @ 2008-12-08 21:00 UTC (permalink / raw)
  To: u-boot

Dear Ben,

In message <20081208205048.07E13834B020@gemini.denx.de> I wrote:
> 
> Any comments on this?

Please ignore. I missed the v3 patch.

Best regards,

Wolfgang Denk

-- 
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
A committee is a group that keeps the minutes and loses hours.
                                                      -- Milton Berle

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

* [U-Boot] [PATCH v2] mgcoge make ether_scc.c work with CONFIG_NET_MULTI
  2008-12-08 20:50   ` Wolfgang Denk
  2008-12-08 21:00     ` Wolfgang Denk
@ 2008-12-08 22:05     ` Ben Warren
  2008-12-09  8:56       ` Gary Jennejohn
  1 sibling, 1 reply; 10+ messages in thread
From: Ben Warren @ 2008-12-08 22:05 UTC (permalink / raw)
  To: u-boot

Hi Wolfgang,

Wolfgang Denk wrote:
> Dear Ben,
>
> In message <20081111170728.73ca9b7a@ernst.jennejohn.org> Gary Jennejohn wrote:
>   
>> This change is needed for mgcoge because it uses two ethernet drivers.
>>
>> Add a check for the presence of the PIGGY board on mgcoge.  Without this
>> board networking cannot work and the initialization must be aborted.
>>
>> Only allocate rtx once to prevent DPRAM exhaustion.
>>
>> Initialize ether_scc.c and the keymile-specific HDLC driver (to be added
>> soon) in eth.c.
>>
>> Signed-off-by: Gary Jennejohn <garyj@denx.de>
>>     
>
> Any comments on this?
>
> Best regards,
>
> Wolfgang Denk
>
>   
Looks like I pulled it into the 'next' branch and forgot to tell anyone 
:-(  Do you want it in the current release?

regards,
Ben

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

* [U-Boot] [PATCH v2] mgcoge make ether_scc.c work with CONFIG_NET_MULTI
  2008-12-08 22:05     ` Ben Warren
@ 2008-12-09  8:56       ` Gary Jennejohn
  0 siblings, 0 replies; 10+ messages in thread
From: Gary Jennejohn @ 2008-12-09  8:56 UTC (permalink / raw)
  To: u-boot

On Mon, 08 Dec 2008 14:05:22 -0800
Ben Warren <biggerbadderben@gmail.com> wrote:

> Wolfgang Denk wrote:
> > Dear Ben,
> >
> > In message <20081111170728.73ca9b7a@ernst.jennejohn.org> Gary Jennejohn wrote:
> >   
> >> This change is needed for mgcoge because it uses two ethernet drivers.
> >>
> >> Add a check for the presence of the PIGGY board on mgcoge.  Without this
> >> board networking cannot work and the initialization must be aborted.
> >>
> >> Only allocate rtx once to prevent DPRAM exhaustion.
> >>
> >> Initialize ether_scc.c and the keymile-specific HDLC driver (to be added
> >> soon) in eth.c.
> >>
> >> Signed-off-by: Gary Jennejohn <garyj@denx.de>
> >>     
> >
> > Any comments on this?
> >
> > Best regards,
> >
> > Wolfgang Denk
> >
> >   
> Looks like I pulled it into the 'next' branch and forgot to tell anyone 
> :-(  Do you want it in the current release?
> 

You told me :-)

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

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

end of thread, other threads:[~2008-12-09  8:56 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-09 10:58 [U-Boot] [PATCH] mgcoge make ether_scc.c work with CONFIG_NET_MULTI Gary Jennejohn
2008-11-10  6:09 ` Ben Warren
2008-11-10 17:27   ` Gary Jennejohn
2008-11-10 17:53     ` Ben Warren
2008-11-11 10:41       ` Gary Jennejohn
2008-11-11 16:07 ` [U-Boot] [PATCH v2] " Gary Jennejohn
2008-12-08 20:50   ` Wolfgang Denk
2008-12-08 21:00     ` Wolfgang Denk
2008-12-08 22:05     ` Ben Warren
2008-12-09  8:56       ` Gary Jennejohn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox