diff options
author | Marek Vasut <marek.vasut@gmail.com> | 2020-05-09 22:34:43 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-06-12 13:17:23 -0400 |
commit | d8afb8b28efb5af640d693e7f848732141482cfb (patch) | |
tree | e648e6451cc3c88b155b41f93e5093b9def96832 /drivers/net | |
parent | 2df3a51510758dc6208ecf36f5e4b929d01f2dd1 (diff) |
net: rtl8139: Read HW address from EEPROM only on probe
Do not re-read the HW address from the EEPROM on every start of
transfer, otherwise the user will not be able to adjust ethaddr
as needed. Read the address only once, when the card is detected.
Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/rtl8139.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c index f3190170d3..d7fabdbcf4 100644 --- a/drivers/net/rtl8139.c +++ b/drivers/net/rtl8139.c @@ -502,17 +502,11 @@ static int rtl8139_free_pkt_common(struct rtl8139_priv *priv, unsigned int len) static int rtl8139_init_common(struct rtl8139_priv *priv) { - unsigned short *ap = (unsigned short *)priv->enetaddr; - int addr_len, i; u8 reg; /* Bring the chip out of low-power mode. */ outb(0x00, priv->ioaddr + RTL_REG_CONFIG1); - addr_len = rtl8139_read_eeprom(priv, 0, 8) == 0x8129 ? 8 : 6; - for (i = 0; i < 3; i++) - *ap++ = le16_to_cpu(rtl8139_read_eeprom(priv, i + 7, addr_len)); - rtl8139_reset(priv); reg = inb(priv->ioaddr + RTL_REG_MEDIASTATUS); @@ -521,9 +515,6 @@ static int rtl8139_init_common(struct rtl8139_priv *priv) return -1; } - /* Non-DM compatibility */ - memcpy(priv->dev.enetaddr, priv->enetaddr, 6); - return 0; } @@ -532,6 +523,19 @@ static void rtl8139_stop_common(struct rtl8139_priv *priv) rtl8139_hw_reset(priv); } +static void rtl8139_get_hwaddr(struct rtl8139_priv *priv) +{ + unsigned short *ap = (unsigned short *)priv->enetaddr; + int i, addr_len; + + /* Bring the chip out of low-power mode. */ + outb(0x00, priv->ioaddr + RTL_REG_CONFIG1); + + addr_len = rtl8139_read_eeprom(priv, 0, 8) == 0x8129 ? 8 : 6; + for (i = 0; i < 3; i++) + *ap++ = le16_to_cpu(rtl8139_read_eeprom(priv, i + 7, addr_len)); +} + static void rtl8139_name(char *str, int card_number) { sprintf(str, "RTL8139#%u", card_number); @@ -626,6 +630,11 @@ int rtl8139_initialize(bd_t *bis) dev->recv = rtl8139_recv; dev->mcast = rtl8139_bcast_addr; + rtl8139_get_hwaddr(priv); + + /* Non-DM compatibility */ + memcpy(priv->dev.enetaddr, priv->enetaddr, 6); + eth_register(dev); card_number++; |