Commit 9b5330ed authored by Fugang Duan's avatar Fugang Duan Committed by David S. Miller

net:fec: add enet refrence clock for i.MX 6SX chip

i.MX6sx enet has below clocks for user config:
clk_ipg: ipg_clk_s, ipg_clk_mac0_s, 66Mhz
clk_ahb: enet system clock, it is enet AXI clock for imx6sx.
	 For imx6sx, it alos is the clock source of interrupt coalescing.
	 The clock range: 200Mhz ~ 266Mhz.
clk_ref: refrence clock for tx and rx. For imx6sx enet RGMII mode,
	 the refrence clock is 125Mhz coming from internal PLL or external.
	 In i.MX6sx-arm2 board, the clock is from internal PLL.
	 clk_ref is optional, depends on board.
clk_enet_out: The clock can be output from internal PLL. It can supply 50Mhz
	 clock for phy. clk_enet_out is optional, depends on chip and board.
clk_ptp: 1588 ts clock. It is optional, depends on chip.

The patch add clk_ref to distiguish the different clocks.
Signed-off-by: default avatarFugang Duan <B38611@freescale.com>
Signed-off-by: default avatarFrank Li <Frank.Li@freescale.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 42f27253
...@@ -272,6 +272,7 @@ struct fec_enet_private { ...@@ -272,6 +272,7 @@ struct fec_enet_private {
struct clk *clk_ipg; struct clk *clk_ipg;
struct clk *clk_ahb; struct clk *clk_ahb;
struct clk *clk_ref;
struct clk *clk_enet_out; struct clk *clk_enet_out;
struct clk *clk_ptp; struct clk *clk_ptp;
......
...@@ -1621,6 +1621,11 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable) ...@@ -1621,6 +1621,11 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
} }
mutex_unlock(&fep->ptp_clk_mutex); mutex_unlock(&fep->ptp_clk_mutex);
} }
if (fep->clk_ref) {
ret = clk_prepare_enable(fep->clk_ref);
if (ret)
goto failed_clk_ref;
}
} else { } else {
clk_disable_unprepare(fep->clk_ahb); clk_disable_unprepare(fep->clk_ahb);
clk_disable_unprepare(fep->clk_ipg); clk_disable_unprepare(fep->clk_ipg);
...@@ -1632,9 +1637,15 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable) ...@@ -1632,9 +1637,15 @@ static int fec_enet_clk_enable(struct net_device *ndev, bool enable)
fep->ptp_clk_on = false; fep->ptp_clk_on = false;
mutex_unlock(&fep->ptp_clk_mutex); mutex_unlock(&fep->ptp_clk_mutex);
} }
if (fep->clk_ref)
clk_disable_unprepare(fep->clk_ref);
} }
return 0; return 0;
failed_clk_ref:
if (fep->clk_ref)
clk_disable_unprepare(fep->clk_ref);
failed_clk_ptp: failed_clk_ptp:
if (fep->clk_enet_out) if (fep->clk_enet_out)
clk_disable_unprepare(fep->clk_enet_out); clk_disable_unprepare(fep->clk_enet_out);
...@@ -2637,6 +2648,12 @@ fec_probe(struct platform_device *pdev) ...@@ -2637,6 +2648,12 @@ fec_probe(struct platform_device *pdev)
fep->ptp_clk_on = false; fep->ptp_clk_on = false;
mutex_init(&fep->ptp_clk_mutex); mutex_init(&fep->ptp_clk_mutex);
/* clk_ref is optional, depends on board */
fep->clk_ref = devm_clk_get(&pdev->dev, "enet_clk_ref");
if (IS_ERR(fep->clk_ref))
fep->clk_ref = NULL;
fep->clk_ptp = devm_clk_get(&pdev->dev, "ptp"); fep->clk_ptp = devm_clk_get(&pdev->dev, "ptp");
fep->bufdesc_ex = fep->bufdesc_ex =
pdev->id_entry->driver_data & FEC_QUIRK_HAS_BUFDESC_EX; pdev->id_entry->driver_data & FEC_QUIRK_HAS_BUFDESC_EX;
......
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