Re: [PATCH 03/26] phy: qcom: add the SGMII SerDes PHY driver

From: Bartosz Golaszewski
Date: Wed Jun 14 2023 - 03:20:19 EST


On Mon, Jun 12, 2023 at 11:45 AM Konrad Dybcio <konrad.dybcio@xxxxxxxxxx> wrote:
>
>
>
> On 12.06.2023 11:23, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
> >
> > Implement support for the SGMII/SerDes PHY present on various Qualcomm
> > platforms.
> >
> > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
> > ---
> > +static const struct regmap_config qcom_dwmac_sgmii_phy_regmap_cfg = {
> > + .reg_bits = 32,
> > + .val_bits = 32,
> > + .reg_stride = 4,
> > + .use_relaxed_mmio = true,
> > + .disable_locking = true,
> The last two are rather brave, no?
>

We don't need locking because all callbacks are already protected by
the phy subsystem with a mutex and I don't really see anything that
would make it dangerous to use relaxed semantics in this driver. It's
just basic configuration.

Bart

> Konrad
> > +};
> > +
> > +static int qcom_dwmac_sgmii_phy_probe(struct platform_device *pdev)
> > +{
> > + struct qcom_dwmac_sgmii_phy_data *data;
> > + struct device *dev = &pdev->dev;
> > + struct phy_provider *provider;
> > + struct clk *refclk;
> > + void __iomem *base;
> > + struct phy *phy;
> > +
> > + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
> > + if (!data)
> > + return -ENOMEM;
> > +
> > + base = devm_platform_ioremap_resource(pdev, 0);
> > + if (IS_ERR(base))
> > + return PTR_ERR(base);
> > +
> > + data->regmap = devm_regmap_init_mmio(dev, base,
> > + &qcom_dwmac_sgmii_phy_regmap_cfg);
> > + if (IS_ERR(data->regmap))
> > + return PTR_ERR(data->regmap);
> > +
> > + phy = devm_phy_create(dev, NULL, &qcom_dwmac_sgmii_phy_ops);
> > + if (IS_ERR(phy))
> > + return PTR_ERR(phy);
> > +
> > + refclk = devm_clk_get_enabled(dev, "sgmi_ref");
> > + if (IS_ERR(refclk))
> > + return PTR_ERR(refclk);
> > +
> > + provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
> > + if (IS_ERR(provider))
> > + return PTR_ERR(provider);
> > +
> > + phy_set_drvdata(phy, data);
> > + platform_set_drvdata(pdev, data);
> > +
> > + return 0;
> > +}
> > +
> > +static const struct of_device_id qcom_dwmac_sgmii_phy_of_match[] = {
> > + { .compatible = "qcom,sa8775p-dwmac-sgmii-phy" },
> > + { },
> > +};
> > +MODULE_DEVICE_TABLE(of, qcom_dwmac_sgmii_phy_of_match);
> > +
> > +static struct platform_driver qcom_dwmac_sgmii_phy_driver = {
> > + .probe = qcom_dwmac_sgmii_phy_probe,
> > + .driver = {
> > + .name = "qcom-dwmac-sgmii-phy",
> > + .of_match_table = qcom_dwmac_sgmii_phy_of_match,
> > + }
> > +};
> > +
> > +module_platform_driver(qcom_dwmac_sgmii_phy_driver);
> > +
> > +MODULE_DESCRIPTION("Qualcomm DWMAC SGMII PHY driver");
> > +MODULE_LICENSE("GPL");