ARM64: DTS: Fix Firefly board audio driver
[firefly-linux-kernel-4.4.55.git] / drivers / net / ethernet / stmicro / stmmac / stmmac_main.c
index 4b100ef4af9fcb4471ad4de89866f8ffb230e448..ff18bc0378225954788831843f0abe8b76bd9e47 100644 (file)
@@ -165,7 +165,8 @@ 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->stmmac_clk);
+       clk_rate = clk_get_rate(priv->pclk);
 
        /* Platform provided default clk_csr would be assumed valid
         * for all other cases except for the below mentioned ones.
@@ -1621,6 +1622,9 @@ static void stmmac_check_ether_addr(struct stmmac_priv *priv)
        if (!is_valid_ether_addr(priv->dev->dev_addr)) {
                priv->hw->mac->get_umac_addr(priv->hw,
                                             priv->dev->dev_addr, 0);
+               if (likely(priv->plat->get_eth_addr))
+                       priv->plat->get_eth_addr(priv->plat->bsp_priv,
+                               priv->dev->dev_addr);
                if (!is_valid_ether_addr(priv->dev->dev_addr))
                        eth_hw_addr_random(priv->dev);
                pr_info("%s: device MAC address %pM\n", priv->dev->name,
@@ -1745,9 +1749,11 @@ static int stmmac_hw_setup(struct net_device *dev, bool init_ptp)
        }
 
 #ifdef CONFIG_DEBUG_FS
-       ret = stmmac_init_fs(dev);
-       if (ret < 0)
-               pr_warn("%s: failed debugFS registration\n", __func__);
+       if (init_ptp) {
+               ret = stmmac_init_fs(dev);
+               if (ret < 0)
+                       pr_warn("%s: failed debugFS registration\n", __func__);
+       }
 #endif
        /* Start the ball rolling... */
        pr_debug("%s: DMA RX/TX processes started...\n", dev->name);
@@ -2881,7 +2887,8 @@ int stmmac_dvr_probe(struct device *device,
        }
        clk_prepare_enable(priv->stmmac_clk);
 
-       priv->pclk = devm_clk_get(priv->device, "pclk");
+       //priv->pclk = devm_clk_get(priv->device, "pclk");
+       priv->pclk = devm_clk_get(priv->device, "pclk_mac");
        if (IS_ERR(priv->pclk)) {
                if (PTR_ERR(priv->pclk) == -EPROBE_DEFER) {
                        ret = -EPROBE_DEFER;
@@ -3039,13 +3046,13 @@ int stmmac_suspend(struct net_device *ndev)
        if (priv->phydev)
                phy_stop(priv->phydev);
 
-       spin_lock_irqsave(&priv->lock, flags);
-
        netif_device_detach(ndev);
        netif_stop_queue(ndev);
 
        napi_disable(&priv->napi);
 
+       spin_lock_irqsave(&priv->lock, flags);
+
        /* Stop TX/RX DMA */
        priv->hw->dma->stop_tx(priv->ioaddr);
        priv->hw->dma->stop_rx(priv->ioaddr);
@@ -3084,8 +3091,6 @@ int stmmac_resume(struct net_device *ndev)
        if (!netif_running(ndev))
                return 0;
 
-       spin_lock_irqsave(&priv->lock, flags);
-
        /* Power Down bit, into the PM register, is cleared
         * automatically as soon as a magic packet or a Wake-up frame
         * is received. Anyway, it's better to manually clear
@@ -3093,7 +3098,9 @@ int stmmac_resume(struct net_device *ndev)
         * from another devices (e.g. serial console).
         */
        if (device_may_wakeup(priv->device)) {
+               spin_lock_irqsave(&priv->lock, flags);
                priv->hw->mac->pmt(priv->hw, 0);
+               spin_unlock_irqrestore(&priv->lock, flags);
                priv->irq_wake = 0;
        } else {
                pinctrl_pm_select_default_state(priv->device);
@@ -3105,7 +3112,7 @@ int stmmac_resume(struct net_device *ndev)
                        stmmac_mdio_reset(priv->mii);
        }
 
-       netif_device_attach(ndev);
+       spin_lock_irqsave(&priv->lock, flags);
 
        priv->cur_rx = 0;
        priv->dirty_rx = 0;
@@ -3121,6 +3128,8 @@ int stmmac_resume(struct net_device *ndev)
 
        netif_start_queue(ndev);
 
+       netif_device_attach(ndev);
+
        spin_unlock_irqrestore(&priv->lock, flags);
 
        if (priv->phydev)