On Thu, Nov 12, 2015 at 11:16 AM, Richard Cochran <richardcoch...@gmail.com>
wrote:

> On Thu, Nov 12, 2015 at 10:15:04AM -0600, Bassam Alsanie wrote:
> > and my custom clock I can compute the frequency shift as the following:
> >
> >     __u16 fraction = ((__u64) tx.freq & 0x0000ffff);
> >     __u16 integer  = (__u64) tx.freq >> 16;
> > __u64 requestedPpb = (integer * 1000) + fraction;
> >
> > __s64 freqShiftInHz = (__u64) (currentFreq * requestedPpb) / kPpb;
> >
> > where, currentFreq is the current centrer frequency of the clock (mine is
> > around 100 MHz)
> >
> >
> > Thoughts?
>
> Why would you do that?  The kernel PHC subsystem already converts the
> adjustment value into ppb for you.
>
> Look at include/linux/ptp_clock_kernel.h:
>
> /**
>  * struct ptp_clock_info - decribes a PTP hardware clock
>  *
>    ...
>  * clock operations
>  *
>  * @adjfreq:  Adjusts the frequency of the hardware clock.
>  *            parameter delta: Desired frequency offset from nominal
> frequency
>  *            in parts per billion
>    ...
>  */
>
> struct ptp_clock_info {
>         ...
>         int (*adjfreq)(struct ptp_clock_info *ptp, s32 delta);
>         ...
> };
>
> I suggest that you:
>
> 1. read the PHC header file to learn the API, and
> 2. look at a few PHC drivers to see how it is done.
>

I will be going over the PHC APIs and some of the kernel PHC modules to get
deeper understand.
Just to let you know why my questions seem little bit weird. I am working
on developing a user mode framework for to accessing the hardware (for
rapid prototyping). I found its useful to develop a user mode code to
access the custom clock (can take as low as one day of development time)
then update the linuxptp (ptp4l) to adjust the frequency on the clock using
the user-mode code, instead of calling into the PHC framework which require
kernel support.
This is not permanent solution nor to replace the current PHC framework,
its just to characterise the hardware and perform some initial tests in a
very short time. Then after that move to follow the PHC model to make the
final implementation.

Thank you
Bassam,
------------------------------------------------------------------------------
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to