[PATCH 2/2] phy: freescale: Add i.MX8qm Mixel LVDS PHY support
Krzysztof Kozlowski
krzysztof.kozlowski at linaro.org
Sun Jun 19 05:15:03 PDT 2022
On 18/06/2022 11:22, Liu Ying wrote:
> This patch adds Freescale i.MX8qm LVDS PHY support.
Don't use "This patch".
https://elixir.bootlin.com/linux/v5.17.1/source/Documentation/process/submitting-patches.rst#L95
> The PHY IP is from Mixel, Inc.
>
> Signed-off-by: Liu Ying <victor.liu at nxp.com>
> +static int mixel_lvds_phy_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct phy_provider *phy_provider;
> + struct mixel_lvds_phy_priv *priv;
> + struct mixel_lvds_phy *lvds_phy;
> + struct phy *phy;
> + int i;
> + int ret;
> +
> + if (!dev->of_node)
> + return -ENODEV;
> +
> + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> + if (!priv)
> + return -ENOMEM;
> +
> + priv->regmap = syscon_node_to_regmap(dev->of_node->parent);
> + if (IS_ERR(priv->regmap)) {
> + ret = PTR_ERR(priv->regmap);
> + dev_err_probe(dev, ret, "failed to get regmap\n");
> + return ret;
All such calls are one-liners.
> + }
> +
> + priv->phy_ref_clk = devm_clk_get(dev, "phy_ref");
> + if (IS_ERR(priv->phy_ref_clk)) {
> + ret = PTR_ERR(priv->phy_ref_clk);
> + dev_err_probe(dev, ret, "failed to get PHY reference clock\n");
> + return ret;
Again, one line instead of three.
> + }
> +
> + mutex_init(&priv->lock);
> +
> + dev_set_drvdata(dev, priv);
> +
> + pm_runtime_enable(dev);
> +
> + ret = mixel_lvds_phy_reset(dev);
> + if (ret) {
> + dev_err(dev, "failed to do POR reset: %d\n", ret);
> + return ret;
> + }
> +
> + for (i = 0; i < PHY_NUM; i++) {
> + lvds_phy = devm_kzalloc(dev, sizeof(*lvds_phy), GFP_KERNEL);
> + if (!lvds_phy) {
> + ret = -ENOMEM;
> + goto err;
> + }
> +
> + phy = devm_phy_create(dev, NULL, &mixel_lvds_phy_ops);
> + if (IS_ERR(phy)) {
> + ret = PTR_ERR(phy);
> + dev_err(dev, "failed to create PHY for channel%d: %d\n",
> + i, ret);
> + goto err;
> + }
> +
> + lvds_phy->phy = phy;
> + lvds_phy->id = i;
> + priv->phys[i] = lvds_phy;
> +
> + phy_set_drvdata(phy, lvds_phy);
> + }
> +
> + phy_provider = devm_of_phy_provider_register(dev, mixel_lvds_phy_xlate);
> + if (IS_ERR(phy_provider)) {
> + ret = PTR_ERR(phy_provider);
> + dev_err(dev, "failed to register PHY provider: %d\n", ret);
> + goto err;
> + }
> +
> + return 0;
> +err:
> + pm_runtime_disable(dev);
> +
> + return ret;
> +}
> +
> +static int mixel_lvds_phy_remove(struct platform_device *pdev)
> +{
> + pm_runtime_disable(&pdev->dev);
> +
> + return 0;
> +}
> +
> +static int __maybe_unused mixel_lvds_phy_runtime_suspend(struct device *dev)
> +{
> + struct mixel_lvds_phy_priv *priv = dev_get_drvdata(dev);
> +
> + /* power down */
> + mutex_lock(&priv->lock);
> + regmap_write(priv->regmap, PHY_CTRL + REG_SET, PD);
> + mutex_unlock(&priv->lock);
> +
> + dev_dbg(dev, "runtime suspended\n");
> +
> + return 0;
> +}
> +
> +static int __maybe_unused mixel_lvds_phy_runtime_resume(struct device *dev)
> +{
> + struct mixel_lvds_phy_priv *priv = dev_get_drvdata(dev);
> +
> + /* power up + control initialization */
> + mutex_lock(&priv->lock);
> + regmap_update_bits(priv->regmap, PHY_CTRL,
> + CTRL_INIT_MASK | PD, CTRL_INIT_VAL);
> + mutex_unlock(&priv->lock);
> +
> + dev_dbg(dev, "runtime resumed\n");
No such debug messages.
Best regards,
Krzysztof
More information about the linux-arm-kernel
mailing list