Lines Matching +full:phy +full:- +full:qcom +full:- +full:qmp
1 // SPDX-License-Identifier: GPL-2.0-only
10 #include <linux/phy/phy.h>
14 #include "phy-qcom-qmp-pcs-sgmii.h"
15 #include "phy-qcom-qmp-qserdes-com-v5.h"
16 #include "phy-qcom-qmp-qserdes-txrx-v5.h"
220 static int qcom_dwmac_sgmii_phy_calibrate(struct phy *phy) in qcom_dwmac_sgmii_phy_calibrate() argument
222 struct qcom_dwmac_sgmii_phy_data *data = phy_get_drvdata(phy); in qcom_dwmac_sgmii_phy_calibrate()
223 struct device *dev = phy->dev.parent; in qcom_dwmac_sgmii_phy_calibrate()
225 switch (data->speed) { in qcom_dwmac_sgmii_phy_calibrate()
229 qcom_dwmac_sgmii_phy_init_1g(data->regmap); in qcom_dwmac_sgmii_phy_calibrate()
232 qcom_dwmac_sgmii_phy_init_2p5g(data->regmap); in qcom_dwmac_sgmii_phy_calibrate()
236 if (qcom_dwmac_sgmii_phy_poll_status(data->regmap, in qcom_dwmac_sgmii_phy_calibrate()
239 dev_err(dev, "QSERDES_COM_C_READY_STATUS timed-out"); in qcom_dwmac_sgmii_phy_calibrate()
240 return -ETIMEDOUT; in qcom_dwmac_sgmii_phy_calibrate()
243 if (qcom_dwmac_sgmii_phy_poll_status(data->regmap, in qcom_dwmac_sgmii_phy_calibrate()
246 dev_err(dev, "PCS_READY timed-out"); in qcom_dwmac_sgmii_phy_calibrate()
247 return -ETIMEDOUT; in qcom_dwmac_sgmii_phy_calibrate()
250 if (qcom_dwmac_sgmii_phy_poll_status(data->regmap, in qcom_dwmac_sgmii_phy_calibrate()
253 dev_err(dev, "SGMIIPHY_READY timed-out"); in qcom_dwmac_sgmii_phy_calibrate()
254 return -ETIMEDOUT; in qcom_dwmac_sgmii_phy_calibrate()
257 if (qcom_dwmac_sgmii_phy_poll_status(data->regmap, in qcom_dwmac_sgmii_phy_calibrate()
260 dev_err(dev, "PLL Lock Status timed-out"); in qcom_dwmac_sgmii_phy_calibrate()
261 return -ETIMEDOUT; in qcom_dwmac_sgmii_phy_calibrate()
267 static int qcom_dwmac_sgmii_phy_power_on(struct phy *phy) in qcom_dwmac_sgmii_phy_power_on() argument
269 struct qcom_dwmac_sgmii_phy_data *data = phy_get_drvdata(phy); in qcom_dwmac_sgmii_phy_power_on()
271 return clk_prepare_enable(data->refclk); in qcom_dwmac_sgmii_phy_power_on()
274 static int qcom_dwmac_sgmii_phy_power_off(struct phy *phy) in qcom_dwmac_sgmii_phy_power_off() argument
276 struct qcom_dwmac_sgmii_phy_data *data = phy_get_drvdata(phy); in qcom_dwmac_sgmii_phy_power_off()
278 regmap_write(data->regmap, QSERDES_PCS + QPHY_PCS_TX_MID_TERM_CTRL2, 0x08); in qcom_dwmac_sgmii_phy_power_off()
279 regmap_write(data->regmap, QSERDES_PCS + QPHY_PCS_SW_RESET, 0x01); in qcom_dwmac_sgmii_phy_power_off()
281 regmap_write(data->regmap, QSERDES_PCS + QPHY_PCS_SW_RESET, 0x00); in qcom_dwmac_sgmii_phy_power_off()
282 regmap_write(data->regmap, QSERDES_PCS + QPHY_PCS_PHY_START, 0x01); in qcom_dwmac_sgmii_phy_power_off()
284 clk_disable_unprepare(data->refclk); in qcom_dwmac_sgmii_phy_power_off()
289 static int qcom_dwmac_sgmii_phy_set_speed(struct phy *phy, int speed) in qcom_dwmac_sgmii_phy_set_speed() argument
291 struct qcom_dwmac_sgmii_phy_data *data = phy_get_drvdata(phy); in qcom_dwmac_sgmii_phy_set_speed()
293 if (speed != data->speed) in qcom_dwmac_sgmii_phy_set_speed()
294 data->speed = speed; in qcom_dwmac_sgmii_phy_set_speed()
296 return qcom_dwmac_sgmii_phy_calibrate(phy); in qcom_dwmac_sgmii_phy_set_speed()
318 struct device *dev = &pdev->dev; in qcom_dwmac_sgmii_phy_probe()
321 struct phy *phy; in qcom_dwmac_sgmii_phy_probe() local
325 return -ENOMEM; in qcom_dwmac_sgmii_phy_probe()
327 data->speed = SPEED_10; in qcom_dwmac_sgmii_phy_probe()
333 data->regmap = devm_regmap_init_mmio(dev, base, in qcom_dwmac_sgmii_phy_probe()
335 if (IS_ERR(data->regmap)) in qcom_dwmac_sgmii_phy_probe()
336 return PTR_ERR(data->regmap); in qcom_dwmac_sgmii_phy_probe()
338 phy = devm_phy_create(dev, NULL, &qcom_dwmac_sgmii_phy_ops); in qcom_dwmac_sgmii_phy_probe()
339 if (IS_ERR(phy)) in qcom_dwmac_sgmii_phy_probe()
340 return PTR_ERR(phy); in qcom_dwmac_sgmii_phy_probe()
342 data->refclk = devm_clk_get(dev, "sgmi_ref"); in qcom_dwmac_sgmii_phy_probe()
343 if (IS_ERR(data->refclk)) in qcom_dwmac_sgmii_phy_probe()
344 return PTR_ERR(data->refclk); in qcom_dwmac_sgmii_phy_probe()
350 phy_set_drvdata(phy, data); in qcom_dwmac_sgmii_phy_probe()
356 { .compatible = "qcom,sa8775p-dwmac-sgmii-phy" },
364 .name = "qcom-dwmac-sgmii-phy",
371 MODULE_DESCRIPTION("Qualcomm DWMAC SGMII PHY driver");