From: Igor Grinberg <grinberg@compulab.co.il>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 6/8] AM35xx: Read and set ethaddr for EMAC
Date: Wed, 07 Dec 2011 16:48:24 +0200 [thread overview]
Message-ID: <4EDF7CB8.3030205@compulab.co.il> (raw)
In-Reply-To: <1323186582-2811-7-git-send-email-trini@ti.com>
Hi Steve, Tom,
On 12/06/11 17:49, Tom Rini wrote:
> From: Steve Kipisz <s-kipisz2@ti.com>
>
> Signed-off-by: Steve Kipisz <s-kipisz2@ti.com>
> Signed-off-by: Tom Rini <trini@ti.com>
> ---
> arch/arm/cpu/armv7/omap3/emac.c | 20 +++++++++++++++++++-
> arch/arm/include/asm/arch-omap3/emac_defs.h | 3 +++
> 2 files changed, 22 insertions(+), 1 deletions(-)
>
> diff --git a/arch/arm/cpu/armv7/omap3/emac.c b/arch/arm/cpu/armv7/omap3/emac.c
> index 14667f1..d400bef 100644
> --- a/arch/arm/cpu/armv7/omap3/emac.c
> +++ b/arch/arm/cpu/armv7/omap3/emac.c
> @@ -26,6 +26,7 @@
> #include <netdev.h>
> #include <asm/io.h>
> #include <asm/arch/am35x_def.h>
> +#include <asm/arch/emac_defs.h>
>
> /*
> * Initializes on-chip ethernet controllers.
> @@ -33,12 +34,29 @@
> */
> int cpu_eth_init(bd_t *bis)
> {
> - u32 reset;
> + u32 reset, msb, lsb;
> + u_int8_t macaddr[6];
> + int i;
>
> /* ensure that the module is out of reset */
> reset = readl(&am35x_scm_general_regs->ip_sw_reset);
> reset &= ~CPGMACSS_SW_RST;
> writel(reset, &am35x_scm_general_regs->ip_sw_reset);
>
> + /* Read MAC address */
> + msb = readl(EMAC_MACADDR_MSB);
> + lsb = readl(EMAC_MACADDR_LSB);
> +
> + for (i = 0; i < 3; i++) {
> + macaddr[5 - i] = lsb & 0xFF;
> + lsb >>= 8;
> + }
> +
> + for (i = 0; i < 3; i++) {
> + macaddr[2 - i] = msb & 0xFF;
> + msb >>= 8;
> + }
> + eth_setenv_enetaddr("ethaddr", macaddr);
> +
This is a wrong place for this code...
You force every board to use the EFUSE'd MAC address - this is wrong.
The board must have a freedom to choose what MAC address it wants to use.
You don't even check if ethaddr variable is already set...
What you can do is put this implementation into a separate function
and let board to make a decision if it wants to call it or use another
MAC address.
Something like:
int am3517_get_efuse_enetaddr(u8 *enetaddr)
{
/* read the address and shift or whatever */
...
return is_valid_ether_addr(enetaddr);
}
> return davinci_emac_initialize();
> }
> diff --git a/arch/arm/include/asm/arch-omap3/emac_defs.h b/arch/arm/include/asm/arch-omap3/emac_defs.h
> index 8506c55..c3c96c0 100644
> --- a/arch/arm/include/asm/arch-omap3/emac_defs.h
> +++ b/arch/arm/include/asm/arch-omap3/emac_defs.h
> @@ -42,6 +42,9 @@
> #define EMAC_MDIO_BASE_ADDR 0x5C030000
> #define EMAC_HW_RAM_ADDR 0x01E20000
>
> +#define EMAC_MACADDR_LSB 0x48002380
> +#define EMAC_MACADDR_MSB 0x48002384
> +
> #define EMAC_MDIO_BUS_FREQ 166000000 /* 166 MHZ check */
> #define EMAC_MDIO_CLOCK_FREQ 1000000 /* 2.0 MHz */
>
--
Regards,
Igor.
next prev parent reply other threads:[~2011-12-07 14:48 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-06 15:49 [U-Boot] [PATCH 0/8] AM3517 EVM / Crane enhancements Tom Rini
2011-12-06 15:49 ` [U-Boot] [PATCH 1/8] OMAP3: Correct SYSBOOT_MASK Tom Rini
2011-12-06 15:49 ` [U-Boot] [PATCH 2/8] OMAP3: Drop extra delay in gpmc_init Tom Rini
2011-12-06 15:49 ` [U-Boot] [PATCH 3/8] AM3517: Add NOR Flash boot mode Support Tom Rini
2011-12-07 14:25 ` Igor Grinberg
2011-12-08 1:07 ` Tom Rini
2011-12-08 14:12 ` Igor Grinberg
2011-12-08 14:38 ` Tom Rini
2011-12-08 15:11 ` Igor Grinberg
2011-12-08 11:11 ` Hiremath, Vaibhav
2011-12-08 13:48 ` Igor Grinberg
2011-12-08 17:40 ` Hiremath, Vaibhav
2011-12-06 15:49 ` [U-Boot] [PATCH 4/8] AM3517 EVM: Add uEnv.txt to the default bootcmd Tom Rini
2011-12-06 15:49 ` [U-Boot] [PATCH 5/8] AM3517 EVM: Add am3517_evm_norflash and _norflash_boot targets Tom Rini
2011-12-06 15:49 ` [U-Boot] [PATCH 6/8] AM35xx: Read and set ethaddr for EMAC Tom Rini
2011-12-07 14:48 ` Igor Grinberg [this message]
2011-12-07 14:54 ` Tom Rini
2011-12-07 17:41 ` Wolfgang Denk
2011-12-06 15:49 ` [U-Boot] [PATCH 7/8] AM3517 EVM: Enable ethernet Tom Rini
2011-12-06 15:49 ` [U-Boot] [PATCH 8/8] AM3517 Crane: " Tom Rini
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=4EDF7CB8.3030205@compulab.co.il \
--to=grinberg@compulab.co.il \
--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