Blob Blame History Raw
From a584e9bc1b7e88f24f8504886eafbe6c73d8a97c Mon Sep 17 00:00:00 2001
From: Faiz Abbas <faiz_abbas@ti.com>
Date: Tue, 25 Aug 2020 11:24:42 +0530
Subject: [PATCH] can: m_can: m_can_stop(): set device to software init mode before closing
Git-commit: a584e9bc1b7e88f24f8504886eafbe6c73d8a97c
Patch-mainline: v5.10-rc5
References: git-fixes

[ backport note: changed the argument for m_can_config_endisable() -- tiwai ]

There might be some requests pending in the buffer when the interface close
sequence occurs. In some devices, these pending requests might lead to the
module not shutting down properly when m_can_clk_stop() is called.

Therefore, move the device to init state before potentially powering it down.

Fixes: e0d1f4816f2a ("can: m_can: add Bosch M_CAN controller support")
Signed-off-by: Faiz Abbas <faiz_abbas@ti.com>
Acked-by: Dan Murphy <dmurphy@ti.com>
Link: https://lore.kernel.org/r/20200825055442.16994-1-faiz_abbas@ti.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Acked-by: Takashi Iwai <tiwai@suse.de>

---
 drivers/net/can/m_can/m_can.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -1349,6 +1349,9 @@ static void m_can_stop(struct net_device
 	clk_disable_unprepare(priv->hclk);
 	clk_disable_unprepare(priv->cclk);
 
+	/* Set init mode to disengage from the network */
+	m_can_config_endisable(priv, true);
+
 	/* set the state as STOPPED */
 	priv->can.state = CAN_STATE_STOPPED;
 }