Re: [PATCH net-next 3/3] ptp: ptp_clockmatrix: Add adjphase() to support PHC write phase mode.

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

 



On Wed, Apr 29, 2020 at 08:28:25PM -0400, vincent.cheng.xh@xxxxxxxxxxx wrote:
> @@ -871,6 +880,69 @@ static int idtcm_set_pll_mode(struct idtcm_channel *channel,
>  
>  /* PTP Hardware Clock interface */
>  
> +/**
> + * @brief Maximum absolute value for write phase offset in picoseconds
> + *
> + * Destination signed register is 32-bit register in resolution of 50ps
> + *
> + * 0x7fffffff * 50 =  2147483647 * 50 = 107374182350
> + */
> +static int _idtcm_adjphase(struct idtcm_channel *channel, s32 deltaNs)
> +{
> +	struct idtcm *idtcm = channel->idtcm;
> +
> +	int err;
> +	u8 i;
> +	u8 buf[4] = {0};
> +	s32 phaseIn50Picoseconds;
> +	s64 phaseOffsetInPs;

Kernel coding style uses lower_case_underscores rather than lowerCamelCase.

> +
> +	if (channel->pll_mode != PLL_MODE_WRITE_PHASE) {
> +
> +		kthread_cancel_delayed_work_sync(
> +			&channel->write_phase_ready_work);
> +
> +		err = idtcm_set_pll_mode(channel, PLL_MODE_WRITE_PHASE);
> +
> +		if (err)
> +			return err;
> +
> +		channel->write_phase_ready = 0;
> +
> +		kthread_queue_delayed_work(channel->kworker,
> +					   &channel->write_phase_ready_work,
> +					   msecs_to_jiffies(WR_PHASE_SETUP_MS));

Each PHC driver automatically has a kworker provided by the class
layer.  In order to use it, set ptp_clock_info.do_aux_work to your
callback function and then call ptp_schedule_worker() when needed.

See drivers/net/ethernet/ti/cpts.c for example.

Thanks,
Richard




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux