public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH] lan91c96 driver MAC address detection
@ 2004-04-29 17:02 Dave Peverley
  2004-04-30 19:59 ` George G. Davis
  2004-06-06 22:12 ` [U-Boot-Users] [PATCH] lan91c96 driver MAC address detection Wolfgang Denk
  0 siblings, 2 replies; 11+ messages in thread
From: Dave Peverley @ 2004-04-29 17:02 UTC (permalink / raw)
  To: u-boot

Hi all,

  This is a small patch for the lan91c96 ethernet driver that adds the
capability to automatically detect the MAC address stored in EPROM in the
absence of a valid MAC address in the environment. It is modelled on the
system used by the smc91111 driver as suggested by Marius Groeger 
(thanks!)

The patch itself was created against the CVS repository tag 
"U-Boot-1_1_0" using the command :
  diff -purN u-boot u-boot-omap730p2 > u-boot-1.1.0-omap730p2.patch

All comments and feedback welcome.

Best Wishes,

Dave Peverley


---------------------------------------------------------------------------
             Dave Peverley, Software Engineer, MPC Data Limited.
Phone : [+44] (0) 1225 868 228              Web : http://www.mpc-data.co.uk
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: u-boot-1.1.0-lan91c96-mac-detect.patch
Url: http://lists.denx.de/pipermail/u-boot/attachments/20040429/02301e27/attachment.txt 

^ permalink raw reply	[flat|nested] 11+ messages in thread
* [U-Boot-Users] [PATCH] lan91c96 driver MAC address detection
@ 2004-05-04 16:20 Woodruff, Richard
  2004-05-04 17:12 ` Wolfgang Denk
  0 siblings, 1 reply; 11+ messages in thread
From: Woodruff, Richard @ 2004-05-04 16:20 UTC (permalink / raw)
  To: u-boot

Actually, I added the following 2 functions to remove related
problems... 

Aside from the warning you will find that if you 'directly' boot your
system and have NOT set the mac address via the indirect bootp probe, a
kernel built for a nfsroot won't make it, as the kernel driver assumes a
valid mac is set (or available).  So, in my board's misc_init_r() I make
sure to probe for a chip, if its there go ahead and set the mac address
up.  (several boards I've used didn't have a serial eeprom).  Seems like
some chips do something similar (reset anyway) in lib_arm/board.c, but I
think its better to done at the board level.

This probably also kills the mac warning.

Regards,

Richard W.



=============== Added to smc91111.c =======================
static int smc_probe(void)
{
	int bank;
	
	bank =  SMC_inw (BANK_SELECT);
	if ((bank & 0xFF00) != 0x3300)
		return -1;
	return 0;
}

/* 
 * Set MAC address even if smc_open is not called by u-boot. Its a good
idea
 * for the mac to be set in the chip when the kernel starts (no eeprom
case).
 */
int eth_mac_config(bd_t *bd)
{
	int err, i;

	err = smc_probe();
        if(err >= 0){
		SMC_SELECT_BANK (1);
		smc_get_ethaddr (bd);
		for (i = 0; i < 6; i++)
			SMC_outb (smc_mac_addr[i], ADDR0_REG + i);
	}
	return err;
}



========== in myboard.c file ================
int misc_init_r (void)
{   
#ifdef CONFIG_DRIVER_SMC91111
    DECLARE_GLOBAL_DATA_PTR;
    extern int eth_mac_config(bd_t *);

    /* for development board enable ethernet */
    /* take chip out of reset (need shadow reg) */
    toto_bcr_write( toto_bcr_read() | TOTO_BCR_COM_RESET);
    udelay(300);    
    eth_mac_config(gd->bd); /* set mac addr in chip */
#endif

    return(0);
}


> -----Original Message-----
> From: u-boot-users-admin at lists.sourceforge.net [mailto:u-boot-users-
> admin at lists.sourceforge.net] On Behalf Of Dave Peverley
> Sent: Tuesday, May 04, 2004 7:33 AM
> To: Wolfgang Denk
> Cc: u-boot-users at lists.sourceforge.net
> Subject: Re: [U-Boot-Users] [PATCH] lan91c96 driver MAC address
detection
> 
> Wolfgang Denk wrote:
> > The rules are simple and documented:
> Sure, I've read these...
> 
> > You cannot use BOOTP (nor ony  other  network  related  protocol)
to
> > detect a MAC address!!!
> I think that either we operate on utterly different brainwave-lengths
> or theres some kind of language barrier issue here!
> 
> If you issue a 'bootp' command to u-boot via its interface as I
stated,
> the following call sequence happens if you're using the lan91c96 (with
> patch) or smc91111 ethernet devices :
> 
>    do_bootp()                     [cmd_net.c]
>     netboot_common()              [cmd_net.c]
>      NetLoop()                    [net.c]
>       eth_init()                  [lan91c96.c]
>        smc_open()                 [lan91c96.c]
>         smc_get_ethaddr()         [lan91c96.c]
>          get_rom_mac()            [lan91c96.c]
> 
> So in practical use, issuing a bootp detects the mac address of the
> adapter.
> 
> > (nor ony  other  network  related  protocol)
> Well, the following network related protocol calls :
>   do_tftpb()
>   do_rarpb()
>   do_dhcp()
>   do_nfs()
> all call netboot_common() so will in effect detect the MAC address as
> well ;-)
> 
> Best Wishes,
> 
> Dave Peverley
> 
>
------------------------------------------------------------------------
--
> -
>              Dave Peverley, Software Engineer, MPC Data Limited.
> Phone : [+44] (0) 1225 868 228              Web : http://www.mpc-
> data.co.uk
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: Oracle 10g
> Get certified on the hottest thing ever to hit the market... Oracle
10g.
> Take an Oracle 10g class now, and we'll give you the exam FREE.
> http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
> _______________________________________________
> U-Boot-Users mailing list
> U-Boot-Users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/u-boot-users

^ permalink raw reply	[flat|nested] 11+ messages in thread
* [U-Boot-Users] [PATCH] lan91c96 driver MAC address detection
@ 2004-05-04 17:19 Woodruff, Richard
  0 siblings, 0 replies; 11+ messages in thread
From: Woodruff, Richard @ 2004-05-04 17:19 UTC (permalink / raw)
  To: u-boot

:)

You might say that the u-boot 'bootp command implementation', which
utilizes the bootp protocol, will initialize the ether driver which in
turn causes mac address initialization.  All u-boot network 'commands'
do this as their protocols require that the mac is setup as a
precondition to their use.

I have to admit the first time I read the post I was confused to the
intent.

Regards,

Richard W.

> -----Original Message-----
> From: u-boot-users-admin at lists.sourceforge.net [mailto:u-boot-users-
> admin at lists.sourceforge.net] On Behalf Of Wolfgang Denk
> Sent: Tuesday, May 04, 2004 12:02 PM
> To: Dave Peverley
> Cc: u-boot-users at lists.sourceforge.net
> Subject: Re: [U-Boot-Users] [PATCH] lan91c96 driver MAC address
detection
> 
> In message <40978D65.7030805@mpc-data.co.uk> you wrote:
> >
> > > You cannot use BOOTP (nor ony  other  network  related  protocol)
to
> > > detect a MAC address!!!
> > I think that either we operate on utterly different
brainwave-lengths
> > or theres some kind of language barrier issue here!
> 
> BOOTP is a well-defined protocol which is  based  on  the  assumption
> that  you  have  a  network  interface  that  can be used to send and
> receive packets. To do so, the interface must be  initialized.  BOOTP
> does  in  NO  WAY  work if your interface does not have a MAC address
> set. Especially, it does NOT retrieve the MAC address from anywhere.
> 
> > If you issue a 'bootp' command to u-boot via its interface as I
stated,
> > the following call sequence happens if you're using the lan91c96
(with
> > patch) or smc91111 ethernet devices :
> >
> >    do_bootp()                     [cmd_net.c]
> >     netboot_common()              [cmd_net.c]
> >      NetLoop()                    [net.c]
> >       eth_init()                  [lan91c96.c]
> 
> Stop here. eth_init() performs the  initialization  of  the  ethernet
> interface,  if  this  did  not  happen before, because an initialized
> ethernet interface is a precondition to use BOOTP.
> 
> > So in practical use, issuing a bootp detects the mac address of the
> > adapter.
> 
> No, no, no. This is plainly wrong.
> 
> > Well, the following network related protocol calls :
> >   do_tftpb()
> >   do_rarpb()
> >   do_dhcp()
> >   do_nfs()
> > all call netboot_common() so will in effect detect the MAC address
as
> > well ;-)
> 
> None of these protocols has ato do  anything  with  setting  the  MAC
> address. Please don't mix things up.
> 
> You could as well claim that bootp sets the baudrate  of  the  serial
> console,  because  to  run  bootp  you must execute an initialization
> sequence which includes the serial port, thus setting the baudrate.
> 
> IT AIN'T SO!
> 
> 
> Wolfgang Denk
> 
> --
> Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
> Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd at denx.de
> Oh, that sound of male ego.  You travel halfway across the galaxy and
> it's still the same song.
> 	-- Eve McHuron, "Mudd's Women", stardate 1330.1
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: Oracle 10g
> Get certified on the hottest thing ever to hit the market... Oracle
10g.
> Take an Oracle 10g class now, and we'll give you the exam FREE.
> http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
> _______________________________________________
> U-Boot-Users mailing list
> U-Boot-Users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/u-boot-users

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

end of thread, other threads:[~2004-06-06 22:12 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-29 17:02 [U-Boot-Users] [PATCH] lan91c96 driver MAC address detection Dave Peverley
2004-04-30 19:59 ` George G. Davis
2004-05-04  9:48   ` Dave Peverley
2004-05-04 12:06     ` Wolfgang Denk
2004-05-04 12:32       ` Dave Peverley
2004-05-04 17:02         ` Wolfgang Denk
2004-05-04 17:55           ` Communication (Was Re: [U-Boot-Users] [PATCH] lan91c96 driver MAC address detection) Dave Peverley
2004-06-06 22:12 ` [U-Boot-Users] [PATCH] lan91c96 driver MAC address detection Wolfgang Denk
  -- strict thread matches above, loose matches on Subject: below --
2004-05-04 16:20 Woodruff, Richard
2004-05-04 17:12 ` Wolfgang Denk
2004-05-04 17:19 Woodruff, Richard

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