Lines Matching +full:2 +full:- +full:lane

1 // SPDX-License-Identifier: GPL-2.0
9 * Structure inspired from phy-mvebu-cp110-comphy.c written by Antoine Tenart.
13 #include <linux/arm-smccc.h>
23 #define MVEBU_A3700_COMPHY_PORTS 2
40 #define COMPHY_FW_SPEED_3_125G 2 /* 2500BASE-X */
47 ((speed) << 2))
52 unsigned int lane; member
61 .lane = _lane, \
75 /* lane 0 */
82 /* lane 1 */
89 /* lane 2 */
90 MVEBU_A3700_COMPHY_CONF_GEN(2, PHY_MODE_SATA, 0,
92 MVEBU_A3700_COMPHY_CONF_GEN(2, PHY_MODE_USB_HOST_SS, 0,
104 static int mvebu_a3700_comphy_smc(unsigned long function, unsigned long lane, in mvebu_a3700_comphy_smc() argument
110 arm_smccc_smc(function, lane, mode, 0, 0, 0, 0, 0, &res); in mvebu_a3700_comphy_smc()
117 return -EOPNOTSUPP; in mvebu_a3700_comphy_smc()
119 return -EINVAL; in mvebu_a3700_comphy_smc()
123 static int mvebu_a3700_comphy_get_fw_mode(int lane, int port, in mvebu_a3700_comphy_get_fw_mode() argument
131 return -EINVAL; in mvebu_a3700_comphy_get_fw_mode()
134 if (mvebu_a3700_comphy_modes[i].lane == lane && in mvebu_a3700_comphy_get_fw_mode()
142 return -EINVAL; in mvebu_a3700_comphy_get_fw_mode()
150 struct mvebu_a3700_comphy_lane *lane = phy_get_drvdata(phy); in mvebu_a3700_comphy_set_mode() local
156 fw_mode = mvebu_a3700_comphy_get_fw_mode(lane->id, lane->port, mode, in mvebu_a3700_comphy_set_mode()
159 dev_err(lane->dev, "invalid COMPHY mode\n"); in mvebu_a3700_comphy_set_mode()
163 /* Just remember the mode, ->power_on() will do the real setup */ in mvebu_a3700_comphy_set_mode()
164 lane->mode = mode; in mvebu_a3700_comphy_set_mode()
165 lane->submode = submode; in mvebu_a3700_comphy_set_mode()
172 struct mvebu_a3700_comphy_lane *lane = phy_get_drvdata(phy); in mvebu_a3700_comphy_power_on() local
177 fw_mode = mvebu_a3700_comphy_get_fw_mode(lane->id, lane->port, in mvebu_a3700_comphy_power_on()
178 lane->mode, lane->submode); in mvebu_a3700_comphy_power_on()
180 dev_err(lane->dev, "invalid COMPHY mode\n"); in mvebu_a3700_comphy_power_on()
184 switch (lane->mode) { in mvebu_a3700_comphy_power_on()
186 dev_dbg(lane->dev, "set lane %d to USB3 host mode\n", lane->id); in mvebu_a3700_comphy_power_on()
190 dev_dbg(lane->dev, "set lane %d to SATA mode\n", lane->id); in mvebu_a3700_comphy_power_on()
194 switch (lane->submode) { in mvebu_a3700_comphy_power_on()
196 dev_dbg(lane->dev, "set lane %d to SGMII mode\n", in mvebu_a3700_comphy_power_on()
197 lane->id); in mvebu_a3700_comphy_power_on()
198 fw_param = COMPHY_FW_NET(fw_mode, lane->port, in mvebu_a3700_comphy_power_on()
202 dev_dbg(lane->dev, "set lane %d to 2500BASEX mode\n", in mvebu_a3700_comphy_power_on()
203 lane->id); in mvebu_a3700_comphy_power_on()
204 fw_param = COMPHY_FW_NET(fw_mode, lane->port, in mvebu_a3700_comphy_power_on()
208 dev_err(lane->dev, "unsupported PHY submode (%d)\n", in mvebu_a3700_comphy_power_on()
209 lane->submode); in mvebu_a3700_comphy_power_on()
210 return -ENOTSUPP; in mvebu_a3700_comphy_power_on()
214 dev_dbg(lane->dev, "set lane %d to PCIe mode\n", lane->id); in mvebu_a3700_comphy_power_on()
215 fw_param = COMPHY_FW_PCIE(fw_mode, lane->port, in mvebu_a3700_comphy_power_on()
217 phy->attrs.bus_width); in mvebu_a3700_comphy_power_on()
220 dev_err(lane->dev, "unsupported PHY mode (%d)\n", lane->mode); in mvebu_a3700_comphy_power_on()
221 return -ENOTSUPP; in mvebu_a3700_comphy_power_on()
224 ret = mvebu_a3700_comphy_smc(COMPHY_SIP_POWER_ON, lane->id, fw_param); in mvebu_a3700_comphy_power_on()
225 if (ret == -EOPNOTSUPP) in mvebu_a3700_comphy_power_on()
226 dev_err(lane->dev, in mvebu_a3700_comphy_power_on()
234 struct mvebu_a3700_comphy_lane *lane = phy_get_drvdata(phy); in mvebu_a3700_comphy_power_off() local
236 return mvebu_a3700_comphy_smc(COMPHY_SIP_POWER_OFF, lane->id, 0); in mvebu_a3700_comphy_power_off()
249 struct mvebu_a3700_comphy_lane *lane; in mvebu_a3700_comphy_xlate() local
252 if (WARN_ON(args->args[0] >= MVEBU_A3700_COMPHY_PORTS)) in mvebu_a3700_comphy_xlate()
253 return ERR_PTR(-EINVAL); in mvebu_a3700_comphy_xlate()
259 lane = phy_get_drvdata(phy); in mvebu_a3700_comphy_xlate()
260 lane->port = args->args[0]; in mvebu_a3700_comphy_xlate()
270 for_each_available_child_of_node(pdev->dev.of_node, child) { in mvebu_a3700_comphy_probe()
271 struct mvebu_a3700_comphy_lane *lane; in mvebu_a3700_comphy_probe() local
278 dev_err(&pdev->dev, "missing 'reg' property (%d)\n", in mvebu_a3700_comphy_probe()
284 dev_err(&pdev->dev, "invalid 'reg' property\n"); in mvebu_a3700_comphy_probe()
288 lane = devm_kzalloc(&pdev->dev, sizeof(*lane), GFP_KERNEL); in mvebu_a3700_comphy_probe()
289 if (!lane) { in mvebu_a3700_comphy_probe()
291 return -ENOMEM; in mvebu_a3700_comphy_probe()
294 phy = devm_phy_create(&pdev->dev, child, in mvebu_a3700_comphy_probe()
301 lane->dev = &pdev->dev; in mvebu_a3700_comphy_probe()
302 lane->mode = PHY_MODE_INVALID; in mvebu_a3700_comphy_probe()
303 lane->submode = PHY_INTERFACE_MODE_NA; in mvebu_a3700_comphy_probe()
304 lane->id = lane_id; in mvebu_a3700_comphy_probe()
305 lane->port = -1; in mvebu_a3700_comphy_probe()
306 phy_set_drvdata(phy, lane); in mvebu_a3700_comphy_probe()
309 provider = devm_of_phy_provider_register(&pdev->dev, in mvebu_a3700_comphy_probe()
315 { .compatible = "marvell,comphy-a3700" },
323 .name = "mvebu-a3700-comphy",