Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp287984lqd; Wed, 24 Apr 2024 02:13:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUT/cZwWg9ZErsXGxP/GS+hwMK0cjn2l/1GAoCiM8599FKinnDrpTe5G83wigWeKxNY+MK3aiqi2kwE6j+LdU4rJAZeXTOff2vFtuC9Lg== X-Google-Smtp-Source: AGHT+IF+kWPv39Ue31AzaGnrwb0ZOmQRp4GNGc7mx1Kl1C/mpUmQgzcQuvQBFjAsNUV/LP5BaHmN X-Received: by 2002:a92:c26f:0:b0:36a:3101:42b7 with SMTP id h15-20020a92c26f000000b0036a310142b7mr2351556ild.29.1713950030954; Wed, 24 Apr 2024 02:13:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713950030; cv=pass; d=google.com; s=arc-20160816; b=Z6b5Hf32MNlcIwv2H3565gLFXfvYWL7d0+gQJQlhtZiMuiAtrPpm3Cz3AapGK4m0q4 oZk7hkcPjN2qo09ZtNTti8POriYqKUhF50rgHC+Re7RfpEuz7Y13X3P6NsqSNUREfm03 DgLU5JrV6TaEWJJHj8AJX2X+zt2kyVzMuJ4opOfogqbuv77+1WBqo0jf2YfYF67cE8rY BvlBtitK3L71eYf9gOMvSlXWnDLa/pd4K4+tkdu8tSIbkLtZWvMILt+iM2+1anelaOih 2E9Ppg1QZN1aWF9/L43259/0VgdwvLXYsZcA+/zs+55vfhPWtnaumNa52cDTXv6dbom5 gkvw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=FkwsPyixcCSwcd0s2uMQ5Dt/9zWSPn5aWyXJWJ6shg4=; fh=iKbzTsM6Akj2X0N29umtxBSsa4Nmw1Zki5pbjnRyyYA=; b=bs1FsQ0oXHqSKITfREYBZ4M2A9DJVAwUTaSbEUHUCv2HZv9nY0rDjfX18bCpI+o0W3 b9KNWMI3Oykorc+AZ+zGh9AuXPCqUiAqG4tq6ncQvkgE2NQiIeC32cmr1lx3imAIqDnF SywLKGtNnABQpNhxRfuZjJxZsIxqj+HjJ9IWLcS/RUTK6U0UA8pr+d5E10rYBAPO2xC7 iFIwQ253rJuGN7XPai7JGa9U90ymBEOFx1vX1D4vZKiPQEXB9Dmg7t5JXk6Izy2727Hs fLB5zgw5opHfeuEwnIHQhgVgAS6SpkD0OVG+wDF4BbF/DYKGe+gud2KMuUR//H5G0JEg vmjA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=QNO78uHX; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-156600-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156600-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c26-20020a631c5a000000b005cfbe985481si10791964pgm.46.2024.04.24.02.13.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 02:13:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-156600-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=QNO78uHX; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-156600-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156600-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B435F28BC2B for ; Wed, 24 Apr 2024 09:07:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2FCBA159578; Wed, 24 Apr 2024 09:05:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="QNO78uHX" Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF99A158D82; Wed, 24 Apr 2024 09:05:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713949554; cv=none; b=VJBDmpReSBSoB61h7LH5d7CB97lRic1Zwo7f6PRJniIbYG+dS7ZUiF/nNSuX5ga/CXYFbcetEzOqmXJI/uqjXz+ruZfM7a3An82EQfYSwfIgO/BiitNTJsIcEdt+3hCnhn3W+hlsOvDqq63jcGpklxY3ySWiHo9y3JHoPG54vmU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713949554; c=relaxed/simple; bh=A8V2uf3zUCuYbbxdHtjghMTBdJie4K2Lv5z3MIRNpVo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dS7RdDb2GWXdsLg/7rdwrwdoUtqvCWxXBabcWadkGazAjQub5/YY8uHzeGlradwObI9npKYcc2aBeBDCKUZn46H4SXCMl7iaAshLX3VSITq5sbgALmMcZk5pzSxf2BF/nQ8g4STfc+Hjy6Zo8eL4/Ut6ZLWT9INyODAmXUBGgkM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=QNO78uHX; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id C194620013; Wed, 24 Apr 2024 09:05:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1713949550; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FkwsPyixcCSwcd0s2uMQ5Dt/9zWSPn5aWyXJWJ6shg4=; b=QNO78uHX3zk/6aB/m+RaqjpC8/Q+Ha+SRZ+o63Kp59pqhHoc+SVdfJ3aW8qv4vg2kxZ3Gw UoAD7Hle+zHCjzwgP77iE3c12Fh/ha8wa2c24fbBxyEwVhHVAuTtNemciy57JSY88WUsbq pabMuCbBJm3IsbDJwSxqk5rAmL/Y/jOJdAYc+QdqfbLo9YSbnFyf5RU3yqvDas1brgP4gI F2bvfSXzgodCLMfo11dAjuc1G+Q6yEpi4Pwbk/1Tl3dXKyTnSa1yebeqCz+NQSCjvW1UD9 igMu479Ms6aKzvCcXWJKGEVeltEH6QlW6ptzXobCMlM6PoB9QUYQpv3BjPx/oA== From: Romain Gantois Date: Wed, 24 Apr 2024 11:06:22 +0200 Subject: [PATCH net-next v4 4/5] net: stmmac: add support for RZ/N1 GMAC Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20240424-rzn1-gmac1-v4-4-852a5f2ce0c0@bootlin.com> References: <20240424-rzn1-gmac1-v4-0-852a5f2ce0c0@bootlin.com> In-Reply-To: <20240424-rzn1-gmac1-v4-0-852a5f2ce0c0@bootlin.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Geert Uytterhoeven , Magnus Damm , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Russell King , =?utf-8?q?Cl=C3=A9ment_L=C3=A9ger?= , Serge Semin Cc: Thomas Petazzoni , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Romain Gantois X-Mailer: b4 0.13.0 X-GND-Sasl: romain.gantois@bootlin.com From: Clément Léger Add support for the Renesas RZ/N1 GMAC. This support can make use of a custom RZ/N1 PCS which is fetched by parsing the pcs-handle device tree property. Signed-off-by: "Clément Léger" Co-developed-by: Romain Gantois Signed-off-by: Romain Gantois --- MAINTAINERS | 6 ++ drivers/net/ethernet/stmicro/stmmac/Kconfig | 12 ++++ drivers/net/ethernet/stmicro/stmmac/Makefile | 1 + drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c | 86 ++++++++++++++++++++++++ 4 files changed, 105 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index c0bfad3346235..c7ccbc9efeae3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -18850,6 +18850,12 @@ F: include/dt-bindings/net/pcs-rzn1-miic.h F: include/linux/pcs-rzn1-miic.h F: net/dsa/tag_rzn1_a5psw.c +RENESAS RZ/N1 DWMAC GLUE LAYER +M: Romain Gantois +S: Maintained +F: Documentation/devicetree/bindings/net/renesas,rzn1-gmac.yaml +F: drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c + RENESAS RZ/N1 RTC CONTROLLER DRIVER M: Miquel Raynal L: linux-rtc@vger.kernel.org diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig index 4ec61f1ee71a2..05cc07b8f48c0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig @@ -142,6 +142,18 @@ config DWMAC_ROCKCHIP This selects the Rockchip RK3288 SoC glue layer support for the stmmac device driver. +config DWMAC_RZN1 + tristate "Renesas RZ/N1 dwmac support" + default ARCH_RZN1 + depends on OF && (ARCH_RZN1 || COMPILE_TEST) + select PCS_RZN1_MIIC + help + Support for Ethernet controller on Renesas RZ/N1 SoC family. + + This selects the Renesas RZ/N1 SoC glue layer support for + the stmmac device driver. This support can make use of a custom MII + converter PCS device. + config DWMAC_SOCFPGA tristate "SOCFPGA dwmac support" default ARCH_INTEL_SOCFPGA diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile index 26cad4344701e..c2f0e91f6bf83 100644 --- a/drivers/net/ethernet/stmicro/stmmac/Makefile +++ b/drivers/net/ethernet/stmicro/stmmac/Makefile @@ -21,6 +21,7 @@ obj-$(CONFIG_DWMAC_MEDIATEK) += dwmac-mediatek.o obj-$(CONFIG_DWMAC_MESON) += dwmac-meson.o dwmac-meson8b.o obj-$(CONFIG_DWMAC_QCOM_ETHQOS) += dwmac-qcom-ethqos.o obj-$(CONFIG_DWMAC_ROCKCHIP) += dwmac-rk.o +obj-$(CONFIG_DWMAC_RZN1) += dwmac-rzn1.o obj-$(CONFIG_DWMAC_SOCFPGA) += dwmac-altr-socfpga.o obj-$(CONFIG_DWMAC_STARFIVE) += dwmac-starfive.o obj-$(CONFIG_DWMAC_STI) += dwmac-sti.o diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c new file mode 100644 index 0000000000000..848cf3c01f4ab --- /dev/null +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rzn1.c @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2024 Schneider-Electric + * + * Clément Léger + */ + +#include +#include +#include +#include + +#include "stmmac_platform.h" +#include "stmmac.h" + +static int rzn1_dwmac_pcs_init(struct stmmac_priv *priv) +{ + struct device_node *np = priv->device->of_node; + struct device_node *pcs_node; + struct phylink_pcs *pcs; + + pcs_node = of_parse_phandle(np, "pcs-handle", 0); + + if (pcs_node) { + pcs = miic_create(priv->device, pcs_node); + of_node_put(pcs_node); + if (IS_ERR(pcs)) + return PTR_ERR(pcs); + + priv->hw->phylink_pcs = pcs; + } + + return 0; +} + +static void rzn1_dwmac_pcs_exit(struct stmmac_priv *priv) +{ + if (priv->hw->phylink_pcs) + miic_destroy(priv->hw->phylink_pcs); +} + +static int rzn1_dwmac_probe(struct platform_device *pdev) +{ + struct plat_stmmacenet_data *plat_dat; + struct stmmac_resources stmmac_res; + struct device *dev = &pdev->dev; + int ret; + + ret = stmmac_get_platform_resources(pdev, &stmmac_res); + if (ret) + return ret; + + plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac); + if (IS_ERR(plat_dat)) + return PTR_ERR(plat_dat); + + plat_dat->bsp_priv = plat_dat; + plat_dat->pcs_init = rzn1_dwmac_pcs_init; + plat_dat->pcs_exit = rzn1_dwmac_pcs_exit; + + ret = stmmac_dvr_probe(dev, plat_dat, &stmmac_res); + if (ret) + return ret; + + return 0; +} + +static const struct of_device_id rzn1_dwmac_match[] = { + { .compatible = "renesas,rzn1-gmac" }, + { } +}; +MODULE_DEVICE_TABLE(of, rzn1_dwmac_match); + +static struct platform_driver rzn1_dwmac_driver = { + .probe = rzn1_dwmac_probe, + .remove_new = stmmac_pltfr_remove, + .driver = { + .name = "rzn1-dwmac", + .of_match_table = rzn1_dwmac_match, + }, +}; +module_platform_driver(rzn1_dwmac_driver); + +MODULE_AUTHOR("Clément Léger "); +MODULE_DESCRIPTION("Renesas RZN1 DWMAC specific glue layer"); +MODULE_LICENSE("GPL"); -- 2.44.0