[RFC 2/3] Documentation pps.rst: add PPS generators documentation

Rodolfo Giometti posted 3 patches 1 month, 2 weeks ago
There is a newer version of this series
[RFC 2/3] Documentation pps.rst: add PPS generators documentation
Posted by Rodolfo Giometti 1 month, 2 weeks ago
This patch adds some examples about how to register a new PPS
generator in the system, and how to manage it.

Signed-off-by: Rodolfo Giometti <giometti@enneenne.com>
---
 Documentation/driver-api/pps.rst | 40 ++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/Documentation/driver-api/pps.rst b/Documentation/driver-api/pps.rst
index 78dded03e5d8..c71b3b878e41 100644
--- a/Documentation/driver-api/pps.rst
+++ b/Documentation/driver-api/pps.rst
@@ -202,6 +202,46 @@ Sometimes one needs to be able not only to catch PPS signals but to produce
 them also. For example, running a distributed simulation, which requires
 computers' clock to be synchronized very tightly.
 
+To do so the class pps-gen has been added. PPS generators can be
+registered int the kernel by defining a struct pps_gen_source_info as
+follows::
+
+    static struct pps_gen_source_info pps_gen_dummy_info = {
+            .name                   = "dummy",
+            .use_system_clock       = true,
+            .get_time               = pps_gen_dummy_get_time,
+            .enable                 = pps_gen_dummy_enable,
+    };
+
+Where the use_system_clock states if the generator uses the system
+clock to generate its pulses, or from a peripheral device
+clock. Method get_time() is used to query the time stored into the
+generator clock, while the method enable() is used to enable or
+disable the PPS pulse generation.
+
+Then calling the function pps_gen_register_source() in your
+initialization routine as follows a new generator is created into the
+system::
+
+    pps_gen = pps_gen_register_source(&pps_gen_dummy_info);
+
+Generators SYSFS support
+------------------------
+
+If the SYSFS filesystem is enabled in the kernel it provides a new class::
+
+    $ ls /sys/class/pps-gen/
+    pps-gen0/  pps-gen1/  pps-gen2/
+
+Every directory is the ID of a PPS generator defined in the system and
+inside you find several files::
+
+    $ ls -F /sys/class/pps-gen/pps-gen0/
+    dev  enable  name  power/  subsystem@  system  time  uevent
+
+To enable the PPS signal generation you can use the command below::
+
+    $ echo 1 > /sys/class/pps-gen/pps-gen0/enable
 
 Parallel port generator
 ------------------------
-- 
2.34.1
Re: [RFC 2/3] Documentation pps.rst: add PPS generators documentation
Posted by Greg KH 1 month, 2 weeks ago
On Tue, Oct 08, 2024 at 03:50:32PM +0200, Rodolfo Giometti wrote:
> This patch adds some examples about how to register a new PPS
> generator in the system, and how to manage it.
> 
> Signed-off-by: Rodolfo Giometti <giometti@enneenne.com>
> ---
>  Documentation/driver-api/pps.rst | 40 ++++++++++++++++++++++++++++++++

All of this can go into the .c file and autogenerated there, no need for
a separate .rst file that will quickly get out-of-date.

thanks,

greg k-h
Re: [RFC 2/3] Documentation pps.rst: add PPS generators documentation
Posted by Rodolfo Giometti 1 month, 2 weeks ago
On 08/10/24 17:43, Greg KH wrote:
> On Tue, Oct 08, 2024 at 03:50:32PM +0200, Rodolfo Giometti wrote:
>> This patch adds some examples about how to register a new PPS
>> generator in the system, and how to manage it.
>>
>> Signed-off-by: Rodolfo Giometti <giometti@enneenne.com>
>> ---
>>   Documentation/driver-api/pps.rst | 40 ++++++++++++++++++++++++++++++++
> 
> All of this can go into the .c file and autogenerated there, no need for
> a separate .rst file that will quickly get out-of-date.

I see. I'm going to add proper documentation within .c files. But since some 
references about PPS generators are also present in this file, I think it would 
be wise to add some notes about the new interface...

Ciao,

Rodolfo

-- 
GNU/Linux Solutions                  e-mail: giometti@enneenne.com
Linux Device Driver                          giometti@linux.it
Embedded Systems                     phone:  +39 349 2432127
UNIX programming
Re: [RFC 2/3] Documentation pps.rst: add PPS generators documentation
Posted by Greg KH 1 month, 2 weeks ago
On Wed, Oct 09, 2024 at 10:48:18AM +0200, Rodolfo Giometti wrote:
> On 08/10/24 17:43, Greg KH wrote:
> > On Tue, Oct 08, 2024 at 03:50:32PM +0200, Rodolfo Giometti wrote:
> > > This patch adds some examples about how to register a new PPS
> > > generator in the system, and how to manage it.
> > > 
> > > Signed-off-by: Rodolfo Giometti <giometti@enneenne.com>
> > > ---
> > >   Documentation/driver-api/pps.rst | 40 ++++++++++++++++++++++++++++++++
> > 
> > All of this can go into the .c file and autogenerated there, no need for
> > a separate .rst file that will quickly get out-of-date.
> 
> I see. I'm going to add proper documentation within .c files. But since some
> references about PPS generators are also present in this file, I think it
> would be wise to add some notes about the new interface...

Why not just move all of the documentation into the .c files?

thanks,

greg k-h
Re: [RFC 2/3] Documentation pps.rst: add PPS generators documentation
Posted by Rodolfo Giometti 1 month, 2 weeks ago
On 09/10/24 11:14, Greg KH wrote:
> On Wed, Oct 09, 2024 at 10:48:18AM +0200, Rodolfo Giometti wrote:
>> On 08/10/24 17:43, Greg KH wrote:
>>> On Tue, Oct 08, 2024 at 03:50:32PM +0200, Rodolfo Giometti wrote:
>>>> This patch adds some examples about how to register a new PPS
>>>> generator in the system, and how to manage it.
>>>>
>>>> Signed-off-by: Rodolfo Giometti <giometti@enneenne.com>
>>>> ---
>>>>    Documentation/driver-api/pps.rst | 40 ++++++++++++++++++++++++++++++++
>>>
>>> All of this can go into the .c file and autogenerated there, no need for
>>> a separate .rst file that will quickly get out-of-date.
>>
>> I see. I'm going to add proper documentation within .c files. But since some
>> references about PPS generators are also present in this file, I think it
>> would be wise to add some notes about the new interface...
> 
> Why not just move all of the documentation into the .c files?

I see, but this is another story. :-P

At the moment I prefer to just add a note here about the new interface, and 
later we can do what you suggest.

Ciao,

Rodolfo

-- 
GNU/Linux Solutions                  e-mail: giometti@enneenne.com
Linux Device Driver                          giometti@linux.it
Embedded Systems                     phone:  +39 349 2432127
UNIX programming