From patchwork Thu Dec 1 09:02:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yanhong wang X-Patchwork-Id: 13061087 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 A9F40C43217 for ; Thu, 1 Dec 2022 09:03:21 +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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YX3VUdtAT0qug+b4m8Iu9BnnlIsUWE645LstUxDpqxE=; b=IgFzOxC580EyFO GbUGqtCp64l/khKlyc+mXphRXoxjxh7ny8Wi6vGiPfEMw42OIUVZyKaarRFOt6mK8IK/DJVHKeE7h y963XBKQ2L8Ula0WFUwvCzn0xxUMyoAs/aqmqZrlWblD9qvDW8bpYVH9my7UFRh9/gg69Ha7WswSG kPz3GJLTB/P7dbWDKGzcctoe4vDlOvpMdARXXJs3eC6favi45nlIVK+SuDJ+n4F/EuQhOSf3ILMyc Dd9yVkjYwp+Za3GSAG1GbRi6sYLwX0H3J4H6jsipu8p8pDDILoTPixdTHCQ55bDylMciUoH19hA83 aulul1yTe44NbKVaIsXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0fTN-0068dK-Bc; Thu, 01 Dec 2022 09:03:13 +0000 Received: from ex01.ufhost.com ([61.152.239.75]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0fT1-00684I-5Q for linux-riscv@lists.infradead.org; Thu, 01 Dec 2022 09:02:53 +0000 Received: from EXMBX166.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX166", Issuer "EXMBX166" (not verified)) by ex01.ufhost.com (Postfix) with ESMTP id 3E72424E25C; Thu, 1 Dec 2022 17:02:04 +0800 (CST) Received: from EXMBX173.cuchost.com (172.16.6.93) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 1 Dec 2022 17:02:04 +0800 Received: from wyh-VirtualBox.starfivetech.com (171.223.208.138) by EXMBX173.cuchost.com (172.16.6.93) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 1 Dec 2022 17:02:02 +0800 From: Yanhong Wang To: , , , CC: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Emil Renner Berthing , Richard Cochran , Andrew Lunn , Heiner Kallweit , Peter Geis , Yanhong Wang Subject: [PATCH v1 1/7] dt-bindings: net: snps,dwmac: Add compatible string for dwmac-5.20 version. Date: Thu, 1 Dec 2022 17:02:36 +0800 Message-ID: <20221201090242.2381-2-yanhong.wang@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221201090242.2381-1-yanhong.wang@starfivetech.com> References: <20221201090242.2381-1-yanhong.wang@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [171.223.208.138] X-ClientProxiedBy: EXCAS065.cuchost.com (172.16.6.25) To EXMBX173.cuchost.com (172.16.6.93) X-YovoleRuleAgent: yovoleflag X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221201_010251_364631_6ED1E455 X-CRM114-Status: UNSURE ( 8.56 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add dwmac-5.20 version to snps.dwmac.yaml Signed-off-by: Emil Renner Berthing Signed-off-by: Yanhong Wang --- Documentation/devicetree/bindings/net/snps,dwmac.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml index 13b984076af5..d8779d3de3d6 100644 --- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml +++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml @@ -30,6 +30,7 @@ select: - snps,dwmac-4.10a - snps,dwmac-4.20a - snps,dwmac-5.10a + - snps,dwmac-5.20 - snps,dwxgmac - snps,dwxgmac-2.10 From patchwork Thu Dec 1 09:02:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yanhong wang X-Patchwork-Id: 13061084 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 B2FF1C4321E for ; Thu, 1 Dec 2022 09:03:00 +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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QdS4pycwGGghSjXJJNsaqUIRvMwAJRMMKBzf99Qe8lw=; b=PdbTjNu0mR54NI aSGFdaaKwEMglvPxwX4AtcTkQ5X45L1NUSkOyMJV6DwhlrCqnlLq4uzqKh1aHvMEsw+zkS3nP0V+o QWSWPois55F4LbKJIMz2nGI8o/OIHuTZwJ9lU9xbSO97Kzl9jkwxVBPuaXJ9cpfXCiVXgqcgq1flJ 8YzySctQGneEmOU2Exf5a3pgPsGFfmWZnStyrGBEKekjfzkBWUERNDwG/cjdJ9py9m8RD/892S68m Tdu9oN7ZHGkng73GecpS/+Ppl41e2wrvOvFXjDzD4D91CM1gm+QZb62OJewKWyFwGPnn/8taoUmR5 DyRr4q5wFEgCAvrrYxIA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0fT2-0068P8-Mo; Thu, 01 Dec 2022 09:02:52 +0000 Received: from ex01.ufhost.com ([61.152.239.75]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0fSy-00684K-0R for linux-riscv@lists.infradead.org; Thu, 01 Dec 2022 09:02:49 +0000 Received: from EXMBX165.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX165", Issuer "EXMBX165" (not verified)) by ex01.ufhost.com (Postfix) with ESMTP id 2947D24E1F0; Thu, 1 Dec 2022 17:02:05 +0800 (CST) Received: from EXMBX173.cuchost.com (172.16.6.93) by EXMBX165.cuchost.com (172.16.6.75) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 1 Dec 2022 17:02:05 +0800 Received: from wyh-VirtualBox.starfivetech.com (171.223.208.138) by EXMBX173.cuchost.com (172.16.6.93) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 1 Dec 2022 17:02:03 +0800 From: Yanhong Wang To: , , , CC: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Emil Renner Berthing , Richard Cochran , Andrew Lunn , Heiner Kallweit , Peter Geis , Yanhong Wang Subject: [PATCH v1 2/7] net: stmmac: platform: Add snps,dwmac-5.20 IP compatible string Date: Thu, 1 Dec 2022 17:02:37 +0800 Message-ID: <20221201090242.2381-3-yanhong.wang@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221201090242.2381-1-yanhong.wang@starfivetech.com> References: <20221201090242.2381-1-yanhong.wang@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [171.223.208.138] X-ClientProxiedBy: EXCAS065.cuchost.com (172.16.6.25) To EXMBX173.cuchost.com (172.16.6.93) X-YovoleRuleAgent: yovoleflag X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221201_010248_227334_4648F1F5 X-CRM114-Status: GOOD ( 10.60 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add "snps,dwmac-5.20" compatible string for 5.20 version that can avoid to define some platform data in the glue layer. Signed-off-by: Emil Renner Berthing Signed-off-by: Yanhong Wang --- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index 50f6b4a14be4..cc3b701af802 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -519,7 +519,8 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) if (of_device_is_compatible(np, "snps,dwmac-4.00") || of_device_is_compatible(np, "snps,dwmac-4.10a") || of_device_is_compatible(np, "snps,dwmac-4.20a") || - of_device_is_compatible(np, "snps,dwmac-5.10a")) { + of_device_is_compatible(np, "snps,dwmac-5.10a") || + of_device_is_compatible(np, "snps,dwmac-5.20")) { plat->has_gmac4 = 1; plat->has_gmac = 0; plat->pmt = 1; From patchwork Thu Dec 1 09:02:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yanhong wang X-Patchwork-Id: 13061085 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 96095C43217 for ; Thu, 1 Dec 2022 09:03:12 +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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=OgXVetrd0smKvzEJgX36eI+M53smBaFxWg6c+OBAkUY=; b=GUd2lKB+tHe5H0 LWDKkEvUf39Ufc0jL1czsSDZ0IpQrNLIIg/LCLQgpfJAin9OGyoXfz7reP8JZkIau7kT9U7Ac3Nop EI2/BAG+XGHslMruGb594w8PhgB/gNSA3FSp6hW/HTBAP9+KLUQo8cymxCGLpNzJJygVNqCC241CL NhCB7TWiCSdYq9iqgmIIMQQyvuaOVqdRH6EhgsdoO0mKn/6b+35nxbm+hERqiHm0l2xc38IIi4wwt DmRtqAejYwbyNs4wic3hqEMH2AvEZIm8uVkS6oSb3npUOxtJdbHp4YtsNyNlQ5qY0Ssxl0z2tGRQc 69h456ep45U2hZdqOmuw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0fTD-0068WZ-EA; Thu, 01 Dec 2022 09:03:03 +0000 Received: from fd01.gateway.ufhost.com ([61.152.239.71]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0fSy-00687h-Nx for linux-riscv@lists.infradead.org; Thu, 01 Dec 2022 09:02:51 +0000 Received: from EXMBX166.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX166", Issuer "EXMBX166" (not verified)) by fd01.gateway.ufhost.com (Postfix) with ESMTP id 1F87A24E0AC; Thu, 1 Dec 2022 17:02:06 +0800 (CST) Received: from EXMBX173.cuchost.com (172.16.6.93) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 1 Dec 2022 17:02:06 +0800 Received: from wyh-VirtualBox.starfivetech.com (171.223.208.138) by EXMBX173.cuchost.com (172.16.6.93) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 1 Dec 2022 17:02:04 +0800 From: Yanhong Wang To: , , , CC: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Emil Renner Berthing , Richard Cochran , Andrew Lunn , Heiner Kallweit , Peter Geis , Yanhong Wang Subject: [PATCH v1 3/7] dt-bindings: net: Add bindings for StarFive dwmac Date: Thu, 1 Dec 2022 17:02:38 +0800 Message-ID: <20221201090242.2381-4-yanhong.wang@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221201090242.2381-1-yanhong.wang@starfivetech.com> References: <20221201090242.2381-1-yanhong.wang@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [171.223.208.138] X-ClientProxiedBy: EXCAS065.cuchost.com (172.16.6.25) To EXMBX173.cuchost.com (172.16.6.93) X-YovoleRuleAgent: yovoleflag X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221201_010249_082639_F1EA7C15 X-CRM114-Status: GOOD ( 14.06 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add bindings for the StarFive dwmac module on the StarFive RISC-V SoCs. Signed-off-by: Yanhong Wang --- .../devicetree/bindings/net/snps,dwmac.yaml | 1 + .../bindings/net/starfive,dwmac-plat.yaml | 106 ++++++++++++++++++ MAINTAINERS | 5 + 3 files changed, 112 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/starfive,dwmac-plat.yaml diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml index d8779d3de3d6..13c5928d7170 100644 --- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml +++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml @@ -33,6 +33,7 @@ select: - snps,dwmac-5.20 - snps,dwxgmac - snps,dwxgmac-2.10 + - starfive,dwmac # Deprecated - st,spear600-gmac diff --git a/Documentation/devicetree/bindings/net/starfive,dwmac-plat.yaml b/Documentation/devicetree/bindings/net/starfive,dwmac-plat.yaml new file mode 100644 index 000000000000..561cf2a713ab --- /dev/null +++ b/Documentation/devicetree/bindings/net/starfive,dwmac-plat.yaml @@ -0,0 +1,106 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) 2022 StarFive Technology Co., Ltd. +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/net/dwmac-starfive.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: StarFive DWMAC glue layer + +maintainers: + - Yanhong Wang + +select: + properties: + compatible: + contains: + enum: + - starfive,dwmac + required: + - compatible + +allOf: + - $ref: "snps,dwmac.yaml#" + +properties: + compatible: + oneOf: + - items: + - enum: + - starfive,dwmac + - const: snps,dwmac-5.20 + + clocks: + items: + - description: GMAC main clock + - description: GMAC AHB clock + - description: PTP clock + - description: TX clock + - description: GTXC clock + - description: GTX clock + + clock-names: + contains: + enum: + - stmmaceth + - pclk + - ptp_ref + - tx + - gtxc + - gtx + +required: + - compatible + - clocks + - clock-names + - resets + - reset-names + +unevaluatedProperties: false + +examples: + - | + #include + #include + + stmmac_axi_setup: stmmac-axi-config { + snps,wr_osr_lmt = <4>; + snps,rd_osr_lmt = <4>; + snps,blen = <256 128 64 32 0 0 0>; + }; + + gmac0: ethernet@16030000 { + compatible = "starfive,dwmac", "snps,dwmac-5.20"; + reg = <0x16030000 0x10000>; + clocks = <&aoncrg_clk JH7110_AONCLK_GMAC0_AXI>, + <&aoncrg_clk JH7110_AONCLK_GMAC0_AHB>, + <&syscrg_clk JH7110_SYSCLK_GMAC0_PTP>, + <&aoncrg_clk JH7110_AONCLK_GMAC0_TX>, + <&syscrg_clk JH7110_SYSCLK_GMAC0_GTXC>, + <&syscrg_clk JH7110_SYSCLK_GMAC0_GTXCLK>; + clock-names = "stmmaceth", + "pclk", + "ptp_ref", + "tx", + "gtxc", + "gtx"; + resets = <&aoncrg JH7110_AONRST_GMAC0_AXI>, + <&aoncrg JH7110_AONRST_GMAC0_AHB>; + reset-names = "stmmaceth", "ahb"; + interrupts = <7>, <6>, <5>; + interrupt-names = "macirq", "eth_wake_irq", "eth_lpi"; + phy-mode = "rgmii-id"; + snps,multicast-filter-bins = <64>; + snps,perfect-filter-entries = <8>; + rx-fifo-depth = <2048>; + tx-fifo-depth = <2048>; + snps,fixed-burst; + snps,no-pbl-x8; + snps,force_thresh_dma_mode; + snps,axi-config = <&stmmac_axi_setup>; + snps,tso; + snps,en-tx-lpi-clockgating; + snps,lpi_en; + snps,txpbl = <16>; + snps,rxpbl = <16>; + }; diff --git a/MAINTAINERS b/MAINTAINERS index a70c1d0f303e..7eaaec8d3b96 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19606,6 +19606,11 @@ F: Documentation/devicetree/bindings/clock/starfive* F: drivers/clk/starfive/ F: include/dt-bindings/clock/starfive* +STARFIVE DWMAC GLUE LAYER +M: Yanhong Wang +S: Maintained +F: Documentation/devicetree/bindings/net/starfive,dwmac-plat.yaml + STARFIVE PINCTRL DRIVER M: Emil Renner Berthing M: Jianlong Huang From patchwork Thu Dec 1 09:02:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yanhong wang X-Patchwork-Id: 13061091 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 8F483C4321E for ; Thu, 1 Dec 2022 09:03:47 +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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=n8LTYiOLJvNsgt8gdMUUjMnEM8QArx1SJKbmCPMdeBw=; b=hU4Xfk+MGKI0e0 ngqkBVWLC8DhPWyfMkQm0+szqArg7dlMS1sxI5Dk3kYwLKHVKnoAE8RPGjllmBA7iVd9xLQWFMjV5 pdY2zeiqHLvduMVR70M6ByEuCctXZw1/vbdWbAfbb28VYApXNyWySpdo01rS8IV8VLKPSvpsiyNJB c/s3ikrYQSc/fVKpWQI+I/yajwvj1KTykQpobNeOIE3kraXegjwye1U6J+AclphChKCPM7lMRHjAp 9ASk/f0kMfdtHp2Yay+m2df1lQS6jOElZ4TirLolUaz6us/MgGr4GLVIkw+GeqiYX14vp+daNrH29 FJNR9NEN1jJugPUex+xA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0fTm-0068vM-UV; Thu, 01 Dec 2022 09:03:38 +0000 Received: from fd01.gateway.ufhost.com ([61.152.239.71]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0fTA-00687g-3O for linux-riscv@lists.infradead.org; Thu, 01 Dec 2022 09:03:03 +0000 Received: from EXMBX165.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX165", Issuer "EXMBX165" (not verified)) by fd01.gateway.ufhost.com (Postfix) with ESMTP id 0EF8B24E0B4; Thu, 1 Dec 2022 17:02:07 +0800 (CST) Received: from EXMBX173.cuchost.com (172.16.6.93) by EXMBX165.cuchost.com (172.16.6.75) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 1 Dec 2022 17:02:06 +0800 Received: from wyh-VirtualBox.starfivetech.com (171.223.208.138) by EXMBX173.cuchost.com (172.16.6.93) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 1 Dec 2022 17:02:05 +0800 From: Yanhong Wang To: , , , CC: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Emil Renner Berthing , Richard Cochran , Andrew Lunn , Heiner Kallweit , Peter Geis , Yanhong Wang Subject: [PATCH v1 4/7] net: phy: motorcomm: Add YT8531 phy support Date: Thu, 1 Dec 2022 17:02:39 +0800 Message-ID: <20221201090242.2381-5-yanhong.wang@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221201090242.2381-1-yanhong.wang@starfivetech.com> References: <20221201090242.2381-1-yanhong.wang@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [171.223.208.138] X-ClientProxiedBy: EXCAS065.cuchost.com (172.16.6.25) To EXMBX173.cuchost.com (172.16.6.93) X-YovoleRuleAgent: yovoleflag X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221201_010300_475241_C3A393DA X-CRM114-Status: GOOD ( 21.61 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This adds basic support for the Motorcomm YT8531 Gigabit Ethernet PHY. Signed-off-by: Yanhong Wang --- drivers/net/phy/Kconfig | 3 +- drivers/net/phy/motorcomm.c | 185 ++++++++++++++++++++++++++++++++++++ 2 files changed, 187 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index c57a0262fb64..86399254d9ff 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -258,9 +258,10 @@ config MICROSEMI_PHY config MOTORCOMM_PHY tristate "Motorcomm PHYs" + default SOC_STARFIVE help Enables support for Motorcomm network PHYs. - Currently supports the YT8511 gigabit PHY. + Currently supports the YT8511 and YT8531 gigabit PHYs. config NATIONAL_PHY tristate "National Semiconductor PHYs" diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c index 7e6ac2c5e27e..7f3e22879399 100644 --- a/drivers/net/phy/motorcomm.c +++ b/drivers/net/phy/motorcomm.c @@ -3,13 +3,17 @@ * Driver for Motorcomm PHYs * * Author: Peter Geis + * */ +#include #include #include +#include #include #define PHY_ID_YT8511 0x0000010a +#define PHY_ID_YT8531 0x4f51e91b #define YT8511_PAGE_SELECT 0x1e #define YT8511_PAGE 0x1f @@ -17,6 +21,10 @@ #define YT8511_EXT_DELAY_DRIVE 0x0d #define YT8511_EXT_SLEEP_CTRL 0x27 +#define YTPHY_EXT_SMI_SDS_PHY 0xa000 +#define YTPHY_EXT_CHIP_CONFIG 0xa001 +#define YTPHY_EXT_RGMII_CONFIG1 0xa003 + /* 2b00 25m from pll * 2b01 25m from xtl *default* * 2b10 62.m from pll @@ -38,6 +46,34 @@ #define YT8511_DELAY_FE_TX_EN (0xf << 12) #define YT8511_DELAY_FE_TX_DIS (0x2 << 12) +struct ytphy_reg_field { + char *name; + u32 mask; + u8 dflt; /* Default value */ +}; + +struct ytphy_priv_t { + u32 tx_inverted_1000; + u32 tx_inverted_100; + u32 tx_inverted_10; +}; + +static const struct ytphy_reg_field ytphy_rxtxd_grp[] = { + { "rx_delay_sel", GENMASK(13, 10), 0x0 }, + { "tx_delay_sel_fe", GENMASK(7, 4), 0xf }, + { "tx_delay_sel", GENMASK(3, 0), 0x1 } +}; + +static const struct ytphy_reg_field ytphy_txinver_grp[] = { + { "tx_inverted_1000", BIT(14), 0x0 }, + { "tx_inverted_100", BIT(14), 0x0 }, + { "tx_inverted_10", BIT(14), 0x0 } +}; + +static const struct ytphy_reg_field ytphy_rxden_grp[] = { + { "rxc_dly_en", BIT(8), 0x1 } +}; + static int yt8511_read_page(struct phy_device *phydev) { return __phy_read(phydev, YT8511_PAGE_SELECT); @@ -48,6 +84,33 @@ static int yt8511_write_page(struct phy_device *phydev, int page) return __phy_write(phydev, YT8511_PAGE_SELECT, page); }; +static int ytphy_read_ext(struct phy_device *phydev, u32 regnum) +{ + int ret; + int val; + + ret = __phy_write(phydev, YT8511_PAGE_SELECT, regnum); + if (ret < 0) + return ret; + + val = __phy_read(phydev, YT8511_PAGE); + + return val; +} + +static int ytphy_write_ext(struct phy_device *phydev, u32 regnum, u16 val) +{ + int ret; + + ret = __phy_write(phydev, YT8511_PAGE_SELECT, regnum); + if (ret < 0) + return ret; + + ret = __phy_write(phydev, YT8511_PAGE, val); + + return ret; +} + static int yt8511_config_init(struct phy_device *phydev) { int oldpage, ret = 0; @@ -111,6 +174,116 @@ static int yt8511_config_init(struct phy_device *phydev) return phy_restore_page(phydev, oldpage, ret); } +static int ytphy_config_init(struct phy_device *phydev) +{ + struct device_node *of_node; + u32 val; + u32 mask; + u32 cfg; + int ret; + int i = 0; + + of_node = phydev->mdio.dev.of_node; + if (of_node) { + ret = of_property_read_u32(of_node, ytphy_rxden_grp[0].name, &cfg); + if (!ret) { + mask = ytphy_rxden_grp[0].mask; + val = ytphy_read_ext(phydev, YTPHY_EXT_CHIP_CONFIG); + + /* check the cfg overflow or not */ + cfg = cfg > mask >> (ffs(mask) - 1) ? mask : cfg; + + val &= ~mask; + val |= FIELD_PREP(mask, cfg); + ytphy_write_ext(phydev, YTPHY_EXT_CHIP_CONFIG, val); + } + + val = ytphy_read_ext(phydev, YTPHY_EXT_RGMII_CONFIG1); + for (i = 0; i < ARRAY_SIZE(ytphy_rxtxd_grp); i++) { + ret = of_property_read_u32(of_node, ytphy_rxtxd_grp[i].name, &cfg); + if (!ret) { + mask = ytphy_rxtxd_grp[i].mask; + + /* check the cfg overflow or not */ + cfg = cfg > mask >> (ffs(mask) - 1) ? mask : cfg; + + val &= ~mask; + val |= cfg << (ffs(mask) - 1); + } + } + return ytphy_write_ext(phydev, YTPHY_EXT_RGMII_CONFIG1, val); + } + + phydev_err(phydev, "Get of node fail\n"); + + return -EINVAL; +} + +static void ytphy_link_change_notify(struct phy_device *phydev) +{ + u32 val; + struct ytphy_priv_t *ytphy_priv = phydev->priv; + + if (phydev->speed < 0) + return; + + val = ytphy_read_ext(phydev, YTPHY_EXT_RGMII_CONFIG1); + switch (phydev->speed) { + case SPEED_1000: + val &= ~ytphy_txinver_grp[0].mask; + val |= FIELD_PREP(ytphy_txinver_grp[0].mask, + ytphy_priv->tx_inverted_1000); + break; + + case SPEED_100: + val &= ~ytphy_txinver_grp[1].mask; + val |= FIELD_PREP(ytphy_txinver_grp[1].mask, + ytphy_priv->tx_inverted_100); + break; + + case SPEED_10: + val &= ~ytphy_txinver_grp[2].mask; + val |= FIELD_PREP(ytphy_txinver_grp[2].mask, + ytphy_priv->tx_inverted_10); + break; + + default: + break; + } + + ytphy_write_ext(phydev, YTPHY_EXT_RGMII_CONFIG1, val); +} + +static int yt8531_probe(struct phy_device *phydev) +{ + struct ytphy_priv_t *priv; + const struct device_node *of_node; + u32 val; + int ret; + + priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + of_node = phydev->mdio.dev.of_node; + if (of_node) { + ret = of_property_read_u32(of_node, ytphy_txinver_grp[0].name, &val); + if (!ret) + priv->tx_inverted_1000 = val; + + ret = of_property_read_u32(of_node, ytphy_txinver_grp[1].name, &val); + if (!ret) + priv->tx_inverted_100 = val; + + ret = of_property_read_u32(of_node, ytphy_txinver_grp[2].name, &val); + if (!ret) + priv->tx_inverted_10 = val; + } + phydev->priv = priv; + + return 0; +} + static struct phy_driver motorcomm_phy_drvs[] = { { PHY_ID_MATCH_EXACT(PHY_ID_YT8511), @@ -120,6 +293,17 @@ static struct phy_driver motorcomm_phy_drvs[] = { .resume = genphy_resume, .read_page = yt8511_read_page, .write_page = yt8511_write_page, + }, { + PHY_ID_MATCH_EXACT(PHY_ID_YT8531), + .name = "YT8531 Gigabit Ethernet", + .probe = yt8531_probe, + .config_init = ytphy_config_init, + .read_status = genphy_read_status, + .suspend = genphy_suspend, + .resume = genphy_resume, + .read_page = yt8511_read_page, + .write_page = yt8511_write_page, + .link_change_notify = ytphy_link_change_notify, }, }; @@ -131,6 +315,7 @@ MODULE_LICENSE("GPL"); static const struct mdio_device_id __maybe_unused motorcomm_tbl[] = { { PHY_ID_MATCH_EXACT(PHY_ID_YT8511) }, + { PHY_ID_MATCH_EXACT(PHY_ID_YT8531) }, { /* sentinal */ } }; From patchwork Thu Dec 1 09:02:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yanhong wang X-Patchwork-Id: 13061089 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 77CFDC47088 for ; Thu, 1 Dec 2022 09:03:42 +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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sjVEBHf2Xy/04a8yMI1UFVvoAnPxb1mKvuNP54QOAyI=; b=aHq/Dum7W57UZw Moj9szrlJjXtBeVa9puZu8MmYoierh0SXQEaxXJncN49PWKZ2VJNf34YSA9HssJ3IAtie1GmKjO5y 33PqQMavBid8te2aaRRvlaxhHfq19goVjz+0NjrVAv4cy4QfT0tyr7VwXIH0eyUxxPbov9c1ljZVp fsL4cwpi8Mrqs5syV2d8QyUdcMMSGeiGpj5J7rBz9Rpu74JtqtllbggELX8975E5yGFN2FbUS+P7/ nLQrV66zu6UFp3QyNq0CL4ZyE7LYG7scTU4GJfoyoDVeoFF1dmWW85mBNrFYuZU5nSmHTgsYFOa7M YNZxyLHyTWIxboNLkQjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0fTg-0068qU-3I; Thu, 01 Dec 2022 09:03:32 +0000 Received: from ex01.ufhost.com ([61.152.239.75]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0fT6-00684L-Lq for linux-riscv@lists.infradead.org; Thu, 01 Dec 2022 09:03:03 +0000 Received: from EXMBX166.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX166", Issuer "EXMBX166" (not verified)) by ex01.ufhost.com (Postfix) with ESMTP id E527F24E257; Thu, 1 Dec 2022 17:02:07 +0800 (CST) Received: from EXMBX173.cuchost.com (172.16.6.93) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 1 Dec 2022 17:02:08 +0800 Received: from wyh-VirtualBox.starfivetech.com (171.223.208.138) by EXMBX173.cuchost.com (172.16.6.93) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 1 Dec 2022 17:02:06 +0800 From: Yanhong Wang To: , , , CC: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Emil Renner Berthing , Richard Cochran , Andrew Lunn , Heiner Kallweit , Peter Geis , Yanhong Wang Subject: [PATCH v1 5/7] net: stmmac: Add StarFive dwmac supoort Date: Thu, 1 Dec 2022 17:02:40 +0800 Message-ID: <20221201090242.2381-6-yanhong.wang@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221201090242.2381-1-yanhong.wang@starfivetech.com> References: <20221201090242.2381-1-yanhong.wang@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [171.223.208.138] X-ClientProxiedBy: EXCAS065.cuchost.com (172.16.6.25) To EXMBX173.cuchost.com (172.16.6.93) X-YovoleRuleAgent: yovoleflag X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221201_010257_086171_307671A5 X-CRM114-Status: GOOD ( 21.59 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This adds StarFive dwmac driver support on the StarFive JH7110 SoCs. Signed-off-by: Yanhong Wang --- MAINTAINERS | 1 + drivers/net/ethernet/stmicro/stmmac/Kconfig | 11 ++ drivers/net/ethernet/stmicro/stmmac/Makefile | 1 + .../stmicro/stmmac/dwmac-starfive-plat.c | 147 ++++++++++++++++++ 4 files changed, 160 insertions(+) create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-starfive-plat.c diff --git a/MAINTAINERS b/MAINTAINERS index 7eaaec8d3b96..36cb00cf860b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19610,6 +19610,7 @@ STARFIVE DWMAC GLUE LAYER M: Yanhong Wang S: Maintained F: Documentation/devicetree/bindings/net/starfive,dwmac-plat.yaml +F: drivers/net/ethernet/stmicro/stmmac/dwmac-starfive-plat.c STARFIVE PINCTRL DRIVER M: Emil Renner Berthing diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig index 31ff35174034..1e29cd3770b9 100644 --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig @@ -235,6 +235,17 @@ config DWMAC_INTEL_PLAT the stmmac device driver. This driver is used for the Intel Keem Bay SoC. +config DWMAC_STARFIVE_PLAT + tristate "StarFive dwmac support" + depends on OF && COMMON_CLK + depends on STMMAC_ETH + default SOC_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 RISC-V SoCs. + config DWMAC_VISCONTI tristate "Toshiba Visconti DWMAC support" default ARCH_VISCONTI diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile index d4e12e9ace4f..a63ab0ab5071 100644 --- a/drivers/net/ethernet/stmicro/stmmac/Makefile +++ b/drivers/net/ethernet/stmicro/stmmac/Makefile @@ -31,6 +31,7 @@ obj-$(CONFIG_DWMAC_DWC_QOS_ETH) += dwmac-dwc-qos-eth.o obj-$(CONFIG_DWMAC_INTEL_PLAT) += dwmac-intel-plat.o obj-$(CONFIG_DWMAC_GENERIC) += dwmac-generic.o obj-$(CONFIG_DWMAC_IMX8) += dwmac-imx.o +obj-$(CONFIG_DWMAC_STARFIVE_PLAT) += dwmac-starfive-plat.o obj-$(CONFIG_DWMAC_VISCONTI) += dwmac-visconti.o stmmac-platform-objs:= stmmac_platform.o dwmac-altr-socfpga-objs := altr_tse_pcs.o dwmac-socfpga.o diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive-plat.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive-plat.c new file mode 100644 index 000000000000..8fbf584d4e19 --- /dev/null +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive-plat.c @@ -0,0 +1,147 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * StarFive DWMAC platform driver + * + * Copyright(C) 2022 StarFive Technology Co., Ltd. + * + */ + +#include +#include "stmmac_platform.h" + +struct starfive_dwmac { + struct device *dev; + struct clk *clk_tx; + struct clk *clk_gtx; + struct clk *clk_gtxc; +}; + +static void starfive_eth_fix_mac_speed(void *priv, unsigned int speed) +{ + struct starfive_dwmac *dwmac = priv; + unsigned long rate; + int err; + + switch (speed) { + case SPEED_1000: + rate = 125000000; + break; + case SPEED_100: + rate = 25000000; + break; + case SPEED_10: + rate = 2500000; + break; + default: + dev_err(dwmac->dev, "invalid speed %u\n", speed); + return; + } + + err = clk_set_rate(dwmac->clk_gtx, rate); + if (err) + dev_err(dwmac->dev, "failed to set tx rate %lu\n", rate); +} + +static void dwmac_starfive_clk_disable(void *clk) +{ + clk_disable_unprepare(clk); +} + +static int starfive_eth_plat_probe(struct platform_device *pdev) +{ + struct plat_stmmacenet_data *plat_dat; + struct stmmac_resources stmmac_res; + struct starfive_dwmac *dwmac; + int err; + + err = stmmac_get_platform_resources(pdev, &stmmac_res); + if (err) + return err; + + plat_dat = stmmac_probe_config_dt(pdev, stmmac_res.mac); + if (IS_ERR(plat_dat)) { + dev_err(&pdev->dev, "dt configuration failed\n"); + return PTR_ERR(plat_dat); + } + + dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); + if (!dwmac) + return -ENOMEM; + + dwmac->clk_tx = devm_clk_get(&pdev->dev, "tx"); + if (IS_ERR(dwmac->clk_tx)) + return dev_err_probe(&pdev->dev, PTR_ERR(dwmac->clk_tx), + "error getting tx clock\n"); + + err = devm_add_action(&pdev->dev, dwmac_starfive_clk_disable, + dwmac->clk_tx); + if (err) + return err; + + err = clk_prepare_enable(dwmac->clk_tx); + if (err) + return dev_err_probe(&pdev->dev, err, "error enabling tx clock\n"); + + dwmac->clk_gtx = devm_clk_get(&pdev->dev, "gtx"); + if (IS_ERR(dwmac->clk_gtx)) + return dev_err_probe(&pdev->dev, PTR_ERR(dwmac->clk_gtx), + "error getting gtx clock\n"); + + err = devm_add_action(&pdev->dev, dwmac_starfive_clk_disable, + dwmac->clk_gtx); + if (err) + return err; + + err = clk_prepare_enable(dwmac->clk_gtx); + if (err) + return dev_err_probe(&pdev->dev, err, "error enabling gtx clock\n"); + + dwmac->clk_gtxc = devm_clk_get(&pdev->dev, "gtxc"); + if (IS_ERR(dwmac->clk_gtxc)) + return dev_err_probe(&pdev->dev, PTR_ERR(dwmac->clk_gtxc), + "error getting gtxc clock\n"); + + err = devm_add_action(&pdev->dev, dwmac_starfive_clk_disable, + dwmac->clk_gtxc); + if (err) + return err; + + err = clk_prepare_enable(dwmac->clk_gtxc); + if (err) + return dev_err_probe(&pdev->dev, err, "error enabling gtxc clock\n"); + + dwmac->dev = &pdev->dev; + plat_dat->fix_mac_speed = starfive_eth_fix_mac_speed; + plat_dat->init = NULL; + plat_dat->bsp_priv = dwmac; + plat_dat->dma_cfg->dche = true; + + err = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); + if (err) { + stmmac_remove_config_dt(pdev, plat_dat); + return err; + } + + return 0; +} + +static const struct of_device_id starfive_eth_plat_match[] = { + {.compatible = "starfive,dwmac"}, + { } +}; + +static struct platform_driver starfive_eth_plat_driver = { + .probe = starfive_eth_plat_probe, + .remove = stmmac_pltfr_remove, + .driver = { + .name = "starfive-eth-plat", + .pm = &stmmac_pltfr_pm_ops, + .of_match_table = starfive_eth_plat_match, + }, +}; + +module_platform_driver(starfive_eth_plat_driver); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("StarFive DWMAC platform driver"); +MODULE_AUTHOR("Yanhong Wang "); From patchwork Thu Dec 1 09:02:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yanhong wang X-Patchwork-Id: 13061088 X-Patchwork-Delegate: mail@conchuod.ie 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 EAD95C43217 for ; Thu, 1 Dec 2022 09:03:31 +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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GiApJbxsi3uNtxYYckB51KVfwmbjmBo7ytEIVF8MYcQ=; b=pPv5ObO6p4Q07L b0XLzghNLxxXNISb5Dugzm8K18ZLtWQbT2tjELHU7iguzPEBab5n7ndHeTQfmXVnTsk92EiqD10Ar gucRJCzGG4vrbT2x0jNzrw7YAe1aUaubfFJWbmdLvj2JdlN6bw+DLCylxUillKuWRnrQ5KvqEopFQ a+ibx8zDb96uU+uKxb+md32Sjdpx016I3mhWqGYfJVqXFMjd9PEKUvsHj06GKM81kCe2hKr0qDZ6E SBClu35FhqJsrUfqmWUjqlWoZultR967r9oynJB53UzQtX9LUYrezsUpSL4yes08yU8FHli3klmin TODCU2hOccqnQ5r+hZpg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0fTX-0068lC-FJ; Thu, 01 Dec 2022 09:03:23 +0000 Received: from fd01.gateway.ufhost.com ([61.152.239.71]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0fTA-00687i-Os for linux-riscv@lists.infradead.org; Thu, 01 Dec 2022 09:03:03 +0000 Received: from EXMBX165.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX165", Issuer "EXMBX165" (not verified)) by fd01.gateway.ufhost.com (Postfix) with ESMTP id D68DA24E0D6; Thu, 1 Dec 2022 17:02:08 +0800 (CST) Received: from EXMBX173.cuchost.com (172.16.6.93) by EXMBX165.cuchost.com (172.16.6.75) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 1 Dec 2022 17:02:08 +0800 Received: from wyh-VirtualBox.starfivetech.com (171.223.208.138) by EXMBX173.cuchost.com (172.16.6.93) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 1 Dec 2022 17:02:07 +0800 From: Yanhong Wang To: , , , CC: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Emil Renner Berthing , Richard Cochran , Andrew Lunn , Heiner Kallweit , Peter Geis , Yanhong Wang Subject: [PATCH v1 6/7] riscv: dts: starfive: jh7110: Add ethernet device node Date: Thu, 1 Dec 2022 17:02:41 +0800 Message-ID: <20221201090242.2381-7-yanhong.wang@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221201090242.2381-1-yanhong.wang@starfivetech.com> References: <20221201090242.2381-1-yanhong.wang@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [171.223.208.138] X-ClientProxiedBy: EXCAS065.cuchost.com (172.16.6.25) To EXMBX173.cuchost.com (172.16.6.93) X-YovoleRuleAgent: yovoleflag X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221201_010301_132702_9C1D0E66 X-CRM114-Status: UNSURE ( 9.17 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add JH7110 ethernet device node to support gmac driver for the JH7110 RISC-V SoC. Signed-off-by: Yanhong Wang --- arch/riscv/boot/dts/starfive/jh7110.dtsi | 80 ++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/arch/riscv/boot/dts/starfive/jh7110.dtsi b/arch/riscv/boot/dts/starfive/jh7110.dtsi index c22e8f1d2640..97ed5418d91f 100644 --- a/arch/riscv/boot/dts/starfive/jh7110.dtsi +++ b/arch/riscv/boot/dts/starfive/jh7110.dtsi @@ -433,5 +433,85 @@ reg-shift = <2>; status = "disabled"; }; + + stmmac_axi_setup: stmmac-axi-config { + snps,wr_osr_lmt = <4>; + snps,rd_osr_lmt = <4>; + snps,blen = <256 128 64 32 0 0 0>; + }; + + gmac0: ethernet@16030000 { + compatible = "starfive,dwmac", "snps,dwmac-5.20"; + reg = <0x0 0x16030000 0x0 0x10000>; + clocks = <&aoncrg JH7110_AONCLK_GMAC0_AXI>, + <&aoncrg JH7110_AONCLK_GMAC0_AHB>, + <&syscrg JH7110_SYSCLK_GMAC0_PTP>, + <&aoncrg JH7110_AONCLK_GMAC0_TX>, + <&syscrg JH7110_SYSCLK_GMAC0_GTXC>, + <&syscrg JH7110_SYSCLK_GMAC0_GTXCLK>; + clock-names = "stmmaceth", + "pclk", + "ptp_ref", + "tx", + "gtxc", + "gtx"; + resets = <&aoncrg JH7110_AONRST_GMAC0_AXI>, + <&aoncrg JH7110_AONRST_GMAC0_AHB>; + reset-names = "stmmaceth", "ahb"; + interrupts = <7>, <6>, <5> ; + interrupt-names = "macirq", "eth_wake_irq", "eth_lpi"; + phy-mode = "rgmii-id"; + snps,multicast-filter-bins = <64>; + snps,perfect-filter-entries = <8>; + rx-fifo-depth = <2048>; + tx-fifo-depth = <2048>; + snps,fixed-burst; + snps,no-pbl-x8; + snps,force_thresh_dma_mode; + snps,axi-config = <&stmmac_axi_setup>; + snps,tso; + snps,en-tx-lpi-clockgating; + snps,lpi_en; + snps,txpbl = <16>; + snps,rxpbl = <16>; + status = "disabled"; + }; + + gmac1: ethernet@16040000 { + compatible = "starfive,dwmac", "snps,dwmac-5.20"; + reg = <0x0 0x16040000 0x0 0x10000>; + clocks = <&syscrg JH7110_SYSCLK_GMAC1_AXI>, + <&syscrg JH7110_SYSCLK_GMAC1_AHB>, + <&syscrg JH7110_SYSCLK_GMAC1_PTP>, + <&syscrg JH7110_SYSCLK_GMAC1_TX>, + <&syscrg JH7110_SYSCLK_GMAC1_GTXC>, + <&syscrg JH7110_SYSCLK_GMAC1_GTXCLK>; + clock-names = "stmmaceth", + "pclk", + "ptp_ref", + "tx", + "gtxc", + "gtx"; + resets = <&syscrg JH7110_SYSRST_GMAC1_AXI>, + <&syscrg JH7110_SYSRST_GMAC1_AHB>; + reset-names = "stmmaceth", "ahb"; + interrupts = <78>, <77>, <76> ; + interrupt-names = "macirq", "eth_wake_irq", "eth_lpi"; + phy-mode = "rgmii-id"; + snps,multicast-filter-bins = <64>; + snps,perfect-filter-entries = <8>; + rx-fifo-depth = <2048>; + tx-fifo-depth = <2048>; + snps,fixed-burst; + snps,no-pbl-x8; + snps,force_thresh_dma_mode; + snps,axi-config = <&stmmac_axi_setup>; + snps,tso; + snps,en-tx-lpi-clockgating; + snps,lpi_en; + snps,txpbl = <16>; + snps,rxpbl = <16>; + status = "disabled"; + }; }; }; From patchwork Thu Dec 1 09:02:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yanhong wang X-Patchwork-Id: 13061090 X-Patchwork-Delegate: mail@conchuod.ie 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 BFF89C43217 for ; Thu, 1 Dec 2022 09:03:43 +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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=h5i36aoYUpT8xdSecISOz21gX2NI8NGSUFc7sDkm4XM=; b=pELJdpQzuHRnuy /vfjVx08hashtv9IPz08Vd+ZYlGHTkLhSCeutIi/wK5dMU7cunlwDyFStPm8OkfF2+hFgsVypj/b0 rEOyWJl4L35h9CtRnoOg7z0hVzISyia7PmVTAKTyM3Q3qEgn4d9/ZuN8jgQJ6MIh7VRStp5GQ3vp8 QqS9a5c2Bvjjw/5faXk1bWmrcf7n9Z2odIsWNzd45ANLPCedvO08p+Ago/NN/Rx+/LpYGFsf9kUrf lN/hvCo8/vziyg6puL4sRdge8bzjnAe6AhIeMHQE1BSF0HHhf85GkVYmFjs5ozzIaKa/nt4CrXYXv 7Gwa4FTfEP6KtP0v+JGA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0fTj-0068sq-Bx; Thu, 01 Dec 2022 09:03:35 +0000 Received: from fd01.gateway.ufhost.com ([61.152.239.71]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0fT8-00687e-K1 for linux-riscv@lists.infradead.org; Thu, 01 Dec 2022 09:03:03 +0000 Received: from EXMBX166.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX166", Issuer "EXMBX166" (not verified)) by fd01.gateway.ufhost.com (Postfix) with ESMTP id C011D24E116; Thu, 1 Dec 2022 17:02:09 +0800 (CST) Received: from EXMBX173.cuchost.com (172.16.6.93) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 1 Dec 2022 17:02:10 +0800 Received: from wyh-VirtualBox.starfivetech.com (171.223.208.138) by EXMBX173.cuchost.com (172.16.6.93) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 1 Dec 2022 17:02:08 +0800 From: Yanhong Wang To: , , , CC: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Emil Renner Berthing , Richard Cochran , Andrew Lunn , Heiner Kallweit , Peter Geis , Yanhong Wang Subject: [PATCH v1 7/7] riscv: dts: starfive: visionfive-v2: Add phy delay_chain configuration Date: Thu, 1 Dec 2022 17:02:42 +0800 Message-ID: <20221201090242.2381-8-yanhong.wang@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221201090242.2381-1-yanhong.wang@starfivetech.com> References: <20221201090242.2381-1-yanhong.wang@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [171.223.208.138] X-ClientProxiedBy: EXCAS065.cuchost.com (172.16.6.25) To EXMBX173.cuchost.com (172.16.6.93) X-YovoleRuleAgent: yovoleflag X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221201_010258_857869_093407B8 X-CRM114-Status: UNSURE ( 9.24 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add phy delay_chain configuration to support motorcomm phy driver for StarFive VisionFive 2 board. Signed-off-by: Yanhong Wang --- .../jh7110-starfive-visionfive-v2.dts | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-v2.dts b/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-v2.dts index c8946cf3a268..2868ef4c74ef 100644 --- a/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-v2.dts +++ b/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-v2.dts @@ -15,6 +15,8 @@ aliases { serial0 = &uart0; + ethernet0=&gmac0; + ethernet1=&gmac1; }; chosen { @@ -114,3 +116,47 @@ pinctrl-0 = <&uart0_pins>; status = "okay"; }; + +&gmac0 { + status = "okay"; + #address-cells = <1>; + #size-cells = <0>; + phy-handle = <&phy0>; + status = "okay"; + mdio0 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "snps,dwmac-mdio"; + phy0: ethernet-phy@0 { + reg = <0>; + rxc_dly_en = <1>; + tx_delay_sel_fe = <5>; + tx_delay_sel = <0xa>; + tx_inverted_10 = <0x1>; + tx_inverted_100 = <0x1>; + tx_inverted_1000 = <0x1>; + }; + }; +}; + +&gmac1 { + status = "okay"; + #address-cells = <1>; + #size-cells = <0>; + phy-handle = <&phy1>; + status = "okay"; + mdio1 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "snps,dwmac-mdio"; + phy1: ethernet-phy@1 { + reg = <1>; + tx_delay_sel_fe = <5>; + tx_delay_sel = <0>; + rxc_dly_en = <0>; + tx_inverted_10 = <0x1>; + tx_inverted_100 = <0x1>; + tx_inverted_1000 = <0x0>; + }; + }; +};