Lines Matching +full:d +full:- +full:phy

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>
18 #include <linux/phy.h>
19 #include <linux/phy/phy.h>
123 return -EOPNOTSUPP; in mvebu_a3700_comphy_smc()
125 return -EINVAL; in mvebu_a3700_comphy_smc()
135 /* Unused PHY mux value is 0x0 */ in mvebu_a3700_comphy_get_fw_mode()
137 return -EINVAL; in mvebu_a3700_comphy_get_fw_mode()
148 return -EINVAL; in mvebu_a3700_comphy_get_fw_mode()
153 static int mvebu_a3700_comphy_set_mode(struct phy *phy, enum phy_mode mode, in mvebu_a3700_comphy_set_mode() argument
156 struct mvebu_a3700_comphy_lane *lane = phy_get_drvdata(phy); in mvebu_a3700_comphy_set_mode()
162 fw_mode = mvebu_a3700_comphy_get_fw_mode(lane->id, lane->port, mode, in mvebu_a3700_comphy_set_mode()
165 dev_err(lane->dev, "invalid COMPHY mode\n"); in mvebu_a3700_comphy_set_mode()
169 /* Just remember the mode, ->power_on() will do the real setup */ in mvebu_a3700_comphy_set_mode()
170 lane->mode = mode; in mvebu_a3700_comphy_set_mode()
171 lane->submode = submode; in mvebu_a3700_comphy_set_mode()
176 static int mvebu_a3700_comphy_power_on(struct phy *phy) in mvebu_a3700_comphy_power_on() argument
178 struct mvebu_a3700_comphy_lane *lane = phy_get_drvdata(phy); in mvebu_a3700_comphy_power_on()
183 fw_mode = mvebu_a3700_comphy_get_fw_mode(lane->id, lane->port, in mvebu_a3700_comphy_power_on()
184 lane->mode, lane->submode); in mvebu_a3700_comphy_power_on()
186 dev_err(lane->dev, "invalid COMPHY mode\n"); in mvebu_a3700_comphy_power_on()
190 switch (lane->mode) { in mvebu_a3700_comphy_power_on()
192 dev_dbg(lane->dev, "set lane %d to USB3 host mode\n", lane->id); in mvebu_a3700_comphy_power_on()
196 dev_dbg(lane->dev, "set lane %d to SATA mode\n", lane->id); in mvebu_a3700_comphy_power_on()
200 switch (lane->submode) { in mvebu_a3700_comphy_power_on()
202 dev_dbg(lane->dev, "set lane %d to SGMII 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_dbg(lane->dev, "set lane %d to HS SGMII mode\n", in mvebu_a3700_comphy_power_on()
209 lane->id); in mvebu_a3700_comphy_power_on()
210 fw_param = COMPHY_FW_NET(fw_mode, lane->port, in mvebu_a3700_comphy_power_on()
214 dev_err(lane->dev, "unsupported PHY submode (%d)\n", in mvebu_a3700_comphy_power_on()
215 lane->submode); in mvebu_a3700_comphy_power_on()
216 return -ENOTSUPP; in mvebu_a3700_comphy_power_on()
220 dev_dbg(lane->dev, "set lane %d to PCIe mode\n", lane->id); in mvebu_a3700_comphy_power_on()
221 fw_param = COMPHY_FW_PCIE(fw_mode, lane->port, in mvebu_a3700_comphy_power_on()
223 phy->attrs.bus_width); in mvebu_a3700_comphy_power_on()
226 dev_err(lane->dev, "unsupported PHY mode (%d)\n", lane->mode); in mvebu_a3700_comphy_power_on()
227 return -ENOTSUPP; in mvebu_a3700_comphy_power_on()
230 ret = mvebu_a3700_comphy_smc(COMPHY_SIP_POWER_ON, lane->id, fw_param); in mvebu_a3700_comphy_power_on()
231 if (ret == -EOPNOTSUPP) in mvebu_a3700_comphy_power_on()
232 dev_err(lane->dev, in mvebu_a3700_comphy_power_on()
238 static int mvebu_a3700_comphy_power_off(struct phy *phy) in mvebu_a3700_comphy_power_off() argument
240 struct mvebu_a3700_comphy_lane *lane = phy_get_drvdata(phy); in mvebu_a3700_comphy_power_off()
242 return mvebu_a3700_comphy_smc(COMPHY_SIP_POWER_OFF, lane->id, 0); in mvebu_a3700_comphy_power_off()
252 static struct phy *mvebu_a3700_comphy_xlate(struct device *dev, in mvebu_a3700_comphy_xlate()
256 struct phy *phy; in mvebu_a3700_comphy_xlate() local
258 if (WARN_ON(args->args[0] >= MVEBU_A3700_COMPHY_PORTS)) in mvebu_a3700_comphy_xlate()
259 return ERR_PTR(-EINVAL); in mvebu_a3700_comphy_xlate()
261 phy = of_phy_simple_xlate(dev, args); in mvebu_a3700_comphy_xlate()
262 if (IS_ERR(phy)) in mvebu_a3700_comphy_xlate()
263 return phy; in mvebu_a3700_comphy_xlate()
265 lane = phy_get_drvdata(phy); in mvebu_a3700_comphy_xlate()
266 lane->port = args->args[0]; in mvebu_a3700_comphy_xlate()
268 return phy; in mvebu_a3700_comphy_xlate()
276 for_each_available_child_of_node(pdev->dev.of_node, child) { in mvebu_a3700_comphy_probe()
278 struct phy *phy; in mvebu_a3700_comphy_probe() local
284 dev_err(&pdev->dev, "missing 'reg' property (%d)\n", in mvebu_a3700_comphy_probe()
290 dev_err(&pdev->dev, "invalid 'reg' property\n"); in mvebu_a3700_comphy_probe()
294 lane = devm_kzalloc(&pdev->dev, sizeof(*lane), GFP_KERNEL); in mvebu_a3700_comphy_probe()
297 return -ENOMEM; in mvebu_a3700_comphy_probe()
300 phy = devm_phy_create(&pdev->dev, child, in mvebu_a3700_comphy_probe()
302 if (IS_ERR(phy)) { in mvebu_a3700_comphy_probe()
304 return PTR_ERR(phy); in mvebu_a3700_comphy_probe()
307 lane->dev = &pdev->dev; in mvebu_a3700_comphy_probe()
308 lane->mode = PHY_MODE_INVALID; in mvebu_a3700_comphy_probe()
309 lane->submode = PHY_INTERFACE_MODE_NA; in mvebu_a3700_comphy_probe()
310 lane->id = lane_id; in mvebu_a3700_comphy_probe()
311 lane->port = -1; in mvebu_a3700_comphy_probe()
312 phy_set_drvdata(phy, lane); in mvebu_a3700_comphy_probe()
315 provider = devm_of_phy_provider_register(&pdev->dev, in mvebu_a3700_comphy_probe()
321 { .compatible = "marvell,comphy-a3700" },
329 .name = "mvebu-a3700-comphy",
336 MODULE_DESCRIPTION("Common PHY driver for A3700");