Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp5765253ybf; Thu, 5 Mar 2020 06:39:35 -0800 (PST) X-Google-Smtp-Source: ADFU+vv+MZIs8jBgjVvrHD74ha4EmyRnLwktZ8oybTQoujmMqq26iBjQs1p3rTXSql8R8f8Qe4Ix X-Received: by 2002:aca:75d2:: with SMTP id q201mr5931593oic.81.1583419175247; Thu, 05 Mar 2020 06:39:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583419175; cv=none; d=google.com; s=arc-20160816; b=09oeg/DxhyT9iiIW7KuHpKlrD94baGE3e9LKB5nePTnKD5Fj5iVCKpItbcCwvZkFmD 63xNcAC7IuDNz4Kgo2ecTBayItFz4bRWs8U6utGQqImzo3Mf90E2QEQYxQTWaOZDSCKW PYcqJtjgOTfCiB6LonRvUC+N3qTc2ZgCiB0LrSKczI8SVXk+HOuZeOds2K8iTjozr8Ar NjAgAZrj7d3pY+oiyTZ5UH5ANrfJ6UR27GPTMF1wznfaT39oObg2yolSJbP31WnbxpHu SlGZUHQEYZZrHy3do/xYR2jD8f+i5xAUDc0M6yTrcB1RINhyeOoKClyuyWE6poFg/Y6w FJNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=dT+XiPL1+pbORJP34KLhM4OQRR6HTbqn9JOL5YDXisg=; b=qa360JrttNqzQ4Yf9fpnuaJ5iEtJ81k/BG4vKThCgInVeX/ZDY7Yz9Rm+eOIPhspL/ QpB8YQnY9rv7Wmtt87Kvoo+aOEuPY9XGFbLLrJrIVTREzJuOcBz9kl4Iw53cYaYRVTTz LWcKsfIZE2E/ciQ/j6746JpnqCmZqRUp0sIIgq04kBXQkes9ye0EOTA0ynb8jqset7QG E3fdkRP4XEc2B1CiAGxdwRm6meJbwscR0Xlw6WsrhEjDcw9JTi+pwJbSu2T+pqCLjQyf M5mDDb4WTxVMxlwX1BHGrVtaFDdpEbrFmqFYvdYKZfhRYBK+cA3rNMoJuRJ1IcpMViAj FGlA== 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 d8si3709811oti.306.2020.03.05.06.39.22; Thu, 05 Mar 2020 06:39:35 -0800 (PST) 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 S1726905AbgCEOiT (ORCPT + 99 others); Thu, 5 Mar 2020 09:38:19 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:40923 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726204AbgCEOiS (ORCPT ); Thu, 5 Mar 2020 09:38:18 -0500 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j9rdY-0001EN-Iq; Thu, 05 Mar 2020 15:38:08 +0100 Received: from ore by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1j9rdV-000208-Sz; Thu, 05 Mar 2020 15:38:05 +0100 Date: Thu, 5 Mar 2020 15:38:05 +0100 From: Oleksij Rempel To: Philippe Schenker Cc: Russell King , linux-arm-kernel@lists.infradead.org, NXP Linux Team , Fabio Estevam , Kate Stewart , Greg Kroah-Hartman , Sascha Hauer , linux-kernel@vger.kernel.org, Pengutronix Kernel Team , Thomas Gleixner , Shawn Guo , Allison Randal Subject: Re: [PATCH] ARM: mach-imx6q: add ksz9131rn_phy_fixup Message-ID: <20200305143805.dk7fndblnqjnwxu6@pengutronix.de> References: <20200305134928.19775-1-philippe.schenker@toradex.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200305134928.19775-1-philippe.schenker@toradex.com> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 15:27:00 up 111 days, 5:45, 138 users, load average: 0.18, 0.14, 0.10 User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Philippe, On Thu, Mar 05, 2020 at 02:49:28PM +0100, Philippe Schenker wrote: > The MAC of the i.MX6 SoC is compliant with RGMII v1.3. The KSZ9131 PHY > is like KSZ9031 adhering to RGMII v2.0 specification. This means the > MAC should provide a delay to the TXC line. Because the i.MX6 MAC does > not provide this delay this has to be done in the PHY. > > This patch adds by default ~1.6ns delay to the TXC line. This should > be good for all boards that have the RGMII signals routed with the > same length. > > The KSZ9131 has relatively high tolerances on skew registers from > MMD 2.4 to MMD 2.8. Therefore the new DLL-based delay of 2ns is used > and then as little as possibly subtracted from that so we get more > accurate delay. This is actually needed because the i.MX6 SoC has > an asynchron skew on TXC from -100ps to 900ps, to get all RGMII > values within spec. This configuration has nothing to do in mach-imx/* It belongs to the board devicetree. Please see DT binding documentation for needed properties: Documentation/devicetree/bindings/net/micrel-ksz90x1.txt All of this mach-imx fixups are evil and should be removed or disabled by Kconfig option. Since they will run on all i.MX based boards even if this PHY are connected to some switch and not connected to the FEC directly. And.. If driver didn't made this configuration all this changes will be lost on suspend/resume cycle or on PHY reset. Regards, Oleksij > Signed-off-by: Philippe Schenker > > --- > > arch/arm/mach-imx/mach-imx6q.c | 37 ++++++++++++++++++++++++++++++++++ > 1 file changed, 37 insertions(+) > > diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c > index edd26e0ffeec..8ae5f2fa33e2 100644 > --- a/arch/arm/mach-imx/mach-imx6q.c > +++ b/arch/arm/mach-imx/mach-imx6q.c > @@ -61,6 +61,14 @@ static void mmd_write_reg(struct phy_device *dev, int device, int reg, int val) > phy_write(dev, 0x0e, val); > } > > +static int mmd_read_reg(struct phy_device *dev, int device, int reg) > +{ > + phy_write(dev, 0x0d, device); > + phy_write(dev, 0x0e, reg); > + phy_write(dev, 0x0d, (1 << 14) | device); > + return phy_read(dev, 0x0e); > +} > + > static int ksz9031rn_phy_fixup(struct phy_device *dev) > { > /* > @@ -74,6 +82,33 @@ static int ksz9031rn_phy_fixup(struct phy_device *dev) > return 0; > } > > +#define KSZ9131_RXTXDLL_BYPASS 12 > + > +static int ksz9131rn_phy_fixup(struct phy_device *dev) > +{ > + int tmp; > + > + tmp = mmd_read_reg(dev, 2, 0x4c); > + /* disable rxdll bypass (enable 2ns skew delay on RXC) */ > + tmp &= ~(1 << KSZ9131_RXTXDLL_BYPASS); > + mmd_write_reg(dev, 2, 0x4c, tmp); > + > + tmp = mmd_read_reg(dev, 2, 0x4d); > + /* disable txdll bypass (enable 2ns skew delay on TXC) */ > + tmp &= ~(1 << KSZ9131_RXTXDLL_BYPASS); > + mmd_write_reg(dev, 2, 0x4d, tmp); > + > + /* > + * Subtract ~0.6ns from txdll = ~1.4ns delay. > + * leave RXC path untouched > + */ > + mmd_write_reg(dev, 2, 4, 0x007d); > + mmd_write_reg(dev, 2, 6, 0xdddd); > + mmd_write_reg(dev, 2, 8, 0x0007); > + > + return 0; > +} > + > /* > * fixup for PLX PEX8909 bridge to configure GPIO1-7 as output High > * as they are used for slots1-7 PERST# > @@ -167,6 +202,8 @@ static void __init imx6q_enet_phy_init(void) > ksz9021rn_phy_fixup); > phy_register_fixup_for_uid(PHY_ID_KSZ9031, MICREL_PHY_ID_MASK, > ksz9031rn_phy_fixup); > + phy_register_fixup_for_uid(PHY_ID_KSZ9131, MICREL_PHY_ID_MASK, > + ksz9131rn_phy_fixup); > phy_register_fixup_for_uid(PHY_ID_AR8031, 0xffffffef, > ar8031_phy_fixup); > phy_register_fixup_for_uid(PHY_ID_AR8035, 0xffffffef, > -- > 2.25.1 > > > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |