From patchwork Sat Jun 17 14:07:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Icenowy Zheng X-Patchwork-Id: 9794089 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 39E1A6038E for ; Sat, 17 Jun 2017 14:10:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2905E27EED for ; Sat, 17 Jun 2017 14:10:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B4C0280CF; Sat, 17 Jun 2017 14:10:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8E45927EED for ; Sat, 17 Jun 2017 14:10:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=2SWfgcEYYs1XPPwkvt26tzOt1zgJG4fIJkIp476Zhzc=; b=NWP78wR1SrJZ+NVI2ZtSq9peCG hWxazYqJ78MBAKFQrS7sTN8N8FLh5tuzyloDZ5L7P8oxtZYlGGf+X+YPIxnviN/SGGmgxh3yBZN+r ohEG44OCfwG/Wby3VAkeoUWYVb4Qm2QTeb683d53QHi//fy1u32Sz809xx6cazg4mnFYg+YF/qrWJ 7hx7Mlj9KGuEl2SmaiI6ooYgM9NIiO99kTs1A5gyLUQ1hKu8n10wkI01i3X6Uv28l/dSFxnetytnn LeXIJie43C67WQjFNjNvOhU8Ljxj4tOYcQUnw1dPHrvs/TxpL/Dk5t3Bjf8WpWhsRuj9VLGxIKtqX /+fLp/gw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dMEQb-0003qy-B7; Sat, 17 Jun 2017 14:10:17 +0000 Received: from eastern.birch.relay.mailchannels.net ([23.83.209.55]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dMEQG-00021R-Cv for linux-arm-kernel@lists.infradead.org; Sat, 17 Jun 2017 14:10:00 +0000 X-Sender-Id: lmn-tzduiowcrqmw|x-authsender|icenowy@aosc.io Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id A0D8B7C6348; Sat, 17 Jun 2017 14:09:39 +0000 (UTC) Received: from hermes.aosc.io (unknown [100.96.137.99]) (Authenticated sender: lmn-TZDUIOWCRQMW) by relay.mailchannels.net (Postfix) with ESMTPA id 141537C6B5F; Sat, 17 Jun 2017 14:09:34 +0000 (UTC) X-Sender-Id: lmn-tzduiowcrqmw|x-authsender|icenowy@aosc.io Received: from hermes.aosc.io (hermes.aosc.io [172.20.63.14]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.9.4); Sat, 17 Jun 2017 14:09:39 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: lmn-tzduiowcrqmw|x-authsender|icenowy@aosc.io X-MailChannels-Auth-Id: lmn-TZDUIOWCRQMW X-Irritate-Lyrical: 5d37d14a7ab4e53a_1497708579353_2579592834 X-MC-Loop-Signature: 1497708579353:2988836906 X-MC-Ingress-Time: 1497708579353 Received: from localhost (localhost [127.0.0.1]) (Authenticated sender: icenowy@aosc.io) by hermes.aosc.io (Postfix) with ESMTPSA id 818B0522EF; Sat, 17 Jun 2017 14:09:22 +0000 (UTC) From: Icenowy Zheng To: Rob Herring , LABBE Corentin , "David S . Miller" , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH 3/4] net-next: stmmac: dwmac-sun8i: force EPHY clock freq to 24MHz Date: Sat, 17 Jun 2017 22:07:36 +0800 Message-Id: <20170617140737.41951-4-icenowy@aosc.io> In-Reply-To: <20170617140737.41951-1-icenowy@aosc.io> References: <20170617140737.41951-1-icenowy@aosc.io> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170617_070957_362042_062A3DB0 X-CRM114-Status: UNSURE ( 9.75 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, linux-arm-kernel@lists.infradead.org, Icenowy Zheng MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The EPHY control part of the EMAC syscon register has a bit called CLK_SEL. On the datasheet it says that if it's 0 the EPHY clock is 25MHz and if it's 1 the clock is 24MHz. However, according to the datasheets, no Allwinner SoC with EPHY has any extra xtal input pins for the EPHY, and the system xtal is 24MHz. That means the EPHY is not possible to get a 25MHz xtal input, and thus the frequency can only be 24MHz. It doesn't matter on H3 as the default value of H3 is 24MHz, however on V3s the default value is wrongly set to 25MHz, which prevented the EPHY from working properly. Force the EPHY clock frequency to 24MHz. Signed-off-by: Icenowy Zheng --- drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c index 54f93ee53ef7..61ce3b54f0c6 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c @@ -185,6 +185,7 @@ static const struct emac_variant emac_variant_a64 = { /* H3 specific bits for EPHY */ #define H3_EPHY_ADDR_SHIFT 20 +#define H3_EPHY_CLK_SEL BIT(18) /* 1: 24MHz, 0: 25MHz */ #define H3_EPHY_LED_POL BIT(17) /* 1: active low, 0: active high */ #define H3_EPHY_SHUTDOWN BIT(16) /* 1: shutdown, 0: power up */ #define H3_EPHY_SELECT BIT(15) /* 1: internal PHY, 0: external PHY */ @@ -656,6 +657,9 @@ static int sun8i_dwmac_set_syscon(struct stmmac_priv *priv) else reg &= ~H3_EPHY_LED_POL; + /* Force EPHY xtal frequency to 24MHz. */ + reg |= H3_EPHY_CLK_SEL; + ret = of_mdio_parse_addr(priv->device, priv->plat->phy_node); if (ret < 0) {