1 From 4bf18d5a2dd02db8c5b16a2cfae513510506df5b Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <pali@kernel.org>
3 Date: Thu, 3 Feb 2022 22:44:40 +0100
4 Subject: [PATCH 1/2] phy: marvell: phy-mvebu-a3700-comphy: Remove port from
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
10 Port number is encoded into argument for SMC call. It is zero for SATA,
11 PCIe and also both USB 3.0 PHYs. It is non-zero only for Ethernet PHY
12 (incorrectly called SGMII) on lane 0. Ethernet PHY on lane 1 also uses zero
15 So construct "port" bits for SMC call argument can be constructed directly
16 from PHY type and lane number.
18 Change driver code to always pass zero port number for non-ethernet PHYs
19 and for ethernet PHYs determinate port number from lane number. This
20 simplifies the driver.
22 As port number from DT PHY configuration is not used anymore, remove whole
23 driver code which parses it. This also simplifies the driver.
25 Signed-off-by: Pali Rohár <pali@kernel.org>
26 Signed-off-by: Marek Behún <kabel@kernel.org>
27 Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
28 Link: https://lore.kernel.org/r/20220203214444.1508-2-kabel@kernel.org
29 Signed-off-by: Vinod Koul <vkoul@kernel.org>
31 drivers/phy/marvell/phy-mvebu-a3700-comphy.c | 62 +++++++++-----------
32 1 file changed, 29 insertions(+), 33 deletions(-)
34 --- a/drivers/phy/marvell/phy-mvebu-a3700-comphy.c
35 +++ b/drivers/phy/marvell/phy-mvebu-a3700-comphy.c
37 #include <linux/platform_device.h>
39 #define MVEBU_A3700_COMPHY_LANES 3
40 -#define MVEBU_A3700_COMPHY_PORTS 2
42 /* COMPHY Fast SMC function identifiers */
43 #define COMPHY_SIP_POWER_ON 0x82000001
45 #define COMPHY_FW_NET(mode, idx, speed) (COMPHY_FW_MODE(mode) | \
48 -#define COMPHY_FW_PCIE(mode, idx, speed, width) (COMPHY_FW_NET(mode, idx, speed) | \
49 +#define COMPHY_FW_PCIE(mode, speed, width) (COMPHY_FW_NET(mode, 0, speed) | \
52 struct mvebu_a3700_comphy_conf {
60 -#define MVEBU_A3700_COMPHY_CONF(_lane, _mode, _smode, _port, _fw) \
61 +#define MVEBU_A3700_COMPHY_CONF(_lane, _mode, _smode, _fw) \
70 -#define MVEBU_A3700_COMPHY_CONF_GEN(_lane, _mode, _port, _fw) \
71 - MVEBU_A3700_COMPHY_CONF(_lane, _mode, PHY_INTERFACE_MODE_NA, _port, _fw)
72 +#define MVEBU_A3700_COMPHY_CONF_GEN(_lane, _mode, _fw) \
73 + MVEBU_A3700_COMPHY_CONF(_lane, _mode, PHY_INTERFACE_MODE_NA, _fw)
75 -#define MVEBU_A3700_COMPHY_CONF_ETH(_lane, _smode, _port, _fw) \
76 - MVEBU_A3700_COMPHY_CONF(_lane, PHY_MODE_ETHERNET, _smode, _port, _fw)
77 +#define MVEBU_A3700_COMPHY_CONF_ETH(_lane, _smode, _fw) \
78 + MVEBU_A3700_COMPHY_CONF(_lane, PHY_MODE_ETHERNET, _smode, _fw)
80 static const struct mvebu_a3700_comphy_conf mvebu_a3700_comphy_modes[] = {
82 - MVEBU_A3700_COMPHY_CONF_GEN(0, PHY_MODE_USB_HOST_SS, 0,
83 + MVEBU_A3700_COMPHY_CONF_GEN(0, PHY_MODE_USB_HOST_SS,
84 COMPHY_FW_MODE_USB3H),
85 - MVEBU_A3700_COMPHY_CONF_ETH(0, PHY_INTERFACE_MODE_SGMII, 1,
86 + MVEBU_A3700_COMPHY_CONF_ETH(0, PHY_INTERFACE_MODE_SGMII,
87 COMPHY_FW_MODE_SGMII),
88 - MVEBU_A3700_COMPHY_CONF_ETH(0, PHY_INTERFACE_MODE_2500BASEX, 1,
89 + MVEBU_A3700_COMPHY_CONF_ETH(0, PHY_INTERFACE_MODE_2500BASEX,
90 COMPHY_FW_MODE_2500BASEX),
92 - MVEBU_A3700_COMPHY_CONF_GEN(1, PHY_MODE_PCIE, 0,
93 - COMPHY_FW_MODE_PCIE),
94 - MVEBU_A3700_COMPHY_CONF_ETH(1, PHY_INTERFACE_MODE_SGMII, 0,
95 + MVEBU_A3700_COMPHY_CONF_GEN(1, PHY_MODE_PCIE, COMPHY_FW_MODE_PCIE),
96 + MVEBU_A3700_COMPHY_CONF_ETH(1, PHY_INTERFACE_MODE_SGMII,
97 COMPHY_FW_MODE_SGMII),
98 - MVEBU_A3700_COMPHY_CONF_ETH(1, PHY_INTERFACE_MODE_2500BASEX, 0,
99 + MVEBU_A3700_COMPHY_CONF_ETH(1, PHY_INTERFACE_MODE_2500BASEX,
100 COMPHY_FW_MODE_2500BASEX),
102 - MVEBU_A3700_COMPHY_CONF_GEN(2, PHY_MODE_SATA, 0,
103 - COMPHY_FW_MODE_SATA),
104 - MVEBU_A3700_COMPHY_CONF_GEN(2, PHY_MODE_USB_HOST_SS, 0,
105 + MVEBU_A3700_COMPHY_CONF_GEN(2, PHY_MODE_SATA, COMPHY_FW_MODE_SATA),
106 + MVEBU_A3700_COMPHY_CONF_GEN(2, PHY_MODE_USB_HOST_SS,
107 COMPHY_FW_MODE_USB3H),
110 @@ -98,7 +93,6 @@ struct mvebu_a3700_comphy_lane {
117 static int mvebu_a3700_comphy_smc(unsigned long function, unsigned long lane,
118 @@ -120,7 +114,7 @@ static int mvebu_a3700_comphy_smc(unsign
122 -static int mvebu_a3700_comphy_get_fw_mode(int lane, int port,
123 +static int mvebu_a3700_comphy_get_fw_mode(int lane,
127 @@ -132,7 +126,6 @@ static int mvebu_a3700_comphy_get_fw_mod
129 for (i = 0; i < n; i++) {
130 if (mvebu_a3700_comphy_modes[i].lane == lane &&
131 - mvebu_a3700_comphy_modes[i].port == port &&
132 mvebu_a3700_comphy_modes[i].mode == mode &&
133 mvebu_a3700_comphy_modes[i].submode == submode)
135 @@ -153,7 +146,7 @@ static int mvebu_a3700_comphy_set_mode(s
136 if (submode == PHY_INTERFACE_MODE_1000BASEX)
137 submode = PHY_INTERFACE_MODE_SGMII;
139 - fw_mode = mvebu_a3700_comphy_get_fw_mode(lane->id, lane->port, mode,
140 + fw_mode = mvebu_a3700_comphy_get_fw_mode(lane->id, mode,
143 dev_err(lane->dev, "invalid COMPHY mode\n");
144 @@ -172,9 +165,10 @@ static int mvebu_a3700_comphy_power_on(s
145 struct mvebu_a3700_comphy_lane *lane = phy_get_drvdata(phy);
151 - fw_mode = mvebu_a3700_comphy_get_fw_mode(lane->id, lane->port,
152 + fw_mode = mvebu_a3700_comphy_get_fw_mode(lane->id,
153 lane->mode, lane->submode);
155 dev_err(lane->dev, "invalid COMPHY mode\n");
156 @@ -191,17 +185,18 @@ static int mvebu_a3700_comphy_power_on(s
157 fw_param = COMPHY_FW_MODE(fw_mode);
159 case PHY_MODE_ETHERNET:
160 + fw_port = (lane->id == 0) ? 1 : 0;
161 switch (lane->submode) {
162 case PHY_INTERFACE_MODE_SGMII:
163 dev_dbg(lane->dev, "set lane %d to SGMII mode\n",
165 - fw_param = COMPHY_FW_NET(fw_mode, lane->port,
166 + fw_param = COMPHY_FW_NET(fw_mode, fw_port,
167 COMPHY_FW_SPEED_1_25G);
169 case PHY_INTERFACE_MODE_2500BASEX:
170 dev_dbg(lane->dev, "set lane %d to 2500BASEX mode\n",
172 - fw_param = COMPHY_FW_NET(fw_mode, lane->port,
173 + fw_param = COMPHY_FW_NET(fw_mode, fw_port,
174 COMPHY_FW_SPEED_3_125G);
177 @@ -212,8 +207,7 @@ static int mvebu_a3700_comphy_power_on(s
180 dev_dbg(lane->dev, "set lane %d to PCIe mode\n", lane->id);
181 - fw_param = COMPHY_FW_PCIE(fw_mode, lane->port,
182 - COMPHY_FW_SPEED_5G,
183 + fw_param = COMPHY_FW_PCIE(fw_mode, COMPHY_FW_SPEED_5G,
184 phy->attrs.bus_width);
187 @@ -247,17 +241,20 @@ static struct phy *mvebu_a3700_comphy_xl
188 struct of_phandle_args *args)
190 struct mvebu_a3700_comphy_lane *lane;
194 - if (WARN_ON(args->args[0] >= MVEBU_A3700_COMPHY_PORTS))
195 - return ERR_PTR(-EINVAL);
197 phy = of_phy_simple_xlate(dev, args);
201 lane = phy_get_drvdata(phy);
202 - lane->port = args->args[0];
204 + port = args->args[0];
205 + if (port != 0 && (port != 1 || lane->id != 0)) {
206 + dev_err(lane->dev, "invalid port number %u\n", port);
207 + return ERR_PTR(-EINVAL);
212 @@ -302,7 +299,6 @@ static int mvebu_a3700_comphy_probe(stru
213 lane->mode = PHY_MODE_INVALID;
214 lane->submode = PHY_INTERFACE_MODE_NA;
217 phy_set_drvdata(phy, lane);