Discussion:
[Linuxptp-devel] [PATCH RFC] phc2sys: enable PPS output from PHC
Jiri Benc
2013-04-18 12:32:59 UTC
Permalink
PPS output from sfc driver has to be enabled by PTP_ENABLE_PPS ioctl. This
is also documented in Documentation/ptp/testptp.c in the kernel source. Call
the ioctl when both PHC device and PPS device are specified.

Signed-off-by: Jiri Benc <***@redhat.com>
---
I couldn't get PPS with sfc working without this patch. Am I missing
something?
---
phc2sys.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/phc2sys.c b/phc2sys.c
index 93495a4..f835e1d 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -652,6 +652,14 @@ int main(int argc, char *argv[])
usage(progname);
return -1;
}
+ if (pps_fd && src != CLOCK_INVALID) {
+ int enable = 1;
+
+ if (ioctl(CLOCKID_TO_FD(src), PTP_ENABLE_PPS, enable) < 0) {
+ fprintf(stderr, "failed to enable PPS on a PHC\n");
+ return -1;
+ }
+ }

if (dst_clock.stats_max_count > 0) {
dst_clock.offset_stats = stats_create();
--
1.7.6.5
Keller, Jacob E
2013-04-18 20:30:36 UTC
Permalink
-----Original Message-----
Sent: Thursday, April 18, 2013 5:33 AM
Subject: [Linuxptp-devel] [PATCH RFC] phc2sys: enable PPS output from
PHC
PPS output from sfc driver has to be enabled by PTP_ENABLE_PPS ioctl. This
is also documented in Documentation/ptp/testptp.c in the kernel source. Call
the ioctl when both PHC device and PPS device are specified.
---
I couldn't get PPS with sfc working without this patch. Am I missing
something?
---
phc2sys.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/phc2sys.c b/phc2sys.c
index 93495a4..f835e1d 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -652,6 +652,14 @@ int main(int argc, char *argv[])
usage(progname);
return -1;
}
+ if (pps_fd && src != CLOCK_INVALID) {
+ int enable = 1;
+
+ if (ioctl(CLOCKID_TO_FD(src), PTP_ENABLE_PPS, enable)
< 0) {
+ fprintf(stderr, "failed to enable PPS on a
PHC\n");
+ return -1;
+ }
+ }
if (dst_clock.stats_max_count > 0) {
dst_clock.offset_stats = stats_create();
--
1.7.6.5
This is a good idea. I usually had a different tool enable pps, but it is probably a good
idea to enable it here. I would suggest using the get capabilities ioctl, to see if PPS is
supported, and only attempt to enable it if it is supported for that PTP device.
Example code can be found in the testptp.c file in the kernel source code under
Documentation/ptp

- Jake
Miroslav Lichvar
2013-04-19 07:54:35 UTC
Permalink
Post by Jiri Benc
PPS output from sfc driver has to be enabled by PTP_ENABLE_PPS ioctl. This
is also documented in Documentation/ptp/testptp.c in the kernel source. Call
the ioctl when both PHC device and PPS device are specified.
---
I couldn't get PPS with sfc working without this patch. Am I missing
something?
I used to enable it by echo 1 > /sys/.... It will be nice if it's done
automatically.
Post by Jiri Benc
@@ -652,6 +652,14 @@ int main(int argc, char *argv[])
usage(progname);
return -1;
}
+ if (pps_fd && src != CLOCK_INVALID) {
+ int enable = 1;
+
+ if (ioctl(CLOCKID_TO_FD(src), PTP_ENABLE_PPS, enable) < 0) {
+ fprintf(stderr, "failed to enable PPS on a PHC\n");
+ return -1;
+ }
+ }
I'd suggest to move the ioctl call to do_pps_loop(), use pr_warning()
to print the error message, but not exit on the error to allow using a
separate PPS device with a PHC.

Thanks,
--
Miroslav Lichvar
Loading...