From patchwork Mon Feb 19 16:46:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 13562907 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 7E0B5C5475B for ; Mon, 19 Feb 2024 16:46:30 +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=3Y0VKdTogO+/LaZD5BQLzbPIRvIf3TYMU1s0PVY1UJU=; b=tPBAMwCX1ElTrb vqg4lgQOJnvfgxeLK2RYVwaF+88yREWA4mxuAmOJfww0/7GP+PxtgRmnN80C4uFElKbfq/hVkeEd8 rKLbRLpipcOhyH23nxEX0sRK+PxGn9H3K1+tKGiTHC5cobhgg1y37nQBWO8OezGFdJHGQ5Oju76KP cg629zqcoJE9eTqr18WgKkFeget9YOFMy2KtgECYODpStMwn/SB6FutGGGEaSpwobRy6zLbSUkih1 jcjQEUHDAWNmsH69TvbSshajb045S7AC0NI+s0wDYoNFsggGDDvtD2JEatBlPY/xy+Ze9pBDCZYBo 1icLhMTgWRHy1qLerYPg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rc6mb-0000000BPHM-3kn8; Mon, 19 Feb 2024 16:46:21 +0000 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rc6mW-0000000BPEJ-0sAy for linux-arm-kernel@lists.infradead.org; Mon, 19 Feb 2024 16:46:17 +0000 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a3ee69976c9so7739666b.0 for ; Mon, 19 Feb 2024 08:46:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708361172; x=1708965972; 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=hvQx/ZWr1fmONRjsP3PMsf6y/RwS/zsUlWEFNTxP3t4=; b=fWMVhW8siYflq/mEfPsxm/x9b1+iX1L5Kvq/U82i4IIOncQ4AZeuTK4iA7ZYa+0/yl Jot8zLtxggUjk4sy8NJau1szGABTEwaTGfgnLrki8x3wX1BeilwRyWLYhaZl3+qx66aF qfcs40eU4K+OAuLQN/fERMGMqtf8RL+klT49Brh6ircRPhu5E+CZKb3cPRrvWX/wskE+ ccOfzH8SqyUwpYNvKtDPScfgn5Snuq5zRMSQdwRvor2NvR7bIyZ/b10ohaQ0sISbLhvQ gQ9rYbkRj1DFvCE79JM7ztpDmjEot8TMEGe6Ky+er/Yb1H+jAEfEp2djsvR3c6vCIS0K zOdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708361172; x=1708965972; 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=hvQx/ZWr1fmONRjsP3PMsf6y/RwS/zsUlWEFNTxP3t4=; b=VteQUHj/3o43iiyufIaK2SGhzCZVurS4dYUuG8m56uJgjmQqosx8pMxU2Syax94g5M rIrAjcl7lE71so+aaBVdrp8lsILcu+zT6I0H9vAeKQTNoAeXgznP+X6vAZM58wR4XaGh 1302rIAy5aaqgWDBFO2kTTfTNu1s2F1Gd1IafVMgZywIdjPlxUxBNhhEPJKGHswGCEda kAUdSxKc2gVtuHKEzl0GtT88uzK80co3kzdWuMtkSTyRFohmZc/HLZ6r8YRCzDjyyWae O28nD95Yh6cHpZxv3o1xzFybROPMTG7BlVcXeMZbs9dBVtFwXwkVnx4IvOZoZ71GQiIh qc4A== X-Forwarded-Encrypted: i=1; AJvYcCWIDGuCPLVeUi6s26IjBpVHp7rOgyWgsnqF5Q2FIpiSyRzDtXNKgBhrt42BagADD0lvmFqaTNcFWqbRuyB9/66QjF3sHIcDyW+VbH6ZKoVWuDXqpD4= X-Gm-Message-State: AOJu0Yy6hnI9WU/DUZf//+4f8xTXZVMaGgEcskE1acYXhs2s/aURpuvG D2kPK4PF3j5yF3CXJ/+4pERfLv9cTBjpXUxnRvsuWJ4d6J0+Aa/d X-Google-Smtp-Source: AGHT+IGMrTXFePHwGK0f6Gfcanrxom7RdEshhcX0lXB5XyndiBsQwJpHCJ0fUqxOBqv59BYd5yg1Cw== X-Received: by 2002:a17:906:8c4:b0:a3d:b6c2:fc58 with SMTP id o4-20020a17090608c400b00a3db6c2fc58mr7225638eje.2.1708361172613; Mon, 19 Feb 2024 08:46:12 -0800 (PST) Received: from localhost (p200300e41f2d4600f22f74fffe1f3a53.dip0.t-ipconnect.de. [2003:e4:1f2d:4600:f22f:74ff:fe1f:3a53]) by smtp.gmail.com with ESMTPSA id qo3-20020a170907874300b00a3e4efbfdacsm2186128ejc.225.2024.02.19.08.46.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 08:46:11 -0800 (PST) From: Thierry Reding Date: Mon, 19 Feb 2024 17:46:05 +0100 Subject: [PATCH net-next v3 2/3] net: stmmac: Allow drivers to provide a default AXI configuration MIME-Version: 1.0 Message-Id: <20240219-stmmac-axi-config-v3-2-fca7f046e6ee@nvidia.com> References: <20240219-stmmac-axi-config-v3-0-fca7f046e6ee@nvidia.com> In-Reply-To: <20240219-stmmac-axi-config-v3-0-fca7f046e6ee@nvidia.com> To: Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Serge Semit , 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.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4527; i=treding@nvidia.com; h=from:subject:message-id; bh=LdiFXY9cbeHxsNR8EpusW5e+abDEIKHDPw46DFX7qbE=; b=owEBbQKS/ZANAwAIAd0jrNd/PrOhAcsmYgBl04XQc+VvRHCQa0rFZHSQK8YQYoyBj0+ZspjNm wiF3N9H2gWJAjMEAAEIAB0WIQSI6sMIAUnM98CNyJ/dI6zXfz6zoQUCZdOF0AAKCRDdI6zXfz6z oefgD/oDiQVayaGBy3gD68Lgg02XvmyihQ7dQxJr9YR0oiGoOk2gp3rjgUYIzlzCKv72+CHcRSn Z2tjumF8g1yKw1DNsAjbldFLiUldaSd1yJxvjB5Mnj+XPAcZU2T82LC7k9e9dP1R0MZhxL63858 Pkl5ItL3P0HnUJlDTCQYio9QKe0FZa3KoN+YXGp2bOnJzAsmOM/0NHXps/j0Z36V5oKtcc51Qo0 wLQJivZTpduN7INxBHyVK0MZaGkQOJ3PY++gT78AwujJDbeSd3lXd6esYCesHqVUx6hqMD3t0tG iIeYMqzS6sEbYeJVSnO5vawV0yIjitoReFbU/FDLpEQl8rBWNMEI5bRCu7iZjiVULTjvGq6iha2 e+ExUKqPuN2ShbmnMKPzPHHzfIkG3bqYNuCYuF5+6t+nL7WagNr96PpXvX980dYJGp2W8CiKned NbqyN8fITO8FuydmB5Gt+C5igUVCj9ZUN9pd9R6eHLBIEP7sZgkyomnaGK1IqnDpAjWOPGLvCPx ptpGh0Z/ZrBlxQsqup77PUdIjQbcvtV7EXLDiY+XSIIJvguDFoskjse27vsMvoc0toj0QtfnCE2 IMYg87AbH+uXWUqSQjALEgnuzf3o4+SdWnvNIlczWvIGvmTs6V/4mw0nrABpYNNQpMcxXd0j5Ik 6FVsTp7wlqeiJ6Q== 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-20240219_084616_328851_65E6F3B6 X-CRM114-Status: GOOD ( 21.31 ) 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 v3: - add comments to help explain override logic - add missing kerneldoc for new parameter Changes in v2: - fix bisectability --- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 + .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 59 +++++++++++++++------- 2 files changed, 43 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index dddcaa9220cc..573c5d99b4d6 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -36,6 +36,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 4e2eb54306f9..583f78ae9bb0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -87,38 +87,61 @@ static int dwmac1000_validate_ucast_entries(struct device *dev, /** * stmmac_axi_setup - parse DT parameters for programming the AXI register * @pdev: platform device + * @res: driver-specific parameters * Description: - * if required, from device-tree the AXI internal register can be tuned - * by using platform parameters. + * Use driver-specific defaults for the AXI internal registers if available, + * or parse them from device tree, if present. Driver-specific defaults can + * be overridden by the values from device tree. */ -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; + /* + * Exit early if the driver hasn't provided any defaults and the + * device tree doesn't specify values for the AXI configuration. + */ 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"); + /* copy defaults provided by the driver */ + if (res->axi) + *axi = *res->axi; + + /* override defaults with data from DT */ + 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,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 (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; } @@ -606,7 +629,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) {