From patchwork Thu Jun 16 19:52:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Lemon X-Patchwork-Id: 12884712 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E730C433EF for ; Thu, 16 Jun 2022 19:52:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234527AbiFPTwX (ORCPT ); Thu, 16 Jun 2022 15:52:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229793AbiFPTwW (ORCPT ); Thu, 16 Jun 2022 15:52:22 -0400 Received: from smtp8.emailarray.com (smtp8.emailarray.com [65.39.216.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CCE05133E for ; Thu, 16 Jun 2022 12:52:21 -0700 (PDT) Received: (qmail 75621 invoked by uid 89); 16 Jun 2022 19:52:19 -0000 Received: from unknown (HELO localhost) (amxlbW9uQGZsdWdzdmFtcC5jb21AMTc0LjIxLjg0LjIwNQ==) (POLARISLOCAL) by smtp8.emailarray.com with SMTP; 16 Jun 2022 19:52:19 -0000 From: Jonathan Lemon To: netdev@vger.kernel.org Cc: kernel-team@fb.com, Andrew Lunn , Florian Fainelli , Richard Cochran , Lasse Johnsen , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Broadcom internal kernel review list Subject: [PATCH net-next v8 0/3] Broadcom PTP PHY support Date: Thu, 16 Jun 2022 12:52:15 -0700 Message-Id: <20220616195218.217408-1-jonathan.lemon@gmail.com> X-Mailer: git-send-email 2.34.3 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This adds PTP support for the Broadcom PHY BCM54210E (and the specific variant BCM54213PE that the rpi-5.15 branch uses). This has only been tested on the RPI CM4, which has one port. There are other Broadcom chips which may benefit from using the same framework here, although with different register sets. v7->v8: Style changes in patch 3 (Florian) v6->v7: Fix Kconfig dependencies (Jakub) v5->v6: Fix calculations in bcm_ptp_adjtime_locked (Richard) Add bcm_ptp_stop (Florian) Update framesync handling for better masking and restore Cleanup 1PPS perout function, remove unsync'd version Add 1PPS extts detection Break out extts/perout into its own patch v4->v5: Reorder so bcm-phy-lib.h shows up first, fixing dependency issues. Use set_normalized_timespec for adjusting ns in adjtime Return upscaled config setting from hwtstamp v3->v4: Squash bcm-phy-lib.h and broadcom.c changes into one patch Reorder so the main patch shows up first. v2->v3: Rearrange patches so they apply in order Use ERR_CAST v1->v2: Squash Kconfig into main patch Move config checks into bcm-phy-lib.h Fix delta_ns calculations in adjtime Uppercase mode selector macros Only use NSE_INIT when necessary Remove the inserted Broadcom RX timestamp from the PTP packet Add perout (chip generated) and fsync out (timer generated) Remove PHY_ID_BCM54213PE special casing (needed for rpi tree) --- CC: Andrew Lunn CC: Florian Fainelli CC: Richard Cochran CC: Lasse Johnsen CC: Heiner Kallweit CC: Russell King CC: "David S. Miller" CC: Eric Dumazet CC: Jakub Kicinski CC: Paolo Abeni CC: Broadcom internal kernel review list --- Jonathan Lemon (3): net: phy: broadcom: Add Broadcom PTP hooks to bcm-phy-lib net: phy: broadcom: Add PTP support for some Broadcom PHYs. net: phy: Add support for 1PPS out and external timestamps drivers/net/phy/Kconfig | 5 + drivers/net/phy/Makefile | 1 + drivers/net/phy/bcm-phy-lib.h | 19 + drivers/net/phy/bcm-phy-ptp.c | 944 ++++++++++++++++++++++++++++++++++ drivers/net/phy/broadcom.c | 33 +- 5 files changed, 998 insertions(+), 4 deletions(-) create mode 100644 drivers/net/phy/bcm-phy-ptp.c