Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1039446pxb; Fri, 21 Jan 2022 08:37:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJwswK4pEh0hX+hSs+ur9MbkOAKJrWoDx8Y/elYkr7xO7lBoEic92QBTzAt0Z0yO5Mc1lxwh X-Received: by 2002:a17:90a:f413:: with SMTP id ch19mr1546021pjb.15.1642783064575; Fri, 21 Jan 2022 08:37:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642783064; cv=none; d=google.com; s=arc-20160816; b=Yd3EQ6l+fc2Cvk3QA1DVHiXNHMbDjK5NrWLKkER1QrnDsAe+sONIxPX4o24GMftwcQ VhCPqUhBl2lDsa/G4oSLkkG3XDDHJY5FDN9wryXuk2y/YARMCxZI+cNRSHnVaetlhhon RpJcomegnYFry5zwuRl+757MbFBgtqaV8y0pGDa9WkyC45XWHEIeOx6w4aSKoltr6gy1 ahJeyFAh/0sZHLsLwwZP1iKUh7mXS8YSKYLgMIOBlLaNkOYZ/zDlPukRt9KNSSZS5fGR L9oshGgSlpp7tJBoM7feaCrOegCh1r01sev4zc/XD401v93h9Cl3HVHMIiU+Cwv0jxkW LWIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=A8pMkyAUj72b6fL1NdYkNKofnCbPDAfi95CnErQkq+c=; b=HLQBM/fKbJnxYX4OHOvD5ZCnKvpplkoQeEvGXcAWo/wGRKBHejrBSq1+BMustP9suO +zMeKVvZvIuzxp4pMCSE5sqEEUzNCyIzHyjsLk2nk+J9zy45xaFhNlVuTI6MP9X6XWxO P8aY5ncR8MXPA0riKCMauBB8eGZaygjjq6OMS+tW5XKIMDQxwR1lzIk8S5UOeaB2L4N6 O8D1lAT07wWBh9X2WvOzso8cnfdPsrhHMUmPJTl6CulKLf6dtNEUcQM3hL0YX/W0zvQo XN7wbGOszB5fuL7oyLu/J8Xluaf2C27R5Ygzphr64/2csANL6KVpjF2JXjXwIUmK308y 5OZQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=toshiba.co.jp Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mq17si15867235pjb.175.2022.01.21.08.37.32; Fri, 21 Jan 2022 08:37:44 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=toshiba.co.jp Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351590AbiASEyE (ORCPT + 99 others); Tue, 18 Jan 2022 23:54:04 -0500 Received: from mo-csw1116.securemx.jp ([210.130.202.158]:46864 "EHLO mo-csw.securemx.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351594AbiASEyD (ORCPT ); Tue, 18 Jan 2022 23:54:03 -0500 Received: by mo-csw.securemx.jp (mx-mo-csw1116) id 20J4qIBa001077; Wed, 19 Jan 2022 13:52:18 +0900 X-Iguazu-Qid: 2wHHIL40Qv8bwxaa7m X-Iguazu-QSIG: v=2; s=0; t=1642567938; q=2wHHIL40Qv8bwxaa7m; m=mUv5rSqyBzxQOMJyaic4BAxAPvhK5o4ZF2GjJN3gXb8= Received: from imx2-a.toshiba.co.jp (imx2-a.toshiba.co.jp [106.186.93.35]) by relay.securemx.jp (mx-mr1111) id 20J4qGK8001600 (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128 verify=NOT); Wed, 19 Jan 2022 13:52:17 +0900 X-SA-MID: 30555175 From: Yuji Ishikawa To: "David S . Miller" , Jakub Kicinski Cc: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, nobuhiro1.iwamatsu@toshiba.co.jp, yuji2.ishikawa@toshiba.co.jp Subject: [PATCH v2 2/2] net: stmmac: dwmac-visconti: Fix clock configuration for RMII mode Date: Wed, 19 Jan 2022 13:46:48 +0900 X-TSB-HOP: ON X-TSB-HOP2: ON Message-Id: <20220119044648.18094-3-yuji2.ishikawa@toshiba.co.jp> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220119044648.18094-1-yuji2.ishikawa@toshiba.co.jp> References: <20220119044648.18094-1-yuji2.ishikawa@toshiba.co.jp> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Bit pattern of the ETHER_CLOCK_SEL register for RMII/MII mode should be fixed. Also, some control bits should be modified with a specific sequence. Fixes: b38dd98ff8d0 ("net: stmmac: Add Toshiba Visconti SoCs glue driver") Signed-off-by: Yuji Ishikawa Reviewed-by: Nobuhiro Iwamatsu --- .../ethernet/stmicro/stmmac/dwmac-visconti.c | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c index 43a446cea..dde5b772a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c @@ -96,31 +96,41 @@ static void visconti_eth_fix_mac_speed(void *priv, unsigned int speed) val |= ETHER_CLK_SEL_TX_O_E_N_IN; writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); + /* Set Clock-Mux, Start clock, Set TX_O direction */ switch (dwmac->phy_intf_sel) { case ETHER_CONFIG_INTF_RGMII: val = clk_sel_val | ETHER_CLK_SEL_RX_CLK_EXT_SEL_RXC; + writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); + + val |= ETHER_CLK_SEL_RX_TX_CLK_EN; + writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); + + val &= ~ETHER_CLK_SEL_TX_O_E_N_IN; + writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); break; case ETHER_CONFIG_INTF_RMII: val = clk_sel_val | ETHER_CLK_SEL_RX_CLK_EXT_SEL_DIV | - ETHER_CLK_SEL_TX_CLK_EXT_SEL_TXC | ETHER_CLK_SEL_TX_O_E_N_IN | + ETHER_CLK_SEL_TX_CLK_EXT_SEL_DIV | ETHER_CLK_SEL_TX_O_E_N_IN | ETHER_CLK_SEL_RMII_CLK_SEL_RX_C; + writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); + + val |= ETHER_CLK_SEL_RMII_CLK_RST; + writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); + + val |= ETHER_CLK_SEL_RMII_CLK_EN | ETHER_CLK_SEL_RX_TX_CLK_EN; + writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); break; case ETHER_CONFIG_INTF_MII: default: val = clk_sel_val | ETHER_CLK_SEL_RX_CLK_EXT_SEL_RXC | - ETHER_CLK_SEL_TX_CLK_EXT_SEL_DIV | ETHER_CLK_SEL_TX_O_E_N_IN | - ETHER_CLK_SEL_RMII_CLK_EN; + ETHER_CLK_SEL_TX_CLK_EXT_SEL_TXC | ETHER_CLK_SEL_TX_O_E_N_IN; + writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); + + val |= ETHER_CLK_SEL_RX_TX_CLK_EN; + writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); break; } - /* Start clock */ - writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); - val |= ETHER_CLK_SEL_RX_TX_CLK_EN; - writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); - - val &= ~ETHER_CLK_SEL_TX_O_E_N_IN; - writel(val, dwmac->reg + REG_ETHER_CLOCK_SEL); - spin_unlock_irqrestore(&dwmac->lock, flags); } -- 2.17.1