Received: by 10.192.165.148 with SMTP id m20csp525710imm; Wed, 25 Apr 2018 03:40:31 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/NplC9gJAthQ6EqK26mxXWCaDRIC/YOp667J79z1kCxzQw1VMY1H+VR0yWsjDdBKk3F9yI X-Received: by 10.98.16.142 with SMTP id 14mr27252020pfq.22.1524652831259; Wed, 25 Apr 2018 03:40:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524652831; cv=none; d=google.com; s=arc-20160816; b=qBPp4y6wnDLjHgabyaF6P6c/F2PlDthcaYuEXBQ3nr1TJAsoKYJnh2Z3GPMbSUXr8S F2ARPfy0RSObuMYxLxFYrwLlLrIWc+ibnBUqpbHQGi+sPmKkDn3WcYIp1CBs8A1d51W9 wK5Mk5hpiU2Ly9StjilhcYIyXzM1wv4VlvUKXtFCtU+VDyG6NAo+jb9RFEupLv/PcQV4 +Ajukf85y7z4005PBjko3rmGmUe0UYUom7KNjNCv3drkim9jZDvRlu3tVoyj97Pm6uop eeAKe0P7f+yesSzBth/P8odEe+45yepUqgA+aN2M4YlOo3S8iXFGgRskw0Vu8f+RBpDQ Irbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=sm+WvDhuzgyNNIG8zTH596eCDRNFVDxq/4dh21F//tI=; b=ongTBqTj3/KyeV95JSFdpFXDpYGBwb33oguWqekzEIgAURdb08teeMt24jJu04fqZF 0px2mY5614wn5jCksjE30Yk/1qa+cRicr7L2oHctKZ/xmtpiJxDkZIwu9Bkxyp1cpqie DbiONOsA1h1UseHq+qxvLHH+mMWV1vvqU09CF4jSsRzhBQfkO9d2uV0+898+MQPRWo53 lgPy7ieS2lTmP9pB5+YthNXhAjGiES4/somCB3k/jyuL8Q0iJuAspC5ljooc1kBmdz0X mPYTPGsbsk6TcfbVhk2tzx5lBN9jgT2ytSqwdPwMexM7WohUkS6Tupo0YWNIRcXxSIWg uZCA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z3si14703757pfe.255.2018.04.25.03.40.16; Wed, 25 Apr 2018 03:40:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752864AbeDYKjA (ORCPT + 99 others); Wed, 25 Apr 2018 06:39:00 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:51716 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752806AbeDYKi4 (ORCPT ); Wed, 25 Apr 2018 06:38:56 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id D5F42272; Wed, 25 Apr 2018 10:38:55 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Emiliano Ingrassia , Martin Blumenstingl , Jerome Brunet , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 050/183] net: stmmac: dwmac-meson8b: fix setting the RGMII TX clock on Meson8b Date: Wed, 25 Apr 2018 12:34:30 +0200 Message-Id: <20180425103244.567375102@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425103242.532713678@linuxfoundation.org> References: <20180425103242.532713678@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Martin Blumenstingl [ Upstream commit 433c6cab9d298687c097f6ee82e49157044dc7c6 ] Meson8b only supports MPLL2 as clock input. The rate of the MPLL2 clock set by Odroid-C1's u-boot is close to (but not exactly) 500MHz. The exact rate is 500002394Hz, which is calculated in drivers/clk/meson/clk-mpll.c using the following formula: DIV_ROUND_UP_ULL((u64)parent_rate * SDM_DEN, (SDM_DEN * n2) + sdm) Odroid-C1's u-boot configures MPLL2 with the following values: - SDM_DEN = 16384 - SDM = 1638 - N2 = 5 The 250MHz clock (m250_div) inside dwmac-meson8b driver is derived from the MPLL2 clock. Due to MPLL2 running slightly faster than 500MHz the common clock framework chooses a divider which is too big to generate the 250MHz clock (a divider of 2 would be needed, but this is rounded up to a divider of 3). This breaks the RTL8211F RGMII PHY on Odroid-C1 because it requires a (close to) 125MHz RGMII TX clock (on Gbit speeds, the IP block internally divides that down to 25MHz on 100Mbit/s connections and 2.5MHz on 10Mbit/s connections - we don't need any special configuration for that). Round the divider to the closest value to prevent this issue on Meson8b. This means we'll now end up with a clock rate for the RGMII TX clock of 125001197Hz (= 125MHz plus 1197Hz), which is close-enough to 125MHz. This has no effect on the Meson GX SoCs since there fclk_div2 is used as input clock, which has a rate of 1000MHz (and thus is divisible cleanly to 250MHz and 125MHz). Fixes: 566e8251625304 ("net: stmmac: add a glue driver for the Amlogic Meson 8b / GXBB DWMAC") Reported-by: Emiliano Ingrassia Signed-off-by: Martin Blumenstingl Reviewed-by: Jerome Brunet Tested-by: Jerome Brunet Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c @@ -144,7 +144,9 @@ static int meson8b_init_clk(struct meson dwmac->m250_div.shift = PRG_ETH0_CLK_M250_DIV_SHIFT; dwmac->m250_div.width = PRG_ETH0_CLK_M250_DIV_WIDTH; dwmac->m250_div.hw.init = &init; - dwmac->m250_div.flags = CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO; + dwmac->m250_div.flags = CLK_DIVIDER_ONE_BASED | + CLK_DIVIDER_ALLOW_ZERO | + CLK_DIVIDER_ROUND_CLOSEST; dwmac->m250_div_clk = devm_clk_register(dev, &dwmac->m250_div.hw); if (WARN_ON(IS_ERR(dwmac->m250_div_clk)))