Message ID | cover.1699565880.git.daniel@makrotopia.org |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp727491vqs; Thu, 9 Nov 2023 13:51:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IHQ0Q+UERxolr0t2SUIOzh5LqsEHfUjG8bLinFQfEBWo8Vq1eGgb9sQfv1cUqgBjqXzLG1E X-Received: by 2002:a05:6830:1b63:b0:6cc:d4f7:e37d with SMTP id d3-20020a0568301b6300b006ccd4f7e37dmr7015652ote.5.1699566707748; Thu, 09 Nov 2023 13:51:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699566707; cv=none; d=google.com; s=arc-20160816; b=NyYTkdBE7XiBtNc7CbfvrPM7V3ckdltcu9bkR0Y1yw98zTHQLJYFjprClOwrxSEqGM UZpHbJ5Cc3BbPKOeDvDZSdCzb5sdrlYwW1bkPVZr97wYeVyiaRqsSElmSoHYIYlYRVLG 5pr8ryR95KdYyx8UswMJiSpziLrIR0fxAD6aw2cIYVFuuIhmVvK/klNT3GkBZdYTb0Ka ow5/vNnA+WhjQB3eA+3MR7lPkBkmVwmXzYPuRn8YDKusiXzBt/pl7gDtmLGDa6RGT2eu 1REIJxwjQ3rjIj1XhG4wmwTKWiiGKvWal6jRiacNA15cZbAF/uf4OkUATx+0d6N555Cu ttTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date; bh=1uolZe8cKTsNCbxzystCWtpbdkBcjS+VBbRWLg1T8NM=; fh=9GVzMIks0k0Waq6W0HUSHcdxejYnykUnl93AUDny5kk=; b=BSljrUGJW5L9lr0Nfy4CLSns7Y8r6zXiBkZSkuv/xSMd3aCDNl0Sfm19b7/+9cZvmm 68eT27nYyXG5ASzjScickPy1U8QJ5h+9XHiKDhTmRVcZkowYBkth0ez5ZyJzRFKRE2QX eaFYYs3RpbPNF2PXhWlbpzgfEXQpzNxFVp4b4kqx2jMpf2emwyQ9BN+ywBNvjuZENGJM 6BkCwnkMQgFB5zbc8JwD1TXgZm3dHmWOsK7yJUSp/5uJBJkWqJ4o0GTDyemxc3Wqr4Xz Mo0My9Vgv4bhhoFpgRGQ86g3DS5fr1ibBAac3e8IHi7yHjTdMUxSpKnkzp+GdZK5JEiM AUTQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id bw6-20020a056a02048600b005be09f31e07si2332710pgb.553.2023.11.09.13.51.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 13:51:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 90B398336C45; Thu, 9 Nov 2023 13:51:34 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232443AbjKIVvT (ORCPT <rfc822;lhua1029@gmail.com> + 30 others); Thu, 9 Nov 2023 16:51:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231724AbjKIVvS (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 9 Nov 2023 16:51:18 -0500 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D1A14212; Thu, 9 Nov 2023 13:51:16 -0800 (PST) Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96.2) (envelope-from <daniel@makrotopia.org>) id 1r1CvH-0003Tv-1d; Thu, 09 Nov 2023 21:50:47 +0000 Date: Thu, 9 Nov 2023 21:50:43 +0000 From: Daniel Golle <daniel@makrotopia.org> To: "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Conor Dooley <conor+dt@kernel.org>, Chunfeng Yun <chunfeng.yun@mediatek.com>, Vinod Koul <vkoul@kernel.org>, Kishon Vijay Abraham I <kishon@kernel.org>, Felix Fietkau <nbd@nbd.name>, John Crispin <john@phrozen.org>, Sean Wang <sean.wang@mediatek.com>, Mark Lee <Mark-MC.Lee@mediatek.com>, Lorenzo Bianconi <lorenzo@kernel.org>, Matthias Brugger <matthias.bgg@gmail.com>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, Andrew Lunn <andrew@lunn.ch>, Heiner Kallweit <hkallweit1@gmail.com>, Russell King <linux@armlinux.org.uk>, Alexander Couzens <lynxis@fe80.eu>, Daniel Golle <daniel@makrotopia.org>, Philipp Zabel <p.zabel@pengutronix.de>, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-phy@lists.infradead.org Subject: [RFC PATCH 0/8] Add support for 10G Ethernet SerDes on MT7988 Message-ID: <cover.1699565880.git.daniel@makrotopia.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 09 Nov 2023 13:51:34 -0800 (PST) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782124859636350695 X-GMAIL-MSGID: 1782124859636350695 |
Series |
Add support for 10G Ethernet SerDes on MT7988
|
|
Message
Daniel Golle
Nov. 9, 2023, 9:50 p.m. UTC
This series aims to add support for GMAC2 and GMAC3 of the MediaTek MT7988 SoC. While the vendor SDK stuffs all this into their Ethernet driver, I've tried to seperate things into a PHY driver, a PCS driver as well as changes to the existing Ethernet and LynxI PCS driver. +----------------+ +--------------+ | USXGMII PCS | +------------------+ | Ethernet MAC +--+-------------+ +---+ PEXTP SerDes PHY | +--------------+ | SGMII PCS | | +------------------+ +-------------+--+ Alltogether this allows using GMAC2 and GMAC3 with all possible interface modes, including in-band-status if needed. Daniel Golle (8): dt-bindings: phy: mediatek,xfi-pextp: add new bindings phy: add driver for MediaTek pextp 10GE SerDes PHY net: pcs: pcs-mtk-lynxi: use 2500Base-X without AN net: pcs: pcs-mtk-lynxi: allow calling with NULL advertising dt-bindings: net: pcs: add bindings for MediaTek USXGMII PCS net: pcs: add driver for MediaTek USXGMII PCS dt-bindings: net: mediatek,net: fix and complete mt7988-eth binding net: ethernet: mtk_eth_soc: add paths and SerDes modes for MT7988 .../devicetree/bindings/net/mediatek,net.yaml | 171 ++++- .../bindings/net/pcs/mediatek,usxgmii.yaml | 105 +++ .../bindings/phy/mediatek,xfi-pextp.yaml | 71 ++ MAINTAINERS | 3 + drivers/net/ethernet/mediatek/Kconfig | 17 + drivers/net/ethernet/mediatek/mtk_eth_path.c | 122 +++- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 178 ++++- drivers/net/ethernet/mediatek/mtk_eth_soc.h | 105 ++- drivers/net/pcs/Kconfig | 10 + drivers/net/pcs/Makefile | 1 + drivers/net/pcs/pcs-mtk-lynxi.c | 38 +- drivers/net/pcs/pcs-mtk-usxgmii.c | 688 ++++++++++++++++++ drivers/phy/mediatek/Kconfig | 11 + drivers/phy/mediatek/Makefile | 1 + drivers/phy/mediatek/phy-mtk-pextp.c | 355 +++++++++ include/linux/pcs/pcs-mtk-usxgmii.h | 18 + 16 files changed, 1813 insertions(+), 81 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/pcs/mediatek,usxgmii.yaml create mode 100644 Documentation/devicetree/bindings/phy/mediatek,xfi-pextp.yaml create mode 100644 drivers/net/pcs/pcs-mtk-usxgmii.c create mode 100644 drivers/phy/mediatek/phy-mtk-pextp.c create mode 100644 include/linux/pcs/pcs-mtk-usxgmii.h
Comments
> + mediatek,usxgmii-performance-errata: > + $ref: /schemas/types.yaml#/definitions/flag > + description: > + USXGMII0 on MT7988 suffers from a performance problem in 10GBase-R > + mode which needs a work-around in the driver. The work-around is > + enabled using this flag. Is there more details about this? I'm just wondering if this should be based on the compatible, rather than a bool property. Andrew
Hi Andrew, On Thu, Nov 09, 2023 at 10:55:55PM +0100, Andrew Lunn wrote: > > + mediatek,usxgmii-performance-errata: > > + $ref: /schemas/types.yaml#/definitions/flag > > + description: > > + USXGMII0 on MT7988 suffers from a performance problem in 10GBase-R > > + mode which needs a work-around in the driver. The work-around is > > + enabled using this flag. > > Is there more details about this? I'm just wondering if this should be > based on the compatible, rather than a bool property. The vendor sources where this is coming from are here: https://git01.mediatek.com/plugins/gitiles/openwrt/feeds/mtk-openwrt-feeds/+/a500d94cd47e279015ce22947e1ce396a7516598%5E%21/#F0 And I'm afraid this is as much detail as it gets. And yes, we could also base this on the compatible and just have two different ones for the two PEXTP instances found in MT7988. Let me know your conclusion in that regard. Cheers Daniel
On Thu, Nov 09, 2023 at 09:50:55PM +0000, Daniel Golle wrote: > Add bindings for the MediaTek PEXTP Ethernet SerDes PHY found in the > MediaTek MT7988 SoC which can operate at various interfaces modes: > > * USXGMII > * 10GBase-R > * 5GBase-R > * 2500Base-X > * 1000Base-X > * Cisco SGMII (MAC side) > > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > --- > .../bindings/phy/mediatek,xfi-pextp.yaml | 71 +++++++++++++++++++ > 1 file changed, 71 insertions(+) > create mode 100644 Documentation/devicetree/bindings/phy/mediatek,xfi-pextp.yaml > > diff --git a/Documentation/devicetree/bindings/phy/mediatek,xfi-pextp.yaml b/Documentation/devicetree/bindings/phy/mediatek,xfi-pextp.yaml > new file mode 100644 > index 0000000000000..948d5031af1e3 > --- /dev/null > +++ b/Documentation/devicetree/bindings/phy/mediatek,xfi-pextp.yaml > @@ -0,0 +1,71 @@ > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > +%YAML 1.2 > +--- > +$id: http://devicetree.org/schemas/phy/mediatek,xfi-pextp.yaml# > +$schema: http://devicetree.org/meta-schemas/core.yaml# > + > +title: MediaTek XFI PEXTP SerDes PHY > + > +maintainers: > + - Daniel Golle <daniel@makrotopia.org> > + > +description: | Don't need '|' here. > + The MediaTek XFI PEXTP SerDes PHY provides the physical SerDes lanes > + used by the MediaTek USXGMII PCS. > + > +properties: > + $nodename: > + pattern: "^phy@[0-9a-f]+$" > + > + compatible: > + const: mediatek,mt7988-xfi-pextp > + > + reg: > + maxItems: 1 > + > + clocks: > + items: > + - description: XFI PHY clock > + > + resets: > + items: > + - description: PEXTP reset > + > + mediatek,usxgmii-performance-errata: > + $ref: /schemas/types.yaml#/definitions/flag > + description: > + USXGMII0 on MT7988 suffers from a performance problem in 10GBase-R > + mode which needs a work-around in the driver. The work-around is > + enabled using this flag. > + > + "#phy-cells": > + const: 0 > + > +required: > + - compatible > + - reg > + - clocks > + - resets > + - "#phy-cells" > + > +additionalProperties: false > + > +examples: > + - | > + #include <dt-bindings/clock/mediatek,mt7988-clk.h> > + #include <dt-bindings/reset/mediatek,mt7988-resets.h> > + soc { > + #address-cells = <2>; > + #size-cells = <2>; > + > + xfi_pextp0: phy@11f20000 { Drop unused labels. > + compatible = "mediatek,mt7988-xfi-pextp"; > + reg = <0 0x11f20000 0 0x10000>; > + clocks = <&topckgen CLK_TOP_XFI_PHY_0_XTAL_SEL>; > + resets = <&watchdog MT7988_TOPRGU_XFI_PEXTP0_GRST>; > + mediatek,usxgmii-performance-errata; > + #phy-cells = <0>; > + }; > + }; > + > +... > -- > 2.42.1
On Do, 2023-11-09 at 21:52 +0000, Daniel Golle wrote: > MT7988 comes with a built-in 2.5G PHY as well as SerDes lanes to > connect external PHYs or transceivers in USXGMII, 10GBase-R, 5GBase-R, > 2500Base-X, 1000Base-X and Cisco SGMII interface modes. > > Implement support for configuring for the new paths to SerDes interfaces > and the internal 2.5G PHY. > > Add USXGMII PCS driver for 10GBase-R, 5GBase-R and USXGMII mode, and > setup the new PHYA on MT7988 to access the also still existing old > LynxI PCS for 1000Base-X, 2500Base-X and Cisco SGMII PCS interface > modes. > > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > --- [...] > diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h > index 9ae3b8a71d0e6..ba5998ef7965e 100644 > --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h > +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h > @@ -15,6 +15,7 @@ > #include <linux/u64_stats_sync.h> > #include <linux/refcount.h> > #include <linux/phylink.h> > +#include <linux/reset.h> I can't see what this is required for? regards Philipp
On Thu, Nov 09, 2023 at 09:51:57PM +0000, Daniel Golle wrote: > Add driver for USXGMII PCS found in the MediaTek MT7988 SoC and supporting > USXGMII, 10GBase-R and 5GBase-R interface modes. In order to support > Cisco SGMII, 1000Base-X and 2500Base-X via the also present LynxI PCS > create a wrapped PCS taking care of the components shared between the > new USXGMII PCS and the legacy LynxI PCS. What is the actual hardware setup here? From what I can tell, it's something like this: .---- LynxI PCS ----. MAC ---+ +--- PEXP --- external `--- USXGMII PCS ---' Where PEXP is the serdes, handled by the drivers/phy layer in the kernel. This is not an unusual setup, but we don't have the serdes PHY controlled by the PCS driver. You seem to be combining the whole lot into one driver, which seems rather odd. I would suggest that the serdes PHY is handled in the MAC driver, using the mac_prepare(), mac_config() and mac_finish() methods, as well as other parts of the driver: - when the netdev is opened, call phy_power_on(pextp) - when the netdev is closed, call phy_power_off(pextp) - in mac_prepare(), if the interface has changed, call phy_reset(pextp) - in mac_finish(), if the interface has changed, update your recorded interface mode to detect future changes in either mac_prepare() or mac_finish(), and call phy_set_mode_ext(pextp, PHY_MODE_ETHERNET, interface). That will move most of what seems to be duplicated between the two PCS instances out of the PCS driver and to MAC level, and then the PCS parts become more about just driving the PCS hardware and nothing beyond that. More specifically, the wrapping's only function then is to deal with the sgmii reset. What exactly is that reset signal controlling? The reset to the LynxI PCS or something else? If you don't do that (and I prefer that you _do_ the above), then the following comments apply to the code here: 1. the use of phy_power_on() without any calls to phy_power_off(). These are counted calls, and after the first call to phy_power_on(), the only effect will be to increase the enable-counts of any associated regulator and the power count. So, basically you're missing calls to phy_power_off(). I suggest a call to phy_power_off() in the pcs_disable() function. 2. calling phy_power_on() in pcs_config() is entirely unnecessary. pcs_config() will not be called unless pcs_enable() has _already_ been called, so the call to phy_power_on() in the pcs_enable() function is entirely sufficient. With these two fixed, it means that the pextp PHY will be powered up when one of the pcs_enable() functions is called, and powered down when one of the pcs_disable() functions is called. 3. the complicated reset sequence, which is basically: - phy_reset(pextp) - reset_control_assert(sgmii or xfi reset) - *sleep* 100-500us (yes, sleep) - reset_control_deassert(sgmii or xfi reset) - *delay* 10ms (not sleep, but spin wait) If we are in a schedulable context (which the usleep_range() suggests we are) then why bother sleeping for the short delay, and spin-waiting for the longer delay? A bit of consistency seems to be needed here. 4. really needs to explain why it's necessary to repeatedly call the pcs_config() function at each get_state() if the link is down. Note that with the code the way it is, phy_power_on() will be repeatedly called, and at some point the "power_count" will overflow which would probably be bad. The counting in the regulator core will probably also overflow as well. So this is bad. Apart from the overflow issue, the only thing I can see that this achieves is to call the core of the pcs_config function. In the case of the lynxi, calling its pcs_config() repeatedly with the same parameters. Looking at pcs-mtk-lynxi.c, I can't see what this would achieve. With the above issues dealt with, from the point of view of the lynxi / sgmii code, the only things I can see that the wrapping achieves are: a) when pcs_enable() is called, call phy_power_on(pextp) b) when pcs_disable() is called, call phy_power_offpextp) c) when pcs_config() is called, if the interface has changed: i) call phy_reset() and assert/deassert the "sgmii" reset before calling the lynxi PCS ii) call phy_set_mode_ext(pextp) for the new interface mode after calling the lynxi PCS I haven't picked through the usxgmii code completely, so I'm not specifically commenting on it, although some of the above applies there as well. Thanks.