From patchwork Mon Dec 23 00:58:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inochi Amaoto X-Patchwork-Id: 13918331 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BDED1F4E2; Mon, 23 Dec 2024 00:59:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734915566; cv=none; b=eAL2goKy3qcNxwcg884oynFc0CnDRCdnEwcUeWdnXHo3bl61YARmL6a6fKBsAhOnxZ4/x72c21ABAbiiQErlG/eGrqPiVu7ZzhfxZVZJOQVsjJePxW9QDRXWUctW+v8iJxtaNjplPu4OKM+mclFcU8KDZKACxtQ9B0xxIUjV3ts= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734915566; c=relaxed/simple; bh=i3nUkXLpsqr/fJEuk3YUem+exM6C72muUCZwzlnuuas=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dySVcajTKt5ElC5P4Irw4wL/+c5l8ClwtQkhgxJtrslpbBtMyx6dstlk7QvXgH+itv0Xu7jCCR7IxNaGRoSeN3ho+9S3ucWwFXKKlKH2OzfWauCAOfWHNTVCeX12JjGq6g68TI0H/X7loASwQJkDxkp3yL8Ufk7eaITfpZ9sn/M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Pu35CF37; arc=none smtp.client-ip=209.85.219.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Pu35CF37" Received: by mail-qv1-f49.google.com with SMTP id 6a1803df08f44-6dd1b895541so29055206d6.0; Sun, 22 Dec 2024 16:59:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734915564; x=1735520364; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jRWA/tM4Nlwg4+7MH+fMHivDiS7vd/AnzDx119oQ4ZA=; b=Pu35CF37JHEQTmJiMGg3AyYcLEvGb/k2KvV39I1qT/TeRfY6vpExacm440+h/HjQS6 LHnEILwWAZ5ikuZjsT0ikjXTRXztoBSJfRi8cQhvnDfTeaqbiTGCt49PTmFSLx1kwrJt cbvdITmTK3PKyzeg/fGek2A+N5nM9Eh5TAL4TL42/LnuGtnsNMmWZLLlZk6cjodDhoXQ P0G0vJnmugZjN0eLV3rVdgdIjgV8xucpFctVUMzn/zL1rUSCG2AYI/lKKygVAZjtsrLx M3OlJnsV4TRf8bPZdSNNqt3mahdkI6X6iqozvXvVeHs5njqLc0Vhyy0geh7AFvliYpd9 FWuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734915564; x=1735520364; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jRWA/tM4Nlwg4+7MH+fMHivDiS7vd/AnzDx119oQ4ZA=; b=AqVlVTBLvZZCBBTlkUY4dUdgkYmv/yHYpITWO4792/I4ayEyvGMy1h7tgDu/cwtWyV CqrxQQtBDo1GW6mFqbtq0HN5F1URIk0YBzCpmbMzQhME8PHEs40fSEwVx4ovKGYSTRs/ 3bxU/HVnRBLnyVxsPBOIqxmrNavXiuVorcMehaMfAx066Da+ewwI18fSbZ7kh5UK3S7C qbK/tayJJ+4CLu4msqhMNAXkerhCTzFrMHOrCml4QbqLAaUyvnzoSwLv7a8NUb/v1BNz 0ccSPDaKSKVQabXYZXss2ZT4EmIWNLKmixTbhQ4nOgNX7HCyd1BHV/HVEn/nq5UIgXPf U1dA== X-Forwarded-Encrypted: i=1; AJvYcCVezuHUDxTfOmtwLRnEpNGjw53LSdwV2c9Ez8B3BuLSg2NQgE9FWlq1z9bRGYgMVHqpye68vKNj0oR6@vger.kernel.org, AJvYcCVx8fBdsWTTA2BV5HBdabdIlnM5nx/lZfjjcHRL/t0lbihIFQlSaONYJDDcQwusdxxPX4b+RiiCuX8haB7n@vger.kernel.org, AJvYcCWew+gO8p8icfPL14aczyn2GvGGec2buo1MaK8gZ/swTUB2xCaiR7/QVdCA2Y5MoA57OvUPeH1j@vger.kernel.org X-Gm-Message-State: AOJu0YxEu5YFUbmJdWZJ/bTKFxc4sGcOc2xwU5QTvKcVs2tcZ34aZHDH s2Gi93WJMbjpkLtqAhZe++hJ1aK9nD9Ng+Ta8TQBbyLp+1IVD6hjwu+Luw== X-Gm-Gg: ASbGncviL7+EVrPZrPZrkyGkYij4PO2oZXlbDR76RKi+2L7nFcqcKqs0zyKs0QDAkQg IKvewWRxoSaBQe6fVpecX+SiazXCKg23lkpXCak90U8kkMD4sQG2MkERRhOjVFR8yQRMx1RNFz2 YBK4/QwsdGCBMm7INQd5KJVhq9QXhkvdYq2cnhXW/aPrqBHC6BCZZ/24RYHNXKBYVKM+bCjXlzs ltobM945ZG0yFGv88/U5zDzmmrk9iMe X-Google-Smtp-Source: AGHT+IHN9d1bnlxRzzqRiDcadAYUGSNIOJpqNW2TaHPm8W5wc6dU1Ev4iY1D0s3G2OYKNDwOXlA05w== X-Received: by 2002:a05:6214:d89:b0:6d4:1ea3:981d with SMTP id 6a1803df08f44-6dd233a2bccmr164013606d6.43.1734915563662; Sun, 22 Dec 2024 16:59:23 -0800 (PST) Received: from localhost ([2001:da8:7001:11::cb]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6dd180ea9d0sm39145406d6.7.2024.12.22.16.59.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Dec 2024 16:59:22 -0800 (PST) From: Inochi Amaoto To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen Wang , Inochi Amaoto , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Richard Cochran , Paul Walmsley , Palmer Dabbelt , Albert Ou , Giuseppe Cavallaro Cc: Inochi Amaoto , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, Yixun Lan , Longbin Li , Krzysztof Kozlowski Subject: [PATCH net-next v3 1/3] dt-bindings: net: Add support for Sophgo SG2044 dwmac Date: Mon, 23 Dec 2024 08:58:37 +0800 Message-ID: <20241223005843.483805-2-inochiama@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241223005843.483805-1-inochiama@gmail.com> References: <20241223005843.483805-1-inochiama@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The GMAC IP on SG2044 is almost a standard Synopsys DesignWare MAC (version 5.30a) with some extra clock. Add necessary compatible string for this device. Signed-off-by: Inochi Amaoto Reviewed-by: Krzysztof Kozlowski --- .../devicetree/bindings/net/snps,dwmac.yaml | 4 + .../bindings/net/sophgo,sg2044-dwmac.yaml | 124 ++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml index eb1f3ae41ab9..cd112ef6b3bf 100644 --- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml +++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml @@ -32,6 +32,7 @@ select: - snps,dwmac-4.20a - snps,dwmac-5.10a - snps,dwmac-5.20 + - snps,dwmac-5.30a - snps,dwxgmac - snps,dwxgmac-2.10 @@ -97,8 +98,10 @@ properties: - snps,dwmac-4.20a - snps,dwmac-5.10a - snps,dwmac-5.20 + - snps,dwmac-5.30a - snps,dwxgmac - snps,dwxgmac-2.10 + - sophgo,sg2044-dwmac - starfive,jh7100-dwmac - starfive,jh7110-dwmac - thead,th1520-gmac @@ -630,6 +633,7 @@ allOf: - snps,dwmac-4.20a - snps,dwmac-5.10a - snps,dwmac-5.20 + - snps,dwmac-5.30a - snps,dwxgmac - snps,dwxgmac-2.10 - st,spear600-gmac diff --git a/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml b/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml new file mode 100644 index 000000000000..b7e4216ea45a --- /dev/null +++ b/Documentation/devicetree/bindings/net/sophgo,sg2044-dwmac.yaml @@ -0,0 +1,124 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/sophgo,sg2044-dwmac.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sophgo SG2044 DWMAC glue layer + +maintainers: + - Inochi Amaoto + +select: + properties: + compatible: + contains: + enum: + - sophgo,sg2044-dwmac + required: + - compatible + +properties: + compatible: + items: + - const: sophgo,sg2044-dwmac + - const: snps,dwmac-5.30a + + reg: + maxItems: 1 + + clocks: + items: + - description: GMAC main clock + - description: PTP clock + - description: TX clock + + clock-names: + items: + - const: stmmaceth + - const: ptp_ref + - const: tx + + interrupts: + maxItems: 1 + + interrupt-names: + maxItems: 1 + + resets: + maxItems: 1 + + reset-names: + const: stmmaceth + +required: + - compatible + - reg + - clocks + - clock-names + - interrupts + - interrupt-names + - resets + - reset-names + +allOf: + - $ref: snps,dwmac.yaml# + +unevaluatedProperties: false + +examples: + - | + #include + + ethernet@30006000 { + compatible = "sophgo,sg2044-dwmac", "snps,dwmac-5.30a"; + reg = <0x30006000 0x4000>; + clocks = <&clk 151>, <&clk 152>, <&clk 154>; + clock-names = "stmmaceth", "ptp_ref", "tx"; + interrupt-parent = <&intc>; + interrupts = <296 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "macirq"; + resets = <&rst 30>; + reset-names = "stmmaceth"; + snps,multicast-filter-bins = <0>; + snps,perfect-filter-entries = <1>; + snps,aal; + snps,tso; + snps,txpbl = <32>; + snps,rxpbl = <32>; + snps,mtl-rx-config = <&gmac0_mtl_rx_setup>; + snps,mtl-tx-config = <&gmac0_mtl_tx_setup>; + snps,axi-config = <&gmac0_stmmac_axi_setup>; + status = "disabled"; + + gmac0_mtl_rx_setup: rx-queues-config { + snps,rx-queues-to-use = <8>; + snps,rx-sched-wsp; + queue0 {}; + queue1 {}; + queue2 {}; + queue3 {}; + queue4 {}; + queue5 {}; + queue6 {}; + queue7 {}; + }; + + gmac0_mtl_tx_setup: tx-queues-config { + snps,tx-queues-to-use = <8>; + queue0 {}; + queue1 {}; + queue2 {}; + queue3 {}; + queue4 {}; + queue5 {}; + queue6 {}; + queue7 {}; + }; + + gmac0_stmmac_axi_setup: stmmac-axi-config { + snps,blen = <16 8 4 0 0 0 0>; + snps,wr_osr_lmt = <1>; + snps,rd_osr_lmt = <2>; + }; + }; From patchwork Mon Dec 23 00:58:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inochi Amaoto X-Patchwork-Id: 13918332 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D47E317BB6; Mon, 23 Dec 2024 00:59:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734915570; cv=none; b=ouNaTe2R80mFjkGtM8CNY9I9/KFoBIr/VyCvC36T7IO2wmzydUm0BqmDJN7m4vY8GcHJa42NSN7a52p1gE5Jk4SWjWgFGJUhuXGkRZj9Ym+BLuFF77E7df0KGAFhdRbMj1sxxI9v6mHWvlKXBYzpA91ssKRyDaikc8LB14BC6mE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734915570; c=relaxed/simple; bh=khaXCDhZzZW4H8p3un1TOoMjCQqhPUmCFWqDYVBlDbk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EqaXmmU26+JwFR2Mwax9CFvdxGioGepzf0CVUzryJcBcDfy5u88l7xY1chu3rk1xj8p6pr6AZZMB+P/+CTFwaZBrFIdZXetACJ8V+79VZu+JsPpcdgf3jp3AiBDaYbRLZBRGwVjf6JZwgcSpSJ10zdVqYUgbyKWOEn8DEsqbvf8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=irxM0OqE; arc=none smtp.client-ip=209.85.222.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="irxM0OqE" Received: by mail-qk1-f179.google.com with SMTP id af79cd13be357-7b6ff72ba5aso296097685a.1; Sun, 22 Dec 2024 16:59:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734915568; x=1735520368; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AiKcNAywK5Cmu1NkwsGA/Qh6M5B4fnjylkQgAEZo09A=; b=irxM0OqEeI3A0mNL4iKKebCS12B9a3OV/L1vjVrUFssasadzmaQZ3/sseXTdBl44hr 9SDOhlkkqY980en7zzICza4DWR6LqzUDPZ3q/45kgi5HcK2fqNiCQYtzE+GLY4qJb/RX YMWGTJ7V4j+nudMI+WG76H2peaCqxTS/0jphSj7dghxXsGEomrdIzAGBD5gcP7DrSfz3 jxSbxNTmDewSeAM/PxkS7xFSLacrhE48/H+a2ZOgP70+YZAWgZvy7mOnKLtByk7ol3uQ WIlGx2WJ8hyxaskwnc2jNuqDoBBR/nGvBi3hn9Ldcqwy7TeHyPNElGgXL2ERNBkAXs1Q Akzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734915568; x=1735520368; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AiKcNAywK5Cmu1NkwsGA/Qh6M5B4fnjylkQgAEZo09A=; b=q5p3Dfbil82QLZ86YqrhU/u5Y1hElZ7HrFVcTWrLqX7PIt9h+bnSxbeEsnEl0Lyh/r +DgT7SCGppVNonXenwIzhBR6e34OPa8ifqB+7cFh4tRPaX6gb4N8js4evw1iXiLDDOqR AkzS4ti0cVQfVxHWE2aFZXEjUUVNtdUT+FLFLJMZwRPBNhnrd0PP+5xqhW35SsDrKhf8 XBX5DNdbVcEnM7C+UzCkj9sEp+1rDSEs3hATt06GQ89XOezSnr1KQrxKZCaNjg1uF6Bt flhFZ6DSiAUxDavWgpyxVfyX1yTSLTFwDU4dfml9WzEkEJMEtOCxIoh9yf1NRdOB2E4T vIAQ== X-Forwarded-Encrypted: i=1; AJvYcCVqLp0Lf4vVrGFLAazSeE6p4P+5a41069NZXEe/F2m5EnlWg4AITP38ZD+IEKI5p2Ti8FR6mtVbXIQrioXv@vger.kernel.org, AJvYcCWvDKVtcuSn0zTy4EYn3liYroEP5k+044s18msejeM5eh4vgFRIJhg6F8+kgKQsdt1YxqIU+Qx9@vger.kernel.org, AJvYcCX6XnoxFJC8X4v9IuQxSaeDbm3XkGip4pvG3UKyUjPSE6vEgRdDhj2LwNBM3Qrz8DnQ45aGWEiYBU4u@vger.kernel.org X-Gm-Message-State: AOJu0YxsTt6lUuZUPcWo1qMX72+RWW8B8WeD854BbSeAFmqTQR+uB1e6 3K6mjGaBG1z743l4di8tzQ/knbVG5D75oFbUL2qIVoG/U8Y0UPua X-Gm-Gg: ASbGncvoV+gCVptjZWBmZRUMLC3HF2PXyAtgBnOZFeapVCtDil2XFtziKXK9eU9xg2o wc5c+sYLb+1rMB7u6eudl6sQ9i/fPgDFyMSAGFyr9aDWHyzT4k28wYbSdxTBFhga5N/3vLkqbM2 8OoRIyxVSLTDlqeWNM1SmLtGQxGnt29yOUAXHWOEk8k/gUwwdsJrEm1ZojjOPeMyIKSfqS7xeje ZPE5XoYoLbTd4Z57iaPtFsTOo0Ln+ai X-Google-Smtp-Source: AGHT+IHmWT1/Ptgcfo0yRcOfYVL7jRnYrWxtKz1ZxEcSoQyLNTugTUWefuWbPDDlyPnGLBEXiIHxDA== X-Received: by 2002:a05:620a:394a:b0:7b6:d710:2282 with SMTP id af79cd13be357-7b9ba80ebc6mr1941528985a.49.1734915567731; Sun, 22 Dec 2024 16:59:27 -0800 (PST) Received: from localhost ([2001:da8:7001:11::cb]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7b9ac2bd0b9sm341784485a.23.2024.12.22.16.59.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Dec 2024 16:59:27 -0800 (PST) From: Inochi Amaoto To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen Wang , Inochi Amaoto , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Richard Cochran , Paul Walmsley , Palmer Dabbelt , Albert Ou , Giuseppe Cavallaro Cc: Inochi Amaoto , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, Yixun Lan , Longbin Li Subject: [PATCH net-next v3 2/3] net: stmmac: platform: Add snps,dwmac-5.30a IP compatible string Date: Mon, 23 Dec 2024 08:58:38 +0800 Message-ID: <20241223005843.483805-3-inochiama@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241223005843.483805-1-inochiama@gmail.com> References: <20241223005843.483805-1-inochiama@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Add "snps,dwmac-5.30a" compatible string for 5.30a version that can avoid to define some platform data in the glue layer. Signed-off-by: Inochi Amaoto --- .../ethernet/stmicro/stmmac/stmmac_platform.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index 3ac32444e492..6ce3e538ce0a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -421,6 +421,17 @@ static void stmmac_remove_config_dt(struct platform_device *pdev, of_node_put(plat->mdio_node); } +/* Compatible string array for all gmac4 devices */ +static const char * const stmmac_gmac4_compats[] = { + "snps,dwmac-4.00", + "snps,dwmac-4.10a", + "snps,dwmac-4.20a", + "snps,dwmac-5.10a", + "snps,dwmac-5.20", + "snps,dwmac-5.30a", + NULL +}; + /** * stmmac_probe_config_dt - parse device-tree driver parameters * @pdev: platform_device structure @@ -552,11 +563,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, u8 *mac) plat->pmt = 1; } - 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.20")) { + if (of_device_compatible_match(np, stmmac_gmac4_compats)) { plat->has_gmac4 = 1; plat->has_gmac = 0; plat->pmt = 1; From patchwork Mon Dec 23 00:58:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inochi Amaoto X-Patchwork-Id: 13918333 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEBB5364D6; Mon, 23 Dec 2024 00:59:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734915574; cv=none; b=b7PtgCwM7jxGYus3ps5/0UDLcg6FD9fSus0kLY5GZwIA4Il1Fh91veXm71TiFHPA0pFCe/UzyFkiErxGJ10LpEznX0ZbN3z8Byzf6Sdbx96ZxmmUn38IUnnZZrgvDCxowfBMJG/zw/0dmi/9KfaiVrtTf7xjkGQRIDPQm2gA6pA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734915574; c=relaxed/simple; bh=lYkvdYzvLx9+N909oP0UT60cVLQ2L5Mw+4bjH4vmpK8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a60bjJZ05EGuCCPBJfuCQV3YvrhM7tcQT6jGPiOKiBwdfD8OtuISsz76Kfmr9qUYQKO1ZuYvAG9fth6rOyYMZdgyuw4d73V7st+lWqLmjpUVl3mvWMGUrTdGkgRA+Rcn0sbaemcl41uiwZhbgUQdVlPvXt1A4dHpOTAoISVHnrg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WZU1kdFg; arc=none smtp.client-ip=209.85.160.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WZU1kdFg" Received: by mail-qt1-f174.google.com with SMTP id d75a77b69052e-467838e75ffso45648701cf.3; Sun, 22 Dec 2024 16:59:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734915572; x=1735520372; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dSgmUq6fWDAYGhUiI+1p1Nvpascpw09NerCf1YnBrAA=; b=WZU1kdFgiwdp4vUAgKEqMPx8pdpDTo1c9oqv3gU+zxN99i4HE6M+1FYsLLKYNS6nl/ ESdhEy9i8ts01rBNcV2myGtx9Y6LT/q1vVBnddKhL9r2z0bwnci1ZIl23yRz8L+O3VjP 8CLSnGfdOZwnrobiKr6AA9Zf8OARUnmCIYdTLk08v3uOg/YpenVTNWUHp3dNmQa2FLrV GJ1ABS4zU/mS/ktE5JNtFNMTSvDLbBi2qxEui/0GXXKdfoJ91npRTrRZsj9RnWUxckkW EI4WwM1Z8FLbN1I/Q6cx7uW7mmbefRr5/ioL1WlB1TyzXKxjdRy9FvfL8iNAvKroMove Itnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734915572; x=1735520372; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dSgmUq6fWDAYGhUiI+1p1Nvpascpw09NerCf1YnBrAA=; b=edc2jDgulsus0zQlDiJHMARX2B/b1P571mun5ZsPV0so1dTy3pNqY6Ag8ck4akwSs3 4yqhQBPgWZGcRycqnRhTgE5wCQ43+zjp7tyB335FkcyOEJVBnDbrGk/99MmLnRkXRFD3 kYtpro0Jddvhng843OonRn5yAR8TFlYFXh00i9yaP+UDVesHWGrZUJcq+qm6R8u84n08 JqdkKsXt3FD+IWc1+cismQo/jhP0FBl2/BlESd6XDZg1K6QmtQSlted5e3l3dilNX2ve 4jUiEIkMr0JXk93OUEDuU+uo4vARWZHjejQmbpRitvHK3qWyQbA71ne10MdkjdmAPM47 WI7A== X-Forwarded-Encrypted: i=1; AJvYcCUkPVoHb8Wto6MvRHFShgNql24P81bmHT443kPPW/Ym/GPZN+h6z0kUXPJn6wkcuUAT3izCikKc@vger.kernel.org, AJvYcCV/kLfQ4xQeaul65QJYHsWK1XHBYQGXqcGhJtp05pjMgJLyaQd97pykAiroQe1Rag4AbvHuguEslDBBU/iQ@vger.kernel.org, AJvYcCX0zigqNgONUrwlZyaaJnIQ84aEU0O5Fz8BA6Oufdq7oCIkEc6AxVeR2yn+mxgOuez9SAkZFsgj0090@vger.kernel.org X-Gm-Message-State: AOJu0YzqKMiFlrJALOtjqfYTlUKCa+Es7c+2AJITXsNCVXhm3flqvqty ti9gSXD5Olu798UYE9n8CKOkmv+TvKRIW/7uqJfuDdWUGgxfoC2Z X-Gm-Gg: ASbGncuDSduk7c8Pcpt+pojmdB1UoIgPMfeAFYwypBV2nA2TRiYhEM1T+aL6Ey3suLM Wt81OZ5S65352/1IM62WLp6Sm2kTBeOlKknQJsD3/Cot6NGrAltqeWCK8Fdo2AcVVhRVyu7YvMX oidxMv6S77B9M9D4+Ycla1tXvi1VeD60gqjji204GcYT0eIhKCSJbatmWq3r/kGBrP/hgwnk1GI qNOdBbkD1C0SX1eBjGDD6Qad6xlQT3+ X-Google-Smtp-Source: AGHT+IHjz7WDJXZngk0HiOawE5i+rAuNn2t3oiKW5rDk4l39S/7Vt67KkTJKlnank9Y1jvPWV5vKBA== X-Received: by 2002:ac8:59cf:0:b0:466:9824:16ef with SMTP id d75a77b69052e-46a4a8b5f64mr181259011cf.3.1734915571686; Sun, 22 Dec 2024 16:59:31 -0800 (PST) Received: from localhost ([2001:da8:7001:11::cb]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46a3eb33b11sm39454091cf.72.2024.12.22.16.59.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Dec 2024 16:59:30 -0800 (PST) From: Inochi Amaoto To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen Wang , Inochi Amaoto , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Richard Cochran , Paul Walmsley , Palmer Dabbelt , Albert Ou , Giuseppe Cavallaro Cc: Inochi Amaoto , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, Yixun Lan , Longbin Li Subject: [PATCH net-next v3 3/3] net: stmmac: Add glue layer for Sophgo SG2044 SoC Date: Mon, 23 Dec 2024 08:58:39 +0800 Message-ID: <20241223005843.483805-4-inochiama@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241223005843.483805-1-inochiama@gmail.com> References: <20241223005843.483805-1-inochiama@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Adds Sophgo dwmac driver support on the Sophgo SG2044 SoC. Signed-off-by: Inochi Amaoto --- drivers/net/ethernet/stmicro/stmmac/Kconfig | 11 ++ drivers/net/ethernet/stmicro/stmmac/Makefile | 1 + .../ethernet/stmicro/stmmac/dwmac-sophgo.c | 105 ++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig index 6658536a4e17..23085d27ace6 100644 --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig @@ -169,6 +169,17 @@ config DWMAC_SOCFPGA for the stmmac device driver. This driver is used for arria5 and cyclone5 FPGA SoCs. +config DWMAC_SOPHGO + tristate "Sophgo dwmac support" + depends on OF && (ARCH_SOPHGO || COMPILE_TEST) + default m if ARCH_SOPHGO + help + Support for ethernet controllers on Sophgo RISC-V SoCs + + This selects the Sophgo SoC specific glue layer support + for the stmmac device driver. This driver is used for the + ethernet controllers on various Sophgo SoCs. + config DWMAC_STARFIVE tristate "StarFive dwmac support" depends on OF && (ARCH_STARFIVE || COMPILE_TEST) diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile index 2389fd261344..36f21c86568d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/Makefile +++ b/drivers/net/ethernet/stmicro/stmmac/Makefile @@ -23,6 +23,7 @@ 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_SOPHGO) += dwmac-sophgo.o obj-$(CONFIG_DWMAC_STARFIVE) += dwmac-starfive.o obj-$(CONFIG_DWMAC_STI) += dwmac-sti.o obj-$(CONFIG_DWMAC_STM32) += dwmac-stm32.o diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c new file mode 100644 index 000000000000..a4997cc0294a --- /dev/null +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c @@ -0,0 +1,105 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Sophgo DWMAC platform driver + * + * Copyright (C) 2024 Inochi Amaoto + */ + +#include +#include +#include +#include + +#include "stmmac_platform.h" + +struct sophgo_dwmac { + struct device *dev; + struct clk *clk_tx; +}; + +static void sophgo_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) +{ + struct sophgo_dwmac *dwmac = priv; + long rate; + int ret; + + rate = rgmii_clock(speed); + if (rate < 0) { + dev_err(dwmac->dev, "invalid speed %u\n", speed); + return; + } + + ret = clk_set_rate(dwmac->clk_tx, rate); + if (ret) + dev_err(dwmac->dev, "failed to set tx rate %lu: %pe\n", + rate, ERR_PTR(ret)); +} + +static int sophgo_sg2044_dwmac_init(struct platform_device *pdev, + struct plat_stmmacenet_data *plat_dat, + struct stmmac_resources *stmmac_res) +{ + struct sophgo_dwmac *dwmac; + + dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); + if (!dwmac) + return -ENOMEM; + + 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), + "failed to get tx clock\n"); + + dwmac->dev = &pdev->dev; + plat_dat->bsp_priv = dwmac; + plat_dat->flags |= STMMAC_FLAG_SPH_DISABLE; + plat_dat->fix_mac_speed = sophgo_dwmac_fix_mac_speed; + plat_dat->multicast_filter_bins = 0; + plat_dat->unicast_filter_entries = 1; + + return 0; +} + +static int sophgo_dwmac_probe(struct platform_device *pdev) +{ + struct plat_stmmacenet_data *plat_dat; + struct stmmac_resources stmmac_res; + int ret; + + ret = stmmac_get_platform_resources(pdev, &stmmac_res); + if (ret) + return dev_err_probe(&pdev->dev, ret, + "failed to get resources\n"); + + plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac); + if (IS_ERR(plat_dat)) + return dev_err_probe(&pdev->dev, PTR_ERR(plat_dat), + "dt configuration failed\n"); + + ret = sophgo_sg2044_dwmac_init(pdev, plat_dat, &stmmac_res); + if (ret) + return ret; + + return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); +} + +static const struct of_device_id sophgo_dwmac_match[] = { + { .compatible = "sophgo,sg2044-dwmac" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, sophgo_dwmac_match); + +static struct platform_driver sophgo_dwmac_driver = { + .probe = sophgo_dwmac_probe, + .remove = stmmac_pltfr_remove, + .driver = { + .name = "sophgo-dwmac", + .pm = &stmmac_pltfr_pm_ops, + .of_match_table = sophgo_dwmac_match, + }, +}; +module_platform_driver(sophgo_dwmac_driver); + +MODULE_AUTHOR("Inochi Amaoto "); +MODULE_DESCRIPTION("Sophgo DWMAC platform driver"); +MODULE_LICENSE("GPL");