summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>2026-09-25 13:38:52 +0200
committerJakub Kicinski <kuba@kernel.org>2026-09-30 17:02:01 -0700
commit5b2bb536a3418fe29cd2e8e21eca3d83c833ca6b (patch)
tree43d89bf466c289793f9a77d2ddfbab2cd8d47583
parentcfd0011cb5c2140cc06bcc04a477198a28ffa49e (diff)
downloadlinux-5b2bb536a3418fe29cd2e8e21eca3d83c833ca6b.tar.gz
linux-5b2bb536a3418fe29cd2e8e21eca3d83c833ca6b.zip
net: dsa: microchip: extract ptp_get_pin
The KSZ8463 supports periodic outputs but doesn't handle them in the same way as the other KSZ switches. To add proper support for the KSZ8463, a dedicated ksz8463_ptp_enable_perout() function needs to be created. This function will use the same algorithm to select the output pin as the common ksz_ptp_enable_perout() function. Extract the pin selection algorithm into a dedicated function so it can be used later by the KSZ8463 support. Signed-off-by: Bastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com> Link: https://patch.msgid.link/20260925-ksz-perout-v4-6-d675bd21ce49@bootlin.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r--drivers/net/dsa/microchip/ksz_ptp.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchip/ksz_ptp.c
index fd27e5851003..79520d345efc 100644
--- a/drivers/net/dsa/microchip/ksz_ptp.c
+++ b/drivers/net/dsa/microchip/ksz_ptp.c
@@ -183,6 +183,26 @@ static int ksz_ptp_configure_perout(struct ksz_device *dev,
return 0;
}
+static int ksz_ptp_get_pin(struct ksz_device *dev,
+ struct ptp_perout_request const *request)
+{
+ struct ksz_ptp_data *ptp_data = &dev->ptp_data;
+ int pin;
+
+ if (request->flags & ~PTP_PEROUT_DUTY_CYCLE)
+ return -EOPNOTSUPP;
+
+ if (ptp_data->tou_mode != KSZ_PTP_TOU_PEROUT &&
+ ptp_data->tou_mode != KSZ_PTP_TOU_IDLE)
+ return -EBUSY;
+
+ pin = ptp_find_pin(ptp_data->clock, PTP_PF_PEROUT, request->index);
+ if (pin < 0)
+ return -EINVAL;
+
+ return pin;
+}
+
static int ksz_ptp_enable_perout(struct ksz_device *dev,
struct ptp_perout_request const *request,
int on)
@@ -196,16 +216,9 @@ static int ksz_ptp_enable_perout(struct ksz_device *dev,
u32 data32;
int ret;
- if (request->flags & ~PTP_PEROUT_DUTY_CYCLE)
- return -EOPNOTSUPP;
-
- if (ptp_data->tou_mode != KSZ_PTP_TOU_PEROUT &&
- ptp_data->tou_mode != KSZ_PTP_TOU_IDLE)
- return -EBUSY;
-
- pin = ptp_find_pin(ptp_data->clock, PTP_PF_PEROUT, request->index);
+ pin = ksz_ptp_get_pin(dev, request);
if (pin < 0)
- return -EINVAL;
+ return pin;
data32 = FIELD_PREP(PTP_GPIO_INDEX, pin) |
FIELD_PREP(PTP_TOU_INDEX, request->index);