public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Nick Thompson <nick.thompson@ge.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 1/2][NEXT] davinci_emac: davinci_eth_set_mac_addr to ->write_hwaddr
Date: Thu, 23 Sep 2010 10:03:21 +0100	[thread overview]
Message-ID: <4C9B17D9.6020700@ge.com> (raw)
In-Reply-To: <d13a16f23dd9891f49916c13b983389ed659f8c7.1285180933.git.bengardiner@nanometrics.ca>

On 22/09/10 19:44, Ben Gardiner wrote:
> This patch proposes to migrate the davinci_emac driver to using the
> eth_device->write_hwaddr function pointer as suggested by Ben Warren.
> 
> All the davinci boards had the behaviour, prior to this patch, of
> sync'ing the environment variable enetaddr with the MAC address read
> from non-volatile storage on boot -- when the two locations disagreed,
> the environment variable value took precendence. This patch keeps the
> same behaviour but lets eth_initialize take care of it.
> 
> This patch refactors davinci_emac setup in the boards so that the MAC
> address is read from non-volatile storage into the environment variable
> and then the environment variable value is use in eth_intialize. The
> only exception is the direct call to davinci_eth_set_mac_addr made by
> the da830evm board init which was changed into an assignment of the
> enetaddr field.
> 
> Signed-off-by: Ben Gardiner <bengardiner@nanometrics.ca>
> CC: Ben Warren <biggerbadderben@gmail.com>
> CC: Nick Thompson <nick.thompson@ge.com>
> 
> --
> 
> V4:
>   * no changes
> V3:
>   * rebased to u-boot/next, removed additional direct call of
>     davinci_eth_set_mac_addr added to board_init_r by Heiko's
>     relocation patches
> V2:
>   * introduced this patch
> ---
>  arch/arm/include/asm/arch-davinci/emac_defs.h |    1 -
>  arch/arm/lib/board.c                          |   19 ------
>  board/davinci/common/misc.c                   |   41 +++----------
>  board/davinci/common/misc.h                   |    2 +-
>  board/davinci/da8xxevm/da830evm.c             |   15 ++++-
>  board/davinci/dm365evm/dm365evm.c             |    2 +-
>  board/davinci/dvevm/dvevm.c                   |    2 +-
>  board/davinci/sffsdr/sffsdr.c                 |    2 +-
>  board/davinci/sonata/sonata.c                 |    2 +-
>  drivers/net/davinci_emac.c                    |   80 ++++++++++++-------------
>  10 files changed, 64 insertions(+), 102 deletions(-)
> 

[snip]

> diff --git a/board/davinci/da8xxevm/da830evm.c b/board/davinci/da8xxevm/da830evm.c
> index 6baa860..d5a228f 100644
> --- a/board/davinci/da8xxevm/da830evm.c
> +++ b/board/davinci/da8xxevm/da830evm.c
> @@ -196,19 +196,17 @@ int board_eth_init(bd_t *bis)
>  {
>  	u_int8_t mac_addr[6];
>  	u_int8_t switch_start_cmd[2] = { 0x01, 0x23 };
> +	struct eth_device *dev;
>  
>  	/* Read Ethernet MAC address from EEPROM */
>  	if (dvevm_read_mac_address(mac_addr))
>  		/* set address env if not already set */
> -		dv_configure_mac_address(mac_addr);
> +		davinci_sync_env_enetaddr(mac_addr);
>  
>  	/* read the address back from env */
>  	if (!eth_getenv_enetaddr("ethaddr", mac_addr))
>  		return -1;
>  
> -	/* provide the resulting addr to the driver */
> -	davinci_eth_set_mac_addr(mac_addr);
> -
>  	/* enable the Ethernet switch in the 3 port PHY */
>  	if (i2c_write(PHY_SW_I2C_ADDR, 0, 0,
>  			switch_start_cmd, sizeof(switch_start_cmd))) {
> @@ -222,6 +220,15 @@ int board_eth_init(bd_t *bis)
>  		return -1;
>  	}
>  
> +	dev = eth_get_dev();
> +
> +	/* provide the resulting addr to the driver */
> +	memcpy(dev->enetaddr, mac_addr, 6);
> +	if (!dev->write_hwaddr(dev)) {
> +		printf("Error: Could not set MAC address\n");
> +		return -1;
> +	}
> +
>  	return 0;
>  }
>  #endif /* CONFIG_DRIVER_TI_EMAC */

Hi Ben,

davinci_eth_set_mac_addr() always returns zero, so "if (!dev->write_hwaddr(dev))"
always appears to fail here. 

In net/eth.c the return code is not checked, so da830 should probably ignore it to:

diff --git a/board/davinci/da8xxevm/da830evm.c b/board/davinci/da8xxevm/da830evm.c
index d5a228f..8a9f988 100644
--- a/board/davinci/da8xxevm/da830evm.c
+++ b/board/davinci/da8xxevm/da830evm.c
@@ -224,10 +224,7 @@ int board_eth_init(bd_t *bis)
 
        /* provide the resulting addr to the driver */
        memcpy(dev->enetaddr, mac_addr, 6);
-       if (!dev->write_hwaddr(dev)) {
-               printf("Error: Could not set MAC address\n");
-               return -1;
-       }
+       dev->write_hwaddr(dev);
 
        return 0;
 }

With this change, this patch works on da830. I'll retest when you resubmit.

Nick.

  reply	other threads:[~2010-09-23  9:03 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-10 20:10 [U-Boot] [PATCH] da850evm: basic MII EMAC support Ben Gardiner
2010-09-11  4:01 ` Mike Frysinger
2010-09-13 12:55   ` Ben Gardiner
2010-09-14 13:00     ` Mike Frysinger
2010-09-14 13:07       ` Ben Gardiner
2010-09-13  3:45 ` Ben Warren
2010-09-13 13:07   ` Ben Gardiner
2010-09-13 13:16     ` Ben Warren
2010-09-13 21:04       ` [U-Boot] [PATCH v2 0/2] da850evm " Ben Gardiner
2010-09-13 21:04         ` [U-Boot] [PATCH v2 1/2] davinci_emac: davinci_eth_set_mac_addr to ->write_hwaddr Ben Gardiner
2010-09-14  8:37           ` Nick Thompson
2010-09-13 21:04         ` [U-Boot] [PATCH v2 2/2] da850evm: basic MII EMAC support Ben Gardiner
2010-09-22 17:16         ` [U-Boot] [PATCH v3 0/2][NEXT] da850evm " Ben Gardiner
2010-09-22 17:16           ` [U-Boot] [PATCH v3 1/2][NEXT] davinci_emac: davinci_eth_set_mac_addr to ->write_hwaddr Ben Gardiner
2010-09-22 17:16           ` [U-Boot] [PATCH v3 2/2][NEXT] da850evm: basic MII EMAC support Ben Gardiner
2010-09-22 18:21             ` Mike Frysinger
2010-09-22 18:38               ` Ben Gardiner
2010-09-22 18:44           ` [U-Boot] [PATCH v4 0/2][NEXT] da850evm " Ben Gardiner
2010-09-22 18:44             ` [U-Boot] [PATCH v4 1/2][NEXT] davinci_emac: davinci_eth_set_mac_addr to ->write_hwaddr Ben Gardiner
2010-09-23  9:03               ` Nick Thompson [this message]
2010-09-23 13:24                 ` Ben Gardiner
2010-09-22 18:44             ` [U-Boot] [PATCH v4 2/2][NEXT] da850evm: basic MII EMAC support Ben Gardiner
2010-09-23 13:33             ` [U-Boot] [PATCH v5 0/2][NEXT] da850evm " Ben Gardiner
2010-09-23 13:33               ` [U-Boot] [PATCH v5 1/2][NEXT] davinci_emac: davinci_eth_set_mac_addr to ->write_hwaddr Ben Gardiner
2010-09-23 13:49                 ` Nick Thompson
2010-09-23 13:53                   ` Ben Gardiner
2010-09-23 13:39               ` [U-Boot] [PATCH v5 2/2][NEXT] da850evm: basic MII EMAC support Ben Gardiner
2010-09-23 13:58               ` [U-Boot] [PATCH v6 0/2][NEXT] da850evm " Ben Gardiner
2010-09-23 13:58                 ` [U-Boot] [PATCH v6 1/2][NEXT] davinci_emac: davinci_eth_set_mac_addr to ->write_hwaddr Ben Gardiner
2010-10-12  6:11                   ` Ben Warren
2010-09-23 13:59                 ` [U-Boot] [PATCH v6 2/2][NEXT] da850evm: basic MII EMAC support Ben Gardiner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C9B17D9.6020700@ge.com \
    --to=nick.thompson@ge.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox