Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6945801rdb; Fri, 15 Dec 2023 12:42:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IFuNFqvMtpgjJw1MgMCWFzPyXzV7CZCTRIj/hbG8p8Mq/WffDtidVH77KX4yUsQIYFwOjgz X-Received: by 2002:a05:6a00:2fd4:b0:6d2:9679:8432 with SMTP id fn20-20020a056a002fd400b006d296798432mr267591pfb.13.1702672922900; Fri, 15 Dec 2023 12:42:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702672922; cv=none; d=google.com; s=arc-20160816; b=rxjV34aiBWEXeZAccR4AXThD6yC1KHmgQOpXZ0N5gcvYkDvvUojkefxjIONUSf/5Tm c9ZtO34TBvz3rfRNjhswSWbsmcNFqm77VXGLRgUAd5TXbqG00TwYeLqsaPvrWASTaLxM ojkONZkVb6pXz6FH0mhTuusjFhaOJJpmXAW7eorttHX2f6/LcPJW1OwDwUtbAMG9dcLS 17KRT1N6GqrN/XhRrcHVzq4B74fyX8K76eqf3eKSI8Wjvp/xfax6M0GB3Oj6CdHyBJPS Wdv0GHWruBU5a1soG5lbTHkN2LvJWnmyyBgR6DZznMPnjrF47Zwu8JHK1aw1fVWrf2wm qkhA== 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=0+gM9HYCy4+j0zgpRS43J/rf+C8/FjuFuZRbF3TGlws=; fh=syaDh/WjooBXvAaul+2O0Q827rHRcsPrAm5I86d1V5c=; b=CZRq8PQcN9rE5zFhWuivGByKHpjbkMHWt4RkFWcEnH1BUH3OkcBZSqs9+UnSN/0oWE /bwLwEN7kiSOrkg6xfcaccVInm1ae9R3/nS/pT2gL9eWsmPqY2kIk1zjiHuoDQWjONV3 Ms2IKK/XUa2FuuontMxq4GVXgmcX8Vkaxlfv7UjjJLASuaWgkavVTJ+nRO8Zv9sQWypX yvwQW4Y6MPz4pMiBb88jajigGNQCtqPh0eBW5Z3qAav2u/95zHypIqYIeJqhUDLWyFiN DEloLYpXLYckiF33GWTg59VoAVupcawPjz8q/QKvQXx8lY7ZbMyP3o6Fyb/ts+eGd3E2 RkzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=WoJnTnA4; spf=pass (google.com: domain of linux-kernel+bounces-1634-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1634-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id o10-20020a63e34a000000b005b9293fcf78si13555567pgj.10.2023.12.15.12.42.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 12:42:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1634-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=WoJnTnA4; spf=pass (google.com: domain of linux-kernel+bounces-1634-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1634-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 89F16283613 for ; Fri, 15 Dec 2023 20:42:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 87F4449F71; Fri, 15 Dec 2023 20:40:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="WoJnTnA4" 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 3571747766; Fri, 15 Dec 2023 20:40:56 +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=1702672855; bh=nB8fK2mag7xxaIPXY2D2kiffvAUioRug+1aDDBZv2DY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WoJnTnA4efoBp3Kz0/zwihnCSluO3psS4NHYy8U8kVDP8AU1L91/Hgj6lYi8J60cU qd9j0IGy/JfU7h33EbkMZUbjHDKRncdDRWVhHGvYj6z20XJYY04c8IqM1rTapt/B+4 eC+0NciTlvL3oT1ScyLfV2qGvoA2cDGLGr1krAMRPTIV24m1wfc1ErfPlmkUsR4TYx Zkd4jleZCtFqeY3DnHhRx+rdKLZHQ2QuamzRpWc2rO/qHK5ouFU3Rvmp/T9UH3Ozyd KWPYfe6LOv3XK/Vy0QPTJpFYpsSOqZe7eMmwyq3VVY9TJA/zyJ43vGICqeLH7eY0PR 7hMp/XUWBGAqA== 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 398883781FEE; Fri, 15 Dec 2023 20:40:55 +0000 (UTC) From: Cristian Ciocaltea To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Emil Renner Berthing , Samin Guo , Paul Walmsley , Palmer Dabbelt , Albert Ou , Hal Feng , Michael Turquette , Stephen Boyd , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Richard Cochran , Giuseppe Cavallaro Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-clk@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, kernel@collabora.com Subject: [PATCH v3 3/9] net: stmmac: dwmac-starfive: Add support for JH7100 SoC Date: Fri, 15 Dec 2023 22:40:42 +0200 Message-ID: <20231215204050.2296404-4-cristian.ciocaltea@collabora.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231215204050.2296404-1-cristian.ciocaltea@collabora.com> References: <20231215204050.2296404-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 --- 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