hc
2023-02-14 b625cdcd68479b3d540a915785b6d9809b52a2f8
kernel/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
....@@ -228,7 +228,7 @@
228228 priv->clk_csr = STMMAC_CSR_100_150M;
229229 else if ((clk_rate >= CSR_F_150M) && (clk_rate < CSR_F_250M))
230230 priv->clk_csr = STMMAC_CSR_150_250M;
231
- else if ((clk_rate >= CSR_F_250M) && (clk_rate <= CSR_F_300M))
231
+ else if ((clk_rate >= CSR_F_250M) && (clk_rate < CSR_F_300M))
232232 priv->clk_csr = STMMAC_CSR_250_300M;
233233 }
234234
....@@ -508,7 +508,6 @@
508508 }
509509 }
510510
511
-#ifdef CONFIG_STMMAC_PTP
512511 /**
513512 * stmmac_hwtstamp_set - control hardware timestamping.
514513 * @dev: device pointer.
....@@ -761,7 +760,6 @@
761760 return copy_to_user(ifr->ifr_data, config,
762761 sizeof(*config)) ? -EFAULT : 0;
763762 }
764
-#endif /* CONFIG_STMMAC_PTP */
765763
766764 /**
767765 * stmmac_init_ptp - init PTP
....@@ -802,7 +800,7 @@
802800
803801 static void stmmac_release_ptp(struct stmmac_priv *priv)
804802 {
805
- if (priv->plat->clk_ptp_ref && IS_ENABLED(CONFIG_STMMAC_PTP))
803
+ if (priv->plat->clk_ptp_ref)
806804 clk_disable_unprepare(priv->plat->clk_ptp_ref);
807805 stmmac_ptp_unregister(priv);
808806 }
....@@ -936,6 +934,23 @@
936934 }
937935 }
938936
937
+static void rtl8211F_led_control(struct phy_device *phydev)
938
+{
939
+ printk("ben debug:rtl8211F_led_control...1 \n");
940
+
941
+ if(!phydev) return;
942
+ if(phydev->phy_id!=0x001cc916) return; /* only for 8211E*/
943
+
944
+ /*switch to extension page44*/
945
+ phy_write(phydev, 31, 0x0d04);
946
+//add hc 1000M --> orange
947
+// 100M --> green
948
+ phy_write(phydev, 16, 0x6D02);
949
+//add hc 1000M&100M --> green
950
+// phy_write(phydev, 16, 0x6C0A);
951
+ printk("ben debug:rtl8211F_led_control...2 \n");
952
+}
953
+
939954 /**
940955 * stmmac_init_phy - PHY initialization
941956 * @dev: net device structure
....@@ -956,9 +971,6 @@
956971 priv->oldlink = false;
957972 priv->speed = SPEED_UNKNOWN;
958973 priv->oldduplex = DUPLEX_UNKNOWN;
959
-
960
- if (priv->plat->integrated_phy_power)
961
- priv->plat->integrated_phy_power(priv->plat->bsp_priv, true);
962974
963975 if (priv->plat->phy_node) {
964976 phydev = of_phy_connect(dev, priv->plat->phy_node,
....@@ -1020,6 +1032,9 @@
10201032 phydev->irq = PHY_POLL;
10211033
10221034 phy_attached_info(phydev);
1035
+
1036
+ //add ben
1037
+ rtl8211F_led_control(phydev);
10231038 return 0;
10241039 }
10251040
....@@ -2159,7 +2174,8 @@
21592174 */
21602175 static void stmmac_check_ether_addr(struct stmmac_priv *priv)
21612176 {
2162
- if (!is_valid_ether_addr(priv->dev->dev_addr)) {
2177
+ //if (!is_valid_ether_addr(priv->dev->dev_addr)) {
2178
+ if (1) {
21632179 stmmac_get_umac_addr(priv, priv->hw, priv->dev->dev_addr, 0);
21642180 if (likely(priv->plat->get_eth_addr))
21652181 priv->plat->get_eth_addr(priv->plat->bsp_priv,
....@@ -2552,7 +2568,7 @@
25522568
25532569 stmmac_mmc_setup(priv);
25542570
2555
- if (IS_ENABLED(CONFIG_STMMAC_PTP) && init_ptp) {
2571
+ if (init_ptp) {
25562572 ret = clk_prepare_enable(priv->plat->clk_ptp_ref);
25572573 if (ret < 0)
25582574 netdev_warn(priv->dev, "failed to enable PTP reference clock: %d\n", ret);
....@@ -2594,8 +2610,7 @@
25942610 {
25952611 struct stmmac_priv *priv = netdev_priv(dev);
25962612
2597
- if (IS_ENABLED(CONFIG_STMMAC_PTP))
2598
- clk_disable_unprepare(priv->plat->clk_ptp_ref);
2613
+ clk_disable_unprepare(priv->plat->clk_ptp_ref);
25992614 }
26002615
26012616 /**
....@@ -2733,9 +2748,6 @@
27332748 if (dev->phydev) {
27342749 phy_stop(dev->phydev);
27352750 phy_disconnect(dev->phydev);
2736
- if (priv->plat->integrated_phy_power)
2737
- priv->plat->integrated_phy_power(priv->plat->bsp_priv,
2738
- false);
27392751 }
27402752
27412753 stmmac_disable_all_queues(priv);
....@@ -2766,8 +2778,7 @@
27662778
27672779 netif_carrier_off(dev);
27682780
2769
- if (IS_ENABLED(CONFIG_STMMAC_PTP))
2770
- stmmac_release_ptp(priv);
2781
+ stmmac_release_ptp(priv);
27712782
27722783 return 0;
27732784 }
....@@ -3746,6 +3757,7 @@
37463757 /* To handle GMAC own interrupts */
37473758 if ((priv->plat->has_gmac) || xmac) {
37483759 int status = stmmac_host_irq_status(priv, priv->hw, &priv->xstats);
3760
+ int mtl_status;
37493761
37503762 if (unlikely(status)) {
37513763 /* For LPI we need to save the tx status */
....@@ -3756,8 +3768,17 @@
37563768 }
37573769
37583770 for (queue = 0; queue < queues_count; queue++) {
3759
- status = stmmac_host_mtl_irq_status(priv, priv->hw,
3760
- queue);
3771
+ struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue];
3772
+
3773
+ mtl_status = stmmac_host_mtl_irq_status(priv, priv->hw,
3774
+ queue);
3775
+ if (mtl_status != -EINVAL)
3776
+ status |= mtl_status;
3777
+
3778
+ if (status & CORE_IRQ_MTL_RX_OVERFLOW)
3779
+ stmmac_set_rx_tail_ptr(priv, priv->ioaddr,
3780
+ rx_q->rx_tail_addr,
3781
+ queue);
37613782 }
37623783
37633784 /* PCS link status */
....@@ -3811,14 +3832,12 @@
38113832 return -EINVAL;
38123833 ret = phy_mii_ioctl(dev->phydev, rq, cmd);
38133834 break;
3814
-#ifdef CONFIG_STMMAC_PTP
38153835 case SIOCSHWTSTAMP:
38163836 ret = stmmac_hwtstamp_set(dev, rq);
38173837 break;
38183838 case SIOCGHWTSTAMP:
38193839 ret = stmmac_hwtstamp_get(dev, rq);
38203840 break;
3821
-#endif
38223841 default:
38233842 break;
38243843 }
....@@ -4565,13 +4584,10 @@
45654584 stmmac_pmt(priv, priv->hw, priv->wolopts);
45664585 priv->irq_wake = 1;
45674586 } else {
4568
- if (priv->plat->integrated_phy_power)
4569
- priv->plat->integrated_phy_power(priv->plat->bsp_priv,
4570
- false);
45714587 stmmac_mac_set(priv, priv->ioaddr, false);
45724588 pinctrl_pm_select_sleep_state(priv->device);
45734589 /* Disable clock in case of PWM is off */
4574
- if (priv->plat->clk_ptp_ref && IS_ENABLED(CONFIG_STMMAC_PTP))
4590
+ if (priv->plat->clk_ptp_ref)
45754591 clk_disable_unprepare(priv->plat->clk_ptp_ref);
45764592 clk_disable_unprepare(priv->plat->pclk);
45774593 clk_disable_unprepare(priv->plat->stmmac_clk);
....@@ -4608,8 +4624,6 @@
46084624 tx_q->cur_tx = 0;
46094625 tx_q->dirty_tx = 0;
46104626 tx_q->mss = 0;
4611
-
4612
- netdev_tx_reset_queue(netdev_get_tx_queue(priv->dev, queue));
46134627 }
46144628 }
46154629
....@@ -4627,6 +4641,7 @@
46274641 if (!netif_running(ndev))
46284642 return 0;
46294643
4644
+ printk("troy test %s start .... \n",__func__);
46304645 /* Power Down bit, into the PM register, is cleared
46314646 * automatically as soon as a magic packet or a Wake-up frame
46324647 * is received. Anyway, it's better to manually clear
....@@ -4643,14 +4658,11 @@
46434658 /* enable the clk previously disabled */
46444659 clk_prepare_enable(priv->plat->stmmac_clk);
46454660 clk_prepare_enable(priv->plat->pclk);
4646
- if (priv->plat->clk_ptp_ref && IS_ENABLED(CONFIG_STMMAC_PTP))
4661
+ if (priv->plat->clk_ptp_ref)
46474662 clk_prepare_enable(priv->plat->clk_ptp_ref);
46484663 /* reset the phy so that it's ready */
46494664 if (priv->mii)
46504665 stmmac_mdio_reset(priv->mii);
4651
- if (priv->plat->integrated_phy_power)
4652
- priv->plat->integrated_phy_power(priv->plat->bsp_priv,
4653
- true);
46544666 }
46554667
46564668 mutex_lock(&priv->lock);
....@@ -4672,6 +4684,8 @@
46724684
46734685 if (ndev->phydev)
46744686 phy_start(ndev->phydev);
4687
+ printk("troy test %s end .... \n",__func__);
4688
+ rtl8211F_led_control(ndev->phydev);
46754689
46764690 return 0;
46774691 }