* [U-Boot] [PATCH 2/2] at91_emac: Write MAC address automatically
@ 2010-06-15 12:36 Eric Bénard
2010-06-21 5:59 ` Ben Warren
0 siblings, 1 reply; 5+ messages in thread
From: Eric Bénard @ 2010-06-15 12:36 UTC (permalink / raw)
To: u-boot
tested on cpuat91.
Signed-off-by: Eric B?nard <eric@eukrea.com>
---
drivers/net/at91_emac.c | 31 +++++++++++++++++++++++--------
1 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/drivers/net/at91_emac.c b/drivers/net/at91_emac.c
index 1ebcf05..ac5903d 100644
--- a/drivers/net/at91_emac.c
+++ b/drivers/net/at91_emac.c
@@ -352,14 +352,6 @@ static int at91emac_init(struct eth_device *netdev, bd_t *bd)
writel(1 << AT91_ID_EMAC, &pmc->pcer);
writel(readl(&emac->ctl) | AT91_EMAC_CTL_CSR, &emac->ctl);
- DEBUG_AT91EMAC("init MAC-ADDR %x%x \n",
- cpu_to_le16(*((u16 *)(netdev->enetaddr + 4))),
- cpu_to_le32(*((u32 *)netdev->enetaddr)));
- writel(cpu_to_le32(*((u32 *)netdev->enetaddr)), &emac->sa2l);
- writel(cpu_to_le16(*((u16 *)(netdev->enetaddr + 4))), &emac->sa2h);
- DEBUG_AT91EMAC("init MAC-ADDR %x%x \n",
- readl(&emac->sa2h), readl(&emac->sa2l));
-
/* Init Ethernet buffers */
for (i = 0; i < RBF_FRAMEMAX; i++) {
dev->rbfdt[i].addr = (unsigned long) NetRxPackets[i];
@@ -460,6 +452,28 @@ static int at91emac_recv(struct eth_device *netdev)
return 0;
}
+static int at91emac_write_hwaddr(struct eth_device *netdev)
+{
+ emac_device *dev;
+ at91_emac_t *emac;
+ at91_pmc_t *pmc = (at91_pmc_t *) AT91_PMC_BASE;
+
+ if (netdev->enetaddr != 0) {
+ emac = (at91_emac_t *) netdev->iobase;
+ dev = (emac_device *) netdev->priv;
+
+ writel(1 << AT91_ID_EMAC, &pmc->pcer);
+ DEBUG_AT91EMAC("init MAC-ADDR %x%x \n",
+ cpu_to_le16(*((u16 *)(netdev->enetaddr + 4))),
+ cpu_to_le32(*((u32 *)netdev->enetaddr)));
+ writel(cpu_to_le32(*((u32 *)netdev->enetaddr)), &emac->sa2l);
+ writel(cpu_to_le16(*((u16 *)(netdev->enetaddr + 4))), &emac->sa2h);
+ DEBUG_AT91EMAC("init MAC-ADDR %x%x \n",
+ readl(&emac->sa2h), readl(&emac->sa2l));
+ }
+ return 0;
+}
+
int at91emac_register(bd_t *bis, unsigned long iobase)
{
emac_device *emac;
@@ -492,6 +506,7 @@ int at91emac_register(bd_t *bis, unsigned long iobase)
dev->halt = at91emac_halt;
dev->send = at91emac_send;
dev->recv = at91emac_recv;
+ dev->write_hwaddr = at91emac_write_hwaddr;
eth_register(dev);
--
1.6.3.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH 2/2] at91_emac: Write MAC address automatically
2010-06-15 12:36 [U-Boot] [PATCH 2/2] at91_emac: Write MAC address automatically Eric Bénard
@ 2010-06-21 5:59 ` Ben Warren
2010-06-21 7:41 ` [U-Boot] [PATCH v2] " Eric Bénard
2010-06-21 7:50 ` [U-Boot] [PATCH 2/2] " Eric Bénard
0 siblings, 2 replies; 5+ messages in thread
From: Ben Warren @ 2010-06-21 5:59 UTC (permalink / raw)
To: u-boot
Hi Eric,
On 6/15/2010 5:36 AM, Eric B?nard wrote:
> tested on cpuat91.
>
> Signed-off-by: Eric B?nard<eric@eukrea.com>
> ---
> drivers/net/at91_emac.c | 31 +++++++++++++++++++++++--------
> 1 files changed, 23 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/at91_emac.c b/drivers/net/at91_emac.c
> index 1ebcf05..ac5903d 100644
> --- a/drivers/net/at91_emac.c
> +++ b/drivers/net/at91_emac.c
> @@ -352,14 +352,6 @@ static int at91emac_init(struct eth_device *netdev, bd_t *bd)
> writel(1<< AT91_ID_EMAC,&pmc->pcer);
> writel(readl(&emac->ctl) | AT91_EMAC_CTL_CSR,&emac->ctl);
>
> - DEBUG_AT91EMAC("init MAC-ADDR %x%x \n",
> - cpu_to_le16(*((u16 *)(netdev->enetaddr + 4))),
> - cpu_to_le32(*((u32 *)netdev->enetaddr)));
> - writel(cpu_to_le32(*((u32 *)netdev->enetaddr)),&emac->sa2l);
> - writel(cpu_to_le16(*((u16 *)(netdev->enetaddr + 4))),&emac->sa2h);
> - DEBUG_AT91EMAC("init MAC-ADDR %x%x \n",
> - readl(&emac->sa2h), readl(&emac->sa2l));
> -
> /* Init Ethernet buffers */
> for (i = 0; i< RBF_FRAMEMAX; i++) {
> dev->rbfdt[i].addr = (unsigned long) NetRxPackets[i];
> @@ -460,6 +452,28 @@ static int at91emac_recv(struct eth_device *netdev)
> return 0;
> }
>
> +static int at91emac_write_hwaddr(struct eth_device *netdev)
> +{
> + emac_device *dev;
> + at91_emac_t *emac;
> + at91_pmc_t *pmc = (at91_pmc_t *) AT91_PMC_BASE;
> +
> + if (netdev->enetaddr != 0) {
>
This check's not necessary. The caller checks if the MAC address is
valid ( a more extensive check than you do here)
> + emac = (at91_emac_t *) netdev->iobase;
> + dev = (emac_device *) netdev->priv;
> +
> + writel(1<< AT91_ID_EMAC,&pmc->pcer);
> + DEBUG_AT91EMAC("init MAC-ADDR %x%x \n",
> + cpu_to_le16(*((u16 *)(netdev->enetaddr + 4))),
> + cpu_to_le32(*((u32 *)netdev->enetaddr)));
> + writel(cpu_to_le32(*((u32 *)netdev->enetaddr)),&emac->sa2l);
> + writel(cpu_to_le16(*((u16 *)(netdev->enetaddr + 4))),&emac->sa2h);
> + DEBUG_AT91EMAC("init MAC-ADDR %x%x \n",
> + readl(&emac->sa2h), readl(&emac->sa2l));
> + }
> + return 0;
> +}
> +
> int at91emac_register(bd_t *bis, unsigned long iobase)
> {
> emac_device *emac;
> @@ -492,6 +506,7 @@ int at91emac_register(bd_t *bis, unsigned long iobase)
> dev->halt = at91emac_halt;
> dev->send = at91emac_send;
> dev->recv = at91emac_recv;
> + dev->write_hwaddr = at91emac_write_hwaddr;
>
> eth_register(dev);
>
>
regards,
Ben
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH v2] at91_emac: Write MAC address automatically
2010-06-21 5:59 ` Ben Warren
@ 2010-06-21 7:41 ` Eric Bénard
2010-06-21 17:57 ` Ben Warren
2010-06-21 7:50 ` [U-Boot] [PATCH 2/2] " Eric Bénard
1 sibling, 1 reply; 5+ messages in thread
From: Eric Bénard @ 2010-06-21 7:41 UTC (permalink / raw)
To: u-boot
tested on cpuat91.
Signed-off-by: Eric B?nard <eric@eukrea.com>
---
v2 :
don't check if the MAC address is valid
drivers/net/at91_emac.c | 28 ++++++++++++++++++++--------
1 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/drivers/net/at91_emac.c b/drivers/net/at91_emac.c
index cf0a7c0..1213a1a 100644
--- a/drivers/net/at91_emac.c
+++ b/drivers/net/at91_emac.c
@@ -360,14 +360,6 @@ static int at91emac_init(struct eth_device *netdev, bd_t *bd)
writel(1 << AT91_ID_EMAC, &pmc->pcer);
writel(readl(&emac->ctl) | AT91_EMAC_CTL_CSR, &emac->ctl);
- DEBUG_AT91EMAC("init MAC-ADDR %x%x \n",
- cpu_to_le16(*((u16 *)(netdev->enetaddr + 4))),
- cpu_to_le32(*((u32 *)netdev->enetaddr)));
- writel(cpu_to_le32(*((u32 *)netdev->enetaddr)), &emac->sa2l);
- writel(cpu_to_le16(*((u16 *)(netdev->enetaddr + 4))), &emac->sa2h);
- DEBUG_AT91EMAC("init MAC-ADDR %x%x \n",
- readl(&emac->sa2h), readl(&emac->sa2l));
-
/* Init Ethernet buffers */
for (i = 0; i < RBF_FRAMEMAX; i++) {
dev->rbfdt[i].addr = (unsigned long) NetRxPackets[i];
@@ -468,6 +460,25 @@ static int at91emac_recv(struct eth_device *netdev)
return 0;
}
+static int at91emac_write_hwaddr(struct eth_device *netdev)
+{
+ emac_device *dev;
+ at91_emac_t *emac;
+ at91_pmc_t *pmc = (at91_pmc_t *) AT91_PMC_BASE;
+ emac = (at91_emac_t *) netdev->iobase;
+ dev = (emac_device *) netdev->priv;
+
+ writel(1 << AT91_ID_EMAC, &pmc->pcer);
+ DEBUG_AT91EMAC("init MAC-ADDR %x%x \n",
+ cpu_to_le16(*((u16 *)(netdev->enetaddr + 4))),
+ cpu_to_le32(*((u32 *)netdev->enetaddr)));
+ writel(cpu_to_le32(*((u32 *)netdev->enetaddr)), &emac->sa2l);
+ writel(cpu_to_le16(*((u16 *)(netdev->enetaddr + 4))), &emac->sa2h);
+ DEBUG_AT91EMAC("init MAC-ADDR %x%x \n",
+ readl(&emac->sa2h), readl(&emac->sa2l));
+ return 0;
+}
+
int at91emac_register(bd_t *bis, unsigned long iobase)
{
emac_device *emac;
@@ -500,6 +511,7 @@ int at91emac_register(bd_t *bis, unsigned long iobase)
dev->halt = at91emac_halt;
dev->send = at91emac_send;
dev->recv = at91emac_recv;
+ dev->write_hwaddr = at91emac_write_hwaddr;
eth_register(dev);
--
1.6.3.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH 2/2] at91_emac: Write MAC address automatically
2010-06-21 5:59 ` Ben Warren
2010-06-21 7:41 ` [U-Boot] [PATCH v2] " Eric Bénard
@ 2010-06-21 7:50 ` Eric Bénard
1 sibling, 0 replies; 5+ messages in thread
From: Eric Bénard @ 2010-06-21 7:50 UTC (permalink / raw)
To: u-boot
Hi Ben,
Le 21/06/2010 07:59, Ben Warren a ?crit :
> On 6/15/2010 5:36 AM, Eric B?nard wrote:
>> +
>> + if (netdev->enetaddr != 0) {
>>
> This check's not necessary. The caller checks if the MAC address is
> valid ( a more extensive check than you do here)
OK, fixed patch sent, thanks.
Eric
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH v2] at91_emac: Write MAC address automatically
2010-06-21 7:41 ` [U-Boot] [PATCH v2] " Eric Bénard
@ 2010-06-21 17:57 ` Ben Warren
0 siblings, 0 replies; 5+ messages in thread
From: Ben Warren @ 2010-06-21 17:57 UTC (permalink / raw)
To: u-boot
Hi Eric,
On 6/21/2010 12:41 AM, Eric B?nard wrote:
> tested on cpuat91.
>
> Signed-off-by: Eric B?nard<eric@eukrea.com>
> ---
> v2 :
> don't check if the MAC address is valid
>
> drivers/net/at91_emac.c | 28 ++++++++++++++++++++--------
> 1 files changed, 20 insertions(+), 8 deletions(-)
>
Applied to net/next repo.
regards,
Ben
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-06-21 17:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-15 12:36 [U-Boot] [PATCH 2/2] at91_emac: Write MAC address automatically Eric Bénard
2010-06-21 5:59 ` Ben Warren
2010-06-21 7:41 ` [U-Boot] [PATCH v2] " Eric Bénard
2010-06-21 17:57 ` Ben Warren
2010-06-21 7:50 ` [U-Boot] [PATCH 2/2] " Eric Bénard
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.