public inbox for linux-can@vger.kernel.org
 help / color / mirror / Atom feed
From: Torin Cooper-Bennun <torin@maxiluxsystems.com>
To: linux-can@vger.kernel.org
Cc: Torin Cooper-Bennun <torin@maxiluxsystems.com>
Subject: [PATCH RFC can-next 3/3] can: tcan4x5x: add handle_dev_interrupts callback to ops
Date: Fri, 14 May 2021 13:19:46 +0100	[thread overview]
Message-ID: <20210514121946.2344901-4-torin@maxiluxsystems.com> (raw)
In-Reply-To: <20210514121946.2344901-1-torin@maxiluxsystems.com>

Though the TCAN4550's device-specific interrupts are cleared in
tcan4x5x_clear_interrupts(), they are ignored, which may cause the m_can
driver to stop working due to the ISR becoming disabled (the famous
"nobody cared" message).

Signed-off-by: Torin Cooper-Bennun <torin@maxiluxsystems.com>
---
 drivers/net/can/m_can/tcan4x5x-core.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/net/can/m_can/tcan4x5x-core.c b/drivers/net/can/m_can/tcan4x5x-core.c
index 4147cecfbbd6..cee7dfff381f 100644
--- a/drivers/net/can/m_can/tcan4x5x-core.c
+++ b/drivers/net/can/m_can/tcan4x5x-core.c
@@ -39,6 +39,7 @@
 #define TCAN4X5X_CANBUS_ERR_INT_EN BIT(5)
 #define TCAN4X5X_BUS_FAULT BIT(4)
 #define TCAN4X5X_MCAN_INT BIT(1)
+#define TCAN4X5X_VTWD_INT BIT(0)
 #define TCAN4X5X_ENABLE_TCAN_INT \
 	(TCAN4X5X_MCAN_INT | TCAN4X5X_BUS_FAULT | \
 	 TCAN4X5X_CANBUS_ERR_INT_EN | TCAN4X5X_CANINT_INT_EN)
@@ -190,6 +191,16 @@ static int tcan4x5x_power_enable(struct regulator *reg, int enable)
 		return regulator_disable(reg);
 }
 
+static u32 tcan4x5x_read_tcan_reg(struct m_can_classdev *cdev, int reg)
+{
+	struct tcan4x5x_priv *priv = cdev_to_priv(cdev);
+	u32 val;
+
+	regmap_read(priv->regmap, reg, &val);
+
+	return val;
+}
+
 static int tcan4x5x_write_tcan_reg(struct m_can_classdev *cdev,
 				   int reg, int val)
 {
@@ -221,6 +232,19 @@ static int tcan4x5x_clear_interrupts(struct m_can_classdev *cdev)
 				       TCAN4X5X_CLEAR_ALL_INT);
 }
 
+static irqreturn_t tcan4x5x_handle_dev_interrupts(struct m_can_classdev *cdev)
+{
+	irqreturn_t ret = IRQ_NONE;
+	int ir;
+
+	ir = tcan4x5x_read_tcan_reg(cdev, TCAN4X5X_INT_FLAGS);
+
+	if (ir & (TCAN4X5X_CANDOM_INT_EN | TCAN4X5X_VTWD_INT))
+		ret = IRQ_HANDLED;
+
+	return ret;
+}
+
 static int tcan4x5x_init(struct m_can_classdev *cdev)
 {
 	struct tcan4x5x_priv *tcan4x5x = cdev_to_priv(cdev);
@@ -305,6 +329,7 @@ static struct m_can_ops tcan4x5x_ops = {
 	.write_fifo = tcan4x5x_write_fifo,
 	.read_fifo = tcan4x5x_read_fifo,
 	.clear_interrupts = tcan4x5x_clear_interrupts,
+	.handle_dev_interrupts = tcan4x5x_handle_dev_interrupts,
 };
 
 static int tcan4x5x_can_probe(struct spi_device *spi)
-- 
2.30.2


  parent reply	other threads:[~2021-05-14 12:20 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-14 12:19 [PATCH RFC can-next 0/3] m_can: support device-specific interrupt handling Torin Cooper-Bennun
2021-05-14 12:19 ` [PATCH RFC can-next 1/3] can: m_can: add handle_dev_interrupts callback to m_can_ops Torin Cooper-Bennun
2021-05-14 12:26   ` Marc Kleine-Budde
2021-05-14 13:21     ` Torin Cooper-Bennun
2021-05-14 14:16       ` Marc Kleine-Budde
2021-05-14 12:19 ` [PATCH RFC can-next 2/3] can: m_can: m_can_isr(): handle device-specific interrupts Torin Cooper-Bennun
2021-05-14 12:19 ` Torin Cooper-Bennun [this message]
2021-05-14 14:10   ` [PATCH RFC can-next 3/3] can: tcan4x5x: add handle_dev_interrupts callback to ops Marc Kleine-Budde
2021-05-14 14:51     ` Torin Cooper-Bennun
2021-05-14 15:15       ` Marc Kleine-Budde
2021-05-14 16:27         ` Torin Cooper-Bennun
2021-05-14 12:34 ` [PATCH RFC can-next 0/3] m_can: support device-specific interrupt handling Marc Kleine-Budde
2021-05-14 13:10   ` Torin Cooper-Bennun
2021-05-14 14:12     ` Marc Kleine-Budde
2021-05-14 14:44       ` Torin Cooper-Bennun
2021-05-14 14:55         ` Marc Kleine-Budde
2021-05-14 16:46           ` Torin Cooper-Bennun
2021-05-14 14:54       ` Torin Cooper-Bennun
2021-05-14 15:21         ` Marc Kleine-Budde
2021-05-14 16:44           ` Torin Cooper-Bennun
2021-05-14 17:13             ` Marc Kleine-Budde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210514121946.2344901-4-torin@maxiluxsystems.com \
    --to=torin@maxiluxsystems.com \
    --cc=linux-can@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox