Skip to content

Commit 1ae2624

Browse files
Ciprian Marian Costeajfvogel
authored andcommitted
can: flexcan: Add quirk to handle separate interrupt lines for mailboxes
[ Upstream commit 8c652cf030a769fbfc73cfc280ed3f1656343c35 ] 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 <[email protected]> Reviewed-by: Vincent Mailhol <[email protected]> Link: https://patch.msgid.link/[email protected] [mkl: flexcan_open(): change order and free irq_secondary_mb first] Signed-off-by: Marc Kleine-Budde <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit fba5f41f1536086e0c24d444865f035ebf300825) Signed-off-by: Jack Vogel <[email protected]>
1 parent aa29a95 commit 1ae2624

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

drivers/net/can/flexcan/flexcan-core.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1762,14 +1762,25 @@ static int flexcan_open(struct net_device *dev)
17621762
goto out_free_irq_boff;
17631763
}
17641764

1765+
if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SECONDARY_MB_IRQ) {
1766+
err = request_irq(priv->irq_secondary_mb,
1767+
flexcan_irq, IRQF_SHARED, dev->name, dev);
1768+
if (err)
1769+
goto out_free_irq_err;
1770+
}
1771+
17651772
flexcan_chip_interrupts_enable(dev);
17661773

17671774
netif_start_queue(dev);
17681775

17691776
return 0;
17701777

1778+
out_free_irq_err:
1779+
if (priv->devtype_data.quirks & FLEXCAN_QUIRK_NR_IRQ_3)
1780+
free_irq(priv->irq_err, dev);
17711781
out_free_irq_boff:
1772-
free_irq(priv->irq_boff, dev);
1782+
if (priv->devtype_data.quirks & FLEXCAN_QUIRK_NR_IRQ_3)
1783+
free_irq(priv->irq_boff, dev);
17731784
out_free_irq:
17741785
free_irq(dev->irq, dev);
17751786
out_can_rx_offload_disable:
@@ -1794,6 +1805,9 @@ static int flexcan_close(struct net_device *dev)
17941805
netif_stop_queue(dev);
17951806
flexcan_chip_interrupts_disable(dev);
17961807

1808+
if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SECONDARY_MB_IRQ)
1809+
free_irq(priv->irq_secondary_mb, dev);
1810+
17971811
if (priv->devtype_data.quirks & FLEXCAN_QUIRK_NR_IRQ_3) {
17981812
free_irq(priv->irq_err, dev);
17991813
free_irq(priv->irq_boff, dev);
@@ -2187,6 +2201,14 @@ static int flexcan_probe(struct platform_device *pdev)
21872201
}
21882202
}
21892203

2204+
if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SECONDARY_MB_IRQ) {
2205+
priv->irq_secondary_mb = platform_get_irq_byname(pdev, "mb-1");
2206+
if (priv->irq_secondary_mb < 0) {
2207+
err = priv->irq_secondary_mb;
2208+
goto failed_platform_get_irq;
2209+
}
2210+
}
2211+
21902212
if (priv->devtype_data.quirks & FLEXCAN_QUIRK_SUPPORT_FD) {
21912213
priv->can.ctrlmode_supported |= CAN_CTRLMODE_FD |
21922214
CAN_CTRLMODE_FD_NON_ISO;

drivers/net/can/flexcan/flexcan.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@
7070
#define FLEXCAN_QUIRK_SUPPORT_RX_FIFO BIT(16)
7171
/* Setup stop mode with ATF SCMI protocol to support wakeup */
7272
#define FLEXCAN_QUIRK_SETUP_STOP_MODE_SCMI BIT(17)
73+
/* Device has two separate interrupt lines for two mailbox ranges, which
74+
* both need to have an interrupt handler registered.
75+
*/
76+
#define FLEXCAN_QUIRK_SECONDARY_MB_IRQ BIT(18)
7377

7478
struct flexcan_devtype_data {
7579
u32 quirks; /* quirks needed for different IP cores */
@@ -107,6 +111,7 @@ struct flexcan_priv {
107111

108112
int irq_boff;
109113
int irq_err;
114+
int irq_secondary_mb;
110115

111116
/* IPC handle when setup stop mode by System Controller firmware(scfw) */
112117
struct imx_sc_ipc *sc_ipc_handle;

0 commit comments

Comments
 (0)