Received: by 2002:a05:7412:d008:b0:f9:6acb:47ec with SMTP id bd8csp233213rdb; Tue, 19 Dec 2023 15:11:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IHfqQOyIQXv3o+ju2/Gf5SQXyKNYpBcSVeW1j48wr+Mya9A4DAa2Zhpb3+1mfJkpoVZPIa/ X-Received: by 2002:ac2:4251:0:b0:50e:2033:4875 with SMTP id m17-20020ac24251000000b0050e20334875mr2944985lfl.4.1703027473185; Tue, 19 Dec 2023 15:11:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703027473; cv=none; d=google.com; s=arc-20160816; b=zNQPnIRfgDDS5rbULRreWBdNfLnAHu8oZbIuy7Uyoveiq0RFgJOZyGZsYuJ15s0iQs 4EC+fGlUZqUwEq7Cwg2Mh+YtYWOyzBQESmKjTkJ65EfqpAeaTmIZsxz9js8/Dwv+2BaA YbCHWGgFgpcAbFTra6FE1fB/1a4jB7Eyexy1XStAp/I0cfemGK+2AZ/Jio5lFuSAJgGr YKI45yhhO/Ttks1i8wgqDYTQo3t/U6cj4G2CbXc4i8Fjh4qE+bpRrO+GWQ+644kFOR4U 367wv7d1BudAAscsskWV4AGFLvKe06jlHNpSsyoBnTz/wuSKoG3jIz7rj/tiLduxXLJq PigA== 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=tP94JFGnNGVzkfua2HUoQF7pVy6Z+v52dOnLwF8BgV8=; fh=QljYTX+ZLsm9tybO/qTAkhhMpPF0wtiJegELIMhaqOQ=; b=Thl1mqqh2qZuDtulZT1fqJvoIPC2nbLGp5LZTE4VY48MqZWnXwdzpfg0L7rMQg9XX3 4uHarN+Zq8FK4sA9kVuz+pQs9llNoy70sFnVmMolknHw8pTtZB7kzPK0MX+169Gn5f0Y ESfM8baXQ7cNrFto+c3d5uVlfQOGswXaHPHbcOuwNi3gbk1sjVklhDOo3KPls+y/JVwz PXJEuq2sJggDdSuw/LmpQ1/kFVSXNoyCNWQm8u70LVTZaEk9W5q1yvp5lnyaK2xuqefa t/b+dOweMtpf5uu4niby+3+R1c+ZxR1e7nkOBmXZ9wmrgYhwpa/cNPn/Xcj38Rbhx4Ib hWNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=LIJXWKgU; spf=pass (google.com: domain of linux-kernel+bounces-6081-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6081-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id s16-20020a170906285000b00a1db8805188si10980487ejc.229.2023.12.19.15.11.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 15:11:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6081-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=LIJXWKgU; spf=pass (google.com: domain of linux-kernel+bounces-6081-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6081-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.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 am.mirrors.kernel.org (Postfix) with ESMTPS id E795B1F25AB7 for ; Tue, 19 Dec 2023 23:11:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6048A3F8E1; Tue, 19 Dec 2023 23:10:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="LIJXWKgU" X-Original-To: linux-kernel@vger.kernel.org Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (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 14EED3EA7E; Tue, 19 Dec 2023 23:10:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1703027444; bh=WQe4wDwRNT0S65UeCvFunjCWa8R+Rf3G+Co3wYKG0EU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LIJXWKgUayG6RS6B71Z+IwOwFcbGiCyQ0HCJA9fSi0YlCy5VvDHlXRGRgm3y1WOEi bidRCS6PZ7x3XH+RGZvjY7qtE3RczeoemTEX0w49bCPeuSyazX68YJWK/lv2xZMXrK EFy6MmdXtDl5rJeDR6jsXgARTLBEZyyaFVugiY2VURFuYxtensv+/WULYK2eGNjuFx /aIhbsIMazsHTsct4MFNpg61WCQDKvecC11u2eGIwX5ss4AnqTbKwcHWGtGY6TZOtC twTaW/WGGpGdxu5A7Pedw7a3vexU98Lv2VBbZT3dCVVlJMLi1i6xSCJLlwEJ6yPOyq komt87BGO/TtA== Received: from localhost (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madrid.collaboradmins.com (Postfix) with ESMTPSA id DC4F03781495; Tue, 19 Dec 2023 23:10:43 +0000 (UTC) From: Cristian Ciocaltea To: Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Emil Renner Berthing , Samin Guo Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com, Jacob Keller , Andrew Lunn Subject: [PATCH 1/1] net: stmmac: dwmac-starfive: Add support for JH7100 SoC Date: Wed, 20 Dec 2023 01:10:39 +0200 Message-ID: <20231219231040.2459358-2-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231219231040.2459358-1-cristian.ciocaltea@collabora.com> References: <20231219231040.2459358-1-cristian.ciocaltea@collabora.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 Add a missing quirk to enable support for the StarFive JH7100 SoC. Additionally, for greater flexibility in operation, allow using the rgmii-rxid and rgmii-txid phy modes. Co-developed-by: Emil Renner Berthing Signed-off-by: Emil Renner Berthing Signed-off-by: Cristian Ciocaltea Reviewed-by: Jacob Keller Reviewed-by: Andrew Lunn --- drivers/net/ethernet/stmicro/stmmac/Kconfig | 6 ++-- .../ethernet/stmicro/stmmac/dwmac-starfive.c | 32 ++++++++++++++++--- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig index 85dcda51df05..4ec61f1ee71a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig @@ -165,9 +165,9 @@ config DWMAC_STARFIVE help Support for ethernet controllers on StarFive RISC-V SoCs - This selects the StarFive platform specific glue layer support for - the stmmac device driver. This driver is used for StarFive JH7110 - ethernet controller. + This selects the StarFive platform specific glue layer support + for the stmmac device driver. This driver is used for the + StarFive JH7100 and JH7110 ethernet controllers. config DWMAC_STI tristate "STi GMAC support" diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c index 5d630affb4d1..4e1076faee0c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c @@ -15,13 +15,20 @@ #include "stmmac_platform.h" -#define STARFIVE_DWMAC_PHY_INFT_RGMII 0x1 -#define STARFIVE_DWMAC_PHY_INFT_RMII 0x4 -#define STARFIVE_DWMAC_PHY_INFT_FIELD 0x7U +#define STARFIVE_DWMAC_PHY_INFT_RGMII 0x1 +#define STARFIVE_DWMAC_PHY_INFT_RMII 0x4 +#define STARFIVE_DWMAC_PHY_INFT_FIELD 0x7U + +#define JH7100_SYSMAIN_REGISTER49_DLYCHAIN 0xc8 + +struct starfive_dwmac_data { + unsigned int gtxclk_dlychain; +}; struct starfive_dwmac { struct device *dev; struct clk *clk_tx; + const struct starfive_dwmac_data *data; }; static void starfive_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) @@ -67,6 +74,8 @@ static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat) case PHY_INTERFACE_MODE_RGMII: case PHY_INTERFACE_MODE_RGMII_ID: + case PHY_INTERFACE_MODE_RGMII_RXID: + case PHY_INTERFACE_MODE_RGMII_TXID: mode = STARFIVE_DWMAC_PHY_INFT_RGMII; break; @@ -89,6 +98,14 @@ static int starfive_dwmac_set_mode(struct plat_stmmacenet_data *plat_dat) if (err) return dev_err_probe(dwmac->dev, err, "error setting phy mode\n"); + if (dwmac->data) { + err = regmap_write(regmap, JH7100_SYSMAIN_REGISTER49_DLYCHAIN, + dwmac->data->gtxclk_dlychain); + if (err) + return dev_err_probe(dwmac->dev, err, + "error selecting gtxclk delay chain\n"); + } + return 0; } @@ -114,6 +131,8 @@ static int starfive_dwmac_probe(struct platform_device *pdev) if (!dwmac) return -ENOMEM; + dwmac->data = device_get_match_data(&pdev->dev); + dwmac->clk_tx = devm_clk_get_enabled(&pdev->dev, "tx"); if (IS_ERR(dwmac->clk_tx)) return dev_err_probe(&pdev->dev, PTR_ERR(dwmac->clk_tx), @@ -144,8 +163,13 @@ static int starfive_dwmac_probe(struct platform_device *pdev) return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); } +static const struct starfive_dwmac_data jh7100_data = { + .gtxclk_dlychain = 4, +}; + static const struct of_device_id starfive_dwmac_match[] = { - { .compatible = "starfive,jh7110-dwmac" }, + { .compatible = "starfive,jh7100-dwmac", .data = &jh7100_data }, + { .compatible = "starfive,jh7110-dwmac" }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, starfive_dwmac_match); -- 2.43.0