Re: [PATCH v8] can: usb: IXXAT USB-to-CAN adapters drivers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Markus,

On Wed. 24 May 2023 at 20:24, Markus Marb <marm@xxxxxxxxxxxxxxx> wrote:
> Hi,
>
> > If you do not have the hardware specification (or at least the documentation of ixxat_canbtp->tdo) then it will be hard for you to do anything here.
> The tdo field is documented in our windows drivers manual[1]. The socketcan driver seems to use CAN_BTMODE_RAW(IXXAT_USB_BTMODE_NAT), so the hardware specific number of CAN clock cycles is expected here.
>
> From the manual:
> wTDO:
> Offset to the transceiver delay (or Secondary Sample Point SSP) that is
> automatically determined by the controller. Value is only relevant with fast data
> bit rate. If in field dwMode the bit CAN_BTMODE_RAW is set, the hardware
> specific number of CAN clock cycles is expected here. If not, the value defines
> the Secondary Sample Point (SSP) in relation to the total number of time quanta
> per bit (example: if wTS1+wTS2=100 and wTDO=65 the SSP is 65% of a bit time).
> Value 0 deactivates the SSP.
>
> [1]: https://www.ixxat.com/docs/librariesprovider8/ixxat-english-new/pc-can-interfaces/02---windows-drivers/vci-v4.0.1133.0-windows-11-10.zip?sfvrsn=2d1dfdd7_20
> See "./VCI V4.0.1133.0 - Windows 11, 10/Manuals/VCI V4 C-CanFD Software Design Guide English.pdf"

This seems enough to implement the feature. Unless documented
elsewhere, it seems that you have no TDCV or TDCF support. So
something like that should do the job:

  static const struct can_tdc_const es58x_tdc_const = {
          .tdcv_min = 0,
          .tdcv_max = 0, /* Manual mode not supported. */
          .tdco_min = <Minimum value wTDO can take, should be
documented somewhere>,
          .tdco_max = <Maximum value wTDO can take, should be
documented somewhere>,
          .tdcf_min = 0,
          .tdcf_max = 0, /* Manual mode not supported. */
};

Look at the doc of struct can_tdc and can_tdc_const for the details:

  https://elixir.bootlin.com/linux/v6.3/source/include/linux/can/bittiming.h#L20

Then add the CAN_CTRLMODE_TDC_AUTO capabilities.

Finally, using it should be something in this spirit:

  if (can_tdc_is_enabled(&priv->can)) {
          ixxat_canbtp->tdo = cpu_to_le16(priv->can.tdc.tdco);
  } else {
          ixxat_canbtp->tdo = 0;
  }

The else branch can be omitted in case you already memset()
ixxat_canbtp to zero.

You can test it by running your device at the maximum supported data
bitrate. Below ip command should show you the tdco value:

  ip --details link show can0

> Please note that for example the simplified SSP positioning (setting tdo to 0XFFFF) described in the document is handled in the windows driver and not in the device firmware, so it cannot be used here.

That part will be out of scope of the linux driver, I guess.

> Best regards
> Markus



[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux