mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-21 23:04:54 -04:00
can: rcar_canfd: Simplify data bit rate config
Introduce rcar_canfd_compute_data_bit_rate_cfg() for simplifying data bit rate configuration by replacing function-like macros. Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> Link: https://patch.msgid.link/20250908120940.147196-5-biju.das.jz@bp.renesas.com Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
committed by
Marc Kleine-Budde
parent
02d274adf4
commit
33815032b0
@@ -169,15 +169,7 @@
|
||||
#define RCANFD_CERFL_ERR(x) ((x) & (0x7fff)) /* above bits 14:0 */
|
||||
|
||||
/* RSCFDnCFDCmDCFG */
|
||||
#define RCANFD_DCFG_DSJW(gpriv, x) (((x) & ((gpriv)->info->data_bittiming->sjw_max - 1)) << 24)
|
||||
|
||||
#define RCANFD_DCFG_DTSEG2(gpriv, x) \
|
||||
(((x) & ((gpriv)->info->data_bittiming->tseg2_max - 1)) << (gpriv)->info->sh->dtseg2)
|
||||
|
||||
#define RCANFD_DCFG_DTSEG1(gpriv, x) \
|
||||
(((x) & ((gpriv)->info->data_bittiming->tseg1_max - 1)) << (gpriv)->info->sh->dtseg1)
|
||||
|
||||
#define RCANFD_DCFG_DBRP(x) (((x) & 0xff) << 0)
|
||||
#define RCANFD_DCFG_DBRP GENMASK(7, 0)
|
||||
|
||||
/* RSCFDnCFDCmFDCFG */
|
||||
#define RCANFD_GEN4_FDCFG_CLOE BIT(30)
|
||||
@@ -1401,6 +1393,19 @@ static inline u32 rcar_canfd_compute_nominal_bit_rate_cfg(struct rcar_canfd_chan
|
||||
return (ntseg1 | ntseg2 | nsjw | nbrp);
|
||||
}
|
||||
|
||||
static inline u32 rcar_canfd_compute_data_bit_rate_cfg(const struct rcar_canfd_hw_info *info,
|
||||
u16 tseg1, u16 tseg2, u16 sjw, u16 brp)
|
||||
{
|
||||
u32 dtseg1, dtseg2, dsjw, dbrp;
|
||||
|
||||
dtseg1 = (tseg1 & (info->data_bittiming->tseg1_max - 1)) << info->sh->dtseg1;
|
||||
dtseg2 = (tseg2 & (info->data_bittiming->tseg2_max - 1)) << info->sh->dtseg2;
|
||||
dsjw = (sjw & (info->data_bittiming->sjw_max - 1)) << 24;
|
||||
dbrp = FIELD_PREP(RCANFD_DCFG_DBRP, brp);
|
||||
|
||||
return (dtseg1 | dtseg2 | dsjw | dbrp);
|
||||
}
|
||||
|
||||
static void rcar_canfd_set_bittiming(struct net_device *ndev)
|
||||
{
|
||||
u32 mask = RCANFD_FDCFG_TDCO | RCANFD_FDCFG_TDCE | RCANFD_FDCFG_TDCOC;
|
||||
@@ -1430,10 +1435,7 @@ static void rcar_canfd_set_bittiming(struct net_device *ndev)
|
||||
sjw = dbt->sjw - 1;
|
||||
tseg1 = dbt->prop_seg + dbt->phase_seg1 - 1;
|
||||
tseg2 = dbt->phase_seg2 - 1;
|
||||
|
||||
cfg = (RCANFD_DCFG_DTSEG1(gpriv, tseg1) | RCANFD_DCFG_DBRP(brp) |
|
||||
RCANFD_DCFG_DSJW(gpriv, sjw) | RCANFD_DCFG_DTSEG2(gpriv, tseg2));
|
||||
|
||||
cfg = rcar_canfd_compute_data_bit_rate_cfg(gpriv->info, tseg1, tseg2, sjw, brp);
|
||||
writel(cfg, &gpriv->fcbase[ch].dcfg);
|
||||
|
||||
/* Transceiver Delay Compensation */
|
||||
|
||||
Reference in New Issue
Block a user