LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Nicolas Frattaroli <frattaroli.nicolas@gmail.com>
To: Yifeng Zhao <yifeng.zhao@rock-chips.com>
Cc: heiko@sntech.de, robh+dt@kernel.org,
linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org,
vkoul@kernel.org, michael.riesch@wolfvision.net,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org,
kishon@ti.com, p.zabel@pengutronix.de
Subject: Re: [PATCH v1 2/3] phy/rockchip: add naneng combo phy for RK3568
Date: Tue, 12 Oct 2021 09:36:51 +0200 [thread overview]
Message-ID: <1807525.kHsN9XgAzY@archbook> (raw)
In-Reply-To: <20210826123844.8464-3-yifeng.zhao@rock-chips.com>
On Donnerstag, 26. August 2021 14:38:43 CEST Yifeng Zhao wrote:
> This patch implements a combo phy driver for Rockchip SoCs
> with NaNeng IP block. This phy can be used as pcie-phy, usb3-phy,
> sata-phy or sgmii-phy.
>
> Signed-off-by: Yifeng Zhao <yifeng.zhao@rock-chips.com>
> ---
> [...]
> +static int rockchip_combphy_pcie_init(struct rockchip_combphy_priv *priv)
> +{
> + int ret = 0;
> +
> + if (priv->cfg->combphy_cfg) {
> + ret = priv->cfg->combphy_cfg(priv);
> + if (ret) {
> + dev_err(priv->dev, "failed to init phy for
pcie\n");
> + return ret;
> + }
> + }
> +
> + return ret;
> +}
> +
> +static int rockchip_combphy_usb3_init(struct rockchip_combphy_priv *priv)
> +{
> + int ret = 0;
> +
> + if (priv->cfg->combphy_cfg) {
> + ret = priv->cfg->combphy_cfg(priv);
> + if (ret) {
> + dev_err(priv->dev, "failed to init phy for
usb3\n");
> + return ret;
> + }
> + }
> +
> + return ret;
> +}
> +
> +static int rockchip_combphy_sata_init(struct rockchip_combphy_priv *priv)
> +{
> + int ret = 0;
> +
> + if (priv->cfg->combphy_cfg) {
> + ret = priv->cfg->combphy_cfg(priv);
> + if (ret) {
> + dev_err(priv->dev, "failed to init phy for
sata\n");
> + return ret;
> + }
> + }
> +
> + return ret;
> +}
> +
> +static int rockchip_combphy_sgmii_init(struct rockchip_combphy_priv *priv)
> +{
> + int ret = 0;
> +
> + if (priv->cfg->combphy_cfg) {
> + ret = priv->cfg->combphy_cfg(priv);
> + if (ret) {
> + dev_err(priv->dev, "failed to init phy for
sgmii\n");
> + return ret;
> + }
> + }
> +
> + return ret;
> +}
> +
> +static int rockchip_combphy_set_mode(struct rockchip_combphy_priv *priv)
> +{
> + switch (priv->mode) {
> + case PHY_TYPE_PCIE:
> + rockchip_combphy_pcie_init(priv);
> + break;
> + case PHY_TYPE_USB3:
> + rockchip_combphy_usb3_init(priv);
> + break;
> + case PHY_TYPE_SATA:
> + rockchip_combphy_sata_init(priv);
> + break;
> + case PHY_TYPE_SGMII:
> + case PHY_TYPE_QSGMII:
> + return rockchip_combphy_sgmii_init(priv);
> + default:
> + dev_err(priv->dev, "incompatible PHY type\n");
> + return -EINVAL;
> + }
> +
> + return 0;
> +}
All of the _init functions appear to be the same except for the error
string.
I think it would be better to just have the init done in _set_mode,
and then use the switch case statement to show the right error
message on if (ret).
> [...]
> +
> +static int rockchip_combphy_probe(struct platform_device *pdev)
> +{
> + struct phy_provider *phy_provider;
> + struct device *dev = &pdev->dev;
> + struct rockchip_combphy_priv *priv;
> + const struct rockchip_combphy_cfg *phy_cfg;
> + struct resource *res;
> + int ret;
> +
> + phy_cfg = of_device_get_match_data(dev);
> + if (!phy_cfg) {
> + dev_err(dev, "No OF match data provided\n");
> + return -EINVAL;
> + }
> +
> + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> + if (!priv)
> + return -ENOMEM;
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + priv->mmio = devm_ioremap_resource(dev, res);
I think devm_platform_get_and_ioremap_resource is preferred here,
using it also means you can get rid of res.
> + if (IS_ERR(priv->mmio)) {
> + ret = PTR_ERR(priv->mmio);
> + return ret;
> + }
> +
> [...]
Regards,
Nicolas Frattaroli
next prev parent reply other threads:[~2021-10-12 7:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-26 12:38 [PATCH v1 0/3] Yifeng Zhao
2021-08-26 12:38 ` [PATCH v1 1/3] dt-bindings: phy: rockchip: Add Naneng combo PHY bindings Yifeng Zhao
2021-08-26 13:26 ` Rob Herring
2021-08-26 12:38 ` [PATCH v1 2/3] phy/rockchip: add naneng combo phy for RK3568 Yifeng Zhao
2021-10-12 7:36 ` Nicolas Frattaroli [this message]
2021-08-26 12:38 ` [PATCH v1 3/3] arm64: dts: rockchip: add naneng combo phy nodes for rk3568 Yifeng Zhao
2021-10-12 11:24 ` Nicolas Frattaroli
2021-09-17 17:21 ` [PATCH v1 0/3] Peter Geis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1807525.kHsN9XgAzY@archbook \
--to=frattaroli.nicolas@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=heiko@sntech.de \
--cc=kishon@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=michael.riesch@wolfvision.net \
--cc=p.zabel@pengutronix.de \
--cc=robh+dt@kernel.org \
--cc=vkoul@kernel.org \
--cc=yifeng.zhao@rock-chips.com \
--subject='Re: [PATCH v1 2/3] phy/rockchip: add naneng combo phy for RK3568' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).