Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp615931pxf; Wed, 10 Mar 2021 13:16:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJx71i79mBCzuGjZvKk6vTjrGD0Zw3oXsLcWphqrAgtp1ZFdLk+fekYgNO3f/RNrG92zaeHY X-Received: by 2002:a17:906:c405:: with SMTP id u5mr353386ejz.341.1615411008213; Wed, 10 Mar 2021 13:16:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615411008; cv=none; d=google.com; s=arc-20160816; b=GsO08FYv35B6VLr9C/cf0GXIjlk0fYaruo+shR031lCeV9rL02KzF6JwhQRr1mFDvY wgJiaz3aAFTYv+dljVDmr8uI6AbFMsTEk/YMpi981w6iyYKRHykxeAikyQYonZ+aYEsw WhtGMsiaBFOiNF2vnD55hOgRRAiEzc64W6sb743TZLVAq8LyCkSBf8GKJ63lopq/qoIz w72C+7o74N/pYUHwsHvEcDICcr7AIgMtji/ZKDf4A5TFpjxQWjiaaOSD2HpusQ02axP8 rUV55r82rI2FyGl/PZr4O9/qFb+RLid0Tn5U+NgD1YYp/tJ501blJZ0hH1KthY0mLDjJ AdAA== 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=+v6qAt05GB3pyWDepiyyyWC9bZx8wHfiUnSye/9786g=; b=qC9sqRcf5lVz5o634sz9LMssxLQ0hVH029KqBmJxw6gB/JvislF84xhFyWs9U07Ry4 8VkR0kh3EtY1EftIwTE1ndhNNaP2xLqsWNLhU3so1rCxsPzA7iyOgrNjzdS1kbULlOIK CYQBZ/ug3ouyPVDaf902Wnrc2kxUwSF2g0BH/kgOzzzU1wM41hNpzlGO2UXz12yToqV5 R+m7YO6BChECnAx3El5wZBUD76Citf6IRg+1c+9wIS13yync1bvC/pARvCSvbwt40jI/ U//G1/ZgsiGLMGzWCxDxhc6f2LPOjeMdqyoEZCkcQa9jpzRZtfbaSzhNcSpvJvt7Ka6K 8lSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Bfqtm0qv; 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 sb9si396748ejb.29.2021.03.10.13.16.25; Wed, 10 Mar 2021 13:16:48 -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=Bfqtm0qv; 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 S232186AbhCJVOo (ORCPT + 99 others); Wed, 10 Mar 2021 16:14:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231975AbhCJVO3 (ORCPT ); Wed, 10 Mar 2021 16:14:29 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 260B3C061574; Wed, 10 Mar 2021 13:14:29 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id f2-20020a17090a4a82b02900c67bf8dc69so7944733pjh.1; Wed, 10 Mar 2021 13:14:29 -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=+v6qAt05GB3pyWDepiyyyWC9bZx8wHfiUnSye/9786g=; b=Bfqtm0qvVc7TNTh3q4/EWyuJxpXX1jie2lxkaJCEITbnbLyk0BhgBkeuSK8vlurR3I tHGC2RErjqD8Us9Bkr/Oy5IwY/9UbbTnbCJNyit/Z2EFVhC9DrB1yUtiZj8oN6U7R093 RfQEKm6ske5N6nQN3d35cJcADPN2pmjnYHYQMxea6SB80bI5w1wTZGPvNaHHjOyW3TL4 K29LwBcVT1BvpysQmbya22RNFNTMpAbOuwb6elDvr6QK4EuudQ6Y2nwpeDUC6rJ4kngV yMuvwW5/lxRwCHbHlceUYpFBgVTgH7xDbMAJi+D7Pybpef7uE42zewEDfeAX4MV93Wh9 eSxg== 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=+v6qAt05GB3pyWDepiyyyWC9bZx8wHfiUnSye/9786g=; b=Nw+X7P9RLENEoeOhfnWOEWIz6yFNnbAN0bWYw9jxFfESm1OpX9SjenHb67anG9lTUx nQl3TaV+s101Lvyw7w0Ve5rbSf2gZWJ6ZvWclWXhF5Z35ENp2xvYwJCHCGk9a96HUa0C yLJah7V6wCDkIiQq/lY0Tmz1WPrSPG8rINY+UiHIDkMqkCH1FGJeD5/jIr8c8XwDxtng LkbGcBWj1VeFmFasrOzqeJnX7vKlhs1QPGUib2cpqsOZeg0Ad4IUlviYGDs6Va5T8iwk WNu38hflniVgqLbKBg9LvVq4YWLr9yJ6GHMycWMmFBK2z/JF4OUnmbMqVZjbXm6m1vrm CYmg== X-Gm-Message-State: AOAM530z/TEo7lWL/NR361f2jr7YPjXCd/koGduP9tyP4l7mGUGc0nFg eTkAfwefCSGEZ5Pj8g1wX+s= X-Received: by 2002:a17:90a:7182:: with SMTP id i2mr5360459pjk.111.1615410868697; Wed, 10 Mar 2021 13:14:28 -0800 (PST) Received: from ilya-fury.lan ([2602:61:738f:1000::b87]) by smtp.gmail.com with ESMTPSA id 35sm412090pgr.14.2021.03.10.13.14.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 13:14:27 -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 3/3] net: dsa: mt7530: setup core clock even in TRGMII mode Date: Wed, 10 Mar 2021 13:14:20 -0800 Message-Id: <20210310211420.649985-3-ilya.lipnitskiy@gmail.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210310211420.649985-1-ilya.lipnitskiy@gmail.com> References: <20210310211420.649985-1-ilya.lipnitskiy@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3f9ef7785a9c ("MIPS: ralink: manage low reset lines") 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. Also, disable both core and TRGMII Tx clocks prior to reconfiguring. Previously, only the core clock was disabled, but not TRGMII Tx clock. Tested on Ubiquity ER-X (MT7621) with TRGMII mode enabled. Signed-off-by: Ilya Lipnitskiy --- drivers/net/dsa/mt7530.c | 44 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index b106ea816778..7ef5e7c23e05 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -435,30 +435,30 @@ 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 */ - 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(priv, CORE_GSWPLL_GRP1, 0); - - /* Set core clock into 500Mhz */ - core_write(priv, CORE_GSWPLL_GRP2, - RG_GSWPLL_POSDIV_500M(1) | - RG_GSWPLL_FBKDIV_500M(25)); + /* 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. + */ - /* Enable PLL */ - core_write(priv, CORE_GSWPLL_GRP1, - RG_GSWPLL_EN_PRE | - RG_GSWPLL_POSDIV_200M(2) | - RG_GSWPLL_FBKDIV_200M(32)); + /* 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 */ + 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)); /* Setup the MT7530 TRGMII Tx Clock */ core_write(priv, CORE_PLL_GROUP5, RG_LCDDS_PCW_NCPO1(ncpo1)); -- 2.30.1