Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4582925rwl; Mon, 3 Apr 2023 07:03:15 -0700 (PDT) X-Google-Smtp-Source: AKy350afTHqO36niaEzme4GabJsvdTRznoWJnnNZp4TPQ+5U1g6wUFbfLdG/9s5DEyYKfhzzf2s+ X-Received: by 2002:a17:903:280b:b0:19c:65bd:d44b with SMTP id kp11-20020a170903280b00b0019c65bdd44bmr28548242plb.60.1680530595360; Mon, 03 Apr 2023 07:03:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680530595; cv=none; d=google.com; s=arc-20160816; b=FA8a6HAQkZQMONNHDqfFkuyYo7t03oIT+Egpy+7DozW+qK/oKp0yJSAKL10/AayNaT GG54y0AX4Yg2149+9XH5fRMEImfd2pKXEMw5UZw7S11hvD6rC9OvCbQGRmkEFJJ8/8sy y6bhp4VCoAIc8Hp9nr6QiPkZALeHif5CJpGESumhahGJETKH7TNagfVbeviwSPEEGtXV xxaINADQHO2io59RG0Cq8SaleTMU6Yy0J3LOLUYL2lVkz9wWHyTOa33jslOoxcSx5NOu 8qxkPe4tNFfTPHRi5Ji6eaeCXbVf0VINSTq8CypEA/bps9oq1xc3CroC0PebfsENAkjr /07A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=cOmxQf/XohzQNc1y5zh+u/LIlyyFogpvuBcXFkIatHs=; b=tE5VxOUknDxYXxMHwFAZPqoA3WbDKl+XppZ+/9uVXcBN2y/NVc4WjIc1h9TsK5kBvD 0pG6TtKaw3eWQYXQkzWREn6+HaNZCuh1XLfpnfZWxcR4eWGMx/gYLDJg4xGA6H0DZs9A 4OB6HFBk/U3VCB17juPPWJzBQ+W3Koo11McnlRwYsmDoqJTKc+bf9ss4bD0c/pUIDqvB UI2kGJgoTm0hoU8TQBEn16c2L4seaHVh96hd6ZB9JXczHIsMqWqFWQ5kRkGuq/Hn/cbN MoxY+bVOSNzZLLRBYNt5Z0DBPy0/r30Qs/fgDnDb/yf//DywbldK6+98ek+vYKW4mXnY iNsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=URJqNH7R; 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=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j3-20020a170902758300b001a25fe2f0e1si7896764pll.95.2023.04.03.07.02.29; Mon, 03 Apr 2023 07:03: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=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=URJqNH7R; 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=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232735AbjDCN4E (ORCPT + 99 others); Mon, 3 Apr 2023 09:56:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232683AbjDCN4A (ORCPT ); Mon, 3 Apr 2023 09:56:00 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 711BF2706; Mon, 3 Apr 2023 06:55:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=cOmxQf/XohzQNc1y5zh+u/LIlyyFogpvuBcXFkIatHs=; b=URJqNH7Rivp8gJDAiwyB6mCoIy k+OV9TsBUl6zrXJdh1g1kG8iO/9y8ZfdI8h5o34bT4+SU7tyXjLjR+gJ9uUEiSFcGQuFWnLfTCpx6 1VEWmbwB0a+V4mbFOCI+jzV9EE3fIjGni9SV1P8OBiXAo+YpgFW/Vv6ETXhM5ahGWbzmzmcW2Pw4g 22u3J/cGTLLHWjyLZIObT0EZlC6gkPAZHCkqa2I75MO4mERzluyF8+51SUO0Y/6qTzoKMjkwSJ98t eYoLvrE8E9clC3hZTjdTtoyFvMn+3Cfv1LpUJQoK6/rys/TPycRxdij9spOkDo6wscfRQlDM7dB3V Si0RCsOg==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:48436) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pjKf2-0002s6-TQ; Mon, 03 Apr 2023 14:55:52 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1pjKf1-0004IF-S6; Mon, 03 Apr 2023 14:55:51 +0100 Date: Mon, 3 Apr 2023 14:55:51 +0100 From: "Russell King (Oracle)" To: Siddharth Vadapalli Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, rogerq@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, srk@ti.com Subject: Re: [PATCH net-next v2 1/3] net: ethernet: ti: am65-cpsw: Move mode specific config to mac_config() Message-ID: References: <20230403110106.983994-1-s-vadapalli@ti.com> <20230403110106.983994-2-s-vadapalli@ti.com> <3a62f5cf-ebba-1603-50a0-7a873973534d@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Russell King (Oracle) X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 On Mon, Apr 03, 2023 at 07:20:21PM +0530, Siddharth Vadapalli wrote: > > > On 03-04-2023 18:43, Russell King (Oracle) wrote: > > On Mon, Apr 03, 2023 at 06:31:52PM +0530, Siddharth Vadapalli wrote: > >> > >> > >> On 03-04-2023 16:38, Russell King (Oracle) wrote: > >>> On Mon, Apr 03, 2023 at 04:31:04PM +0530, Siddharth Vadapalli wrote: > >>>> Move the interface mode specific configuration to the mac_config() > >>>> callback am65_cpsw_nuss_mac_config(). > >>>> > >>>> Signed-off-by: Siddharth Vadapalli > >>>> --- > >>>> drivers/net/ethernet/ti/am65-cpsw-nuss.c | 10 +++++++--- > >>>> 1 file changed, 7 insertions(+), 3 deletions(-) > >>>> > >>>> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c > >>>> index d17757ecbf42..74e099828978 100644 > >>>> --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c > >>>> +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c > >>>> @@ -1504,12 +1504,17 @@ static void am65_cpsw_nuss_mac_config(struct phylink_config *config, unsigned in > >>>> phylink_config); > >>>> struct am65_cpsw_port *port = container_of(slave, struct am65_cpsw_port, slave); > >>>> struct am65_cpsw_common *common = port->common; > >>>> + u32 mac_control = 0; > >>>> > >>>> if (common->pdata.extra_modes & BIT(state->interface)) { > >>>> - if (state->interface == PHY_INTERFACE_MODE_SGMII) > >>>> + if (state->interface == PHY_INTERFACE_MODE_SGMII) { > >>>> + mac_control |= CPSW_SL_CTL_EXT_EN; > >>>> writel(ADVERTISE_SGMII, > >>>> port->sgmii_base + AM65_CPSW_SGMII_MR_ADV_ABILITY_REG); > >>>> + } > >>>> > >>>> + if (mac_control) > >>>> + cpsw_sl_ctl_set(port->slave.mac_sl, mac_control); > >>>> writel(AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE, > >>>> port->sgmii_base + AM65_CPSW_SGMII_CONTROL_REG); > >>>> } > >>>> @@ -1553,8 +1558,7 @@ 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; > >>>> + /* TODO: Verify whether in-band is necessary for 10 Mbps RGMII */ > >>>> 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; > >>> > >>> I'm afraid I can see you haven't thought this patch through properly. > >>> > >>> am65_cpsw_nuss_mac_link_down() will call > >>> cpsw_sl_ctl_reset(port->slave.mac_sl); which has the effect of clearing > >>> to zero the entire MAC control register. This will clear > >>> CPSW_SL_CTL_EXT_EN that was set in am65_cpsw_nuss_mac_config() which is > >>> not what you want to be doing. > >>> > >>> Given that we have the 10Mbps issue with RGMII, I think what you want > >>> to be doing is: > >>> > >>> 1. Set CPSW_SL_CTL_EXT_EN in am65_cpsw_nuss_mac_config() if in SGMII > >>> mode, otherwise clear this bit. > >>> > >>> 2. Clear the mac_control register in am65_cpsw_nuss_mac_link_down() > >>> if in RMGII mode, otherwise preserve the state of > >>> CPSW_SL_CTL_EXT_EN but clear all other bits. > >>> > >>> 3. Set CPSW_SL_CTL_EXT_EN in am65_cpsw_nuss_mac_link_up() if in > >>> RGMII mode and 10Mbps. > >> > >> I plan to implement it as follows: > >> 1. Add a member "u32 mode_config" to "struct am65_cpsw_slave_data" in > >> "am65-cpsw-nuss.h". > >> 2. In am65_cpsw_nuss_mac_config(), store the value of mac_control in > >> "port->slave.mode_config". > >> 3. In am65_cpsw_nuss_mac_link_down(), after the reset via > >> cpsw_sl_ctl_reset(), execute: > >> cpsw_sl_ctl_set(port->slave.mac_sl, port->slave.mode_config) in order to > >> restore the configuration performed in am65_cpsw_nuss_mac_config(). > >> > >> Please let me know in case of any suggestions to implement it in a > >> better manner. > > > > Do you think this complexity is really worth it? > > > > Let's look at what's available: > > > > cpsw_sl_ctl_set() - sets bits in the mac control register > > cpsw_sl_ctl_clr() - clears bits in the mac control register > > cpsw_sl_ctl_reset() - sets the mac control register to zero > > > > So, in mac_config(), we can do: > > > > if (interface == SGMII) > > cpsw_sl_ctl_set(CPSW_SL_CTL_EXT_EN); > > else > > cpsw_sl_ctl_clr(CPSW_SL_CTL_EXT_EN); > > While this will work for patch 1/3, once I add support for USXGMII mode > as in patch 3/3, I believe that I have to invert it, beginning by > invoking a cpsw_sl_ctl_clr(CPSW_SL_CTL_EXT_EN) at the start in > mac_config() followed by switching through the modes. If the mode is > SGMII, then I invoke cpsw_sl_ctl_set(CPSW_SL_CTL_EXT_EN), along with the > write to the MR_ADV_ABILITY_REG register to advertise SGMII. If the mode > is USXGMII, then I invoke: > cpsw_sl_ctl_set(CPSW_SL_CTL_XGIG | CPSW_SL_CTL_XGMII_EN) For patch 1, I did leave out the write for MR_ADV_ABILITY_REG, I had assumed you'd get the idea on that and merge the if() condition you already had with my suggestion above (which isn't literal code!) In patch 3, you simply need to add: if (interface == USXGMII) cpsw_sl_ctl_set(CPSW_SL_CTL_XGIG | CPSW_SL_CTL_XGMII_EN); else cpsw_sl_ctl_clr(CPSW_SL_CTL_XGIG | CPSW_SL_CTL_XGMII_EN); Thanks. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!