]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.20.16/net-stmmac-fallback-to-platform-data-clock-in-watchd.patch
Linux 4.20.16
[thirdparty/kernel/stable-queue.git] / releases / 4.20.16 / net-stmmac-fallback-to-platform-data-clock-in-watchd.patch
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
5
6 [ Upstream commit 4ec5302fa906ec9d86597b236f62315bacdb9622 ]
7
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.
10
11 This way we can still use the coalesce command in PCI based setups.
12
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>
20 ---
21 .../net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 14 ++++++++++----
22 include/linux/stmmac.h | 1 +
23 2 files changed, 11 insertions(+), 4 deletions(-)
24
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)
30 {
31 unsigned long clk = clk_get_rate(priv->plat->stmmac_clk);
32
33 - if (!clk)
34 - return 0;
35 + if (!clk) {
36 + clk = priv->plat->clk_ref_rate;
37 + if (!clk)
38 + return 0;
39 + }
40
41 return (usec * (clk / 1000000)) / 256;
42 }
43 @@ -729,8 +732,11 @@ static u32 stmmac_riwt2usec(u32 riwt, struct stmmac_priv *priv)
44 {
45 unsigned long clk = clk_get_rate(priv->plat->stmmac_clk);
46
47 - if (!clk)
48 - return 0;
49 + if (!clk) {
50 + clk = priv->plat->clk_ref_rate;
51 + if (!clk)
52 + return 0;
53 + }
54
55 return (riwt * 256) / (clk / 1000000);
56 }
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 {
62 struct clk *pclk;
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;
68 int has_gmac4;
69 --
70 2.19.1
71