Commit f5473d1d authored by Harini Katakam's avatar Harini Katakam Committed by David S. Miller

net: macb: Support clock management for tsu_clk

TSU clock needs to be enabled/disabled as per support in devicetree
and it should also be controlled during suspend/resume (WOL has no
dependency on this clock).
Signed-off-by: default avatarHarini Katakam <harini.katakam@xilinx.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8beb79b7
...@@ -1085,7 +1085,7 @@ struct macb_config { ...@@ -1085,7 +1085,7 @@ struct macb_config {
unsigned int dma_burst_length; unsigned int dma_burst_length;
int (*clk_init)(struct platform_device *pdev, struct clk **pclk, int (*clk_init)(struct platform_device *pdev, struct clk **pclk,
struct clk **hclk, struct clk **tx_clk, struct clk **hclk, struct clk **tx_clk,
struct clk **rx_clk); struct clk **rx_clk, struct clk **tsu_clk);
int (*init)(struct platform_device *pdev); int (*init)(struct platform_device *pdev);
int jumbo_max_len; int jumbo_max_len;
}; };
...@@ -1165,6 +1165,7 @@ struct macb { ...@@ -1165,6 +1165,7 @@ struct macb {
struct clk *hclk; struct clk *hclk;
struct clk *tx_clk; struct clk *tx_clk;
struct clk *rx_clk; struct clk *rx_clk;
struct clk *tsu_clk;
struct net_device *dev; struct net_device *dev;
union { union {
struct macb_stats macb; struct macb_stats macb;
......
...@@ -3325,7 +3325,7 @@ static void macb_probe_queues(void __iomem *mem, ...@@ -3325,7 +3325,7 @@ static void macb_probe_queues(void __iomem *mem,
static int macb_clk_init(struct platform_device *pdev, struct clk **pclk, static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
struct clk **hclk, struct clk **tx_clk, struct clk **hclk, struct clk **tx_clk,
struct clk **rx_clk) struct clk **rx_clk, struct clk **tsu_clk)
{ {
struct macb_platform_data *pdata; struct macb_platform_data *pdata;
int err; int err;
...@@ -3359,6 +3359,10 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk, ...@@ -3359,6 +3359,10 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
if (IS_ERR(*rx_clk)) if (IS_ERR(*rx_clk))
*rx_clk = NULL; *rx_clk = NULL;
*tsu_clk = devm_clk_get(&pdev->dev, "tsu_clk");
if (IS_ERR(*tsu_clk))
*tsu_clk = NULL;
err = clk_prepare_enable(*pclk); err = clk_prepare_enable(*pclk);
if (err) { if (err) {
dev_err(&pdev->dev, "failed to enable pclk (%u)\n", err); dev_err(&pdev->dev, "failed to enable pclk (%u)\n", err);
...@@ -3383,8 +3387,17 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk, ...@@ -3383,8 +3387,17 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
goto err_disable_txclk; goto err_disable_txclk;
} }
err = clk_prepare_enable(*tsu_clk);
if (err) {
dev_err(&pdev->dev, "failed to enable tsu_clk (%u)\n", err);
goto err_disable_rxclk;
}
return 0; return 0;
err_disable_rxclk:
clk_disable_unprepare(*rx_clk);
err_disable_txclk: err_disable_txclk:
clk_disable_unprepare(*tx_clk); clk_disable_unprepare(*tx_clk);
...@@ -3835,13 +3848,14 @@ static const struct net_device_ops at91ether_netdev_ops = { ...@@ -3835,13 +3848,14 @@ static const struct net_device_ops at91ether_netdev_ops = {
static int at91ether_clk_init(struct platform_device *pdev, struct clk **pclk, static int at91ether_clk_init(struct platform_device *pdev, struct clk **pclk,
struct clk **hclk, struct clk **tx_clk, struct clk **hclk, struct clk **tx_clk,
struct clk **rx_clk) struct clk **rx_clk, struct clk **tsu_clk)
{ {
int err; int err;
*hclk = NULL; *hclk = NULL;
*tx_clk = NULL; *tx_clk = NULL;
*rx_clk = NULL; *rx_clk = NULL;
*tsu_clk = NULL;
*pclk = devm_clk_get(&pdev->dev, "ether_clk"); *pclk = devm_clk_get(&pdev->dev, "ether_clk");
if (IS_ERR(*pclk)) if (IS_ERR(*pclk))
...@@ -3992,11 +4006,12 @@ static int macb_probe(struct platform_device *pdev) ...@@ -3992,11 +4006,12 @@ static int macb_probe(struct platform_device *pdev)
{ {
const struct macb_config *macb_config = &default_gem_config; const struct macb_config *macb_config = &default_gem_config;
int (*clk_init)(struct platform_device *, struct clk **, int (*clk_init)(struct platform_device *, struct clk **,
struct clk **, struct clk **, struct clk **) struct clk **, struct clk **, struct clk **,
= macb_config->clk_init; struct clk **) = macb_config->clk_init;
int (*init)(struct platform_device *) = macb_config->init; int (*init)(struct platform_device *) = macb_config->init;
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct clk *pclk, *hclk = NULL, *tx_clk = NULL, *rx_clk = NULL; struct clk *pclk, *hclk = NULL, *tx_clk = NULL, *rx_clk = NULL;
struct clk *tsu_clk = NULL;
unsigned int queue_mask, num_queues; unsigned int queue_mask, num_queues;
struct macb_platform_data *pdata; struct macb_platform_data *pdata;
bool native_io; bool native_io;
...@@ -4024,7 +4039,7 @@ static int macb_probe(struct platform_device *pdev) ...@@ -4024,7 +4039,7 @@ static int macb_probe(struct platform_device *pdev)
} }
} }
err = clk_init(pdev, &pclk, &hclk, &tx_clk, &rx_clk); err = clk_init(pdev, &pclk, &hclk, &tx_clk, &rx_clk, &tsu_clk);
if (err) if (err)
return err; return err;
...@@ -4061,6 +4076,7 @@ static int macb_probe(struct platform_device *pdev) ...@@ -4061,6 +4076,7 @@ static int macb_probe(struct platform_device *pdev)
bp->hclk = hclk; bp->hclk = hclk;
bp->tx_clk = tx_clk; bp->tx_clk = tx_clk;
bp->rx_clk = rx_clk; bp->rx_clk = rx_clk;
bp->tsu_clk = tsu_clk;
if (macb_config) if (macb_config)
bp->jumbo_max_len = macb_config->jumbo_max_len; bp->jumbo_max_len = macb_config->jumbo_max_len;
...@@ -4180,6 +4196,7 @@ static int macb_probe(struct platform_device *pdev) ...@@ -4180,6 +4196,7 @@ static int macb_probe(struct platform_device *pdev)
clk_disable_unprepare(hclk); clk_disable_unprepare(hclk);
clk_disable_unprepare(pclk); clk_disable_unprepare(pclk);
clk_disable_unprepare(rx_clk); clk_disable_unprepare(rx_clk);
clk_disable_unprepare(tsu_clk);
return err; return err;
} }
...@@ -4207,6 +4224,7 @@ static int macb_remove(struct platform_device *pdev) ...@@ -4207,6 +4224,7 @@ static int macb_remove(struct platform_device *pdev)
clk_disable_unprepare(bp->hclk); clk_disable_unprepare(bp->hclk);
clk_disable_unprepare(bp->pclk); clk_disable_unprepare(bp->pclk);
clk_disable_unprepare(bp->rx_clk); clk_disable_unprepare(bp->rx_clk);
clk_disable_unprepare(bp->tsu_clk);
of_node_put(bp->phy_node); of_node_put(bp->phy_node);
free_netdev(dev); free_netdev(dev);
} }
...@@ -4232,6 +4250,7 @@ static int __maybe_unused macb_suspend(struct device *dev) ...@@ -4232,6 +4250,7 @@ static int __maybe_unused macb_suspend(struct device *dev)
clk_disable_unprepare(bp->pclk); clk_disable_unprepare(bp->pclk);
clk_disable_unprepare(bp->rx_clk); clk_disable_unprepare(bp->rx_clk);
} }
clk_disable_unprepare(bp->tsu_clk);
return 0; return 0;
} }
...@@ -4251,6 +4270,7 @@ static int __maybe_unused macb_resume(struct device *dev) ...@@ -4251,6 +4270,7 @@ static int __maybe_unused macb_resume(struct device *dev)
clk_prepare_enable(bp->tx_clk); clk_prepare_enable(bp->tx_clk);
clk_prepare_enable(bp->rx_clk); clk_prepare_enable(bp->rx_clk);
} }
clk_prepare_enable(bp->tsu_clk);
netif_device_attach(netdev); netif_device_attach(netdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment