On 11/03/2020 11:01, Lokesh Vutla wrote:
Hi Richard,

On 10/03/20 7:02 PM, Richard Cochran wrote:
On Tue, Mar 10, 2020 at 01:17:40PM +0530, Lokesh Vutla wrote:
Timer resolution is entirely dependent on the input clock frequency. 30us
resolution is true only if the input clock frequency of DMTIMER is 32KHz.
AM335x[0] and later TI SoCs provide the following 3 options as the input clocks
to DMTIMERs that we are concerned with:
- Oscillator clock (24MHz in BBB). Resolution is 42ns

That is better.  Still a bit disappointing considering that the
resolution is coarser than the expected synchronization accuracy.

Is this information sufficient to consider for a generic user-space solution :)
Or you have other opinions?

It would be useful.  I can see several moving parts:

You have got the moving parts right. Let me provide the status of each:


- A device tree snippet that configures the clock tree to select
   TIMERx_GCLK source.

PWM omap timer already has this support for selecting the clock[0]


- Somehow arrange for the pulse to appear both as an input to CPTS
   EXTTS and also as an output on a GPIO pin  (device tree covers this?)

Output of DMTIMER(PWM Pulse) is already connected to both CPTS EXTTS and a GPIO
pin. Just pinmux need to be configured properly to capture the pulse on the
scope. DT captures the pinmux part.


- Kernel driver work to configure the DMTIMER (?) (iirc this is missing from 
mainline)

There is already existing pwm omap dmtimer driver. I have recently posted
updates to this driver to be able to change pwm period on the fly [1]. Hoping to
get this merged soon.


- Kernel driver work in CPTS to support PTP_EXTTS_REQUEST (and PTP_PIN_SETFUNC?)

Grygorii (in CC) is already working on that. Patches will be posted soon to ML.

I've posted TI CPSW CPTS updates to enable HW_TS_PUSH events 
(PTP_EXTTS_REQUEST).

PTP_PIN_SETFUNC - there are no direct pins which can be manipulated.



- User space program that:

   - configures pwm via sysfs
   - enables CPTS PHC PIN
   - enables and reads PTP_EXTTS_REQUESTs
   - feeds the offsets into a servo
   - corrects PWM period with servo adjustment via sysfs

This is the userspace program I have worked on to get the synchronization
working. Currently the servo part of the tool is in very hacky shape. Before
cleanup I wanted to get more inputs on where it can be integrated. But anyways
as you said, Ill clean it up and post it as a separate tool. We can then decide
the correct location.

And I'd like to rise additional question here.
The above solution adds PPS generation using  PTP_EXTTS events and PIN output,
but, as per my understanding, there are no way now to feed phc2sys with such 
PPS.
So question is how PPS generated by PTP_EXTTS events can be wired to phc2sys?
 - option1: update phc2sys to accept PTP_EXTTS as PPS
 - option2: allow kernel PHC to generate or PTP_CLOCK_EXTTS/or PTP_CLOCK_PPS/or 
both
   by somehow configuring that PTP_EXTTSx is also PPS.
   Challenge with option 2 is that Kernel PPS configuration is part of
   ptp_clock_register() and so static.




(please comment/correct the above)

I agree that this would be useful.  However, this is really
device-specific stuff and not general purpose.  Possibly we could
publish this in linuxptp under contrib/ or something, but my feeling
is that it really belongs in its own little project.  Does TI have a
github or similar from which to publish?

TI does host all the public code under git.ti.com.


In any case, please do post what you have got to this list.  I am
eager to try it out!

okay. Give me couple of days. Patches will be posted to the list.



[1] https://lkml.org/lkml/2020/3/13/1008
[2] https://patchwork.ozlabs.org/cover/1254708/

--
Best regards,
grygorii


_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to