Re: [PATCH v8 4/7] can: Add Nuvoton NCT6694 CANFD support

From: Ming Yu
Date: Thu Mar 27 2025 - 01:31:27 EST


Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx> 於 2025年3月27日 週四 上午1:35寫道:
>
> > > > +static int nct6694_can_start(struct net_device *ndev)
> > > > +{
> > > > + struct nct6694_can_priv *priv = netdev_priv(ndev);
> > > > + const struct can_bittiming *d_bt = &priv->can.data_bittiming;
> > > > + const struct can_bittiming *n_bt = &priv->can.bittiming;
> > > > + struct nct6694_can_setting *setting __free(kfree) = NULL;
> > > > + const struct nct6694_cmd_header cmd_hd = {
> > > > + .mod = NCT6694_CAN_MOD,
> > > > + .cmd = NCT6694_CAN_SETTING,
> > > > + .sel = ndev->dev_port,
> > > > + .len = cpu_to_le16(sizeof(*setting))
> > > > + };
> > > > + int ret;
> > > > +
> > > > + setting = kzalloc(sizeof(*setting), GFP_KERNEL);
> > > > + if (!setting)
> > > > + return -ENOMEM;
> > > > +
> > > > + setting->nbr = cpu_to_le32(n_bt->bitrate);
> > > > + setting->dbr = cpu_to_le32(d_bt->bitrate);
> > >
> > > I just noticed one thing that needs clarification/documentation.
> > >
> > > You have nct6694_can_bittiming_nominal_const and
> > > nct6694_can_bittiming_data_const, but only pass the bit rates to your
> > > device.
> > >
> > > Do the bit timing const really reflect the HW limitations of your
> > > device?
> > >
> > > Are you sure your device uses the same algorithm as the kernel and
> > > calculates the same bit timing parameters as the kernel, so that the
> > > values given to the user space reflects the bit timing parameter chosen
> > > by your device?
> > >
> >
> > Originally, I only intended to provide NBR and DBR for user
> > configuration. In the next patch, I will add code to configure
> > NBTP(Nominal Bit Timing Prescaler) and DBTP(Data Bit Timing Prescaler)
> > based on the setting of nct6694_can_bittiming_nominal_const and
> > nct6694_can_bittiming_data_const.
>
> Sounds good, but this doesn't answer my questions:
>
> You have nct6694_can_bittiming_nominal_const and
> nct6694_can_bittiming_data_const, but only pass the bit rates and the
> prescaler to your device.
>

I understand.
The prescaler field is used to calculate sjw, brp, prop_seg,
phase_seg1 and phase_seg2. I will update the code in the next patch.


Thanks,
Ming