Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp9573rdb; Fri, 5 Jan 2024 00:27:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IErhJmXOjqx1ji9RujhSVYEZPf+oQ6dPhg/vvmw18Jjyjx8yG5Vlva68wlTf0QeZI3IvHLX X-Received: by 2002:a05:600c:34c2:b0:40e:38eb:4eb6 with SMTP id d2-20020a05600c34c200b0040e38eb4eb6mr208578wmq.24.1704443261135; Fri, 05 Jan 2024 00:27:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704443261; cv=none; d=google.com; s=arc-20160816; b=Il+dchDWxcSHtXNMzTLccVUG6dCY7SnshvCXUIWY0DAkx5k5+HyKJfHomDz9d3OKxb ouOnqw18pdbjXGor7/lkPTx8TVXgGI5aCXtyX/RpWcP9YK1GA1TXYtzvTHbfFqcn2tmf wu8F2XUy2JpY/hdAnfDtSjmPMvgmbFd2HcDlzWE+lGWO2AoSI2jUgrb3g3GAuNTcowyb vmBwR2s7uplTkxbSPsporvEhzazw2CaqEJufeLQaoFvbKmhUIrmEMAwrsgacV8UD7SgG ddgXx0KnUnvbOzIa9V3bq1S7EMYKa+V5XCRb9JsUttrKR5ExAagNvkas+ArndjOw02Z9 Lz5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Za7hqwvcFVwC9gLR2Ag52yQIz1AeWmVDkMHSuVYL5EU=; fh=qryrdWWtksp4Ojh0keXejXriHeHARah4mOGZkuZ1jnk=; b=09a/24lwy7F5TwnERSYkmR70uJBpQ7/YfdzNw4YQKaxyei/0hgkb79bwDBI5cKmbgg LYfi7N5Mot8EvPFW3fWnLFwva/8OnpRXbekk/00WvzZNjnr6zkk20RR73XWitXXYYHZc SvfH2W5BBlFCrM+WTqE4VURFb+buJDoYqmWo7c8kct5s3q21L/xy5HfAF1bKxDcFpVhr uRzLpJZvniVDJ8VzprXpDwqpLTUamjJnBkcZJhSRW6hXHv5SUnzEVevnO3yX4K4Vc4lw MIYf7phgzfWt01FoiuRgBHQm2IxWNKeb9GvpD6X88w9hedhIs0MBhFI2ZcnmCwre6W7r +rPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=WNSCGCEb; spf=pass (google.com: domain of linux-kernel+bounces-17589-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17589-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id m14-20020a1709061ece00b00a2930695e10si343571ejj.549.2024.01.05.00.27.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:27:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17589-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@tuxon.dev header.s=google header.b=WNSCGCEb; spf=pass (google.com: domain of linux-kernel+bounces-17589-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17589-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B3EBC1F2204E for ; Fri, 5 Jan 2024 08:27:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 13D962D629; Fri, 5 Jan 2024 08:24:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="WNSCGCEb" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF56E2D615 for ; Fri, 5 Jan 2024 08:24:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a2814fa68eeso106324666b.1 for ; Fri, 05 Jan 2024 00:24:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1704443088; x=1705047888; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Za7hqwvcFVwC9gLR2Ag52yQIz1AeWmVDkMHSuVYL5EU=; b=WNSCGCEbM+Z1oNOMFtgYCDyiEoUoCsdGjru4UOs5C5ExNZLYkf6TOllf7f7zeV+9Yt mfw/tVJ+9roDtj1WO4gt8gAsLnSzInpw9I09fbiytttomggKwMEyRASFfNy6AwAIsC/x +pELEDDjH1PkmgebBvNwyIathPADEgDTYvB/UCDor1T51ibr+l8qRCtJvhaKQwT7sgHS dWnSYJxw44a7OxC4kLEnoIea+VTEjb2QJ2DQ9qgay1vz9EaiXWwUVeg10JJmFBuXEHqy q7MB/6A5zH+KmzosRB9INgZcK0wvkRNtdfyETXlNa6Oig2DhrPCBSBsE7JVGjYbinwQr iK6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704443088; x=1705047888; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Za7hqwvcFVwC9gLR2Ag52yQIz1AeWmVDkMHSuVYL5EU=; b=ms8uYK7X/GPcBZQvQjDInsIwC7ZKmY/83B2lWwOv8Gg1Aquko2qXlpqtYiNfiqUv5d RXPMJux69eRmePkPWgvvULYbDoTmLAFPrmOsd23msOEtyVjaM/aYwmTglTlxrmXdQ+Oh nDDrpKH5U0p0bIsDenMKywnn73VMnfkp21lT1zT+1HvQ6qhMW46pkH+M5gVhmhNtFl7v 1K6smlFdSdM2YLSoHuekN1UTfJe6elmp3Obq5jAv09o6eSo9lxbcZDa1jcr24uQq1S4E PM7mmDC+wftkcCOIwfyMTsXvjuFSQxFSlHAjLhs1jvFBCcx/Mpj8QgOqPOMR36tUCDcV 8s2Q== X-Gm-Message-State: AOJu0YyOaayJeqQ9a5t2OcYH3OcmkReK0WZguK9wrt1jj9KpuoGBsvXc mmMfxzM6hi22N7TMTamB55QthyDM4kYbNQ== X-Received: by 2002:a17:906:4e89:b0:a28:60d4:a292 with SMTP id v9-20020a1709064e8900b00a2860d4a292mr989984eju.16.1704443088224; Fri, 05 Jan 2024 00:24:48 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.5]) by smtp.gmail.com with ESMTPSA id j15-20020a1709064b4f00b00a28e759a447sm596198ejv.213.2024.01.05.00.24.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 00:24:47 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: s.shtylyov@omp.ru, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, p.zabel@pengutronix.de, yoshihiro.shimoda.uh@renesas.com, wsa+renesas@sang-engineering.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, claudiu.beznea@tuxon.dev, geert+renesas@glider.be, Claudiu Beznea Subject: [PATCH net-next v3 10/19] net: ravb: Move delay mode set in the driver's ndo_open API Date: Fri, 5 Jan 2024 10:23:30 +0200 Message-Id: <20240105082339.1468817-11-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com> References: <20240105082339.1468817-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Claudiu Beznea Delay parsing and setting were done in the driver's probe API. As some IP variants switch to reset mode (and thus registers content is lost) when setting clocks (due to module standby functionality) to be able to implement runtime PM keep the delay parsing in the driver's probe function and move the delay applying function to the driver's ndo_open API. Along with it, both delay specific functions were kept together. Signed-off-by: Claudiu Beznea --- Changes in v3: - fixed typos in patch description Changes in v2: - none; this patch is new drivers/net/ethernet/renesas/ravb_main.c | 107 ++++++++++++----------- 1 file changed, 56 insertions(+), 51 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index f386a3b7effb..946abd7606ca 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -1761,6 +1761,59 @@ static int ravb_compute_gti(struct net_device *ndev) return 0; } +/* Set tx and rx clock internal delay modes */ +static void ravb_parse_delay_mode(struct device_node *np, struct net_device *ndev) +{ + struct ravb_private *priv = netdev_priv(ndev); + bool explicit_delay = false; + u32 delay; + + if (!priv->info->internal_delay) + return; + + if (!of_property_read_u32(np, "rx-internal-delay-ps", &delay)) { + /* Valid values are 0 and 1800, according to DT bindings */ + priv->rxcidm = !!delay; + explicit_delay = true; + } + if (!of_property_read_u32(np, "tx-internal-delay-ps", &delay)) { + /* Valid values are 0 and 2000, according to DT bindings */ + priv->txcidm = !!delay; + explicit_delay = true; + } + + if (explicit_delay) + return; + + /* Fall back to legacy rgmii-*id behavior */ + if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID || + priv->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID) { + priv->rxcidm = 1; + priv->rgmii_override = 1; + } + + if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID || + priv->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) { + priv->txcidm = 1; + priv->rgmii_override = 1; + } +} + +static void ravb_set_delay_mode(struct net_device *ndev) +{ + struct ravb_private *priv = netdev_priv(ndev); + u32 set = 0; + + if (!priv->info->internal_delay) + return; + + if (priv->rxcidm) + set |= APSR_RDM; + if (priv->txcidm) + set |= APSR_TDM; + ravb_modify(ndev, APSR, APSR_RDM | APSR_TDM, set); +} + /* Network device open function for Ethernet AVB */ static int ravb_open(struct net_device *ndev) { @@ -1772,6 +1825,8 @@ static int ravb_open(struct net_device *ndev) if (info->nc_queues) napi_enable(&priv->napi[RAVB_NC]); + ravb_set_delay_mode(ndev); + /* Device init */ error = ravb_dmac_init(ndev); if (error) @@ -2492,41 +2547,6 @@ static int ravb_set_config_mode(struct net_device *ndev) return error; } -/* Set tx and rx clock internal delay modes */ -static void ravb_parse_delay_mode(struct device_node *np, struct net_device *ndev) -{ - struct ravb_private *priv = netdev_priv(ndev); - bool explicit_delay = false; - u32 delay; - - if (!of_property_read_u32(np, "rx-internal-delay-ps", &delay)) { - /* Valid values are 0 and 1800, according to DT bindings */ - priv->rxcidm = !!delay; - explicit_delay = true; - } - if (!of_property_read_u32(np, "tx-internal-delay-ps", &delay)) { - /* Valid values are 0 and 2000, according to DT bindings */ - priv->txcidm = !!delay; - explicit_delay = true; - } - - if (explicit_delay) - return; - - /* Fall back to legacy rgmii-*id behavior */ - if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID || - priv->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID) { - priv->rxcidm = 1; - priv->rgmii_override = 1; - } - - if (priv->phy_interface == PHY_INTERFACE_MODE_RGMII_ID || - priv->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) { - priv->txcidm = 1; - priv->rgmii_override = 1; - } -} - static int ravb_setup_irq(struct ravb_private *priv, const char *irq_name, const char *ch, int *irq, irq_handler_t handler) { @@ -2611,18 +2631,6 @@ static int ravb_setup_irqs(struct ravb_private *priv) return ravb_setup_irq(priv, "ch19", "ch19:tx_nc", &irq, ravb_nc_interrupt); } -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_RDM; - if (priv->txcidm) - set |= APSR_TDM; - ravb_modify(ndev, APSR, APSR_RDM | APSR_TDM, set); -} - static int ravb_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -2746,10 +2754,7 @@ static int ravb_probe(struct platform_device *pdev) if (error) goto out_rpm_put; - if (info->internal_delay) { - ravb_parse_delay_mode(np, ndev); - ravb_set_delay_mode(ndev); - } + ravb_parse_delay_mode(np, ndev); /* Allocate descriptor base address table */ priv->desc_bat_size = sizeof(struct ravb_desc) * DBAT_ENTRY_NUM; -- 2.39.2