Skip to content

Commit 1dba0a3

Browse files
bijudasmarckleinebudde
authored andcommitted
can: rcar_canfd: Fix page entries in the AFL list
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: dd3bd23 ("can: rcar_canfd: Add Renesas R-Car CAN FD driver") Cc: [email protected] Signed-off-by: Biju Das <[email protected]> Tested-by: Geert Uytterhoeven <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 51f6fc9 commit 1dba0a3

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

drivers/net/can/rcar/rcar_canfd.c

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -787,22 +787,14 @@ static void rcar_canfd_configure_controller(struct rcar_canfd_global *gpriv)
787787
}
788788

789789
static void rcar_canfd_configure_afl_rules(struct rcar_canfd_global *gpriv,
790-
u32 ch)
790+
u32 ch, u32 rule_entry)
791791
{
792-
u32 cfg;
793-
int offset, start, page, num_rules = RCANFD_CHANNEL_NUMRULES;
792+
int offset, page, num_rules = RCANFD_CHANNEL_NUMRULES;
793+
u32 rule_entry_index = rule_entry % 16;
794794
u32 ridx = ch + RCANFD_RFFIFO_IDX;
795795

796-
if (ch == 0) {
797-
start = 0; /* Channel 0 always starts from 0th rule */
798-
} else {
799-
/* Get number of Channel 0 rules and adjust */
800-
cfg = rcar_canfd_read(gpriv->base, RCANFD_GAFLCFG(ch));
801-
start = RCANFD_GAFLCFG_GETRNC(gpriv, 0, cfg);
802-
}
803-
804796
/* Enable write access to entry */
805-
page = RCANFD_GAFL_PAGENUM(start);
797+
page = RCANFD_GAFL_PAGENUM(rule_entry);
806798
rcar_canfd_set_bit(gpriv->base, RCANFD_GAFLECTR,
807799
(RCANFD_GAFLECTR_AFLPN(gpriv, page) |
808800
RCANFD_GAFLECTR_AFLDAE));
@@ -818,13 +810,13 @@ static void rcar_canfd_configure_afl_rules(struct rcar_canfd_global *gpriv,
818810
offset = RCANFD_C_GAFL_OFFSET;
819811

820812
/* Accept all IDs */
821-
rcar_canfd_write(gpriv->base, RCANFD_GAFLID(offset, start), 0);
813+
rcar_canfd_write(gpriv->base, RCANFD_GAFLID(offset, rule_entry_index), 0);
822814
/* IDE or RTR is not considered for matching */
823-
rcar_canfd_write(gpriv->base, RCANFD_GAFLM(offset, start), 0);
815+
rcar_canfd_write(gpriv->base, RCANFD_GAFLM(offset, rule_entry_index), 0);
824816
/* Any data length accepted */
825-
rcar_canfd_write(gpriv->base, RCANFD_GAFLP0(offset, start), 0);
817+
rcar_canfd_write(gpriv->base, RCANFD_GAFLP0(offset, rule_entry_index), 0);
826818
/* Place the msg in corresponding Rx FIFO entry */
827-
rcar_canfd_set_bit(gpriv->base, RCANFD_GAFLP1(offset, start),
819+
rcar_canfd_set_bit(gpriv->base, RCANFD_GAFLP1(offset, rule_entry_index),
828820
RCANFD_GAFLP1_GAFLFDP(ridx));
829821

830822
/* Disable write access to page */
@@ -1851,6 +1843,7 @@ static int rcar_canfd_probe(struct platform_device *pdev)
18511843
unsigned long channels_mask = 0;
18521844
int err, ch_irq, g_irq;
18531845
int g_err_irq, g_recc_irq;
1846+
u32 rule_entry = 0;
18541847
bool fdmode = true; /* CAN FD only mode - default */
18551848
char name[9] = "channelX";
18561849
int i;
@@ -2023,7 +2016,8 @@ static int rcar_canfd_probe(struct platform_device *pdev)
20232016
rcar_canfd_configure_tx(gpriv, ch);
20242017

20252018
/* Configure receive rules */
2026-
rcar_canfd_configure_afl_rules(gpriv, ch);
2019+
rcar_canfd_configure_afl_rules(gpriv, ch, rule_entry);
2020+
rule_entry += RCANFD_CHANNEL_NUMRULES;
20272021
}
20282022

20292023
/* Configure common interrupts */

0 commit comments

Comments
 (0)