Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp475063pxa; Wed, 19 Aug 2020 06:45:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/YyU+bhaH9nzSLq5ZEvTvqhByldCsyOBHKXwtbvnuUPHCNf06lUOSd6Qw7aHG13h7sJ6S X-Received: by 2002:a17:906:a8f:: with SMTP id y15mr24766862ejf.140.1597844744519; Wed, 19 Aug 2020 06:45:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597844744; cv=none; d=google.com; s=arc-20160816; b=BVyCWrLIWrDmLNTfrL1u/equUuJz5LHzJQft1MWAna2eN3AkFpqKplDaZz3M8HbY4V ZhZRbqSBhzKaEmf63iQhiY/x1sjpEMMQS8vFD14Px6EsnOxWTjf7PysOBvss8mwp0/z8 sV/IIf+jCJqFtBRPmLpgAONcl4KpDmFrXxZgy+KeQxwP/ORaoXpIYs2FJ2p0seJIIkvx UBWc/qfEfQ30aR7SjpS8HczfIGIjZlTWO+txlkxCYId1TI1awhsdQQtOq9qs+9M4wzPt 6KuFMB874gQP3JBmjAFsCu5a407lyQiRrK0YbgSzhsKtBkWneIj0Y1+BRaCdz4w5Jii/ 1Wkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=IMiBpOUqH2KZf6EdZ7Sxol4SRp5FWMKnvyeLyfGAjzo=; b=Wd+zjcPGy9omhpR8t/ZWc71s62swKj4h4oQc7rk/f/O9L1aJykwjPT0YQjkf6SKBHt f1nXUjx00pqQoY/95k7Z2vFaWwv1TJRYu9APjU1dwk9PW3Sr/63LYKpI2zhxhXSAKILY PAe73S2cogdv0JmnIR7f2Zl4ekxun4J4J50djsoEte4A1ud0PKGYPbZQI6jy1YBHdZ7u um4XKGqjpSBQ4GRoEzk+EaCC/ObGDd81EArrOw13Lm4YQA+udhiiFL4UpqbBD0p3WyIW 5gileHRgGYPlvqq0g2YjGjI0SRNXsB5FOIJV+JTlsY03vja5/oJ+ZBXcjb8jVk2hoKPK Ii+w== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r21si18219019edc.313.2020.08.19.06.45.19; Wed, 19 Aug 2020 06:45:44 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728529AbgHSNoS (ORCPT + 99 others); Wed, 19 Aug 2020 09:44:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728350AbgHSNn7 (ORCPT ); Wed, 19 Aug 2020 09:43:59 -0400 Received: from baptiste.telenet-ops.be (baptiste.telenet-ops.be [IPv6:2a02:1800:120:4::f00:13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C8CFC061342 for ; Wed, 19 Aug 2020 06:43:56 -0700 (PDT) Received: from ramsan ([84.195.186.194]) by baptiste.telenet-ops.be with bizsmtp id HRjl2300V4C55Sk01RjlZk; Wed, 19 Aug 2020 15:43:54 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan with esmtp (Exim 4.90_1) (envelope-from ) id 1k8ONV-0003E0-Gz; Wed, 19 Aug 2020 15:43:45 +0200 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1k8ONV-0007Fc-FB; Wed, 19 Aug 2020 15:43:45 +0200 From: Geert Uytterhoeven To: "David S . Miller" , Jakub Kicinski , Rob Herring , Sergei Shtylyov Cc: Andrew Lunn , Oleksij Rempel , Philippe Schenker , Florian Fainelli , Heiner Kallweit , Dan Murphy , Kazuya Mizuguchi , Wolfram Sang , Magnus Damm , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v3 4/7] ravb: Split delay handling in parsing and applying Date: Wed, 19 Aug 2020 15:43:41 +0200 Message-Id: <20200819134344.27813-5-geert+renesas@glider.be> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200819134344.27813-1-geert+renesas@glider.be> References: <20200819134344.27813-1-geert+renesas@glider.be> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, full delay handling is done in both the probe and resume paths. Split it in two parts, so the resume path doesn't have to redo the parsing part over and over again. Signed-off-by: Geert Uytterhoeven Reviewed-by: Sergei Shtylyov --- v3: - No changes, v2: - Add Reviewed-by, - Use 1 instead of true when assigning to a single-bit bitfield. --- drivers/net/ethernet/renesas/ravb.h | 4 +++- drivers/net/ethernet/renesas/ravb_main.c | 21 ++++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h index 9f88b5db4f89843a..e5ca12ce93c730a9 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -1036,7 +1036,9 @@ struct ravb_private { unsigned no_avb_link:1; unsigned avb_link_active_low:1; unsigned wol_enabled:1; - int num_tx_desc; /* TX descriptors per packet */ + unsigned rxcidm:1; /* RX Clock Internal Delay Mode */ + unsigned txcidm:1; /* TX Clock Internal Delay Mode */ + int num_tx_desc; /* TX descriptors per packet */ }; static inline u32 ravb_read(struct net_device *ndev, enum ravb_reg reg) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 99f7aae102ce12a1..59dadd971345e0d1 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1989,23 +1989,32 @@ static const struct soc_device_attribute ravb_delay_mode_quirk_match[] = { }; /* Set tx and rx clock internal delay modes */ -static void ravb_set_delay_mode(struct net_device *ndev) +static void ravb_parse_delay_mode(struct net_device *ndev) { struct ravb_private *priv = netdev_priv(ndev); - int set = 0; if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID || priv->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID) - set |= APSR_DM_RDM; + priv->rxcidm = 1; if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID || priv->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) { if (!WARN(soc_device_match(ravb_delay_mode_quirk_match), "phy-mode %s requires TX clock internal delay mode which is not supported by this hardware revision. Please update device tree", phy_modes(priv->phy_interface))) - set |= APSR_DM_TDM; + priv->txcidm = 1; } +} +static void ravb_set_delay_mode(struct net_device *ndev) +{ + struct ravb_private *priv = netdev_priv(ndev); + u32 set = 0; + + if (priv->rxcidm) + set |= APSR_DM_RDM; + if (priv->txcidm) + set |= APSR_DM_TDM; ravb_modify(ndev, APSR, APSR_DM, set); } @@ -2138,8 +2147,10 @@ static int ravb_probe(struct platform_device *pdev) /* Request GTI loading */ ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI); - if (priv->chip_id != RCAR_GEN2) + if (priv->chip_id != RCAR_GEN2) { + ravb_parse_delay_mode(ndev); ravb_set_delay_mode(ndev); + } /* Allocate descriptor base address table */ priv->desc_bat_size = sizeof(struct ravb_desc) * DBAT_ENTRY_NUM; -- 2.17.1