kernel: remove obsolete kernel version switches
[openwrt/openwrt.git] / target / linux / ramips / files / drivers / net / ethernet / ralink / mtk_eth_soc.c
index f8301ad3ca7b2c7acada544831315cd9e6c90830..b79b34893808c26149e54032515a08cd0593d5de 100644 (file)
@@ -141,6 +141,17 @@ void fe_reset(u32 reset_bits)
        usleep_range(10, 20);
 }
 
+void fe_reset_fe(struct fe_priv *priv)
+{
+       if (!priv->rst_fe)
+               return;
+
+       reset_control_assert(priv->rst_fe);
+       usleep_range(60, 120);
+       reset_control_deassert(priv->rst_fe);
+       usleep_range(60, 120);
+}
+
 static inline void fe_int_disable(u32 mask)
 {
        fe_reg_w32(fe_reg_r32(FE_REG_FE_INT_ENABLE) & ~mask,
@@ -1085,7 +1096,7 @@ poll_again:
        return rx_done;
 }
 
-static void fe_tx_timeout(struct net_device *dev)
+static void fe_tx_timeout(struct net_device *dev, unsigned int txqueue)
 {
        struct fe_priv *priv = netdev_priv(dev);
        struct fe_tx_ring *ring = &priv->tx_ring;
@@ -1353,22 +1364,27 @@ static int __init fe_init(struct net_device *dev)
 {
        struct fe_priv *priv = netdev_priv(dev);
        struct device_node *port;
-       const char *mac_addr;
        int err;
 
-       priv->soc->reset_fe();
+       if (priv->soc->reset_fe)
+               priv->soc->reset_fe(priv);
+       else
+               fe_reset_fe(priv);
+
+       if (priv->soc->switch_init) {
+               err = priv->soc->switch_init(priv);
+               if (err) {
+                       if (err == -EPROBE_DEFER)
+                               return err;
 
-       if (priv->soc->switch_init)
-               if (priv->soc->switch_init(priv)) {
                        netdev_err(dev, "failed to initialize switch core\n");
                        return -ENODEV;
                }
+       }
 
        fe_reset_phy(priv);
 
-       mac_addr = of_get_mac_address(priv->dev->of_node);
-       if (!IS_ERR_OR_NULL(mac_addr))
-               ether_addr_copy(dev->dev_addr, mac_addr);
+       of_get_mac_address(priv->dev->of_node, dev->dev_addr);
 
        /* If the mac address is invalid, use random mac address  */
        if (!is_valid_ether_addr(dev->dev_addr)) {
@@ -1541,7 +1557,9 @@ static int fe_probe(struct platform_device *pdev)
        struct clk *sysclk;
        int err, napi_weight;
 
-       device_reset(&pdev->dev);
+       err = device_reset(&pdev->dev);
+       if (err)
+               dev_err(&pdev->dev, "failed to reset device\n");
 
        match = of_match_device(of_fe_match, &pdev->dev);
        soc = (struct fe_soc_data *)match->data;
@@ -1575,6 +1593,12 @@ static int fe_probe(struct platform_device *pdev)
                goto err_free_dev;
        }
 
+       priv = netdev_priv(netdev);
+       spin_lock_init(&priv->page_lock);
+       priv->rst_fe = devm_reset_control_get(&pdev->dev, "fe");
+       if (IS_ERR(priv->rst_fe))
+               priv->rst_fe = NULL;
+
        if (soc->init_data)
                soc->init_data(soc, netdev);
        netdev->vlan_features = netdev->hw_features &
@@ -1589,8 +1613,6 @@ static int fe_probe(struct platform_device *pdev)
        if (fe_reg_table[FE_REG_FE_DMA_VID_BASE])
                netdev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
 
-       priv = netdev_priv(netdev);
-       spin_lock_init(&priv->page_lock);
        if (fe_reg_table[FE_REG_FE_COUNTER_BASE]) {
                priv->hw_stats = kzalloc(sizeof(*priv->hw_stats), GFP_KERNEL);
                if (!priv->hw_stats) {