Commit aead88bd authored by shubhrajyoti.datta@xilinx.com's avatar shubhrajyoti.datta@xilinx.com Committed by David S. Miller

net: ethernet: macb: Add support for rx_clk

Some of the platforms like zynqmp ultrascale+ has a
separate clock gate for the rx clock. Add an optional
rx_clk so that the clock can be enabled.
Signed-off-by: default avatarShubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
Acked-by: default avatarNicolas Ferre <nicolas.ferre@atmel.com>
Acked-by: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d52bfbda
...@@ -21,6 +21,7 @@ Required properties: ...@@ -21,6 +21,7 @@ Required properties:
- clock-names: Tuple listing input clock names. - clock-names: Tuple listing input clock names.
Required elements: 'pclk', 'hclk' Required elements: 'pclk', 'hclk'
Optional elements: 'tx_clk' Optional elements: 'tx_clk'
Optional elements: 'rx_clk' applies to cdns,zynqmp-gem
- clocks: Phandles to input clocks. - clocks: Phandles to input clocks.
Optional properties for PHY child node: Optional properties for PHY child node:
......
...@@ -2332,7 +2332,8 @@ static void macb_probe_queues(void __iomem *mem, ...@@ -2332,7 +2332,8 @@ 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)
{ {
int err; int err;
...@@ -2354,6 +2355,10 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk, ...@@ -2354,6 +2355,10 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
if (IS_ERR(*tx_clk)) if (IS_ERR(*tx_clk))
*tx_clk = NULL; *tx_clk = NULL;
*rx_clk = devm_clk_get(&pdev->dev, "rx_clk");
if (IS_ERR(*rx_clk))
*rx_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);
...@@ -2372,8 +2377,17 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk, ...@@ -2372,8 +2377,17 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
goto err_disable_hclk; goto err_disable_hclk;
} }
err = clk_prepare_enable(*rx_clk);
if (err) {
dev_err(&pdev->dev, "failed to enable rx_clk (%u)\n", err);
goto err_disable_txclk;
}
return 0; return 0;
err_disable_txclk:
clk_disable_unprepare(*tx_clk);
err_disable_hclk: err_disable_hclk:
clk_disable_unprepare(*hclk); clk_disable_unprepare(*hclk);
...@@ -2763,12 +2777,14 @@ static const struct net_device_ops at91ether_netdev_ops = { ...@@ -2763,12 +2777,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)
{ {
int err; int err;
*hclk = NULL; *hclk = NULL;
*tx_clk = NULL; *tx_clk = NULL;
*rx_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))
...@@ -2892,13 +2908,13 @@ MODULE_DEVICE_TABLE(of, macb_dt_ids); ...@@ -2892,13 +2908,13 @@ MODULE_DEVICE_TABLE(of, macb_dt_ids);
static int macb_probe(struct platform_device *pdev) static int macb_probe(struct platform_device *pdev)
{ {
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 **)
= macb_clk_init; = macb_clk_init;
int (*init)(struct platform_device *) = macb_init; int (*init)(struct platform_device *) = macb_init;
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct device_node *phy_node; struct device_node *phy_node;
const struct macb_config *macb_config = NULL; const struct macb_config *macb_config = NULL;
struct clk *pclk, *hclk = NULL, *tx_clk = NULL; struct clk *pclk, *hclk = NULL, *tx_clk = NULL, *rx_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;
...@@ -2926,7 +2942,7 @@ static int macb_probe(struct platform_device *pdev) ...@@ -2926,7 +2942,7 @@ static int macb_probe(struct platform_device *pdev)
} }
} }
err = clk_init(pdev, &pclk, &hclk, &tx_clk); err = clk_init(pdev, &pclk, &hclk, &tx_clk, &rx_clk);
if (err) if (err)
return err; return err;
...@@ -2962,6 +2978,7 @@ static int macb_probe(struct platform_device *pdev) ...@@ -2962,6 +2978,7 @@ static int macb_probe(struct platform_device *pdev)
bp->pclk = pclk; bp->pclk = pclk;
bp->hclk = hclk; bp->hclk = hclk;
bp->tx_clk = tx_clk; bp->tx_clk = tx_clk;
bp->rx_clk = rx_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;
...@@ -3060,6 +3077,7 @@ static int macb_probe(struct platform_device *pdev) ...@@ -3060,6 +3077,7 @@ static int macb_probe(struct platform_device *pdev)
clk_disable_unprepare(tx_clk); clk_disable_unprepare(tx_clk);
clk_disable_unprepare(hclk); clk_disable_unprepare(hclk);
clk_disable_unprepare(pclk); clk_disable_unprepare(pclk);
clk_disable_unprepare(rx_clk);
return err; return err;
} }
...@@ -3086,6 +3104,7 @@ static int macb_remove(struct platform_device *pdev) ...@@ -3086,6 +3104,7 @@ static int macb_remove(struct platform_device *pdev)
clk_disable_unprepare(bp->tx_clk); clk_disable_unprepare(bp->tx_clk);
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);
free_netdev(dev); free_netdev(dev);
} }
...@@ -3109,6 +3128,7 @@ static int __maybe_unused macb_suspend(struct device *dev) ...@@ -3109,6 +3128,7 @@ static int __maybe_unused macb_suspend(struct device *dev)
clk_disable_unprepare(bp->tx_clk); clk_disable_unprepare(bp->tx_clk);
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);
} }
return 0; return 0;
...@@ -3128,6 +3148,7 @@ static int __maybe_unused macb_resume(struct device *dev) ...@@ -3128,6 +3148,7 @@ static int __maybe_unused macb_resume(struct device *dev)
clk_prepare_enable(bp->pclk); clk_prepare_enable(bp->pclk);
clk_prepare_enable(bp->hclk); clk_prepare_enable(bp->hclk);
clk_prepare_enable(bp->tx_clk); clk_prepare_enable(bp->tx_clk);
clk_prepare_enable(bp->rx_clk);
} }
netif_device_attach(netdev); netif_device_attach(netdev);
......
...@@ -772,7 +772,8 @@ struct macb_config { ...@@ -772,7 +772,8 @@ struct macb_config {
u32 caps; u32 caps;
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);
int (*init)(struct platform_device *pdev); int (*init)(struct platform_device *pdev);
int jumbo_max_len; int jumbo_max_len;
}; };
...@@ -819,6 +820,7 @@ struct macb { ...@@ -819,6 +820,7 @@ struct macb {
struct clk *pclk; struct clk *pclk;
struct clk *hclk; struct clk *hclk;
struct clk *tx_clk; struct clk *tx_clk;
struct clk *rx_clk;
struct net_device *dev; struct net_device *dev;
struct napi_struct napi; struct napi_struct napi;
struct net_device_stats stats; struct net_device_stats stats;
......
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