Skip to contentSkip to conversation

Add Support for MCAN in AM654x-idk

PATCH In review Faiz Abbas 4 participants 13 messages Feb 17, 2020 – Mar 9, 2020

Subsystems (5)
lore
Share & tools
lore

Faiz Abbas

author
#0 lore raw

v2 cover Add Support for MCAN in AM654x-idk

This series adds driver patches to support MCAN in TI's AM654x-idk.

v2: Model the sandby line to the transceiver as a regulator.

Faiz Abbas (3):
dt-bindings: m_can: Add Documentation for transceiver regulator
can: m_can: m_can_platform: Add support for enabling transceiver
arm64: defconfig: Add Support for Bosch M_CAN controllers

 Documentation/devicetree/bindings/net/can/m_can.txt | 3 +++
 arch/arm64/configs/defconfig                        | 3 +++
 drivers/net/can/m_can/m_can_platform.c              | 6 ++++++
 3 files changed, 12 insertions(+)
Signature · 7 lines
2.19.2


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author
#1 lore raw

PATCH v2 1/3 dt-bindings: m_can: Add Documentation for transceiver regulator

Some CAN transceivers have a standby line that needs to be asserted before they can be used. Model this GPIO lines as an optional fixed-regulator node. Document bindings for the same.

---
 Documentation/devicetree/bindings/net/can/m_can.txt | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/net/can/m_can.txt +3 -0
index ed614383af9c..f17e2a5207dc 100644
@@ -48,6 +48,9 @@ Optional Subnode:
 			  that can be used for CAN/CAN-FD modes. See
 			  Documentation/devicetree/bindings/net/can/can-transceiver.txt
 			  for details.
+
+- xceiver-supply: Regulator that powers the CAN transceiver.
+
 Example:
 SoC dtsi:
 m_can1: can@20e8000 {
Signature · 7 lines
2.19.2


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer
#2 lore raw

Re: [PATCH v2 1/3] dt-bindings: m_can: Add Documentation for transceiver regulator

Quoted 8 lines · Faiz Abbas

Some CAN transceivers have a standby line that needs to be asserted before they can be used. Model this GPIO lines as an optional fixed-regulator node. Document bindings for the same.

---
 Documentation/devicetree/bindings/net/can/m_can.txt | 3 +++
 1 file changed, 3 insertions(+)

This has moved to DT schema in my tree, so please adjust it and resend.

Documentation/devicetree/bindings/net/can/m_can.txt Optional Subnode: · line 52

Quoted 10 lines
Documentation/devicetree/bindings/net/can/m_can.txt +2 -0
index ed614383af9c..f17e2a5207dc 100644
@@ -48,6 +48,9 @@ Optional Subnode:
 			  that can be used for CAN/CAN-FD modes. See
 			  Documentation/devicetree/bindings/net/can/can-transceiver.txt
 			  for details.
+
+- xceiver-supply: Regulator that powers the CAN transceiver.

The supply for a transceiver should go in the transceiver node.

Quoted 7 lines
Documentation/devicetree/bindings/net/can/m_can.txt +1 -0
+
 Example:
 SoC dtsi:
 m_can1: can@20e8000 {
Signature · 1 line
2.19.2
author
#3 lore raw

Re: [PATCH v2 1/3] dt-bindings: m_can: Add Documentation for transceiver regulator

Hi Rob,

Quoted 11 lines · Rob Herring
Quoted 8 lines · Faiz Abbas

Some CAN transceivers have a standby line that needs to be asserted before they can be used. Model this GPIO lines as an optional fixed-regulator node. Document bindings for the same.

---
 Documentation/devicetree/bindings/net/can/m_can.txt | 3 +++
 1 file changed, 3 insertions(+)

This has moved to DT schema in my tree, so please adjust it and resend.

Ok.

Quoted 14 lines

Documentation/devicetree/bindings/net/can/m_can.txt Optional Subnode: · line 52

Quoted 11 lines
Documentation/devicetree/bindings/net/can/m_can.txt +2 -0
index ed614383af9c..f17e2a5207dc 100644
@@ -48,6 +48,9 @@ Optional Subnode:
 			  that can be used for CAN/CAN-FD modes. See
 			  Documentation/devicetree/bindings/net/can/can-transceiver.txt
 			  for details.
+
+- xceiver-supply: Regulator that powers the CAN transceiver.

The supply for a transceiver should go in the transceiver node.

Marc, while I have you here, do you agree with this?

Thanks,
Faiz

#4 lore raw

Re: [PATCH v2 1/3] dt-bindings: m_can: Add Documentation for transceiver regulator

Quoted 31 lines · Faiz Abbas

Hi Rob,

Quoted 11 lines · Rob Herring
Quoted 8 lines · Faiz Abbas

Some CAN transceivers have a standby line that needs to be asserted before they can be used. Model this GPIO lines as an optional fixed-regulator node. Document bindings for the same.

---
 Documentation/devicetree/bindings/net/can/m_can.txt | 3 +++
 1 file changed, 3 insertions(+)

This has moved to DT schema in my tree, so please adjust it and resend.

Ok.

Quoted 14 lines

Documentation/devicetree/bindings/net/can/m_can.txt Optional Subnode: · line 52

Quoted 11 lines
Documentation/devicetree/bindings/net/can/m_can.txt +2 -0
index ed614383af9c..f17e2a5207dc 100644
@@ -48,6 +48,9 @@ Optional Subnode:
 			  that can be used for CAN/CAN-FD modes. See
 			  Documentation/devicetree/bindings/net/can/can-transceiver.txt
 			  for details.
+
+- xceiver-supply: Regulator that powers the CAN transceiver.

The supply for a transceiver should go in the transceiver node.

Quoted 1 line

Marc, while I have you here, do you agree with this?

I'll look into the details later today.

Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
author
#5 lore raw

Re: [PATCH v2 1/3] dt-bindings: m_can: Add Documentation for transceiver regulator

Hi Marc,

Quoted 32 lines · Marc Kleine-Budde
Quoted 31 lines · Faiz Abbas

Hi Rob,

Quoted 11 lines · Rob Herring
Quoted 8 lines · Faiz Abbas

Some CAN transceivers have a standby line that needs to be asserted before they can be used. Model this GPIO lines as an optional fixed-regulator node. Document bindings for the same.

---
 Documentation/devicetree/bindings/net/can/m_can.txt | 3 +++
 1 file changed, 3 insertions(+)

This has moved to DT schema in my tree, so please adjust it and resend.

Ok.

Quoted 14 lines

Documentation/devicetree/bindings/net/can/m_can.txt Optional Subnode: · line 52

Quoted 11 lines
Documentation/devicetree/bindings/net/can/m_can.txt +2 -0
index ed614383af9c..f17e2a5207dc 100644
@@ -48,6 +48,9 @@ Optional Subnode:
 			  that can be used for CAN/CAN-FD modes. See
 			  Documentation/devicetree/bindings/net/can/can-transceiver.txt
 			  for details.
+
+- xceiver-supply: Regulator that powers the CAN transceiver.

The supply for a transceiver should go in the transceiver node.

Quoted 4 lines
Quoted 1 line

Marc, while I have you here, do you agree with this?

I'll look into the details later today.

Sure. Be sure to take another look at my attempt to use the transceiver with a phy driver some time ago.

https://lore.kernel.org/patchwork/patch/1006238/

Thanks,
Faiz

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#6 lore raw

Re: [PATCH v2 1/3] dt-bindings: m_can: Add Documentation for transceiver regulator

Marc,

Quoted 37 lines · Faiz Abbas

Hi Marc,

Quoted 34 lines · Marc Kleine-Budde
Quoted 32 lines · Faiz Abbas

Hi Rob,

Quoted 11 lines · Rob Herring
Quoted 8 lines · Faiz Abbas

Some CAN transceivers have a standby line that needs to be asserted before they can be used. Model this GPIO lines as an optional fixed-regulator node. Document bindings for the same.

---
 Documentation/devicetree/bindings/net/can/m_can.txt | 3 +++
 1 file changed, 3 insertions(+)

This has moved to DT schema in my tree, so please adjust it and resend.

Ok.

Quoted 14 lines

Documentation/devicetree/bindings/net/can/m_can.txt Optional Subnode: · line 52

Quoted 11 lines
Documentation/devicetree/bindings/net/can/m_can.txt +2 -0
index ed614383af9c..f17e2a5207dc 100644
@@ -48,6 +48,9 @@ Optional Subnode:
 			  that can be used for CAN/CAN-FD modes. See
 			  Documentation/devicetree/bindings/net/can/can-transceiver.txt
 			  for details.
+
+- xceiver-supply: Regulator that powers the CAN transceiver.

The supply for a transceiver should go in the transceiver node.

Marc, while I have you here, do you agree with this?

Quoted 8 lines
Quoted 2 lines

I'll look into the details later today.

Sure. Be sure to take another look at my attempt to use the transceiver with a phy driver some time ago.

https://lore.kernel.org/patchwork/patch/1006238/

Do you have any comments?

Thanks,
Faiz

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#7 lore raw

Re: [PATCH v2 1/3] dt-bindings: m_can: Add Documentation for transceiver regulator

Hi Marc,

Quoted 43 lines · Faiz Abbas

Marc,

Quoted 40 lines · Faiz Abbas

Hi Marc,

Quoted 36 lines · Marc Kleine-Budde
Quoted 31 lines · Faiz Abbas

Hi Rob,

Quoted 11 lines · Rob Herring
Quoted 8 lines · Faiz Abbas

Some CAN transceivers have a standby line that needs to be asserted before they can be used. Model this GPIO lines as an optional fixed-regulator node. Document bindings for the same.

---
 Documentation/devicetree/bindings/net/can/m_can.txt | 3 +++
 1 file changed, 3 insertions(+)

This has moved to DT schema in my tree, so please adjust it and resend.

Ok.

Quoted 14 lines

Documentation/devicetree/bindings/net/can/m_can.txt Optional Subnode: · line 52

Quoted 11 lines
Documentation/devicetree/bindings/net/can/m_can.txt +2 -0
index ed614383af9c..f17e2a5207dc 100644
@@ -48,6 +48,9 @@ Optional Subnode:
 			  that can be used for CAN/CAN-FD modes. See
 			  Documentation/devicetree/bindings/net/can/can-transceiver.txt
 			  for details.
+
+- xceiver-supply: Regulator that powers the CAN transceiver.

The supply for a transceiver should go in the transceiver node.

Quoted 1 line

Marc, while I have you here, do you agree with this?

I'll look into the details later today.

Quoted 8 lines
Quoted 5 lines

Sure. Be sure to take another look at my attempt to use the transceiver with a phy driver some time ago.

https://lore.kernel.org/patchwork/patch/1006238/

Do you have any comments?

Gentle ping.

Thanks,
Faiz

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#8 lore raw

PATCH v2 2/3 can: m_can: m_can_platform: Add support for enabling transceiver

In reply to Faiz Abbas

CAN transceivers on some boards have a standby line which can be toggled to enable/disable the transceiver. Model this as an optional fixed xceiver regulator.

---
 drivers/net/can/m_can/m_can_platform.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/net/can/m_can/m_can_platform.c +6 -0
index 38ea5e600fb8..719468fab507 100644
@@ -6,6 +6,7 @@
 // Copyright (C) 2018-19 Texas Instruments Incorporated - http://www.ti.com/
 
 #include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
 
 #include "m_can.h"
 
@@ -57,6 +58,7 @@ static int m_can_plat_probe(struct platform_device *pdev)
 {
 	struct m_can_classdev *mcan_class;
 	struct m_can_plat_priv *priv;
+	struct regulator *reg_xceiver;
 	struct resource *res;
 	void __iomem *addr;
 	void __iomem *mram_addr;
@@ -111,6 +113,10 @@ static int m_can_plat_probe(struct platform_device *pdev)
 
 	m_can_init_ram(mcan_class);
 
+	reg_xceiver = devm_regulator_get_optional(&pdev->dev, "xceiver");
+	if (PTR_ERR(reg_xceiver) == -EPROBE_DEFER)
+		return -EPROBE_DEFER;
+
 	ret = m_can_class_register(mcan_class);
 
 failed_ret:
Signature · 1 line
2.19.2
#9 lore raw

Re: [PATCH v2 2/3] can: m_can: m_can_platform: Add support for enabling transceiver

Faiz

Quoted 31 lines · Faiz Abbas

CAN transceivers on some boards have a standby line which can be toggled to enable/disable the transceiver. Model this as an optional fixed xceiver regulator.

---
  drivers/net/can/m_can/m_can_platform.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/net/can/m_can/m_can_platform.c +2 -0
index 38ea5e600fb8..719468fab507 100644
@@ -6,6 +6,7 @@
  // Copyright (C) 2018-19 Texas Instruments Incorporated - http://www.ti.com/
 
  #include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
 
  #include "m_can.h"
 
@@ -57,6 +58,7 @@ static int m_can_plat_probe(struct platform_device *pdev)
  {
  	struct m_can_classdev *mcan_class;
  	struct m_can_plat_priv *priv;
+	struct regulator *reg_xceiver;
  	struct resource *res;
  	void __iomem *addr;
  	void __iomem *mram_addr;

drivers/net/can/m_can/m_can_platform.c static int m_can_plat_probe(struct platform_device *pdev) · line 119

Quoted 7 lines
drivers/net/can/m_can/m_can_platform.c +4 -0
@@ -111,6 +113,10 @@ static int m_can_plat_probe(struct platform_device *pdev)
 
  	m_can_init_ram(mcan_class);
 
+	reg_xceiver = devm_regulator_get_optional(&pdev->dev, "xceiver");
+	if (PTR_ERR(reg_xceiver) == -EPROBE_DEFER)
+		return -EPROBE_DEFER;
+

Where is this regulator enabled?

Shouldn't the regulator be managed by runtime PM as well?

Dan

author
#10 lore raw

Re: [PATCH v2 2/3] can: m_can: m_can_platform: Add support for enabling transceiver

Hi Dan,

Quoted 34 lines · Dan Murphy

Faiz

Quoted 31 lines · Faiz Abbas

CAN transceivers on some boards have a standby line which can be toggled to enable/disable the transceiver. Model this as an optional fixed xceiver regulator.

---
  drivers/net/can/m_can/m_can_platform.c | 6 ++++++

  1 file changed, 6 insertions(+)
drivers/net/can/m_can/m_can_platform.c +0 -0
index 38ea5e600fb8..719468fab507 100644
@@ -6,6 +6,7 @@
   // Copyright (C) 2018-19 Texas Instruments Incorporated -

http://www.ti.com/
    #include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
    #include "m_can.h"
  @@ -57,6 +58,7 @@ static int m_can_plat_probe(struct platform_device *pdev)
  {
      struct m_can_classdev *mcan_class;
      struct m_can_plat_priv *priv;
+    struct regulator *reg_xceiver;
      struct resource *res;
      void __iomem *addr;
      void __iomem *mram_addr;

drivers/net/can/m_can/m_can_platform.c +0 -0
@@ -111,6 +113,10 @@ static int m_can_plat_probe(struct
Quoted 8 lines

drivers/net/can/m_can/m_can_platform.c static int m_can_plat_probe(struct platform_device *pdev) · line 119

Quoted 6 lines
drivers/net/can/m_can/m_can_platform.c +3 -0
 platform_device *pdev)
         m_can_init_ram(mcan_class);
   +    reg_xceiver = devm_regulator_get_optional(&pdev->dev, "xceiver");
+    if (PTR_ERR(reg_xceiver) == -EPROBE_DEFER)
+        return -EPROBE_DEFER;
+

Where is this regulator enabled?

I have set regulator-boot-on flag in the dt so this didn't require an enable.

Quoted 2 lines

Shouldn't the regulator be managed by runtime PM as well?

Let me try this out.

Thanks,
Faiz

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#11 lore raw

Re: [PATCH v2 2/3] can: m_can: m_can_platform: Add support for enabling transceiver

Quoted 46 lines · Faiz Abbas

Hi Dan,

Quoted 34 lines · Dan Murphy

Faiz

Quoted 31 lines · Faiz Abbas

CAN transceivers on some boards have a standby line which can be toggled to enable/disable the transceiver. Model this as an optional fixed xceiver regulator.

---
  drivers/net/can/m_can/m_can_platform.c | 6 ++++++

  1 file changed, 6 insertions(+)
drivers/net/can/m_can/m_can_platform.c +0 -0
index 38ea5e600fb8..719468fab507 100644
@@ -6,6 +6,7 @@
   // Copyright (C) 2018-19 Texas Instruments Incorporated -

http://www.ti.com/
    #include <linux/platform_device.h>
+#include <linux/regulator/consumer.h>
    #include "m_can.h"
  @@ -57,6 +58,7 @@ static int m_can_plat_probe(struct platform_device *pdev)
  {
      struct m_can_classdev *mcan_class;
      struct m_can_plat_priv *priv;
+    struct regulator *reg_xceiver;
      struct resource *res;
      void __iomem *addr;
      void __iomem *mram_addr;

drivers/net/can/m_can/m_can_platform.c +0 -0
@@ -111,6 +113,10 @@ static int m_can_plat_probe(struct
Quoted 8 lines

drivers/net/can/m_can/m_can_platform.c static int m_can_plat_probe(struct platform_device *pdev) · line 119

Quoted 6 lines
drivers/net/can/m_can/m_can_platform.c +3 -0
 platform_device *pdev)
         m_can_init_ram(mcan_class);
   +    reg_xceiver = devm_regulator_get_optional(&pdev->dev, "xceiver");
+    if (PTR_ERR(reg_xceiver) == -EPROBE_DEFER)
+        return -EPROBE_DEFER;
+

Where is this regulator enabled?

Quoted 2 lines

I have set regulator-boot-on flag in the dt so this didn't require an enable.

Please don't do this, please handle it properly.

Quoted 1 line
Quoted 1 line

Shouldn't the regulator be managed by runtime PM as well?

If so, then make the runtime pm kconfig option mandatory.

Marc

Signature · 9 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author
#12 lore raw

PATCH v2 3/3 arm64: defconfig: Add Support for Bosch M_CAN controllers

In reply to Faiz Abbas

Enable configs for supporting Bosch M_CAN controllers.

---
 arch/arm64/configs/defconfig | 3 +++
 1 file changed, 3 insertions(+)
arch/arm64/configs/defconfig +3 -0
index 905109f6814f..b25bbcf691b6 100644
@@ -161,6 +161,9 @@ CONFIG_QRTR=m
 CONFIG_QRTR_SMD=m
 CONFIG_QRTR_TUN=m
 CONFIG_BPF_JIT=y
+CONFIG_CAN=m
+CONFIG_CAN_M_CAN=m
+CONFIG_CAN_M_CAN_PLATFORM=m
 CONFIG_BT=m
 CONFIG_BT_HIDP=m
 # CONFIG_BT_HS is not set
Signature · 1 line
2.19.2