@@ -1220,20 +1220,32 @@ static void m_can_coalescing_update(struct m_can_classdev *cdev, u32 ir)
1220
1220
static int m_can_interrupt_handler (struct m_can_classdev * cdev )
1221
1221
{
1222
1222
struct net_device * dev = cdev -> net ;
1223
- u32 ir ;
1223
+ u32 ir = 0 , ir_read ;
1224
1224
int ret ;
1225
1225
1226
1226
if (pm_runtime_suspended (cdev -> dev ))
1227
1227
return IRQ_NONE ;
1228
1228
1229
- ir = m_can_read (cdev , M_CAN_IR );
1229
+ /* The m_can controller signals its interrupt status as a level, but
1230
+ * depending in the integration the CPU may interpret the signal as
1231
+ * edge-triggered (for example with m_can_pci). For these
1232
+ * edge-triggered integrations, we must observe that IR is 0 at least
1233
+ * once to be sure that the next interrupt will generate an edge.
1234
+ */
1235
+ while ((ir_read = m_can_read (cdev , M_CAN_IR )) != 0 ) {
1236
+ ir |= ir_read ;
1237
+
1238
+ /* ACK all irqs */
1239
+ m_can_write (cdev , M_CAN_IR , ir );
1240
+
1241
+ if (!cdev -> irq_edge_triggered )
1242
+ break ;
1243
+ }
1244
+
1230
1245
m_can_coalescing_update (cdev , ir );
1231
1246
if (!ir )
1232
1247
return IRQ_NONE ;
1233
1248
1234
- /* ACK all irqs */
1235
- m_can_write (cdev , M_CAN_IR , ir );
1236
-
1237
1249
if (cdev -> ops -> clear_interrupts )
1238
1250
cdev -> ops -> clear_interrupts (cdev );
1239
1251
@@ -1695,6 +1707,14 @@ static int m_can_dev_setup(struct m_can_classdev *cdev)
1695
1707
return - EINVAL ;
1696
1708
}
1697
1709
1710
+ /* Write the INIT bit, in case no hardware reset has happened before
1711
+ * the probe (for example, it was observed that the Intel Elkhart Lake
1712
+ * SoCs do not properly reset the CAN controllers on reboot)
1713
+ */
1714
+ err = m_can_cccr_update_bits (cdev , CCCR_INIT , CCCR_INIT );
1715
+ if (err )
1716
+ return err ;
1717
+
1698
1718
if (!cdev -> is_peripheral )
1699
1719
netif_napi_add (dev , & cdev -> napi , m_can_poll );
1700
1720
@@ -1746,11 +1766,7 @@ static int m_can_dev_setup(struct m_can_classdev *cdev)
1746
1766
return - EINVAL ;
1747
1767
}
1748
1768
1749
- /* Forcing standby mode should be redundant, as the chip should be in
1750
- * standby after a reset. Write the INIT bit anyways, should the chip
1751
- * be configured by previous stage.
1752
- */
1753
- return m_can_cccr_update_bits (cdev , CCCR_INIT , CCCR_INIT );
1769
+ return 0 ;
1754
1770
}
1755
1771
1756
1772
static void m_can_stop (struct net_device * dev )
0 commit comments