From: Biju Das <biju.das.jz@bp.renesas.com>
The calculation formula for nominal bit rate of classical CAN is same as
that of nominal bit rate of CANFD on the RZ/G3E SoC compared to other SoCs.
Add shared_bittiming variable to struct rcar_canfd_hw_info to handle this
difference.
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com>
---
v1->v2:
* No change.
---
drivers/net/can/rcar/rcar_canfd.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index b3c8c592fb0e..ce355f79e6b6 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -461,6 +461,7 @@ struct rcar_canfd_hw_info {
unsigned ch_interface_mode:1; /* Has channel interface mode */
unsigned shared_can_regs:1; /* Has shared classical can registers */
unsigned external_clk:1; /* Has external clock */
+ unsigned shared_bittiming:1; /* Has shared nominal bittiming constants */
};
/* Channel priv data */
@@ -632,6 +633,7 @@ static const struct rcar_canfd_hw_info rcar_gen3_hw_info = {
.ch_interface_mode = 0,
.shared_can_regs = 0,
.external_clk = 1,
+ .shared_bittiming = 0,
};
static const struct rcar_canfd_hw_info rcar_gen4_hw_info = {
@@ -649,6 +651,7 @@ static const struct rcar_canfd_hw_info rcar_gen4_hw_info = {
.ch_interface_mode = 1,
.shared_can_regs = 1,
.external_clk = 1,
+ .shared_bittiming = 0,
};
static const struct rcar_canfd_hw_info rzg2l_hw_info = {
@@ -666,6 +669,7 @@ static const struct rcar_canfd_hw_info rzg2l_hw_info = {
.ch_interface_mode = 0,
.shared_can_regs = 0,
.external_clk = 1,
+ .shared_bittiming = 0,
};
static const struct rcar_canfd_hw_info r9a09g047_hw_info = {
@@ -683,6 +687,7 @@ static const struct rcar_canfd_hw_info r9a09g047_hw_info = {
.ch_interface_mode = 1,
.shared_can_regs = 1,
.external_clk = 0,
+ .shared_bittiming = 1,
};
/* Helper functions */
@@ -1912,7 +1917,10 @@ static int rcar_canfd_channel_probe(struct rcar_canfd_global *gpriv, u32 ch,
priv->can.fd.do_get_auto_tdcv = rcar_canfd_get_auto_tdcv;
} else {
/* Controller starts in Classical CAN only mode */
- priv->can.bittiming_const = &rcar_canfd_bittiming_const;
+ if (gpriv->info->shared_bittiming)
+ priv->can.bittiming_const = gpriv->info->nom_bittiming;
+ else
+ priv->can.bittiming_const = &rcar_canfd_bittiming_const;
priv->can.ctrlmode_supported = CAN_CTRLMODE_BERR_REPORTING;
}
--
2.43.0
Hi Biju, On Thu, 21 Aug 2025 at 16:14, Biju <biju.das.au@gmail.com> wrote: > From: Biju Das <biju.das.jz@bp.renesas.com> > > The calculation formula for nominal bit rate of classical CAN is same as > that of nominal bit rate of CANFD on the RZ/G3E SoC compared to other SoCs. > Add shared_bittiming variable to struct rcar_canfd_hw_info to handle this > difference. > > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> > Reviewed-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com> Thanks for your patch! > --- a/drivers/net/can/rcar/rcar_canfd.c > +++ b/drivers/net/can/rcar/rcar_canfd.c > @@ -461,6 +461,7 @@ struct rcar_canfd_hw_info { > unsigned ch_interface_mode:1; /* Has channel interface mode */ > unsigned shared_can_regs:1; /* Has shared classical can registers */ > unsigned external_clk:1; /* Has external clock */ > + unsigned shared_bittiming:1; /* Has shared nominal bittiming constants */ > }; > > /* Channel priv data */ > @@ -632,6 +633,7 @@ static const struct rcar_canfd_hw_info rcar_gen3_hw_info = { > .ch_interface_mode = 0, > .shared_can_regs = 0, > .external_clk = 1, > + .shared_bittiming = 0, > }; > > static const struct rcar_canfd_hw_info rcar_gen4_hw_info = { > @@ -649,6 +651,7 @@ static const struct rcar_canfd_hw_info rcar_gen4_hw_info = { > .ch_interface_mode = 1, > .shared_can_regs = 1, > .external_clk = 1, > + .shared_bittiming = 0, I could find no stricter limitation of the bit timings in classical CAN mode on R-Car Gen4, so it looks like this should be 1, too... > }; > > static const struct rcar_canfd_hw_info rzg2l_hw_info = { > @@ -666,6 +669,7 @@ static const struct rcar_canfd_hw_info rzg2l_hw_info = { > .ch_interface_mode = 0, > .shared_can_regs = 0, > .external_clk = 1, > + .shared_bittiming = 0, > }; > > static const struct rcar_canfd_hw_info r9a09g047_hw_info = { > @@ -683,6 +687,7 @@ static const struct rcar_canfd_hw_info r9a09g047_hw_info = { > .ch_interface_mode = 1, > .shared_can_regs = 1, > .external_clk = 0, > + .shared_bittiming = 1, > }; > > /* Helper functions */ > @@ -1912,7 +1917,10 @@ static int rcar_canfd_channel_probe(struct rcar_canfd_global *gpriv, u32 ch, > priv->can.fd.do_get_auto_tdcv = rcar_canfd_get_auto_tdcv; > } else { > /* Controller starts in Classical CAN only mode */ > - priv->can.bittiming_const = &rcar_canfd_bittiming_const; > + if (gpriv->info->shared_bittiming) ... hence you can just check the existing shared_can_regs flag here, and don't need to introduce a new flag for shared bittimings? > + priv->can.bittiming_const = gpriv->info->nom_bittiming; > + else > + priv->can.bittiming_const = &rcar_canfd_bittiming_const; > priv->can.ctrlmode_supported = CAN_CTRLMODE_BERR_REPORTING; > } Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
© 2016 - 2025 Red Hat, Inc.