hc
2023-11-06 e3e12f52b214121840b44c91de5b3e5af5d3eb84
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,6 +508,7 @@
508508 }
509509 }
510510
511
+#ifdef CONFIG_STMMAC_PTP
511512 /**
512513 * stmmac_hwtstamp_set - control hardware timestamping.
513514 * @dev: device pointer.
....@@ -760,6 +761,7 @@
760761 return copy_to_user(ifr->ifr_data, config,
761762 sizeof(*config)) ? -EFAULT : 0;
762763 }
764
+#endif /* CONFIG_STMMAC_PTP */
763765
764766 /**
765767 * stmmac_init_ptp - init PTP
....@@ -800,7 +802,7 @@
800802
801803 static void stmmac_release_ptp(struct stmmac_priv *priv)
802804 {
803
- if (priv->plat->clk_ptp_ref)
805
+ if (priv->plat->clk_ptp_ref && IS_ENABLED(CONFIG_STMMAC_PTP))
804806 clk_disable_unprepare(priv->plat->clk_ptp_ref);
805807 stmmac_ptp_unregister(priv);
806808 }
....@@ -934,23 +936,6 @@
934936 }
935937 }
936938
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
-
954939 /**
955940 * stmmac_init_phy - PHY initialization
956941 * @dev: net device structure
....@@ -971,6 +956,9 @@
971956 priv->oldlink = false;
972957 priv->speed = SPEED_UNKNOWN;
973958 priv->oldduplex = DUPLEX_UNKNOWN;
959
+
960
+ if (priv->plat->integrated_phy_power)
961
+ priv->plat->integrated_phy_power(priv->plat->bsp_priv, true);
974962
975963 if (priv->plat->phy_node) {
976964 phydev = of_phy_connect(dev, priv->plat->phy_node,
....@@ -1032,9 +1020,6 @@
10321020 phydev->irq = PHY_POLL;
10331021
10341022 phy_attached_info(phydev);
1035
-
1036
- //add ben
1037
- rtl8211F_led_control(phydev);
10381023 return 0;
10391024 }
10401025
....@@ -2174,8 +2159,7 @@
21742159 */
21752160 static void stmmac_check_ether_addr(struct stmmac_priv *priv)
21762161 {
2177
- //if (!is_valid_ether_addr(priv->dev->dev_addr)) {
2178
- if (1) {
2162
+ if (!is_valid_ether_addr(priv->dev->dev_addr)) {
21792163 stmmac_get_umac_addr(priv, priv->hw, priv->dev->dev_addr, 0);
21802164 if (likely(priv->plat->get_eth_addr))
21812165 priv->plat->get_eth_addr(priv->plat->bsp_priv,
....@@ -2568,7 +2552,7 @@
25682552
25692553 stmmac_mmc_setup(priv);
25702554
2571
- if (init_ptp) {
2555
+ if (IS_ENABLED(CONFIG_STMMAC_PTP) && init_ptp) {
25722556 ret = clk_prepare_enable(priv->plat->clk_ptp_ref);
25732557 if (ret < 0)
25742558 netdev_warn(priv->dev, "failed to enable PTP reference clock: %d\n", ret);
....@@ -2610,7 +2594,8 @@
26102594 {
26112595 struct stmmac_priv *priv = netdev_priv(dev);
26122596
2613
- clk_disable_unprepare(priv->plat->clk_ptp_ref);
2597
+ if (IS_ENABLED(CONFIG_STMMAC_PTP))
2598
+ clk_disable_unprepare(priv->plat->clk_ptp_ref);
26142599 }
26152600
26162601 /**
....@@ -2748,6 +2733,9 @@
27482733 if (dev->phydev) {
27492734 phy_stop(dev->phydev);
27502735 phy_disconnect(dev->phydev);
2736
+ if (priv->plat->integrated_phy_power)
2737
+ priv->plat->integrated_phy_power(priv->plat->bsp_priv,
2738
+ false);
27512739 }
27522740
27532741 stmmac_disable_all_queues(priv);
....@@ -2778,7 +2766,8 @@
27782766
27792767 netif_carrier_off(dev);
27802768
2781
- stmmac_release_ptp(priv);
2769
+ if (IS_ENABLED(CONFIG_STMMAC_PTP))
2770
+ stmmac_release_ptp(priv);
27822771
27832772 return 0;
27842773 }
....@@ -3757,7 +3746,6 @@
37573746 /* To handle GMAC own interrupts */
37583747 if ((priv->plat->has_gmac) || xmac) {
37593748 int status = stmmac_host_irq_status(priv, priv->hw, &priv->xstats);
3760
- int mtl_status;
37613749
37623750 if (unlikely(status)) {
37633751 /* For LPI we need to save the tx status */
....@@ -3768,17 +3756,8 @@
37683756 }
37693757
37703758 for (queue = 0; queue < queues_count; 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);
3759
+ status = stmmac_host_mtl_irq_status(priv, priv->hw,
3760
+ queue);
37823761 }
37833762
37843763 /* PCS link status */
....@@ -3832,12 +3811,14 @@
38323811 return -EINVAL;
38333812 ret = phy_mii_ioctl(dev->phydev, rq, cmd);
38343813 break;
3814
+#ifdef CONFIG_STMMAC_PTP
38353815 case SIOCSHWTSTAMP:
38363816 ret = stmmac_hwtstamp_set(dev, rq);
38373817 break;
38383818 case SIOCGHWTSTAMP:
38393819 ret = stmmac_hwtstamp_get(dev, rq);
38403820 break;
3821
+#endif
38413822 default:
38423823 break;
38433824 }
....@@ -4584,10 +4565,13 @@
45844565 stmmac_pmt(priv, priv->hw, priv->wolopts);
45854566 priv->irq_wake = 1;
45864567 } else {
4568
+ if (priv->plat->integrated_phy_power)
4569
+ priv->plat->integrated_phy_power(priv->plat->bsp_priv,
4570
+ false);
45874571 stmmac_mac_set(priv, priv->ioaddr, false);
45884572 pinctrl_pm_select_sleep_state(priv->device);
45894573 /* Disable clock in case of PWM is off */
4590
- if (priv->plat->clk_ptp_ref)
4574
+ if (priv->plat->clk_ptp_ref && IS_ENABLED(CONFIG_STMMAC_PTP))
45914575 clk_disable_unprepare(priv->plat->clk_ptp_ref);
45924576 clk_disable_unprepare(priv->plat->pclk);
45934577 clk_disable_unprepare(priv->plat->stmmac_clk);
....@@ -4624,6 +4608,8 @@
46244608 tx_q->cur_tx = 0;
46254609 tx_q->dirty_tx = 0;
46264610 tx_q->mss = 0;
4611
+
4612
+ netdev_tx_reset_queue(netdev_get_tx_queue(priv->dev, queue));
46274613 }
46284614 }
46294615
....@@ -4641,7 +4627,6 @@
46414627 if (!netif_running(ndev))
46424628 return 0;
46434629
4644
- printk("troy test %s start .... \n",__func__);
46454630 /* Power Down bit, into the PM register, is cleared
46464631 * automatically as soon as a magic packet or a Wake-up frame
46474632 * is received. Anyway, it's better to manually clear
....@@ -4658,11 +4643,14 @@
46584643 /* enable the clk previously disabled */
46594644 clk_prepare_enable(priv->plat->stmmac_clk);
46604645 clk_prepare_enable(priv->plat->pclk);
4661
- if (priv->plat->clk_ptp_ref)
4646
+ if (priv->plat->clk_ptp_ref && IS_ENABLED(CONFIG_STMMAC_PTP))
46624647 clk_prepare_enable(priv->plat->clk_ptp_ref);
46634648 /* reset the phy so that it's ready */
46644649 if (priv->mii)
46654650 stmmac_mdio_reset(priv->mii);
4651
+ if (priv->plat->integrated_phy_power)
4652
+ priv->plat->integrated_phy_power(priv->plat->bsp_priv,
4653
+ true);
46664654 }
46674655
46684656 mutex_lock(&priv->lock);
....@@ -4684,8 +4672,6 @@
46844672
46854673 if (ndev->phydev)
46864674 phy_start(ndev->phydev);
4687
- printk("troy test %s end .... \n",__func__);
4688
- rtl8211F_led_control(ndev->phydev);
46894675
46904676 return 0;
46914677 }