From patchwork Fri Feb 2 11:53:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 13542820 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 A50A6C4828E for ; Fri, 2 Feb 2024 11:54:07 +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=zIwDJmZe5ClfKzU9Vs6h+gkGte8x6kMI5L8LN6NXYFQ=; b=p22yi2gRRvv70B CvKt8ebvbEneRqMavFII2ZTm3HGHkuosM1n/QAjzVNInGSBWuV1MLcFPlFSomU0J1brzfdujORyVQ HNgV9h/4p1hnWdqRwU72aLeYFQAV4+s4O2F+/1PJfGJBDh9P9enuRILEMbWQaGGaOjblgNg2CY66v MyDom0DAKCCfNXoZToa1//eALefoS20WhjHscFH5qGORk8fkAI/R/3ekPoC79+DDzldfZ7qdo63W7 /Zt6y3wmOJPMInoCXEDso72+eQIvMxXA7Y3V1ZCQE7FcLVIluQYLsTkXs+M5XBuJSwa6AW5hM+3a1 2Tlr5yCjKB1CoQT/ix9w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rVs7H-0000000BNmf-2JNA; Fri, 02 Feb 2024 11:53:55 +0000 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rVs7D-0000000BNgx-0JI1 for linux-arm-kernel@lists.infradead.org; Fri, 02 Feb 2024 11:53:52 +0000 Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-55a8fd60af0so2803298a12.1 for ; Fri, 02 Feb 2024 03:53:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706874827; x=1707479627; 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=Np7u1hXKM5rI6U/dlseYWouqV6C4YX8LzVJmyooXeU4=; b=HHIYUWVMBw0/XXdRWZE26wie1DN63OKeBh3kk5N/QtkfGOwDeGYEudFK9r0YqDUiUn azSsgU0KoaZMBrKgrTMiGH7K6dt+rBZNpwrrizXssBvxq3DKeDpNX7UE2fNvlqRRc5yB zjOgTLFAlMVph8qFcwj+oKOmoiKEj82SY19pkWgeTWabkmUQQUfikgVpTzWOCoOcfvwz 7tEHK+KHtuJNS3rOrZTtmN64I0/Lo3w4zqfIUzGjua647RCkYCs0belELLrzQKwN9ZL2 EvBvdMP8nWdKdiaQ0UOv1tQzB/PYTcjhPRnM6DY9Npfke9s0qXYUwwZZcrvEf+nz3R4T K9zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706874827; x=1707479627; 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=Np7u1hXKM5rI6U/dlseYWouqV6C4YX8LzVJmyooXeU4=; b=w6sBuPPQQeOIR41CfNCFd8E+DX7NQhNkaAGPUuYE656xDcj5ATqxzHinZM16sCSVss PYvSKUaDlb8QPagguwbFuA8AwDRXpfEOplRDtJuv+S8/ukE0C6oWMHq6pYTQLHCVWHtT MjCwcT3Hm8jLy3slcofp8x8Htg8cjEGdUNIQxw6mby+Ej/DaAYjHOcMSCJWRIgydVY48 SJ1vZflh0mxvSvp7HN8GEeTD6pTv2czmsPSgYJ0LtfWi1gsgapjwth1Vea4m6mClhBdW 4AlkBJ3RVIhxpULf8dOGBokOpTNNkL00a3KsndPGnehg7FoGuW6A5dpy8xIN9uDWJUzf Ys0g== X-Gm-Message-State: AOJu0YwcQOBk06KLawMs4fiq+8/da8x/Fl6Kbsh2gBm1oSPV8B6TjgKp DCdT1wiKbrHq8rKzrOIjPE47a5zrC1t1cjfHoQBsylvj/Z0FoIgg X-Google-Smtp-Source: AGHT+IGXAB7OY/9527WOWDw2boh21DlXg5QEgxoOS1s+t4s7jiOUM+xbeT+3S9LvGOjj9dd43wl4og== X-Received: by 2002:a17:906:1d6:b0:a36:fe5f:12ea with SMTP id 22-20020a17090601d600b00a36fe5f12eamr1466409ejj.11.1706874826621; Fri, 02 Feb 2024 03:53:46 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUbHjgqn6OGJaSZiz/MJvW0xJGgV3YaTmVkJX/pkkcbMdNTxXe26Hrt4N2J5+Che02N4EpBAowTrg/h1CuORkWetUIul9fPIjxlHVVNDLtTdgUaO+37E/4qOr99TE7Vx/QgH/JFsIK3zyt8siy9jjxb8zxVzYH2W/MlMXDWPu4RMgsUiDGOIXxFxMTwHqrECx9EXzN3pV1FrI78j1BqqYGifuvecUkYbzXgIridLMUdN/upU0+UV/LRjTZG/0BPDzL6EWuVjmYo8426b6/rPkRV/Te2zWdMzyVNW+HO1Rwnwt5LfMy8o01tU2CueLzz2JRxV/sPoQ14rp1x47CfVACOLMXpR3nQQRAzRoC+15tg93Bj1ZH/VVDUV4bUo/s= Received: from localhost (p200300e41f147f00f22f74fffe1f3a53.dip0.t-ipconnect.de. [2003:e4:1f14:7f00:f22f:74ff:fe1f:3a53]) by smtp.gmail.com with ESMTPSA id jy13-20020a170907762d00b00a2b1a20e662sm815025ejc.34.2024.02.02.03.53.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 03:53:45 -0800 (PST) From: Thierry Reding Date: Fri, 02 Feb 2024 12:53:34 +0100 Subject: [PATCH net-next v2 2/3] net: stmmac: Allow drivers to provide a default AXI configuration MIME-Version: 1.0 Message-Id: <20240202-stmmac-axi-config-v2-2-64eab2bab17b@nvidia.com> References: <20240202-stmmac-axi-config-v2-0-64eab2bab17b@nvidia.com> In-Reply-To: <20240202-stmmac-axi-config-v2-0-64eab2bab17b@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 X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=3804; i=treding@nvidia.com; h=from:subject:message-id; bh=jjLbVkcITf7A0bBP/JxRfOK9o0PWmiljex/57VdQidQ=; b=owEBbQKS/ZANAwAIAd0jrNd/PrOhAcsmYgBlvNfFukeArHXtXK5OpnuugX7cDo941KJypi4WA a1km2kECCeJAjMEAAEIAB0WIQSI6sMIAUnM98CNyJ/dI6zXfz6zoQUCZbzXxQAKCRDdI6zXfz6z oW7HEADClKBGhWi0Zx82nAXZaCzfIVvZNrfpOpy9Xdz4gFT11/y3rXDPXfVfO73YI2/V/FFnPD9 hEW1+UOH8m3qBULTMjf6ngVg2Cb7Xy8Tgn3Xsq9KUjxr7itXUu7PYgeSR7Xry6+k8RXkTHdXK5R VoXBd1nxwfnd6WnUQSs2WQg/eOeZ5xGrownugVu8ZyULrhOuu7muz5w1ajr4YETqhohzxNNi9af UB+iNF+xPK2D8y3g8HZVA8rr1/q7f3dtjWziHxIpyorqIls/pnF7yoR4edqSF2ZcPhJ9R1S3UA+ auSS8mwh+G7jbclrVkxryIgm8QwxmhKSV2yq6pAwoC15zyf0bYmOpyIpngKf7QWNe/+zDz6o19k eJoqb8LPHb9hekU7JDhiB/hSu1MZiFJvWrqm7rNnrXM92KCUgPEOCfA9wLw2ao30QvQvYQP0g8h sreziZZcVIoEEq8b7xAJ/Qhw3C8xdOxAviulQ3MoFTizTzLJZ8S/agdAkyl6KeItQ7XYn4siWFR AoQqlMshTZJ6x0rARbMfitzM/hcsMHvjvJo5UVYzJkqo5+wS4Qc5f8y8lKNxdHDKnnL337oKMcg B3sPTHlcfbX8MUU9UscLGCkmak/0e+b5/+vcGxeXGoKTRuUSOx+IDMf33Tno05tQAYgdpoIgGuY ZmwCXzrtIFLcjNA== 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-20240202_035351_203514_A6902E93 X-CRM114-Status: GOOD ( 17.34 ) 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 --- Changes in v2: - fix bisectability --- 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 650ec8d2f5d7..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 (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); - 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); + of_node_put(np); + } return axi; } @@ -606,7 +621,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, of_property_read_u32(np, "snps,ps-speed", &plat->mac_port_sel_speed); - plat->axi = stmmac_axi_setup(pdev); + plat->axi = stmmac_axi_setup(pdev, res); rc = stmmac_mtl_setup(pdev, plat); if (rc) {