Skip to content

Commit f5473d1

Browse files
harini-katakamdavem330
authored andcommitted
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: Harini Katakam <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8beb79b commit f5473d1

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

drivers/net/ethernet/cadence/macb.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ struct macb_config {
10851085
unsigned int dma_burst_length;
10861086
int (*clk_init)(struct platform_device *pdev, struct clk **pclk,
10871087
struct clk **hclk, struct clk **tx_clk,
1088-
struct clk **rx_clk);
1088+
struct clk **rx_clk, struct clk **tsu_clk);
10891089
int (*init)(struct platform_device *pdev);
10901090
int jumbo_max_len;
10911091
};
@@ -1165,6 +1165,7 @@ struct macb {
11651165
struct clk *hclk;
11661166
struct clk *tx_clk;
11671167
struct clk *rx_clk;
1168+
struct clk *tsu_clk;
11681169
struct net_device *dev;
11691170
union {
11701171
struct macb_stats macb;

drivers/net/ethernet/cadence/macb_main.c

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3325,7 +3325,7 @@ static void macb_probe_queues(void __iomem *mem,
33253325

33263326
static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
33273327
struct clk **hclk, struct clk **tx_clk,
3328-
struct clk **rx_clk)
3328+
struct clk **rx_clk, struct clk **tsu_clk)
33293329
{
33303330
struct macb_platform_data *pdata;
33313331
int err;
@@ -3359,6 +3359,10 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
33593359
if (IS_ERR(*rx_clk))
33603360
*rx_clk = NULL;
33613361

3362+
*tsu_clk = devm_clk_get(&pdev->dev, "tsu_clk");
3363+
if (IS_ERR(*tsu_clk))
3364+
*tsu_clk = NULL;
3365+
33623366
err = clk_prepare_enable(*pclk);
33633367
if (err) {
33643368
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,
33833387
goto err_disable_txclk;
33843388
}
33853389

3390+
err = clk_prepare_enable(*tsu_clk);
3391+
if (err) {
3392+
dev_err(&pdev->dev, "failed to enable tsu_clk (%u)\n", err);
3393+
goto err_disable_rxclk;
3394+
}
3395+
33863396
return 0;
33873397

3398+
err_disable_rxclk:
3399+
clk_disable_unprepare(*rx_clk);
3400+
33883401
err_disable_txclk:
33893402
clk_disable_unprepare(*tx_clk);
33903403

@@ -3835,13 +3848,14 @@ static const struct net_device_ops at91ether_netdev_ops = {
38353848

38363849
static int at91ether_clk_init(struct platform_device *pdev, struct clk **pclk,
38373850
struct clk **hclk, struct clk **tx_clk,
3838-
struct clk **rx_clk)
3851+
struct clk **rx_clk, struct clk **tsu_clk)
38393852
{
38403853
int err;
38413854

38423855
*hclk = NULL;
38433856
*tx_clk = NULL;
38443857
*rx_clk = NULL;
3858+
*tsu_clk = NULL;
38453859

38463860
*pclk = devm_clk_get(&pdev->dev, "ether_clk");
38473861
if (IS_ERR(*pclk))
@@ -3992,11 +4006,12 @@ static int macb_probe(struct platform_device *pdev)
39924006
{
39934007
const struct macb_config *macb_config = &default_gem_config;
39944008
int (*clk_init)(struct platform_device *, struct clk **,
3995-
struct clk **, struct clk **, struct clk **)
3996-
= macb_config->clk_init;
4009+
struct clk **, struct clk **, struct clk **,
4010+
struct clk **) = macb_config->clk_init;
39974011
int (*init)(struct platform_device *) = macb_config->init;
39984012
struct device_node *np = pdev->dev.of_node;
39994013
struct clk *pclk, *hclk = NULL, *tx_clk = NULL, *rx_clk = NULL;
4014+
struct clk *tsu_clk = NULL;
40004015
unsigned int queue_mask, num_queues;
40014016
struct macb_platform_data *pdata;
40024017
bool native_io;
@@ -4024,7 +4039,7 @@ static int macb_probe(struct platform_device *pdev)
40244039
}
40254040
}
40264041

4027-
err = clk_init(pdev, &pclk, &hclk, &tx_clk, &rx_clk);
4042+
err = clk_init(pdev, &pclk, &hclk, &tx_clk, &rx_clk, &tsu_clk);
40284043
if (err)
40294044
return err;
40304045

@@ -4061,6 +4076,7 @@ static int macb_probe(struct platform_device *pdev)
40614076
bp->hclk = hclk;
40624077
bp->tx_clk = tx_clk;
40634078
bp->rx_clk = rx_clk;
4079+
bp->tsu_clk = tsu_clk;
40644080
if (macb_config)
40654081
bp->jumbo_max_len = macb_config->jumbo_max_len;
40664082

@@ -4180,6 +4196,7 @@ static int macb_probe(struct platform_device *pdev)
41804196
clk_disable_unprepare(hclk);
41814197
clk_disable_unprepare(pclk);
41824198
clk_disable_unprepare(rx_clk);
4199+
clk_disable_unprepare(tsu_clk);
41834200

41844201
return err;
41854202
}
@@ -4207,6 +4224,7 @@ static int macb_remove(struct platform_device *pdev)
42074224
clk_disable_unprepare(bp->hclk);
42084225
clk_disable_unprepare(bp->pclk);
42094226
clk_disable_unprepare(bp->rx_clk);
4227+
clk_disable_unprepare(bp->tsu_clk);
42104228
of_node_put(bp->phy_node);
42114229
free_netdev(dev);
42124230
}
@@ -4232,6 +4250,7 @@ static int __maybe_unused macb_suspend(struct device *dev)
42324250
clk_disable_unprepare(bp->pclk);
42334251
clk_disable_unprepare(bp->rx_clk);
42344252
}
4253+
clk_disable_unprepare(bp->tsu_clk);
42354254

42364255
return 0;
42374256
}
@@ -4251,6 +4270,7 @@ static int __maybe_unused macb_resume(struct device *dev)
42514270
clk_prepare_enable(bp->tx_clk);
42524271
clk_prepare_enable(bp->rx_clk);
42534272
}
4273+
clk_prepare_enable(bp->tsu_clk);
42544274

42554275
netif_device_attach(netdev);
42564276

0 commit comments

Comments
 (0)