@@ -502,6 +502,7 @@
struct rcar_canfd_global;
struct rcar_canfd_hw_info {
+ u8 rnc_field_width;
u8 max_channels;
u8 postdiv;
/* hardware features */
@@ -578,18 +579,21 @@ static const struct can_bittiming_const rcar_canfd_bittiming_const = {
};
static const struct rcar_canfd_hw_info rcar_gen3_hw_info = {
+ .rnc_field_width = 8,
.max_channels = 2,
.postdiv = 2,
.shared_global_irqs = 1,
};
static const struct rcar_canfd_hw_info rcar_gen4_hw_info = {
+ .rnc_field_width = 16,
.max_channels = 8,
.postdiv = 2,
.shared_global_irqs = 1,
};
static const struct rcar_canfd_hw_info rzg2l_hw_info = {
+ .rnc_field_width = 8,
.max_channels = 2,
.postdiv = 1,
.multi_channel_irqs = 1,
@@ -675,9 +679,10 @@ static void rcar_canfd_tx_failure_cleanup(struct net_device *ndev)
static void rcar_canfd_setrnc(struct rcar_canfd_global *gpriv, unsigned int ch,
unsigned int num_rules)
{
- unsigned int shift = reg_gen4(gpriv, 16, 24) - (ch & 1) * reg_gen4(gpriv, 16, 8);
+ unsigned int rnc_stride = 32 / gpriv->info->rnc_field_width;
+ unsigned int shift = 32 - (ch % rnc_stride + 1) * gpriv->info->rnc_field_width;
+ unsigned int w = ch / rnc_stride;
u32 rnc = num_rules << shift;
- unsigned int w = ch / 2;
rcar_canfd_set_bit(gpriv->base, RCANFD_GAFLCFG(w), rnc);
}