Skip to content

Commit 9ed63c6

Browse files
can: flexcan: remove TX mailbox bit from struct flexcan_priv::rx_mask{1,2}
The flexcan IP core has up to 64 mailboxes, each one has a corresponding interrupt bit in the iflag1 or iflag2 registers and a mask bit in the imask1 or imask2 registers. In the timestamp (i.e. non FIFO) mode the driver needs to mask out all non RX interrupt sources and uses the precomputed values rx_mask1 and rx_mask2 of struct flexcan_priv for this. Currently these values cannot be used directly, as they contain the TX mailbox flag. This patch removes the TX flag from flexcan_priv::rx_mask1 and flexcan_priv::rx_mask2, and sets the TX flag directly when writing the regs->iflag1 and regs->iflag2 into the hardware. Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 07c054d commit 9ed63c6

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

drivers/net/can/flexcan.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -878,8 +878,7 @@ static inline u64 flexcan_read_reg_iflag_rx(struct flexcan_priv *priv)
878878
struct flexcan_regs __iomem *regs = priv->regs;
879879
u32 iflag1, iflag2;
880880

881-
iflag2 = priv->read(&regs->iflag2) & priv->rx_mask2 &
882-
~FLEXCAN_IFLAG2_MB(priv->tx_mb_idx);
881+
iflag2 = priv->read(&regs->iflag2) & priv->rx_mask2;
883882
iflag1 = priv->read(&regs->iflag1) & priv->rx_mask1;
884883

885884
return (u64)iflag2 << 32 | iflag1;
@@ -1228,7 +1227,7 @@ static int flexcan_chip_start(struct net_device *dev)
12281227
disable_irq(dev->irq);
12291228
priv->write(priv->reg_ctrl_default, &regs->ctrl);
12301229
priv->write(priv->rx_mask1, &regs->imask1);
1231-
priv->write(priv->rx_mask2, &regs->imask2);
1230+
priv->write(priv->rx_mask2 | FLEXCAN_IFLAG2_MB(priv->tx_mb_idx), &regs->imask2);
12321231
enable_irq(dev->irq);
12331232

12341233
/* print chip status */
@@ -1297,9 +1296,6 @@ static int flexcan_open(struct net_device *dev)
12971296
priv->tx_mb_idx = priv->mb_count - 1;
12981297
priv->tx_mb = flexcan_get_mb(priv, priv->tx_mb_idx);
12991298

1300-
priv->rx_mask1 = 0;
1301-
priv->rx_mask2 = FLEXCAN_IFLAG2_MB(priv->tx_mb_idx);
1302-
13031299
priv->offload.mailbox_read = flexcan_mailbox_read;
13041300

13051301
if (priv->devtype_data->quirks & FLEXCAN_QUIRK_USE_OFF_TIMESTAMP) {
@@ -1310,12 +1306,12 @@ static int flexcan_open(struct net_device *dev)
13101306

13111307
imask = GENMASK_ULL(priv->offload.mb_last,
13121308
priv->offload.mb_first);
1313-
priv->rx_mask1 |= imask;
1314-
priv->rx_mask2 |= imask >> 32;
1309+
priv->rx_mask1 = imask;
1310+
priv->rx_mask2 = imask >> 32;
13151311

13161312
err = can_rx_offload_add_timestamp(dev, &priv->offload);
13171313
} else {
1318-
priv->rx_mask1 |= FLEXCAN_IFLAG_RX_FIFO_OVERFLOW |
1314+
priv->rx_mask1 = FLEXCAN_IFLAG_RX_FIFO_OVERFLOW |
13191315
FLEXCAN_IFLAG_RX_FIFO_AVAILABLE;
13201316
err = can_rx_offload_add_fifo(dev, &priv->offload,
13211317
FLEXCAN_NAPI_WEIGHT);

0 commit comments

Comments
 (0)