Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp445317pxk; Thu, 17 Sep 2020 07:16:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcUbLXn+5Q9G7bjJkQ403jbrSlpjqGE7EbZs2hSUnq19gT7jQ/ymLMSmN6GEc1j78yjHCK X-Received: by 2002:a17:906:7116:: with SMTP id x22mr31938643ejj.426.1600352218684; Thu, 17 Sep 2020 07:16:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600352218; cv=none; d=google.com; s=arc-20160816; b=Dk08IBOQFo9t4d8wVhFreH+PtC3U1X8izCsG1LqP9aNiXFn+QPvXqi72cdn4vP2vGe 7M3gAWPNqsVZUQVcgsd4EkkfiAR4om9EPzpwxQiLpu6A719Y0Q4rIXxHA69ay+yZhBdo RBF5R8lATeopHQG1eA2kLTEmcyyZuWyabtV1kXaWQOlsIgruNaff9lwp1VchMI+MX9aq Oe3wffIFQHdwF7ejqaBOO97pUKCInLUE/Feb2L5aZvso0YNlC0I7zlCw7tpjgA68Mncq kVwinEbSeYti6qi8hMdEysrDL0TCarlFK9pVnRJRPo9ibaqzGSlT+g3mfT8OEv3jS9q8 fNmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=QeK5dT9CJqcGvD94JgSzVKZsaQUX/WqcN/SrrdqOfR4=; b=UWz4uAfckJi6ns+LIZq83X6tkP9k2bnddoLWnOVz58ZNicqmeteO7yxW8rq7ox5sbJ c5JbUMh5XKjF8h9DSYCoh7WKT6j0G7tIctUMqYuiFArIjtoyZxviVu90qs5q0k6ykMCn yU8Wy2vYKtZ8wCOg7aoEp9f8LomExeHidnFhCZyVJifxsDRYuetjEygLtJmYsnk14t8f XgiR9zCsPvdDRcWkqqmKqnCPezccEo3JSZp9NRBwIzPSx2aWLk3ul7C4SP2suPxA7M26 yjuTiaTmwgnjiey6ImV5KH34MLUqVZV5G4I41Vn0lRuzuyXWu/e6ITBpKHlskMZkUUsv dj1A== 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 m27si24235ejb.476.2020.09.17.07.16.30; Thu, 17 Sep 2020 07:16:58 -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 S1727420AbgIQOPC (ORCPT + 99 others); Thu, 17 Sep 2020 10:15:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727215AbgIQN6D (ORCPT ); Thu, 17 Sep 2020 09:58:03 -0400 Received: from michel.telenet-ops.be (michel.telenet-ops.be [IPv6:2a02:1800:110:4::f00:18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75E40C0698C2 for ; Thu, 17 Sep 2020 06:57:26 -0700 (PDT) Received: from ramsan ([84.195.186.194]) by michel.telenet-ops.be with bizsmtp id V1xD230064C55Sk061xDYG; Thu, 17 Sep 2020 15:57:22 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan with esmtp (Exim 4.90_1) (envelope-from ) id 1kIuPR-0001Kk-2P; Thu, 17 Sep 2020 15:57:13 +0200 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1kIuPR-0003Hf-0t; Thu, 17 Sep 2020 15:57:13 +0200 From: Geert Uytterhoeven To: "David S . Miller" , Jakub Kicinski Cc: Rob Herring , Sergei Shtylyov , Florian Fainelli , Andrew Lunn , Oleksij Rempel , Philippe Schenker , 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 net-next v4 4/5] ravb: Split delay handling in parsing and applying Date: Thu, 17 Sep 2020 15:57:06 +0200 Message-Id: <20200917135707.12563-5-geert+renesas@glider.be> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200917135707.12563-1-geert+renesas@glider.be> References: <20200917135707.12563-1-geert+renesas@glider.be> 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 Reviewed-by: Florian Fainelli --- v4: - Add Reviewed-by, 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