forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-11-20 2e7bd41e4e8ab3d1efdabd9e263a2f7fe79bff8c
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,8 @@
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)) {
2163
+ if(1) {
21792164 stmmac_get_umac_addr(priv, priv->hw, priv->dev->dev_addr, 0);
21802165 if (likely(priv->plat->get_eth_addr))
21812166 priv->plat->get_eth_addr(priv->plat->bsp_priv,
....@@ -2568,7 +2553,7 @@
25682553
25692554 stmmac_mmc_setup(priv);
25702555
2571
- if (init_ptp) {
2556
+ if (IS_ENABLED(CONFIG_STMMAC_PTP) && init_ptp) {
25722557 ret = clk_prepare_enable(priv->plat->clk_ptp_ref);
25732558 if (ret < 0)
25742559 netdev_warn(priv->dev, "failed to enable PTP reference clock: %d\n", ret);
....@@ -2610,7 +2595,8 @@
26102595 {
26112596 struct stmmac_priv *priv = netdev_priv(dev);
26122597
2613
- clk_disable_unprepare(priv->plat->clk_ptp_ref);
2598
+ if (IS_ENABLED(CONFIG_STMMAC_PTP))
2599
+ clk_disable_unprepare(priv->plat->clk_ptp_ref);
26142600 }
26152601
26162602 /**
....@@ -2748,6 +2734,9 @@
27482734 if (dev->phydev) {
27492735 phy_stop(dev->phydev);
27502736 phy_disconnect(dev->phydev);
2737
+ if (priv->plat->integrated_phy_power)
2738
+ priv->plat->integrated_phy_power(priv->plat->bsp_priv,
2739
+ false);
27512740 }
27522741
27532742 stmmac_disable_all_queues(priv);
....@@ -2778,7 +2767,8 @@
27782767
27792768 netif_carrier_off(dev);
27802769
2781
- stmmac_release_ptp(priv);
2770
+ if (IS_ENABLED(CONFIG_STMMAC_PTP))
2771
+ stmmac_release_ptp(priv);
27822772
27832773 return 0;
27842774 }
....@@ -3757,7 +3747,6 @@
37573747 /* To handle GMAC own interrupts */
37583748 if ((priv->plat->has_gmac) || xmac) {
37593749 int status = stmmac_host_irq_status(priv, priv->hw, &priv->xstats);
3760
- int mtl_status;
37613750
37623751 if (unlikely(status)) {
37633752 /* For LPI we need to save the tx status */
....@@ -3768,17 +3757,8 @@
37683757 }
37693758
37703759 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);
3760
+ status = stmmac_host_mtl_irq_status(priv, priv->hw,
3761
+ queue);
37823762 }
37833763
37843764 /* PCS link status */
....@@ -3832,12 +3812,14 @@
38323812 return -EINVAL;
38333813 ret = phy_mii_ioctl(dev->phydev, rq, cmd);
38343814 break;
3815
+#ifdef CONFIG_STMMAC_PTP
38353816 case SIOCSHWTSTAMP:
38363817 ret = stmmac_hwtstamp_set(dev, rq);
38373818 break;
38383819 case SIOCGHWTSTAMP:
38393820 ret = stmmac_hwtstamp_get(dev, rq);
38403821 break;
3822
+#endif
38413823 default:
38423824 break;
38433825 }
....@@ -4584,10 +4566,13 @@
45844566 stmmac_pmt(priv, priv->hw, priv->wolopts);
45854567 priv->irq_wake = 1;
45864568 } else {
4569
+ if (priv->plat->integrated_phy_power)
4570
+ priv->plat->integrated_phy_power(priv->plat->bsp_priv,
4571
+ false);
45874572 stmmac_mac_set(priv, priv->ioaddr, false);
45884573 pinctrl_pm_select_sleep_state(priv->device);
45894574 /* Disable clock in case of PWM is off */
4590
- if (priv->plat->clk_ptp_ref)
4575
+ if (priv->plat->clk_ptp_ref && IS_ENABLED(CONFIG_STMMAC_PTP))
45914576 clk_disable_unprepare(priv->plat->clk_ptp_ref);
45924577 clk_disable_unprepare(priv->plat->pclk);
45934578 clk_disable_unprepare(priv->plat->stmmac_clk);
....@@ -4624,6 +4609,8 @@
46244609 tx_q->cur_tx = 0;
46254610 tx_q->dirty_tx = 0;
46264611 tx_q->mss = 0;
4612
+
4613
+ netdev_tx_reset_queue(netdev_get_tx_queue(priv->dev, queue));
46274614 }
46284615 }
46294616
....@@ -4641,7 +4628,6 @@
46414628 if (!netif_running(ndev))
46424629 return 0;
46434630
4644
- printk("troy test %s start .... \n",__func__);
46454631 /* Power Down bit, into the PM register, is cleared
46464632 * automatically as soon as a magic packet or a Wake-up frame
46474633 * is received. Anyway, it's better to manually clear
....@@ -4658,11 +4644,14 @@
46584644 /* enable the clk previously disabled */
46594645 clk_prepare_enable(priv->plat->stmmac_clk);
46604646 clk_prepare_enable(priv->plat->pclk);
4661
- if (priv->plat->clk_ptp_ref)
4647
+ if (priv->plat->clk_ptp_ref && IS_ENABLED(CONFIG_STMMAC_PTP))
46624648 clk_prepare_enable(priv->plat->clk_ptp_ref);
46634649 /* reset the phy so that it's ready */
46644650 if (priv->mii)
46654651 stmmac_mdio_reset(priv->mii);
4652
+ if (priv->plat->integrated_phy_power)
4653
+ priv->plat->integrated_phy_power(priv->plat->bsp_priv,
4654
+ true);
46664655 }
46674656
46684657 mutex_lock(&priv->lock);
....@@ -4684,8 +4673,6 @@
46844673
46854674 if (ndev->phydev)
46864675 phy_start(ndev->phydev);
4687
- printk("troy test %s end .... \n",__func__);
4688
- rtl8211F_led_control(ndev->phydev);
46894676
46904677 return 0;
46914678 }