diff options
author | Hauke Mehrtens <hauke@hauke-m.de> | 2018-09-15 14:08:47 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-09-17 08:12:11 -0700 |
commit | a44ecfbda48f1ddc52e6119f594e3711c1b39924 (patch) | |
tree | af4ca0383f1ecbc6585f047a0df528f59c587755 /drivers/net/ethernet/lantiq_xrx200.c | |
parent | e82b5fe5d480657dee83a7674caf5bf90bdb4fbd (diff) |
net: lantiq: lantiq_xrx200: Move clock prepare to probe function
The switch and the MAC are in one IP core and they use the same clock
signal from the clock generation unit.
Currently the clock architecture in the lantiq SoC code does not allow
to easily share the same clocks, this has to be fixed by switching to
the common clock framework.
As a workaround the clock of the switch and MAC should be activated when
the MAC gets probed and only disabled when the MAC gets removed. This
way it is ensured that the clock is always enabled when the switch or
MAC is used. The switch can not be used without the MAC.
This fixes a data bus error when rebooting the system and deactivating
the switch and mac and later accessing some registers in the cleanup
while the clocks are disabled.
Fixes: fe1a56420cf2 ("net: lantiq: Add Lantiq / Intel VRX200 Ethernet driver")
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/lantiq_xrx200.c')
-rw-r--r-- | drivers/net/ethernet/lantiq_xrx200.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/drivers/net/ethernet/lantiq_xrx200.c b/drivers/net/ethernet/lantiq_xrx200.c index 4a160761b3ff..8c5ba4b81fb7 100644 --- a/drivers/net/ethernet/lantiq_xrx200.c +++ b/drivers/net/ethernet/lantiq_xrx200.c @@ -115,12 +115,6 @@ static void xrx200_flush_dma(struct xrx200_chan *ch) static int xrx200_open(struct net_device *net_dev) { struct xrx200_priv *priv = netdev_priv(net_dev); - int err; - - /* enable clock gate */ - err = clk_prepare_enable(priv->clk); - if (err) - return err; napi_enable(&priv->chan_tx.napi); ltq_dma_open(&priv->chan_tx.dma); @@ -155,8 +149,6 @@ static int xrx200_close(struct net_device *net_dev) napi_disable(&priv->chan_tx.napi); ltq_dma_close(&priv->chan_tx.dma); - clk_disable_unprepare(priv->clk); - return 0; } @@ -497,6 +489,11 @@ static int xrx200_probe(struct platform_device *pdev) if (err) return err; + /* enable clock gate */ + err = clk_prepare_enable(priv->clk); + if (err) + goto err_uninit_dma; + /* set IPG to 12 */ xrx200_pmac_mask(priv, PMAC_RX_IPG_MASK, 0xb, PMAC_RX_IPG); @@ -514,9 +511,12 @@ static int xrx200_probe(struct platform_device *pdev) err = register_netdev(net_dev); if (err) - goto err_uninit_dma; + goto err_unprepare_clk; return err; +err_unprepare_clk: + clk_disable_unprepare(priv->clk); + err_uninit_dma: xrx200_hw_cleanup(priv); @@ -536,6 +536,9 @@ static int xrx200_remove(struct platform_device *pdev) /* remove the actual device */ unregister_netdev(net_dev); + /* release the clock */ + clk_disable_unprepare(priv->clk); + /* shut down hardware */ xrx200_hw_cleanup(priv); |