From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Dimitri Fedrau via B4 Relay
<devnull+dimitri.fedrau.liebherr.com@kernel.org>
Cc: Vincent Mailhol <mailhol.vincent@wanadoo.fr>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
linux-can@vger.kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org,
Dimitri Fedrau <dimitri.fedrau@liebherr.com>,
Dimitri Fedrau <dima.fedrau@gmail.com>
Subject: Re: [PATCH v2 2/2] can: flexcan: add transceiver capabilities
Date: Thu, 20 Feb 2025 09:43:13 +0100 [thread overview]
Message-ID: <20250220-rugged-solid-gopher-541299-mkl@pengutronix.de> (raw)
In-Reply-To: <20250220-flexcan-add-transceiver-caps-v2-2-a81970f11846@liebherr.com>
[-- Attachment #1: Type: text/plain, Size: 3135 bytes --]
On 20.02.2025 09:22:11, Dimitri Fedrau via B4 Relay wrote:
> From: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
>
> Currently the flexcan driver does only support adding PHYs by using the
> "old" regulator bindings. Add support for CAN transceivers as a PHY. Add
> the capability to ensure that the PHY is in operational state when the link
> is set to an "up" state.
>
> Signed-off-by: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
> ---
> drivers/net/can/flexcan/flexcan-core.c | 30 ++++++++++++++++++++++++------
> drivers/net/can/flexcan/flexcan.h | 1 +
> 2 files changed, 25 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/flexcan-core.c
> index b347a1c93536d54efaa5f7d3347bd47c20860b3e..45d9a6957d9a806ed80d810a6a5f7eb99fcc702c 100644
> --- a/drivers/net/can/flexcan/flexcan-core.c
> +++ b/drivers/net/can/flexcan/flexcan-core.c
> @@ -30,6 +30,7 @@
> #include <linux/property.h>
> #include <linux/regmap.h>
> #include <linux/regulator/consumer.h>
> +#include <linux/phy/phy.h>
>
> #include "flexcan.h"
>
> @@ -644,18 +645,22 @@ static void flexcan_clks_disable(const struct flexcan_priv *priv)
>
> static inline int flexcan_transceiver_enable(const struct flexcan_priv *priv)
> {
> - if (!priv->reg_xceiver)
> - return 0;
> + if (priv->reg_xceiver)
> + return regulator_enable(priv->reg_xceiver);
> + else if (priv->transceiver)
> + return phy_power_on(priv->transceiver);
>
> - return regulator_enable(priv->reg_xceiver);
> + return 0;
> }
>
> static inline int flexcan_transceiver_disable(const struct flexcan_priv *priv)
> {
> - if (!priv->reg_xceiver)
> - return 0;
> + if (priv->reg_xceiver)
> + return regulator_disable(priv->reg_xceiver);
> + else if (priv->transceiver)
> + return phy_power_off(priv->transceiver);
>
> - return regulator_disable(priv->reg_xceiver);
> + return 0;
> }
>
> static int flexcan_chip_enable(struct flexcan_priv *priv)
> @@ -2086,6 +2091,7 @@ static int flexcan_probe(struct platform_device *pdev)
> struct net_device *dev;
> struct flexcan_priv *priv;
> struct regulator *reg_xceiver;
> + struct phy *transceiver;
> struct clk *clk_ipg = NULL, *clk_per = NULL;
> struct flexcan_regs __iomem *regs;
> struct flexcan_platform_data *pdata;
> @@ -2101,6 +2107,14 @@ static int flexcan_probe(struct platform_device *pdev)
> else if (IS_ERR(reg_xceiver))
> return PTR_ERR(reg_xceiver);
>
> + transceiver = devm_phy_optional_get(&pdev->dev, NULL);
> + if (PTR_ERR(transceiver) == -EPROBE_DEFER) {
> + return -EPROBE_DEFER;
> + } else if (IS_ERR(transceiver)) {
> + dev_err(&pdev->dev, "failed to get phy\n");
> + return PTR_ERR(transceiver);
> + }
Please use dev_err_probe(), it will be silent in case of EPROBE_DEFER.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2025-02-20 8:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-20 8:22 [PATCH v2 0/2] can: flexcan: add transceiver capabilities Dimitri Fedrau via B4 Relay
2025-02-20 8:22 ` [PATCH v2 1/2] dt-bindings: can: fsl,flexcan: " Dimitri Fedrau via B4 Relay
2025-02-20 8:44 ` Marc Kleine-Budde
2025-02-20 15:56 ` Dimitri Fedrau
2025-02-20 16:02 ` Marc Kleine-Budde
2025-02-20 17:20 ` Conor Dooley
2025-02-20 8:22 ` [PATCH v2 2/2] can: flexcan: " Dimitri Fedrau via B4 Relay
2025-02-20 8:43 ` Marc Kleine-Budde [this message]
2025-02-20 15:57 ` Dimitri Fedrau
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=20250220-rugged-solid-gopher-541299-mkl@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=devnull+dimitri.fedrau.liebherr.com@kernel.org \
--cc=dima.fedrau@gmail.com \
--cc=dimitri.fedrau@liebherr.com \
--cc=krzk+dt@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mailhol.vincent@wanadoo.fr \
--cc=robh@kernel.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox