On 10/31/2022 6:20 AM, Maciek Machnikowski wrote:
On Thu, Oct 27, 2022 at 03:32:48AM -0700, Jacob Keller wrote:
Add a new function to phc_ctl to display the devices pin configuration
data. First, obtain the device capabilities to determine the number of
pins. Then, for each pin, print the name, function, and channel
information.
Signed-off-by: Jacob Keller <jacob.e.kel...@intel.com>
---
phc_ctl.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 73 insertions(+)
diff --git a/phc_ctl.c b/phc_ctl.c
index 92e597c40a23..1d1b0ab61020 100644
--- a/phc_ctl.c
+++ b/phc_ctl.c
@@ -114,6 +114,7 @@ static void usage(const char *progname)
" freq [ppb] adjust PHC frequency (default returns current
offset)\n"
" cmp compare PHC offset to CLOCK_REALTIME\n"
" caps display device capabilities (default if no
command given)\n"
+ " pin_cfg display device pin configuration\n"
Can we change it to pins_get or pins_cfg_get to be able to add set in the
future?
Also s/pin/pins/g
Yep, I'll fix that for v2.
+ pr_notice("device has %d configurable input/output pins",
+ caps.n_pins);
+
+ /* For each pin, read its configuration */
+ for (index = 0; index < caps.n_pins; index++) {
+ memset(&pin_desc, 0, sizeof(pin_desc));
+ pin_desc.index = index;
+
+ if (ioctl(CLOCKID_TO_FD(clkid), PTP_PIN_GETFUNC, &pin_desc)) {
+ pr_warning("get pin configuration for pin %d failed:
%s",
+ index,
+ strerror(errno));
+ /* keep going */
+ continue;
+ }
+
+ if (pin_desc.func == PTP_PF_NONE) {
+ pr_notice("pin %d [%s] is not configured",
+ pin_desc.index,
+ pin_desc.name);
+ } else {
+ pr_notice("pin %d [%s] performing %s using channel %d",
Remove "performing" to avoid wordiness :)
But a very useful addition!
I'll shorten this up a little.
Thanks,
Jake
Regards
Maciek
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel