]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[linux.git] / drivers / net / ethernet / stmicro / stmmac / stmmac_main.c
index e3f6389e1b01c5bba89c9cf3b632113fa9b4db42..38e1fb75490ef95776fdc117ae651aaaf989e0e2 100644 (file)
@@ -158,7 +158,7 @@ static void stmmac_clk_csr_set(struct stmmac_priv *priv)
 {
        u32 clk_rate;
 
-       clk_rate = clk_get_rate(priv->stmmac_clk);
+       clk_rate = clk_get_rate(priv->plat->stmmac_clk);
 
        /* Platform provided default clk_csr would be assumed valid
         * for all other cases except for the below mentioned ones.
@@ -239,7 +239,8 @@ static void stmmac_enable_eee_mode(struct stmmac_priv *priv)
        /* Check and enter in LPI mode */
        if ((priv->dirty_tx == priv->cur_tx) &&
            (priv->tx_path_in_lpi_mode == false))
-               priv->hw->mac->set_eee_mode(priv->hw);
+               priv->hw->mac->set_eee_mode(priv->hw,
+                                           priv->plat->en_tx_lpi_clockgating);
 }
 
 /**
@@ -606,7 +607,7 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
 
                /* program Sub Second Increment reg */
                sec_inc = priv->hw->ptp->config_sub_second_increment(
-                       priv->ptpaddr, priv->clk_ptp_rate,
+                       priv->ptpaddr, priv->plat->clk_ptp_rate,
                        priv->plat->has_gmac4);
                temp = div_u64(1000000000ULL, sec_inc);
 
@@ -616,7 +617,7 @@ static int stmmac_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr)
                 * where, freq_div_ratio = 1e9ns/sec_inc
                 */
                temp = (u64)(temp << 32);
-               priv->default_addend = div_u64(temp, priv->clk_ptp_rate);
+               priv->default_addend = div_u64(temp, priv->plat->clk_ptp_rate);
                priv->hw->ptp->config_addend(priv->ptpaddr,
                                             priv->default_addend);
 
@@ -644,18 +645,6 @@ static int stmmac_init_ptp(struct stmmac_priv *priv)
        if (!(priv->dma_cap.time_stamp || priv->dma_cap.atime_stamp))
                return -EOPNOTSUPP;
 
-       /* Fall-back to main clock in case of no PTP ref is passed */
-       priv->clk_ptp_ref = devm_clk_get(priv->device, "clk_ptp_ref");
-       if (IS_ERR(priv->clk_ptp_ref)) {
-               priv->clk_ptp_rate = clk_get_rate(priv->stmmac_clk);
-               priv->clk_ptp_ref = NULL;
-               netdev_dbg(priv->dev, "PTP uses main clock\n");
-       } else {
-               clk_prepare_enable(priv->clk_ptp_ref);
-               priv->clk_ptp_rate = clk_get_rate(priv->clk_ptp_ref);
-               netdev_dbg(priv->dev, "PTP rate %d\n", priv->clk_ptp_rate);
-       }
-
        priv->adv_ts = 0;
        /* Check if adv_ts can be enabled for dwmac 4.x core */
        if (priv->plat->has_gmac4 && priv->dma_cap.atime_stamp)
@@ -682,8 +671,8 @@ static int stmmac_init_ptp(struct stmmac_priv *priv)
 
 static void stmmac_release_ptp(struct stmmac_priv *priv)
 {
-       if (priv->clk_ptp_ref)
-               clk_disable_unprepare(priv->clk_ptp_ref);
+       if (priv->plat->clk_ptp_ref)
+               clk_disable_unprepare(priv->plat->clk_ptp_ref);
        stmmac_ptp_unregister(priv);
 }
 
@@ -1270,6 +1259,28 @@ static void free_dma_desc_resources(struct stmmac_priv *priv)
        kfree(priv->tx_skbuff);
 }
 
+/**
+ *  stmmac_mac_enable_rx_queues - Enable MAC rx queues
+ *  @priv: driver private structure
+ *  Description: It is used for enabling the rx queues in the MAC
+ */
+static void stmmac_mac_enable_rx_queues(struct stmmac_priv *priv)
+{
+       int rx_count = priv->dma_cap.number_rx_queues;
+       int queue = 0;
+
+       /* If GMAC does not have multiple queues, then this is not necessary*/
+       if (rx_count == 1)
+               return;
+
+       /**
+        *  If the core is synthesized with multiple rx queues / multiple
+        *  dma channels, then rx queues will be disabled by default.
+        *  For now only rx queue 0 is enabled.
+        */
+       priv->hw->mac->rx_queue_enable(priv->hw, queue);
+}
+
 /**
  *  stmmac_dma_operation_mode - HW DMA operation mode
  *  @priv: driver private structure
@@ -1691,6 +1702,10 @@ static int stmmac_hw_setup(struct net_device *dev, bool init_ptp)
        /* Initialize the MAC Core */
        priv->hw->mac->core_init(priv->hw, dev->mtu);
 
+       /* Initialize MAC RX Queues */
+       if (priv->hw->mac->rx_queue_enable)
+               stmmac_mac_enable_rx_queues(priv);
+
        ret = priv->hw->mac->rx_ipc(priv->hw);
        if (!ret) {
                netdev_warn(priv->dev, "RX IPC Checksum Offload disabled\n");
@@ -3251,44 +3266,8 @@ int stmmac_dvr_probe(struct device *device,
        if ((phyaddr >= 0) && (phyaddr <= 31))
                priv->plat->phy_addr = phyaddr;
 
-       priv->stmmac_clk = devm_clk_get(priv->device, STMMAC_RESOURCE_NAME);
-       if (IS_ERR(priv->stmmac_clk)) {
-               netdev_warn(priv->dev, "%s: warning: cannot get CSR clock\n",
-                           __func__);
-               /* If failed to obtain stmmac_clk and specific clk_csr value
-                * is NOT passed from the platform, probe fail.
-                */
-               if (!priv->plat->clk_csr) {
-                       ret = PTR_ERR(priv->stmmac_clk);
-                       goto error_clk_get;
-               } else {
-                       priv->stmmac_clk = NULL;
-               }
-       }
-       clk_prepare_enable(priv->stmmac_clk);
-
-       priv->pclk = devm_clk_get(priv->device, "pclk");
-       if (IS_ERR(priv->pclk)) {
-               if (PTR_ERR(priv->pclk) == -EPROBE_DEFER) {
-                       ret = -EPROBE_DEFER;
-                       goto error_pclk_get;
-               }
-               priv->pclk = NULL;
-       }
-       clk_prepare_enable(priv->pclk);
-
-       priv->stmmac_rst = devm_reset_control_get(priv->device,
-                                                 STMMAC_RESOURCE_NAME);
-       if (IS_ERR(priv->stmmac_rst)) {
-               if (PTR_ERR(priv->stmmac_rst) == -EPROBE_DEFER) {
-                       ret = -EPROBE_DEFER;
-                       goto error_hw_init;
-               }
-               dev_info(priv->device, "no reset control found\n");
-               priv->stmmac_rst = NULL;
-       }
-       if (priv->stmmac_rst)
-               reset_control_deassert(priv->stmmac_rst);
+       if (priv->plat->stmmac_rst)
+               reset_control_deassert(priv->plat->stmmac_rst);
 
        /* Init MAC and get the capabilities */
        ret = stmmac_hw_init(priv);
@@ -3391,10 +3370,6 @@ int stmmac_dvr_probe(struct device *device,
 error_mdio_register:
        netif_napi_del(&priv->napi);
 error_hw_init:
-       clk_disable_unprepare(priv->pclk);
-error_pclk_get:
-       clk_disable_unprepare(priv->stmmac_clk);
-error_clk_get:
        free_netdev(ndev);
 
        return ret;
@@ -3420,10 +3395,10 @@ int stmmac_dvr_remove(struct device *dev)
        stmmac_set_mac(priv->ioaddr, false);
        netif_carrier_off(ndev);
        unregister_netdev(ndev);
-       if (priv->stmmac_rst)
-               reset_control_assert(priv->stmmac_rst);
-       clk_disable_unprepare(priv->pclk);
-       clk_disable_unprepare(priv->stmmac_clk);
+       if (priv->plat->stmmac_rst)
+               reset_control_assert(priv->plat->stmmac_rst);
+       clk_disable_unprepare(priv->plat->pclk);
+       clk_disable_unprepare(priv->plat->stmmac_clk);
        if (priv->hw->pcs != STMMAC_PCS_RGMII &&
            priv->hw->pcs != STMMAC_PCS_TBI &&
            priv->hw->pcs != STMMAC_PCS_RTBI)
@@ -3472,8 +3447,8 @@ int stmmac_suspend(struct device *dev)
                stmmac_set_mac(priv->ioaddr, false);
                pinctrl_pm_select_sleep_state(priv->device);
                /* Disable clock in case of PWM is off */
-               clk_disable(priv->pclk);
-               clk_disable(priv->stmmac_clk);
+               clk_disable(priv->plat->pclk);
+               clk_disable(priv->plat->stmmac_clk);
        }
        spin_unlock_irqrestore(&priv->lock, flags);
 
@@ -3513,8 +3488,8 @@ int stmmac_resume(struct device *dev)
        } else {
                pinctrl_pm_select_default_state(priv->device);
                /* enable the clk prevously disabled */
-               clk_enable(priv->stmmac_clk);
-               clk_enable(priv->pclk);
+               clk_enable(priv->plat->stmmac_clk);
+               clk_enable(priv->plat->pclk);
                /* reset the phy so that it's ready */
                if (priv->mii)
                        stmmac_mdio_reset(priv->mii);