Skip to contentSkip to conversation

Add DT support to C_CAN/D_CAN controller

PATCH Superseded AnilKumar Ch 4 participants 7 messages Jul 25, 2012 – Aug 2, 2012 4 messages not in the archive

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add DT support to C_CAN/D_CAN controller

This patch series adds the device tree support to C_CAN/D_CAN controller with pinmux configuration and device tree data addition to corresponding dts and dtsi files.

Also adds Runtime PM support to C_CAN/D_CAN controller.

These patches have been tested on AM335x EVM using some additional patches to add device tree data to EVM dts files and to initialize D_CAN RAM. D_CAN raminit is controlled from control module register. This patch will be submitted once control module MFD driver support is added to mainline.

Due to lack of hardware I am not able to test c_can functionality. I appreciate if anyone can test c_can functionality with this patch series.

First and last patches applies on top of linux-next tree, 2nd and 3rd patches applies on linux-omap tree.

Changes from v1:
- Separated 4 patches into CAN driver specific and device tree data addition specific.
- Incorporated Marc's comments on v1
* Modified c_can_dev_id enum to handle both devtype and platform device id index.
* Removed "legacy bosch,c_can_platform" from DT bindings

AnilKumar Ch (2):
can: c_can: Add device tree support to Bosch C_CAN/D_CAN controller
can: c_can: Add runtime PM support to Bosch C_CAN/D_CAN controller

 .../devicetree/bindings/net/can/c_can.txt          |   37 +++++++++++
 drivers/net/can/c_can/c_can.h                      |    5 +-
 drivers/net/can/c_can/c_can_platform.c             |   65 +++++++++++++++-----
 3 files changed, 88 insertions(+), 19 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/can/c_can.txt
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v2 1/2 can: c_can: Add device tree support to Bosch C_CAN/D_CAN controller

In reply to a message not in the archive

Add device tree support to C_CAN/D_CAN controller and usage details are added to device tree documentation. Driver was tested on AM335x EVM.

---
 .../devicetree/bindings/net/can/c_can.txt          |   37 +++++++++++++
 drivers/net/can/c_can/c_can.h                      |    5 +-
 drivers/net/can/c_can/c_can_platform.c             |   57 ++++++++++++++------
 3 files changed, 80 insertions(+), 19 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/can/c_can.txt
Documentation/devicetree/bindings/net/can/c_can.txt new file +37 -0
new file mode 100644
index 0000000..dc4aec5
@@ -0,0 +1,37 @@
+Bosch C_CAN/D_CAN controller Device Tree Bindings
+-------------------------------------------------
+
+Required properties:
+- compatible		: Should be "bosch,c_can" for C_CAN controllers and
+			  "bosch,d_can" for D_CAN controllers.
+- reg			: physical base address and size of the C_CAN/D_CAN
+			  registers map
+- interrupts		: property with a value describing the interrupt
+			  number
+- interrupt-parent	: The parent interrupt controller
+
+Optional properties:
+- ti,hwmods		: Must be "d_can<n>" or "c_can<n>", n being the
+			  instance number
+
+Note: "ti,hwmods" field is used to fetch the base address and irq
+resources from TI, omap hwmod data base during device registration.
+Future plan is to migrate hwmod data base contents into device tree
+blob so that, all the required data will be used from device tree dts
+file.
+
+Examples:
+
+	d_can@481D0000 {
+		compatible = "bosch,d_can";
+		reg = <0x481D0000 0x1000>;
+		interrupts = <55 0x4>;
+		interrupt-parent = <&intc>;
+	};
+
+(or)
+
+	d_can@481D0000 {
+		compatible = "bosch,d_can";
+		ti,hwmods = "d_can1";
+	};
drivers/net/can/c_can/c_can.h +3 -2
index 01a7049..4e56baa 100644
@@ -143,8 +143,9 @@ static const u16 reg_map_d_can[] = {
 };
 
 enum c_can_dev_id {
-	C_CAN_DEVTYPE,
-	D_CAN_DEVTYPE,
+	BOSCH_C_CAN_PLATFORM,
+	BOSCH_C_CAN,
+	BOSCH_D_CAN,
 };
 
 /* c_can private data structure */
drivers/net/can/c_can/c_can_platform.c +40 -17

103 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#10 lore raw

PATCH RESEND v2 2/2 can: c_can: Add runtime PM support to Bosch C_CAN/D_CAN controller

In reply to AnilKumar Ch

Add Runtime PM support to C_CAN/D_CAN controller. The runtime PM APIs control clocks for C_CAN/D_CAN IP and prevent access to the register of C_CAN/D_CAN IP when clock is turned off.

---
 drivers/net/can/c_can/c_can_platform.c |    8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/can/c_can/c_can_platform.c +8 -0
index d0a66cf..83a1e17 100644
@@ -32,6 +32,7 @@
 #include <linux/clk.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/pm_runtime.h>
 
 #include <linux/can/dev.h>
 
@@ -177,6 +178,9 @@ static int __devinit c_can_plat_probe(struct platform_device *pdev)
 		goto exit_free_device;
 	}
 
+	pm_runtime_enable(&pdev->dev);
+	pm_runtime_get_sync(&pdev->dev);
+
 	dev->irq = irq;
 	priv->base = addr;
 	priv->can.clock.freq = clk_get_rate(clk);
@@ -198,6 +202,8 @@ static int __devinit c_can_plat_probe(struct platform_device *pdev)
 
 exit_free_device:
 	platform_set_drvdata(pdev, NULL);
+	pm_runtime_put_sync(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
 	free_c_can_dev(dev);
 exit_iounmap:
 	iounmap(addr);
@@ -226,6 +232,8 @@ static int __devexit c_can_plat_remove(struct platform_device *pdev)
 	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	release_mem_region(mem->start, resource_size(mem));
 
+	pm_runtime_put_sync(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
 	clk_put(priv->priv);
 
 	return 0;
Signature · 1 line
1.7.9.5
#3 lore raw

Re: [PATCH v2 1/2] can: c_can: Add device tree support to Bosch C_CAN/D_CAN controller

In reply to AnilKumar Ch
Quoted 3 lines · AnilKumar Ch

Add device tree support to C_CAN/D_CAN controller and usage details are added to device tree documentation. Driver was tested on AM335x EVM.

Does not apply to linux-can-next, as Viresh Kumar's patch "net/c_can:
remove conditional compilation of clk code" is not yet included. I suggest to delay this patch until we have Viresh's patch in net-next.

See comment inline.

Quoted 56 lines
---
 .../devicetree/bindings/net/can/c_can.txt          |   37 +++++++++++++
 drivers/net/can/c_can/c_can.h                      |    5 +-
 drivers/net/can/c_can/c_can_platform.c             |   57 ++++++++++++++------
 3 files changed, 80 insertions(+), 19 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/can/c_can.txt
Documentation/devicetree/bindings/net/can/c_can.txt new file +37 -0
new file mode 100644
index 0000000..dc4aec5
@@ -0,0 +1,37 @@
+Bosch C_CAN/D_CAN controller Device Tree Bindings
+-------------------------------------------------
+
+Required properties:
+- compatible		: Should be "bosch,c_can" for C_CAN controllers and
+			  "bosch,d_can" for D_CAN controllers.
+- reg			: physical base address and size of the C_CAN/D_CAN
+			  registers map
+- interrupts		: property with a value describing the interrupt
+			  number
+- interrupt-parent	: The parent interrupt controller
+
+Optional properties:
+- ti,hwmods		: Must be "d_can<n>" or "c_can<n>", n being the
+			  instance number
+
+Note: "ti,hwmods" field is used to fetch the base address and irq
+resources from TI, omap hwmod data base during device registration.
+Future plan is to migrate hwmod data base contents into device tree
+blob so that, all the required data will be used from device tree dts
+file.
+
+Examples:
+
+	d_can@481D0000 {
+		compatible = "bosch,d_can";
+		reg = <0x481D0000 0x1000>;
+		interrupts = <55 0x4>;
+		interrupt-parent = <&intc>;
+	};
+
+(or)
+
+	d_can@481D0000 {
+		compatible = "bosch,d_can";
+		ti,hwmods = "d_can1";
+	};
drivers/net/can/c_can/c_can.h +0 -0
index 01a7049..4e56baa 100644

drivers/net/can/c_can/c_can.h static const u16 reg_map_d_can[] = { · line 148

Quoted 8 lines
drivers/net/can/c_can/c_can.h +3 -2
@@ -143,8 +143,9 @@ static const u16 reg_map_d_can[] = {
 };
 
 enum c_can_dev_id {
-	C_CAN_DEVTYPE,
-	D_CAN_DEVTYPE,
+	BOSCH_C_CAN_PLATFORM,
+	BOSCH_C_CAN,
+	BOSCH_D_CAN,

Note: these symbols are used in "drivers/net/can/c_can/c_can_pci.c", too.

Marc

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

RE: [PATCH v2 1/2] can: c_can: Add device tree support to Bosch C_CAN/D_CAN controller

In reply to a message not in the archive

Marc,

Quoted 10 lines · Marc Kleine-Budde
Quoted 3 lines · AnilKumar Ch

Add device tree support to C_CAN/D_CAN controller and usage details are added to device tree documentation. Driver was tested on AM335x EVM.

Does not apply to linux-can-next, as Viresh Kumar's patch "net/c_can:
remove conditional compilation of clk code" is not yet included. I suggest to delay this patch until we have Viresh's patch in net-next.

See comment inline.

Ok, I will wait till net-next is updated with Viresh Kumar's patch.

Quoted 59 lines
Quoted 59 lines
---
 .../devicetree/bindings/net/can/c_can.txt          |   37 +++++++++++++
 drivers/net/can/c_can/c_can.h                      |    5 +-
 drivers/net/can/c_can/c_can_platform.c             |   57 ++++++++++++++------
 3 files changed, 80 insertions(+), 19 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/can/c_can.txt
Documentation/devicetree/bindings/net/can/c_can.txt new file +37 -0
new file mode 100644
index 0000000..dc4aec5
@@ -0,0 +1,37 @@
+Bosch C_CAN/D_CAN controller Device Tree Bindings
+-------------------------------------------------
+
+Required properties:
+- compatible		: Should be "bosch,c_can" for C_CAN controllers and
+			  "bosch,d_can" for D_CAN controllers.
+- reg			: physical base address and size of the C_CAN/D_CAN
+			  registers map
+- interrupts		: property with a value describing the interrupt
+			  number
+- interrupt-parent	: The parent interrupt controller
+
+Optional properties:
+- ti,hwmods		: Must be "d_can<n>" or "c_can<n>", n being the
+			  instance number
+
+Note: "ti,hwmods" field is used to fetch the base address and irq
+resources from TI, omap hwmod data base during device registration.
+Future plan is to migrate hwmod data base contents into device tree
+blob so that, all the required data will be used from device tree dts
+file.
+
+Examples:
+
+	d_can@481D0000 {
+		compatible = "bosch,d_can";
+		reg = <0x481D0000 0x1000>;
+		interrupts = <55 0x4>;
+		interrupt-parent = <&intc>;
+	};
+
+(or)
+
+	d_can@481D0000 {
+		compatible = "bosch,d_can";
+		ti,hwmods = "d_can1";
+	};
drivers/net/can/c_can/c_can.h +0 -0
index 01a7049..4e56baa 100644
@@ -143,8 +143,9 @@ static const u16 reg_map_d_can[] = {
 };
 
Quoted 9 lines

drivers/net/can/c_can/c_can.h static const u16 reg_map_d_can[] = { · line 148

Quoted 6 lines
drivers/net/can/c_can/c_can.h +3 -2
 enum c_can_dev_id {
-	C_CAN_DEVTYPE,
-	D_CAN_DEVTYPE,
+	BOSCH_C_CAN_PLATFORM,
+	BOSCH_C_CAN,
+	BOSCH_D_CAN,

Note: these symbols are used in "drivers/net/can/c_can/c_can_pci.c", too.

Oops! I missed out. Separate patch will be added in v3 with this series to take care of this issue.

Regards
AnilKumar

#7 lore raw

Re: [PATCH v2 1/2] can: c_can: Add device tree support to Bosch C_CAN/D_CAN controller

In reply to a message not in the archive
Quoted 8 lines · Chimata

Marc,

Quoted 5 lines · Marc Kleine-Budde
Quoted 3 lines · AnilKumar Ch

Add device tree support to C_CAN/D_CAN controller and usage details are added to device tree documentation. Driver was tested on AM335x EVM.

Quoted 7 lines
Quoted 5 lines

Does not apply to linux-can-next, as Viresh Kumar's patch "net/c_can:
remove conditional compilation of clk code" is not yet included. I suggest to delay this patch until we have Viresh's patch in net-next.

See comment inline.

Ok, I will wait till net-next is updated with Viresh Kumar's patch.

Now Viresh's patch is in net-next, feel free to post your new patches.

Marc

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

_______________________________________________
devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss

#9 lore raw

RE: [PATCH v2 1/2] can: c_can: Add device tree support to Bosch C_CAN/D_CAN controller

In reply to a message not in the archive

Hi Marc,

Quoted 13 lines · Marc Kleine-Budde
Quoted 12 lines · Chimata

Marc,

Quoted 9 lines · Marc Kleine-Budde
Quoted 3 lines · AnilKumar Ch

Add device tree support to C_CAN/D_CAN controller and usage details are added to device tree documentation. Driver was tested on AM335x EVM.

Does not apply to linux-can-next, as Viresh Kumar's patch "net/c_can:
remove conditional compilation of clk code" is not yet included. I suggest to delay this patch until we have Viresh's patch in net-next.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

See comment inline.

Ok, I will wait till net-next is updated with Viresh Kumar's patch.

Now Viresh's patch is in net-next, feel free to post your new patches.

I will send the patches.

Thanks
AnilKumar