hc
2023-11-20 69d6da3c1c63675524a25e7dc92a4f43c4164cef
kernel/drivers/net/ethernet/realtek/r8169.c
....@@ -7435,6 +7435,7 @@
74357435 clk_disable_unprepare(data);
74367436 }
74377437
7438
+extern ssize_t at24_mac1_read(unsigned char* mac);
74387439 static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
74397440 {
74407441 const struct rtl_cfg_info *cfg = rtl_cfg_infos + ent->driver_data;
....@@ -7442,6 +7443,7 @@
74427443 struct net_device *dev;
74437444 int chipset, region, i;
74447445 int jumbo_max, rc;
7446
+ unsigned char mac[6];
74457447
74467448 dev = devm_alloc_etherdev(&pdev->dev, sizeof (*tp));
74477449 if (!dev)
....@@ -7593,8 +7595,30 @@
75937595 default:
75947596 break;
75957597 }
7596
- for (i = 0; i < ETH_ALEN; i++)
7597
- dev->dev_addr[i] = RTL_R8(tp, MAC0 + i);
7598
+// for (i = 0; i < ETH_ALEN; i++)
7599
+// dev->dev_addr[i] = RTL_R8(tp, MAC0 + i);
7600
+ memset(mac, 0x00, 6);
7601
+ at24_mac1_read(mac);
7602
+
7603
+ if ((mac[0] == 0x68) && (mac[1] == 0xed))
7604
+ {
7605
+ printk("rtl811h mac read from eeprom success!! \n");
7606
+ for (i = 0; i < ETH_ALEN; i++)
7607
+ dev->dev_addr[i] = mac[i];
7608
+ }
7609
+ else
7610
+ {
7611
+ printk("rtl811h mac read from eeprom error!! \n");
7612
+
7613
+ dev->dev_addr[0] = 0x66;
7614
+ dev->dev_addr[1] = 0xED;
7615
+ dev->dev_addr[2] = 0xB5;
7616
+ dev->dev_addr[3] = 0x64;
7617
+ dev->dev_addr[4] = 0x72;
7618
+ dev->dev_addr[5] = 0x2C;
7619
+ }
7620
+
7621
+ rtl_rar_set(tp, dev->dev_addr);
75987622
75997623 dev->ethtool_ops = &rtl8169_ethtool_ops;
76007624 dev->watchdog_timeo = RTL8169_TX_TIMEOUT;
....@@ -7696,4 +7720,5 @@
76967720 .driver.pm = RTL8169_PM_OPS,
76977721 };
76987722
7699
-module_pci_driver(rtl8169_pci_driver);
7723
+//module_pci_driver(rtl8169_pci_driver);
7724
+module_pci_driver2(rtl8169_pci_driver); //late_initcall();