Message ID | 20230321111958.2800005-3-s-vadapalli@ti.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1725229wrt; Tue, 21 Mar 2023 04:44:08 -0700 (PDT) X-Google-Smtp-Source: AK7set/m6JmfTZhjMTdcUsEyZa9BtUsw/UvGYWuOWV8mkMUljekQLbV0DuGPd5PGi7RriSc4PuCL X-Received: by 2002:a17:90b:4a02:b0:23f:e675:9c4a with SMTP id kk2-20020a17090b4a0200b0023fe6759c4amr2297774pjb.21.1679399048626; Tue, 21 Mar 2023 04:44:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679399048; cv=none; d=google.com; s=arc-20160816; b=IMRMvaJGDy9fyvpzEhlJidtTt+lwMV43q2SdIm5/f/oEiiUu0fmwcXKPwV1VjsjUXU RjcpXXvfVSXMRVLHosa/h0haJoLXKuzJVLn3o/UpURBQa6HlMY0Vlp4CDL7n2PB7gDHi 5C4rTx6J6iEkk36DQQ+srUU4ZuBKBc22ETjnrdz7JOi7qRwlvVLRe2SBlrVjisRaSAkX 9zjJSaWmrf1+UsSxMQh6ykstqxH7G4Op5XQa32yjhIxB9duddoDSeOeDga3YC4K0G/FG 3sOHN+6PM98B0LzyobRSyw05If/u2kZkeCffR+WOCxXJ3IjXwyvL3/dHQEu8TdLNUpcE 5z+A== 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=rg0pr5+qWnGZXVJsqCJwL2c2bXVbI+dN4RZpf6rUM8o=; b=iGLli7WYA5uGKU1i/n5H20oEyad91q8fOPyGvljSMT8o582n4mnBch0C4kXtaAZX1o rBMIB5YyJaFOa70CgspaRuUxx6eocSwgg9um3Y8fKjViq7fEjlIajmXudFmDR11dM/CR /rtJXuqbX3qYzjkvHz9sW/iXXXka+BqdlAES4wfsjzB0bbiuw5t6uS3FYfsg0psNzOKe p3AiqYgQAqeY6gfRgXjCSD0W6R9Zaw5AVIdw22p+7WBqzxWixcSQGuk6eoaYJ9NjOTDp brOPzJ/4MlZbikkUg23n+37V0ic02LMbOCLwGCM7z2jphZY0yhkm7VFSKYaAzHg2vXFR ug0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="LJybZsh/"; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h132-20020a636c8a000000b0050f8d62c7b5si4023569pgc.785.2023.03.21.04.43.55; Tue, 21 Mar 2023 04:44: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=@ti.com header.s=ti-com-17Q1 header.b="LJybZsh/"; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231177AbjCULUw (ORCPT <rfc822;ezelljr.billy@gmail.com> + 99 others); Tue, 21 Mar 2023 07:20:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230172AbjCULUn (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 21 Mar 2023 07:20:43 -0400 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3307B33CD0; Tue, 21 Mar 2023 04:20:25 -0700 (PDT) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 32LBK9r2127867; Tue, 21 Mar 2023 06:20:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1679397610; bh=rg0pr5+qWnGZXVJsqCJwL2c2bXVbI+dN4RZpf6rUM8o=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=LJybZsh/aPXT7rXlUyDWAqJK+AbG9k1iCcuA71oOjbvTzhjnbj9Z0Zmq+2lmiKhxu vwj1vy2t4Xo9BuGwFvp0yfjW/hikrzo/ht0w33aM7yDXhWl8tpd0pKLNddN6rwXt4d 6T/dkntlH+VHzbg/aei4oXuViHEKLqI1zfowUvHk= Received: from DLEE101.ent.ti.com (dlee101.ent.ti.com [157.170.170.31]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 32LBK9VS091452 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 21 Mar 2023 06:20:09 -0500 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16; Tue, 21 Mar 2023 06:20:09 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.16 via Frontend Transport; Tue, 21 Mar 2023 06:20:09 -0500 Received: from uda0492258.dhcp.ti.com (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 32LBJxVo088542; Tue, 21 Mar 2023 06:20:06 -0500 From: Siddharth Vadapalli <s-vadapalli@ti.com> To: <davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>, <linux@armlinux.org.uk>, <pabeni@redhat.com>, <rogerq@kernel.org> CC: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, <srk@ti.com>, <s-vadapalli@ti.com> Subject: [PATCH net-next 2/4] net: ethernet: ti: am65-cpsw: Add support for SGMII mode Date: Tue, 21 Mar 2023 16:49:56 +0530 Message-ID: <20230321111958.2800005-3-s-vadapalli@ti.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230321111958.2800005-1-s-vadapalli@ti.com> References: <20230321111958.2800005-1-s-vadapalli@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760977425649247109?= X-GMAIL-MSGID: =?utf-8?q?1760977536538555144?= |
Series |
Add CPSWxG SGMII support for J7200 and J721E
|
|
Commit Message
Siddharth Vadapalli
March 21, 2023, 11:19 a.m. UTC
Add support for configuring the CPSW Ethernet Switch in SGMII mode.
Depending on the SoC, allow selecting SGMII mode as a supported interface,
based on the compatible used.
Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
---
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
Comments
Hello Russell, On 21-03-2023 16:59, Russell King (Oracle) wrote: > On Tue, Mar 21, 2023 at 04:49:56PM +0530, Siddharth Vadapalli wrote: >> Add support for configuring the CPSW Ethernet Switch in SGMII mode. >> >> Depending on the SoC, allow selecting SGMII mode as a supported interface, >> based on the compatible used. >> >> Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com> >> --- >> drivers/net/ethernet/ti/am65-cpsw-nuss.c | 11 ++++++++++- >> 1 file changed, 10 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c >> index cba8db14e160..d2ca1f2035f4 100644 >> --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c >> +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c >> @@ -76,6 +76,7 @@ >> #define AM65_CPSW_PORTN_REG_TS_CTL_LTYPE2 0x31C >> >> #define AM65_CPSW_SGMII_CONTROL_REG 0x010 >> +#define AM65_CPSW_SGMII_MR_ADV_ABILITY_REG 0x018 >> #define AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE BIT(0) > > Isn't this misplaced? Shouldn't AM65_CPSW_SGMII_MR_ADV_ABILITY_REG come > after AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE, rather than splitting that > from its register offset definition? Thank you for reviewing the patch. The registers are as follows: CONTROL_REG offset 0x10 STATUS_REG offset 0x14 MR_ADV_REG offset 0x18 Since the STATUS_REG is not used in the driver, its offset is omitted. The next register is the MR_ADV_REG, which I placed after the CONTROL_REG. I grouped the register offsets together, to represent the order in which the registers are placed. Due to this, the MR_ADV_ABILITY_REG offset is placed after the CONTROL_REG offset define. Please let me know if I should move it after the CONTROL_MR_AN_ENABLE define instead. > > If the advertisement register is at 0x18, and the lower 16 bits is the > advertisement, are the link partner advertisement found in the upper > 16 bits? The MR_LP_ADV_ABILITY_REG is at offset 0x020, which is the the register corresponding to the Link Partner advertised value. Also, the AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE Bit is in the CONTROL_REG. The CPSW Hardware specification describes the process of configuring the CPSW MAC for SGMII mode as follows: 1. Write 0x1 (ADVERTISE_SGMII) to the MR_ADV_ABILITY_REG register. 2. Enable auto-negotiation in the CONTROL_REG by setting the AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE bit. > >> #define AM65_CPSW_CTL_VLAN_AWARE BIT(1) >> @@ -1496,9 +1497,14 @@ static void am65_cpsw_nuss_mac_config(struct phylink_config *config, unsigned in >> struct am65_cpsw_port *port = container_of(slave, struct am65_cpsw_port, slave); >> struct am65_cpsw_common *common = port->common; >> >> - if (common->pdata.extra_modes & BIT(state->interface)) >> + if (common->pdata.extra_modes & BIT(state->interface)) { >> + if (state->interface == PHY_INTERFACE_MODE_SGMII) >> + writel(ADVERTISE_SGMII, >> + port->sgmii_base + AM65_CPSW_SGMII_MR_ADV_ABILITY_REG); >> + > > I think we can do better with this, by implementing proper PCS support. > > It seems manufacturers tend to use bought-in IP for this, so have a > look at drivers/net/pcs/ to see whether any of those (or the one in > the Mediatek patch set on netdev that has recently been applied) will > idrive your hardware. > > However, given the definition of AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE, > I suspect you won't find a compatible implementation. I have tested with an SGMII Ethernet PHY in the standard SGMII MAC2PHY configuration. I am not sure if PCS support will be required or not. I hope that the information shared above by me regarding the CPSW Hardware's specification for configuring it in SGMII mode will help determine what the right approach might be. Please let me know whether the current implementation is acceptable or PCS support is necessary. Regards, Siddharth.
On Tue, Mar 21, 2023 at 07:04:50PM +0530, Siddharth Vadapalli wrote: > Hello Russell, > > On 21-03-2023 16:59, Russell King (Oracle) wrote: > > On Tue, Mar 21, 2023 at 04:49:56PM +0530, Siddharth Vadapalli wrote: > >> Add support for configuring the CPSW Ethernet Switch in SGMII mode. > >> > >> Depending on the SoC, allow selecting SGMII mode as a supported interface, > >> based on the compatible used. > >> > >> Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com> > >> --- > >> drivers/net/ethernet/ti/am65-cpsw-nuss.c | 11 ++++++++++- > >> 1 file changed, 10 insertions(+), 1 deletion(-) > >> > >> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c > >> index cba8db14e160..d2ca1f2035f4 100644 > >> --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c > >> +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c > >> @@ -76,6 +76,7 @@ > >> #define AM65_CPSW_PORTN_REG_TS_CTL_LTYPE2 0x31C > >> > >> #define AM65_CPSW_SGMII_CONTROL_REG 0x010 > >> +#define AM65_CPSW_SGMII_MR_ADV_ABILITY_REG 0x018 > >> #define AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE BIT(0) > > > > Isn't this misplaced? Shouldn't AM65_CPSW_SGMII_MR_ADV_ABILITY_REG come > > after AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE, rather than splitting that > > from its register offset definition? > > Thank you for reviewing the patch. The registers are as follows: > CONTROL_REG offset 0x10 > STATUS_REG offset 0x14 > MR_ADV_REG offset 0x18 > > Since the STATUS_REG is not used in the driver, its offset is omitted. > The next register is the MR_ADV_REG, which I placed after the > CONTROL_REG. I grouped the register offsets together, to represent the > order in which the registers are placed. Due to this, the > MR_ADV_ABILITY_REG offset is placed after the CONTROL_REG offset define. > > Please let me know if I should move it after the CONTROL_MR_AN_ENABLE > define instead. Well, it's up to you - whether you wish to group the register offsets separately from the bit definitions for those registers, or whether you wish to describe the register offset and its associated bit definitions in one group before moving on to the next register. > > If the advertisement register is at 0x18, and the lower 16 bits is the > > advertisement, are the link partner advertisement found in the upper > > 16 bits? > > The MR_LP_ADV_ABILITY_REG is at offset 0x020, which is the the register > corresponding to the Link Partner advertised value. Also, the > AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE Bit is in the CONTROL_REG. The CPSW > Hardware specification describes the process of configuring the CPSW MAC > for SGMII mode as follows: > 1. Write 0x1 (ADVERTISE_SGMII) to the MR_ADV_ABILITY_REG register. > 2. Enable auto-negotiation in the CONTROL_REG by setting the > AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE bit. Good to hear that there is a link partner register. > >> #define AM65_CPSW_CTL_VLAN_AWARE BIT(1) > >> @@ -1496,9 +1497,14 @@ static void am65_cpsw_nuss_mac_config(struct phylink_config *config, unsigned in > >> struct am65_cpsw_port *port = container_of(slave, struct am65_cpsw_port, slave); > >> struct am65_cpsw_common *common = port->common; > >> > >> - if (common->pdata.extra_modes & BIT(state->interface)) > >> + if (common->pdata.extra_modes & BIT(state->interface)) { > >> + if (state->interface == PHY_INTERFACE_MODE_SGMII) > >> + writel(ADVERTISE_SGMII, > >> + port->sgmii_base + AM65_CPSW_SGMII_MR_ADV_ABILITY_REG); > >> + > > > > I think we can do better with this, by implementing proper PCS support. > > > > It seems manufacturers tend to use bought-in IP for this, so have a > > look at drivers/net/pcs/ to see whether any of those (or the one in > > the Mediatek patch set on netdev that has recently been applied) will > > idrive your hardware. > > > > However, given the definition of AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE, > > I suspect you won't find a compatible implementation. > > I have tested with an SGMII Ethernet PHY in the standard SGMII MAC2PHY > configuration. I am not sure if PCS support will be required or not. I > hope that the information shared above by me regarding the CPSW > Hardware's specification for configuring it in SGMII mode will help > determine what the right approach might be. Please let me know whether > the current implementation is acceptable or PCS support is necessary. Nevertheless, this SGMII block is a PCS, and if you're going to want to support inband mode (e.g. to read the SGMII word from the PHY), or if someone ever wants to use 1000base-X, you're going to need to implement this properly as a PCS. That said, it can be converted later, so isn't a blocking sisue.
Hello Russell, On 21-03-2023 21:08, Russell King (Oracle) wrote: > On Tue, Mar 21, 2023 at 07:04:50PM +0530, Siddharth Vadapalli wrote: >> Hello Russell, >> >> On 21-03-2023 16:59, Russell King (Oracle) wrote: >>> On Tue, Mar 21, 2023 at 04:49:56PM +0530, Siddharth Vadapalli wrote: >>>> Add support for configuring the CPSW Ethernet Switch in SGMII mode. >>>> >>>> Depending on the SoC, allow selecting SGMII mode as a supported interface, >>>> based on the compatible used. >>>> >>>> Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com> >>>> --- >>>> drivers/net/ethernet/ti/am65-cpsw-nuss.c | 11 ++++++++++- >>>> 1 file changed, 10 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c >>>> index cba8db14e160..d2ca1f2035f4 100644 >>>> --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c >>>> +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c >>>> @@ -76,6 +76,7 @@ >>>> #define AM65_CPSW_PORTN_REG_TS_CTL_LTYPE2 0x31C >>>> >>>> #define AM65_CPSW_SGMII_CONTROL_REG 0x010 >>>> +#define AM65_CPSW_SGMII_MR_ADV_ABILITY_REG 0x018 >>>> #define AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE BIT(0) >>> >>> Isn't this misplaced? Shouldn't AM65_CPSW_SGMII_MR_ADV_ABILITY_REG come >>> after AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE, rather than splitting that >>> from its register offset definition? >> >> Thank you for reviewing the patch. The registers are as follows: >> CONTROL_REG offset 0x10 >> STATUS_REG offset 0x14 >> MR_ADV_REG offset 0x18 >> >> Since the STATUS_REG is not used in the driver, its offset is omitted. >> The next register is the MR_ADV_REG, which I placed after the >> CONTROL_REG. I grouped the register offsets together, to represent the >> order in which the registers are placed. Due to this, the >> MR_ADV_ABILITY_REG offset is placed after the CONTROL_REG offset define. >> >> Please let me know if I should move it after the CONTROL_MR_AN_ENABLE >> define instead. > > Well, it's up to you - whether you wish to group the register offsets > separately from the bit definitions for those registers, or whether > you wish to describe the register offset and its associated bit > definitions in one group before moving on to the next register. > >>> If the advertisement register is at 0x18, and the lower 16 bits is the >>> advertisement, are the link partner advertisement found in the upper >>> 16 bits? >> >> The MR_LP_ADV_ABILITY_REG is at offset 0x020, which is the the register >> corresponding to the Link Partner advertised value. Also, the >> AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE Bit is in the CONTROL_REG. The CPSW >> Hardware specification describes the process of configuring the CPSW MAC >> for SGMII mode as follows: >> 1. Write 0x1 (ADVERTISE_SGMII) to the MR_ADV_ABILITY_REG register. >> 2. Enable auto-negotiation in the CONTROL_REG by setting the >> AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE bit. > > Good to hear that there is a link partner register. > >>>> #define AM65_CPSW_CTL_VLAN_AWARE BIT(1) >>>> @@ -1496,9 +1497,14 @@ static void am65_cpsw_nuss_mac_config(struct phylink_config *config, unsigned in >>>> struct am65_cpsw_port *port = container_of(slave, struct am65_cpsw_port, slave); >>>> struct am65_cpsw_common *common = port->common; >>>> >>>> - if (common->pdata.extra_modes & BIT(state->interface)) >>>> + if (common->pdata.extra_modes & BIT(state->interface)) { >>>> + if (state->interface == PHY_INTERFACE_MODE_SGMII) >>>> + writel(ADVERTISE_SGMII, >>>> + port->sgmii_base + AM65_CPSW_SGMII_MR_ADV_ABILITY_REG); >>>> + >>> >>> I think we can do better with this, by implementing proper PCS support. >>> >>> It seems manufacturers tend to use bought-in IP for this, so have a >>> look at drivers/net/pcs/ to see whether any of those (or the one in >>> the Mediatek patch set on netdev that has recently been applied) will >>> idrive your hardware. >>> >>> However, given the definition of AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE, >>> I suspect you won't find a compatible implementation. >> >> I have tested with an SGMII Ethernet PHY in the standard SGMII MAC2PHY >> configuration. I am not sure if PCS support will be required or not. I >> hope that the information shared above by me regarding the CPSW >> Hardware's specification for configuring it in SGMII mode will help >> determine what the right approach might be. Please let me know whether >> the current implementation is acceptable or PCS support is necessary. > > Nevertheless, this SGMII block is a PCS, and if you're going to want to > support inband mode (e.g. to read the SGMII word from the PHY), or if > someone ever wants to use 1000base-X, you're going to need to implement > this properly as a PCS. > > That said, it can be converted later, so isn't a blocking sisue. Thank you for clarifying. I will work on converting it to PCS in a future series. Regards, Siddharth.
Hi Russell, On Tue, 2023-03-21 at 15:38 +0000, Russell King (Oracle) wrote: > On Tue, Mar 21, 2023 at 07:04:50PM +0530, Siddharth Vadapalli wrote: > > Hello Russell, > > > > On 21-03-2023 16:59, Russell King (Oracle) wrote: > > > On Tue, Mar 21, 2023 at 04:49:56PM +0530, Siddharth Vadapalli wrote: > > > > Add support for configuring the CPSW Ethernet Switch in SGMII mode. > > > > > > > > Depending on the SoC, allow selecting SGMII mode as a supported interface, > > > > based on the compatible used. > > > > > > > > Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com> > > > > --- > > > > drivers/net/ethernet/ti/am65-cpsw-nuss.c | 11 ++++++++++- > > > > 1 file changed, 10 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c > > > > index cba8db14e160..d2ca1f2035f4 100644 > > > > --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c > > > > +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c > > > > @@ -76,6 +76,7 @@ > > > > #define AM65_CPSW_PORTN_REG_TS_CTL_LTYPE2 0x31C > > > > > > > > #define AM65_CPSW_SGMII_CONTROL_REG 0x010 > > > > +#define AM65_CPSW_SGMII_MR_ADV_ABILITY_REG 0x018 > > > > #define AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE BIT(0) > > > > > > Isn't this misplaced? Shouldn't AM65_CPSW_SGMII_MR_ADV_ABILITY_REG come > > > after AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE, rather than splitting that > > > from its register offset definition? > > > > Thank you for reviewing the patch. The registers are as follows: > > CONTROL_REG offset 0x10 > > STATUS_REG offset 0x14 > > MR_ADV_REG offset 0x18 > > > > Since the STATUS_REG is not used in the driver, its offset is omitted. > > The next register is the MR_ADV_REG, which I placed after the > > CONTROL_REG. I grouped the register offsets together, to represent the > > order in which the registers are placed. Due to this, the > > MR_ADV_ABILITY_REG offset is placed after the CONTROL_REG offset define. > > > > Please let me know if I should move it after the CONTROL_MR_AN_ENABLE > > define instead. > > Well, it's up to you - whether you wish to group the register offsets > separately from the bit definitions for those registers, or whether > you wish to describe the register offset and its associated bit > definitions in one group before moving on to the next register. > > > > If the advertisement register is at 0x18, and the lower 16 bits is the > > > advertisement, are the link partner advertisement found in the upper > > > 16 bits? > > > > The MR_LP_ADV_ABILITY_REG is at offset 0x020, which is the the register > > corresponding to the Link Partner advertised value. Also, the > > AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE Bit is in the CONTROL_REG. The CPSW > > Hardware specification describes the process of configuring the CPSW MAC > > for SGMII mode as follows: > > 1. Write 0x1 (ADVERTISE_SGMII) to the MR_ADV_ABILITY_REG register. > > 2. Enable auto-negotiation in the CONTROL_REG by setting the > > AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE bit. > > Good to hear that there is a link partner register. > > > > > #define AM65_CPSW_CTL_VLAN_AWARE BIT(1) > > > > @@ -1496,9 +1497,14 @@ static void am65_cpsw_nuss_mac_config(struct phylink_config *config, unsigned in > > > > struct am65_cpsw_port *port = container_of(slave, struct am65_cpsw_port, slave); > > > > struct am65_cpsw_common *common = port->common; > > > > > > > > - if (common->pdata.extra_modes & BIT(state->interface)) > > > > + if (common->pdata.extra_modes & BIT(state->interface)) { > > > > + if (state->interface == PHY_INTERFACE_MODE_SGMII) > > > > + writel(ADVERTISE_SGMII, > > > > + port->sgmii_base + AM65_CPSW_SGMII_MR_ADV_ABILITY_REG); > > > > + > > > > > > I think we can do better with this, by implementing proper PCS support. > > > > > > It seems manufacturers tend to use bought-in IP for this, so have a > > > look at drivers/net/pcs/ to see whether any of those (or the one in > > > the Mediatek patch set on netdev that has recently been applied) will > > > idrive your hardware. > > > > > > However, given the definition of AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE, > > > I suspect you won't find a compatible implementation. > > > > I have tested with an SGMII Ethernet PHY in the standard SGMII MAC2PHY > > configuration. I am not sure if PCS support will be required or not. I > > hope that the information shared above by me regarding the CPSW > > Hardware's specification for configuring it in SGMII mode will help > > determine what the right approach might be. Please let me know whether > > the current implementation is acceptable or PCS support is necessary. > > Nevertheless, this SGMII block is a PCS, and if you're going to want to > support inband mode (e.g. to read the SGMII word from the PHY), or if > someone ever wants to use 1000base-X, you're going to need to implement > this properly as a PCS. > > That said, it can be converted later, so isn't a blocking sisue. Just to be on the same page, I read all the above as you do accept/do not oppose to this series in the current form, am I correct? Thanks, Paolo
On Wed, Mar 22, 2023 at 03:49:41PM +0100, Paolo Abeni wrote: > Hi Russell, > > On Tue, 2023-03-21 at 15:38 +0000, Russell King (Oracle) wrote: > > On Tue, Mar 21, 2023 at 07:04:50PM +0530, Siddharth Vadapalli wrote: > > > Hello Russell, > > > > > > On 21-03-2023 16:59, Russell King (Oracle) wrote: > > > > On Tue, Mar 21, 2023 at 04:49:56PM +0530, Siddharth Vadapalli wrote: > > > > > Add support for configuring the CPSW Ethernet Switch in SGMII mode. > > > > > > > > > > Depending on the SoC, allow selecting SGMII mode as a supported interface, > > > > > based on the compatible used. > > > > > > > > > > Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com> > > > > > --- > > > > > drivers/net/ethernet/ti/am65-cpsw-nuss.c | 11 ++++++++++- > > > > > 1 file changed, 10 insertions(+), 1 deletion(-) > > > > > > > > > > diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c > > > > > index cba8db14e160..d2ca1f2035f4 100644 > > > > > --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c > > > > > +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c > > > > > @@ -76,6 +76,7 @@ > > > > > #define AM65_CPSW_PORTN_REG_TS_CTL_LTYPE2 0x31C > > > > > > > > > > #define AM65_CPSW_SGMII_CONTROL_REG 0x010 > > > > > +#define AM65_CPSW_SGMII_MR_ADV_ABILITY_REG 0x018 > > > > > #define AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE BIT(0) > > > > > > > > Isn't this misplaced? Shouldn't AM65_CPSW_SGMII_MR_ADV_ABILITY_REG come > > > > after AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE, rather than splitting that > > > > from its register offset definition? > > > > > > Thank you for reviewing the patch. The registers are as follows: > > > CONTROL_REG offset 0x10 > > > STATUS_REG offset 0x14 > > > MR_ADV_REG offset 0x18 > > > > > > Since the STATUS_REG is not used in the driver, its offset is omitted. > > > The next register is the MR_ADV_REG, which I placed after the > > > CONTROL_REG. I grouped the register offsets together, to represent the > > > order in which the registers are placed. Due to this, the > > > MR_ADV_ABILITY_REG offset is placed after the CONTROL_REG offset define. > > > > > > Please let me know if I should move it after the CONTROL_MR_AN_ENABLE > > > define instead. > > > > Well, it's up to you - whether you wish to group the register offsets > > separately from the bit definitions for those registers, or whether > > you wish to describe the register offset and its associated bit > > definitions in one group before moving on to the next register. > > > > > > If the advertisement register is at 0x18, and the lower 16 bits is the > > > > advertisement, are the link partner advertisement found in the upper > > > > 16 bits? > > > > > > The MR_LP_ADV_ABILITY_REG is at offset 0x020, which is the the register > > > corresponding to the Link Partner advertised value. Also, the > > > AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE Bit is in the CONTROL_REG. The CPSW > > > Hardware specification describes the process of configuring the CPSW MAC > > > for SGMII mode as follows: > > > 1. Write 0x1 (ADVERTISE_SGMII) to the MR_ADV_ABILITY_REG register. > > > 2. Enable auto-negotiation in the CONTROL_REG by setting the > > > AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE bit. > > > > Good to hear that there is a link partner register. > > > > > > > #define AM65_CPSW_CTL_VLAN_AWARE BIT(1) > > > > > @@ -1496,9 +1497,14 @@ static void am65_cpsw_nuss_mac_config(struct phylink_config *config, unsigned in > > > > > struct am65_cpsw_port *port = container_of(slave, struct am65_cpsw_port, slave); > > > > > struct am65_cpsw_common *common = port->common; > > > > > > > > > > - if (common->pdata.extra_modes & BIT(state->interface)) > > > > > + if (common->pdata.extra_modes & BIT(state->interface)) { > > > > > + if (state->interface == PHY_INTERFACE_MODE_SGMII) > > > > > + writel(ADVERTISE_SGMII, > > > > > + port->sgmii_base + AM65_CPSW_SGMII_MR_ADV_ABILITY_REG); > > > > > + > > > > > > > > I think we can do better with this, by implementing proper PCS support. > > > > > > > > It seems manufacturers tend to use bought-in IP for this, so have a > > > > look at drivers/net/pcs/ to see whether any of those (or the one in > > > > the Mediatek patch set on netdev that has recently been applied) will > > > > idrive your hardware. > > > > > > > > However, given the definition of AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE, > > > > I suspect you won't find a compatible implementation. > > > > > > I have tested with an SGMII Ethernet PHY in the standard SGMII MAC2PHY > > > configuration. I am not sure if PCS support will be required or not. I > > > hope that the information shared above by me regarding the CPSW > > > Hardware's specification for configuring it in SGMII mode will help > > > determine what the right approach might be. Please let me know whether > > > the current implementation is acceptable or PCS support is necessary. > > > > Nevertheless, this SGMII block is a PCS, and if you're going to want to > > support inband mode (e.g. to read the SGMII word from the PHY), or if > > someone ever wants to use 1000base-X, you're going to need to implement > > this properly as a PCS. > > > > That said, it can be converted later, so isn't a blocking sisue. > > Just to be on the same page, I read all the above as you do accept/do > not oppose to this series in the current form, am I correct? I don't oppose this series. Thanks.
diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index cba8db14e160..d2ca1f2035f4 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -76,6 +76,7 @@ #define AM65_CPSW_PORTN_REG_TS_CTL_LTYPE2 0x31C #define AM65_CPSW_SGMII_CONTROL_REG 0x010 +#define AM65_CPSW_SGMII_MR_ADV_ABILITY_REG 0x018 #define AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE BIT(0) #define AM65_CPSW_CTL_VLAN_AWARE BIT(1) @@ -1496,9 +1497,14 @@ static void am65_cpsw_nuss_mac_config(struct phylink_config *config, unsigned in struct am65_cpsw_port *port = container_of(slave, struct am65_cpsw_port, slave); struct am65_cpsw_common *common = port->common; - if (common->pdata.extra_modes & BIT(state->interface)) + if (common->pdata.extra_modes & BIT(state->interface)) { + if (state->interface == PHY_INTERFACE_MODE_SGMII) + writel(ADVERTISE_SGMII, + port->sgmii_base + AM65_CPSW_SGMII_MR_ADV_ABILITY_REG); + writel(AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE, port->sgmii_base + AM65_CPSW_SGMII_CONTROL_REG); + } } static void am65_cpsw_nuss_mac_link_down(struct phylink_config *config, unsigned int mode, @@ -1539,6 +1545,8 @@ static void am65_cpsw_nuss_mac_link_up(struct phylink_config *config, struct phy if (speed == SPEED_1000) mac_control |= CPSW_SL_CTL_GIG; + if (interface == PHY_INTERFACE_MODE_SGMII) + mac_control |= CPSW_SL_CTL_EXT_EN; if (speed == SPEED_10 && phy_interface_mode_is_rgmii(interface)) /* Can be used with in band mode only */ mac_control |= CPSW_SL_CTL_EXT_EN; @@ -2157,6 +2165,7 @@ am65_cpsw_nuss_init_port_ndev(struct am65_cpsw_common *common, u32 port_idx) break; case PHY_INTERFACE_MODE_QSGMII: + case PHY_INTERFACE_MODE_SGMII: if (common->pdata.extra_modes & BIT(port->slave.phy_if)) { __set_bit(port->slave.phy_if, port->slave.phylink_config.supported_interfaces);