From patchwork Thu Mar 11 02:09:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Lipnitskiy X-Patchwork-Id: 12130149 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0984C433E0 for ; Thu, 11 Mar 2021 02:13:14 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 81C3464FAA for ; Thu, 11 Mar 2021 02:13:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 81C3464FAA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=du4m2IiARv0iUcnULkkkBP4Cn1klqa3p4cSbxfVj1ec=; b=R/BSNloVaGLsZsNSzkzh/IsbLl URY/BdFaSECBrDM5SUEJPwd/oz95A8nYn3/OjxoV/3tcDoW/JFhdKDCjYI5aSzdTsXCE/GMLRiilf uVEmxQEI6WnJacyXHabchYu13NViiny49n7Jzo49OEi6SZUxka1r9y0KLH+zrglUHpMxzsJB4C7is dnpJrgL0spKcKXby+fza0m7CVP7y7SPNpHthNgMyt9KdG75dJfqMScbz/jtlUkAVDM3AqIoZm2xse sZqPcGSOeyGRE8UIOO8cK3ft6FqGgrxpwDgR27qZpIxGwM1XEtakLV18lXe7n1ibfyCYmaDjUJdKY mT/oq/GA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lKAnh-008EP9-KO; Thu, 11 Mar 2021 02:11:45 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lKAnc-008EO8-KM; Thu, 11 Mar 2021 02:11:42 +0000 Received: by mail-pl1-x636.google.com with SMTP id w7so5969275pll.8; Wed, 10 Mar 2021 18:11:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=te3KkZ/7y8l0N1gnz9fMIpGsfWHYXiKPURp+vcWCB8E=; b=tVjmXz8D0DjaTjmoWHqistDrym+xbYTnEJwbOaaa4yZ1NOFOvMdMzWtNc9TMAA/O0B zcQi5pgNIF7Fogaq3ReeNE6T9ZdXBzO+0MER/mX5knRuCCxqTjVeuCCONRQqtrnDx1hc mfGPZZJVpmR7eF6jRRYPB090LmBGJPlnUqeF1uu+L5uBDe5l1BulZJpcmvpbvHMCMZnJ tNJsB8TteEWRJgX0EW631qHAfg1o72qZWlEzqW8yAMei17a6bf1AYnNYPczPAmZh3LOb i1FlLZgigsiVCar4a7KETtiqFzD399/pmxUT5LPf8fbICSqSGcal+usmRD98NzJJPkMV c1mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=te3KkZ/7y8l0N1gnz9fMIpGsfWHYXiKPURp+vcWCB8E=; b=PgdliPBn1aZ5ex2Cy6Gn69aNOlXCoFcH6ilns1RGRmndfDekZpqcshL33cvIuoI948 LnWN4UcQwjCPs73WvDILkf25TdESY7YgBtuqC0uVQCQLa6Zgj/T+Ug+t4bwWvv8if7/S jf65AmVf2ozZ/uaJBmb5U8G6Ac1BxS8VZ3y5NG5gt4xbA8k29qaGSDp8UWZwe9OPXYm2 hHHMOXDUfH6h7QXnVa5AOL/vXKRZMhIOMVULKRmRVDnht+IFlu92IZ61JQirLvtVtsQ7 V1RUvPKye4YriZ7RMelE7EgQ/x1yLIcv227JIYxpZn90uDEyZbPe3ua0rL4FtQ0yRhRU 4eCQ== X-Gm-Message-State: AOAM532x7GDI/zmZ/Tt87JzJvhR1zgR+kQiEIqHJn5KyXk+L4VhaPHUq hjh/Lwj3DBOfn2IbkKhwO5g= X-Google-Smtp-Source: ABdhPJzbEp3URJUAJUmTC9QVWB1XRmvmvC/eT7dP/QVWbmPd5x+UG2+7fDGLo72jWAOVPTg54utsBA== X-Received: by 2002:a17:902:10a:b029:e2:e8f7:2988 with SMTP id 10-20020a170902010ab02900e2e8f72988mr5733060plb.4.1615428699155; Wed, 10 Mar 2021 18:11:39 -0800 (PST) Received: from z640-arch.lan ([2602:61:738f:1000::678]) by smtp.gmail.com with ESMTPSA id p190sm672603pga.78.2021.03.10.18.11.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 18:11:38 -0800 (PST) From: Ilya Lipnitskiy To: Sean Wang , Landen Chao , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Matthias Brugger , Philipp Zabel , Russell King , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Ilya Lipnitskiy Subject: [PATCH net-next, v2 1/3] net: dsa: mt7530: setup core clock even in TRGMII mode Date: Wed, 10 Mar 2021 18:09:52 -0800 Message-Id: <20210311020954.842341-1-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210311_021140_797478_931ED963 X-CRM114-Status: GOOD ( 12.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org A recent change to MIPS ralink reset logic made it so mt7530 actually resets the switch on platforms such as mt7621 (where bit 2 is the reset line for the switch). That exposed an issue where the switch would not function properly in TRGMII mode after a reset. Reconfigure core clock in TRGMII mode to fix the issue. Tested on Ubiquiti ER-X (MT7621) with TRGMII mode enabled. Fixes: 3f9ef7785a9c ("MIPS: ralink: manage low reset lines") Signed-off-by: Ilya Lipnitskiy --- drivers/net/dsa/mt7530.c | 52 +++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index f06f5fa2f898..9871d7cff93a 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -436,34 +436,32 @@ mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface) TD_DM_DRVP(8) | TD_DM_DRVN(8)); /* Setup core clock for MT7530 */ - if (!trgint) { - /* Disable MT7530 core clock */ - core_clear(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN); - - /* Disable PLL, since phy_device has not yet been created - * provided for phy_[read,write]_mmd_indirect is called, we - * provide our own core_write_mmd_indirect to complete this - * function. - */ - core_write_mmd_indirect(priv, - CORE_GSWPLL_GRP1, - MDIO_MMD_VEND2, - 0); - - /* Set core clock into 500Mhz */ - core_write(priv, CORE_GSWPLL_GRP2, - RG_GSWPLL_POSDIV_500M(1) | - RG_GSWPLL_FBKDIV_500M(25)); + /* Disable MT7530 core clock */ + core_clear(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN); - /* Enable PLL */ - core_write(priv, CORE_GSWPLL_GRP1, - RG_GSWPLL_EN_PRE | - RG_GSWPLL_POSDIV_200M(2) | - RG_GSWPLL_FBKDIV_200M(32)); - - /* Enable MT7530 core clock */ - core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN); - } + /* Disable PLL, since phy_device has not yet been created + * provided for phy_[read,write]_mmd_indirect is called, we + * provide our own core_write_mmd_indirect to complete this + * function. + */ + core_write_mmd_indirect(priv, + CORE_GSWPLL_GRP1, + MDIO_MMD_VEND2, + 0); + + /* Set core clock into 500Mhz */ + core_write(priv, CORE_GSWPLL_GRP2, + RG_GSWPLL_POSDIV_500M(1) | + RG_GSWPLL_FBKDIV_500M(25)); + + /* Enable PLL */ + core_write(priv, CORE_GSWPLL_GRP1, + RG_GSWPLL_EN_PRE | + RG_GSWPLL_POSDIV_200M(2) | + RG_GSWPLL_FBKDIV_200M(32)); + + /* Enable MT7530 core clock */ + core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN); /* Setup the MT7530 TRGMII Tx Clock */ core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN); From patchwork Thu Mar 11 02:09:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Lipnitskiy X-Patchwork-Id: 12130151 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D5D2C433DB for ; Thu, 11 Mar 2021 02:13:15 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8578164F95 for ; Thu, 11 Mar 2021 02:13:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8578164F95 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=r5AksUbPcLaEpW8E6UvY9MbXnWq2N+7KnmJ6X6glufQ=; b=g94EFtLrebfuqbiXL3H+fJbBr bhbBIr9MA3PGnXlbu8aZkS3Kw9Mr2VFH9OpJ/f49alIWO3vUqo1kj85XiqNB06ssjqxjXAma6NwGg 1QLDlrdAk555iCqRkD8eNO2zlFDm8rn21U/5sK7MstUF0tiI9gnGnkHpi29JHL6yhU0QkqF7nQBUS l+ED/CuML7SKJkZT7t4KyTx44NBJwkA8HW2gDQaVZ9g3a7ZgJ0EF5ybLlY1EZepsGsaG4dt5ksbDB h2yfKdcH03edljIxJioOvXvFZbqxWF/82J4YJtX78ir4nb2pGXAApZ/y9Y0oTXaFmvHCjUQoRwrH/ JBgyS6u6g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lKAno-008EPd-OE; Thu, 11 Mar 2021 02:11:52 +0000 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lKAnd-008EOA-GL; Thu, 11 Mar 2021 02:11:43 +0000 Received: by mail-pj1-x1033.google.com with SMTP id lr1-20020a17090b4b81b02900ea0a3f38c1so952458pjb.0; Wed, 10 Mar 2021 18:11:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=B3NvjxFQkBW7qiD7WXidQCqOgaMtOHmNc5t+RjW8jYs=; b=Ag4U2H/cx+7yWjZGqdF8jnN9Ftc1pFYjhKg1Qw/pfE+4UNlElJXTGt+DRYq5/fLFcf 4ihweh8lj8HfxiisnOoSxxoIio7jJX9I2f3X9SVyKbILLCPRzbVGzxDXjcZsbELf4xVB lRvDAbE6Z12HPMYC1h+p2qvPAU1vTXFHbRn2mVkkm+WI2Q7lS45WcUQ6YwhofEtXKGkB ZSrUAj8Jk2C12+mZyhZHZF4oRkdrc7rHgRDmG0+Qge+kCeou2tb+ZuzUgAUz+Xc6ejHW T+IU2eBT8bjy+9cpBIgrxWSXPM5bkWXaQ4vZppl58LNITAeZvnWoAeWuCW3QDMtNP4ex p77A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B3NvjxFQkBW7qiD7WXidQCqOgaMtOHmNc5t+RjW8jYs=; b=uWrjyJJT7+b0SV9ZToaJ1KIFPyJCG87sDEZnQ/4uPLjvE+Gv4J9PhejmeZN350vFZy IpifP6imOeUL05Fzyuc3PXkXWq9muDUEq/6KKi0wevhzT4gq2DcLGCi3nyoNVvSw27Ys PcUL3JfnwFGzTF/JTxv/2HIeTC5zvLiErTEdRAemqgIhqRMG3H0MAz4cC1VNi0GdsgkT aNGWTBoGqeMGK727L9pc0NszrzaIMFRFvvWRHI1sXoLP9mYznw1sv0aVpoRTMUkTTgRV RW0tWtLGeQ9RLvhkNb3gt0hHE3qMt81oh97HW5jkeYmP0xxr2EZWvKoLTp227cwxgMoB AMzw== X-Gm-Message-State: AOAM5309j1LJ+Vhf+BiCKqbaMI6awsMoCI7eaufGtdFUN6JiFW7LpB5q BrNAybH4nu3fhynAYwzw4tI= X-Google-Smtp-Source: ABdhPJypqyrbNio+ygSelexHSUtxznF8mzVzEBNNmvXV5kFlJJk14K7c2oLyfeZUSoVWv9YhxHNb/Q== X-Received: by 2002:a17:90a:c84:: with SMTP id v4mr6627560pja.228.1615428699863; Wed, 10 Mar 2021 18:11:39 -0800 (PST) Received: from z640-arch.lan ([2602:61:738f:1000::678]) by smtp.gmail.com with ESMTPSA id p190sm672603pga.78.2021.03.10.18.11.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 18:11:39 -0800 (PST) From: Ilya Lipnitskiy To: Sean Wang , Landen Chao , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Matthias Brugger , Philipp Zabel , Russell King , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Ilya Lipnitskiy Subject: [PATCH net-next, v2 2/3] net: dsa: mt7530: clean up redundant clock enables Date: Wed, 10 Mar 2021 18:09:53 -0800 Message-Id: <20210311020954.842341-2-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210311020954.842341-1-ilya.lipnitskiy@gmail.com> References: <20210311020954.842341-1-ilya.lipnitskiy@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210311_021141_688004_59C47B9C X-CRM114-Status: GOOD ( 12.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Two minor changes: - In RGMII mode, the REG_GSWCK_EN bit of CORE_TRGMII_GSW_CLK_CG gets set three times in a row. In TRGMII mode, two times. Simplify the code and only set it once for both modes. - When disabling PLL, there is no need to call core_write_mmd_indirect directly, use the core_write wrapper instead like the rest of the code in the function does. This change helps with consistency and readability. Signed-off-by: Ilya Lipnitskiy --- drivers/net/dsa/mt7530.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 9871d7cff93a..80a35caf920e 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -444,10 +444,7 @@ mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface) * provide our own core_write_mmd_indirect to complete this * function. */ - core_write_mmd_indirect(priv, - CORE_GSWPLL_GRP1, - MDIO_MMD_VEND2, - 0); + core_write(priv, CORE_GSWPLL_GRP1, 0); /* Set core clock into 500Mhz */ core_write(priv, CORE_GSWPLL_GRP2, @@ -460,11 +457,7 @@ mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface) RG_GSWPLL_POSDIV_200M(2) | RG_GSWPLL_FBKDIV_200M(32)); - /* Enable MT7530 core clock */ - core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN); - /* Setup the MT7530 TRGMII Tx Clock */ - core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN); core_write(priv, CORE_PLL_GROUP5, RG_LCDDS_PCW_NCPO1(ncpo1)); core_write(priv, CORE_PLL_GROUP6, RG_LCDDS_PCW_NCPO0(0)); core_write(priv, CORE_PLL_GROUP10, RG_LCDDS_SSC_DELTA(ssc_delta)); @@ -478,6 +471,8 @@ mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface) core_write(priv, CORE_PLL_GROUP7, RG_LCDDS_PCW_NCPO_CHG | RG_LCCDS_C(3) | RG_LCDDS_PWDB | RG_LCDDS_ISO_EN); + + /* Enable MT7530 core and TRGMII Tx clocks */ core_set(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN | REG_TRGMIICK_EN); From patchwork Thu Mar 11 02:09:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Lipnitskiy X-Patchwork-Id: 12130153 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CE9BC433E0 for ; Thu, 11 Mar 2021 02:13:24 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0927864FAA for ; Thu, 11 Mar 2021 02:13:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0927864FAA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=LALNflT2qmiVSh5q9hLHa/pZc8RyRJPM9/OJk+rSgWg=; b=Gphth6RfVYDtsiZErvXGMolVV nVAqd7bb/GnP4brxXbkKKvmF0liRtBLP3gZawZ70NpcRAiO2t/RuhnSG1TgDMENf+EE8P40zok/jF bIdI4rI/0SzWR+K4gomaTiBQ2bnyd2gkq8EfmlrHU1H6NGKk2xH35FmfwHguMu9iOO3pLq40LwkZC pEeq24b6mpWWTVxSauBkfaQ1C19y/HRU69pSLNAzAKSlP0VopMH93aHvq2Mro9UXts5FdecaUJBwH VrBzKwoe6TmC1VwTU2uzkwurhp/fzlYH8RgdQfQkCkKKZn90X/dvedw9qJliqpHyQ2AITdM0t6LwB VtEfeVHWA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lKAnw-008EQq-Pr; Thu, 11 Mar 2021 02:12:01 +0000 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lKAnd-008EOO-WC; Thu, 11 Mar 2021 02:11:44 +0000 Received: by mail-pj1-x1032.google.com with SMTP id x7-20020a17090a2b07b02900c0ea793940so8296660pjc.2; Wed, 10 Mar 2021 18:11:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4eB/nkDB8WywIt0l6dz2tHl2O8kDpGdV2lwOJHNqcUc=; b=b4fS6+abyBz8ouSM5tHvmYgX9bb8z6+u9VUhLMiMV9jrTiyC2A4gEf4pIffMxuJhZ7 xlU9OT2EWfcs9T5AH+7h6LCr6oOqOOReMeVdkgI2YNQmnFSxmzJPrL0l3gIaPYC/X1Cf aFCC5yhhkEckVapXl5kPVaH2moliSCMNX8lOSBD2RSsdA6zmp8CnCQAikmxyr7Mmr5VX rUij/JW2eOIS5j59Ywgd3jHJl+uYlkKqgguKDnrS/mDQOFXco2QIlW7iJPHpJKDvP7Ib TNxh4jFHeCltbWILufmG8SbzXyC3JAyo/jimfC+7wOj/E3AvXXWWUiFE11t68tcjUJ5y mllw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4eB/nkDB8WywIt0l6dz2tHl2O8kDpGdV2lwOJHNqcUc=; b=AFcBnt2yy5HByANBQ4P0SciN7/wzqmx8TobK4ns2neFKNvVAEyqreoB9W/NiaZRnnL NLh6ckN+0dREJVaOklvgmqKKBHsgWQ5p49aDhOJTbRQm7wgCpJETeF42qQqg1HtLS1bx aBcoQ5mK7N8O7AdVjfG0O8M7GZrKnkmc6UBkBX21A/BHMQS5GHTWSvcNWF+GC2EjxTI2 0HNggVzia7xiaMvSpOuiIfN2XkGBYaXz1V+oSiwm0UIReMpdwslOhZmPuBjfzxZ3Db2b VUL9VDVFfSIUEbGQM1Aguxppx/752oO69N52uuExfRY0fnl92hjaZ+Cc2V0Uce1Z7BZ8 45ow== X-Gm-Message-State: AOAM533sHaq15GFcCxTzdofaMu/sLliF4J4i64mAFQFU/vm6jRtNgwB8 iyYX/nyBjFirWmR5XhQyAeo= X-Google-Smtp-Source: ABdhPJwpHtrc/BuEVZnFuQctlYwyq5FgZvAVXrzXzQNwkqcADujjyNsApngDaYJlHkujwOA1RmiubQ== X-Received: by 2002:a17:902:b942:b029:e4:87be:be8c with SMTP id h2-20020a170902b942b02900e487bebe8cmr5525396pls.81.1615428700577; Wed, 10 Mar 2021 18:11:40 -0800 (PST) Received: from z640-arch.lan ([2602:61:738f:1000::678]) by smtp.gmail.com with ESMTPSA id p190sm672603pga.78.2021.03.10.18.11.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 18:11:40 -0800 (PST) From: Ilya Lipnitskiy To: Sean Wang , Landen Chao , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , Matthias Brugger , Philipp Zabel , Russell King , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Ilya Lipnitskiy Subject: [PATCH net-next, v2 3/3] net: dsa: mt7530: disable TRGMII clock at reconfigure Date: Wed, 10 Mar 2021 18:09:54 -0800 Message-Id: <20210311020954.842341-3-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210311020954.842341-1-ilya.lipnitskiy@gmail.com> References: <20210311020954.842341-1-ilya.lipnitskiy@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210311_021142_493160_7088D08B X-CRM114-Status: GOOD ( 13.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Disable both core and TRGMII Tx clocks prior to reconfiguring. Previously, only the core clock was disabled, but not TRGMII Tx clock. So disable both, then configure them, then re-enable both, for consistency. Reword the comment about core_write_mmd_indirect for clarity. Tested on Ubiquiti ER-X running the GMAC and MT7530 in TRGMII mode. Signed-off-by: Ilya Lipnitskiy --- drivers/net/dsa/mt7530.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 80a35caf920e..7ef5e7c23e05 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -435,15 +435,18 @@ mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface) mt7530_write(priv, MT7530_TRGMII_TD_ODT(i), TD_DM_DRVP(8) | TD_DM_DRVN(8)); - /* Setup core clock for MT7530 */ - /* Disable MT7530 core clock */ - core_clear(priv, CORE_TRGMII_GSW_CLK_CG, REG_GSWCK_EN); - - /* Disable PLL, since phy_device has not yet been created - * provided for phy_[read,write]_mmd_indirect is called, we - * provide our own core_write_mmd_indirect to complete this - * function. + /* Since phy_device has not yet been created and + * phy_[read,write]_mmd_indirect is not available, we provide our own + * core_write_mmd_indirect with core_{clear,write,set} wrappers to + * complete this function. */ + + /* Disable MT7530 core and TRGMII Tx clocks */ + core_clear(priv, CORE_TRGMII_GSW_CLK_CG, + REG_GSWCK_EN | REG_TRGMIICK_EN); + + /* Setup core clock for MT7530 */ + /* Disable PLL */ core_write(priv, CORE_GSWPLL_GRP1, 0); /* Set core clock into 500Mhz */