kernel: bump 4.19 to 4.19.115
[openwrt/openwrt.git] / target / linux / mvebu / patches-4.19 / 536-net-marvell-neta-disable-comphy-when-setting-mode.patch
1 From 031b922bfd60c771588911112f8632783de08e5c Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Marek=20Beh=C3=BAn?= <marek.behun@nic.cz>
3 Date: Mon, 25 Feb 2019 17:43:03 +0100
4 Subject: [PATCH] net: marvell: neta: disable comphy when setting mode
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 The comphy driver for Armada 3700 by Miquèl Raynal (which is currently
10 in linux-next) does not actually set comphy mode when phy_set_mode_ext
11 is called. The mode is set at next call of phy_power_on.
12
13 Update the driver to semantics similar to mvpp2: helper
14 mvneta_comphy_init sets comphy mode and powers it on.
15 When mode is to be changed in mvneta_mac_config, first power the comphy
16 off, then call mvneta_comphy_init (which sets the mode to new one).
17
18 Only do this when new mode is different from old mode.
19
20 This should also work for Armada 38x, since in that comphy driver
21 methods power_on and power_off are unimplemented.
22
23 Signed-off-by: Marek Behún <marek.behun@nic.cz>
24 Signed-off-by: David S. Miller <davem@davemloft.net>
25 ---
26 drivers/net/ethernet/marvell/mvneta.c | 28 +++++++++++++++++++++++-----
27 1 file changed, 23 insertions(+), 5 deletions(-)
28
29 --- a/drivers/net/ethernet/marvell/mvneta.c
30 +++ b/drivers/net/ethernet/marvell/mvneta.c
31 @@ -3165,11 +3165,26 @@ static int mvneta_setup_txqs(struct mvne
32 return 0;
33 }
34
35 +static int mvneta_comphy_init(struct mvneta_port *pp)
36 +{
37 + int ret;
38 +
39 + if (!pp->comphy)
40 + return 0;
41 +
42 + ret = phy_set_mode_ext(pp->comphy, PHY_MODE_ETHERNET,
43 + pp->phy_interface);
44 + if (ret)
45 + return ret;
46 +
47 + return phy_power_on(pp->comphy);
48 +}
49 +
50 static void mvneta_start_dev(struct mvneta_port *pp)
51 {
52 int cpu;
53
54 - WARN_ON(phy_power_on(pp->comphy));
55 + WARN_ON(mvneta_comphy_init(pp));
56
57 mvneta_max_rx_size_set(pp, pp->pkt_size);
58 mvneta_txq_max_tx_size_set(pp, pp->pkt_size);
59 @@ -3541,12 +3556,15 @@ static void mvneta_mac_config(struct net
60 if (state->speed == SPEED_2500)
61 new_ctrl4 |= MVNETA_GMAC4_SHORT_PREAMBLE_ENABLE;
62
63 - if (pp->comphy &&
64 + if (pp->comphy && pp->phy_interface != state->interface &&
65 (state->interface == PHY_INTERFACE_MODE_SGMII ||
66 state->interface == PHY_INTERFACE_MODE_1000BASEX ||
67 - state->interface == PHY_INTERFACE_MODE_2500BASEX))
68 - WARN_ON(phy_set_mode_ext(pp->comphy, PHY_MODE_ETHERNET,
69 - state->interface));
70 + state->interface == PHY_INTERFACE_MODE_2500BASEX)) {
71 + pp->phy_interface = state->interface;
72 +
73 + WARN_ON(phy_power_off(pp->comphy));
74 + WARN_ON(mvneta_comphy_init(pp));
75 + }
76
77 if (new_ctrl0 != gmac_ctrl0)
78 mvreg_write(pp, MVNETA_GMAC_CTRL_0, new_ctrl0);