All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Cochran <richardcochran@gmail.com>
To: vincent.cheng.xh@renesas.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net-next 3/3] ptp: ptp_clockmatrix: Add adjphase() to support PHC write phase mode.
Date: Thu, 30 Apr 2020 20:56:01 -0700	[thread overview]
Message-ID: <20200501035601.GC31749@localhost> (raw)
In-Reply-To: <1588206505-21773-4-git-send-email-vincent.cheng.xh@renesas.com>

On Wed, Apr 29, 2020 at 08:28:25PM -0400, vincent.cheng.xh@renesas.com 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


  reply	other threads:[~2020-05-01  3:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-30  0:28 [PATCH net-next 0/3] ptp: Add adjust phase to support phase offset vincent.cheng.xh
2020-04-30  0:28 ` [PATCH net-next 1/3] ptp: Add adjphase function to support phase offset control vincent.cheng.xh
2020-05-01  3:37   ` Richard Cochran
2020-05-01 13:48     ` Vincent Cheng
2020-04-30  0:28 ` [PATCH net-next 2/3] ptp: Add adjust_phase to ptp_clock_caps capability vincent.cheng.xh
2020-05-01  3:38   ` Richard Cochran
2020-04-30  0:28 ` [PATCH net-next 3/3] ptp: ptp_clockmatrix: Add adjphase() to support PHC write phase mode vincent.cheng.xh
2020-05-01  3:56   ` Richard Cochran [this message]
2020-05-01 13:51     ` Vincent Cheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200501035601.GC31749@localhost \
    --to=richardcochran@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=vincent.cheng.xh@renesas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.