a2c897b7a9aadae023d254f2f65152f227248595
[openwrt/staging/svanheule.git] /
1 From 0a6fc70d76bddf98278af2ac000379c82aec8f11 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <pali@kernel.org>
3 Date: Mon, 29 Aug 2022 10:30:46 +0200
4 Subject: [PATCH] phy: marvell: phy-mvebu-a3700-comphy: Remove broken reset
5 support
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 Reset support for SATA PHY is somehow broken and after calling it, kernel
11 is not able to detect and initialize SATA disk Samsung SSD 850 EMT0 [1].
12
13 Reset support was introduced in commit 934337080c6c ("phy: marvell:
14 phy-mvebu-a3700-comphy: Add native kernel implementation") as part of
15 complete rewrite of this driver. v1 patch series of that commit [2] did
16 not contain reset support and was tested that is working fine with
17 Ethernet, SATA and USB PHYs without issues too.
18
19 So for now remove broken reset support and change implementation of
20 power_off callback to power off all functions on specified lane (and not
21 only selected function) because during startup kernel does not know which
22 function was selected and configured by bootloader. Same logic was used
23 also in v1 patch series of that commit.
24
25 This change fixes issues with initialization of SATA disk Samsung SSD 850
26 and disk is working again, like before mentioned commit.
27
28 Once problem with PHY reset callback is solved its functionality could be
29 re-introduced. But for now it is unknown why it does not work.
30
31 [1] - https://lore.kernel.org/r/20220531124159.3e4lgn2v462irbtz@shindev/
32 [2] - https://lore.kernel.org/r/20211028184242.22105-1-kabel@kernel.org/
33
34 Reported-by: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
35 Fixes: 934337080c6c ("phy: marvell: phy-mvebu-a3700-comphy: Add native kernel implementation")
36 Cc: stable@vger.kernel.org # v5.18+
37 Signed-off-by: Pali Rohár <pali@kernel.org>
38 Tested-by: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
39 Link: https://lore.kernel.org/r/20220829083046.15082-1-pali@kernel.org
40 Signed-off-by: Vinod Koul <vkoul@kernel.org>
41 ---
42 drivers/phy/marvell/phy-mvebu-a3700-comphy.c | 87 ++++----------------
43 1 file changed, 17 insertions(+), 70 deletions(-)
44
45 --- a/drivers/phy/marvell/phy-mvebu-a3700-comphy.c
46 +++ b/drivers/phy/marvell/phy-mvebu-a3700-comphy.c
47 @@ -274,7 +274,6 @@ struct mvebu_a3700_comphy_lane {
48 int submode;
49 bool invert_tx;
50 bool invert_rx;
51 - bool needs_reset;
52 };
53
54 struct gbe_phy_init_data_fix {
55 @@ -1097,40 +1096,12 @@ mvebu_a3700_comphy_pcie_power_off(struct
56 0x0, PU_PLL_BIT | PU_RX_BIT | PU_TX_BIT);
57 }
58
59 -static int mvebu_a3700_comphy_reset(struct phy *phy)
60 +static void mvebu_a3700_comphy_usb3_power_off(struct mvebu_a3700_comphy_lane *lane)
61 {
62 - struct mvebu_a3700_comphy_lane *lane = phy_get_drvdata(phy);
63 - u16 mask, data;
64 -
65 - dev_dbg(lane->dev, "resetting lane %d\n", lane->id);
66 -
67 - /* COMPHY reset for internal logic */
68 - comphy_lane_reg_set(lane, COMPHY_SFT_RESET,
69 - SFT_RST_NO_REG, SFT_RST_NO_REG);
70 -
71 - /* COMPHY register reset (cleared automatically) */
72 - comphy_lane_reg_set(lane, COMPHY_SFT_RESET, SFT_RST, SFT_RST);
73 -
74 - /* PIPE soft and register reset */
75 - data = PIPE_SOFT_RESET | PIPE_REG_RESET;
76 - mask = data;
77 - comphy_lane_reg_set(lane, COMPHY_PIPE_RST_CLK_CTRL, data, mask);
78 -
79 - /* Release PIPE register reset */
80 - comphy_lane_reg_set(lane, COMPHY_PIPE_RST_CLK_CTRL,
81 - 0x0, PIPE_REG_RESET);
82 -
83 - /* Reset SB configuration register (only for lanes 0 and 1) */
84 - if (lane->id == 0 || lane->id == 1) {
85 - u32 mask, data;
86 -
87 - data = PIN_RESET_CORE_BIT | PIN_RESET_COMPHY_BIT |
88 - PIN_PU_PLL_BIT | PIN_PU_RX_BIT | PIN_PU_TX_BIT;
89 - mask = data | PIN_PU_IVREF_BIT | PIN_TX_IDLE_BIT;
90 - comphy_periph_reg_set(lane, COMPHY_PHY_CFG1, data, mask);
91 - }
92 -
93 - return 0;
94 + /*
95 + * The USB3 MAC sets the USB3 PHY to low state, so we do not
96 + * need to power off USB3 PHY again.
97 + */
98 }
99
100 static bool mvebu_a3700_comphy_check_mode(int lane,
101 @@ -1171,10 +1142,6 @@ static int mvebu_a3700_comphy_set_mode(s
102 (lane->mode != mode || lane->submode != submode))
103 return -EBUSY;
104
105 - /* If changing mode, ensure reset is called */
106 - if (lane->mode != PHY_MODE_INVALID && lane->mode != mode)
107 - lane->needs_reset = true;
108 -
109 /* Just remember the mode, ->power_on() will do the real setup */
110 lane->mode = mode;
111 lane->submode = submode;
112 @@ -1185,7 +1152,6 @@ static int mvebu_a3700_comphy_set_mode(s
113 static int mvebu_a3700_comphy_power_on(struct phy *phy)
114 {
115 struct mvebu_a3700_comphy_lane *lane = phy_get_drvdata(phy);
116 - int ret;
117
118 if (!mvebu_a3700_comphy_check_mode(lane->id, lane->mode,
119 lane->submode)) {
120 @@ -1193,14 +1159,6 @@ static int mvebu_a3700_comphy_power_on(s
121 return -EINVAL;
122 }
123
124 - if (lane->needs_reset) {
125 - ret = mvebu_a3700_comphy_reset(phy);
126 - if (ret)
127 - return ret;
128 -
129 - lane->needs_reset = false;
130 - }
131 -
132 switch (lane->mode) {
133 case PHY_MODE_USB_HOST_SS:
134 dev_dbg(lane->dev, "set lane %d to USB3 host mode\n", lane->id);
135 @@ -1224,38 +1182,28 @@ static int mvebu_a3700_comphy_power_off(
136 {
137 struct mvebu_a3700_comphy_lane *lane = phy_get_drvdata(phy);
138
139 - switch (lane->mode) {
140 - case PHY_MODE_USB_HOST_SS:
141 - /*
142 - * The USB3 MAC sets the USB3 PHY to low state, so we do not
143 - * need to power off USB3 PHY again.
144 - */
145 - break;
146 -
147 - case PHY_MODE_SATA:
148 - mvebu_a3700_comphy_sata_power_off(lane);
149 - break;
150 -
151 - case PHY_MODE_ETHERNET:
152 + switch (lane->id) {
153 + case 0:
154 + mvebu_a3700_comphy_usb3_power_off(lane);
155 mvebu_a3700_comphy_ethernet_power_off(lane);
156 - break;
157 -
158 - case PHY_MODE_PCIE:
159 + return 0;
160 + case 1:
161 mvebu_a3700_comphy_pcie_power_off(lane);
162 - break;
163 -
164 + mvebu_a3700_comphy_ethernet_power_off(lane);
165 + return 0;
166 + case 2:
167 + mvebu_a3700_comphy_usb3_power_off(lane);
168 + mvebu_a3700_comphy_sata_power_off(lane);
169 + return 0;
170 default:
171 dev_err(lane->dev, "invalid COMPHY mode\n");
172 return -EINVAL;
173 }
174 -
175 - return 0;
176 }
177
178 static const struct phy_ops mvebu_a3700_comphy_ops = {
179 .power_on = mvebu_a3700_comphy_power_on,
180 .power_off = mvebu_a3700_comphy_power_off,
181 - .reset = mvebu_a3700_comphy_reset,
182 .set_mode = mvebu_a3700_comphy_set_mode,
183 .owner = THIS_MODULE,
184 };
185 @@ -1393,8 +1341,7 @@ static int mvebu_a3700_comphy_probe(stru
186 * To avoid relying on the bootloader/firmware configuration,
187 * power off all comphys.
188 */
189 - mvebu_a3700_comphy_reset(phy);
190 - lane->needs_reset = false;
191 + mvebu_a3700_comphy_power_off(phy);
192 }
193
194 provider = devm_of_phy_provider_register(&pdev->dev,