From: Marc Kleine-Budde <mkl@pengutronix.de>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, linux-can@vger.kernel.org,
kernel@pengutronix.de,
Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com>,
Vincent Mailhol <mailhol.vincent@wanadoo.fr>,
Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [PATCH net-next 06/12] can: flexcan: Add quirk to handle separate interrupt lines for mailboxes
Date: Wed, 19 Feb 2025 12:21:11 +0100 [thread overview]
Message-ID: <20250219113354.529611-7-mkl@pengutronix.de> (raw)
In-Reply-To: <20250219113354.529611-1-mkl@pengutronix.de>
From: Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com>
Introduce 'FLEXCAN_QUIRK_SECONDARY_MB_IRQ' quirk to handle a FlexCAN
hardware module integration particularity where two ranges of mailboxes
are controlled by separate hardware interrupt lines.
The same 'flexcan_irq' handler is used for both separate mailbox interrupt
lines, with no other changes.
Signed-off-by: Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com>
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Link: https://patch.msgid.link/20250113120704.522307-3-ciprianmarian.costea@oss.nxp.com
[mkl: flexcan_open(): change order and free irq_secondary_mb first]
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/flexcan/flexcan-core.c | 24 +++++++++++++++++++++++-
drivers/net/can/flexcan/flexcan.h | 5 +++++
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/flexcan-core.c
index ac1a860986df..a8a4cc4c064d 100644
--- a/drivers/net/can/flexcan/flexcan-core.c
+++ b/drivers/net/can/flexcan/flexcan-core.c
@@ -1762,14 +1762,25 @@ static int flexcan_open(struct net_device *dev)
goto out_free_irq_boff;
}
+ if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SECONDARY_MB_IRQ) {
+ err = request_irq(priv->irq_secondary_mb,
+ flexcan_irq, IRQF_SHARED, dev->name, dev);
+ if (err)
+ goto out_free_irq_err;
+ }
+
flexcan_chip_interrupts_enable(dev);
netif_start_queue(dev);
return 0;
+ out_free_irq_err:
+ if (priv->devtype_data.quirks & FLEXCAN_QUIRK_NR_IRQ_3)
+ free_irq(priv->irq_err, dev);
out_free_irq_boff:
- free_irq(priv->irq_boff, dev);
+ if (priv->devtype_data.quirks & FLEXCAN_QUIRK_NR_IRQ_3)
+ free_irq(priv->irq_boff, dev);
out_free_irq:
free_irq(dev->irq, dev);
out_can_rx_offload_disable:
@@ -1794,6 +1805,9 @@ static int flexcan_close(struct net_device *dev)
netif_stop_queue(dev);
flexcan_chip_interrupts_disable(dev);
+ if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SECONDARY_MB_IRQ)
+ free_irq(priv->irq_secondary_mb, dev);
+
if (priv->devtype_data.quirks & FLEXCAN_QUIRK_NR_IRQ_3) {
free_irq(priv->irq_err, dev);
free_irq(priv->irq_boff, dev);
@@ -2187,6 +2201,14 @@ static int flexcan_probe(struct platform_device *pdev)
}
}
+ if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SECONDARY_MB_IRQ) {
+ priv->irq_secondary_mb = platform_get_irq_byname(pdev, "mb-1");
+ if (priv->irq_secondary_mb < 0) {
+ err = priv->irq_secondary_mb;
+ goto failed_platform_get_irq;
+ }
+ }
+
if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SUPPORT_FD) {
priv->can.ctrlmode_supported |= CAN_CTRLMODE_FD |
CAN_CTRLMODE_FD_NON_ISO;
diff --git a/drivers/net/can/flexcan/flexcan.h b/drivers/net/can/flexcan/flexcan.h
index 4933d8c7439e..2cf886618c96 100644
--- a/drivers/net/can/flexcan/flexcan.h
+++ b/drivers/net/can/flexcan/flexcan.h
@@ -70,6 +70,10 @@
#define FLEXCAN_QUIRK_SUPPORT_RX_FIFO BIT(16)
/* Setup stop mode with ATF SCMI protocol to support wakeup */
#define FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI BIT(17)
+/* Device has two separate interrupt lines for two mailbox ranges, which
+ * both need to have an interrupt handler registered.
+ */
+#define FLEXCAN_QUIRK_SECONDARY_MB_IRQ BIT(18)
struct flexcan_devtype_data {
u32 quirks; /* quirks needed for different IP cores */
@@ -107,6 +111,7 @@ struct flexcan_priv {
int irq_boff;
int irq_err;
+ int irq_secondary_mb;
/* IPC handle when setup stop mode by System Controller firmware(scfw) */
struct imx_sc_ipc *sc_ipc_handle;
--
2.47.2
next prev parent reply other threads:[~2025-02-19 11:34 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-19 11:21 [PATCH net-next 0/12] pull-request: can-next 2025-02-19 Marc Kleine-Budde
2025-02-19 11:21 ` [PATCH net-next 01/12] can: c_can: Drop useless final probe failure message Marc Kleine-Budde
2025-02-20 9:40 ` patchwork-bot+netdevbpf
2025-02-19 11:21 ` [PATCH net-next 02/12] can: c_can: Simplify handling syscon error path Marc Kleine-Budde
2025-02-19 11:21 ` [PATCH net-next 03/12] can: c_can: Use of_property_present() to test existence of DT property Marc Kleine-Budde
2025-02-19 11:21 ` [PATCH net-next 04/12] can: c_can: Use syscon_regmap_lookup_by_phandle_args Marc Kleine-Budde
2025-02-19 11:21 ` [PATCH net-next 05/12] dt-bindings: can: fsl,flexcan: add S32G2/S32G3 SoC support Marc Kleine-Budde
2025-02-19 11:21 ` Marc Kleine-Budde [this message]
2025-02-19 11:21 ` [PATCH net-next 07/12] can: flexcan: add NXP " Marc Kleine-Budde
2025-02-19 11:21 ` [PATCH net-next 08/12] dt-binding: can: mcp251xfd: remove duplicate word Marc Kleine-Budde
2025-02-19 11:21 ` [PATCH net-next 09/12] can: j1939: Extend stack documentation with buffer size behavior Marc Kleine-Budde
2025-02-19 11:21 ` [PATCH net-next 10/12] can: canxl: support Remote Request Substitution bit access Marc Kleine-Budde
2025-02-19 11:21 ` [PATCH net-next 11/12] can: gs_usb: add VID/PID for the CANnectivity firmware Marc Kleine-Budde
2025-02-19 11:21 ` [PATCH net-next 12/12] can: rockchip_canfd: rkcanfd_chip_fifo_setup(): remove duplicated setup of RX FIFO Marc Kleine-Budde
2025-02-20 9:23 ` [PATCH net-next 0/12] pull-request: can-next 2025-02-19 Paolo Abeni
2025-02-20 9:27 ` 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=20250219113354.529611-7-mkl@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=ciprianmarian.costea@oss.nxp.com \
--cc=davem@davemloft.net \
--cc=kernel@pengutronix.de \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=mailhol.vincent@wanadoo.fr \
--cc=netdev@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