forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
....@@ -1101,6 +1101,62 @@
11011101 }
11021102 }
11031103
1104
+#if 0
1105
+static void rtl8211F_led_control(struct phy_device *phydev)
1106
+{
1107
+ printk("ben debug:rtl8211F_led_control...1 \n");
1108
+
1109
+ if(!phydev) return;
1110
+ if(phydev->phy_id!=0x001cc916) return; /* only for 8211E*/
1111
+
1112
+ /*switch to extension page44*/
1113
+ phy_write(phydev, 31, 0x0d04);
1114
+//add hc 1000M --> orange
1115
+// 100M --> green
1116
+ phy_write(phydev, 16, 0x6D02);
1117
+//add hc 1000M&100M --> green
1118
+// phy_write(phydev, 16, 0x6C0A);
1119
+ printk("ben debug:rtl8211F_led_control...2 \n");
1120
+}
1121
+#endif
1122
+#define RTL_8211F_PHY_ID 0x001cc916
1123
+#define RTL_8211F_PHY_ID_MASK 0x001fffff
1124
+#define RTL_8211F_PAGE_SELECT 0x1f
1125
+#define RTL_8211F_LCR_ADDR 0x10
1126
+
1127
+#define GREEN_LED 0 // Â̵ÆÊÇLED0
1128
+#define YELLOW0_LED 1 // »ÆµÆÊÇLED1
1129
+#define YELLOW1_LED 2 // »ÆµÆÊÇLED2
1130
+
1131
+static int rtl8211F_led_control(struct phy_device *phydev)
1132
+{
1133
+ unsigned int temp;
1134
+
1135
+ printk("<<<<<<ben test led ctrl start... %s\n",__FUNCTION__);
1136
+ if(!phydev) return 0;
1137
+ if(phydev->phy_id!=0x001cc916) return 0; /* only for 8211E*/
1138
+
1139
+ // ÅäÖÃÍø¿ÚLEDµÆ
1140
+ phy_write(phydev, 31, 0xd04);
1141
+ temp = 0x02 << (5 * GREEN_LED); // Â̵ƱíʾÁ¬½Ó״̬
1142
+ temp |= 0x08 << (5 * YELLOW0_LED); // »ÆµÆ±íʾÁ¬½Ó״̬
1143
+
1144
+ temp |= 0x1b << (5 * YELLOW1_LED); // »ÆµÆ±íʾÊý¾Ý°üÊÕ·¢×´Ì¬
1145
+ phy_write(phydev, 0x10, temp);
1146
+
1147
+ temp = 1 << (YELLOW1_LED + 1); // Â̵Ʋ»Ö¸Ê¾EEE½ÚÄÜ״̬, ²åÁËÍøÏߺóµÆÒª³£ÁÁ
1148
+ // µ«»ÆµÆÒªÖ¸Ê¾EEE½ÚÄÜ״̬, ûÓÐÊý¾Ý°üʱµÆÒªÏ¨Ãð
1149
+ phy_write(phydev, 0x11, 0x00);
1150
+ phy_write(phydev, 31, 0);
1151
+
1152
+ // ²åÉÏÍøÏߺó, Â̵Ƴ£ÁÁ; °ÎµôÍøÏߺó, Â̵ÆÏ¨Ãð
1153
+ // Á´Â·Ö§³ÖEEE½ÚÄÜ: ÓÐÊý¾Ý´«Êä, »ÆµÆÉÁ˸, ·ñÔòϨÃð
1154
+ // Á´Â·²»Ö§³ÖEEE½ÚÄÜ: ÓÐÊý¾Ý´«Êä, »ÆµÆÉÁ˸, ·ñÔò³£ÁÁ
1155
+
1156
+ printk("<<<<<<<ben test led ctrl end %s\n",__FUNCTION__);
1157
+ return 0;
1158
+}
1159
+
11041160 /**
11051161 * stmmac_init_phy - PHY initialization
11061162 * @dev: net device structure
....@@ -1115,28 +1171,43 @@
11151171 struct device_node *node;
11161172 int ret;
11171173
1174
+
1175
+ printk("ben stmmac_init_phy .. \n");
1176
+ mdelay(2000);
1177
+ printk("ben stmmac_init_phy delay .. \n");
11181178 if (priv->plat->integrated_phy_power)
11191179 ret = priv->plat->integrated_phy_power(priv->plat->bsp_priv, true);
11201180
11211181 node = priv->plat->phylink_node;
11221182
11231183 if (node)
1184
+ {
1185
+ //printk("ben ttt.. \n");
11241186 ret = phylink_of_phy_connect(priv->phylink, node, 0);
1187
+ //printk("ben ttt:%d \n", ret);
1188
+ }
11251189
11261190 /* Some DT bindings do not set-up the PHY handle. Let's try to
11271191 * manually parse it
11281192 */
1193
+ //printk("ben:stmmac_init_phy..1 \n");
11291194 if (!node || ret) {
1195
+ //if (1) {
11301196 int addr = priv->plat->phy_addr;
11311197 struct phy_device *phydev;
11321198
1199
+ //printk("ben:stmmac_init_phy..2 \n");
11331200 phydev = mdiobus_get_phy(priv->mii, addr);
11341201 if (!phydev) {
11351202 netdev_err(priv->dev, "no phy at addr %d\n", addr);
11361203 return -ENODEV;
11371204 }
11381205
1206
+ //rtl8211F_led_control(phydev);
1207
+
1208
+ //printk("ben:stmmac_init_phy..3 \n");
11391209 ret = phylink_connect_phy(priv->phylink, phydev);
1210
+ //rtl8211F_led_control(phydev);
11401211 }
11411212
11421213 if (!priv->plat->pmt) {
....@@ -1145,7 +1216,6 @@
11451216 phylink_ethtool_get_wol(priv->phylink, &wol);
11461217 device_set_wakeup_capable(priv->device, !!wol.supported);
11471218 }
1148
-
11491219 return ret;
11501220 }
11511221
....@@ -2345,7 +2415,8 @@
23452415 */
23462416 static void stmmac_check_ether_addr(struct stmmac_priv *priv)
23472417 {
2348
- if (!is_valid_ether_addr(priv->dev->dev_addr)) {
2418
+// if (!is_valid_ether_addr(priv->dev->dev_addr)) {
2419
+ if (1) {
23492420 stmmac_get_umac_addr(priv, priv->hw, priv->dev->dev_addr, 0);
23502421 if (likely(priv->plat->get_eth_addr))
23512422 priv->plat->get_eth_addr(priv->plat->bsp_priv,
....@@ -2866,6 +2937,7 @@
28662937 u32 chan;
28672938 int ret;
28682939
2940
+ //printk("ben:stmmac_open.. \n");
28692941 ret = pm_runtime_get_sync(priv->device);
28702942 if (ret < 0) {
28712943 pm_runtime_put_noidle(priv->device);
....@@ -2939,6 +3011,12 @@
29393011 goto init_error;
29403012 }
29413013 }
3014
+
3015
+
3016
+ #if 1
3017
+ printk("ben -------bootup add 2s delay time.\n");
3018
+ mdelay(2500);
3019
+ #endif
29423020
29433021 ret = stmmac_hw_setup(dev, true);
29443022 if (ret < 0) {
....@@ -5228,6 +5306,9 @@
52285306 */
52295307 pm_runtime_put(device);
52305308
5309
+ //add
5310
+ phy_register_fixup_for_uid(RTL_8211F_PHY_ID, RTL_8211F_PHY_ID_MASK, rtl8211F_led_control);
5311
+
52315312 return ret;
52325313
52335314 error_netdev_register:
....@@ -5439,6 +5520,12 @@
54395520 stmmac_free_tx_skbufs(priv);
54405521 stmmac_clear_descriptors(priv);
54415522
5523
+#if 1
5524
+ printk("ben -------resume add 2s delay time.\n");
5525
+ mdelay(2000);
5526
+
5527
+#endif
5528
+
54425529 stmmac_hw_setup(ndev, false);
54435530 stmmac_init_coalesce(priv);
54445531 stmmac_set_rx_mode(ndev);