From mboxrd@z Thu Jan 1 00:00:00 1970 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=-20.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 87E64C433F5 for ; Thu, 23 Sep 2021 03:41:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 715CF6135F for ; Thu, 23 Sep 2021 03:41:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239826AbhIWDmj (ORCPT ); Wed, 22 Sep 2021 23:42:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:42480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239275AbhIWDlF (ORCPT ); Wed, 22 Sep 2021 23:41:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D715761131; Thu, 23 Sep 2021 03:39:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632368375; bh=1axoiNAjA9fn3dhllJ6mlnrdl4L3sQzVBsp4cEFZYXE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X7Dh8HzwLbIvT3X4xvpREGYyu7nKejC2jhaZSLXOzgM+86m52Pkd+ooKbtPVmlPK2 shja/BfFPsvZCyK03cVkv95cBPLt9V6nGTmPzLiFxLbBHC95AEUclsf03hpjEJwa70 6W7wy8ZuriXES60L42M3DK9ORcItWDuzgOEDJ3HKERcjOeR9iBgbfujwjajD+qFqaB 1tRpkxubbQuGZyPGMdY9Y9i/FF9M/7lNYg61FjWopMv1JcxxhU4V1WLynNAHXcTV+c QdDqnfXA0EW4R9G9v/u6keLV9zJwSOppZIUZlh78yoc4xT8MnsRa9WW4EqdV+OPPD5 Md4fIvxyal6Ag== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jesper Nilsson , "David S . Miller" , Sasha Levin , peppe.cavallaro@st.com, alexandre.torgue@foss.st.com, joabreu@synopsys.com, kuba@kernel.org, mcoquelin.stm32@gmail.com, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 4.19 03/15] net: stmmac: allow CSR clock of 300MHz Date: Wed, 22 Sep 2021 23:39:17 -0400 Message-Id: <20210923033929.1421446-3-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210923033929.1421446-1-sashal@kernel.org> References: <20210923033929.1421446-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jesper Nilsson [ Upstream commit 08dad2f4d541fcfe5e7bfda72cc6314bbfd2802f ] The Synopsys Ethernet IP uses the CSR clock as a base clock for MDC. The divisor used is set in the MAC_MDIO_Address register field CR (Clock Rate) The divisor is there to change the CSR clock into a clock that falls below the IEEE 802.3 specified max frequency of 2.5MHz. If the CSR clock is 300MHz, the code falls back to using the reset value in the MAC_MDIO_Address register, as described in the comment above this code. However, 300MHz is actually an allowed value and the proper divider can be estimated quite easily (it's just 1Hz difference!) A CSR frequency of 300MHz with the maximum clock rate value of 0x5 (STMMAC_CSR_250_300M, a divisor of 124) gives somewhere around ~2.42MHz which is below the IEEE 802.3 specified maximum. For the ARTPEC-8 SoC, the CSR clock is this problematic 300MHz, and unfortunately, the reset-value of the MAC_MDIO_Address CR field is 0x0. This leads to a clock rate of zero and a divisor of 42, and gives an MDC frequency of ~7.14MHz. Allow CSR clock of 300MHz by making the comparison inclusive. Signed-off-by: Jesper Nilsson Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index af59761ddfa0..064e13bd2c8b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -227,7 +227,7 @@ static void stmmac_clk_csr_set(struct stmmac_priv *priv) priv->clk_csr = STMMAC_CSR_100_150M; else if ((clk_rate >= CSR_F_150M) && (clk_rate < CSR_F_250M)) priv->clk_csr = STMMAC_CSR_150_250M; - else if ((clk_rate >= CSR_F_250M) && (clk_rate < CSR_F_300M)) + else if ((clk_rate >= CSR_F_250M) && (clk_rate <= CSR_F_300M)) priv->clk_csr = STMMAC_CSR_250_300M; } -- 2.30.2 From mboxrd@z Thu Jan 1 00:00:00 1970 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=-18.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 E4434C433EF for ; Thu, 23 Sep 2021 03:41:17 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 B7E086135F for ; Thu, 23 Sep 2021 03:41:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B7E086135F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; 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=qGBTHWl7sEJi/w3jNFCKPmX0BbIK3URAcrfXil+P6l8=; b=kwP7Kl27UPtjAa DbTTQ1YzIbc2/GR23aOi1RRaGb946kvIUcxcOkpbtfvuy/eWDrmzVIc0g+2304XQsZHZjUT5Gxo1b U8unxnYgV5ZZYYfNEN0FhoEAT4oqzgAwofVFGslZ1cAG9NMGjvugTuKUUKUpXgqOTuYYKx8ANtrrQ NHZP7Lh8M+MpyNzw+bSqDHjpM0j8A5WIAn01eTPNSQRV5IF425tlgMzILpm6Ms/wWR50m+hWDY7db EcLUb/I0FNEU0CmpjtkR7dEIGUZrnaGNI9KpPsPhXTeJ3dkCldXgxql7aSt0iEV4A325rhxPta5nV josZe/WhnHxX9davfZWw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mTFaH-00AAro-6b; Thu, 23 Sep 2021 03:39:41 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mTFaB-00AApU-CV for linux-arm-kernel@lists.infradead.org; Thu, 23 Sep 2021 03:39:36 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id D715761131; Thu, 23 Sep 2021 03:39:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632368375; bh=1axoiNAjA9fn3dhllJ6mlnrdl4L3sQzVBsp4cEFZYXE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X7Dh8HzwLbIvT3X4xvpREGYyu7nKejC2jhaZSLXOzgM+86m52Pkd+ooKbtPVmlPK2 shja/BfFPsvZCyK03cVkv95cBPLt9V6nGTmPzLiFxLbBHC95AEUclsf03hpjEJwa70 6W7wy8ZuriXES60L42M3DK9ORcItWDuzgOEDJ3HKERcjOeR9iBgbfujwjajD+qFqaB 1tRpkxubbQuGZyPGMdY9Y9i/FF9M/7lNYg61FjWopMv1JcxxhU4V1WLynNAHXcTV+c QdDqnfXA0EW4R9G9v/u6keLV9zJwSOppZIUZlh78yoc4xT8MnsRa9WW4EqdV+OPPD5 Md4fIvxyal6Ag== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jesper Nilsson , "David S . Miller" , Sasha Levin , peppe.cavallaro@st.com, alexandre.torgue@foss.st.com, joabreu@synopsys.com, kuba@kernel.org, mcoquelin.stm32@gmail.com, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 4.19 03/15] net: stmmac: allow CSR clock of 300MHz Date: Wed, 22 Sep 2021 23:39:17 -0400 Message-Id: <20210923033929.1421446-3-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210923033929.1421446-1-sashal@kernel.org> References: <20210923033929.1421446-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210922_203935_497888_517E91D8 X-CRM114-Status: GOOD ( 14.42 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Jesper Nilsson [ Upstream commit 08dad2f4d541fcfe5e7bfda72cc6314bbfd2802f ] The Synopsys Ethernet IP uses the CSR clock as a base clock for MDC. The divisor used is set in the MAC_MDIO_Address register field CR (Clock Rate) The divisor is there to change the CSR clock into a clock that falls below the IEEE 802.3 specified max frequency of 2.5MHz. If the CSR clock is 300MHz, the code falls back to using the reset value in the MAC_MDIO_Address register, as described in the comment above this code. However, 300MHz is actually an allowed value and the proper divider can be estimated quite easily (it's just 1Hz difference!) A CSR frequency of 300MHz with the maximum clock rate value of 0x5 (STMMAC_CSR_250_300M, a divisor of 124) gives somewhere around ~2.42MHz which is below the IEEE 802.3 specified maximum. For the ARTPEC-8 SoC, the CSR clock is this problematic 300MHz, and unfortunately, the reset-value of the MAC_MDIO_Address CR field is 0x0. This leads to a clock rate of zero and a divisor of 42, and gives an MDC frequency of ~7.14MHz. Allow CSR clock of 300MHz by making the comparison inclusive. Signed-off-by: Jesper Nilsson Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index af59761ddfa0..064e13bd2c8b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -227,7 +227,7 @@ static void stmmac_clk_csr_set(struct stmmac_priv *priv) priv->clk_csr = STMMAC_CSR_100_150M; else if ((clk_rate >= CSR_F_150M) && (clk_rate < CSR_F_250M)) priv->clk_csr = STMMAC_CSR_150_250M; - else if ((clk_rate >= CSR_F_250M) && (clk_rate < CSR_F_300M)) + else if ((clk_rate >= CSR_F_250M) && (clk_rate <= CSR_F_300M)) priv->clk_csr = STMMAC_CSR_250_300M; } -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel