summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBhuvanchandra DV <bhuvanchandra.dv@toradex.com>2017-01-02 09:32:47 +0530
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2017-01-11 16:00:18 +0100
commit418f717cce5834203e24368717f542360b020681 (patch)
tree79436f3d018f099ccc6cc5f0632819bf3480bb21
parent86b0182b0ccc9186be850b300225291f0fb54ba4 (diff)
net: fsl_l2_switch: cleanup in remove callbackColibri_VF_LinuxImageV2.7Beta1_20170112
Cleanup remove callback allowing the switch driver to cleanup resources it used. Signed-off-by: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com> Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
-rw-r--r--drivers/net/ethernet/freescale/fsl_l2_switch.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/drivers/net/ethernet/freescale/fsl_l2_switch.c b/drivers/net/ethernet/freescale/fsl_l2_switch.c
index 4a971e8fdd15..af38259b65ae 100644
--- a/drivers/net/ethernet/freescale/fsl_l2_switch.c
+++ b/drivers/net/ethernet/freescale/fsl_l2_switch.c
@@ -749,28 +749,31 @@ static irqreturn_t switch_enet_interrupt(int irq, void *dev_id)
static int eth_switch_remove(struct platform_device *pdev)
{
- struct net_device *dev = NULL;
+ struct net_device *dev = platform_get_drvdata(pdev);
struct switch_enet_private *fep;
- struct switch_platform_private *chip;
- int slot = 0;
-
- chip = platform_get_drvdata(pdev);
- if (chip) {
- for (slot = 0; slot < chip->num_slots; slot++) {
- fep = chip->fep_host[slot];
- dev = fep->netdev;
- fep->sequence_done = 1;
- unregister_netdev(dev);
- free_netdev(dev);
- }
- platform_set_drvdata(pdev, NULL);
- kfree(chip);
+ fep = netdev_priv(dev);
+
+ unregister_netdev(dev);
+
+ writel(0, fep->enetbase + FSL_FEC_ECR0);
+ writel(0, fep->enetbase + FSL_FEC_ECR1);
+ udelay(10);
+
+ writel(FSL_ESW_MODE_SW_RST, fep->membase + FEC_ESW_MODE);
+ udelay(10);
+ writel(FSL_ESW_MODE_STATRST, fep->membase + FEC_ESW_MODE);
+ writel(0, fep->membase + FEC_ESW_MODE);
+
+ /* Disable transmit/receive on all ports */
+ writel(0, fep->membase + FEC_ESW_PER);
+
+ clk_disable_unprepare(fep->clk_enet1);
+ clk_disable_unprepare(fep->clk_enet0);
+ clk_disable_unprepare(fep->clk_enet);
+ clk_disable_unprepare(fep->clk_esw);
- } else
- netdev_err(dev, "%s: Can not get the "
- "switch_platform_private %x\n", __func__,
- (unsigned int)chip);
+ free_netdev(dev);
return 0;
}