From patchwork Thu Feb 1 18:49:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 13541665 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B36F0C4828D for ; Thu, 1 Feb 2024 18:49:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=I23WLP0R+c/0OPPguOVraSw5WIw3PP+gWomyGynaEhk=; b=N/IDkytm/6RT4e B3VzMeINmFZ9//eUylKOw1E1dMK/LFS/0i3ZY1Yl0AqnE9Ow83BKcqQkA3UqCgSPcoSqXtMe/SaD6 LXjv8GpzPE3wi86NAuGwFzxggqAOmZoV2DTbsAcXW8fTlu0b1pxp5cy9/2xAUQ1fIxEYVDKGwiB6c OnjQph8IhS7hsqdrEbUX91GvOrATowbGxlLcPwXwT9M+bT4r1mJrP33WN2NWAj+yn5kklJutdIwXW mcZe9/+P7cFRfLKnSVD93dNZv5hWasDqApRzQC91rTN4yAiL2w87onF5ZtNwLvfgd66nPgwsdmPrW uUYBHnZod3xHFxx8rIQQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rVc7n-000000094lx-2CUz; Thu, 01 Feb 2024 18:49:23 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rVc7k-000000094k2-3up1 for linux-arm-kernel@lists.infradead.org; Thu, 01 Feb 2024 18:49:22 +0000 Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a26fa294e56so182121566b.0 for ; Thu, 01 Feb 2024 10:49:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706813357; x=1707418157; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=AqDWY8wmk/fnuJTUL0gf+MfJA0JNC72CzhLE0DV6ueU=; b=etUzlS8KBWh/tBadU9rNu9hGzSrs4cwBf1LhzJlJztc2xsTs/8fcIM4c6beiUEfwRK b9z0LyB+GuQ/A/qiuWBsQBoLJuwI81kujMcov80Yf9MQqmHWs4FH7XKLH+44AjUEKQS7 YMbUEI0f2EV4DjKVdzlDGnsbK8rFXci8chtVNhxU6p1+dNl84/3Qg2Rbtc/WU+/1FQ9U LzRf/edPg9+ynh6ieJxeuRx9HqjmOEskQqYSfMjSejVF22s1gvzETD587mAKDxohJJkg ouC+mOUTunQxBOI6Vhwe7JMqZEU0ZOiGpvPrGnlKOyj36kiuqlLmkrFqR50D/enZxb2j Tw7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706813357; x=1707418157; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AqDWY8wmk/fnuJTUL0gf+MfJA0JNC72CzhLE0DV6ueU=; b=MbXHTo2HIkXWAVlF8H4DhJI4tXe9stF6GtXKWaMMqGFMiOAR0zezIrKIlH2tOp8Hjz gkCnzSYjqj9fZdJ1S4J3MQYpe7VIpvwHp9sn55hCs+IWj61xxk/D+Q7CwEhWVLal6TQi bcYFetfa4P5+/UAcScBpYjh+2Vpwpu3nbCD95QXRftfsylmkmxN3GDpKuFlndqJpaj4i b73OF7VQMfMHEQAzEZcHGY2hWiSkhULlj1mjJ+rR8AipB1YUxxjMaO28U8sp1BGjFtln tTwGyP1pDfQMfjmK6iqqO1UVFyFp7RNfngG0Q9nYN+/ckFwmgrYWGAQ5/JFP0WKXbXTh /8WQ== X-Gm-Message-State: AOJu0Yy8ZahjPg45YJ4KSRRZTncLoRXNsVblXTx7EatpH6gTIQmp+M65 9S0/yTLBKNE/dMgPNcFnjdxfLT2/DHD7Yc5Mgef6j8kVVaRQObtI X-Google-Smtp-Source: AGHT+IGlCSjy95AXH4mYJjWbk+DnMRTrJeOc6/n32vxw6jslXvR6wtcmhksIMqv5Ku85ONcTVpRJIA== X-Received: by 2002:a17:906:4f0a:b0:a35:43d8:a297 with SMTP id t10-20020a1709064f0a00b00a3543d8a297mr4200860eju.0.1706813357648; Thu, 01 Feb 2024 10:49:17 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXg0D4fOjs5HYilBzZpjxO0yJ3sjv2MuAzioOusiL3HyFcWt+sLiMfzeT8BjpFfqnacv7Yby1XXcVHHzOR/xpT+QEskLx0mC9QT+ACNiFR8yS9HHWB6kjXFIf1xkgamzvKGPTfpUs0nFT/kIie32a/YjaeOKyyLcF//DAoNDQ0g1dQBVsH9hcu+yJzPruQUZxhC7Xav6Ephswrty10jq6fjYgREh11U2HnZfz8BZnXDBs9DMt1ZR8BYLGXRKH3kgoM4waLf50/Xdb+S1apLl5R86GarCVapWXen6MCZAmT+n2cB1wva3iCIJnoIa8mFWBLUl+i6mD6AT355vz+L2dGnOZ3hbScsotx818w9xNBhAjfoI7M7GfmX0a9Zb4GxyM9etfoacWRMkVLXALUZMLlDWg== Received: from localhost (p200300e41f147f00f22f74fffe1f3a53.dip0.t-ipconnect.de. [2003:e4:1f14:7f00:f22f:74ff:fe1f:3a53]) by smtp.gmail.com with ESMTPSA id va11-20020a17090711cb00b00a36894739bbsm64066ejb.88.2024.02.01.10.49.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 10:49:16 -0800 (PST) From: Thierry Reding Date: Thu, 01 Feb 2024 19:49:06 +0100 Subject: [PATCH net-next 2/3] net: stmmac: Allow drivers to provide a default AXI configuration MIME-Version: 1.0 Message-Id: <20240201-stmmac-axi-config-v1-2-822e97b2d26e@nvidia.com> References: <20240201-stmmac-axi-config-v1-0-822e97b2d26e@nvidia.com> In-Reply-To: <20240201-stmmac-axi-config-v1-0-822e97b2d26e@nvidia.com> To: Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, Thierry Reding X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=3475; i=treding@nvidia.com; h=from:subject:message-id; bh=w0xggOKS1PGq0kFbzfjy2DAd3e5snbUxtXdb8/CdR8M=; b=owEBbQKS/ZANAwAIAd0jrNd/PrOhAcsmYgBlu+eo4do/ibRD22vEaMX4s5Ja/xO0RyvXT1Cnc RiSCmMpHyKJAjMEAAEIAB0WIQSI6sMIAUnM98CNyJ/dI6zXfz6zoQUCZbvnqAAKCRDdI6zXfz6z ocs5EACceS9fQZ3tL3oUiof4CHxmR+8LkFehtBa+PFf8289m6QSjXlUa+U6BmQYDYO82XRAQSWp sWLqVLFl+P06C9lS55li+177xc31OTwMkmTFPz6Flz/JkLkTx1IbZ7ECWXI3JObwAzAW7KAcDK2 FFEdopjouSg8ZFMuREYFowuyHiQq8clPeHRitwdByxW7rmtfb6Y7nJ5PZ+T6+0fI40v9GV6GA+M Ru97tkDMOVKGYkBf1PP1NR8YhZGv0x/rusw8SxU0uTzEvIbLsBahNtM0MrJtHIJ/NM0oC3e4/se Z+WWE7wBuxGoMSx/rhvwS/XtHmpneR8RxdZQEZZuqTXsb2jN/wLcW1XYwCdsALuMMqnrRf7l/yj GVS/0N2rbCt9oQqoXxWcCnbSS5qnBuo3cc0cQKBnQRe8hsfX2YATDtGCnY753qymvwtM3XqKndx 4Q9j5Q2ZgAeIc75t1Mozsaj5oFbjXLnNOZZKkiIjnwbnwgb215Gi7Y0bqKCoSH51v7H5LaX2Z+2 fFdp5oBoKyfxJmy3ue0dkohWH3alIPb0JzF7/iawpgLCeQcv4r6HycHubcU3QPR5HedcNDoP5rv 7FTWnqy4tAoriipDpD3G9VfWF747TP5EvjvkZkCeU9qmNDwMKWEeNvKZVdegLqn+BKPL5gMsKu8 j5QK3IU/pg3yO1g== X-Developer-Key: i=treding@nvidia.com; a=openpgp; fpr=88EAC3080149CCF7C08DC89FDD23ACD77F3EB3A1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240201_104921_015785_81FA8B4F X-CRM114-Status: GOOD ( 16.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Thierry Reding In many cases the AXI configuration can be derived from the compatible string, so there's no need to add the configuration to DT. Allow drivers to pass in the default AXI configuration so they can be properly set up without extra data in DT. Signed-off-by: Thierry Reding --- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 + .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 47 ++++++++++++++-------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index f155e4841c62..07706e7b3cfc 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -35,6 +35,8 @@ struct stmmac_resources { int sfty_ue_irq; int rx_irq[MTL_MAX_RX_QUEUES]; int tx_irq[MTL_MAX_TX_QUEUES]; + + const struct stmmac_axi *axi; }; enum stmmac_txbuf_type { diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index 8ec2ac28a775..0d5f2cebd6fc 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -91,34 +91,49 @@ static int dwmac1000_validate_ucast_entries(struct device *dev, * if required, from device-tree the AXI internal register can be tuned * by using platform parameters. */ -static struct stmmac_axi *stmmac_axi_setup(struct platform_device *pdev) +static struct stmmac_axi *stmmac_axi_setup(struct platform_device *pdev, + struct stmmac_resources *res) { struct device_node *np; struct stmmac_axi *axi; np = of_parse_phandle(pdev->dev.of_node, "snps,axi-config", 0); - if (!np) + if (!np && !res->axi) return NULL; axi = devm_kzalloc(&pdev->dev, sizeof(*axi), GFP_KERNEL); if (!axi) { - of_node_put(np); + if (np) + of_node_put(np); + return ERR_PTR(-ENOMEM); } - axi->axi_lpi_en = of_property_read_bool(np, "snps,lpi_en"); - axi->axi_xit_frm = of_property_read_bool(np, "snps,xit_frm"); - axi->axi_kbbe = of_property_read_bool(np, "snps,kbbe"); - axi->axi_fb = of_property_read_bool(np, "snps,fb"); - axi->axi_mb = of_property_read_bool(np, "snps,mb"); - axi->axi_rb = of_property_read_bool(np, "snps,rb"); - - if (of_property_read_u32(np, "snps,wr_osr_lmt", &axi->axi_wr_osr_lmt)) - axi->axi_wr_osr_lmt = 1; - if (of_property_read_u32(np, "snps,rd_osr_lmt", &axi->axi_rd_osr_lmt)) - axi->axi_rd_osr_lmt = 1; - of_property_read_u32_array(np, "snps,blen", axi->axi_blen, AXI_BLEN); - of_node_put(np); + if (res->axi) + *axi = *res->axi; + + if (np) { + axi->axi_lpi_en = of_property_read_bool(np, "snps,lpi_en"); + axi->axi_xit_frm = of_property_read_bool(np, "snps,xit_frm"); + axi->axi_kbbe = of_property_read_bool(np, "snps,kbbe"); + axi->axi_fb = of_property_read_bool(np, "snps,fb"); + axi->axi_mb = of_property_read_bool(np, "snps,mb"); + axi->axi_rb = of_property_read_bool(np, "snps,rb"); + + if (of_property_read_u32(np, "snps,wr_osr_lmt", &axi->axi_wr_osr_lmt)) { + if (!res->axi) + axi->axi_wr_osr_lmt = 1; + } + + if (of_property_read_u32(np, "snps,rd_osr_lmt", &axi->axi_rd_osr_lmt)) { + if (!res->axi) + axi->axi_rd_osr_lmt = 1; + } + + of_property_read_u32_array(np, "snps,blen", axi->axi_blen, AXI_BLEN); + + of_node_put(np); + } return axi; }