[PATCH net v6 2/8] net: dsa: sja1105: keep pin function on PEROUT disable

From: Ahmad Byagowi

Date: Thu Nov 26 2026 - 11:42:50 EST


From: ahmadexp <ahmadexp@xxxxxxxxx>

Disabling periodic output currently selects PTP_PF_PEROUT even when the shared PTP_CLK pin is configured for external timestamping. Only select the PEROUT function when enabling the output; disable should stop the generator without reprogramming the pin.

A coding assistant helped identify this related pin-direction side effect, develop the correction and regression test, and prepare this changelog. The source-derived test checks the actual callback behavior with configuration writes stubbed.

Fixes: 747e5eb31d59 ("net: dsa: sja1105: configure the PTP_CLK pin as EXT_TS or PER_OUT")
Signed-off-by: Ahmad Byagowi <ahmadexp@xxxxxxxxx>
---
drivers/net/dsa/sja1105/sja1105_ptp.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/dsa/sja1105/sja1105_ptp.c b/drivers/net/dsa/sja1105/sja1105_ptp.c
index da35805152e0..7c07f76caccf 100644
--- a/drivers/net/dsa/sja1105/sja1105_ptp.c
+++ b/drivers/net/dsa/sja1105/sja1105_ptp.c
@@ -733,9 +733,11 @@ static int sja1105_per_out_enable(struct sja1105_private *priv,

mutex_lock(&ptp_data->lock);

- rc = sja1105_change_ptp_clk_pin_func(priv, PTP_PF_PEROUT);
- if (rc)
- goto out;
+ if (on) {
+ rc = sja1105_change_ptp_clk_pin_func(priv, PTP_PF_PEROUT);
+ if (rc)
+ goto out;
+ }

if (on) {
struct timespec64 pin_duration_ts = {
--
2.54.0 (Apple Git-157)