From nobody Tue Dec 16 16:03:40 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D89BA155A4E; Wed, 12 Mar 2025 17:45:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741801525; cv=none; b=W49c1sKS1G0lJspLfqFQfxn9CihSWCtZU8qcgkddLD4/gRjyHADxVYEn3uAo7oPz7vuJj/GrUypHDpNCLrUPXPv92IQGiKUVdU6uct1MO+db7sHfq7dCthWf74xaL25BtgmKoRJkoI+8+4jxxKJS9SreTM/GonZrJ0rffYyUpKw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741801525; c=relaxed/simple; bh=lx38Ii4qB/AI3pWRJSXPUS3zXu9HaBtlPizO41uROZw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PlGGtoLuCF8YvPd5O2e2b2vGTht19mC4c8LhgwHcBPiX+AV7EtqVUYqco74/ziCdnKRTzSrCaBsNYEKtjW4n3tGnruy87PQi6P2uIm5SPnNNjVC/BBGH0DlBkfgx64Ch3xPc8MwZt1o2AvedSlFTtdNqffjJzLvR8CJDAXHgnQU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Iwozdm6s; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Iwozdm6s" Received: by smtp.kernel.org (Postfix) with ESMTPS id 5DCC7C4CEEA; Wed, 12 Mar 2025 17:45:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741801524; bh=lx38Ii4qB/AI3pWRJSXPUS3zXu9HaBtlPizO41uROZw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Iwozdm6srOJ2BUI358DChciWMbxghN82umYlbou5N+Xqq85kNwh5DU+3GrSSljTyK 8dLP6GZgpIsDuEXXeTfbrFgma6ALzdU0pUwxvvP5PiuzhDXSwrxd6Z+fzKeJUZ4XDX rz0zLzJ/uiDbdxP/gMqaNDr3NYiVevJETcHPCG4tNSt1r01FKkqbHY5Pwp2XlJnOUS JApqjowHu/tF8bsTwrluvU4N1tUBKjJS9L4k4kJ0HVWgaA9fUUkuwV12OC+x409aqL OfSw/9jecYxjwVJAuCDRch+mlZG40vLRKK3/IeVJJq1pS7kzriwhx8NnvGMoP9sPuD u5rKeA31Zl/Og== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46A16C2BA1B; Wed, 12 Mar 2025 17:45:24 +0000 (UTC) From: Dimitri Fedrau via B4 Relay Date: Wed, 12 Mar 2025 18:45:22 +0100 Subject: [PATCH RESEND v4 1/2] dt-bindings: can: fsl,flexcan: add transceiver capabilities Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250312-flexcan-add-transceiver-caps-v4-1-29e89ae0225a@liebherr.com> References: <20250312-flexcan-add-transceiver-caps-v4-0-29e89ae0225a@liebherr.com> In-Reply-To: <20250312-flexcan-add-transceiver-caps-v4-0-29e89ae0225a@liebherr.com> To: Marc Kleine-Budde , Vincent Mailhol , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-can@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Dimitri Fedrau , Dimitri Fedrau , Conor Dooley X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1741801523; l=1240; i=dimitri.fedrau@liebherr.com; s=20241202; h=from:subject:message-id; bh=62w1D1rpX0pQNS5ptfX/YuY6csaGTzAr13ql41pZT30=; b=w0StHzeG3yjCTmwia2JcPgwssxDl2A9/pZOd9mcssUGPsQmT71i5++o2li3XNgCsEoMFpbyGl QUaOiHGIo0bDx5sb+cmbG7vCQ/KfXCM+iSIQnKJLgFbhodbg6AK9L/9 X-Developer-Key: i=dimitri.fedrau@liebherr.com; a=ed25519; pk=rT653x09JSQvotxIqQl4/XiI4AOiBZrdOGvxDUbb5m8= X-Endpoint-Received: by B4 Relay for dimitri.fedrau@liebherr.com/20241202 with auth_id=290 X-Original-From: Dimitri Fedrau Reply-To: dimitri.fedrau@liebherr.com From: Dimitri Fedrau Currently the flexcan driver does only support adding PHYs by using the "old" regulator bindings. Add support for CAN transceivers as a PHY. Acked-by: Conor Dooley Signed-off-by: Dimitri Fedrau --- Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml b/D= ocumentation/devicetree/bindings/net/can/fsl,flexcan.yaml index 73252fe56fe6c8e9fd19142208bb655dc86d47cd..37e3e4f487629f4df427dd8f711= dc632f8dc5a2a 100644 --- a/Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml +++ b/Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml @@ -77,6 +77,9 @@ properties: xceiver-supply: description: Regulator that powers the CAN transceiver. =20 + phys: + maxItems: 1 + big-endian: $ref: /schemas/types.yaml#/definitions/flag description: | @@ -171,6 +174,12 @@ allOf: interrupts: maxItems: 1 interrupt-names: false + - if: + required: + - xceiver-supply + then: + properties: + phys: false =20 additionalProperties: false =20 --=20 2.39.5 From nobody Tue Dec 16 16:03:40 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D896D200CB; Wed, 12 Mar 2025 17:45:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741801525; cv=none; b=kFT+pwnqIOdqqnusXU26smRy/0bXwPBhJgMGLsW8fB1Ukq9XMUaHX4C3mURf4lbpJsAduHTTuuxaD76PomPHPyUBtauutocR5tZ0wZhemN0K1p4EJxYk8iWMrGcJbdnl7xdPP0rsBsEQETS+xtKXBuBH+8lZUGrYE0G77nxID40= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741801525; c=relaxed/simple; bh=BtOhGRVLO/4z5tXwtnomJn5XJEhbKXaC1bZE6yJRkys=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ntRCkmTa1f/BY2HhbTCey9rJHy9cZiJ3wq4/qkzlbeGK861RvJEdF+d/muapT57V6wjlCwVzhh7hhrIeRKMqMHQgmjw8NB0/rj3G0GEaTlri2juu4dfz9NxbUH2mkt2ycKEKuTsNY0qN8XHlOhdIZzgsTEh41W/MYXkhgZ3GXeY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ntj7boR7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ntj7boR7" Received: by smtp.kernel.org (Postfix) with ESMTPS id 6BEA4C4CEEB; Wed, 12 Mar 2025 17:45:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741801524; bh=BtOhGRVLO/4z5tXwtnomJn5XJEhbKXaC1bZE6yJRkys=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Ntj7boR7aNijqOwkm7tVBWyJ7pTKcmoMJFSX0Vi1De5xsSZzEnbRMujiFSiLoTCug c8ZmN64aTwni4zjkt8rZlgEIq21Ly68tEUXYFy3UuSsmYSMg94brR0uq1oFtci2d3n 290x3XW6k1Wm/deRdL6oLmwavEXB2+zdalC+NdkwTq5tPTumh0yV4v6nCJ9q7s3Yd8 0cAShO2b44hFn8UR0SB0SGIKVXoT89w36CbYSY/1KMkgvHoaEv8GnoLgptMvyWDdIX RM8RiOSvA8/7H5DCO0JYjS8EF/a1U2DD0PJsIRv636736CPi6WH0UmfiJUnSQKiszd oSqEOkRy20bqA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 559A8C35FF1; Wed, 12 Mar 2025 17:45:24 +0000 (UTC) From: Dimitri Fedrau via B4 Relay Date: Wed, 12 Mar 2025 18:45:23 +0100 Subject: [PATCH RESEND v4 2/2] can: flexcan: add transceiver capabilities Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250312-flexcan-add-transceiver-caps-v4-2-29e89ae0225a@liebherr.com> References: <20250312-flexcan-add-transceiver-caps-v4-0-29e89ae0225a@liebherr.com> In-Reply-To: <20250312-flexcan-add-transceiver-caps-v4-0-29e89ae0225a@liebherr.com> To: Marc Kleine-Budde , Vincent Mailhol , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-can@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Dimitri Fedrau , Dimitri Fedrau X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1741801523; l=3555; i=dimitri.fedrau@liebherr.com; s=20241202; h=from:subject:message-id; bh=kSxxiQHxl//wCevFJfiq2EaHcqBYYuWBjHktSM+Fwds=; b=AyaNOZsIKwCr/iDwY2md+sZf0aTIm3EaIUXHX7cY4JKTqFM9nvuYvL0r9TSbYDJSrqWDj64sA /klYUbJb9PwCwOMH+b/ZXl54OvwSn3huH7mu48di2Ugu7AYfH4mqHKY X-Developer-Key: i=dimitri.fedrau@liebherr.com; a=ed25519; pk=rT653x09JSQvotxIqQl4/XiI4AOiBZrdOGvxDUbb5m8= X-Endpoint-Received: by B4 Relay for dimitri.fedrau@liebherr.com/20241202 with auth_id=290 X-Original-From: Dimitri Fedrau Reply-To: dimitri.fedrau@liebherr.com From: Dimitri Fedrau 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 --- drivers/net/can/flexcan/flexcan-core.c | 27 +++++++++++++++++++++------ drivers/net/can/flexcan/flexcan.h | 1 + 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexc= an/flexcan-core.c index b347a1c93536d54efaa5f7d3347bd47c20860b3e..7588cb54a909af065522ddbcb06= cc3acb9669893 100644 --- a/drivers/net/can/flexcan/flexcan-core.c +++ b/drivers/net/can/flexcan/flexcan-core.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -644,18 +645,22 @@ static void flexcan_clks_disable(const struct flexcan= _priv *priv) =20 static inline int flexcan_transceiver_enable(const struct flexcan_priv *pr= iv) { - 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); =20 - return regulator_enable(priv->reg_xceiver); + return 0; } =20 static inline int flexcan_transceiver_disable(const struct flexcan_priv *p= riv) { - 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); =20 - return regulator_disable(priv->reg_xceiver); + return 0; } =20 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 =3D NULL, *clk_per =3D NULL; struct flexcan_regs __iomem *regs; struct flexcan_platform_data *pdata; @@ -2101,6 +2107,11 @@ static int flexcan_probe(struct platform_device *pde= v) else if (IS_ERR(reg_xceiver)) return PTR_ERR(reg_xceiver); =20 + transceiver =3D devm_phy_optional_get(&pdev->dev, NULL); + if (IS_ERR(transceiver)) + return dev_err_probe(&pdev->dev, PTR_ERR(transceiver), + "failed to get phy\n"); + if (pdev->dev.of_node) { of_property_read_u32(pdev->dev.of_node, "clock-frequency", &clock_freq); @@ -2198,6 +2209,10 @@ static int flexcan_probe(struct platform_device *pde= v) priv->clk_per =3D clk_per; priv->clk_src =3D clk_src; priv->reg_xceiver =3D reg_xceiver; + priv->transceiver =3D transceiver; + + if (transceiver) + priv->can.bitrate_max =3D transceiver->attrs.max_link_rate; =20 if (priv->devtype_data.quirks & FLEXCAN_QUIRK_NR_IRQ_3) { priv->irq_boff =3D platform_get_irq(pdev, 1); diff --git a/drivers/net/can/flexcan/flexcan.h b/drivers/net/can/flexcan/fl= excan.h index 2cf886618c9621166173b865f266830b3f6c1fb0..16692a2502eba26575eeeec83df= ffdf35f07b034 100644 --- a/drivers/net/can/flexcan/flexcan.h +++ b/drivers/net/can/flexcan/flexcan.h @@ -107,6 +107,7 @@ struct flexcan_priv { struct clk *clk_per; struct flexcan_devtype_data devtype_data; struct regulator *reg_xceiver; + struct phy *transceiver; struct flexcan_stop_mode stm; =20 int irq_boff; --=20 2.39.5