Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp780682pxf; Wed, 10 Mar 2021 18:13:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJzCmJqwd5iFxbkK2EiJAHq+ITm9omFnrnZ8LEGrh++TtCkHFuZVplKYZqAWXrL/3UQ65XCW X-Received: by 2002:a50:ee10:: with SMTP id g16mr6196133eds.215.1615428822231; Wed, 10 Mar 2021 18:13:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615428822; cv=none; d=google.com; s=arc-20160816; b=x6TWM+xORuAE437Nv6bGT5EefOfp1jGyoKirap0WML5UYJRCuZXO6j8QuYCnKzr7fK xXbg0B8iYCbb2rxNnavIXzIpN6cnijmh0dTdXESMKdS+EuBNoV80jFo950tT8EB7vWiE F7ioPg3UFAUwzSG5swwu9gvFgnrEbh9Gwad/pi8w/ic7VfyER0e/n61dy6SjeO56gZyL 6eu0Cv1MCr6XJ7ywDjHcBVZbFJk9NmInSuJ/UjpYDHKd/EKZ/WsOpONaTLKBzJCPeh8b BXygR97TVyaq1F9IRIWGvFPvEatqMU9/l4xxgz1uo6BhDs00qS6wtiGp3F5up4DPZ+Te 7AZg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=te3KkZ/7y8l0N1gnz9fMIpGsfWHYXiKPURp+vcWCB8E=; b=POu0W+b2juWCFXO76fcvD19QOCpht5/VA6FOwLmrX+1CZyrsJ235eG2rKdmZZPjQE3 6Er4lhztdKWq8IcgsetNaL9th59UTPFsLOuBPcIKLE+jcmt3Po/idgp/3TBrLuPmehFZ okcLeoPrAIkcG7N5EMthQfRvK6DRqVJLZuhEdRqtZqlLx4Nv3uH2gE+ryxlNR7/MdE9S erZOEVowZ6GdI+Xy4QFgrMmZpkNsnN8hAI5+ZTGy9/Xmp2AUB1EXwYPrucef+IvyolWJ Wz00XkOmSKXcY6C2qz1r2k6N/6WsMSEPkfRlYVn7c8uYHNHLWDmcUGhVPrCtMrKWml15 zGwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tVjmXz8D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id eb13si810015edb.8.2021.03.10.18.13.20; Wed, 10 Mar 2021 18:13:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tVjmXz8D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230242AbhCKCMK (ORCPT + 99 others); Wed, 10 Mar 2021 21:12:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229851AbhCKCLj (ORCPT ); Wed, 10 Mar 2021 21:11:39 -0500 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A42FC061762; Wed, 10 Mar 2021 18:11:39 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id d23so6246423plq.2; Wed, 10 Mar 2021 18:11:39 -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=jBZ4C8yDNdvFP+z2m4+7FcAhc966ekZ2sfBYmWmTS9i5pm12pfrZMeABrTVbUtZJf5 8JsJ02OQdqH2SVY0upb2jMV4BJGcEppOBx2N7D1Guczbx6RviiDIVR7T6j2gaGpDPphV yC66mOZeNv2MzB1hfgOMmK7SJqJXCNs6kslVVMZMoHrIw4dC/0y0yEIPe7egviKM5VCi EA4hwk9J4lzr5Koe0yGcZnWTcXDzglRzdphpG91FEftkwQRy8fIPeizJh5BbCbTaTmGz fFlIm4sHs4mUtDpjqbZM6IMKv4jvA5mPBPr5iQ0MBhhGpQokOmLsEDav20xuzrR/rY4i TgkA== X-Gm-Message-State: AOAM530B41Y7Obue4l6uW/OKF/So7huhCF+w4Cu/pisD+SqIyW289SCp EbTMfosTiOeUjhYdYbfDHTWlVwrnSatPPXOa 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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); -- 2.30.2