netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/4] pull-request: can-next 2025-03-14
@ 2025-03-14 13:19 Marc Kleine-Budde
  2025-03-14 13:19 ` [PATCH net-next 1/4] dt-bindings: can: fsl,flexcan: add transceiver capabilities Marc Kleine-Budde
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Marc Kleine-Budde @ 2025-03-14 13:19 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel

Hello netdev-team,

this is a pull request of 4 patches for net-next/main.

In the first 2 patches by Dimitri Fedrau add CAN transceiver support
to the flexcan driver.

Frank Li's patch adds i.MX94 support to the flexcan device tree
bindings.

The last patch is by Davide Caratti and adds protocol counter for
AF_CAN sockets.

regards,
Marc

---
The following changes since commit 941defcea7e11ad7ff8f0d4856716dd637d757dd:

  Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net (2025-03-13 23:08:11 +0100)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git tags/linux-can-next-for-6.15-20250314

for you to fetch changes up to 6bffe88452dbe284747442f10a7ac8249d6495d7:

  can: add protocol counter for AF_CAN sockets (2025-03-14 13:27:33 +0100)

----------------------------------------------------------------
linux-can-next-for-6.15-20250314

----------------------------------------------------------------
Davide Caratti (1):
      can: add protocol counter for AF_CAN sockets

Dimitri Fedrau (2):
      dt-bindings: can: fsl,flexcan: add transceiver capabilities
      can: flexcan: add transceiver capabilities

Frank Li (1):
      dt-bindings: can: fsl,flexcan: add i.MX94 support

Marc Kleine-Budde (1):
      Merge patch series "can: flexcan: add transceiver capabilities"

 .../devicetree/bindings/net/can/fsl,flexcan.yaml   | 13 +++++++++++
 drivers/net/can/flexcan/flexcan-core.c             | 27 +++++++++++++++++-----
 drivers/net/can/flexcan/flexcan.h                  |  1 +
 net/can/af_can.c                                   |  2 ++
 net/can/bcm.c                                      |  1 +
 net/can/isotp.c                                    |  1 +
 net/can/raw.c                                      |  5 +++-
 7 files changed, 43 insertions(+), 7 deletions(-)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net-next 1/4] dt-bindings: can: fsl,flexcan: add transceiver capabilities
  2025-03-14 13:19 [PATCH net-next 0/4] pull-request: can-next 2025-03-14 Marc Kleine-Budde
@ 2025-03-14 13:19 ` Marc Kleine-Budde
  2025-03-18 12:00   ` patchwork-bot+netdevbpf
  2025-03-14 13:19 ` [PATCH net-next 2/4] can: flexcan: " Marc Kleine-Budde
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Marc Kleine-Budde @ 2025-03-14 13:19 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Dimitri Fedrau, Conor Dooley,
	Marc Kleine-Budde

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.

Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
Link: https://patch.msgid.link/20250312-flexcan-add-transceiver-caps-v4-1-29e89ae0225a@liebherr.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 .../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/Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml
index 73252fe56fe6..37e3e4f48762 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.
 
+  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
 
 additionalProperties: false
 

base-commit: 941defcea7e11ad7ff8f0d4856716dd637d757dd
-- 
2.47.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 2/4] can: flexcan: add transceiver capabilities
  2025-03-14 13:19 [PATCH net-next 0/4] pull-request: can-next 2025-03-14 Marc Kleine-Budde
  2025-03-14 13:19 ` [PATCH net-next 1/4] dt-bindings: can: fsl,flexcan: add transceiver capabilities Marc Kleine-Budde
@ 2025-03-14 13:19 ` Marc Kleine-Budde
  2025-03-14 13:19 ` [PATCH net-next 3/4] dt-bindings: can: fsl,flexcan: add i.MX94 support Marc Kleine-Budde
  2025-03-14 13:19 ` [PATCH net-next 4/4] can: add protocol counter for AF_CAN sockets Marc Kleine-Budde
  3 siblings, 0 replies; 6+ messages in thread
From: Marc Kleine-Budde @ 2025-03-14 13:19 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel, Dimitri Fedrau, Marc Kleine-Budde

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>
Link: https://patch.msgid.link/20250312-flexcan-add-transceiver-caps-v4-2-29e89ae0225a@liebherr.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 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/flexcan/flexcan-core.c
index b347a1c93536..7588cb54a909 100644
--- a/drivers/net/can/flexcan/flexcan-core.c
+++ b/drivers/net/can/flexcan/flexcan-core.c
@@ -26,6 +26,7 @@
 #include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/can/platform/flexcan.h>
+#include <linux/phy/phy.h>
 #include <linux/pm_runtime.h>
 #include <linux/property.h>
 #include <linux/regmap.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,11 @@ 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 (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 *pdev)
 	priv->clk_per = clk_per;
 	priv->clk_src = clk_src;
 	priv->reg_xceiver = reg_xceiver;
+	priv->transceiver = transceiver;
+
+	if (transceiver)
+		priv->can.bitrate_max = transceiver->attrs.max_link_rate;
 
 	if (priv->devtype_data.quirks & FLEXCAN_QUIRK_NR_IRQ_3) {
 		priv->irq_boff = platform_get_irq(pdev, 1);
diff --git a/drivers/net/can/flexcan/flexcan.h b/drivers/net/can/flexcan/flexcan.h
index 2cf886618c96..16692a2502eb 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;
 
 	int irq_boff;
-- 
2.47.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 3/4] dt-bindings: can: fsl,flexcan: add i.MX94 support
  2025-03-14 13:19 [PATCH net-next 0/4] pull-request: can-next 2025-03-14 Marc Kleine-Budde
  2025-03-14 13:19 ` [PATCH net-next 1/4] dt-bindings: can: fsl,flexcan: add transceiver capabilities Marc Kleine-Budde
  2025-03-14 13:19 ` [PATCH net-next 2/4] can: flexcan: " Marc Kleine-Budde
@ 2025-03-14 13:19 ` Marc Kleine-Budde
  2025-03-14 13:19 ` [PATCH net-next 4/4] can: add protocol counter for AF_CAN sockets Marc Kleine-Budde
  3 siblings, 0 replies; 6+ messages in thread
From: Marc Kleine-Budde @ 2025-03-14 13:19 UTC (permalink / raw)
  To: netdev
  Cc: davem, kuba, linux-can, kernel, Frank Li, Conor Dooley,
	Marc Kleine-Budde

From: Frank Li <Frank.Li@nxp.com>

Add compatible string "fsl,imx94-flexcan" for the i.MX94 chip, which
is backward compatible with i.MX95. Set it to fall back to
"fsl,imx95-flexcan".

Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20250307190816.2971810-1-Frank.Li@nxp.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml b/Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml
index 37e3e4f48762..f81d56f7c12a 100644
--- a/Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml
+++ b/Documentation/devicetree/bindings/net/can/fsl,flexcan.yaml
@@ -45,6 +45,10 @@ properties:
           - enum:
               - nxp,s32g3-flexcan
           - const: nxp,s32g2-flexcan
+      - items:
+          - enum:
+              - fsl,imx94-flexcan
+          - const: fsl,imx95-flexcan
 
   reg:
     maxItems: 1
-- 
2.47.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 4/4] can: add protocol counter for AF_CAN sockets
  2025-03-14 13:19 [PATCH net-next 0/4] pull-request: can-next 2025-03-14 Marc Kleine-Budde
                   ` (2 preceding siblings ...)
  2025-03-14 13:19 ` [PATCH net-next 3/4] dt-bindings: can: fsl,flexcan: add i.MX94 support Marc Kleine-Budde
@ 2025-03-14 13:19 ` Marc Kleine-Budde
  3 siblings, 0 replies; 6+ messages in thread
From: Marc Kleine-Budde @ 2025-03-14 13:19 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, linux-can, kernel, Davide Caratti, Marc Kleine-Budde

From: Davide Caratti <dcaratti@redhat.com>

The third column in the output of the following command:

| # grep CAN /proc/net/protocols

is systematically '0': use sock_prot_inuse_add() to account for the number
of sockets for each protocol on top of AF_CAN family.

Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Link: https://patch.msgid.link/9db5d0e6c11b232ad895885616f1258882a32f61.1741952160.git.dcaratti@redhat.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 net/can/af_can.c | 2 ++
 net/can/bcm.c    | 1 +
 net/can/isotp.c  | 1 +
 net/can/raw.c    | 5 ++++-
 4 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/net/can/af_can.c b/net/can/af_can.c
index 01f3fbb3b67d..7b191dbe3693 100644
--- a/net/can/af_can.c
+++ b/net/can/af_can.c
@@ -172,6 +172,8 @@ static int can_create(struct net *net, struct socket *sock, int protocol,
 		sock_orphan(sk);
 		sock_put(sk);
 		sock->sk = NULL;
+	} else {
+		sock_prot_inuse_add(net, sk->sk_prot, 1);
 	}
 
  errout:
diff --git a/net/can/bcm.c b/net/can/bcm.c
index 217049fa496e..6dc041e054ba 100644
--- a/net/can/bcm.c
+++ b/net/can/bcm.c
@@ -1625,6 +1625,7 @@ static int bcm_release(struct socket *sock)
 	sock->sk = NULL;
 
 	release_sock(sk);
+	sock_prot_inuse_add(net, sk->sk_prot, -1);
 	sock_put(sk);
 
 	return 0;
diff --git a/net/can/isotp.c b/net/can/isotp.c
index 16046931542a..789583c62f98 100644
--- a/net/can/isotp.c
+++ b/net/can/isotp.c
@@ -1239,6 +1239,7 @@ static int isotp_release(struct socket *sock)
 	sock->sk = NULL;
 
 	release_sock(sk);
+	sock_prot_inuse_add(net, sk->sk_prot, -1);
 	sock_put(sk);
 
 	return 0;
diff --git a/net/can/raw.c b/net/can/raw.c
index 9b1d5f036f57..020f21430b1d 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -397,11 +397,13 @@ static int raw_release(struct socket *sock)
 {
 	struct sock *sk = sock->sk;
 	struct raw_sock *ro;
+	struct net *net;
 
 	if (!sk)
 		return 0;
 
 	ro = raw_sk(sk);
+	net = sock_net(sk);
 
 	spin_lock(&raw_notifier_lock);
 	while (raw_busy_notifier == ro) {
@@ -421,7 +423,7 @@ static int raw_release(struct socket *sock)
 			raw_disable_allfilters(dev_net(ro->dev), ro->dev, sk);
 			netdev_put(ro->dev, &ro->dev_tracker);
 		} else {
-			raw_disable_allfilters(sock_net(sk), NULL, sk);
+			raw_disable_allfilters(net, NULL, sk);
 		}
 	}
 
@@ -440,6 +442,7 @@ static int raw_release(struct socket *sock)
 	release_sock(sk);
 	rtnl_unlock();
 
+	sock_prot_inuse_add(net, sk->sk_prot, -1);
 	sock_put(sk);
 
 	return 0;
-- 
2.47.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 1/4] dt-bindings: can: fsl,flexcan: add transceiver capabilities
  2025-03-14 13:19 ` [PATCH net-next 1/4] dt-bindings: can: fsl,flexcan: add transceiver capabilities Marc Kleine-Budde
@ 2025-03-18 12:00   ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-03-18 12:00 UTC (permalink / raw)
  To: Marc Kleine-Budde
  Cc: netdev, davem, kuba, linux-can, kernel, dimitri.fedrau,
	conor.dooley

Hello:

This series was applied to netdev/net-next.git (main)
by Marc Kleine-Budde <mkl@pengutronix.de>:

On Fri, 14 Mar 2025 14:19:15 +0100 you 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.
> 
> Acked-by: Conor Dooley <conor.dooley@microchip.com>
> Signed-off-by: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
> Link: https://patch.msgid.link/20250312-flexcan-add-transceiver-caps-v4-1-29e89ae0225a@liebherr.com
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> 
> [...]

Here is the summary with links:
  - [net-next,1/4] dt-bindings: can: fsl,flexcan: add transceiver capabilities
    https://git.kernel.org/netdev/net-next/c/6263bad801ec
  - [net-next,2/4] can: flexcan: add transceiver capabilities
    https://git.kernel.org/netdev/net-next/c/d80bfde3c57a
  - [net-next,3/4] dt-bindings: can: fsl,flexcan: add i.MX94 support
    https://git.kernel.org/netdev/net-next/c/958ee3d71577
  - [net-next,4/4] can: add protocol counter for AF_CAN sockets
    https://git.kernel.org/netdev/net-next/c/6bffe88452db

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-03-18 12:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-14 13:19 [PATCH net-next 0/4] pull-request: can-next 2025-03-14 Marc Kleine-Budde
2025-03-14 13:19 ` [PATCH net-next 1/4] dt-bindings: can: fsl,flexcan: add transceiver capabilities Marc Kleine-Budde
2025-03-18 12:00   ` patchwork-bot+netdevbpf
2025-03-14 13:19 ` [PATCH net-next 2/4] can: flexcan: " Marc Kleine-Budde
2025-03-14 13:19 ` [PATCH net-next 3/4] dt-bindings: can: fsl,flexcan: add i.MX94 support Marc Kleine-Budde
2025-03-14 13:19 ` [PATCH net-next 4/4] can: add protocol counter for AF_CAN sockets Marc Kleine-Budde

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).