OSDN Git Service

Merge branches 'for-3.16/i2c-hid', 'for-3.16/rmi4', 'for-3.16/sony' and 'for-3.16...
[uclinux-h8/linux.git] / drivers / net / ethernet / samsung / sxgbe / sxgbe_main.c
index a72688e..82a9a98 100644 (file)
@@ -1076,6 +1076,9 @@ static int sxgbe_open(struct net_device *dev)
 
        /* Initialize the MAC Core */
        priv->hw->mac->core_init(priv->ioaddr);
+       SXGBE_FOR_EACH_QUEUE(SXGBE_RX_QUEUES, queue_num) {
+               priv->hw->mac->enable_rxqueue(priv->ioaddr, queue_num);
+       }
 
        /* Request the IRQ lines */
        ret = devm_request_irq(priv->device, priv->irq, sxgbe_common_interrupt,
@@ -1453,6 +1456,7 @@ static void sxgbe_rx_refill(struct sxgbe_priv_data *priv)
                /* Added memory barrier for RX descriptor modification */
                wmb();
                priv->hw->desc->set_rx_owner(p);
+               priv->hw->desc->set_rx_int_on_com(p);
                /* Added memory barrier for RX descriptor modification */
                wmb();
        }
@@ -2070,6 +2074,24 @@ static int sxgbe_hw_init(struct sxgbe_priv_data * const priv)
        return 0;
 }
 
+static int sxgbe_sw_reset(void __iomem *addr)
+{
+       int retry_count = 10;
+
+       writel(SXGBE_DMA_SOFT_RESET, addr + SXGBE_DMA_MODE_REG);
+       while (retry_count--) {
+               if (!(readl(addr + SXGBE_DMA_MODE_REG) &
+                     SXGBE_DMA_SOFT_RESET))
+                       break;
+               mdelay(10);
+       }
+
+       if (retry_count < 0)
+               return -EBUSY;
+
+       return 0;
+}
+
 /**
  * sxgbe_drv_probe
  * @device: device pointer
@@ -2102,6 +2124,10 @@ struct sxgbe_priv_data *sxgbe_drv_probe(struct device *device,
        priv->plat = plat_dat;
        priv->ioaddr = addr;
 
+       ret = sxgbe_sw_reset(priv->ioaddr);
+       if (ret)
+               goto error_free_netdev;
+
        /* Verify driver arguments */
        sxgbe_verify_args();
 
@@ -2113,11 +2139,11 @@ struct sxgbe_priv_data *sxgbe_drv_probe(struct device *device,
        /* allocate memory resources for Descriptor rings */
        ret = txring_mem_alloc(priv);
        if (ret)
-               goto error_free_netdev;
+               goto error_free_hw;
 
        ret = rxring_mem_alloc(priv);
        if (ret)
-               goto error_free_netdev;
+               goto error_free_hw;
 
        ndev->netdev_ops = &sxgbe_netdev_ops;
 
@@ -2163,7 +2189,7 @@ struct sxgbe_priv_data *sxgbe_drv_probe(struct device *device,
        if (IS_ERR(priv->sxgbe_clk)) {
                netdev_warn(ndev, "%s: warning: cannot get CSR clock\n",
                            __func__);
-               goto error_clk_get;
+               goto error_napi_del;
        }
 
        /* If a specific clk_csr value is passed from the platform
@@ -2182,24 +2208,27 @@ struct sxgbe_priv_data *sxgbe_drv_probe(struct device *device,
        if (ret < 0) {
                netdev_dbg(ndev, "%s: MDIO bus (id: %d) registration failed\n",
                           __func__, priv->plat->bus_id);
-               goto error_mdio_register;
+               goto error_clk_put;
        }
 
        ret = register_netdev(ndev);
        if (ret) {
                pr_err("%s: ERROR %i registering the device\n", __func__, ret);
-               goto error_netdev_register;
+               goto error_mdio_unregister;
        }
 
        sxgbe_check_ether_addr(priv);
 
        return priv;
 
-error_mdio_register:
+error_mdio_unregister:
+       sxgbe_mdio_unregister(ndev);
+error_clk_put:
        clk_put(priv->sxgbe_clk);
-error_clk_get:
-error_netdev_register:
+error_napi_del:
        netif_napi_del(&priv->napi);
+error_free_hw:
+       kfree(priv->hw);
 error_free_netdev:
        free_netdev(ndev);
 
@@ -2215,20 +2244,29 @@ error_free_netdev:
 int sxgbe_drv_remove(struct net_device *ndev)
 {
        struct sxgbe_priv_data *priv = netdev_priv(ndev);
+       u8 queue_num;
 
        netdev_info(ndev, "%s: removing driver\n", __func__);
 
+       SXGBE_FOR_EACH_QUEUE(SXGBE_RX_QUEUES, queue_num) {
+               priv->hw->mac->disable_rxqueue(priv->ioaddr, queue_num);
+       }
+
        priv->hw->dma->stop_rx(priv->ioaddr, SXGBE_RX_QUEUES);
        priv->hw->dma->stop_tx(priv->ioaddr, SXGBE_TX_QUEUES);
 
        priv->hw->mac->enable_tx(priv->ioaddr, false);
        priv->hw->mac->enable_rx(priv->ioaddr, false);
 
-       netif_napi_del(&priv->napi);
+       unregister_netdev(ndev);
 
        sxgbe_mdio_unregister(ndev);
 
-       unregister_netdev(ndev);
+       clk_put(priv->sxgbe_clk);
+
+       netif_napi_del(&priv->napi);
+
+       kfree(priv->hw);
 
        free_netdev(ndev);