Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1190054ybx; Tue, 5 Nov 2019 11:52:06 -0800 (PST) X-Google-Smtp-Source: APXvYqxB4CQ/HJB510f+TczeLAE/gIVDm4tOryXzmqwB7r64Uc2qm3psExF40msKOU+L25xHGJE1 X-Received: by 2002:aa7:c7c1:: with SMTP id o1mr37745500eds.123.1572983526830; Tue, 05 Nov 2019 11:52:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572983526; cv=none; d=google.com; s=arc-20160816; b=JEurtOWpuV544MLu+RHB1HeedERnmDyZEjRaqhlp/fF2eJrbP90WvWKsURR+kcS8yV ep0yTV1ajlV0miXHq/+gXj7f/SPRViVZenWSKFXd5e3otsvzrTEH+yCrHxegVTqfJj3E AN9nuiKka2Y+X4Ypz5p1lGWYRfEeNwah8snXhEGB10iZIj/vzHNfAr8ClXw+3CIt1zZs 8vs/MWfMoiKC2tpG0cI1i3h177DiKQxdK2z7A/d55xHian93rgjI9iLw/0pF1HNND/PA JxVEg8EkbtPVPxzGFVHf0e9vxsjgHrX0i/Q/ekTo44kZD/qYd7jhl4fAcSW8XFm28+66 BX3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=UxXl5CJZIoFnMZL6/cL403hkZBabWwNFlZGMcKNv9CI=; b=Y6uAIusr3uSgPEIHGY9bnsWpphLpV9HjLWqiRHz3rmX+tQopTJi23V28+54VDI0fDN F6rcfdTrL9Pre/E3+1jK6cZT2MGXwzJyp+kHu1zxAgWSwZ38j11hwL1a+ke/pkuGLIZ/ eXhMJkUUTA9J65F76RuXyedb1i9auA6u+IZPH25WC6jN3XQ0ypjt5vlNtlr3g6BtWx4U kBEqb6YPdY8vGQIHOpET/d9XJ64jdOJRHfJB/i5T7Iw3MXR3uzr8WY2GMrbwu6Qhtwyn dLdPnwm27SanX6GwbjC8EJ5w4RdAUgwPjg/22+pFZ6ly6fMeonjBPyWlQgU/tueTpD5K Hcmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=DfYf1tIr; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z4si12782706edi.38.2019.11.05.11.51.43; Tue, 05 Nov 2019 11:52:06 -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; dkim=pass header.i=@broadcom.com header.s=google header.b=DfYf1tIr; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727004AbfKETtE (ORCPT + 99 others); Tue, 5 Nov 2019 14:49:04 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:33208 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726608AbfKETtD (ORCPT ); Tue, 5 Nov 2019 14:49:03 -0500 Received: by mail-wm1-f67.google.com with SMTP id 6so654336wmf.0 for ; Tue, 05 Nov 2019 11:49:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=UxXl5CJZIoFnMZL6/cL403hkZBabWwNFlZGMcKNv9CI=; b=DfYf1tIrKNQZt5fdgVqLgqi9HccpFBFoGh8ZAIkWq7pZT4qlZBAGSwp0X/aWi9iSvF jdNUkLVEFALgwFaBiECrIdp8xyCC63qPPxyOhzLyGFAprniDgrisk5yOz3hXvx6aw7+2 mznBwKqa7nyBfAp3+8t/VOThwm5XgrDCzgLRk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=UxXl5CJZIoFnMZL6/cL403hkZBabWwNFlZGMcKNv9CI=; b=cu8Eqr3Wa71XfyEXCbYyxOgmfSc08R89npfrYdOXDLBiwjyGl5amjuHr+JYLeM8Uob ukN+Eux2HmHbB6R7is7qy6sT2b9K5hVgc24BiMfJqt2mYU5jV0h447Z1FfO10gQ/xHWz Y1ruZCP8l6wCgkdAVoRpeSOmbuMe72oXSak06VtLwvo/5eKov4ghhUTUUKRKS7JOCbaU kTqVanf5RxrN/WBC7uTo97wzKbN8bbghjIdxqNCv4UoN71oz+0gYhpozCByZyA5nKNGQ VyLPqFC6MKazigbIOfun22REQoJQWQibkvbnQICLklX+G4/GUvZmrGI5hOB9k2e0zZOh 4SCg== X-Gm-Message-State: APjAAAVlRCaqIgHBe70pRDImPuUKbZ6l82jexgWpfrrOSOf0k65W0vk1 BzJGockTPgOYQqV01ZEpDY8aAuoTlc8QmZRvMPi8f0FxCIeivxK4GQmIvRHPdV50pvQFSNY/yz5 Y5+SnvbeyEi3qVfljOS5wgPqEohi3nvMjuXdM7fclV73BB4yB6I7Dhzj/NhtHFD9wY9UPOT56nR P2N0cCuSNB6Vo= X-Received: by 2002:a1c:ed0e:: with SMTP id l14mr580961wmh.74.1572983341018; Tue, 05 Nov 2019 11:49:01 -0800 (PST) Received: from [10.136.13.65] ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id j22sm30194509wrd.41.2019.11.05.11.48.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Nov 2019 11:49:00 -0800 (PST) Subject: Re: [PATCH net 1/3] net: bcmgenet: use RGMII loopback for MAC reset To: Doug Berger , "David S. Miller" Cc: Florian Fainelli , bcm-kernel-feedback-list@broadcom.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <1572980846-37707-1-git-send-email-opendmb@gmail.com> <1572980846-37707-2-git-send-email-opendmb@gmail.com> <8c5c8028-a897-bf70-95ba-a1ffc8b68264@broadcom.com> <5f68345e-c58d-3d99-189b-b4be39c4b899@gmail.com> From: Scott Branden Message-ID: <6bc48252-952c-008d-f43d-b8093c021ba8@broadcom.com> Date: Tue, 5 Nov 2019 11:48:56 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <5f68345e-c58d-3d99-189b-b4be39c4b899@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-11-05 11:27 a.m., Doug Berger wrote: > On 11/5/19 11:14 AM, Scott Branden wrote: >> Hi Doug, >> >> On 2019-11-05 11:07 a.m., Doug Berger wrote: >>> As noted in commit 28c2d1a7a0bf ("net: bcmgenet: enable loopback >>> during UniMAC sw_reset") the UniMAC must be clocked while sw_reset >>> is asserted for its state machines to reset cleanly. >>> >>> The transmit and receive clocks used by the UniMAC are derived from >>> the signals used on its PHY interface. The bcmgenet MAC can be >>> configured to work with different PHY interfaces including MII, >>> GMII, RGMII, and Reverse MII on internal and external interfaces. >>> Unfortunately for the UniMAC, when configured for MII the Tx clock >>> is always driven from the PHY which places it outside of the direct >>> control of the MAC. -- SNIP >>> +        /* Switch MAC clocking to RGMII generated clock */ >>> +        bcmgenet_sys_writel(priv, PORT_MODE_EXT_GPHY, SYS_PORT_CTRL); >>> +        /* Ensure 5 clks with Rx disabled >>> +         * followed by 5 clks with Reset asserted >>> +         */ >>> +        udelay(4); >> How do these magic delays work, they are different values? >> In one case you have a udelay(4) to ensure rx disabled for 5 clks. >> Yet below you have a udelay(2) to ensure 4 more clocks? > The delays are based on 2.5MHz clock cycles (the clock used for 10Mbps). > 5 clocks is 2us. > > The udelay(4) is for 10 clocks: rx is disabled for 5 and then 5 more > clocks with reset held. The requirement is poorly specified and this is > a conservative interpretation. > > The udelay(2) allows at least 5 more clocks without reset before rx can > be enabled. > Thanks, the part I was missing was "2.5MHz clock cycles (the clock used for 10Mbps)". If that was added to the comment it would help those unfamiliar with in understanding. >>> +        reg &= ~(CMD_SW_RESET | CMD_LCL_LOOP_EN); >>> +        bcmgenet_umac_writel(priv, reg, UMAC_CMD); >>> +        /* Ensure 5 more clocks before Rx is enabled */ >>> +        udelay(2); >>> +    } >>> + >>>       priv->ext_phy = !priv->internal_phy && >>>               (priv->phy_interface != PHY_INTERFACE_MODE_MOCA); >>>   @@ -254,6 +284,9 @@ int bcmgenet_mii_config(struct net_device *dev, >>> bool init) >>>           phy_set_max_speed(phydev, SPEED_100); >>>           bcmgenet_sys_writel(priv, >>>                       PORT_MODE_EXT_EPHY, SYS_PORT_CTRL); >>> +        /* Restore the MII PHY after isolation */ >>> +        if (bmcr >= 0) >>> +            phy_write(phydev, MII_BMCR, bmcr); >>>           break; >>>         case PHY_INTERFACE_MODE_REVMII: > Regards, > Doug