From patchwork Thu Aug 24 12:50:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keguang Zhang X-Patchwork-Id: 13364092 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4892CC83003 for ; Thu, 24 Aug 2023 12:51:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235830AbjHXMvO (ORCPT ); Thu, 24 Aug 2023 08:51:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241053AbjHXMuu (ORCPT ); Thu, 24 Aug 2023 08:50:50 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20D71E59; Thu, 24 Aug 2023 05:50:48 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-68a6f6a66e1so2158579b3a.2; Thu, 24 Aug 2023 05:50:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692881447; x=1693486247; 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=AEnO7+4Ucyc9S7UpaeQH2qCtWkbPSwVUI/lztRqRSCc=; b=Kr6KYeCCzb1FqfLDm6L/W1YznkJbI1MLy6qfy0p+SER8/Prvxn0y4XmUOSIbvPQsb7 Xc3ZMXp9wQk7quwnGfLAG1eGRPXEnY7FYeIponpEvKcnsExgsKSHwQgqoImCbMotFbMX MO5bjZO5elRElvvrKOYRi25s82SeQQDvc3IsavH4aEMz0rJd1vuleTluBImYLx1R13rf PPF4IjwOMdtJW8u3wWrgCs8JmMUlsyWSsXZ/vSM/NbcJHDkdRwMN/Bq2fK2ZLhBS/AaV xrQkdDroHORBaHDUwEzneYavGYjWZ/Lcv4Q3is7Y9LdGgrQgEDDkUVX10wk0mxYIDG+O l2bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692881447; x=1693486247; 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=AEnO7+4Ucyc9S7UpaeQH2qCtWkbPSwVUI/lztRqRSCc=; b=g1ccNZDoiEZoUVYsp6RTIRI0oKGlouXm6h29urIr+XmHKd1UAgPFc2rkl7AW8Y8BXl 6ZUloZVg4Zf5WT9u+L48IRtvp7G7oy3Mppw2N9bGZTjdIbmteAaIAXEJ8rePktqWzDl1 NBWyHj/2sSYNvMWoRlD4VQeCyMI2Eq+U/UledExDktVRM/jZhyVWg2umxxL/I6z9Xze5 ScJcOqeS5a13/xGQqFzEke+UYgWhPys1Us6J40oUxTBorVAsnI555nWsI9wXQRMrN34V m+ZTjeQNGpTQ1qgP9NhT93oESyJKzkFgdhzleUkvWkvxkfz6qsnrxe+2CSapPWH7or7D BG+w== X-Gm-Message-State: AOJu0YzVsjZ7nF4lxo+zlJp8Bil+5mTvfi3b9+q+w++7dxCp5TnBdj5U 32FnNhkC+8wCUF406rQxqF5zjLgSIwTwSeGP X-Google-Smtp-Source: AGHT+IEJezqgxyuKMZOPnyEl/qqvBIYOTw8oxxpD1uk5UcTBbkSzuwhIiGs7TIDE/ERjC4BUcN0WxA== X-Received: by 2002:a05:6a20:969a:b0:13d:c70d:de62 with SMTP id hp26-20020a056a20969a00b0013dc70dde62mr11644803pzc.22.1692881447110; Thu, 24 Aug 2023 05:50:47 -0700 (PDT) Received: from kelvin-ThinkPad-L14-Gen-1.lan ([103.184.129.7]) by smtp.gmail.com with ESMTPSA id 19-20020a170902c11300b001afd821c057sm12837295pli.58.2023.08.24.05.50.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 05:50:46 -0700 (PDT) From: Keguang Zhang To: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Thomas Bogendoerfer , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Serge Semin , Keguang Zhang Subject: [PATCH v3 1/4] dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon Date: Thu, 24 Aug 2023 20:50:09 +0800 Message-Id: <20230824125012.1040288-2-keguang.zhang@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230824125012.1040288-1-keguang.zhang@gmail.com> References: <20230824125012.1040288-1-keguang.zhang@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org Add Loongson LS1B and LS1C compatibles for system controller. Signed-off-by: Keguang Zhang Acked-by: Krzysztof Kozlowski --- V2 -> V3: Change compatibles back to loongson,ls1b-syscon and loongson,ls1c-syscon V1 -> V2: Make the syscon compatibles more specific Documentation/devicetree/bindings/mfd/syscon.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/mfd/syscon.yaml b/Documentation/devicetree/bindings/mfd/syscon.yaml index 8103154bbb52..c77d7b155a4c 100644 --- a/Documentation/devicetree/bindings/mfd/syscon.yaml +++ b/Documentation/devicetree/bindings/mfd/syscon.yaml @@ -49,6 +49,8 @@ properties: - hisilicon,peri-subctrl - hpe,gxp-sysreg - intel,lgm-syscon + - loongson,ls1b-syscon + - loongson,ls1c-syscon - marvell,armada-3700-usb2-host-misc - mediatek,mt8135-pctl-a-syscfg - mediatek,mt8135-pctl-b-syscfg From patchwork Thu Aug 24 12:50:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keguang Zhang X-Patchwork-Id: 13364095 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B77B8EE49A3 for ; Thu, 24 Aug 2023 12:51:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240573AbjHXMvQ (ORCPT ); Thu, 24 Aug 2023 08:51:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241108AbjHXMuz (ORCPT ); Thu, 24 Aug 2023 08:50:55 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5002CD0; Thu, 24 Aug 2023 05:50:52 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1bc63ef9959so52273475ad.2; Thu, 24 Aug 2023 05:50:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692881452; x=1693486252; 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=WUXscSapF9yGyR5ril9a18hQD4+b8Ok8ZJpFPuWKi8s=; b=KSx8Ak4b1VIS6QGZC5sHaLiSi94U4eEHlRE6nxttTgYzEtAdBO4DtAiXzaED3E36TZ ZcEioTzigs+ojfl0fse4RG6f1SYbfYmtE7QmGQfodPAMJBBRQUikDSqYadeZ0jScqTAn VPWf/BcitOg6H/KzaVk3BgKIvT8tgx0KgWfgAmrh62HLZO7bzNbL4ITZ/q7UA78hrqH9 BYQAsfPwSMgH0rlkvBLNIhkSmNjKtMafjpmOeSFUTwiJ5sezaShx07hzQ2X6Ppt9LpuU rB4PDSCDP03mDoArJRNQcdE9c7Z9Isgl0fga8TtKzqkfiyH/4Dee6HFKAjXWkgSy1+Ir mxrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692881452; x=1693486252; 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=WUXscSapF9yGyR5ril9a18hQD4+b8Ok8ZJpFPuWKi8s=; b=IeMi53vipn5poQ24kBUMOXofhGXh36dZhRVewKyuasrua3KoTl0K2+TDjzw3PzEesb Cb3NkILlmPAQ5IQtcGKeJYMqUaOnP7OHdz6YpJM5QZsuFg5WMqPdhkeCQylvkySHHqxX BzPF5hqFgg8p9LF64PlQ1z4EzHxCN9bNbCLhQGE+1HfAvmIY/4NeUw+Wx539ur38/EC+ anvNzn81u2amO4cYQihZXLUogU6BgjKY3JM2oRBKlwHaqNloC0keVjLplGE8PqQbLuo/ lvi/vt4cxJKmR3usHbvZp8ElkB1lH0JriGqNMBJ/tQ/xNusznQjJIYwg7lHf+uCui0Zf AsMA== X-Gm-Message-State: AOJu0YyoQMlqKp+dD1V3OiDX7KiCXKEf54ABR1uG17JbZHGz5CiLDZLu n/TnuDG/7ZKKy5TErJPVnoZXiExG5PsOdh5J X-Google-Smtp-Source: AGHT+IFyXMoHbZwQKpothocwplbnduuSnD772GzGJmdhqm+QCGN0yBbigjTudUUHmLan3m4uRc+nmQ== X-Received: by 2002:a17:902:c411:b0:1bf:73ec:b977 with SMTP id k17-20020a170902c41100b001bf73ecb977mr17424627plk.46.1692881451760; Thu, 24 Aug 2023 05:50:51 -0700 (PDT) Received: from kelvin-ThinkPad-L14-Gen-1.lan ([103.184.129.7]) by smtp.gmail.com with ESMTPSA id 19-20020a170902c11300b001afd821c057sm12837295pli.58.2023.08.24.05.50.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 05:50:51 -0700 (PDT) From: Keguang Zhang To: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Thomas Bogendoerfer , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Serge Semin , Keguang Zhang , Krzysztof Kozlowski Subject: [PATCH v3 2/4] dt-bindings: net: Add Loongson-1 Ethernet Controller Date: Thu, 24 Aug 2023 20:50:10 +0800 Message-Id: <20230824125012.1040288-3-keguang.zhang@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230824125012.1040288-1-keguang.zhang@gmail.com> References: <20230824125012.1040288-1-keguang.zhang@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org Add devicetree binding document for Loongson-1 Ethernet controller. Signed-off-by: Keguang Zhang Reviewed-by: Krzysztof Kozlowski --- V2 -> V3: Split the DT-schema file into loongson,ls1b-gmac.yaml and loongson,ls1c-emac.yaml (suggested by Serge Semin) Change the compatibles to loongson,ls1b-gmac and loongson,ls1c-emac Rename loongson,dwmac-syscon to loongson,ls1-syscon Amend the title Add description Add Reviewed-by tag from Krzysztof Kozlowski(Sorry! I'm not sure) V1 -> V2: Fix "clock-names" and "interrupt-names" property Rename the syscon property to "loongson,dwmac-syscon" Drop "phy-handle" and "phy-mode" requirement Revert adding loongson,ls1b-dwmac/loongson,ls1c-dwmac to snps,dwmac.yaml .../bindings/net/loongson,ls1b-gmac.yaml | 115 ++++++++++++++++++ .../bindings/net/loongson,ls1c-emac.yaml | 114 +++++++++++++++++ 2 files changed, 229 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml create mode 100644 Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml diff --git a/Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml b/Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml new file mode 100644 index 000000000000..f661d5b86649 --- /dev/null +++ b/Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml @@ -0,0 +1,115 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/loongson,ls1b-gmac.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Loongson-1B Gigabit Ethernet MAC Controller + +maintainers: + - Keguang Zhang + +description: + Loongson-1B Gigabit Ethernet MAC Controller is based on + Synopsys DesignWare MAC (version 3.50a). + + Main features + - Dual 10/100/1000Mbps GMAC controllers + - Full-duplex operation (IEEE 802.3x flow control automatic transmission) + - Half-duplex operation (CSMA/CD Protocol and back-pressure support) + - RX Checksum Offload + - TX Checksum insertion + - MII interface + - RGMII interface + +select: + properties: + compatible: + contains: + enum: + - loongson,ls1b-gmac + required: + - compatible + +properties: + compatible: + items: + - enum: + - loongson,ls1b-gmac + - const: snps,dwmac-3.50a + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + clock-names: + items: + - const: stmmaceth + + interrupts: + maxItems: 1 + + interrupt-names: + items: + - const: macirq + + loongson,ls1-syscon: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the syscon containing some extra configurations + including PHY interface mode. + + phy-mode: + items: + - enum: + - mii + - rgmii-id + +required: + - compatible + - reg + - clocks + - clock-names + - interrupts + - interrupt-names + - loongson,ls1-syscon + +allOf: + - $ref: snps,dwmac.yaml# + +unevaluatedProperties: false + +examples: + - | + #include + #include + + gmac0: ethernet@1fe10000 { + compatible = "loongson,ls1b-gmac", "snps,dwmac-3.50a"; + reg = <0x1fe10000 0x10000>; + + clocks = <&clkc LS1X_CLKID_AHB>; + clock-names = "stmmaceth"; + + interrupt-parent = <&intc1>; + interrupts = <2 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "macirq"; + + loongson,ls1-syscon = <&syscon>; + + phy-handle = <&phy0>; + phy-mode = "mii"; + snps,pbl = <1>; + + mdio { + #address-cells = <1>; + #size-cells = <0>; + compatible = "snps,dwmac-mdio"; + + phy0: ethernet-phy@0 { + reg = <0x0>; + }; + }; + }; diff --git a/Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml b/Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml new file mode 100644 index 000000000000..1ffad41941bf --- /dev/null +++ b/Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml @@ -0,0 +1,114 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/loongson,ls1c-emac.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Loongson-1C Ethernet MAC Controller + +maintainers: + - Keguang Zhang + +description: + Loongson-1C Ethernet MAC Controller is based on + Synopsys DesignWare MAC (version 3.50a). + + Main features + - 10/100Mbps + - Full-duplex operation (IEEE 802.3x flow control automatic transmission) + - Half-duplex operation (CSMA/CD Protocol and back-pressure support) + - IEEE 802.1Q VLAN tag detection for reception frames + - MII interface + - RMII interface + +select: + properties: + compatible: + contains: + enum: + - loongson,ls1c-emac + required: + - compatible + +properties: + compatible: + items: + - enum: + - loongson,ls1c-emac + - const: snps,dwmac-3.50a + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + clock-names: + items: + - const: stmmaceth + + interrupts: + maxItems: 1 + + interrupt-names: + items: + - const: macirq + + loongson,ls1-syscon: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the syscon containing some extra configurations + including PHY interface mode. + + phy-mode: + items: + - enum: + - mii + - rmii + +required: + - compatible + - reg + - clocks + - clock-names + - interrupts + - interrupt-names + - loongson,ls1-syscon + +allOf: + - $ref: snps,dwmac.yaml# + +unevaluatedProperties: false + +examples: + - | + #include + #include + + emac: ethernet@1fe10000 { + compatible = "loongson,ls1c-emac", "snps,dwmac-3.50a"; + reg = <0x1fe10000 0x10000>; + + clocks = <&clkc LS1X_CLKID_AHB>; + clock-names = "stmmaceth"; + + interrupt-parent = <&intc1>; + interrupts = <2 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "macirq"; + + loongson,ls1-syscon = <&syscon>; + + phy-handle = <&phy0>; + phy-mode = "mii"; + snps,pbl = <1>; + + mdio { + #address-cells = <1>; + #size-cells = <0>; + compatible = "snps,dwmac-mdio"; + + phy0: ethernet-phy@13 { + reg = <0x13>; + }; + }; + }; From patchwork Thu Aug 24 12:50:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keguang Zhang X-Patchwork-Id: 13364096 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C72CAEE49AB for ; Thu, 24 Aug 2023 12:51:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240742AbjHXMvR (ORCPT ); Thu, 24 Aug 2023 08:51:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241118AbjHXMu7 (ORCPT ); Thu, 24 Aug 2023 08:50:59 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DDD1CD0; Thu, 24 Aug 2023 05:50:57 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-68a3b66f350so4268375b3a.3; Thu, 24 Aug 2023 05:50:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692881456; x=1693486256; 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=b2qJ+ZrE2rzRm3KwJwNRefCH5p7DDBNIE1s+DWcekf0=; b=KNy3mkRfpXrDFNb4pEQ1bSCkG3nDncH/8rFKxkV8NUK5KsNcj7g+3ZxHxJlXEU0HFm 8cqs1VASeUGmB951dZWObLPT9+xHKRVBBSnV8W+HprgDJelj1Vm4v5AxwZPkD+PvJ+ph 2fWZVJkMi2E2vnjs+yldnt6+3YB00R7cCDvk22kJOCgWbK1D1LEow+jwnwy5Xp66gcEb jXqUHC8lIXfUV3Z7y7MQQs/MwNhTP91ZAtZU468XhGOqJS3nh9emQrnOoxKHFVTizZq8 hADjVXYP5ETWedWzA0R2AuSMn7EXp6zXc+b/oVMwGH2K8smrexUrRwKW3bGdfRgU0WBW hhjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692881456; x=1693486256; 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=b2qJ+ZrE2rzRm3KwJwNRefCH5p7DDBNIE1s+DWcekf0=; b=fmUpht2iPrjL4yQlFnT6mshHpwWMu2UUCw/+FSq9A5ax9H9GfNdsjnVD8hjoK0exG3 fn5XUUDMd5c8XPRR/e0hcAWD8LeYtqghB5hdAt3NuZfpDszx/GLqrV8tudJLCsaJgUWs fen9D03N2gTOAJon9tvGqsIyvwwFcaqZgMXfUgjPGozvjh1+X0up0R9S3bn4FtN2v5kt c2sZv4JlwtVLnxQtD5KQJs8j26jmqfBMpCGrT7yCbTMsshScfN+DyruMDV9aVvZ8yWCr RCStNHbY0V/B7y0UNSHriFgK+YwRkAkc0msyrhsW0Q/1aPBD0haseMm1Ow8wxxixNC6P VlMA== X-Gm-Message-State: AOJu0YwNAd2QQhVGegM+TmhJrom+yV1B0J1k9GyEAPUGhWHrozigfWrl roI+S65fqEYsByKiGTNJYbgJSxWPDyOBX+TN X-Google-Smtp-Source: AGHT+IHs+SBXK7T/NEjvUUeGBnWj2OMsKKo8fCDtKIuoqZNtLVyGBLkZCLRAMGU1VqCjyUd3KBRbKA== X-Received: by 2002:a05:6a20:3ca7:b0:149:7a49:f7be with SMTP id b39-20020a056a203ca700b001497a49f7bemr10374697pzj.4.1692881456111; Thu, 24 Aug 2023 05:50:56 -0700 (PDT) Received: from kelvin-ThinkPad-L14-Gen-1.lan ([103.184.129.7]) by smtp.gmail.com with ESMTPSA id 19-20020a170902c11300b001afd821c057sm12837295pli.58.2023.08.24.05.50.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 05:50:55 -0700 (PDT) From: Keguang Zhang To: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Thomas Bogendoerfer , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Serge Semin , Keguang Zhang Subject: [PATCH v3 3/4] net: stmmac: Add glue layer for Loongson-1 SoC Date: Thu, 24 Aug 2023 20:50:11 +0800 Message-Id: <20230824125012.1040288-4-keguang.zhang@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230824125012.1040288-1-keguang.zhang@gmail.com> References: <20230824125012.1040288-1-keguang.zhang@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org This glue driver is created based on the arch-code implemented earlier with the platform-specific settings. Use syscon for SYSCON register access. Partially based on the previous work by Serge Semin. Signed-off-by: Keguang Zhang --- V2 -> V3: Determine the device ID by physical base address(suggested by Serge Semin) Use regmap instead of regmap fields Use syscon_regmap_lookup_by_phandle() Some minor fixes V1 -> V2: Fix the build errors due to CONFIG_OF being unset Change struct reg_field definitions to const Rename the syscon property to "loongson,dwmac-syscon" Add MII PHY mode for LS1C drivers/net/ethernet/stmicro/stmmac/Kconfig | 11 + drivers/net/ethernet/stmicro/stmmac/Makefile | 1 + .../ethernet/stmicro/stmmac/dwmac-loongson1.c | 240 ++++++++++++++++++ 3 files changed, 252 insertions(+) create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig index 06c6871f8788..a2b9e289aa36 100644 --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig @@ -239,6 +239,17 @@ config DWMAC_INTEL_PLAT the stmmac device driver. This driver is used for the Intel Keem Bay SoC. +config DWMAC_LOONGSON1 + tristate "Loongson1 GMAC support" + default MACH_LOONGSON32 + depends on OF && (MACH_LOONGSON32 || COMPILE_TEST) + help + Support for ethernet controller on Loongson1 SoC. + + This selects Loongson1 SoC glue layer support for the stmmac + device driver. This driver is used for Loongson1-based boards + like Loongson LS1B/LS1C. + config DWMAC_TEGRA tristate "NVIDIA Tegra MGBE support" depends on ARCH_TEGRA || COMPILE_TEST diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile index 5b57aee19267..80e598bd4255 100644 --- a/drivers/net/ethernet/stmicro/stmmac/Makefile +++ b/drivers/net/ethernet/stmicro/stmmac/Makefile @@ -29,6 +29,7 @@ obj-$(CONFIG_DWMAC_SUNXI) += dwmac-sunxi.o obj-$(CONFIG_DWMAC_SUN8I) += dwmac-sun8i.o obj-$(CONFIG_DWMAC_DWC_QOS_ETH) += dwmac-dwc-qos-eth.o obj-$(CONFIG_DWMAC_INTEL_PLAT) += dwmac-intel-plat.o +obj-$(CONFIG_DWMAC_LOONGSON1) += dwmac-loongson1.o obj-$(CONFIG_DWMAC_GENERIC) += dwmac-generic.o obj-$(CONFIG_DWMAC_IMX8) += dwmac-imx.o obj-$(CONFIG_DWMAC_TEGRA) += dwmac-tegra.o diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c new file mode 100644 index 000000000000..347d842141e4 --- /dev/null +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c @@ -0,0 +1,240 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Loongson-1 DWMAC glue layer + * + * Copyright (C) 2011-2023 Keguang Zhang + */ + +#include +#include +#include +#include +#include +#include + +#include "stmmac.h" +#include "stmmac_platform.h" + +#define LS1X_GMAC0_BASE (0xe10000) +#define LS1X_GMAC1_BASE (0xe20000) + +/* Loongson-1 SYSCON Registers */ +#define LS1X_SYSCON0 (0x0) +#define LS1X_SYSCON1 (0x4) + +/* Loongson-1B SYSCON Register Bits */ +#define GMAC1_USE_UART1 BIT(4) +#define GMAC1_USE_UART0 BIT(3) + +#define GMAC1_SHUT BIT(13) +#define GMAC0_SHUT BIT(12) + +#define GMAC1_USE_TXCLK BIT(3) +#define GMAC0_USE_TXCLK BIT(2) +#define GMAC1_USE_PWM23 BIT(1) +#define GMAC0_USE_PWM01 BIT(0) + +/* Loongson-1C SYSCON Register Bits */ +#define GMAC_SHUT BIT(6) + +#define PHY_INTF_SELI GENMASK(30, 28) +#define PHY_INTF_SELI_SHIFT 28 + +struct ls1x_dwmac_syscon { + int (*syscon_init)(struct plat_stmmacenet_data *plat); +}; + +struct ls1x_dwmac { + unsigned long reg_base; + struct device *dev; + struct plat_stmmacenet_data *plat_dat; + const struct ls1x_dwmac_syscon *syscon; + struct regmap *regmap; +}; + +static int ls1b_dwmac_syscon_init(struct plat_stmmacenet_data *plat) +{ + struct ls1x_dwmac *dwmac = plat->bsp_priv; + struct regmap *regmap = dwmac->regmap; + + if ((dwmac->reg_base & LS1X_GMAC0_BASE) == LS1X_GMAC0_BASE) { + switch (plat->phy_interface) { + case PHY_INTERFACE_MODE_RGMII_ID: + regmap_update_bits(regmap, LS1X_SYSCON0, + GMAC0_USE_TXCLK | GMAC0_USE_PWM01, + 0); + break; + case PHY_INTERFACE_MODE_MII: + regmap_update_bits(regmap, LS1X_SYSCON0, + GMAC0_USE_TXCLK | GMAC0_USE_PWM01, + GMAC0_USE_TXCLK | GMAC0_USE_PWM01); + break; + default: + dev_err(dwmac->dev, "Unsupported PHY mode %u\n", + plat->phy_interface); + return -EOPNOTSUPP; + } + + regmap_update_bits(regmap, LS1X_SYSCON0, GMAC0_SHUT, 0); + } + + if ((dwmac->reg_base & LS1X_GMAC1_BASE) == LS1X_GMAC1_BASE) { + regmap_update_bits(regmap, LS1X_SYSCON0, + GMAC1_USE_UART1 | GMAC1_USE_UART0, + GMAC1_USE_UART1 | GMAC1_USE_UART0); + + switch (plat->phy_interface) { + case PHY_INTERFACE_MODE_RGMII_ID: + regmap_update_bits(regmap, LS1X_SYSCON1, + GMAC1_USE_TXCLK | GMAC1_USE_PWM23, + 0); + + break; + case PHY_INTERFACE_MODE_MII: + regmap_update_bits(regmap, LS1X_SYSCON1, + GMAC1_USE_TXCLK | GMAC1_USE_PWM23, + GMAC1_USE_TXCLK | GMAC1_USE_PWM23); + break; + default: + dev_err(dwmac->dev, "Unsupported PHY mode %u\n", + plat->phy_interface); + return -EOPNOTSUPP; + } + + regmap_update_bits(regmap, LS1X_SYSCON1, GMAC1_SHUT, 0); + } + + return 0; +} + +static int ls1c_dwmac_syscon_init(struct plat_stmmacenet_data *plat) +{ + struct ls1x_dwmac *dwmac = plat->bsp_priv; + struct regmap *regmap = dwmac->regmap; + + switch (plat->phy_interface) { + case PHY_INTERFACE_MODE_MII: + regmap_update_bits(regmap, LS1X_SYSCON1, PHY_INTF_SELI, 0); + break; + case PHY_INTERFACE_MODE_RMII: + regmap_update_bits(regmap, LS1X_SYSCON1, PHY_INTF_SELI, + 4 << PHY_INTF_SELI_SHIFT); + break; + default: + dev_err(dwmac->dev, "Unsupported PHY-mode %u\n", + plat->phy_interface); + return -EOPNOTSUPP; + } + + regmap_update_bits(regmap, LS1X_SYSCON0, GMAC0_SHUT, 0); + + return 0; +} + +static const struct ls1x_dwmac_syscon ls1b_dwmac_syscon = { + .syscon_init = ls1b_dwmac_syscon_init, +}; + +static const struct ls1x_dwmac_syscon ls1c_dwmac_syscon = { + .syscon_init = ls1c_dwmac_syscon_init, +}; + +static int ls1x_dwmac_init(struct platform_device *pdev, void *priv) +{ + struct ls1x_dwmac *dwmac = priv; + struct resource *res; + int ret; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(&pdev->dev, "Could not get IO_MEM resources\n"); + return -EINVAL; + } + dwmac->reg_base = (unsigned long)res->start; + + if (dwmac->syscon->syscon_init) { + ret = dwmac->syscon->syscon_init(dwmac->plat_dat); + if (ret) + return ret; + } + + return 0; +} + +static int ls1x_dwmac_probe(struct platform_device *pdev) +{ + struct plat_stmmacenet_data *plat_dat; + struct stmmac_resources stmmac_res; + struct regmap *regmap; + struct ls1x_dwmac *dwmac; + const struct ls1x_dwmac_syscon *syscon; + int ret; + + ret = stmmac_get_platform_resources(pdev, &stmmac_res); + if (ret) + return ret; + + /* Probe syscon */ + regmap = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, + "loongson,ls1-syscon"); + if (IS_ERR(regmap)) { + ret = PTR_ERR(regmap); + dev_err(&pdev->dev, "Unable to map syscon: %d\n", ret); + return ret; + } + + syscon = of_device_get_match_data(&pdev->dev); + if (!syscon) { + dev_err(&pdev->dev, "No of match data provided\n"); + return -EINVAL; + } + + dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); + if (!dwmac) + return -ENOMEM; + + 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); + } + + plat_dat->bsp_priv = dwmac; + plat_dat->init = ls1x_dwmac_init; + dwmac->dev = &pdev->dev; + dwmac->plat_dat = plat_dat; + dwmac->syscon = syscon; + dwmac->regmap = regmap; + + ret = stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res); + if (ret) + goto err_remove_config_dt; + + return 0; + +err_remove_config_dt: + stmmac_remove_config_dt(pdev, plat_dat); + + return ret; +} + +static const struct of_device_id ls1x_dwmac_match[] = { + { .compatible = "loongson,ls1b-gmac", .data = &ls1b_dwmac_syscon, }, + { .compatible = "loongson,ls1c-emac", .data = &ls1c_dwmac_syscon, }, + { } +}; +MODULE_DEVICE_TABLE(of, ls1x_dwmac_match); + +static struct platform_driver ls1x_dwmac_driver = { + .probe = ls1x_dwmac_probe, + .remove_new = stmmac_pltfr_remove, + .driver = { + .name = "loongson1-dwmac", + .of_match_table = ls1x_dwmac_match, + }, +}; +module_platform_driver(ls1x_dwmac_driver); + +MODULE_AUTHOR("Keguang Zhang "); +MODULE_DESCRIPTION("Loongson1 DWMAC glue layer"); +MODULE_LICENSE("GPL"); From patchwork Thu Aug 24 12:50:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keguang Zhang X-Patchwork-Id: 13364093 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21D1FC71145 for ; Thu, 24 Aug 2023 12:51:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240464AbjHXMvP (ORCPT ); Thu, 24 Aug 2023 08:51:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241127AbjHXMvD (ORCPT ); Thu, 24 Aug 2023 08:51:03 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 789B6CD0; Thu, 24 Aug 2023 05:51:01 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1bc83a96067so42213835ad.0; Thu, 24 Aug 2023 05:51:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692881460; x=1693486260; 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=kDfo1abF1Y082BBrZFHZQzYLHOisTvdpROer1sOJEwU=; b=jd0VZmQajINAqsLXp9n23+2+1KPtGpIthpO0CZAlRVylZIpMh4ujG6YwTiR3tZBuwk RLpZgr1je0bYfJGFMGeS3aUNK+A/+CjktG8ViaA/JEbd7xQDBlKJSbUbZ+ttsgBriprX nrHRe4lZdRnyJubEaCzDLsjxoDVNA+/gQobHjRYXZtdH+1YxRJTEm9m/jlrHruz0czn3 RLF7YhqwVdTOoB9PnJdU8HA/YABsQgrxZH4z/wEil53cgrxD/DbNSRtQfgm0J0c3kLHf Ox4RfN2SmJNKgLNatsA1wL79fyyHLgZaVepVaVkbELcYg4CPfzp4xNAGoZ2Dx9qEk0MM GlWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692881460; x=1693486260; 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=kDfo1abF1Y082BBrZFHZQzYLHOisTvdpROer1sOJEwU=; b=YoWHPFI6cvu9DXUr9SLhACJgxA7besC8W0KdGb7h4FgfR9xeDYighwzKsKfnR44jLE RzkFbzSmUJl0CUg6euqy8nnmoSUSRlefZU72/21pC6Vv3enAOFLqEWyy/rXBt6ZGjRGj IHslagduGF7MK1/c+o/T3KPOLq/QSRRM+7/2GHZWhK2uEPlAItheI7HRJT0om9W4T5ot beFA8DJZ/G9+YcYP1HoUIzMuxZMHdXA+9vSIYaHsfoi+VwE45t8Qil3r9+xp49aMcZWK JwjbvGUQ0zvYhYqC4u3VaV6yWN2oMKZQI/g7hQFYnEBC8eSm79SvOsqryNcyYuF8VMt2 5ZfA== X-Gm-Message-State: AOJu0YzgpfVcPXe28nanu7a0bbuJr4D/vZYHBwAupcB+shry9CyRyLkF VZu6wqeDXi9PLYu3BArL4rqEVGEGgsS9jRDl X-Google-Smtp-Source: AGHT+IH1QQxInN2YyhJi1/gXe8Z0jHb1Wi+ficwRqovF5m3ZZocGRw+bUK+J91HtdzoFxOXNDj5+4g== X-Received: by 2002:a17:902:8c85:b0:1bf:13a7:d3ef with SMTP id t5-20020a1709028c8500b001bf13a7d3efmr11086285plo.66.1692881460511; Thu, 24 Aug 2023 05:51:00 -0700 (PDT) Received: from kelvin-ThinkPad-L14-Gen-1.lan ([103.184.129.7]) by smtp.gmail.com with ESMTPSA id 19-20020a170902c11300b001afd821c057sm12837295pli.58.2023.08.24.05.50.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 05:51:00 -0700 (PDT) From: Keguang Zhang To: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Thomas Bogendoerfer , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Serge Semin , Keguang Zhang Subject: [PATCH v3 4/4] MAINTAINERS: Update MIPS/LOONGSON1 entry Date: Thu, 24 Aug 2023 20:50:12 +0800 Message-Id: <20230824125012.1040288-5-keguang.zhang@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230824125012.1040288-1-keguang.zhang@gmail.com> References: <20230824125012.1040288-1-keguang.zhang@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org Add two new F: entries for Loongson1 Ethernet driver and dt-binding document. Add a new F: entry for the rest Loongson-1 dt-binding documents. Signed-off-by: Keguang Zhang --- V2 -> V3: Update the entries and the commit message V1 -> V2: Improve the commit message MAINTAINERS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 250c43c675cb..f462f3d19e4a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14341,9 +14341,12 @@ MIPS/LOONGSON1 ARCHITECTURE M: Keguang Zhang L: linux-mips@vger.kernel.org S: Maintained +F: Documentation/devicetree/bindings/*/loongson,ls1x-*.yaml +F: Documentation/devicetree/bindings/net/loongson,ls1[bc]-*.yaml F: arch/mips/include/asm/mach-loongson32/ F: arch/mips/loongson32/ F: drivers/*/*loongson1* +F: drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c MIPS/LOONGSON2EF ARCHITECTURE M: Jiaxun Yang