[PATCH 3/3] net: RTL-8125B -- write mac to MAC0_BKP

In the case of RTL-8125B, Linux reads the mac address from register MAC0_BKP instead of MAC0, so let u-boot write the mac address there.
Note: writing to MAC0 is still needed too, because this register is used by the hardware for mac filtering (the board will not receive packets if MAC0 is not set).
Tested on a FriendlyElec Nanopi R5C board.
Signed-off-by: Etienne Dublé etienne.duble@imag.fr
---
drivers/net/rtl8169.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c index b30d51731f..7c4d658c6b 100644 --- a/drivers/net/rtl8169.c +++ b/drivers/net/rtl8169.c @@ -153,6 +153,7 @@ enum RTL8125_registers { IntrMask_8125 = 0x38, IntrStatus_8125 = 0x3C, TxPoll_8125 = 0x90, + MAC0_BKP = 0x19e0, };
enum RTL8169_register_content { @@ -881,6 +882,7 @@ void rtl8169_eth_stop(struct udevice *dev) static int rtl8169_write_hwaddr(struct udevice *dev) { struct eth_pdata *plat = dev_get_plat(dev); + struct pci_child_plat *pplat = dev_get_parent_plat(dev); unsigned int i;
RTL_W8(Cfg9346, Cfg9346_Unlock); @@ -888,6 +890,19 @@ static int rtl8169_write_hwaddr(struct udevice *dev) for (i = 0; i < MAC_ADDR_LEN; i++) RTL_W8(MAC0 + i, plat->enetaddr[i]);
+ /* + * In the case of RTL8125, linux is reading the mac + * address from register MAC0_BKP instead of MAC0, + * so let's copy it there. + * Note: we still need to write the mac to MAC0 too + * (cf. the loop above) because the hardware uses MAC0 + * for mac filtering. + */ + if (pplat->device == 0x8125) { + for (i = 0; i < MAC_ADDR_LEN; i++) + RTL_W8(MAC0_BKP + i, plat->enetaddr[i]); + } + RTL_W8(Cfg9346, Cfg9346_Lock);
return 0;
participants (1)
-
ETIENNE DUBLE