From 69d6da3c1c63675524a25e7dc92a4f43c4164cef Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Mon, 20 Nov 2023 06:31:22 +0000
Subject: [PATCH] add r8169 read mac form eeprom
---
kernel/drivers/net/ethernet/realtek/r8169.c | 31 ++++++++++++++++++++++++++++---
1 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/kernel/drivers/net/ethernet/realtek/r8169.c b/kernel/drivers/net/ethernet/realtek/r8169.c
index 99678fd..cc7db2f 100644
--- a/kernel/drivers/net/ethernet/realtek/r8169.c
+++ b/kernel/drivers/net/ethernet/realtek/r8169.c
@@ -7435,6 +7435,7 @@
clk_disable_unprepare(data);
}
+extern ssize_t at24_mac1_read(unsigned char* mac);
static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
const struct rtl_cfg_info *cfg = rtl_cfg_infos + ent->driver_data;
@@ -7442,6 +7443,7 @@
struct net_device *dev;
int chipset, region, i;
int jumbo_max, rc;
+ unsigned char mac[6];
dev = devm_alloc_etherdev(&pdev->dev, sizeof (*tp));
if (!dev)
@@ -7593,8 +7595,30 @@
default:
break;
}
- for (i = 0; i < ETH_ALEN; i++)
- dev->dev_addr[i] = RTL_R8(tp, MAC0 + i);
+// for (i = 0; i < ETH_ALEN; i++)
+// dev->dev_addr[i] = RTL_R8(tp, MAC0 + i);
+ memset(mac, 0x00, 6);
+ at24_mac1_read(mac);
+
+ if ((mac[0] == 0x68) && (mac[1] == 0xed))
+ {
+ printk("rtl811h mac read from eeprom success!! \n");
+ for (i = 0; i < ETH_ALEN; i++)
+ dev->dev_addr[i] = mac[i];
+ }
+ else
+ {
+ printk("rtl811h mac read from eeprom error!! \n");
+
+ dev->dev_addr[0] = 0x66;
+ dev->dev_addr[1] = 0xED;
+ dev->dev_addr[2] = 0xB5;
+ dev->dev_addr[3] = 0x64;
+ dev->dev_addr[4] = 0x72;
+ dev->dev_addr[5] = 0x2C;
+ }
+
+ rtl_rar_set(tp, dev->dev_addr);
dev->ethtool_ops = &rtl8169_ethtool_ops;
dev->watchdog_timeo = RTL8169_TX_TIMEOUT;
@@ -7696,4 +7720,5 @@
.driver.pm = RTL8169_PM_OPS,
};
-module_pci_driver(rtl8169_pci_driver);
+//module_pci_driver(rtl8169_pci_driver);
+module_pci_driver2(rtl8169_pci_driver); //late_initcall();
--
Gitblit v1.6.2