Re: [PATCH 1/2] can: gs_usb: hardware timestamp support

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

 



On 26.08.2022 12:46:28, Marc Kleine-Budde wrote:
> +void gs_usb_timestamp_init(struct gs_can *dev)
> +{
> +	struct cyclecounter *cc = &dev->cc;
> +
> +	cc->read = gs_usb_timestamp_read;
> +	cc->mask = CYCLECOUNTER_MASK(32);
> +	cc->shift = 1;

Using

| cc->shift = 32 - bits_per(NSEC_PER_SEC / GSUSB_TIMESTAMP_TIMER_HZ);

gives the max precision. If you want for example to tune the gs_usb's
clock against the Linux system clock (which needs some extra code
though...).

> +	cc->mult = clocksource_hz2mult(GSUSB_TIMESTAMP_TIMER_HZ, cc->shift);
> +
> +	timecounter_init(&dev->tc, &dev->cc, ktime_get_real_ns());
> +
> +	INIT_DELAYED_WORK(&dev->timestamp, gs_usb_timestamp_work);
> +	schedule_delayed_work(&dev->timestamp,
> +			      GSUSB_TIMESTAMP_WORK_DELAY_SEC * HZ);
> +}

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

Attachment: signature.asc
Description: PGP signature


[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