mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 02:21:52 +09:00
can: rcar_canfd: Fix page entries in the AFL list
commit 1dba0a37644ed3022558165bbb5cb9bda540eaf7 upstream.
There are a total of 96 AFL pages and each page has 16 entries with
registers CFDGAFLIDr, CFDGAFLMr, CFDGAFLP0r, CFDGAFLP1r holding
the rule entries (r = 0..15).
Currently, RCANFD_GAFL* macros use a start variable to find AFL entries,
which is incorrect as the testing on RZ/G3E shows ch1 and ch4
gets a start value of 0 and the register contents are overwritten.
Fix this issue by using rule_entry corresponding to the channel
to find the page entries in the AFL list.
Fixes: dd3bd23eb4 ("can: rcar_canfd: Add Renesas R-Car CAN FD driver")
Cc: stable@vger.kernel.org
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://patch.msgid.link/20250307170330.173425-3-biju.das.jz@bp.renesas.com
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
78f6d8f8fc
commit
a8a89a6d37
@@ -772,22 +772,14 @@ static void rcar_canfd_configure_controller(struct rcar_canfd_global *gpriv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void rcar_canfd_configure_afl_rules(struct rcar_canfd_global *gpriv,
|
static void rcar_canfd_configure_afl_rules(struct rcar_canfd_global *gpriv,
|
||||||
u32 ch)
|
u32 ch, u32 rule_entry)
|
||||||
{
|
{
|
||||||
u32 cfg;
|
int offset, page, num_rules = RCANFD_CHANNEL_NUMRULES;
|
||||||
int offset, start, page, num_rules = RCANFD_CHANNEL_NUMRULES;
|
u32 rule_entry_index = rule_entry % 16;
|
||||||
u32 ridx = ch + RCANFD_RFFIFO_IDX;
|
u32 ridx = ch + RCANFD_RFFIFO_IDX;
|
||||||
|
|
||||||
if (ch == 0) {
|
|
||||||
start = 0; /* Channel 0 always starts from 0th rule */
|
|
||||||
} else {
|
|
||||||
/* Get number of Channel 0 rules and adjust */
|
|
||||||
cfg = rcar_canfd_read(gpriv->base, RCANFD_GAFLCFG(ch));
|
|
||||||
start = RCANFD_GAFLCFG_GETRNC(gpriv, 0, cfg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Enable write access to entry */
|
/* Enable write access to entry */
|
||||||
page = RCANFD_GAFL_PAGENUM(start);
|
page = RCANFD_GAFL_PAGENUM(rule_entry);
|
||||||
rcar_canfd_set_bit(gpriv->base, RCANFD_GAFLECTR,
|
rcar_canfd_set_bit(gpriv->base, RCANFD_GAFLECTR,
|
||||||
(RCANFD_GAFLECTR_AFLPN(gpriv, page) |
|
(RCANFD_GAFLECTR_AFLPN(gpriv, page) |
|
||||||
RCANFD_GAFLECTR_AFLDAE));
|
RCANFD_GAFLECTR_AFLDAE));
|
||||||
@@ -803,13 +795,13 @@ static void rcar_canfd_configure_afl_rules(struct rcar_canfd_global *gpriv,
|
|||||||
offset = RCANFD_C_GAFL_OFFSET;
|
offset = RCANFD_C_GAFL_OFFSET;
|
||||||
|
|
||||||
/* Accept all IDs */
|
/* Accept all IDs */
|
||||||
rcar_canfd_write(gpriv->base, RCANFD_GAFLID(offset, start), 0);
|
rcar_canfd_write(gpriv->base, RCANFD_GAFLID(offset, rule_entry_index), 0);
|
||||||
/* IDE or RTR is not considered for matching */
|
/* IDE or RTR is not considered for matching */
|
||||||
rcar_canfd_write(gpriv->base, RCANFD_GAFLM(offset, start), 0);
|
rcar_canfd_write(gpriv->base, RCANFD_GAFLM(offset, rule_entry_index), 0);
|
||||||
/* Any data length accepted */
|
/* Any data length accepted */
|
||||||
rcar_canfd_write(gpriv->base, RCANFD_GAFLP0(offset, start), 0);
|
rcar_canfd_write(gpriv->base, RCANFD_GAFLP0(offset, rule_entry_index), 0);
|
||||||
/* Place the msg in corresponding Rx FIFO entry */
|
/* Place the msg in corresponding Rx FIFO entry */
|
||||||
rcar_canfd_set_bit(gpriv->base, RCANFD_GAFLP1(offset, start),
|
rcar_canfd_set_bit(gpriv->base, RCANFD_GAFLP1(offset, rule_entry_index),
|
||||||
RCANFD_GAFLP1_GAFLFDP(ridx));
|
RCANFD_GAFLP1_GAFLFDP(ridx));
|
||||||
|
|
||||||
/* Disable write access to page */
|
/* Disable write access to page */
|
||||||
@@ -1825,6 +1817,7 @@ static int rcar_canfd_probe(struct platform_device *pdev)
|
|||||||
unsigned long channels_mask = 0;
|
unsigned long channels_mask = 0;
|
||||||
int err, ch_irq, g_irq;
|
int err, ch_irq, g_irq;
|
||||||
int g_err_irq, g_recc_irq;
|
int g_err_irq, g_recc_irq;
|
||||||
|
u32 rule_entry = 0;
|
||||||
bool fdmode = true; /* CAN FD only mode - default */
|
bool fdmode = true; /* CAN FD only mode - default */
|
||||||
enum rcanfd_chip_id chip_id;
|
enum rcanfd_chip_id chip_id;
|
||||||
int max_channels;
|
int max_channels;
|
||||||
@@ -2003,7 +1996,8 @@ static int rcar_canfd_probe(struct platform_device *pdev)
|
|||||||
rcar_canfd_configure_tx(gpriv, ch);
|
rcar_canfd_configure_tx(gpriv, ch);
|
||||||
|
|
||||||
/* Configure receive rules */
|
/* Configure receive rules */
|
||||||
rcar_canfd_configure_afl_rules(gpriv, ch);
|
rcar_canfd_configure_afl_rules(gpriv, ch, rule_entry);
|
||||||
|
rule_entry += RCANFD_CHANNEL_NUMRULES;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Configure common interrupts */
|
/* Configure common interrupts */
|
||||||
|
|||||||
Reference in New Issue
Block a user