Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2432309rwb; Mon, 19 Sep 2022 05:11:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM60hZE3Oz5+B2vGgwKU8pFbQHABRzQmoH7DoqIGOfy+W5nDCnm/5jogLpXmv7A+nKHCVTu8 X-Received: by 2002:a05:6402:35c1:b0:451:e1aa:e66e with SMTP id z1-20020a05640235c100b00451e1aae66emr14527464edc.275.1663589492179; Mon, 19 Sep 2022 05:11:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663589492; cv=none; d=google.com; s=arc-20160816; b=PwY9UjVvWInPOpi5WUq3POqJ4RCg8yiHwMr95BQNi7nnaByEd5ln9vIhFnKYYu7Jmq 6xZWNcKNAstzu0QA/xcW72R82Fzi2mdUB0WFXeDIgeuIahYGkPQQ64B0bAEAGmFfQ2Gs FtnHXRZTtxyglgTOcJMnp1cIsx7mbu8NdgqDL5e7/8O8dtbZkY/ZIsry3l5Lg0To2DtT Bgkfxp/c2Ruzug3ywtwKy/eHydqrrdelGSFO4OiNoGgFOhFD6E2MB9uF4N7T1tZAe6S+ 4LUvmH98xvPHdSV+cPIIJY4QwVbVaFnp2ONHUwyv2mUUmsM83RW47TZbp525hJajZEpF PVdg== 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=mQIM/EJij0VCL0/KLKnA4As/obLNORXFYtrVRXtkL68=; b=z2iV0NLzv83k9lE1J73/g6reanIUZZXRi+dNYl5d0MGbhGixKVrmyaeJnJmzWWdXy3 ItOz4yhUGKl5HCcrTbh0dl6ZeNeIeS7CXo9qf+y1KjISziEsRCr738uO86oEx8em2g/x asHf7jRkoBRNe0XQ+bDAuhn2r9qmVeTDFi7ImTetajxJ94x/pGL6NPRcchzWJecwKMVn sCYDr/zzBN7kSCOZ8u53cBHwyzoHQhXEdnNR49+jGCX1vR4dYuyf9Yrf/itLX/qVoS32 /tmT9SeyzTa9lPWXdHkBdFI1KnGW8xvQQdLWURhV7Y2BYsPnkpcA8JXPeXh5Flz11+gl XtOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=Uy73segP; 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 dz21-20020a0564021d5500b0044ecd80f257si10086548edb.603.2022.09.19.05.11.07; Mon, 19 Sep 2022 05:11:32 -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=Uy73segP; 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 S230099AbiISLYP (ORCPT + 99 others); Mon, 19 Sep 2022 07:24:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229799AbiISLYO (ORCPT ); Mon, 19 Sep 2022 07:24:14 -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 6485E1A80A; Mon, 19 Sep 2022 04:24:12 -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=mQIM/EJij0VCL0/KLKnA4As/obLNORXFYtrVRXtkL68=; b=Uy73segPjVyktd8MoQvEluJ9Sh 8UMlXvBQXgcmxdqKPCvnG0AJB5XTJrqI6TkyZbqzLgvj3De5Z8SaAM66xp2jYDyFPEyh5IoLJBoyV YnFSkxf+7niuxzR2BJeS+2IUuG63xeDlCLVR6SXgLpKW2GK3p64cjCvnfjEBFSlbhVt5LwUBoty/0 17xzYlZme8iC9EEtdlDJLQ6nK5GSU+zmxYvhlmyPJiY/l4nLkPJKT6yULBWYHKzZ1YSxRkPJquYcW 16AZAqjaiImN+9RUOneXZF5KblFKbB4dTrNfXa1amvIj0XOknpHPV8q1ZVxCVKiFwppyWVpbxHQNp C+IMmD4g==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:34400) 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 1oaEsa-0000no-KQ; Mon, 19 Sep 2022 12:24:00 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1oaEsX-0006Lj-R3; Mon, 19 Sep 2022 12:23:57 +0100 Date: Mon, 19 Sep 2022 12:23:57 +0100 From: "Russell King (Oracle)" To: Alexander Couzens Cc: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , Daniel Golle , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next v2 5/5] net: mediatek: sgmii: refactor power cycling into mtk_pcs_config() Message-ID: References: <20220919083713.730512-1-lynxis@fe80.eu> <20220919083713.730512-6-lynxis@fe80.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220919083713.730512-6-lynxis@fe80.eu> Sender: Russell King (Oracle) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE 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 On Mon, Sep 19, 2022 at 10:37:12AM +0200, Alexander Couzens wrote: > Both code paths (autonegotiated and force mode) are power cycling > the phy. Move power cycling code to the caller to remove code > duplicity. I think we can do more consolidation here - and it probably makes sense to do in another patch. > diff --git a/drivers/net/ethernet/mediatek/mtk_sgmii.c b/drivers/net/ethernet/mediatek/mtk_sgmii.c > index 4c8e8c7b1d32..50f605208295 100644 > --- a/drivers/net/ethernet/mediatek/mtk_sgmii.c > +++ b/drivers/net/ethernet/mediatek/mtk_sgmii.c > @@ -25,9 +25,6 @@ static int mtk_pcs_setup_mode_an(struct mtk_pcs *mpcs, phy_interface_t interface > { > unsigned int val; > > - /* PHYA power down */ > - regmap_write(mpcs->regmap, SGMSYS_QPHY_PWR_STATE_CTRL, SGMII_PHYA_PWD); > - > /* Set SGMII phy speed */ > regmap_read(mpcs->regmap, mpcs->ana_rgc3, &val); > val &= ~RG_PHY_SPEED_MASK; > @@ -72,9 +57,6 @@ static int mtk_pcs_setup_mode_force(struct mtk_pcs *mpcs, > { > unsigned int val; > > - /* PHYA power down */ > - regmap_write(mpcs->regmap, SGMSYS_QPHY_PWR_STATE_CTRL, SGMII_PHYA_PWD); > - > regmap_read(mpcs->regmap, mpcs->ana_rgc3, &val); > val &= ~RG_PHY_SPEED_MASK; > if (interface == PHY_INTERFACE_MODE_2500BASEX) After powering the PHY down, the next thing that is done is to configure the speed. Even with my comments on patch 4, this can still be consolidated. > @@ -115,12 +85,27 @@ static int mtk_pcs_config(struct phylink_pcs *pcs, unsigned int mode, > struct mtk_pcs *mpcs = pcs_to_mtk_pcs(pcs); unsigned int val; > int err = 0; > > + /* PHYA power down */ > + regmap_write(mpcs->regmap, SGMSYS_QPHY_PWR_STATE_CTRL, SGMII_PHYA_PWD); > + regmap_read(mpcs->regmap, mpcs->ana_rgc3, &val); val &= ~RG_PHY_SPEED_MASK; if (interface == PHY_INTERFACE_MODE_2500BASEX) val |= RG_PHY_SPEED_3_125G; regmap_write(mpcs->regmap, mpcs->ana_rgc3, val); which would make logical sense to do here, so we always configure the speed for the PCS correctly. That then leaves the configuration of SGMSYS_PCS_CONTROL_1 and SGMSYS_SGMII_MODE, which I think could also be consolidated, but I'll leave that to those with the hardware to make that decision. Reading between the lines of the code in this driver, it looks to me like this hardware supports only SGMII, but doesn't actually support 1000base-X and 2500base-X with negotiation. Is that correct? If so, it would be good to add a mtk_pcs_validate() function that clears ETHTOOL_LINK_MODE_Autoneg_BIT for these modes. Thanks. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!