[U-Boot] [PATCH 2/2] ARM:AM33XX:Added cpsw support for AM335x EVM

Tom Rini tom.rini at gmail.com
Fri Oct 21 17:44:30 CEST 2011


On Fri, Oct 21, 2011 at 12:02 AM, Chandan Nath <chandan.nath at ti.com> wrote:
> This patch adds cpsw support on AM335X EVM.
>
> Signed-off-by: Chandan Nath <chandan.nath at ti.com>
[snip]
> +int board_eth_init(bd_t *bis)
> +{
> +       uint8_t mac_addr[6];
> +       uint32_t mac_hi, mac_lo;
> +       char mac_buf[32];
> +
> +       if (!eth_getenv_enetaddr("ethaddr", mac_addr)) {
> +               debug("<ethaddr> not set. Reading from E-fuse\n");
> +               /* try reading mac address from efuse */
> +               mac_lo = readl(&cdev->macid0l);
> +               mac_hi = readl(&cdev->macid0h);
> +               mac_addr[0] = mac_hi & 0xFF;
> +               mac_addr[1] = (mac_hi & 0xFF00) >> 8;
> +               mac_addr[2] = (mac_hi & 0xFF0000) >> 16;
> +               mac_addr[3] = (mac_hi & 0xFF000000) >> 24;
> +               mac_addr[4] = mac_lo & 0xFF;
> +               mac_addr[5] = (mac_lo & 0xFF00) >> 8;
> +
> +               if (is_valid_ether_addr(mac_addr)) {
> +                       sprintf(mac_buf, "%02x:%02x:%02x:%02x:%02x:%02x",
> +                               mac_addr[0], mac_addr[1], mac_addr[2],
> +                               mac_addr[3], mac_addr[4], mac_addr[5]);
> +
> +                       printf("ENET MAC address: %s\n", mac_buf);
> +                       setenv("ethaddr", (char *)mac_buf);

This should be eth_setenv_enetaddr("ethaddr", mac_addr) like in my tree.  Please
check there as well before submitting patches to the ML as there's some cleanups
I did while updating the original codebase.  Thanks.

[snip]
> diff --git a/common/miiphyutil.c b/common/miiphyutil.c
> index 35ad357..4551240 100644
> --- a/common/miiphyutil.c
> +++ b/common/miiphyutil.c
> @@ -558,7 +558,7 @@ int miiphy_is_1000base_x(const char *devname, unsigned char addr)
>                        "1000BASE-X\n");
>                return 0;
>        }
> -       return 0 != (exsr & (ESTATUS_1000XF | ESTATUS_1000XH));
> +       return 0;
>  #else
>        return 0;
>  #endif

And this, if nothing else, needs a bit of explanation.

> diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
> index 4cef4cf..c41eeaf 100644
> --- a/drivers/net/cpsw.c
> +++ b/drivers/net/cpsw.c
> @@ -1,22 +1,16 @@

These cleanups and changes should be folded into the initial driver submission.

Also:

> +static u_int8_t cpsw_eth_mac_addr[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x66 };
> +
> +/*
> + * This function must be called before cpsw_init() if you want to override
> + * the default mac address.
> + */
> +void cpsw_eth_set_mac_addr(const u_int8_t *addr)
> +{
> +       int i;
> +
> +       for (i = 0; i < sizeof(cpsw_eth_mac_addr); i++)
> +               cpsw_eth_mac_addr[i] = addr[i];
> +}
> +

This goes away, again please see my tree.

-- 
Tom


More information about the U-Boot mailing list