1 From 9f27ec4f2fa03545da6bbaa44e99253f1b29639e Mon Sep 17 00:00:00 2001
2 From: Jose Abreu <jose.abreu@synopsys.com>
3 Date: Wed, 30 Jan 2019 15:54:19 +0100
4 Subject: net: stmmac: Fallback to Platform Data clock in Watchdog conversion
6 [ Upstream commit 4ec5302fa906ec9d86597b236f62315bacdb9622 ]
8 If we don't have DT then stmmac_clk will not be available. Let's add a
9 new Platform Data field so that we can specify the refclk by this mean.
11 This way we can still use the coalesce command in PCI based setups.
13 Signed-off-by: Jose Abreu <joabreu@synopsys.com>
14 Cc: Joao Pinto <jpinto@synopsys.com>
15 Cc: David S. Miller <davem@davemloft.net>
16 Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
17 Cc: Alexandre Torgue <alexandre.torgue@st.com>
18 Signed-off-by: David S. Miller <davem@davemloft.net>
19 Signed-off-by: Sasha Levin <sashal@kernel.org>
21 .../net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 14 ++++++++++----
22 include/linux/stmmac.h | 1 +
23 2 files changed, 11 insertions(+), 4 deletions(-)
25 diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
26 index 9caf79ba5ef1..4d5fb4b51cc4 100644
27 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
28 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
29 @@ -719,8 +719,11 @@ static u32 stmmac_usec2riwt(u32 usec, struct stmmac_priv *priv)
31 unsigned long clk = clk_get_rate(priv->plat->stmmac_clk);
36 + clk = priv->plat->clk_ref_rate;
41 return (usec * (clk / 1000000)) / 256;
43 @@ -729,8 +732,11 @@ static u32 stmmac_riwt2usec(u32 riwt, struct stmmac_priv *priv)
45 unsigned long clk = clk_get_rate(priv->plat->stmmac_clk);
50 + clk = priv->plat->clk_ref_rate;
55 return (riwt * 256) / (clk / 1000000);
57 diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
58 index 7ddfc65586b0..4335bd771ce5 100644
59 --- a/include/linux/stmmac.h
60 +++ b/include/linux/stmmac.h
61 @@ -184,6 +184,7 @@ struct plat_stmmacenet_data {
63 struct clk *clk_ptp_ref;
64 unsigned int clk_ptp_rate;
65 + unsigned int clk_ref_rate;
66 struct reset_control *stmmac_rst;
67 struct stmmac_axi *axi;