CAN clock issues on 3.14 mainline kernel

Discussion around products based on ARM Cortex-A5 core.

Moderator: nferre

flotter
Posts: 8
Joined: Thu Mar 27, 2014 5:32 pm

CAN clock issues on 3.14 mainline kernel

Mon May 12, 2014 2:52 pm

Hi guys,

It looks like clock support in the mainline kernel is broken, at least for CAN.

I have tested with 3.14 and 3.15 rc5. The results are shown below.

Any ideas?

Code: Select all

[color=#FF0000]root@sama5d3xek:~# cat /proc/cpuinfo
processor       : 0
model name      : ARMv7 Processor rev 1 (v7l)
Features        : swp half thumb fastmult vfp edsp vfpv3 vfpv3d16 tls vfpv4
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xc05
CPU revision    : 1

Hardware        : Atmel SAMA5 (Device Tree)
Revision        : 0000
Serial          : 0000000000000000


root@sama5d3xek:~# uname -a
Linux sama5d3xek 3.15.0-rc5-yocto-standard #2 Mon May 12 14:21:35 SAST 2014 armv7l GNU/Linux


root@sama5d3xek:~# ip link set can0 up type can bitrate 125000
------------[ cut here ]------------
WARNING: CPU: 0 PID: 1344 at /home/flotter/mix/oe/build/tmp-angstrom_v2013_12-eglibc/work/sama5d3xek-angstrom-linux-gnueabi/linux-yocto-custom/3.15+gitd6d211db37e75de2ddc3a4f979038c40df7cc79c-r1/linux/drivers/clk/clk.c:930 __clk_enable+0x94/0x9c()
Modules linked in:
CPU: 0 PID: 1344 Comm: ip Tainted: G        W     3.15.0-rc5-yocto-standard #2
[<c0012cc4>] (unwind_backtrace) from [<c0010c44>] (show_stack+0x10/0x14)
[<c0010c44>] (show_stack) from [<c001b0b0>] (warn_slowpath_common+0x6c/0x84)
[<c001b0b0>] (warn_slowpath_common) from [<c001b164>] (warn_slowpath_null+0x1c/0x24)
[<c001b164>] (warn_slowpath_null) from [<c02d2ea4>] (__clk_enable+0x94/0x9c)
[<c02d2ea4>] (__clk_enable) from [<c02d2ec4>] (clk_enable+0x18/0x2c)
[<c02d2ec4>] (clk_enable) from [<c025bb48>] (at91_open+0x14/0xc0)
[<c025bb48>] (at91_open) from [<c02f54bc>] (__dev_open+0xb8/0x11c)
[<c02f54bc>] (__dev_open) from [<c02f5744>] (__dev_change_flags+0x94/0x168)
[<c02f5744>] (__dev_change_flags) from [<c02f5830>] (dev_change_flags+0x18/0x48)
[<c02f5830>] (dev_change_flags) from [<c0302810>] (do_setlink+0x308/0x870)
[<c0302810>] (do_setlink) from [<c0303338>] (rtnl_newlink+0x4c4/0x5d0)
[<c0303338>] (rtnl_newlink) from [<c03023b8>] (rtnetlink_rcv_msg+0x178/0x214)
[<c03023b8>] (rtnetlink_rcv_msg) from [<c030f5b4>] (netlink_rcv_skb+0xc4/0xd8)
[<c030f5b4>] (netlink_rcv_skb) from [<c0302238>] (rtnetlink_rcv+0x24/0x2c)
[<c0302238>] (rtnetlink_rcv) from [<c030ef08>] (netlink_unicast+0x158/0x224)
[<c030ef08>] (netlink_unicast) from [<c030f340>] (netlink_sendmsg+0x2c8/0x380)
[<c030f340>] (netlink_sendmsg) from [<c02dee90>] (sock_sendmsg+0x88/0xac)
[<c02dee90>] (sock_sendmsg) from [<c02e0208>] (___sys_sendmsg.part.38+0x268/0x278)
[<c02e0208>] (___sys_sendmsg.part.38) from [<c02e1164>] (__sys_sendmsg+0x4c/0x7c)
[<c02e1164>] (__sys_sendmsg) from [<c000e020>] (ret_fast_syscall+0x0/0x30)
---[ end trace 2b7de31833b4bec7 ]---
at91_can f000c000.can can0: writing AT91_BR: 0x00200561
root@sama5d3xek:~#
[/color]
flotter
Posts: 8
Joined: Thu Mar 27, 2014 5:32 pm

Re: CAN clock issues on 3.14 mainline kernel

Tue May 13, 2014 10:26 am

I managed to fix the problem. There are some common clock code missing in the CAN driver and a typo in the Device Tree files.

Code: Select all

diff --git a/arch/arm/boot/dts/sama5d3_can.dtsi b/arch/arm/boot/dts/sama5d3_can.dtsi
index a077585..eaf4145 100644
--- a/arch/arm/boot/dts/sama5d3_can.dtsi
+++ b/arch/arm/boot/dts/sama5d3_can.dtsi
@@ -40,7 +40,7 @@
 						atmel,clk-output-range = <0 66000000>;
 					};
 
-					can1_clk: can0_clk {
+					can1_clk: can1_clk {
 						#clock-cells = <0>;
 						reg = <41>;
 						atmel,clk-output-range = <0 66000000>;
diff --git a/drivers/net/can/at91_can.c b/drivers/net/can/at91_can.c
index f07fa89..b2fd52a 100644
--- a/drivers/net/can/at91_can.c
+++ b/drivers/net/can/at91_can.c
@@ -1123,7 +1123,7 @@ static int at91_open(struct net_device *dev)
 	struct at91_priv *priv = netdev_priv(dev);
 	int err;
 
-	clk_enable(priv->clk);
+       clk_prepare_enable(priv->clk);
 
 	/* check or determine and set bittime */
 	err = open_candev(dev);
@@ -1149,7 +1149,7 @@ static int at91_open(struct net_device *dev)
  out_close:
 	close_candev(dev);
  out:
-	clk_disable(priv->clk);
+	clk_disable_unprepare(priv->clk);
 
 	return err;
 }
@@ -1166,7 +1166,7 @@ static int at91_close(struct net_device *dev)
 	at91_chip_stop(dev, CAN_STATE_STOPPED);
 
 	free_irq(dev->irq, dev);
-	clk_disable(priv->clk);
+	clk_disable_unprepare(priv->clk);
 
 	close_candev(dev);
 
Enjoy!

Return to “SAMA5D Cortex-A5 MPU”

Who is online

Users browsing this forum: No registered users and 1 guest