From: Ahmad Byagowi <ahmadexp@gmail.com>
To: netdev@vger.kernel.org
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
jonathan.lemon@gmail.com, kuba@kernel.org, pabeni@redhat.com,
richardcochran@gmail.com, vadim.fedorenko@linux.dev
Subject: [PATCH net v7 4/7] ptp: ocp: recover SMA direction from both enable bits on bind
Date: Fri, 27 Nov 2026 11:22:59 -0800 [thread overview]
Message-ID: <20261127-timecard-driver-v7-4-ahmadexp@gmail.com> (raw)
In-Reply-To: <20261127-timecard-driver-v7-0-ahmadexp@gmail.com>
An IN: None request clears the input register. On bind, interpreting
a clear input enable bit as an enabled output (SMA1/SMA2) loses the
disabled state that is already represented by the register pair.
For configurable FB and ADVA connectors, use both enable bits. An
enabled input or output selects the corresponding direction. If
both are clear, report the disabled connector as IN: None. Keep
the existing per-connector default if both bits are set, and leave
fixed-direction hardware unchanged. Probe does not rewrite the mux.
Developed with coding-assistant support using v6 review feedback.
Fixes: b2c4f0ac53f3 ("ptp: ocp: Add ability to disable input selectors.")
Link: https://lore.kernel.org/r/179579808276.3135.5382400825629748441@kernel.org
Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
---
drivers/ptp/ptp_ocp.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 3781f6582b7b..6cf060d3b1a1 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -2926,13 +2926,22 @@ ptp_ocp_sma_fb_init(struct ptp_ocp *bp)
for (i = 0; i < OCP_SMA_NUM; i++)
bp->sma[i].fixed_dir = true;
} else {
- reg = ioread32(&bp->sma_map1->gpio1);
- bp->sma[0].mode = reg & BIT(15) ? SMA_MODE_IN : SMA_MODE_OUT;
- bp->sma[1].mode = reg & BIT(31) ? SMA_MODE_IN : SMA_MODE_OUT;
+ u32 inputs[] = { ioread32(&bp->sma_map1->gpio1),
+ ioread32(&bp->sma_map2->gpio1) };
+ u32 outputs[] = { reg, ioread32(&bp->sma_map1->gpio2) };
- reg = ioread32(&bp->sma_map1->gpio2);
- bp->sma[2].mode = reg & BIT(15) ? SMA_MODE_OUT : SMA_MODE_IN;
- bp->sma[3].mode = reg & BIT(31) ? SMA_MODE_OUT : SMA_MODE_IN;
+ for (i = 0; i < OCP_SMA_NUM; i++) {
+ u32 mask = SMA_ENABLE << (16 * (i & 1));
+ bool input = inputs[i / 2] & mask;
+ bool output = outputs[i / 2] & mask;
+
+ bp->sma[i].disabled = !input && !output;
+ /* If both are active, retain this connector's default. */
+ if (!output)
+ bp->sma[i].mode = SMA_MODE_IN;
+ else if (!input)
+ bp->sma[i].mode = SMA_MODE_OUT;
+ }
}
}
--
2.54.0 (Apple Git-157)
next prev parent reply other threads:[~2026-11-27 19:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 19:22 [PATCH net v7 0/7] ptp: fix OCP routes and SJA1105 pin direction Ahmad Byagowi
2026-11-27 19:22 ` [PATCH net v7 1/7] net: dsa: sja1105: keep pin function on EXTTS disable Ahmad Byagowi
2026-11-27 19:22 ` [PATCH net v7 2/7] net: dsa: sja1105: keep pin function on PEROUT disable Ahmad Byagowi
2026-11-27 19:22 ` [PATCH net v7 3/7] ptp: ocp: preserve timestamp routes on DPLL frequency changes Ahmad Byagowi
2026-11-27 19:22 ` Ahmad Byagowi [this message]
2026-11-27 19:23 ` [PATCH net v7 5/7] ptp: ocp: report disabled SMA inputs as zero Hz Ahmad Byagowi
2026-11-27 19:23 ` [PATCH net v7 6/7] ptp: ocp: correct the DCF output frequency Ahmad Byagowi
2026-11-27 19:23 ` [PATCH net v7 7/7] ptp: ocp: match ART DPLL frequencies to selectors Ahmad Byagowi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261127-timecard-driver-v7-4-ahmadexp@gmail.com \
--to=ahmadexp@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=jonathan.lemon@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=vadim.fedorenko@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox