.. | .. |
---|
228 | 228 | priv->clk_csr = STMMAC_CSR_100_150M; |
---|
229 | 229 | else if ((clk_rate >= CSR_F_150M) && (clk_rate < CSR_F_250M)) |
---|
230 | 230 | 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)) |
---|
232 | 232 | priv->clk_csr = STMMAC_CSR_250_300M; |
---|
233 | 233 | } |
---|
234 | 234 | |
---|
.. | .. |
---|
508 | 508 | } |
---|
509 | 509 | } |
---|
510 | 510 | |
---|
| 511 | +#ifdef CONFIG_STMMAC_PTP |
---|
511 | 512 | /** |
---|
512 | 513 | * stmmac_hwtstamp_set - control hardware timestamping. |
---|
513 | 514 | * @dev: device pointer. |
---|
.. | .. |
---|
760 | 761 | return copy_to_user(ifr->ifr_data, config, |
---|
761 | 762 | sizeof(*config)) ? -EFAULT : 0; |
---|
762 | 763 | } |
---|
| 764 | +#endif /* CONFIG_STMMAC_PTP */ |
---|
763 | 765 | |
---|
764 | 766 | /** |
---|
765 | 767 | * stmmac_init_ptp - init PTP |
---|
.. | .. |
---|
800 | 802 | |
---|
801 | 803 | static void stmmac_release_ptp(struct stmmac_priv *priv) |
---|
802 | 804 | { |
---|
803 | | - if (priv->plat->clk_ptp_ref) |
---|
| 805 | + if (priv->plat->clk_ptp_ref && IS_ENABLED(CONFIG_STMMAC_PTP)) |
---|
804 | 806 | clk_disable_unprepare(priv->plat->clk_ptp_ref); |
---|
805 | 807 | stmmac_ptp_unregister(priv); |
---|
806 | 808 | } |
---|
.. | .. |
---|
934 | 936 | } |
---|
935 | 937 | } |
---|
936 | 938 | |
---|
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 | | - |
---|
954 | 939 | /** |
---|
955 | 940 | * stmmac_init_phy - PHY initialization |
---|
956 | 941 | * @dev: net device structure |
---|
.. | .. |
---|
971 | 956 | priv->oldlink = false; |
---|
972 | 957 | priv->speed = SPEED_UNKNOWN; |
---|
973 | 958 | priv->oldduplex = DUPLEX_UNKNOWN; |
---|
| 959 | + |
---|
| 960 | + if (priv->plat->integrated_phy_power) |
---|
| 961 | + priv->plat->integrated_phy_power(priv->plat->bsp_priv, true); |
---|
974 | 962 | |
---|
975 | 963 | if (priv->plat->phy_node) { |
---|
976 | 964 | phydev = of_phy_connect(dev, priv->plat->phy_node, |
---|
.. | .. |
---|
1032 | 1020 | phydev->irq = PHY_POLL; |
---|
1033 | 1021 | |
---|
1034 | 1022 | phy_attached_info(phydev); |
---|
1035 | | - |
---|
1036 | | - //add ben |
---|
1037 | | - rtl8211F_led_control(phydev); |
---|
1038 | 1023 | return 0; |
---|
1039 | 1024 | } |
---|
1040 | 1025 | |
---|
.. | .. |
---|
2174 | 2159 | */ |
---|
2175 | 2160 | static void stmmac_check_ether_addr(struct stmmac_priv *priv) |
---|
2176 | 2161 | { |
---|
2177 | | - //if (!is_valid_ether_addr(priv->dev->dev_addr)) { |
---|
2178 | | - if (1) { |
---|
| 2162 | + if (!is_valid_ether_addr(priv->dev->dev_addr)) { |
---|
2179 | 2163 | stmmac_get_umac_addr(priv, priv->hw, priv->dev->dev_addr, 0); |
---|
2180 | 2164 | if (likely(priv->plat->get_eth_addr)) |
---|
2181 | 2165 | priv->plat->get_eth_addr(priv->plat->bsp_priv, |
---|
.. | .. |
---|
2568 | 2552 | |
---|
2569 | 2553 | stmmac_mmc_setup(priv); |
---|
2570 | 2554 | |
---|
2571 | | - if (init_ptp) { |
---|
| 2555 | + if (IS_ENABLED(CONFIG_STMMAC_PTP) && init_ptp) { |
---|
2572 | 2556 | ret = clk_prepare_enable(priv->plat->clk_ptp_ref); |
---|
2573 | 2557 | if (ret < 0) |
---|
2574 | 2558 | netdev_warn(priv->dev, "failed to enable PTP reference clock: %d\n", ret); |
---|
.. | .. |
---|
2610 | 2594 | { |
---|
2611 | 2595 | struct stmmac_priv *priv = netdev_priv(dev); |
---|
2612 | 2596 | |
---|
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); |
---|
2614 | 2599 | } |
---|
2615 | 2600 | |
---|
2616 | 2601 | /** |
---|
.. | .. |
---|
2748 | 2733 | if (dev->phydev) { |
---|
2749 | 2734 | phy_stop(dev->phydev); |
---|
2750 | 2735 | phy_disconnect(dev->phydev); |
---|
| 2736 | + if (priv->plat->integrated_phy_power) |
---|
| 2737 | + priv->plat->integrated_phy_power(priv->plat->bsp_priv, |
---|
| 2738 | + false); |
---|
2751 | 2739 | } |
---|
2752 | 2740 | |
---|
2753 | 2741 | stmmac_disable_all_queues(priv); |
---|
.. | .. |
---|
2778 | 2766 | |
---|
2779 | 2767 | netif_carrier_off(dev); |
---|
2780 | 2768 | |
---|
2781 | | - stmmac_release_ptp(priv); |
---|
| 2769 | + if (IS_ENABLED(CONFIG_STMMAC_PTP)) |
---|
| 2770 | + stmmac_release_ptp(priv); |
---|
2782 | 2771 | |
---|
2783 | 2772 | return 0; |
---|
2784 | 2773 | } |
---|
.. | .. |
---|
3757 | 3746 | /* To handle GMAC own interrupts */ |
---|
3758 | 3747 | if ((priv->plat->has_gmac) || xmac) { |
---|
3759 | 3748 | int status = stmmac_host_irq_status(priv, priv->hw, &priv->xstats); |
---|
3760 | | - int mtl_status; |
---|
3761 | 3749 | |
---|
3762 | 3750 | if (unlikely(status)) { |
---|
3763 | 3751 | /* For LPI we need to save the tx status */ |
---|
.. | .. |
---|
3768 | 3756 | } |
---|
3769 | 3757 | |
---|
3770 | 3758 | 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); |
---|
3782 | 3761 | } |
---|
3783 | 3762 | |
---|
3784 | 3763 | /* PCS link status */ |
---|
.. | .. |
---|
3832 | 3811 | return -EINVAL; |
---|
3833 | 3812 | ret = phy_mii_ioctl(dev->phydev, rq, cmd); |
---|
3834 | 3813 | break; |
---|
| 3814 | +#ifdef CONFIG_STMMAC_PTP |
---|
3835 | 3815 | case SIOCSHWTSTAMP: |
---|
3836 | 3816 | ret = stmmac_hwtstamp_set(dev, rq); |
---|
3837 | 3817 | break; |
---|
3838 | 3818 | case SIOCGHWTSTAMP: |
---|
3839 | 3819 | ret = stmmac_hwtstamp_get(dev, rq); |
---|
3840 | 3820 | break; |
---|
| 3821 | +#endif |
---|
3841 | 3822 | default: |
---|
3842 | 3823 | break; |
---|
3843 | 3824 | } |
---|
.. | .. |
---|
4584 | 4565 | stmmac_pmt(priv, priv->hw, priv->wolopts); |
---|
4585 | 4566 | priv->irq_wake = 1; |
---|
4586 | 4567 | } else { |
---|
| 4568 | + if (priv->plat->integrated_phy_power) |
---|
| 4569 | + priv->plat->integrated_phy_power(priv->plat->bsp_priv, |
---|
| 4570 | + false); |
---|
4587 | 4571 | stmmac_mac_set(priv, priv->ioaddr, false); |
---|
4588 | 4572 | pinctrl_pm_select_sleep_state(priv->device); |
---|
4589 | 4573 | /* 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)) |
---|
4591 | 4575 | clk_disable_unprepare(priv->plat->clk_ptp_ref); |
---|
4592 | 4576 | clk_disable_unprepare(priv->plat->pclk); |
---|
4593 | 4577 | clk_disable_unprepare(priv->plat->stmmac_clk); |
---|
.. | .. |
---|
4624 | 4608 | tx_q->cur_tx = 0; |
---|
4625 | 4609 | tx_q->dirty_tx = 0; |
---|
4626 | 4610 | tx_q->mss = 0; |
---|
| 4611 | + |
---|
| 4612 | + netdev_tx_reset_queue(netdev_get_tx_queue(priv->dev, queue)); |
---|
4627 | 4613 | } |
---|
4628 | 4614 | } |
---|
4629 | 4615 | |
---|
.. | .. |
---|
4641 | 4627 | if (!netif_running(ndev)) |
---|
4642 | 4628 | return 0; |
---|
4643 | 4629 | |
---|
4644 | | - printk("troy test %s start .... \n",__func__); |
---|
4645 | 4630 | /* Power Down bit, into the PM register, is cleared |
---|
4646 | 4631 | * automatically as soon as a magic packet or a Wake-up frame |
---|
4647 | 4632 | * is received. Anyway, it's better to manually clear |
---|
.. | .. |
---|
4658 | 4643 | /* enable the clk previously disabled */ |
---|
4659 | 4644 | clk_prepare_enable(priv->plat->stmmac_clk); |
---|
4660 | 4645 | 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)) |
---|
4662 | 4647 | clk_prepare_enable(priv->plat->clk_ptp_ref); |
---|
4663 | 4648 | /* reset the phy so that it's ready */ |
---|
4664 | 4649 | if (priv->mii) |
---|
4665 | 4650 | stmmac_mdio_reset(priv->mii); |
---|
| 4651 | + if (priv->plat->integrated_phy_power) |
---|
| 4652 | + priv->plat->integrated_phy_power(priv->plat->bsp_priv, |
---|
| 4653 | + true); |
---|
4666 | 4654 | } |
---|
4667 | 4655 | |
---|
4668 | 4656 | mutex_lock(&priv->lock); |
---|
.. | .. |
---|
4684 | 4672 | |
---|
4685 | 4673 | if (ndev->phydev) |
---|
4686 | 4674 | phy_start(ndev->phydev); |
---|
4687 | | - printk("troy test %s end .... \n",__func__); |
---|
4688 | | - rtl8211F_led_control(ndev->phydev); |
---|
4689 | 4675 | |
---|
4690 | 4676 | return 0; |
---|
4691 | 4677 | } |
---|