diff mbox series

[net-next] ptp: ocp: Fix PTP_PF_* verification requests

Message ID 20220315194626.1895-1-jonathan.lemon@gmail.com (mailing list archive)
State Accepted
Commit 05fc65f3f5e45e8194e16b8e43e92133ada06e26
Delegated to: Netdev Maintainers
Headers show
Series [net-next] ptp: ocp: Fix PTP_PF_* verification requests | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 3 of 3 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 47 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Jonathan Lemon March 15, 2022, 7:46 p.m. UTC
Update and check functionality for pin configuration requests:

PTP_PF_NONE: requests "IN: None", disabling the pin.

  # testptp -d /dev/ptp3 -L3,0 -i1
  set pin function okay
  # cat sma4
  IN: None

PTP_PF_EXTTS: should configure external timestamps, but since the
timecard can steer inputs to multiple inputs as well as timestamps,
allow the request, but don't change configurations.

  # testptp -d /dev/ptp3 -L3,1 -i1
  set pin function okay

  (no functional or configuration change here yet)

PTP_PF_PEROUT: Channel 0 is the PHC, at 1PPS.  Channels 1-4 are
the programmable frequency generators.

  # fails because period is not 1PPS.
  # testptp -d /dev/ptp3 -L3,2 -i0  -p 500000000
  PTP_PEROUT_REQUEST: Invalid argument

  # testptp -d /dev/ptp3 -L3,2 -i0  -p 1000000000
  periodic output request okay
  # cat sma4
  OUT: PHC

  # testptp -d /dev/ptp3 -L3,2 -i1 -p 500000000 -w 200000000
  periodic output request okay
  # cat sma4
  OUT: GEN1
  # cat gen1/signal
  500000000 40 0 1 2022-03-10T23:55:26 TAI
  # cat gen1/running
  1

  # testptp -d /dev/ptp3 -L3,2 -i1 -p 0
  periodic output request okay
  # cat gen1/running
  0

Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com>
---
 drivers/ptp/ptp_ocp.c | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org March 17, 2022, 9:50 a.m. UTC | #1
Hello:

This patch was applied to netdev/net-next.git (master)
by Paolo Abeni <pabeni@redhat.com>:

On Tue, 15 Mar 2022 12:46:26 -0700 you wrote:
> Update and check functionality for pin configuration requests:
> 
> PTP_PF_NONE: requests "IN: None", disabling the pin.
> 
>   # testptp -d /dev/ptp3 -L3,0 -i1
>   set pin function okay
>   # cat sma4
>   IN: None
> 
> [...]

Here is the summary with links:
  - [net-next] ptp: ocp: Fix PTP_PF_* verification requests
    https://git.kernel.org/netdev/net-next/c/05fc65f3f5e4

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 56b04a7bba3a..d8cefc89a588 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -970,13 +970,25 @@  ptp_ocp_verify(struct ptp_clock_info *ptp_info, unsigned pin,
 	struct ptp_ocp *bp = container_of(ptp_info, struct ptp_ocp, ptp_info);
 	char buf[16];
 
-	if (func != PTP_PF_PEROUT)
+	switch (func) {
+	case PTP_PF_NONE:
+		sprintf(buf, "IN: None");
+		break;
+	case PTP_PF_EXTTS:
+		/* Allow timestamps, but require sysfs configuration. */
+		return 0;
+	case PTP_PF_PEROUT:
+		/* channel 0 is 1PPS from PHC.
+		 * channels 1..4 are the frequency generators.
+		 */
+		if (chan)
+			sprintf(buf, "OUT: GEN%d", chan);
+		else
+			sprintf(buf, "OUT: PHC");
+		break;
+	default:
 		return -EOPNOTSUPP;
-
-	if (chan)
-		sprintf(buf, "OUT: GEN%d", chan);
-	else
-		sprintf(buf, "OUT: PHC");
+	}
 
 	return ptp_ocp_sma_store(bp, buf, pin + 1);
 }
@@ -2922,7 +2934,7 @@  _signal_summary_show(struct seq_file *s, struct ptp_ocp *bp, int nr)
 		return;
 
 	on = signal->running;
-	sprintf(label, "GEN%d", nr);
+	sprintf(label, "GEN%d", nr + 1);
 	seq_printf(s, "%7s: %s, period:%llu duty:%d%% phase:%llu pol:%d",
 		   label, on ? " ON" : "OFF",
 		   signal->period, signal->duty, signal->phase,
@@ -2947,7 +2959,7 @@  _frequency_summary_show(struct seq_file *s, int nr,
 	if (!reg)
 		return;
 
-	sprintf(label, "FREQ%d", nr);
+	sprintf(label, "FREQ%d", nr + 1);
 	val = ioread32(&reg->ctrl);
 	on = val & 1;
 	val = (val >> 8) & 0xff;