Re: [PATCH v3 10/15] can: grcan: Add saving and restoring of CAN FD baud-rate registers

Marc Kleine-Budde
2026-01-23T14:00:17Z

[-- Attachment #1: Type: text/plain, Size: 1911 bytes --]

On 22.01.2026 13:10:33, Arun Muthusamy wrote:
> From: Daniel Hellstrom <daniel@gaisler.com>
>
> While reset the GRCAN baud-rates are preserved, since GRCANFD has the
> baud-rate in different registers we need to add saving of those
> registers too.
>
> Signed-off-by: Daniel Hellstrom <daniel@gaisler.com>
> Signed-off-by: Arun Muthusamy <arun.muthusamy@gaisler.com>
> ---
> drivers/net/can/grcan.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c
> index a2a5a5c868ff..0ee6e9bfbe7f 100644
> --- a/drivers/net/can/grcan.c
> +++ b/drivers/net/can/grcan.c
> @@ -517,15 +517,27 @@ static void grcan_reset(struct net_device *dev)
> struct grcan_priv *priv = netdev_priv(dev);
> struct grcan_registers __iomem *regs = priv->regs;
> u32 config = grcan_read_reg(&regs->conf);
> + u32 nbtr, fdbtr;
> +
> + if (priv->hwcap->fd) {
> + nbtr = grcan_read_reg(&regs->nbtr);

Why do you save nbtr....

> + fdbtr = grcan_read_reg(&regs->fdbtr);

Who writes fdbtr in the first place?

> + }
>
> grcan_set_bits(&regs->ctrl, GRCAN_CTRL_RESET);
> grcan_write_reg(&regs->conf, config);
> + if (priv->hwcap->fd) {
> + grcan_write_reg(&regs->nbtr, nbtr);
> + grcan_write_reg(&regs->fdbtr, fdbtr);
> + }
>
> priv->eskbp = grcan_read_reg(&regs->txrd);
> priv->can.state = CAN_STATE_STOPPED;
>
> /* Turn off hardware filtering - regs->rxcode set to 0 by reset */
> grcan_write_reg(&regs->rxmask, 0);
> +
> + priv->hwcap->set_bittiming(dev);

...if you configure the bit timing again, wich writes nbtr?

regards,
Marc

--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]