From patchwork Fri Jun 16 10:04:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexis_Lothor=C3=A9?= X-Patchwork-Id: 109016 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1225311vqr; Fri, 16 Jun 2023 03:18:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5S94UB9zG9KNN6EEwCpK6wwD9lHhEIL4jvgQUyeUXyti0CNP4XkjmdvIuGCVgxlTnhE95I X-Received: by 2002:a17:902:ab5c:b0:1b0:522d:8ff4 with SMTP id ij28-20020a170902ab5c00b001b0522d8ff4mr1331931plb.21.1686910694071; Fri, 16 Jun 2023 03:18:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686910694; cv=none; d=google.com; s=arc-20160816; b=HnE9Ae694uCjDF0+/ARBTRVJb3lx499o0htzp5eBvXSA4JRb7dUF4sIvPYTYnIj8Bl RgEGCczmlzOqrtN/0CqsYJAB++tgKdiVv1rVX2nvZ57GcXsynqrRzHrwubWiaxt5wW0B IWZeoqSq78JiiS7gAVkXiTSGhYyXJ4N/5WiCUxz21tjzopPYBfM3Uz5Kd9f+0l7IuxHU ddokMm0XZj+KT1zRq0EddhqNDGbILnQ/+2ReUSMcJTL1xFzrVo60ZHYopXxiRiexrX3V ETwqz2c7b0iVpJrP5LN678zN8tRI4eeW7o12Ogp/krkqybPHACxUU9BVwV7XEuJfvcMJ yd/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZQ1+xbvMnidBmGeXT0nP+KHmlPyfa+N1kU3ye5N9Y2M=; b=q/qgbcVfiwZZj78TMdog6bAtIAC4kyQV1Rnx0T90yp0sX49jBvIn+RGfWGzGRaQgVV chYVEUpPEVrcO7jkMQFUS1LJr77Gis2Zip0oozwjMisQHe0HCSZTmr5ZxG3+apkiG7VW fkku2jwGaHHZnUJa15qoYPpdr2i5YDr40mPLuujo/IGc/Wu/oaTLJDT3WqedchnkA2YJ ysMJ91zSmJOc0sfk3Yvh6wJxYUD5vj+XJCfc7HepJqAxKmVXZ/eKTGCyD1CARN+WHpOT qe4blJdr2eTBnEWGuKWo+kT3lq1+nRC5CT1exB3dhnNczNXkRhtht6/JCA7Q5kmygeUn 4HuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Sicjf9ks; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p5-20020a170902e74500b001ab147e4539si13623505plf.419.2023.06.16.03.17.59; Fri, 16 Jun 2023 03:18:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Sicjf9ks; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232085AbjFPKFj (ORCPT + 99 others); Fri, 16 Jun 2023 06:05:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229658AbjFPKFe (ORCPT ); Fri, 16 Jun 2023 06:05:34 -0400 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3168C2137; Fri, 16 Jun 2023 03:05:33 -0700 (PDT) X-GND-Sasl: alexis.lothore@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686909931; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZQ1+xbvMnidBmGeXT0nP+KHmlPyfa+N1kU3ye5N9Y2M=; b=Sicjf9ks2PJoF/K2iAiEzxbRBrNIvgpB0mTA1GqD4eEWaZ/tLOB7KOSnyaLhISAEocTwyv RPPNUS3DqAW37JRUxacbu68edCx2UY30ktDi8ZHWIPaU3ya2meksVLKyBsbYx8Z9NbUvDu TufohlkapBs05jQMj4Z1KYsaobvwW/QyXoaLG2TKo6rfGryl2XQ/dTwFIZfZAjjr+0dl3Z uho3Q9qfYJAsLMrKUaCReSYe1T/RMrWJp3tNl2W3+RR20V7o1YE5iN3C/mCGPEeHFOqnDc FRadOLh+++SFziNFZf4WOF9z9MFgLm/RUxOx94IdYHQeAe/56hJzx92ZbJ5n1w== X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 83BF520003; Fri, 16 Jun 2023 10:05:30 +0000 (UTC) From: alexis.lothore@bootlin.com To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Thomas Petazzoni , Nicolas Carrier Subject: [PATCH net-next 1/8] net: stmmac: add IP-specific callbacks for auxiliary snapshot Date: Fri, 16 Jun 2023 12:04:02 +0200 Message-ID: <20230616100409.164583-2-alexis.lothore@bootlin.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616100409.164583-1-alexis.lothore@bootlin.com> References: <20230616100409.164583-1-alexis.lothore@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768854067828682891?= X-GMAIL-MSGID: =?utf-8?q?1768854067828682891?= From: Alexis Lothoré Since auxiliary snapshots configuration registers may be different depending the DWMAC IP, we need a specific set of callbacks to - configure timestamp snapshot triggers - clear the snapshots FIFO Signed-off-by: Alexis Lothoré --- drivers/net/ethernet/stmicro/stmmac/hwif.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index 6ee7cf07cfd7..d0b2f13510aa 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -419,6 +419,10 @@ struct stmmac_ops { void (*fpe_send_mpacket)(void __iomem *ioaddr, enum stmmac_mpacket_type type); int (*fpe_irq_status)(void __iomem *ioaddr, struct net_device *dev); + /* Auxiliary snapshots */ + void (*extts_configure)(void __iomem *ioaddr, int ext_snapshot_num, + bool on, struct net_device *dev); + int (*clear_snapshot_fifo)(void __iomem *ioaddr); }; #define stmmac_core_init(__priv, __args...) \ @@ -523,6 +527,10 @@ struct stmmac_ops { stmmac_do_void_callback(__priv, mac, fpe_send_mpacket, __args) #define stmmac_fpe_irq_status(__priv, __args...) \ stmmac_do_callback(__priv, mac, fpe_irq_status, __args) +#define stmmac_extts_configure(__priv, __args...) \ + stmmac_do_void_callback(__priv, mac, extts_configure, __args) +#define stmmac_clear_snapshot_fifo(__priv, __args...) \ + stmmac_do_callback(__priv, mac, clear_snapshot_fifo, __args) /* PTP and HW Timer helpers */ struct stmmac_hwtimestamp { From patchwork Fri Jun 16 10:04:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexis_Lothor=C3=A9?= X-Patchwork-Id: 109006 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1219860vqr; Fri, 16 Jun 2023 03:10:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ465zLfUioCTlyUR+p1HUUI5TReo0qOYw+JwcSHxe4Bv0X50W/KLyptS59hI5nrc+CBU+2G X-Received: by 2002:a05:6358:cb24:b0:12f:1965:d7a7 with SMTP id gr36-20020a056358cb2400b0012f1965d7a7mr1301432rwb.21.1686910215223; Fri, 16 Jun 2023 03:10:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686910215; cv=none; d=google.com; s=arc-20160816; b=JW/bnrvgJjJS4ZRy3/iJvpSY8bufiWeJrHsgH0e2vYNNsNu17eBXOKByoHoWA6pOIw cafahNeMdCZHm4KJd5StT1fUofC2ka93vm5hwAlPBEIFCkxIc5RKv94nyY5KJTh53XB/ ftDe1mUuVtVzUFFW05eVZA4eZPWe1AfLXjfmtDwsX/wFYAh0+4bDVmJstljZTvfUR41T /V8k/dvUyzZ/cpYyhacz8zT1q3fseg3Tpop77p3KKuvzmbjcNfKF5KLOVEJrPWKbYC2P c0wtqJA22kamAXmYCPAWWn07/XeLYuga8JtgN/kf1cB0JSMjq+VxJERwCzcvmMif6aV6 ZV6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RlKfBubQaLPW6K+ql37Q+2HGvyJMouSBVoPzyWY8+lQ=; b=AtfEuHbWORZdfug8j6NLKJ4d/9orXqkfkskPG2fI5B10GWO8kAGD6gOzTHFOqYSJM3 AmFPn/xqwdxtJVSSvCSpqGMQ3w+il3qZBRIpzmSlL/CSnNuk+8uQUIxikobkZCUmnjX1 vUAgdJdkcNYu/StN6CHl5kFiP9ATdYmEGIfwF20cge//tqNCvIYHIIejF1IuBXb7xsXN C83gjNNg8BVGgTotfkPmoUdX07bne8IFiAAVp2b2zyN/JLEQUN+x2AmG2IqWxYzcfOHd 9ZqBCQDgxYPjeSrMLm/ADxuNHMwhUBtZ2UUnsV5E78cazFq+7PkmE1YExqJpUHPZ6ldc rG4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=abt1qeCl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q18-20020a632a12000000b0054fdb18c873si4418659pgq.645.2023.06.16.03.09.59; Fri, 16 Jun 2023 03:10:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=abt1qeCl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229778AbjFPKFn (ORCPT + 99 others); Fri, 16 Jun 2023 06:05:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230045AbjFPKFg (ORCPT ); Fri, 16 Jun 2023 06:05:36 -0400 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E0992D67; Fri, 16 Jun 2023 03:05:34 -0700 (PDT) X-GND-Sasl: alexis.lothore@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686909932; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RlKfBubQaLPW6K+ql37Q+2HGvyJMouSBVoPzyWY8+lQ=; b=abt1qeClvlCyL9z75uDOY0nQ5EnUQwmGYXSQLVRjO5Q+K0qaH5HZFECsb/jfWAfTGmiwiI K2G6belDwjs+QVzaFr84OxGGRJanZVw5Tt7qGn91iooeVuNNxqb3F3FTbyS/BAy3Q366vo ITok6AyovOMB4aJhksCAVYNMrYkfnwW4Ryn6V5Ijiw1pjNXEnR9nPeF1zsV96rM0EIRTLf tsK5I/FGVNRZwUIaxl+U5XzLctE3ZsMCdYDT2JoUaxCokTxVIyJcIj3bmR/q/9XJ1BORYA Gy2ZlECDEv9Cf5E2SCPYz+WWeNUWpHcp29AIORVPsW3Hb8B5NNhTTQcum2LiFw== X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id D258D2000D; Fri, 16 Jun 2023 10:05:31 +0000 (UTC) From: alexis.lothore@bootlin.com To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Thomas Petazzoni , Nicolas Carrier Subject: [PATCH net-next 2/8] net: stmmac: populate dwmac4 callbacks for auxiliary snapshots Date: Fri, 16 Jun 2023 12:04:03 +0200 Message-ID: <20230616100409.164583-3-alexis.lothore@bootlin.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616100409.164583-1-alexis.lothore@bootlin.com> References: <20230616100409.164583-1-alexis.lothore@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768853565579015300?= X-GMAIL-MSGID: =?utf-8?q?1768853565579015300?= From: Alexis Lothoré Contrary to generic PTP registers (timestamp control, system time, time update, addend, etc), auxiliary snapshots registers addresses and layout differ depending on exact DWMAC IP. Current implementation matches register layout for DWMAC4, so move current behaviour from stmmac_ptp.c to dwmac4_core.c. Wire those callbacks for all DWMAC4 versions. Signed-off-by: Alexis Lothoré --- drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 22 ++++++++++++ .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 34 +++++++++++++++++++ .../net/ethernet/stmicro/stmmac/stmmac_ptp.c | 24 +++---------- .../net/ethernet/stmicro/stmmac/stmmac_ptp.h | 19 ----------- 4 files changed, 60 insertions(+), 39 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h index d3c5306f1c41..d249a68f6787 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h @@ -51,6 +51,7 @@ #define GMAC_L3_ADDR0(reg) (0x910 + (reg) * 0x30) #define GMAC_L3_ADDR1(reg) (0x914 + (reg) * 0x30) #define GMAC_TIMESTAMP_STATUS 0x00000b20 +#define GMAC_AUXILIARY_CONTROL 0x00000b40 /* Auxiliary Control Reg */ /* RX Queues Routing */ #define GMAC_RXQCTRL_AVCPQ_MASK GENMASK(2, 0) @@ -580,6 +581,27 @@ static inline u32 mtl_low_credx_base_addr(const struct dwmac4_addrs *addrs, #define GMAC_PHYIF_CTRLSTATUS_SPEED_25 0x1 #define GMAC_PHYIF_CTRLSTATUS_SPEED_2_5 0x0 +/* Auxiliary Control defines */ +#define PTP_ACR_ATSFC BIT(0) /* Auxiliary Snapshot FIFO Clear */ +#define PTP_ACR_ATSEN0 BIT(4) /* Auxiliary Snapshot 0 Enable */ +#define PTP_ACR_ATSEN1 BIT(5) /* Auxiliary Snapshot 1 Enable */ +#define PTP_ACR_ATSEN2 BIT(6) /* Auxiliary Snapshot 2 Enable */ +#define PTP_ACR_ATSEN3 BIT(7) /* Auxiliary Snapshot 3 Enable */ +#define PTP_ACR_ATSEN_SHIFT 5 /* Auxiliary Snapshot shift */ +#define PTP_ACR_MASK GENMASK(7, 4) /* Aux Snapshot Mask */ +#define PMC_ART_VALUE0 0x01 /* PMC_ART[15:0] timer value */ +#define PMC_ART_VALUE1 0x02 /* PMC_ART[31:16] timer value */ +#define PMC_ART_VALUE2 0x03 /* PMC_ART[47:32] timer value */ +#define PMC_ART_VALUE3 0x04 /* PMC_ART[63:48] timer value */ +#define GMAC4_ART_TIME_SHIFT 16 /* ART TIME 16-bits shift */ + +enum aux_snapshot { + AUX_SNAPSHOT0 = 0x10, + AUX_SNAPSHOT1 = 0x20, + AUX_SNAPSHOT2 = 0x40, + AUX_SNAPSHOT3 = 0x80, +}; + extern const struct stmmac_dma_ops dwmac4_dma_ops; extern const struct stmmac_dma_ops dwmac410_dma_ops; #endif /* __DWMAC4_H__ */ diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index 03b1c5a97826..01c0822d37e6 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -1129,6 +1129,34 @@ static int dwmac4_config_l4_filter(struct mac_device_info *hw, u32 filter_no, return 0; } +static void dwmac4_extts_configure(void __iomem *ioaddr, int ext_snapshot_num, bool on, + struct net_device *dev) +{ + u32 acr_value; + + acr_value = readl(ioaddr + GMAC_AUXILIARY_CONTROL); + acr_value &= ~PTP_ACR_MASK; + if (on) { + /* Enable External snapshot trigger */ + acr_value |= ext_snapshot_num; + acr_value |= PTP_ACR_ATSFC; + netdev_dbg(dev, "Auxiliary Snapshot %d enabled.\n", + ext_snapshot_num >> PTP_ACR_ATSEN_SHIFT); + } else { + netdev_dbg(dev, "Auxiliary Snapshot %d disabled.\n", + ext_snapshot_num >> PTP_ACR_ATSEN_SHIFT); + } + writel(acr_value, ioaddr + GMAC_AUXILIARY_CONTROL); +} + +static int dwmac4_clear_snapshot_fifo(void __iomem *ioaddr) +{ + u32 acr_value; + + return readl_poll_timeout(ioaddr + GMAC_AUXILIARY_CONTROL, acr_value, + !(acr_value & PTP_ACR_ATSFC), 10, 10000); +} + const struct stmmac_ops dwmac4_ops = { .core_init = dwmac4_core_init, .set_mac = stmmac_set_mac, @@ -1169,6 +1197,8 @@ const struct stmmac_ops dwmac4_ops = { .add_hw_vlan_rx_fltr = dwmac4_add_hw_vlan_rx_fltr, .del_hw_vlan_rx_fltr = dwmac4_del_hw_vlan_rx_fltr, .restore_hw_vlan_rx_fltr = dwmac4_restore_hw_vlan_rx_fltr, + .extts_configure = dwmac4_extts_configure, + .clear_snapshot_fifo = dwmac4_clear_snapshot_fifo }; const struct stmmac_ops dwmac410_ops = { @@ -1217,6 +1247,8 @@ const struct stmmac_ops dwmac410_ops = { .add_hw_vlan_rx_fltr = dwmac4_add_hw_vlan_rx_fltr, .del_hw_vlan_rx_fltr = dwmac4_del_hw_vlan_rx_fltr, .restore_hw_vlan_rx_fltr = dwmac4_restore_hw_vlan_rx_fltr, + .extts_configure = dwmac4_extts_configure, + .clear_snapshot_fifo = dwmac4_clear_snapshot_fifo }; const struct stmmac_ops dwmac510_ops = { @@ -1269,6 +1301,8 @@ const struct stmmac_ops dwmac510_ops = { .add_hw_vlan_rx_fltr = dwmac4_add_hw_vlan_rx_fltr, .del_hw_vlan_rx_fltr = dwmac4_del_hw_vlan_rx_fltr, .restore_hw_vlan_rx_fltr = dwmac4_restore_hw_vlan_rx_fltr, + .extts_configure = dwmac4_extts_configure, + .clear_snapshot_fifo = dwmac4_clear_snapshot_fifo }; static u32 dwmac4_get_num_vlan(void __iomem *ioaddr) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c index b4388ca8d211..167bfbf68911 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c @@ -165,11 +165,9 @@ static int stmmac_enable(struct ptp_clock_info *ptp, { struct stmmac_priv *priv = container_of(ptp, struct stmmac_priv, ptp_clock_ops); - void __iomem *ptpaddr = priv->ptpaddr; struct stmmac_pps_cfg *cfg; int ret = -EOPNOTSUPP; unsigned long flags; - u32 acr_value; switch (rq->type) { case PTP_CLK_REQ_PEROUT: @@ -194,26 +192,12 @@ static int stmmac_enable(struct ptp_clock_info *ptp, case PTP_CLK_REQ_EXTTS: priv->plat->ext_snapshot_en = on; mutex_lock(&priv->aux_ts_lock); - acr_value = readl(ptpaddr + PTP_ACR); - acr_value &= ~PTP_ACR_MASK; - if (on) { - /* Enable External snapshot trigger */ - acr_value |= priv->plat->ext_snapshot_num; - acr_value |= PTP_ACR_ATSFC; - netdev_dbg(priv->dev, "Auxiliary Snapshot %d enabled.\n", - priv->plat->ext_snapshot_num >> - PTP_ACR_ATSEN_SHIFT); - } else { - netdev_dbg(priv->dev, "Auxiliary Snapshot %d disabled.\n", - priv->plat->ext_snapshot_num >> - PTP_ACR_ATSEN_SHIFT); - } - writel(acr_value, ptpaddr + PTP_ACR); + stmmac_extts_configure(priv, priv->ioaddr, + priv->plat->ext_snapshot_num, on, + priv->dev); mutex_unlock(&priv->aux_ts_lock); /* wait for auxts fifo clear to finish */ - ret = readl_poll_timeout(ptpaddr + PTP_ACR, acr_value, - !(acr_value & PTP_ACR_ATSFC), - 10, 10000); + ret = stmmac_clear_snapshot_fifo(priv, priv->ioaddr); break; default: diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h index bf619295d079..9e0ff2cec352 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h @@ -67,25 +67,6 @@ #define PTP_SSIR_SSINC_MAX 0xff #define GMAC4_PTP_SSIR_SSINC_SHIFT 16 -/* Auxiliary Control defines */ -#define PTP_ACR_ATSFC BIT(0) /* Auxiliary Snapshot FIFO Clear */ -#define PTP_ACR_ATSEN0 BIT(4) /* Auxiliary Snapshot 0 Enable */ -#define PTP_ACR_ATSEN1 BIT(5) /* Auxiliary Snapshot 1 Enable */ -#define PTP_ACR_ATSEN2 BIT(6) /* Auxiliary Snapshot 2 Enable */ -#define PTP_ACR_ATSEN3 BIT(7) /* Auxiliary Snapshot 3 Enable */ -#define PTP_ACR_ATSEN_SHIFT 5 /* Auxiliary Snapshot shift */ -#define PTP_ACR_MASK GENMASK(7, 4) /* Aux Snapshot Mask */ -#define PMC_ART_VALUE0 0x01 /* PMC_ART[15:0] timer value */ -#define PMC_ART_VALUE1 0x02 /* PMC_ART[31:16] timer value */ -#define PMC_ART_VALUE2 0x03 /* PMC_ART[47:32] timer value */ -#define PMC_ART_VALUE3 0x04 /* PMC_ART[63:48] timer value */ -#define GMAC4_ART_TIME_SHIFT 16 /* ART TIME 16-bits shift */ -enum aux_snapshot { - AUX_SNAPSHOT0 = 0x10, - AUX_SNAPSHOT1 = 0x20, - AUX_SNAPSHOT2 = 0x40, - AUX_SNAPSHOT3 = 0x80, -}; #endif /* __STMMAC_PTP_H__ */ From patchwork Fri Jun 16 10:04:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexis_Lothor=C3=A9?= X-Patchwork-Id: 109008 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1222360vqr; Fri, 16 Jun 2023 03:13:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5SMmw+oOjuciT5HdezHerp3C+ALhuQ6osRr99fJKo1iWzmrxlm7uosvRcBqLEmYFNVFuox X-Received: by 2002:a05:6358:9f9f:b0:129:b8e9:b740 with SMTP id fy31-20020a0563589f9f00b00129b8e9b740mr285991rwb.27.1686910427251; Fri, 16 Jun 2023 03:13:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686910427; cv=none; d=google.com; s=arc-20160816; b=SDIK5zAUTrSLDptvDQ0X3lDTENMTXaYw/nacwOYaltNN94Hau+LLIfyBqEcy7j+5qe ml+t3c6pDveN+lqqIV3imSkiVPqjqG3ah+DcbwjF2gfxphHfBhy3kVAHo96YLQecKLG5 JvuHdmaTNrlI8GZQVD6TW+YnTGiAg2tapy8iM9na6dYC1yxSttaYw4hr6IPWsPfCMj7f POnfaDjynrudgYQik9NxdM1jO9HedT62t0j5NW3w3BucHhlWPQ61EGFwkewqaBhVbdRF sfvGxMGFQPp4XsCh1ha8fBwacQ0QS3gegQdqPR+g96pfnQVQpwA3XlOFblDFKuwCZmGC 0i3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bu3ZgXdHuaAGXwkANc4+sjRTQos43KxjZuFR24WnayE=; b=Nxs4EAyVC1DCyPu6bwj0Tud4ZcHWf1SyGURmBUL3Y/Zh7af0Ti+QfK5vRSG7jv+XOD zVsT4YCgBaGRoOqP8M6aIcuB9aRxV2u1xLEXh/p0zTpgZQqoDwsNLikdZ72QEYJd0B1Y l0q6jgvrZAi6JmEbPlGkQAEgeYLXvbjvoOpoSkJgrtzFpHI5a94B9ze3U1gOto+quFkp emzbrMwV8lBTkZlT3CQXC8nCCR+iB1s6CJfdRCz+cRGrxPG1d0Kh2Ba6vTcSAyt+MhgB FLz5JrpoTxlV/vimcjKhfmIx8MDa+UIkhcx66T60GAqZIB6xx8wcbH9KEJ1LjB4sP5Ez KQ6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=MB6d8Q+e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b73-20020a63344c000000b0053f955eda7csi14906843pga.559.2023.06.16.03.13.32; Fri, 16 Jun 2023 03:13:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=MB6d8Q+e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243849AbjFPKFt (ORCPT + 99 others); Fri, 16 Jun 2023 06:05:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230108AbjFPKFh (ORCPT ); Fri, 16 Jun 2023 06:05:37 -0400 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9779F2137; Fri, 16 Jun 2023 03:05:35 -0700 (PDT) X-GND-Sasl: alexis.lothore@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686909934; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bu3ZgXdHuaAGXwkANc4+sjRTQos43KxjZuFR24WnayE=; b=MB6d8Q+efJDjMCCibSm0q2VQUawspSNupGdeu4AIyYnF8Kr/l2mSqcHmOklij2dXf0xHUk tjpJ5i/Mi+0wmJExgdWlqVW/EeLGopEBvb5S7RLExSoEDMwzH5NG5cdznKjVziHCoAhNMv HTftMCzak3QoMU8w92BIjqKQtJCwUndNbxSE5G4SDWYX18y5NO+ebczf/lCTkPfOr/KlNQ xjmsdTImMhCVfrhyc3SZgGs8QxDijRNejOAKG5t8JlfOiAHMljNy/Ds/Sc8kN6GQlh7sqF Wb9IGt0MI7XvUZHfT5Rn5v98g5wbq3yY2zEk2lbKidkyldL9m6SE5koVDAHj9Q== X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 0F28620010; Fri, 16 Jun 2023 10:05:33 +0000 (UTC) From: alexis.lothore@bootlin.com To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Thomas Petazzoni , Nicolas Carrier Subject: [PATCH net-next 3/8] net: stmmac: move PTP interrupt handling to IP-specific DWMAC file Date: Fri, 16 Jun 2023 12:04:04 +0200 Message-ID: <20230616100409.164583-4-alexis.lothore@bootlin.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616100409.164583-1-alexis.lothore@bootlin.com> References: <20230616100409.164583-1-alexis.lothore@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768853788528373877?= X-GMAIL-MSGID: =?utf-8?q?1768853788528373877?= From: Alexis Lothoré As for auxiliary snapshot triggers configuration, reading snapshots depends on specific registers addresses and layout. As a consequence, move PTP-specific part of stmmac interrupt handling to specific DWMAC IP file Signed-off-by: Alexis Lothoré --- drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 2 + .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 51 ++++++++++++++++++ .../ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 52 ------------------- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 2 - .../net/ethernet/stmicro/stmmac/stmmac_ptp.h | 3 -- 5 files changed, 53 insertions(+), 57 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h index d249a68f6787..9e7ba5f2e53a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h @@ -52,6 +52,8 @@ #define GMAC_L3_ADDR1(reg) (0x914 + (reg) * 0x30) #define GMAC_TIMESTAMP_STATUS 0x00000b20 #define GMAC_AUXILIARY_CONTROL 0x00000b40 /* Auxiliary Control Reg */ +#define GMAC_AT_NS 0x00000b48 /* Auxiliary Timestamp - Nanoseconds Reg */ +#define GMAC_AT_S 0x00000b4c /* Auxiliary Timestamp - Seconds Reg */ /* RX Queues Routing */ #define GMAC_RXQCTRL_AVCPQ_MASK GENMASK(2, 0) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index 01c0822d37e6..b36fbb0fa5da 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -16,6 +16,7 @@ #include #include "stmmac.h" #include "stmmac_pcs.h" +#include "stmmac_ptp.h" #include "dwmac4.h" #include "dwmac5.h" @@ -798,9 +799,56 @@ static int dwmac4_irq_mtl_status(struct stmmac_priv *priv, return ret; } +static void get_ptptime(void __iomem *ioaddr, u64 *ptp_time) +{ + u64 ns; + + ns = readl(ioaddr + GMAC_AT_NS); + ns += readl(ioaddr + GMAC_AT_S) * NSEC_PER_SEC; + + *ptp_time = ns; +} + +static void dwmac4_ptp_isr(struct stmmac_priv *priv) +{ + u32 num_snapshot, ts_status; + struct ptp_clock_event event; + unsigned long flags; + u64 ptp_time; + int i; + + if (priv->plat->int_snapshot_en) { + wake_up(&priv->tstamp_busy_wait); + return; + } + + /* Read timestamp status to clear interrupt from either external + * timestamp or start/end of PPS. + */ + ts_status = readl(priv->ioaddr + GMAC_TIMESTAMP_STATUS); + + if (!priv->plat->ext_snapshot_en) + return; + + num_snapshot = (ts_status & GMAC_TIMESTAMP_ATSNS_MASK) >> + GMAC_TIMESTAMP_ATSNS_SHIFT; + + for (i = 0; i < num_snapshot; i++) { + read_lock_irqsave(&priv->ptp_lock, flags); + get_ptptime(priv->ioaddr, &ptp_time); + read_unlock_irqrestore(&priv->ptp_lock, flags); + event.type = PTP_CLOCK_EXTTS; + event.index = 0; + event.timestamp = ptp_time; + ptp_clock_event(priv->ptp_clock, &event); + } +} + static int dwmac4_irq_status(struct mac_device_info *hw, struct stmmac_extra_stats *x) { + struct stmmac_priv *priv = + container_of(x, struct stmmac_priv, xstats); void __iomem *ioaddr = hw->pcsr; u32 intr_status = readl(ioaddr + GMAC_INT_STATUS); u32 intr_enable = readl(ioaddr + GMAC_INT_EN); @@ -841,6 +889,9 @@ static int dwmac4_irq_status(struct mac_device_info *hw, x->irq_rx_path_exit_lpi_mode_n++; } + if (intr_status & time_stamp_irq) + dwmac4_ptp_isr(priv); + dwmac_pcs_isr(ioaddr, GMAC_PCS_BASE, intr_status, x); if (intr_status & PCS_RGSMIIIS_IRQ) dwmac4_phystatus(ioaddr, x); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c index 8b50f03056b7..2cd0ec17f4c6 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c @@ -162,56 +162,6 @@ static void get_systime(void __iomem *ioaddr, u64 *systime) *systime = ns + (sec1 * 1000000000ULL); } -static void get_ptptime(void __iomem *ptpaddr, u64 *ptp_time) -{ - u64 ns; - - ns = readl(ptpaddr + PTP_ATNR); - ns += readl(ptpaddr + PTP_ATSR) * NSEC_PER_SEC; - - *ptp_time = ns; -} - -static void timestamp_interrupt(struct stmmac_priv *priv) -{ - u32 num_snapshot, ts_status, tsync_int; - struct ptp_clock_event event; - unsigned long flags; - u64 ptp_time; - int i; - - if (priv->plat->int_snapshot_en) { - wake_up(&priv->tstamp_busy_wait); - return; - } - - tsync_int = readl(priv->ioaddr + GMAC_INT_STATUS) & GMAC_INT_TSIE; - - if (!tsync_int) - return; - - /* Read timestamp status to clear interrupt from either external - * timestamp or start/end of PPS. - */ - ts_status = readl(priv->ioaddr + GMAC_TIMESTAMP_STATUS); - - if (!priv->plat->ext_snapshot_en) - return; - - num_snapshot = (ts_status & GMAC_TIMESTAMP_ATSNS_MASK) >> - GMAC_TIMESTAMP_ATSNS_SHIFT; - - for (i = 0; i < num_snapshot; i++) { - read_lock_irqsave(&priv->ptp_lock, flags); - get_ptptime(priv->ptpaddr, &ptp_time); - read_unlock_irqrestore(&priv->ptp_lock, flags); - event.type = PTP_CLOCK_EXTTS; - event.index = 0; - event.timestamp = ptp_time; - ptp_clock_event(priv->ptp_clock, &event); - } -} - const struct stmmac_hwtimestamp stmmac_ptp = { .config_hw_tstamping = config_hw_tstamping, .init_systime = init_systime, @@ -219,6 +169,4 @@ const struct stmmac_hwtimestamp stmmac_ptp = { .config_addend = config_addend, .adjust_systime = adjust_systime, .get_systime = get_systime, - .get_ptptime = get_ptptime, - .timestamp_interrupt = timestamp_interrupt, }; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 5c645b6d5660..4f0ef73d5121 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -5804,8 +5804,6 @@ static void stmmac_common_interrupt(struct stmmac_priv *priv) else netif_carrier_off(priv->dev); } - - stmmac_timestamp_interrupt(priv, priv); } } diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h index 9e0ff2cec352..92ed421702b9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h @@ -23,9 +23,6 @@ #define PTP_STSUR 0x10 /* System Time – Seconds Update Reg */ #define PTP_STNSUR 0x14 /* System Time – Nanoseconds Update Reg */ #define PTP_TAR 0x18 /* Timestamp Addend Reg */ -#define PTP_ACR 0x40 /* Auxiliary Control Reg */ -#define PTP_ATNR 0x48 /* Auxiliary Timestamp - Nanoseconds Reg */ -#define PTP_ATSR 0x4c /* Auxiliary Timestamp - Seconds Reg */ #define PTP_STNSUR_ADDSUB_SHIFT 31 #define PTP_DIGITAL_ROLLOVER_MODE 0x3B9ACA00 /* 10e9-1 ns */ From patchwork Fri Jun 16 10:04:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexis_Lothor=C3=A9?= X-Patchwork-Id: 109014 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1225174vqr; Fri, 16 Jun 2023 03:18:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6xfOSljwKOKZSY8DtY0gtZZ62cY4HF6G/V0Z4ebJzCR31/qdKiqsEvm3dbAxn3p/sc7/KO X-Received: by 2002:a17:902:d501:b0:1b0:307c:e706 with SMTP id b1-20020a170902d50100b001b0307ce706mr1313369plg.45.1686910684160; Fri, 16 Jun 2023 03:18:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686910684; cv=none; d=google.com; s=arc-20160816; b=irNAd9eg6Ph7pE3dERFfHejDsY8ONFE/Y768jb1I2KWiLHPuEYArgxNW8N1TqLKbx2 unL+9uPiKccHClQ/yqbwOaCoW8e3fLJ4o+uIAwfazXAQ/xj0OHIS/MJgtD6Tg63KT9ed U6Yjwi4gE0OSAaVXYH8FtZ7NCCftgvxWyKTqAWJQvwXyPVN9cpcn1GL0MzlwEcnC5dq8 vW6hB6BUvvd5+oAmungeq8W3Ma63z6UMbB3nwVtXLSmLQxU19wvTH3YXh6iE01P6CyIX 23mlW3aJpcesKDDEmOVT0fePX9W4jbT/z/3Mp8+rViKvv5uoMDd8Q6Fgubk6+nQxGZCi YkJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WQbCjIioSzpbvbd6fIl1lAwDG3upjPsirLpyT1TX/+k=; b=yjvyGkBqHpUCyTPUOhq6JhHV25t47XygpoNsyI7DbVa+eMUAm17vjIPhMxXQebJI9u CWKMZxBq2Q5eCmeMmLI0q9OP2Ln3ai57xIZbJlFUNG4SexQwE8ducO7iI/HsD6BxvWTA t1fXLoUkpURSlAkgPzeJce8oZWd+5aAnh4i8Gni35Z1dK3Grf+KUPSi6C422LX7ZYYZT iQJZA1Y1F0TJ/efkI5JJZjQCzambs370VHELfFqt86X+ihvCARUYfu2UNfw+l6ZexO32 k2ZR7LPSOmqiypYmPImrKh5zOdAUJZIkiW6UXmVH4IYKgvMLJqQ1oO4s+Lh79bWqTu5u Fx8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=FwY8GMlD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kz3-20020a170902f9c300b001a65688c863si403301plb.56.2023.06.16.03.17.48; Fri, 16 Jun 2023 03:18:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=FwY8GMlD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244144AbjFPKFz (ORCPT + 99 others); Fri, 16 Jun 2023 06:05:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232166AbjFPKFi (ORCPT ); Fri, 16 Jun 2023 06:05:38 -0400 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC8DB2D69; Fri, 16 Jun 2023 03:05:36 -0700 (PDT) X-GND-Sasl: alexis.lothore@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686909935; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WQbCjIioSzpbvbd6fIl1lAwDG3upjPsirLpyT1TX/+k=; b=FwY8GMlD/bBWxk8342rA6F1IqDZ1jjrj++Nq7MUtdB9mGuU2C72330sqMSEubUgeEIby8G /FuksITI31BlpVpofEogiJe3NdE4Z6hwTtxfe3ErdY5NALmv5t5hivLA/jaS8xC1mvMdkd e5uSI0AB5xO0bjjobDQqbRV55DjeDv6ZmqFrijmS+caeeq2xP72H2zv8CeFzAlmQgfAPhc L1S5kQ8TPNghKGkjm3xR+xQX4NL9Uumb8MGH9pOAS30gyGcKbq0nZBbk+KfGxcd1+6mzkq nI8ebkmz5rZgSV/WTqv7Bark6usUQJnoutNBXNcICbmq3FNiSLzngxksao9tEA== X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 6708420002; Fri, 16 Jun 2023 10:05:34 +0000 (UTC) From: alexis.lothore@bootlin.com To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Thomas Petazzoni , Nicolas Carrier Subject: [PATCH net-next 4/8] net: stmmac: move common defines in stmmac_ptp.h Date: Fri, 16 Jun 2023 12:04:05 +0200 Message-ID: <20230616100409.164583-5-alexis.lothore@bootlin.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616100409.164583-1-alexis.lothore@bootlin.com> References: <20230616100409.164583-1-alexis.lothore@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768854057118709063?= X-GMAIL-MSGID: =?utf-8?q?1768854057118709063?= From: Alexis Lothoré Even if the address of registers containing statuses is not the same between dwamc4 and dwmac 1000, the offsets of interest inside those register are the same regarding auxiliary snapshots. As a consequence, move those offset definitions in stmmac_ptp.h Signed-off-by: Alexis Lothoré --- drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 5 ----- drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h | 4 +++- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h index 9e7ba5f2e53a..32a15c020a43 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h @@ -313,11 +313,6 @@ enum power_event { #define GMAC_L4DP0_SHIFT 16 #define GMAC_L4SP0 GENMASK(15, 0) -/* MAC Timestamp Status */ -#define GMAC_TIMESTAMP_AUXTSTRIG BIT(2) -#define GMAC_TIMESTAMP_ATSNS_MASK GENMASK(29, 25) -#define GMAC_TIMESTAMP_ATSNS_SHIFT 25 - /* MTL registers */ #define MTL_OPERATION_MODE 0x00000c00 #define MTL_FRPE BIT(15) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h index 92ed421702b9..04bbf12dfd4b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.h @@ -64,6 +64,8 @@ #define PTP_SSIR_SSINC_MAX 0xff #define GMAC4_PTP_SSIR_SSINC_SHIFT 16 - +/* MAC Timestamp Status */ +#define GMAC_TIMESTAMP_ATSNS_MASK GENMASK(29, 25) +#define GMAC_TIMESTAMP_ATSNS_SHIFT 25 #endif /* __STMMAC_PTP_H__ */ From patchwork Fri Jun 16 10:04:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexis_Lothor=C3=A9?= X-Patchwork-Id: 109005 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1219817vqr; Fri, 16 Jun 2023 03:10:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5tnBNUOUltSMI3ifUPwrfH9tu3Ji/r7TNIAnogYvCFttv1l7tyCFPwi+fe7ThEozzrkGE+ X-Received: by 2002:a05:6a20:7491:b0:104:8045:c952 with SMTP id p17-20020a056a20749100b001048045c952mr9153513pzd.23.1686910209829; Fri, 16 Jun 2023 03:10:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686910209; cv=none; d=google.com; s=arc-20160816; b=q5lUzA2q77SGZZY30/fGDPgL7GixFg5aR1R/Uuefta/V7MMOvCBQ5675tWhHJx8gi4 cykODxmJdmQ5aUfmX9y138U++wkDfSFE773wS0TfoZfw1qb9JJmVDw98SZ46mGByzRsQ 7ZckdTgVrTONEGpOdeB1uDH/0HIcsVqTe/bq8o+j8yWMfRY0FR2nZhjb+jpB1gdwB3gL ew2V8MlJPC4r+Q2QNEGqw0pNBdT3jY14Ep5uZRSABuRWglJTiZl8VmmYdkTo96qZn1Pb YaHS3ueqfySxRAhKgbvidQhTiGzC8GE5xpX4Fl7BZqhDrV1CUmmBWO4YJ9AkuO9RT+t0 aXHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TuLT0Dx8INmVuQ+Tjg5nObFk3ZPU55oE6gxmpAOjP2k=; b=oywGs7xA1wKvRQF7po7xPjoU6tkZcmntA2N6rT/Gqa4KyPcXAdess1A4KbcTMKUT/p 3vki7m4V42vnOL3IcWqQY9sWyM0hpLf3UNFbUwvTq7CSlkkoUTD7RuBXwrU0bNNGT0aI mAOyXXHP2pyBUOOL0HbcetxpBP3oGVyr6rD5OOR70+Yak2lRgBuYJFesllWIRS6CHxlv M0zCCEEOSPPmK5Z4a5jFZ27/PKw6dRti/NseajhD4i/GeU7mwUyvt85sQVG1MmJcD81B oEv4oPQyQe+sZJG5Jbm3U3fs68qPJKXaI7w+vRZhQgdgHbd669R2fCW5Db/VNNLxt9X/ xrbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=lzUlV6Vl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z8-20020a63b908000000b005533c53f3fbsi1651336pge.800.2023.06.16.03.09.54; Fri, 16 Jun 2023 03:10:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=lzUlV6Vl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244629AbjFPKF6 (ORCPT + 99 others); Fri, 16 Jun 2023 06:05:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229558AbjFPKFj (ORCPT ); Fri, 16 Jun 2023 06:05:39 -0400 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4352B2D67; Fri, 16 Jun 2023 03:05:38 -0700 (PDT) X-GND-Sasl: alexis.lothore@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686909936; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TuLT0Dx8INmVuQ+Tjg5nObFk3ZPU55oE6gxmpAOjP2k=; b=lzUlV6Vl1+7PGIIxMRVfnCBB6Dz/NpkZawq1V/uJWhuAkOFIuN+draPM1L5Gg566KO4kvF z8zjlfLDt8oXatl77D3OHSqS/P5KebT1YLOHsBw2aGvtvFrYeZsNMFFYazPh/h80l8mpzu PjKiDGTM7rvRB7E9n7NNjVRH/0TnjV+/oNTag4KyZ4mLPJGNMpdliEy5NXYRM9kHDAAqC1 NqCggXkU2o8fSr+1asolZiUSSvxvvj1VmoZOTRnkNtWvMgaGMZthqLCU+yZqKtSF6riVM0 SpxF5DQJi9JFcreWJcbOgVttfiHi08F8TPdlEpG1VL1p168dIPEAdqu27IChVw== X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id ADD9920007; Fri, 16 Jun 2023 10:05:35 +0000 (UTC) From: alexis.lothore@bootlin.com To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Thomas Petazzoni , Nicolas Carrier Subject: [PATCH net-next 5/8] net: stmmac: set number of snapshot external triggers for GMAC3 Date: Fri, 16 Jun 2023 12:04:06 +0200 Message-ID: <20230616100409.164583-6-alexis.lothore@bootlin.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616100409.164583-1-alexis.lothore@bootlin.com> References: <20230616100409.164583-1-alexis.lothore@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768853560101256367?= X-GMAIL-MSGID: =?utf-8?q?1768853560101256367?= From: Alexis Lothoré While GMAC4 exposes number of available auxiliary snapshots inputs in MAC_HW_FEATURE2 register, GMAC3 (DWMAC1000) does not expose this information in its only hardware feature register. When running on GMAC3, hardcode the value to 1 to allow external trigger usage Signed-off-by: Alexis Lothoré --- drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c index 167bfbf68911..090a9d803446 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c @@ -280,7 +280,10 @@ void stmmac_ptp_register(struct stmmac_priv *priv) priv->plat->cdc_error_adj = (2 * NSEC_PER_SEC) / priv->plat->clk_ptp_rate; stmmac_ptp_clock_ops.n_per_out = priv->dma_cap.pps_out_num; - stmmac_ptp_clock_ops.n_ext_ts = priv->dma_cap.aux_snapshot_n; + /* Number of available external triggers is not provided through a + * hardware capabilities register for GMAC3 + */ + stmmac_ptp_clock_ops.n_ext_ts = priv->plat->has_gmac ? 1 : priv->dma_cap.aux_snapshot_n; rwlock_init(&priv->ptp_lock); mutex_init(&priv->aux_ts_lock); From patchwork Fri Jun 16 10:04:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexis_Lothor=C3=A9?= X-Patchwork-Id: 109015 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1225212vqr; Fri, 16 Jun 2023 03:18:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7MeBfBIi1pFIJvYAJWYXPJIH8j56wrMpbe99LuEwQCLzgqqDB+xX4ej9bZ0Hyho0iGHltC X-Received: by 2002:a05:6359:2e90:b0:12f:1792:6bfc with SMTP id rp16-20020a0563592e9000b0012f17926bfcmr1108958rwb.17.1686910688135; Fri, 16 Jun 2023 03:18:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686910688; cv=none; d=google.com; s=arc-20160816; b=ZfY+izgre0ZjsPjpfEkdaZ+77L7xc7pIqCLQFf49tafAmhpWsYqO1lFB1sjomFHfbd nCNdHBWkz557/+axjoRWv0wv4KvShlXVNlXkihTPlAqiit4ElvAvQ1mueZxtzmwstghf zthrme1e+gGS2YPiLmOfWdZK9dXAkpo+u/BEJCpaJ9LPbdJ19FIeA50azNX48QAKYcUA tIVRekZIHC22ImWfXnByUR2qlf53PoaG90/vJYv0ppWxbppmpCoDvB6KDG2kGLWH1NcB cN22q8xYih3J/FQrGQeWEAQSeqtisGMxnHyPCM017s4LDzTde+G++VlbxaFxU1Zz5Chx wKKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NYtleP6ALm9DjFnX75BkWEiXccu4UQqKWZMcyeQcTVc=; b=hARfftsODYJH44m9MLHbT4JJwklJjNn1Bg7i8KboW88t/H719Uei/Px6/OY6O7wp+Z PlopqYKqrFaS12Xb/npOsCfYkwKn7YmJ35IrOWhLbb+j2sMtlAbVVje4JskwqdWU6I5j BfypcMzCmdaw75mm6sro02VlVgbqkKGxxO53RTg45ZiG1lKf9Xd/7/h5a2v4ABANcadE 7o5NSKlZzL/9F3CgR16Mf3boEiY3o0Q/SStmX5XwOZrkau9WeFoBGGqd3MyCElYZ2A14 9coo/jdvr0vhV9siJ4qIOMpPJghKy3oMwfTXtsUvN7oSHYGIFCOCpXRJiuUHQ6Lr4qNm kR6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=bVuD32OC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w15-20020a63934f000000b005533db5fbb0si1523294pgm.379.2023.06.16.03.17.53; Fri, 16 Jun 2023 03:18:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=bVuD32OC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230045AbjFPKGH (ORCPT + 99 others); Fri, 16 Jun 2023 06:06:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232355AbjFPKFk (ORCPT ); Fri, 16 Jun 2023 06:05:40 -0400 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5570B194; Fri, 16 Jun 2023 03:05:39 -0700 (PDT) X-GND-Sasl: alexis.lothore@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686909938; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NYtleP6ALm9DjFnX75BkWEiXccu4UQqKWZMcyeQcTVc=; b=bVuD32OCRkfoKqqd+GjpOZlYBL3/cZ0Gs1SZIDvFe+/r51UUGDB5Cx5AYiAKtYihhicTB9 QPA8ezsc4lv0pVDzIXZ/E4xMMXQ2cVJPko+EmH4Qer8NH3fl7CN07G4C1ufbp0DO3OZdA8 R5SO/tk4qD/V6AIFTnmJWYx6hHYkLiT1lEEBlfXgZJSx2giXMIEbIIHy5FIKi4DTWzbqhp BBZ+OAPvRSYaki/0kKFa8d5l6n0JpTLOZPKiX/TCp20ieG/9r8tiIUn8Mwn+Rg9341eCIJ UQcYf+abSmCGMKr5WDElVT3bSdYWIr9FrcHr77Xp6qe2awhZVUVwvtHIBZp1fw== X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id EB87C20013; Fri, 16 Jun 2023 10:05:36 +0000 (UTC) From: alexis.lothore@bootlin.com To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Thomas Petazzoni , Nicolas Carrier Subject: [PATCH net-next 6/8] net: stmmac: introduce setter/getter for timestamp configuration Date: Fri, 16 Jun 2023 12:04:07 +0200 Message-ID: <20230616100409.164583-7-alexis.lothore@bootlin.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616100409.164583-1-alexis.lothore@bootlin.com> References: <20230616100409.164583-1-alexis.lothore@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768854061495154175?= X-GMAIL-MSGID: =?utf-8?q?1768854061495154175?= From: Alexis Lothoré stmmac_hwtstamp_set currently writes the whole Timestamp Control register when configuring hardware timestamping. It is done for all GMAC variants, and leads to issues with DWMAC1000: this version also bears the Auxiliary Snapshot Trigger bit in the same register. This field, which is set independently with during PTP_CLK_REQ_EXTTS ioctl, is then overwritten when stmmac_hwtstamp_set is called. Introduce setter and getter to allow modifying only relevant parts of the timestamp control register instead of overwriting it all. Signed-off-by: Alexis Lothoré --- drivers/net/ethernet/stmicro/stmmac/hwif.h | 9 ++++++--- drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 10 ++++++++-- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.h b/drivers/net/ethernet/stmicro/stmmac/hwif.h index d0b2f13510aa..927324e3d748 100644 --- a/drivers/net/ethernet/stmicro/stmmac/hwif.h +++ b/drivers/net/ethernet/stmicro/stmmac/hwif.h @@ -534,7 +534,8 @@ struct stmmac_ops { /* PTP and HW Timer helpers */ struct stmmac_hwtimestamp { - void (*config_hw_tstamping) (void __iomem *ioaddr, u32 data); + void (*config_hw_tstamping_set)(void __iomem *ioaddr, u32 data); + u32 (*config_hw_tstamping_get)(void __iomem *ioaddr); void (*config_sub_second_increment)(void __iomem *ioaddr, u32 ptp_clock, int gmac4, u32 *ssinc); int (*init_systime) (void __iomem *ioaddr, u32 sec, u32 nsec); @@ -546,8 +547,10 @@ struct stmmac_hwtimestamp { void (*timestamp_interrupt)(struct stmmac_priv *priv); }; -#define stmmac_config_hw_tstamping(__priv, __args...) \ - stmmac_do_void_callback(__priv, ptp, config_hw_tstamping, __args) +#define stmmac_config_hw_tstamping_set(__priv, __args...) \ + stmmac_do_void_callback(__priv, ptp, config_hw_tstamping_set, __args) +#define stmmac_config_hw_tstamping_get(__priv, __args...) \ + stmmac_do_callback(__priv, ptp, config_hw_tstamping_get, __args) #define stmmac_config_sub_second_increment(__priv, __args...) \ stmmac_do_void_callback(__priv, ptp, config_sub_second_increment, __args) #define stmmac_init_systime(__priv, __args...) \ diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c index 2cd0ec17f4c6..cbb94d3e0fa1 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c @@ -18,11 +18,16 @@ #include "dwmac4.h" #include "stmmac.h" -static void config_hw_tstamping(void __iomem *ioaddr, u32 data) +static void config_hw_tstamping_set(void __iomem *ioaddr, u32 data) { writel(data, ioaddr + PTP_TCR); } +static u32 config_hw_tstamping_get(void __iomem *ioaddr) +{ + return readl(ioaddr + PTP_TCR); +} + static void config_sub_second_increment(void __iomem *ioaddr, u32 ptp_clock, int gmac4, u32 *ssinc) { @@ -163,7 +168,8 @@ static void get_systime(void __iomem *ioaddr, u64 *systime) } const struct stmmac_hwtimestamp stmmac_ptp = { - .config_hw_tstamping = config_hw_tstamping, + .config_hw_tstamping_set = config_hw_tstamping_set, + .config_hw_tstamping_get = config_hw_tstamping_get, .init_systime = init_systime, .config_sub_second_increment = config_sub_second_increment, .config_addend = config_addend, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 4f0ef73d5121..528d2e010926 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -792,7 +792,7 @@ static int stmmac_hwtstamp_set(struct net_device *dev, struct ifreq *ifr) ts_master_en | snap_type_sel; } - stmmac_config_hw_tstamping(priv, priv->ptpaddr, priv->systime_flags); + stmmac_config_hw_tstamping_set(priv, priv->ptpaddr, priv->systime_flags); memcpy(&priv->tstamp_config, &config, sizeof(config)); @@ -841,7 +841,7 @@ int stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32 systime_flags) if (!(priv->dma_cap.time_stamp || priv->dma_cap.atime_stamp)) return -EOPNOTSUPP; - stmmac_config_hw_tstamping(priv, priv->ptpaddr, systime_flags); + stmmac_config_hw_tstamping_set(priv, priv->ptpaddr, systime_flags); priv->systime_flags = systime_flags; /* program Sub Second Increment reg */ From patchwork Fri Jun 16 10:04:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexis_Lothor=C3=A9?= X-Patchwork-Id: 109007 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1219940vqr; Fri, 16 Jun 2023 03:10:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4utDEAgyM9fckAuZNkHDSI9qsQt9Dx6gpWrA/MGxqDc/EsTUWC3EwmlC3ef1lOrcye3VqL X-Received: by 2002:a05:6a20:e615:b0:111:366:eeb2 with SMTP id my21-20020a056a20e61500b001110366eeb2mr1734468pzb.9.1686910221919; Fri, 16 Jun 2023 03:10:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686910221; cv=none; d=google.com; s=arc-20160816; b=MT+WCoWddkypmBKveQy2xrF73jWnyTggOqncidYKBHmAFmkbdfv3eBxXgXsWTQqHyX gme0RA4VXzbJ3zfueL6c8eb1ST2AmUoWqCMUAkK6S8fSyBUbh4oFKzThX0dHk7nb6Bi1 toZgQuwyFcxNimnK3asYUxfnE7s9itHAq2XHqjckq3QOroiV+oxo/uGPaeVBnAJlF5ek +9hbsXeKYkAqX5sY60KVUMBmJ2rt3R+Ma4wFty0BUJ1XpEUqvPKW2SzNTJqy3MX3LJ0e xaLSRnTLHPNLmj20UX7N0K/bF0y/HaBSzLCt2VSti7O6wclTyqh2lx2qkjpm8Vjjpuj6 TBWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rkCCowvxOYGZg7Z9wbkDB7S4cuEwrkMFzeVio1wTdXo=; b=t74EarjRd3x1mDb2Gzm134T1kJrQQUg9dkzpuRgnAZqTXrdasXzE6wRw+uxM4+4OuV pPI7NGsMu9KWzEmwMazpfIW0247z8MitmdwsZujWJDI6KrZCyMYdR1vhdvS/pdbOwYBL nmU92U5xyhfsuByzzxrRoD0wBoOqJg7CLm+yyLQ0+T1x7KNYaMnALFLtKsiUpopFm+xI 7CkbBmAqkJku/Lh0LGG2p+6k/JbxRjoZgCyeJZ/rzps2VNiVzb5qB+63+GMfytSmtbNr pqfLsGkaWCMKH6PMNVQacNEby/MoiF1EgWcJJm4wUU4giVOI+EeJfWHyMo4/NjwF0La6 lnIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=NlNjR5Ik; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b3-20020a62cf03000000b0064354230c2asi621277pfg.367.2023.06.16.03.10.06; Fri, 16 Jun 2023 03:10:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=NlNjR5Ik; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229770AbjFPKGD (ORCPT + 99 others); Fri, 16 Jun 2023 06:06:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229658AbjFPKFl (ORCPT ); Fri, 16 Jun 2023 06:05:41 -0400 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87D1A2D67; Fri, 16 Jun 2023 03:05:40 -0700 (PDT) X-GND-Sasl: alexis.lothore@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686909939; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rkCCowvxOYGZg7Z9wbkDB7S4cuEwrkMFzeVio1wTdXo=; b=NlNjR5IkiS/CJUICRXHd3Pdo1W8yas6A2Oo6pwfqiAQO+7QGvo0k3a8IM+afn5B2XKdwbr MtWhVmbCN5DDEioTii3QuSGjQfveVj0G0Z/sJBRwIdWmECCZuMGdr4u7V1a/ss6AhgUQMg PVSZdgDUpckaph1m4J6etyD8BvA1x/eynmEZTnzUq9ALTNbD5dj4Nj1H0odPELVqLvjir6 onQGCqinFG/Wk6VozVsdDsZPNGuEzLFuZUre7dTmQ/OYkkzcVCWJZQXo7F0UoykYmDAUIE 9xy34PWfCvDrG9OGH1DwUk2YpoiMDT6jVQHxr/OQWJXCZsE0d3ec7yOTicWFmw== X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 2E0CE2000F; Fri, 16 Jun 2023 10:05:38 +0000 (UTC) From: alexis.lothore@bootlin.com To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Thomas Petazzoni , Nicolas Carrier Subject: [PATCH net-next 7/8] net: stmmac: do not overwrite other flags when writing timestamp control Date: Fri, 16 Jun 2023 12:04:08 +0200 Message-ID: <20230616100409.164583-8-alexis.lothore@bootlin.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616100409.164583-1-alexis.lothore@bootlin.com> References: <20230616100409.164583-1-alexis.lothore@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768853572971973025?= X-GMAIL-MSGID: =?utf-8?q?1768853572971973025?= From: Alexis Lothoré On some versions of GMAC IP, for example, DWMAC1000, we may overwrite some other flags like ATSEN0 when writing Timestamp Control register. Avoid overwriting those additional flags by setting a read-write-modify process only on flags of interest Signed-off-by: Alexis Lothoré --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 528d2e010926..ba483adf4e1a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -616,6 +616,10 @@ static void stmmac_get_rx_hwtstamp(struct stmmac_priv *priv, struct dma_desc *p, */ static int stmmac_hwtstamp_set(struct net_device *dev, struct ifreq *ifr) { + u32 reset_mask = PTP_TCR_SNAPTYPSEL_1 | PTP_TCR_TSIPV4ENA | + PTP_TCR_TSIPV6ENA | PTP_TCR_TSEVNTENA | + PTP_TCR_TSMSTRENA | PTP_TCR_TSVER2ENA | + PTP_TCR_TSIPENA | PTP_TCR_TSENALL; struct stmmac_priv *priv = netdev_priv(dev); struct hwtstamp_config config; u32 ptp_v2 = 0; @@ -783,7 +787,9 @@ static int stmmac_hwtstamp_set(struct net_device *dev, struct ifreq *ifr) priv->hwts_rx_en = ((config.rx_filter == HWTSTAMP_FILTER_NONE) ? 0 : 1); priv->hwts_tx_en = config.tx_type == HWTSTAMP_TX_ON; - priv->systime_flags = STMMAC_HWTS_ACTIVE; + priv->systime_flags = stmmac_config_hw_tstamping_get(priv, priv->ptpaddr); + priv->systime_flags &= ~reset_mask; + priv->systime_flags |= STMMAC_HWTS_ACTIVE; if (priv->hwts_tx_en || priv->hwts_rx_en) { priv->systime_flags |= tstamp_all | ptp_v2 | From patchwork Fri Jun 16 10:04:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexis_Lothor=C3=A9?= X-Patchwork-Id: 109012 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1224460vqr; Fri, 16 Jun 2023 03:16:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4QZ1sfqoZuSNRJiuQ3WajyHZVdyTeOuSiptRQwRR6gEmoxqhqiD0mE2P/EUr5FRCX0WgWV X-Received: by 2002:a17:902:8bcc:b0:1b2:450f:9b6 with SMTP id r12-20020a1709028bcc00b001b2450f09b6mr1262776plo.8.1686910618197; Fri, 16 Jun 2023 03:16:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686910618; cv=none; d=google.com; s=arc-20160816; b=tuStwWq4lFTr1Zi3smoF6ubiTWGzcKPNdWPhjNsqH7f7v9GqIMUUNyyjDv8rth3PCb zmglzdGXZB4+K9rrOmGams0Uk6/tGWNEucfbtq0yz6O4urlxpa7yn8kvQosfzZAuYJTy bP4QMHa7sLXvicDnr3N9d56bWmITPyYS4bPlp0/ony/MjaI78NMYgSqwOZAik3q91Z63 VYT9nBH7RAVr7kH88/CMWPaJVZfp/iEl9XsvCBlZZux0rFcVQtQoqFK8qvsQJtMmvxBU 53BrSsxCnb9o3jUqdlWwx6XlUf1Xhd6VOPyvrMH9NrmKCdgGjv4q841h94mqpFuyYvjE ie1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=t2Z5u2pdOFyGeWrHTpiauz2Y6DQCmtBj67ZZlH6r9Yw=; b=vnB082xw+ghn6cv1Zmklwn4hNGBLVPh/Nwt/cBUT5dMvy7wIDZP6jBgPwZmRm8kEpq NHv5mNmBvOnUL+rdF6qGLypHQSy7bKFE7dWNkOu0kgK3PnTUJ257pUqok/qPrVWG0JbT hsIFPt2ha8Q0VbpzRQA9W5q8/9Ra2noxICmLo7RdJ6/Jx0fVjYxypbSlLlmxLmlxmM5R iqNITSha9vOHfQ0zWh2W+Qdl5BBgSepbZ9DX533R4Z0D8ZnwioqXbA6tZPDAbL07RxMz NMaZmeeVQ7PrY2sOjKcnmHJpLDjEnOwWfFrJsjVyBrjKyDdQJ/kaJGWdXypmjIcGLwwq 57YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=VlB+mmJ2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s18-20020a170903201200b001a1deff6062si4806813pla.281.2023.06.16.03.16.43; Fri, 16 Jun 2023 03:16:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=VlB+mmJ2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244639AbjFPKGK (ORCPT + 99 others); Fri, 16 Jun 2023 06:06:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233955AbjFPKFn (ORCPT ); Fri, 16 Jun 2023 06:05:43 -0400 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB2C02D6A; Fri, 16 Jun 2023 03:05:41 -0700 (PDT) X-GND-Sasl: alexis.lothore@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1686909940; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t2Z5u2pdOFyGeWrHTpiauz2Y6DQCmtBj67ZZlH6r9Yw=; b=VlB+mmJ2KMVQ8xlzcP3HMRvb5AeWgOC78aVXaAdm09rhishVYbGo+PWKobqI3HDIUmYt2g 9H26shu1MISdr0Dia4H4wI2xmUuJX6x7PfTBr6o7bwSKeqNcq+SjtLTaIuzTSDGJiV2CTc eMZtWGVB03cIOL/+zTHKONDW9IVPnQ2JXqMX7Sh8ngeoZVSBwebjDYE/5hFvPuQ9kypHdO Gr0yiCKawtD8wSSvJjkdLmo0WZc6XL1ODdy2i94C7PBAt9Y19PpLySKigSUxM74dGF6eSn XWBgVNi/8rf6CjbYOie1iT5GEko7xJWXEPVqJQsGNDkOdydVBmyZKLTNTdEXEg== X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com X-GND-Sasl: alexis.lothore@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 70DAC20014; Fri, 16 Jun 2023 10:05:39 +0000 (UTC) From: alexis.lothore@bootlin.com To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, Thomas Petazzoni , Nicolas Carrier Subject: [PATCH net-next 8/8] net: stmmac: enable timestamp external trigger for dwmac1000 Date: Fri, 16 Jun 2023 12:04:09 +0200 Message-ID: <20230616100409.164583-9-alexis.lothore@bootlin.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616100409.164583-1-alexis.lothore@bootlin.com> References: <20230616100409.164583-1-alexis.lothore@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768853988816647648?= X-GMAIL-MSGID: =?utf-8?q?1768853988816647648?= From: Alexis Lothoré The code is pretty similar to dwmac4 snapshot external trigger code. The difference is mostly about used registers addresses and/or bits offset in registers Signed-off-by: Alexis Lothoré --- .../ethernet/stmicro/stmmac/dwmac-socfpga.c | 2 + .../net/ethernet/stmicro/stmmac/dwmac1000.h | 12 ++- .../ethernet/stmicro/stmmac/dwmac1000_core.c | 83 +++++++++++++++++++ 3 files changed, 95 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c index 6267bcb60206..98f5413cefee 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c @@ -17,6 +17,7 @@ #include "stmmac.h" #include "stmmac_platform.h" +#include "dwmac1000.h" #define SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII 0x0 #define SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RGMII 0x1 @@ -428,6 +429,7 @@ static int socfpga_dwmac_probe(struct platform_device *pdev) dwmac->ops = ops; plat_dat->bsp_priv = dwmac; plat_dat->fix_mac_speed = socfpga_dwmac_fix_mac_speed; + plat_dat->ext_snapshot_num = GMAC_TC_ATSEN0; ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); if (ret) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h index 4296ddda8aaa..d17929ea63e0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h @@ -41,8 +41,7 @@ #define GMAC_INT_DISABLE_PCS (GMAC_INT_DISABLE_RGMII | \ GMAC_INT_DISABLE_PCSLINK | \ GMAC_INT_DISABLE_PCSAN) -#define GMAC_INT_DEFAULT_MASK (GMAC_INT_DISABLE_TIMESTAMP | \ - GMAC_INT_DISABLE_PCS) +#define GMAC_INT_DEFAULT_MASK GMAC_INT_DISABLE_PCS /* PMT Control and Status */ #define GMAC_PMT 0x0000002c @@ -329,5 +328,14 @@ enum rtc_control { #define GMAC_MMC_RX_CSUM_OFFLOAD 0x208 #define GMAC_EXTHASH_BASE 0x500 +/* Timestamping registers */ +#define GMAC_TIMESTAMP_C0NTROL 0x00000700 +#define GMAC_TC_ATSFC BIT(24) +#define GMAC_TC_ATSEN0 BIT(25) +#define GMAC_TIMESTAMP_STATUS 0x00000728 +#define GMAC_AT_NS 0x00000730 +#define GMAC_AT_NS_MASK 0x7FFFFFFF +#define GMAC_AT_S 0x00000734 + extern const struct stmmac_dma_ops dwmac1000_dma_ops; #endif /* __DWMAC1000_H__ */ diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c index 3927609abc44..97d94b009014 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c @@ -19,6 +19,7 @@ #include "stmmac.h" #include "stmmac_pcs.h" #include "dwmac1000.h" +#include "stmmac_ptp.h" static void dwmac1000_core_init(struct mac_device_info *hw, struct net_device *dev) @@ -294,9 +295,58 @@ static void dwmac1000_rgsmii(void __iomem *ioaddr, struct stmmac_extra_stats *x) } } +static void get_ptptime(void __iomem *ioaddr, u64 *ptp_time) +{ + u64 ns; + + ns = (readl(ioaddr + GMAC_AT_NS) & GMAC_AT_NS_MASK); + *ptp_time = ns; + ns = readl(ioaddr + GMAC_AT_S); + *ptp_time += ns * NSEC_PER_SEC; +} + +static void dwmac1000_ptp_isr(struct stmmac_priv *priv) +{ + struct ptp_clock_event event; + u32 status_reg, num_snapshot; + unsigned long flags; + u64 ptp_time; + int i = 0; + + if (priv->plat->int_snapshot_en) { + wake_up(&priv->tstamp_busy_wait); + return; + } + + /* Read timestamp status to clear interrupt from either external + * timestamp or start/end of PPS. + */ + status_reg = readl(priv->ioaddr + GMAC_TIMESTAMP_STATUS); + + if (!priv->plat->ext_snapshot_en) + return; + + num_snapshot = (status_reg & GMAC_TIMESTAMP_ATSNS_MASK) >> + GMAC_TIMESTAMP_ATSNS_SHIFT; + if (!num_snapshot) + return; + + for (i = 0; i < num_snapshot; i++) { + read_lock_irqsave(&priv->ptp_lock, flags); + get_ptptime(priv->ioaddr, &ptp_time); + read_unlock_irqrestore(&priv->ptp_lock, flags); + event.type = PTP_CLOCK_EXTTS; + event.index = 0; + event.timestamp = ptp_time; + ptp_clock_event(priv->ptp_clock, &event); + } +} + static int dwmac1000_irq_status(struct mac_device_info *hw, struct stmmac_extra_stats *x) { + struct stmmac_priv *priv = + container_of(x, struct stmmac_priv, xstats); void __iomem *ioaddr = hw->pcsr; u32 intr_status = readl(ioaddr + GMAC_INT_STATUS); u32 intr_mask = readl(ioaddr + GMAC_INT_MASK); @@ -318,6 +368,9 @@ static int dwmac1000_irq_status(struct mac_device_info *hw, x->irq_receive_pmt_irq_n++; } + if (intr_status & GMAC_INT_STATUS_TSTAMP) + dwmac1000_ptp_isr(priv); + /* MAC tx/rx EEE LPI entry/exit interrupts */ if (intr_status & GMAC_INT_STATUS_LPIIS) { /* Clean LPI interrupt by reading the Reg 12 */ @@ -502,6 +555,34 @@ static void dwmac1000_set_mac_loopback(void __iomem *ioaddr, bool enable) writel(value, ioaddr + GMAC_CONTROL); } +static void dwmac1000_extts_configure(void __iomem *ioaddr, int ext_snapshot_num, + bool on, struct net_device *dev) +{ + u32 acr_value; + + /* Since DWMAC1000 has only one external trigger input, + * ext_snapshot_num is not used + */ + acr_value = readl(ioaddr + GMAC_TIMESTAMP_C0NTROL); + acr_value &= ~GMAC_TC_ATSEN0; + if (on) { + acr_value |= GMAC_TC_ATSEN0; + acr_value |= GMAC_TC_ATSFC; + netdev_dbg(dev, "Auxiliary Snapshot 0 enabled.\n"); + } else { + netdev_dbg(dev, "Auxiliary Snapshot 0 disabled.\n"); + } + writel(acr_value, ioaddr + GMAC_TIMESTAMP_C0NTROL); +} + +static int dwmac1000_clear_snapshot_fifo(void __iomem *ioaddr) +{ + u32 acr_value; + + return readl_poll_timeout(ioaddr + GMAC_TIMESTAMP_C0NTROL, acr_value, + !(acr_value & GMAC_TC_ATSFC), 10, 10000); +} + const struct stmmac_ops dwmac1000_ops = { .core_init = dwmac1000_core_init, .set_mac = stmmac_set_mac, @@ -522,6 +603,8 @@ const struct stmmac_ops dwmac1000_ops = { .pcs_rane = dwmac1000_rane, .pcs_get_adv_lp = dwmac1000_get_adv_lp, .set_mac_loopback = dwmac1000_set_mac_loopback, + .extts_configure = dwmac1000_extts_configure, + .clear_snapshot_fifo = dwmac1000_clear_snapshot_fifo }; int dwmac1000_setup(struct stmmac_priv *priv)