hc
2024-02-19 1c055e55a242a33e574e48be530e06770a210dcd
kernel/drivers/net/ethernet/realtek/r8169_main.c
....@@ -2098,6 +2098,9 @@
20982098 /* Adjust EEE LED frequency */
20992099 if (tp->mac_version != RTL_GIGA_MAC_VER_38)
21002100 RTL_W8(tp, EEE_LED, RTL_R8(tp, EEE_LED) & ~0x07);
2101
+ printk("r8169 EEE_LED value init: %x\n", RTL_R16(tp, 0x18));
2102
+ RTL_W16(tp, 0x18, 0x0248);
2103
+ printk("r8169 EEE_LED write: %x\n", RTL_R16(tp, 0x18));
21012104
21022105 rtl_eri_set_bits(tp, 0x1b0, 0x0003);
21032106 }
....@@ -5298,31 +5301,36 @@
52985301 u8 *mac_addr = dev->dev_addr;
52995302 int rc;
53005303
5304
+ rtl_read_mac_address(tp, mac_addr);
5305
+ if (is_valid_ether_addr(mac_addr))
5306
+ goto done;
5307
+
5308
+ if (is_valid_ether_addr(mac_addr))
5309
+ goto done;
5310
+
53015311 rc = eth_platform_get_mac_address(tp_to_dev(tp), mac_addr);
53025312 if (!rc)
5303
- goto done;
5304
-
5305
- rtl_read_mac_address(tp, mac_addr);
5306
- if (is_valid_ether_addr(mac_addr))
53075313 goto done;
53085314
53095315 rtl_read_mac_from_reg(tp, mac_addr, MAC0);
53105316 if (is_valid_ether_addr(mac_addr))
53115317 goto done;
53125318
5313
- eth_hw_addr_random(dev);
5319
+ //eth_hw_addr_random(dev);
53145320 dev_warn(tp_to_dev(tp), "can't read MAC address, setting random one\n");
53155321 done:
53165322 rtl_rar_set(tp, mac_addr);
53175323 }
53185324
5325
+extern ssize_t at24_mac1_read(unsigned char* mac);
53195326 static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
53205327 {
53215328 struct rtl8169_private *tp;
5322
- int jumbo_max, region, rc;
5329
+ int jumbo_max, region, rc, i;
53235330 enum mac_version chipset;
53245331 struct net_device *dev;
53255332 u16 xid;
5333
+ unsigned char mac[6];
53265334
53275335 dev = devm_alloc_etherdev(&pdev->dev, sizeof (*tp));
53285336 if (!dev)
....@@ -5416,6 +5424,30 @@
54165424 u64_stats_init(&tp->tx_stats.syncp);
54175425
54185426 rtl_init_mac_address(tp);
5427
+
5428
+ for (i = 0; i < ETH_ALEN; i++)
5429
+ dev->dev_addr[i] = RTL_R8(tp, MAC0 + i);
5430
+ memset(mac, 0x00, 6);
5431
+ at24_mac1_read(mac);
5432
+
5433
+ if ((mac[0] == 0x68) && (mac[1] == 0xed))
5434
+ {
5435
+ printk("rtl811h mac read from eeprom success!!\n");
5436
+ for (i = 0; i < ETH_ALEN; i++)
5437
+ dev->dev_addr[i] = mac[i];
5438
+ }
5439
+ else
5440
+ {
5441
+ printk("rtl811h mac read from eeprom error!!\n");
5442
+ dev->dev_addr[0] = 0x66;
5443
+ dev->dev_addr[1] = 0xED;
5444
+ dev->dev_addr[2] = 0xB5;
5445
+ dev->dev_addr[3] = 0x64;
5446
+ dev->dev_addr[4] = 0x72;
5447
+ dev->dev_addr[5] = 0x2c;
5448
+ }
5449
+
5450
+ rtl_rar_set(tp, dev->dev_addr);
54195451
54205452 dev->ethtool_ops = &rtl8169_ethtool_ops;
54215453
....@@ -5518,4 +5550,5 @@
55185550 #endif
55195551 };
55205552
5521
-module_pci_driver(rtl8169_pci_driver);
5553
+//module_pci_driver(rtl8169_pci_driver);
5554
+module_pci_driver2(rtl8169_pci_driver);