From nobody Sat Sep 26 17:09:07 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BAD542AFAA for ; Mon, 31 Aug 2026 13:25:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788182735; cv=none; b=SKSTKIcnGal6RjqM/EKlXjTpanvUp9KocRG14LnEtDjRt40hPEOyTG6Qmsccp18v/D/DDDG1/UIxsBvqMlhWIMel32+ESYcLIVxPe5NMSjJEN8hEmwk+sC7l1MC6mIvWR0f3lMrdEc5LFOeZjka/+Cui96UmksJ3n/RTwAwdWk8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788182735; c=relaxed/simple; bh=d04wpqsohMxtT46GB5OwdPPMJTzhM7T/Scb1AeqpBKA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ViKtUd/tN9AcM+oiIft7DR0Y7nTe712ir0fkZbyMhuBppnehdRJjb1+MK9oJNZ71BjfV/oEC37eRJ+XgnwVDHQnYgPoJoofxi2BsAfJLIg2X5cVxbVh4lGkFSUvY88wQ34D00nuPqGU++DeRI1sf0ThEIEWWxPNfZaX3aO2mAKA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=FfNhmqkV; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="FfNhmqkV" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id C66604E41480; Mon, 31 Aug 2026 13:25:31 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 94AD560231; Mon, 31 Aug 2026 13:25:31 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 97AD411C78C5F; Mon, 31 Aug 2026 15:25:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1788182730; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=44OE30qyZdWSpo3MMeDedIEJG4P6WUx7rEu5KOCgtO0=; b=FfNhmqkVRenbd+MRx+0pOFNtLNCvArdK4n95I8JZAMZlddSYPbI1KzNTd2Bqgva9LJLlnW 5IfeMeOpt+h8LKhLJTPqy23ZxUmFr9dGEuFNRVsnzezPOailtzcFHvlIQWvlConMLzcz5v HfvQh+wKWCWsIAxkrJKFfE2njrOwfEXeU0H8f9tGLlUP8PmCs+q8Pv34uLEHgnzHcbXeoL CmSgiHU2Ks/W8nTY3SyM9EWqOMA0vbNXi6mQQ+ihfO7s+oiyDYvM7LfXXWsb69Qp/VsJ9R /WX34I8JDmpmjJXKz6hgJrtnY/lryRx1lVm2JMyQ2+1uV/N0dQCOrOR6VEJ5DA== From: "Bastien Curutchet (Schneider Electric)" Date: Mon, 31 Aug 2026 15:25:23 +0200 Subject: [PATCH net-next 01/10] net: dsa: microchip: add the number of pins to chip infos Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260831-ksz-perout-v1-1-14202db763b3@bootlin.com> References: <20260831-ksz-perout-v1-0-14202db763b3@bootlin.com> In-Reply-To: <20260831-ksz-perout-v1-0-14202db763b3@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 The number of periodic output pins available is hardcoded to 2 while KSZ8463 has 12 pins that can be used as periodic outputs. Add an n_pin attribute to the struct ksz_chip_data to make this setting configurable. Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz_common.c | 1 + drivers/net/dsa/microchip/ksz_common.h | 1 + drivers/net/dsa/microchip/ksz_ptp.c | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index 1a9d6f83a023..55d1e3e3c529 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -1194,6 +1194,7 @@ const struct ksz_chip_data ksz_switch_chips[] =3D { .ptp_capable =3D true, .wr_table =3D &ksz8563_register_set, .rd_table =3D &ksz8563_register_set, + .n_pins =3D 2, }, =20 [KSZ8795] =3D { diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/micro= chip/ksz_common.h index cbe98494578c..c678fc6597dc 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -139,6 +139,7 @@ struct ksz_chip_data { u8 sgmii_port; const struct regmap_access_table *wr_table; const struct regmap_access_table *rd_table; + const u8 n_pins; }; =20 struct ksz_irq { diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchi= p/ksz_ptp.c index 39cc70d65900..c92936bf78d3 100644 --- a/drivers/net/dsa/microchip/ksz_ptp.c +++ b/drivers/net/dsa/microchip/ksz_ptp.c @@ -1050,14 +1050,14 @@ int ksz_ptp_clock_register(struct dsa_switch *ds) ptp_data->caps.do_aux_work =3D ksz_ptp_do_aux_work; ptp_data->caps.enable =3D ksz_ptp_enable; ptp_data->caps.verify =3D ksz_ptp_verify_pin; - ptp_data->caps.n_pins =3D KSZ_PTP_N_GPIO; + ptp_data->caps.n_pins =3D dev->info->n_pins; ptp_data->caps.n_per_out =3D 3; =20 ret =3D ksz_ptp_start_clock(dev); if (ret) return ret; =20 - for (i =3D 0; i < KSZ_PTP_N_GPIO; i++) { + for (i =3D 0; i < dev->info->n_pins; i++) { struct ptp_pin_desc *ptp_pin =3D &ptp_data->pin_config[i]; =20 snprintf(ptp_pin->name, --=20 2.55.0 From nobody Sat Sep 26 17:09:07 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F046242B301 for ; Mon, 31 Aug 2026 13:25:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788182737; cv=none; b=oF7NK8IWSvtWTw+BKO/+jMiCCFXgdLHdIXsOB4OBSUVc/zZ54vImMjB44cXzvSB/M5aPZj18NzocVubRemFvNcfa3sNNnn+SA19BJfoAC+MoqlhDWhC63X7I4PvJ+npIIvMgQxAL1ou1nCIXpdJOSXtg6D6IP4Q8qyYHLF0hAlA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788182737; c=relaxed/simple; bh=P/UMv5H6zbtVnNRcI0dxKxNZpVVHnXAJ61vPuF1fZAI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FE46VDJ/c2/K/w00Ew6HQHujafkgmAXADUpxkn2W2mvSKHF2dZ31k+7wrcmOSIvZ/6/mngx1ZZWFblOr5bJZmlLc9gc7X0Osx6jqk4UVCLrLJcsDHtaZIT6qkpz/c8pfRKZTOw5sIZ9NG1ISsX8jrb8MPYcR+YkW0pbNwF9q6fo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=RnbH4I39; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="RnbH4I39" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 8DB4D1A191E; Mon, 31 Aug 2026 13:25:33 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 61F2660231; Mon, 31 Aug 2026 13:25:33 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1CF2E11C783F8; Mon, 31 Aug 2026 15:25:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1788182732; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=1MxpOXIUTCRRJoPPX0UBHlVCsOVhuvqrmli9AWb4L64=; b=RnbH4I39/xSljrZxoGq6o/9VemRF3WRMHUwsb/kKkRc+F+NJVrDwiPa6DUvFWI235RRY1+ 4lcUUQtwIcik8QAKcXJkw9Ak1wulfVhx+OFmmILoqXIvNuI5neqHMELZ4yDKGIKkoAa4Pr Afs7aP9vzKUUxHEXQEV4b70852emQo9VwA8hDYAWJJstMGS0DhLe0fNpjATqgT2zAItqVV vsPwYEraNIn/O1IC9CfoqI/Rg26Z4rrHEd4nqEYugNVs/En0ziC7tEfyjsK8z30eKwrJaR PK4OQDAcfTgnvIEkw1UFr2mreRWfI87OrDTpsp+OcXM3FivvRzB7ymFnvxtpYA== From: "Bastien Curutchet (Schneider Electric)" Date: Mon, 31 Aug 2026 15:25:24 +0200 Subject: [PATCH net-next 02/10] net: dsa: microchip: add the number of periodic signals to chip infos Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260831-ksz-perout-v1-2-14202db763b3@bootlin.com> References: <20260831-ksz-perout-v1-0-14202db763b3@bootlin.com> In-Reply-To: <20260831-ksz-perout-v1-0-14202db763b3@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 The number of periodic signals available is hardcoded to 3 while KSZ8463 can produce 12 different periodic signals. Add an n_per_out attribute to the struct ksz_chip_data to make this setting configurable. Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz_common.c | 1 + drivers/net/dsa/microchip/ksz_common.h | 1 + drivers/net/dsa/microchip/ksz_ptp.c | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index 55d1e3e3c529..194c88cdd00b 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -1195,6 +1195,7 @@ const struct ksz_chip_data ksz_switch_chips[] =3D { .wr_table =3D &ksz8563_register_set, .rd_table =3D &ksz8563_register_set, .n_pins =3D 2, + .n_per_out =3D 3, }, =20 [KSZ8795] =3D { diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/micro= chip/ksz_common.h index c678fc6597dc..1155b39350c2 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -140,6 +140,7 @@ struct ksz_chip_data { const struct regmap_access_table *wr_table; const struct regmap_access_table *rd_table; const u8 n_pins; + const u8 n_per_out; }; =20 struct ksz_irq { diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchi= p/ksz_ptp.c index c92936bf78d3..f80015250e5a 100644 --- a/drivers/net/dsa/microchip/ksz_ptp.c +++ b/drivers/net/dsa/microchip/ksz_ptp.c @@ -1051,7 +1051,7 @@ int ksz_ptp_clock_register(struct dsa_switch *ds) ptp_data->caps.enable =3D ksz_ptp_enable; ptp_data->caps.verify =3D ksz_ptp_verify_pin; ptp_data->caps.n_pins =3D dev->info->n_pins; - ptp_data->caps.n_per_out =3D 3; + ptp_data->caps.n_per_out =3D dev->info->n_per_out; =20 ret =3D ksz_ptp_start_clock(dev); if (ret) --=20 2.55.0 From nobody Sat Sep 26 17:09:07 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9891142E407 for ; Mon, 31 Aug 2026 13:25:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788182738; cv=none; b=e+izeRFriAen5UxpVqt3w6sKVWVFCztAzkh3uLCycr0HVSYUxvWLnNhFiW/7RlEEYpuOnK++2s1xBOkWxADT0lu6pOasemG36bebkNUEIrosSSEjTL2YCTOTKOxlT7KxqlNGa/5Cq56+JFpCuXJ4ZJ7RVm92bF4keahfogAqARY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788182738; c=relaxed/simple; bh=HkXxTB72wQCMpzYwUnwAJU9KwsD3ZJwAbFrv0fPqNd8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=u8vOUJJ53KgRyI59v9GvN/S8ZXWw1JWJgfUVpcymqS6jU/JaWDi58oCoXvrNF5N6OK4T9XGCfW2VmgJaUGwMiY0FGLQAW4HZ69cvYEVV5drYyR1Ug/HF3AOXgsQS5EQln9rmKHHya86VovJ4u1vvLpzg2yXy1FAtAufKFQ9Thww= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=xR8yMutY; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="xR8yMutY" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id DC9721A191F; Mon, 31 Aug 2026 13:25:34 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id AB32360231; Mon, 31 Aug 2026 13:25:34 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B310811C78B96; Mon, 31 Aug 2026 15:25:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1788182733; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=OUS3SdUwNSk48tuvVvsVFTUNr9za3nsJwxnsYhhP2sM=; b=xR8yMutYsque89ValjlL01hm9mGxgQh39pYSb7xs968dGYukL8omyZztecG6HL9pWRqQC7 fdxSomoDlX3JWgAPziZ9npXESsAm+dsY19kKBV5T//I2y8iaeEq/vNOiuXZ0hf5QKkaYGV 8ZOQwkg2J50w5vI2HPgJhx5340/WnDlSNAGG0PqnzUi/GaL6svC8UEc6Huibmi+Pndk9Vo uRIvlOHm1PJ3AYZmzOwso7EMCGbpZWB+Zo0Pr6J4o2Vmqc/GPOqDWVK5+ayVE8svRL5o2h 37ZuVjA3vKmPHom5N6x0GFcBTnwrOdJ2zC289mTiwttwfNEvTNzF0/rKPuxP2Q== From: "Bastien Curutchet (Schneider Electric)" Date: Mon, 31 Aug 2026 15:25:25 +0200 Subject: [PATCH net-next 03/10] net: dsa: microchip: use dynamic mask to check pulse width validity Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260831-ksz-perout-v1-3-14202db763b3@bootlin.com> References: <20260831-ksz-perout-v1-0-14202db763b3@bootlin.com> In-Reply-To: <20260831-ksz-perout-v1-0-14202db763b3@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 The pulse width validity is checked against an hardcoded mask. KSZ8463 uses a smaller register than other switches so this check won't work for it. Move the mask as a ksz_ptp_tou_pulse_verify()'s input to allow changing it for KSZ8463 case. Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz_ptp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchi= p/ksz_ptp.c index f80015250e5a..7bf83e0b5918 100644 --- a/drivers/net/dsa/microchip/ksz_ptp.c +++ b/drivers/net/dsa/microchip/ksz_ptp.c @@ -86,7 +86,7 @@ static int ksz_ptp_tou_reset(struct ksz_device *dev, u8 u= nit) 0); } =20 -static int ksz_ptp_tou_pulse_verify(u64 pulse_ns) +static int ksz_ptp_tou_pulse_verify(u64 pulse_ns, u32 mask) { u32 data; =20 @@ -94,7 +94,7 @@ static int ksz_ptp_tou_pulse_verify(u64 pulse_ns) return -EINVAL; =20 data =3D (pulse_ns / 8); - if (!FIELD_FIT(TRIG_PULSE_WIDTH_M, data)) + if ((mask & data) !=3D data) return -ERANGE; =20 return 0; @@ -245,7 +245,7 @@ static int ksz_ptp_enable_perout(struct ksz_device *dev, KSZ_MAX_PULSE_WIDTH); } =20 - ret =3D ksz_ptp_tou_pulse_verify(pulse_width_ns); + ret =3D ksz_ptp_tou_pulse_verify(pulse_width_ns, TRIG_PULSE_WIDTH_M); if (ret) return ret; =20 --=20 2.55.0 From nobody Sat Sep 26 17:09:07 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E67642F70E; Mon, 31 Aug 2026 13:25:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788182740; cv=none; b=fTEV5dMsSSpgM8aBLbPyo2y5npqX81la8GczqJEqnSD2dSQLAX3V8dOGeGahw9eWVxk5hgTAjEI507QHIT0jG3PFV9EiZtWaCRcTtFBBx1uIQ0u/Sb4FRq/NgjN1oy9OmmzabPQXTo9uvFEtGFBxzrDpMdz0TKMT0QHXnUipiy8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788182740; c=relaxed/simple; bh=4ov+NSQSBX9Qvd8THsxWYSJTFFg1Yr0ldf+mlrYxNTE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rOOAbZnEy7prm0NcCKzD8MNSut3ux6ZUANe5DB85hsyyH3KYO9dkWQDI/7jOGe47qvDQQ8RWUc2e83LdxwPkiTiWEmBzwcc4Py4q9rejdyD5TJ+ps2JaAtP0yxTt5j1Um60kwyZ4f8+talaQjk2RKg9vmqf+KkUIB+4veO39Dis= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=T0ufBtNl; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="T0ufBtNl" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id A850C1A191A; Mon, 31 Aug 2026 13:25:36 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 6E9CC60231; Mon, 31 Aug 2026 13:25:36 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 2D0B211C78D63; Mon, 31 Aug 2026 15:25:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1788182735; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=RZ7rb6VbA9/VWHZ6BBtewbfE+bCLAayiZRWpfJptYvM=; b=T0ufBtNlv0elzhk2vn0MjIjGpT65c169J12XtMUivXfF5+yBYbmbNlRDqEBjLBsSI1bzt1 /VzWKZ5der1ikdFB3W51rx6SHBjSs8qDZRt/wG9Nj1mf7xW5+JWH/xaSFb7HW4F5X/77hG 87twW178bAATjA68wMDkIgat75SSvwJr7cvDmb80YdeIt/wcnTMAm82lWbHJxDPEgWF2YH u8y2Ql7IePHr51iYljD7xfM8IXGRJFx7H3d3R/yAyV7Dy9PaVH0rZwEyovd5rzYwnjksyS mK8p/QbCSHbcKVYJRFD1fXpMe3tkX8110hCywy5ztvN9h0OGbo6NV2WhSZmfjg== From: "Bastien Curutchet (Schneider Electric)" Date: Mon, 31 Aug 2026 15:25:26 +0200 Subject: [PATCH net-next 04/10] net: dsa: microchip: extract PTP callbacks configuration from PTP registration Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260831-ksz-perout-v1-4-14202db763b3@bootlin.com> References: <20260831-ksz-perout-v1-0-14202db763b3@bootlin.com> In-Reply-To: <20260831-ksz-perout-v1-0-14202db763b3@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 KSZ8463 also has periodic output capabilities but the way its outputs are driven differs from the other switches. It will need its own set of PTP callbacks to implements this behaviour. Extract the PTP callbacks configuration in a dedicated function to be called before the PTP registration to ease the use of others callbacks when needed. Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz8.c | 2 ++ drivers/net/dsa/microchip/ksz9477.c | 1 + drivers/net/dsa/microchip/ksz_ptp.c | 20 ++++++++++++++------ drivers/net/dsa/microchip/ksz_ptp.h | 2 ++ drivers/net/dsa/microchip/lan937x_main.c | 1 + 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/k= sz8.c index 941ae9f66f70..f2a23e2e474a 100644 --- a/drivers/net/dsa/microchip/ksz8.c +++ b/drivers/net/dsa/microchip/ksz8.c @@ -2478,6 +2478,7 @@ static int ksz8463_setup(struct dsa_switch *ds) if (ret) goto free_girq; =20 + ksz_ptp_set_caps(ds); ret =3D ksz_ptp_clock_register(ds); if (ret) { dev_err(dev->dev, "Failed to register PTP clock: %d\n", @@ -2775,6 +2776,7 @@ static int ksz8_setup(struct dsa_switch *ds) } =20 if (dev->info->ptp_capable) { + ksz_ptp_set_caps(ds); ret =3D ksz_ptp_clock_register(ds); if (ret) { dev_err(dev->dev, "Failed to register PTP clock: %d\n", diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchi= p/ksz9477.c index 3ee995545c57..72528a53b67d 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -1781,6 +1781,7 @@ static int ksz9477_setup(struct dsa_switch *ds) } =20 if (dev->info->ptp_capable) { + ksz_ptp_set_caps(ds); ret =3D ksz_ptp_clock_register(ds); if (ret) { dev_err(dev->dev, "Failed to register PTP clock: %d\n", diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchi= p/ksz_ptp.c index 7bf83e0b5918..ea22601f6b26 100644 --- a/drivers/net/dsa/microchip/ksz_ptp.c +++ b/drivers/net/dsa/microchip/ksz_ptp.c @@ -1028,17 +1028,12 @@ static int ksz_ptp_start_clock(struct ksz_device *d= ev) return 0; } =20 -int ksz_ptp_clock_register(struct dsa_switch *ds) +void ksz_ptp_set_caps(struct dsa_switch *ds) { struct ksz_device *dev =3D ds->priv; - const u16 *regs =3D dev->info->regs; struct ksz_ptp_data *ptp_data; - int ret; - u8 i; =20 ptp_data =3D &dev->ptp_data; - mutex_init(&ptp_data->lock); - spin_lock_init(&ptp_data->clock_lock); =20 ptp_data->caps.owner =3D THIS_MODULE; snprintf(ptp_data->caps.name, 16, "Microchip Clock"); @@ -1052,6 +1047,19 @@ int ksz_ptp_clock_register(struct dsa_switch *ds) ptp_data->caps.verify =3D ksz_ptp_verify_pin; ptp_data->caps.n_pins =3D dev->info->n_pins; ptp_data->caps.n_per_out =3D dev->info->n_per_out; +} + +int ksz_ptp_clock_register(struct dsa_switch *ds) +{ + struct ksz_device *dev =3D ds->priv; + const u16 *regs =3D dev->info->regs; + struct ksz_ptp_data *ptp_data; + int ret; + u8 i; + + ptp_data =3D &dev->ptp_data; + mutex_init(&ptp_data->lock); + spin_lock_init(&ptp_data->clock_lock); =20 ret =3D ksz_ptp_start_clock(dev); if (ret) diff --git a/drivers/net/dsa/microchip/ksz_ptp.h b/drivers/net/dsa/microchi= p/ksz_ptp.h index 7067ec9bd1e6..89716b31596b 100644 --- a/drivers/net/dsa/microchip/ksz_ptp.h +++ b/drivers/net/dsa/microchip/ksz_ptp.h @@ -33,6 +33,7 @@ struct ksz_ptp_data { struct timespec64 perout_period; }; =20 +void ksz_ptp_set_caps(struct dsa_switch *ds); int ksz_ptp_clock_register(struct dsa_switch *ds); =20 void ksz_ptp_clock_unregister(struct dsa_switch *ds); @@ -65,6 +66,7 @@ struct ksz_ptp_data { struct mutex lock; }; =20 +static inline void ksz_ptp_set_caps(struct dsa_switch *ds) { } static inline int ksz_ptp_clock_register(struct dsa_switch *ds) { return 0; diff --git a/drivers/net/dsa/microchip/lan937x_main.c b/drivers/net/dsa/mic= rochip/lan937x_main.c index 86ce3a86705f..3a209122fc7d 100644 --- a/drivers/net/dsa/microchip/lan937x_main.c +++ b/drivers/net/dsa/microchip/lan937x_main.c @@ -867,6 +867,7 @@ static int lan937x_setup(struct dsa_switch *ds) } } =20 + ksz_ptp_set_caps(ds); ret =3D ksz_ptp_clock_register(ds); if (ret) { dev_err(dev->dev, "Failed to register PTP clock: %d\n", --=20 2.55.0 From nobody Sat Sep 26 17:09:07 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BAD6E431A23 for ; Mon, 31 Aug 2026 13:25:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788182742; cv=none; b=cwgwWpCYSpHlcxhlriY8vwMsirN9ZThIVNA+hykb0kKY3CJDKdBqqQ0idDCvdWYgM9itl6BTV0qFuFYTamerAqY3mPyUNxgduf2DndrYoA4+vrn8AfU4Hw+q9rw1o/11Ok7fdabrTvglxYyBnVDqac4yRO9tWptTiRoIKhv88rc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788182742; c=relaxed/simple; bh=8G7v58vm4MsYglvYir8IarLbnRs5ks3dw3PAJnTs2gU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uDaW2RB0pMDTFOVwKGUR77vh0uHyPvnFqKlhYhUL9D9CqDomG5+XvPHbzOKyBseNMmKhFLif3DU0aXjNr2ToYOPpzTX0+K5l4EDnJ7QXJhMWe43SzpIbc0Hg23/0w9pRyTwzwmfwhLeX03YS3u1hRtDhkQwryxS85b3/3a92Duk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=GRag/eW7; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="GRag/eW7" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 59A601A191B; Mon, 31 Aug 2026 13:25:38 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 2E3EF60231; Mon, 31 Aug 2026 13:25:38 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id DBE7811C78D6B; Mon, 31 Aug 2026 15:25:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1788182737; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=o9jL6igQLJRDua5JaF1IyEJ/zeHLPSI/dmv7m8kdRo8=; b=GRag/eW7QCChVCagJn3HhZ10uDVbLGKR8KS91GCmRMqpGoq5yHaCdE8bxGL9tOf/eKX05O i1DcdsmSEzo0UCnoq5pslTyLxHP/fFgs1TtlraoNPh3wRJENoOIkv27bzLopXj8h+ahbGM NrXChSPPc5UUCW0o1lOlVbhMeOMtcuHfIY2Vx6raAaAV4QlFMbZYL8HlfKh6f3D/p3K8Y9 Kqfc28MnEYbwU5kQsnjXHwLfifKxTMOBjPeCYvTB2T41aIFhXvAdYSXMr+QVPnyp1pi10D lzx4IRit2MuQMDv/LFKDWYr44rwpvwUzFp+umQHqaG9A5XGWEVIf6Aj52DIJLg== From: "Bastien Curutchet (Schneider Electric)" Date: Mon, 31 Aug 2026 15:25:27 +0200 Subject: [PATCH net-next 05/10] net: dsa: microchip: extract ptp_get_pin Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260831-ksz-perout-v1-5-14202db763b3@bootlin.com> References: <20260831-ksz-perout-v1-0-14202db763b3@bootlin.com> In-Reply-To: <20260831-ksz-perout-v1-0-14202db763b3@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 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) --- drivers/net/dsa/microchip/ksz_ptp.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchi= p/ksz_ptp.c index ea22601f6b26..f97ea9d69ebc 100644 --- a/drivers/net/dsa/microchip/ksz_ptp.c +++ b/drivers/net/dsa/microchip/ksz_ptp.c @@ -183,17 +183,11 @@ static int ksz_ptp_configure_perout(struct ksz_device= *dev, return 0; } =20 -static int ksz_ptp_enable_perout(struct ksz_device *dev, - struct ptp_perout_request const *request, - int on) +static int ksz_ptp_get_pin(struct ksz_device *dev, + struct ptp_perout_request const *request) { struct ksz_ptp_data *ptp_data =3D &dev->ptp_data; - u64 req_pulse_width_ns; - u64 cycle_width_ns; - u64 pulse_width_ns; - int pin =3D 0; - u32 data32; - int ret; + int pin; =20 if (request->flags & ~PTP_PEROUT_DUTY_CYCLE) return -EOPNOTSUPP; @@ -206,6 +200,25 @@ static int ksz_ptp_enable_perout(struct ksz_device *de= v, if (pin < 0) return -EINVAL; =20 + return pin; +} + +static int ksz_ptp_enable_perout(struct ksz_device *dev, + struct ptp_perout_request const *request, + int on) +{ + struct ksz_ptp_data *ptp_data =3D &dev->ptp_data; + u64 req_pulse_width_ns; + u64 cycle_width_ns; + u64 pulse_width_ns; + int pin =3D 0; + u32 data32; + int ret; + + pin =3D ksz_ptp_get_pin(dev, request); + if (pin < 0) + return pin; + data32 =3D FIELD_PREP(PTP_GPIO_INDEX, pin) | FIELD_PREP(PTP_TOU_INDEX, request->index); ret =3D ksz_rmw32(dev, REG_PTP_UNIT_INDEX__4, --=20 2.55.0 From nobody Sat Sep 26 17:09:07 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8EE6E433042; Mon, 31 Aug 2026 13:25:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788182743; cv=none; b=nKGrVHITVAKJdtgbwsulF/xRAcL/3bjhQY+DlPabq01yhRJ57QwdL0cAsmp7u/FkbjoNpmd5yuTxvTOmCcTfaE/5Bjgmg+41Cs/YlaaV16iD5IdB5qvlLq86o10w8UZ4ci0BzXB8RsoiID5IygE0PRvSJUW2IHPEn1tska0xjZs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788182743; c=relaxed/simple; bh=vXKUgJKXsx7Kv49NZnrrFQ+yzUjOQ+zLrt/7kLCcoPE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TPU9sSrfpgBWipdSC6wZMuzd6dsjIosi7TzbTe3AZ5zYYeVK//SGjm18bQ79HpVSIYtADplUAYHyRluhm3ZRawMtooPH0loTKRjdmXd39+cc1UK+3Krh/6i7kZEkSK53msSlmSfFxCK9H2hE37Orhol9FlhEQEMBtYRDrLRDBhw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=R2ZzFZkO; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="R2ZzFZkO" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id F2C491A191E; Mon, 31 Aug 2026 13:25:39 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id C6A1060231; Mon, 31 Aug 2026 13:25:39 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 61F7111C78B96; Mon, 31 Aug 2026 15:25:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1788182738; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=mpkRRBCGYrpAM2XmasON5pHjjfU5MVVzSv16ATHoLl8=; b=R2ZzFZkO/VXHIGSYC2f9pMrBVww1GNqjp8UzFn7/rDmv+0XjRKdmUG4QS0vA+c9ejS82kH plxgxHpKea4lA/YB4hcIgwrrgsfcQettW9XH29E1fdGugoKEL9+KVgsk3szv4eY1YqO6pE T+jYUDhKYs95ZkXwQp3t6nZXqCBNs0Z03iPdtTsBxv+/AYSaq8osT6MW0+0nRpPbO2KMaO mdC6On5qe6My9VD/QjQKyVZvoPkmzO/JeE2uwMiB0NbJ/bA1EMG5SsrkEPd6UyedCw8mZe bFD27s0nyQGWkotIvdK7R6fU4SeNURLGJ7TVxHay1XQrVXV56DSwfHDbUbcZNA== From: "Bastien Curutchet (Schneider Electric)" Date: Mon, 31 Aug 2026 15:25:28 +0200 Subject: [PATCH net-next 06/10] net: dsa: microchip: extract compute_width Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260831-ksz-perout-v1-6-14202db763b3@bootlin.com> References: <20260831-ksz-perout-v1-0-14202db763b3@bootlin.com> In-Reply-To: <20260831-ksz-perout-v1-0-14202db763b3@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 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 compute the periodic cycles as the common ksz_ptp_enable_perout() function. Extract these algorithms into dedicated functions so they can be used later by the KSZ8463 support. Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz_ptp.c | 67 ++++++++++++++++++++++++---------= ---- 1 file changed, 43 insertions(+), 24 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchi= p/ksz_ptp.c index f97ea9d69ebc..2f141df65eb0 100644 --- a/drivers/net/dsa/microchip/ksz_ptp.c +++ b/drivers/net/dsa/microchip/ksz_ptp.c @@ -203,12 +203,49 @@ static int ksz_ptp_get_pin(struct ksz_device *dev, return pin; } =20 +static int ksz_ptp_compute_perout_cycle(struct ksz_device *dev, + struct ptp_perout_request const *request, + u64 *cycle_width_ns) +{ + struct ksz_ptp_data *ptp_data =3D &dev->ptp_data; + + ptp_data->perout_target_time_first.tv_sec =3D request->start.sec; + ptp_data->perout_target_time_first.tv_nsec =3D request->start.nsec; + + ptp_data->perout_period.tv_sec =3D request->period.sec; + ptp_data->perout_period.tv_nsec =3D request->period.nsec; + + *cycle_width_ns =3D timespec64_to_ns(&ptp_data->perout_period); + if ((*cycle_width_ns & TRIG_CYCLE_WIDTH_M) !=3D *cycle_width_ns) { + *cycle_width_ns =3D 0; + return -EINVAL; + } + + return 0; +} + +static u64 ksz_ptp_compute_perout_pulse(struct ksz_device *dev, + struct ptp_perout_request const *request, + u64 max_pulse_width) +{ + u64 req_pulse_width_ns; + + if (request->flags & PTP_PEROUT_DUTY_CYCLE) + return request->on.sec * NSEC_PER_SEC + request->on.nsec; + + /* Use a duty cycle of 50%. Maximum pulse width supported by the + * hardware is a little bit more than 125 ms. + */ + req_pulse_width_ns =3D (request->period.sec * NSEC_PER_SEC + + request->period.nsec) / 2; + return min_t(u64, req_pulse_width_ns, max_pulse_width); +} + static int ksz_ptp_enable_perout(struct ksz_device *dev, struct ptp_perout_request const *request, int on) { struct ksz_ptp_data *ptp_data =3D &dev->ptp_data; - u64 req_pulse_width_ns; u64 cycle_width_ns; u64 pulse_width_ns; int pin =3D 0; @@ -234,29 +271,11 @@ static int ksz_ptp_enable_perout(struct ksz_device *d= ev, ptp_data->tou_mode =3D KSZ_PTP_TOU_IDLE; return 0; } - - ptp_data->perout_target_time_first.tv_sec =3D request->start.sec; - ptp_data->perout_target_time_first.tv_nsec =3D request->start.nsec; - - ptp_data->perout_period.tv_sec =3D request->period.sec; - ptp_data->perout_period.tv_nsec =3D request->period.nsec; - - cycle_width_ns =3D timespec64_to_ns(&ptp_data->perout_period); - if ((cycle_width_ns & TRIG_CYCLE_WIDTH_M) !=3D cycle_width_ns) - return -EINVAL; - - if (request->flags & PTP_PEROUT_DUTY_CYCLE) { - pulse_width_ns =3D request->on.sec * NSEC_PER_SEC + - request->on.nsec; - } else { - /* Use a duty cycle of 50%. Maximum pulse width supported by the - * hardware is a little bit more than 125 ms. - */ - req_pulse_width_ns =3D (request->period.sec * NSEC_PER_SEC + - request->period.nsec) / 2; - pulse_width_ns =3D min_t(u64, req_pulse_width_ns, - KSZ_MAX_PULSE_WIDTH); - } + ret =3D ksz_ptp_compute_perout_cycle(dev, request, &cycle_width_ns); + if (ret) + return ret; + pulse_width_ns =3D ksz_ptp_compute_perout_pulse(dev, request, + KSZ_MAX_PULSE_WIDTH); =20 ret =3D ksz_ptp_tou_pulse_verify(pulse_width_ns, TRIG_PULSE_WIDTH_M); if (ret) --=20 2.55.0 From nobody Sat Sep 26 17:09:07 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3509F415B68; Mon, 31 Aug 2026 13:25:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788182745; cv=none; b=Jf2IPYL+8MldZ6EGUJ4wzsaU4LuXFlbKgvWXF7fEV8L/rdu3c1M/PqlbDN3wy3wYXkN8dhg49NWEnfmyD8nihoPbX/f8Na0hXX+C6clxIhdEsmNEVDWny3fmcJCElnRIfz3P8HT37ShxTAidPwzlrHYNrWjt8bw3pN+7lBjGQaE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788182745; c=relaxed/simple; bh=j1+ZBVJmPVW03bJXf/56FabNKgWY7EFAGihdRcW3d0M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=E34EQvCipNtKN3LOmpJt/FRXlHRzmxEKVZlb4VeVQOx7f2k43Mcl3W9a52KOyakPqIn4LJoRzGbdrUmqBSxyvviwSCxJm3qCWMnlL+xFd9g6i4z1LwP/pudH9upywh3NCq+NXHF4NfGWpBtkuwH07sIKMzm8Ts3XgR8zRY2Te4s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=vgI9QscX; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="vgI9QscX" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id A8B7D4E41480; Mon, 31 Aug 2026 13:25:41 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 7D47E60231; Mon, 31 Aug 2026 13:25:41 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 432BA11C78D63; Mon, 31 Aug 2026 15:25:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1788182740; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=B3aS/Mr7RC/ZOcg+EzhbjQUCCCKDV341PmBKKjmtwgs=; b=vgI9QscXXtXzNjenW3yFrgKHyHRXV6CqBpP4HhCrZAd5Kh6H3guTd7W5ZiSGpfkueXfQkX cqi6OuuZ6lKZ1VyW9lDRbzE9YDVrc7H3wcXKfIbLHNdFQbsOC1FP53vXfjBBxgLhmKs/6V vdNSh190wJnGsGu02ljvZbg0eITMSMM+TIy3IuzBAEjfXhYNn5VdHmrBcHNncckr8EO60J voTz88fRCij8GFW3lfgm3b6ovdoDwxJnJJ7dBbjQQr8ePi9d9cwc2O/+PAiYB81Woh6YEx bRLrkU6+WHD5HOer8vR0sHaQoG4Y+LoaQuv9p3CFd+uc5PIs3+y56fpiatW36A== From: "Bastien Curutchet (Schneider Electric)" Date: Mon, 31 Aug 2026 15:25:29 +0200 Subject: [PATCH net-next 07/10] net: dsa: microchip: extract prepare reset Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260831-ksz-perout-v1-7-14202db763b3@bootlin.com> References: <20260831-ksz-perout-v1-0-14202db763b3@bootlin.com> In-Reply-To: <20260831-ksz-perout-v1-0-14202db763b3@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 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_restart_perout() function needs to be created. This function will use the same request initialization as the common ksz_ptp_restart_perout() function. Extract the inialization into a dedicated function so it can be used later by the KSZ8463 support. Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz_ptp.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchi= p/ksz_ptp.c index 2f141df65eb0..e262bc7448f2 100644 --- a/drivers/net/dsa/microchip/ksz_ptp.c +++ b/drivers/net/dsa/microchip/ksz_ptp.c @@ -788,11 +788,11 @@ static int ksz_ptp_gettime(struct ptp_clock_info *ptp= , struct timespec64 *ts) return ret; } =20 -static int ksz_ptp_restart_perout(struct ksz_device *dev) +static int ksz_ptp_prepare_restart_perout(struct ksz_device *dev, + struct ptp_perout_request *request) { struct ksz_ptp_data *ptp_data =3D &dev->ptp_data; s64 now_ns, first_ns, period_ns, next_ns; - struct ptp_perout_request request; struct timespec64 next; struct timespec64 now; unsigned int count; @@ -823,12 +823,24 @@ static int ksz_ptp_restart_perout(struct ksz_device *= dev) =20 /* Restart periodic output signal */ next =3D ns_to_timespec64(next_ns); - request.start.sec =3D next.tv_sec; - request.start.nsec =3D next.tv_nsec; - request.period.sec =3D ptp_data->perout_period.tv_sec; - request.period.nsec =3D ptp_data->perout_period.tv_nsec; - request.index =3D 0; - request.flags =3D 0; + request->start.sec =3D next.tv_sec; + request->start.nsec =3D next.tv_nsec; + request->period.sec =3D ptp_data->perout_period.tv_sec; + request->period.nsec =3D ptp_data->perout_period.tv_nsec; + request->index =3D 0; + request->flags =3D 0; + + return 0; +} + +static int ksz_ptp_restart_perout(struct ksz_device *dev) +{ + struct ptp_perout_request request; + int ret; + + ret =3D ksz_ptp_prepare_restart_perout(dev, &request); + if (ret) + return ret; =20 return ksz_ptp_enable_perout(dev, &request, 1); } --=20 2.55.0 From nobody Sat Sep 26 17:09:07 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 324B443D50E; Mon, 31 Aug 2026 13:25:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788182746; cv=none; b=ta4rlwXfdHYbw1zFM++Xz1Pkc2UoBfK0M1KgEy74Bk8Ws0pGqxxZg7ceZqL4ulZiWMryMe7z4Apnldq3hWTfM5HyQYalrbxxTIFfhVuizOjaWGUiKThlgwCsfqOoh9zOY3y46dnQYD1sSSevRTbcAiARlwVTRtu5Flm5TnTn9Yw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788182746; c=relaxed/simple; bh=elhEQoqrJU0Bva3r+jlfTvSY8EbxMP1ywSHdj8Kg318=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rjiSi+MmjzCuT5VTjgqKI7guGFR30RMHVPARJ+yRl+kXjZCaZhFi8d4gp41pCfjC5WDyxTk3Akkcil0YDKrdfeWQeTo8ylKZtMONvrHT9wprHP/p+RGYVvtDDs+AmiWdx1Rsd6DNvoFrdpAC8lZ90v9vo07+6D9llZuZtZ5D/h8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=nQV6rkFs; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="nQV6rkFs" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 64B144E4147F; Mon, 31 Aug 2026 13:25:43 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 38F8660231; Mon, 31 Aug 2026 13:25:43 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 010BF11C78C5F; Mon, 31 Aug 2026 15:25:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1788182742; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=UE3d8uBd3AkiHRdBNbCVNULk3X2F/j5sdXNN38PNd5o=; b=nQV6rkFs7zcRLCAa+U/agvUmj9T0Mhg9/3rQApUJOqja/ECpyKQbV1kDRAIB/BGKVH/3ns ZPgJxuKyiWw+KgGdI3tzqaIWYOP4fjlhhcvFKSTqU6yR1ueo0ed8QRxYV0OJcmrCFVSd0s bijIshKGa8MDtNA2eJPwAMIzAAY3E4cZNspQ08m4C1pmiw/riAexOM60w5vvISJ2mbynbu e6yn7i1MsaNaYLqICGAkBW3R1w4gMm8/fECrHY5ycSDkIw6bxub3H6R6r3fSq0N98Pywzn hZzr9NHgHnjdmqmLtJs48EhQTFd/J+ZnjsgNYeyx+2WKeXOdnOR7HesUhSFXvQ== From: "Bastien Curutchet (Schneider Electric)" Date: Mon, 31 Aug 2026 15:25:30 +0200 Subject: [PATCH net-next 08/10] net: dsa: microchip: extract time update Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260831-ksz-perout-v1-8-14202db763b3@bootlin.com> References: <20260831-ksz-perout-v1-0-14202db763b3@bootlin.com> In-Reply-To: <20260831-ksz-perout-v1-0-14202db763b3@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 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_settime() function needs to be created. This function will access the same registers than the common ksz_ptp_settime(). Extract the register accesses into a dedicated function so it can be used later by the KSZ8463 support. Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz_ptp.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchi= p/ksz_ptp.c index e262bc7448f2..aa73ad1f05d8 100644 --- a/drivers/net/dsa/microchip/ksz_ptp.c +++ b/drivers/net/dsa/microchip/ksz_ptp.c @@ -845,30 +845,42 @@ static int ksz_ptp_restart_perout(struct ksz_device *= dev) return ksz_ptp_enable_perout(dev, &request, 1); } =20 -static int ksz_ptp_settime(struct ptp_clock_info *ptp, - const struct timespec64 *ts) +static int __ksz_ptp_settime(struct ksz_device *dev, + const struct timespec64 *ts) { - struct ksz_ptp_data *ptp_data =3D ptp_caps_to_data(ptp); - struct ksz_device *dev =3D ptp_data_to_ksz_dev(ptp_data); const u16 *regs =3D dev->info->regs; int ret; =20 - mutex_lock(&ptp_data->lock); - /* Write to shadow registers and Load PTP clock */ ret =3D ksz_write16(dev, regs[PTP_RTC_SUB_NANOSEC], PTP_RTC_0NS); if (ret) - goto unlock; + return ret; =20 ret =3D ksz_write32(dev, regs[PTP_RTC_NANOSEC], ts->tv_nsec); if (ret) - goto unlock; + return ret; =20 ret =3D ksz_write32(dev, regs[PTP_RTC_SEC], ts->tv_sec); if (ret) - goto unlock; + return ret; =20 ret =3D ksz_rmw16(dev, regs[PTP_CLK_CTRL], PTP_LOAD_TIME, PTP_LOAD_TIME); + if (ret) + return ret; + + return 0; +} + +static int ksz_ptp_settime(struct ptp_clock_info *ptp, + const struct timespec64 *ts) +{ + struct ksz_ptp_data *ptp_data =3D ptp_caps_to_data(ptp); + struct ksz_device *dev =3D ptp_data_to_ksz_dev(ptp_data); + int ret; + + mutex_lock(&ptp_data->lock); + + ret =3D __ksz_ptp_settime(dev, ts); if (ret) goto unlock; =20 --=20 2.55.0 From nobody Sat Sep 26 17:09:07 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE8EA43F0AF for ; Mon, 31 Aug 2026 13:25:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788182748; cv=none; b=jzqwMxG+OX6vWFLuGoVigL7ibM0YmllICLuTt39MDjT4Qr029rZirXtjwAkKgx1Np0NR97o6kRofjGm20kMsLEDx3qiO6+fzwhi0Wz9CuPCZDjW/tQCfwx0kNVtkgSpsTDVA3Oqv3TVaSLO1iarTX3uv6EcbppHzrDmI13h0wIo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788182748; c=relaxed/simple; bh=TsIhuHzuFTywoVrgOlVnMNKYyPqvRsXdnxoJalehQEk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bzdHaT7xuTlx/P1YGPh9cSuVVd2kOIxgbp6zfGF1dbAyLHm4aJcHznuU71JIBoh+1NbSjqWxrjcDhnzLgc4DfcQu6mfZzj4EaZqoTQ8Y2QLeDYhptu/Gn5wRVr1VBY/Erbz0yzIe0z1sdkL0HW7NN+b2YFjxBva3HEDE6+Uen44= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=NlLYDX36; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="NlLYDX36" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 115C14E41488; Mon, 31 Aug 2026 13:25:45 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id DA11B60231; Mon, 31 Aug 2026 13:25:44 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B418411C783F8; Mon, 31 Aug 2026 15:25:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1788182744; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=8domjthatR7Oi/LI1vxQUg/eTcs+Epax+tMV1ZAjQ64=; b=NlLYDX36F/psIWz9sm6Ym4xtUsNT7+yk7j2CHtNQIUTOed9pLYz4lKRGEY2n1H+fBfZoBC UikogtryYBsMg9Ddzp0NhXms66svRD0UC3dafnh3wak6Ex+8zK/n+doCLAIbw7bBg543Rv BEm+LEMYpaR/h/p0ejfRSVEBsG5MMgCf5eT6SxiOs3KEzNMX4xC3Dx4r+gskYcL+ihe7Nk c296tzobrzaqIbY6Osx7Ci9spA1P4HH2uIltH78L0yZcZnzoQ8TFPPts0lHbgPo5oonw3I fF7OwuZqTK9dCCrWJg3ap3HOhOz6mcLPiyz0TO4pPVIA6VY/KpDXgCRORaVFeg== From: "Bastien Curutchet (Schneider Electric)" Date: Mon, 31 Aug 2026 15:25:31 +0200 Subject: [PATCH net-next 09/10] net: dsa: microchip: extract time adjustment Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260831-ksz-perout-v1-9-14202db763b3@bootlin.com> References: <20260831-ksz-perout-v1-0-14202db763b3@bootlin.com> In-Reply-To: <20260831-ksz-perout-v1-0-14202db763b3@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 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_adjtime() function needs to be created. This function will access the same registers as the common ksz_ptp_adjtime() function. Extract the register accesses into a dedicated function so it can be used later by the KSZ8463 support. Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz_ptp.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchi= p/ksz_ptp.c index aa73ad1f05d8..0a77b46cfad2 100644 --- a/drivers/net/dsa/microchip/ksz_ptp.c +++ b/drivers/net/dsa/microchip/ksz_ptp.c @@ -946,18 +946,13 @@ static int ksz_ptp_adjfine(struct ptp_clock_info *ptp= , long scaled_ppm) return ret; } =20 -static int ksz_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta) +static int __ksz_ptp_adjtime(struct ksz_device *dev, s64 delta) { - struct ksz_ptp_data *ptp_data =3D ptp_caps_to_data(ptp); - struct ksz_device *dev =3D ptp_data_to_ksz_dev(ptp_data); - struct timespec64 delta64 =3D ns_to_timespec64(delta); const u16 *regs =3D dev->info->regs; s32 sec, nsec; u16 data16; int ret; =20 - mutex_lock(&ptp_data->lock); - /* do not use ns_to_timespec64(), * both sec and nsec are subtracted by hw */ @@ -965,15 +960,15 @@ static int ksz_ptp_adjtime(struct ptp_clock_info *ptp= , s64 delta) =20 ret =3D ksz_write32(dev, regs[PTP_RTC_NANOSEC], abs(nsec)); if (ret) - goto unlock; + return ret; =20 ret =3D ksz_write32(dev, regs[PTP_RTC_SEC], abs(sec)); if (ret) - goto unlock; + return ret; =20 ret =3D ksz_read16(dev, regs[PTP_CLK_CTRL], &data16); if (ret) - goto unlock; + return ret; =20 data16 |=3D PTP_STEP_ADJ; =20 @@ -984,6 +979,22 @@ static int ksz_ptp_adjtime(struct ptp_clock_info *ptp,= s64 delta) data16 |=3D PTP_STEP_DIR; =20 ret =3D ksz_write16(dev, regs[PTP_CLK_CTRL], data16); + if (ret) + return ret; + + return 0; +} + +static int ksz_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta) +{ + struct ksz_ptp_data *ptp_data =3D ptp_caps_to_data(ptp); + struct ksz_device *dev =3D ptp_data_to_ksz_dev(ptp_data); + struct timespec64 delta64 =3D ns_to_timespec64(delta); + int ret; + + mutex_lock(&ptp_data->lock); + + ret =3D __ksz_ptp_adjtime(dev, delta); if (ret) goto unlock; =20 --=20 2.55.0 From nobody Sat Sep 26 17:09:07 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 37562435A86 for ; Mon, 31 Aug 2026 13:25:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788182754; cv=none; b=cu7RQbYpymW0NxEdYd1N51DAwDgzpqnA9knBiePHJEfHGMDiEeip6S1jhh+bGzlo5XIUZty3x9c7rc+efFhOyDUleaxvUy+j2uHzxZgQuFTXbSuktKY1lutDEAbxiWBI8u+upO4gtSFzOlZPISSA5nlCL6APQx0D5m/6iRdrjnw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788182754; c=relaxed/simple; bh=gY8Txk0MvRXn9ike7J4w0hfcCmt/+Ijo7qXVYCoFB2g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ekTYJKI+Ond0ev1erjlqoRx/t6Bf6qv/rDkEpxqTaYchJDdjpyii4R5qRb+hVAKKCjYvj1KdpKmqJoPGDF+oa1F8pR4mOUVDS6O+UhU1Oxu2vrc1l+te7JQ9hbIG4QBjWRaO1h23V2PAajehkdvZ4HEq3AnjK8IwXf2sfbEmgIA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=plkVitwj; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="plkVitwj" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id BB1264E4147F; Mon, 31 Aug 2026 13:25:50 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 8EE5160231; Mon, 31 Aug 2026 13:25:50 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 6478B11C78D63; Mon, 31 Aug 2026 15:25:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1788182745; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=0QqBjLvBZb3HskOPQXGXIouIa+SH8TMZVHy6E7n0de0=; b=plkVitwjm5uGEagOpyZyPghvek6NEGjlS9o/9SU3KsEPSHNsg2Ft9OCs9PoAy/Vghuez4G 14VLrXoMBdJ2HHDcIQXqIHt57WIvW88N9YZJxX4J5aPutaF4c/nmCNy3ReaueyDpLizov6 RC2O2KSj6hvstiAe3T0UTADeIWn93vaYOHXxIGq/fD5z0hZNpVI4a6/9A/qTnlOFnc/su1 OuFAzX1QiW4ZtMHcw3gn6olfR9JCqn++FjFVKRUGppmNedx8RVyvnEdkkPzkfZ79eh5OVx x6VhpdXDexSOspzayHJJPCgsX1j4NNpUYW+y8/oLCrklQ6eyAAHGsMPWwHquFw== From: "Bastien Curutchet (Schneider Electric)" Date: Mon, 31 Aug 2026 15:25:32 +0200 Subject: [PATCH net-next 10/10] net: dsa: microchip: add periodic output support for the KSZ8463 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260831-ksz-perout-v1-10-14202db763b3@bootlin.com> References: <20260831-ksz-perout-v1-0-14202db763b3@bootlin.com> In-Reply-To: <20260831-ksz-perout-v1-0-14202db763b3@bootlin.com> To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran Cc: Pascal Eberhard , =?utf-8?q?Miqu=C3=A8l_Raynal?= , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (Schneider Electric)" X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 KSZ8463 has several periodic outputs. The way it handles them differ from the other KSZ switches: - KSZ8463 has one set of registers for each of its 12 units while others switches share on set of configuration registers for all their units. - Maximum size of the KSZ8463 pulse width is smaller - KSZ8463 has 12 outputs while others only have 2 Add support for the KSZ8463 periodics outputs through a set of KSZ8463 specific functions. Signed-off-by: Bastien Curutchet (Schneider Electric) --- drivers/net/dsa/microchip/ksz8.c | 2 +- drivers/net/dsa/microchip/ksz_common.c | 2 + drivers/net/dsa/microchip/ksz_ptp.c | 258 ++++++++++++++++++++++++++++= ++++ drivers/net/dsa/microchip/ksz_ptp.h | 3 +- drivers/net/dsa/microchip/ksz_ptp_reg.h | 16 ++ 5 files changed, 279 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/k= sz8.c index f2a23e2e474a..6b08bb8fed5b 100644 --- a/drivers/net/dsa/microchip/ksz8.c +++ b/drivers/net/dsa/microchip/ksz8.c @@ -2478,7 +2478,7 @@ static int ksz8463_setup(struct dsa_switch *ds) if (ret) goto free_girq; =20 - ksz_ptp_set_caps(ds); + ksz8463_ptp_set_caps(ds); ret =3D ksz_ptp_clock_register(ds); if (ret) { dev_err(dev->dev, "Failed to register PTP clock: %d\n", diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/micro= chip/ksz_common.c index 194c88cdd00b..111f3014e5a9 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -1161,6 +1161,8 @@ const struct ksz_chip_data ksz_switch_chips[] =3D { .supports_mii =3D {false, false, true}, .supports_rmii =3D {false, false, true}, .internal_phy =3D {true, true, false}, + .n_pins =3D 12, + .n_per_out =3D 12, }, =20 [KSZ8563] =3D { diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchi= p/ksz_ptp.c index 0a77b46cfad2..d33034892a8f 100644 --- a/drivers/net/dsa/microchip/ksz_ptp.c +++ b/drivers/net/dsa/microchip/ksz_ptp.c @@ -26,6 +26,7 @@ */ #define KSZ_MAX_DRIFT_CORR 6249999 #define KSZ_MAX_PULSE_WIDTH 125000000LL +#define KSZ8463_MAX_PULSE_WIDTH 500000LL =20 #define KSZ_PTP_INC_NS 40ULL /* HW clock is incremented every 40 ns (by 4= 0) */ #define KSZ_PTP_SUBNS_BITS 32 @@ -63,6 +64,17 @@ static int ksz_ptp_tou_gpio(struct ksz_device *dev) LED_SRC_PTP_GPIO_1 | LED_SRC_PTP_GPIO_2); } =20 +static int ksz8463_ptp_tou_reset(struct ksz_device *dev, u8 unit) +{ + int ret; + + ret =3D ksz_rmw16(dev, KSZ8463_TOU_SW_RST, BIT(unit), BIT(unit)); + if (ret) + return ret; + + return ksz_rmw16(dev, KSZ8463_TOU_SW_RST, BIT(unit), 0); +} + static int ksz_ptp_tou_reset(struct ksz_device *dev, u8 unit) { u32 data; @@ -120,6 +132,28 @@ static int ksz_ptp_tou_target_time_set(struct ksz_devi= ce *dev, return 0; } =20 +static int ksz8463_ptp_tou_start(struct ksz_device *dev, u8 unit) +{ + u16 data; + int ret; + + ret =3D ksz_rmw16(dev, KSZ8463_TOU_EN, BIT(unit), BIT(unit)); + if (ret) + return ret; + + ret =3D ksz_read16(dev, KSZ8463_TOU_ACTIVE, &data); + if (ret) + return ret; + + if (!(data & BIT(unit))) { + dev_err(dev->dev, "%s: Trigger unit%d error!\n", __func__, + unit); + return -EIO; + } + + return 0; +} + static int ksz_ptp_tou_start(struct ksz_device *dev, u8 unit) { u32 data; @@ -147,6 +181,56 @@ static int ksz_ptp_tou_start(struct ksz_device *dev, u= 8 unit) return 0; } =20 +static int ksz8463_ptp_configure_perout(struct ksz_device *dev, + u32 cycle_width_ns, u32 pulse_width_ns, + struct timespec64 const *target_time, + u8 index) +{ + struct ptp_pin_desc *pin =3D &dev->ptp_data.pin_config[index]; + u16 cfg_base =3D KSZ8463_TRIG1_CFG + KSZ8463_TRIGN_CFG_SIZE * pin->chan; + u16 data; + int ret; + + /* Hardware has only 32 bit */ + if ((target_time->tv_sec & 0xffffffff) !=3D target_time->tv_sec) + return -EINVAL; + + data =3D KSZ8463_NOTIFY_BIT | + FIELD_PREP(KSZ8463_PATTERN_M, TRIG_POS_PERIOD) | + pin->index; + ret =3D ksz_write16(dev, cfg_base + KSZ8463_PATTERN_OFF, data); + if (ret) + return ret; + + ret =3D ksz_write32(dev, cfg_base + KSZ8463_CYCLE_WIDTH_OFF, + cycle_width_ns); + if (ret) + return ret; + + /* Set cycle count 0 - Infinite */ + ret =3D ksz_write16(dev, cfg_base + KSZ8463_CYCLE_CNT_OFF, 0); + if (ret) + return ret; + + /* KSZ8463 uses a 8 ns unit value to compute the pulse width */ + data =3D (pulse_width_ns / 8); + ret =3D ksz_write16(dev, cfg_base + KSZ8463_PULSE_WIDTH_OFF, data); + if (ret) + return ret; + + ret =3D ksz_write32(dev, cfg_base + KSZ8463_TARGET_NSEC, + target_time->tv_nsec); + if (ret) + return ret; + + ret =3D ksz_write32(dev, cfg_base + KSZ8463_TARGET_SEC, + target_time->tv_sec); + if (ret) + return ret; + + return 0; +} + static int ksz_ptp_configure_perout(struct ksz_device *dev, u32 cycle_width_ns, u32 pulse_width_ns, struct timespec64 const *target_time, @@ -241,6 +325,58 @@ static u64 ksz_ptp_compute_perout_pulse(struct ksz_dev= ice *dev, return min_t(u64, req_pulse_width_ns, max_pulse_width); } =20 +static int ksz8463_ptp_enable_perout(struct ksz_device *dev, + struct ptp_perout_request const *request, + int on) +{ + struct ksz_ptp_data *ptp_data =3D &dev->ptp_data; + u64 cycle_width_ns; + u64 pulse_width_ns; + int pin; + int ret; + + pin =3D ksz_ptp_get_pin(dev, request); + if (pin < 0) + return pin; + + ret =3D ksz8463_ptp_tou_reset(dev, request->index); + if (ret) + return ret; + + if (!on) { + ptp_data->tou_mode =3D KSZ_PTP_TOU_IDLE; + return 0; + } + ret =3D ksz_ptp_compute_perout_cycle(dev, request, &cycle_width_ns); + if (ret) + return ret; + pulse_width_ns =3D ksz_ptp_compute_perout_pulse(dev, request, + KSZ8463_MAX_PULSE_WIDTH); + + ret =3D ksz_ptp_tou_pulse_verify(pulse_width_ns, + KSZ8463_TRIG_PULSE_WIDTH_M); + if (ret) + return ret; + + ret =3D ksz8463_ptp_configure_perout(dev, cycle_width_ns, pulse_width_ns, + &ptp_data->perout_target_time_first, + pin); + if (ret) + return ret; + + ret =3D ksz_ptp_tou_gpio(dev); + if (ret) + return ret; + + ret =3D ksz8463_ptp_tou_start(dev, request->index); + if (ret) + return ret; + + ptp_data->tou_mode =3D KSZ_PTP_TOU_PEROUT; + + return 0; +} + static int ksz_ptp_enable_perout(struct ksz_device *dev, struct ptp_perout_request const *request, int on) @@ -845,6 +981,18 @@ static int ksz_ptp_restart_perout(struct ksz_device *d= ev) return ksz_ptp_enable_perout(dev, &request, 1); } =20 +static int ksz8463_ptp_restart_perout(struct ksz_device *dev) +{ + struct ptp_perout_request request; + int ret; + + ret =3D ksz_ptp_prepare_restart_perout(dev, &request); + if (ret) + return ret; + + return ksz8463_ptp_enable_perout(dev, &request, 1); +} + static int __ksz_ptp_settime(struct ksz_device *dev, const struct timespec64 *ts) { @@ -871,6 +1019,41 @@ static int __ksz_ptp_settime(struct ksz_device *dev, return 0; } =20 +static int ksz8463_ptp_settime(struct ptp_clock_info *ptp, + const struct timespec64 *ts) +{ + struct ksz_ptp_data *ptp_data =3D ptp_caps_to_data(ptp); + struct ksz_device *dev =3D ptp_data_to_ksz_dev(ptp_data); + int ret; + + mutex_lock(&ptp_data->lock); + + ret =3D __ksz_ptp_settime(dev, ts); + if (ret) + goto unlock; + + switch (ptp_data->tou_mode) { + case KSZ_PTP_TOU_IDLE: + break; + + case KSZ_PTP_TOU_PEROUT: + ret =3D ksz8463_ptp_restart_perout(dev); + if (ret) + goto unlock; + + break; + } + + spin_lock_bh(&ptp_data->clock_lock); + ptp_data->clock_time =3D *ts; + spin_unlock_bh(&ptp_data->clock_lock); + +unlock: + mutex_unlock(&ptp_data->lock); + + return ret; +} + static int ksz_ptp_settime(struct ptp_clock_info *ptp, const struct timespec64 *ts) { @@ -985,6 +1168,40 @@ static int __ksz_ptp_adjtime(struct ksz_device *dev, = s64 delta) return 0; } =20 +static int ksz8463_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta) +{ + struct ksz_ptp_data *ptp_data =3D ptp_caps_to_data(ptp); + struct ksz_device *dev =3D ptp_data_to_ksz_dev(ptp_data); + struct timespec64 delta64 =3D ns_to_timespec64(delta); + int ret; + + mutex_lock(&ptp_data->lock); + + ret =3D __ksz_ptp_adjtime(dev, delta); + if (ret) + goto unlock; + + switch (ptp_data->tou_mode) { + case KSZ_PTP_TOU_IDLE: + break; + + case KSZ_PTP_TOU_PEROUT: + ret =3D ksz8463_ptp_restart_perout(dev); + if (ret) + goto unlock; + + break; + } + + spin_lock_bh(&ptp_data->clock_lock); + ptp_data->clock_time =3D timespec64_add(ptp_data->clock_time, delta64); + spin_unlock_bh(&ptp_data->clock_lock); + +unlock: + mutex_unlock(&ptp_data->lock); + return ret; +} + static int ksz_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta) { struct ksz_ptp_data *ptp_data =3D ptp_caps_to_data(ptp); @@ -1019,6 +1236,26 @@ static int ksz_ptp_adjtime(struct ptp_clock_info *pt= p, s64 delta) return ret; } =20 +static int ksz8463_ptp_enable(struct ptp_clock_info *ptp, + struct ptp_clock_request *req, int on) +{ + struct ksz_ptp_data *ptp_data =3D ptp_caps_to_data(ptp); + struct ksz_device *dev =3D ptp_data_to_ksz_dev(ptp_data); + int ret; + + switch (req->type) { + case PTP_CLK_REQ_PEROUT: + mutex_lock(&ptp_data->lock); + ret =3D ksz8463_ptp_enable_perout(dev, &req->perout, on); + mutex_unlock(&ptp_data->lock); + break; + default: + return -EOPNOTSUPP; + } + + return ret; +} + static int ksz_ptp_enable(struct ptp_clock_info *ptp, struct ptp_clock_request *req, int on) { @@ -1095,6 +1332,27 @@ static int ksz_ptp_start_clock(struct ksz_device *de= v) return 0; } =20 +void ksz8463_ptp_set_caps(struct dsa_switch *ds) +{ + struct ksz_device *dev =3D ds->priv; + struct ksz_ptp_data *ptp_data; + + ptp_data =3D &dev->ptp_data; + + ptp_data->caps.owner =3D THIS_MODULE; + snprintf(ptp_data->caps.name, 16, "Microchip Clock"); + ptp_data->caps.max_adj =3D KSZ_MAX_DRIFT_CORR; + ptp_data->caps.gettime64 =3D ksz_ptp_gettime; + ptp_data->caps.settime64 =3D ksz8463_ptp_settime; + ptp_data->caps.adjfine =3D ksz_ptp_adjfine; + ptp_data->caps.adjtime =3D ksz8463_ptp_adjtime; + ptp_data->caps.do_aux_work =3D ksz_ptp_do_aux_work; + ptp_data->caps.enable =3D ksz8463_ptp_enable; + ptp_data->caps.verify =3D ksz_ptp_verify_pin; + ptp_data->caps.n_pins =3D dev->info->n_pins; + ptp_data->caps.n_per_out =3D dev->info->n_per_out; +} + void ksz_ptp_set_caps(struct dsa_switch *ds) { struct ksz_device *dev =3D ds->priv; diff --git a/drivers/net/dsa/microchip/ksz_ptp.h b/drivers/net/dsa/microchi= p/ksz_ptp.h index 89716b31596b..92589cf373ac 100644 --- a/drivers/net/dsa/microchip/ksz_ptp.h +++ b/drivers/net/dsa/microchip/ksz_ptp.h @@ -12,7 +12,7 @@ =20 #include =20 -#define KSZ_PTP_N_GPIO 2 +#define KSZ_PTP_N_GPIO 12 =20 enum ksz_ptp_tou_mode { KSZ_PTP_TOU_IDLE, @@ -34,6 +34,7 @@ struct ksz_ptp_data { }; =20 void ksz_ptp_set_caps(struct dsa_switch *ds); +void ksz8463_ptp_set_caps(struct dsa_switch *ds); int ksz_ptp_clock_register(struct dsa_switch *ds); =20 void ksz_ptp_clock_unregister(struct dsa_switch *ds); diff --git a/drivers/net/dsa/microchip/ksz_ptp_reg.h b/drivers/net/dsa/micr= ochip/ksz_ptp_reg.h index 65ea8577af75..16f117fa5d49 100644 --- a/drivers/net/dsa/microchip/ksz_ptp_reg.h +++ b/drivers/net/dsa/microchip/ksz_ptp_reg.h @@ -51,6 +51,22 @@ =20 #define REG_PTP_UNIT_INDEX__4 0x0520 =20 +#define KSZ8463_TOU_ACTIVE 0x202 +#define KSZ8463_TOU_EN 0x206 +#define KSZ8463_TOU_SW_RST 0x208 + +#define KSZ8463_TRIGN_CFG_SIZE 0x20 +#define KSZ8463_TRIG1_CFG 0x220 +#define KSZ8463_TARGET_NSEC 0x000 +#define KSZ8463_TARGET_SEC 0x004 +#define KSZ8463_PATTERN_OFF 0x008 +#define KSZ8463_NOTIFY_BIT BIT(8) +#define KSZ8463_PATTERN_M GENMASK(6, 4) +#define KSZ8463_PULSE_WIDTH_OFF 0x00A +#define KSZ8463_TRIG_PULSE_WIDTH_M GENMASK(15, 0) +#define KSZ8463_CYCLE_WIDTH_OFF 0x00C +#define KSZ8463_CYCLE_CNT_OFF 0x010 + #define PTP_GPIO_INDEX GENMASK(19, 16) #define PTP_TSI_INDEX BIT(8) #define PTP_TOU_INDEX GENMASK(1, 0) --=20 2.55.0