Hi,
On 7/6/23 3:21 PM, Francesco Dolcini wrote:
On Thu, Jul 06, 2023 at 10:20:59AM -0500, Judith Mendez wrote:
Hi Marc
On 7/6/23 2:25 AM, Marc Kleine-Budde wrote:
On 05.07.2023 14:53:56, Judith Mendez wrote:
Introduce timer polling method to MCAN since some SoCs may not
have M_CAN interrupt routed to A53 Linux and do not have
interrupt property in device tree M_CAN node.
On AM62x SoC, MCANs on MCU domain do not have hardware interrupt
routed to A53 Linux, instead they will use timer polling method.
Add an hrtimer to MCAN class device. Each MCAN will have its own
hrtimer instantiated if there is no hardware interrupt found in
device tree M_CAN node. The timer will generate a software
interrupt every 1 ms. In hrtimer callback, we check if there is
a transaction pending by reading a register, then process by
calling the isr if there is.
Tested-by: Hiago De Franco <hiago.franco@xxxxxxxxxxx> # Toradex Verdin AM62
Reviewed-by: Tony Lindgren <tony@xxxxxxxxxxx>
Signed-off-by: Judith Mendez <jm@xxxxxx>
---
...
diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/m_can_platform.c
index 94dc82644113..76d11ce38220 100644
--- a/drivers/net/can/m_can/m_can_platform.c
+++ b/drivers/net/can/m_can/m_can_platform.c
@@ -5,6 +5,7 @@
//
// Copyright (C) 2018-19 Texas Instruments Incorporated - http://www.ti.com/
+#include <linux/hrtimer.h>
#include <linux/phy/phy.h>
#include <linux/platform_device.h>
@@ -96,12 +97,28 @@ static int m_can_plat_probe(struct platform_device *pdev)
goto probe_fail;
Please set "irq" to 0 during declaration.
During declaration of irq, it is already set to 0:
int irq, ret = 0;
The initialization here applies only to ret.
int irq = 0, ret = 0;
Understood, thanks!
addr = devm_platform_ioremap_resource_byname(pdev, "m_can");
- irq = platform_get_irq_byname(pdev, "int0");
- if (IS_ERR(addr) || irq < 0) {
- ret = -EINVAL;
+ if (IS_ERR(addr)) {
+ ret = PTR_ERR(addr);
goto probe_fail;
}
+ if (device_property_present(mcan_class->dev, "interrupts") ||
+ device_property_present(mcan_class->dev, "interrupt-names")) {
+ irq = platform_get_irq_byname(pdev, "int0");
+ if (irq == -EPROBE_DEFER) {
+ ret = -EPROBE_DEFER;
+ goto probe_fail;
+ }
+ if (irq < 0) {
+ ret = -EINVAL;
Please return the original error value.
The original value returned is -EINVAL:
- if (IS_ERR(addr) || irq < 0) {
- ret = -EINVAL;
Perhaps I am missing something here?
if (irq < 0) {
ret = irq;
...
}
And you can also get rid of the explicit test for -EPROBE_DEFER this
way simplifying the code.
I misunderstood, thanks!!
~ Judith