Skip to contentSkip to conversation

Move Loongson1 MAC arch-code to the driver dir

PATCH Superseded Keguang Zhang 4 participants 20 messages Aug 16, 2023 – Aug 23, 2023

Subsystems (8)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Keguang Zhang

author maintainer
#0 lore raw

v2 cover Move Loongson1 MAC arch-code to the driver dir

In order to convert Loongson1 MAC platform devices to the devicetree nodes, Loongson1 MAC arch-code should be moved to the driver dir. Add dt-binding document and update MAINTAINERS file accordingly.

In other words, this patchset is a preparation for converting Loongson1 platform devices to devicetree.

Changelog
V1 -> V2: Leave the Ethernet platform data for now
Make the syscon compatibles more specific 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
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
Improve the commit message

Keguang Zhang (4):
dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon
dt-bindings: net: Add Loongson-1 DWMAC glue layer
net: stmmac: Add glue layer for Loongson-1 SoC
MAINTAINERS: Update MIPS/LOONGSON1 entry

 .../devicetree/bindings/mfd/syscon.yaml       |   2 +
 .../bindings/net/loongson,ls1x-dwmac.yaml     |  98 +++++++
 MAINTAINERS                                   |   2 +
 drivers/net/ethernet/stmicro/stmmac/Kconfig   |  11 +
 drivers/net/ethernet/stmicro/stmmac/Makefile  |   1 +
 .../ethernet/stmicro/stmmac/dwmac-loongson1.c | 273 ++++++++++++++++++
 6 files changed, 387 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/loongson,ls1x-dwmac.yaml
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c

base-commit: ef66bf8aeb91fd331cf8f5dca8f9d7bca9ab2849

Signature · 1 line
2.39.2
author maintainer
#1 lore raw

PATCH v2 1/4 dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon

Add Loongson LS1B and LS1C compatibles for system controller.

---
V1 -> V2: Make the syscon compatibles more specific

 Documentation/devicetree/bindings/mfd/syscon.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/mfd/syscon.yaml +2 -0
index 8103154bbb52..d701fff02abe 100644
@@ -49,6 +49,8 @@ properties:
               - hisilicon,peri-subctrl
               - hpe,gxp-sysreg
               - intel,lgm-syscon
+              - loongson,ls1b-dwmac-syscon
+              - loongson,ls1c-dwmac-syscon
               - marvell,armada-3700-usb2-host-misc
               - mediatek,mt8135-pctl-a-syscfg
               - mediatek,mt8135-pctl-b-syscfg
Signature · 1 line
2.39.2
#2 lore raw

Re: [PATCH v2 1/4] dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon

Quoted 1 line · Keguang Zhang

Add Loongson LS1B and LS1C compatibles for system controller.

I asked not to use the same compatible for different blocks. Compatible is dwmac, but are you still going to use for other blocks? Please write proper description of the hardware.

Quoted 13 lines

---
V1 -> V2: Make the syscon compatibles more specific

 Documentation/devicetree/bindings/mfd/syscon.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/mfd/syscon.yaml +0 -0
index 8103154bbb52..d701fff02abe 100644

Documentation/devicetree/bindings/mfd/syscon.yaml properties: · line 53

Quoted 5 lines
Documentation/devicetree/bindings/mfd/syscon.yaml +2 -0
@@ -49,6 +49,8 @@ properties:
               - hisilicon,peri-subctrl
               - hpe,gxp-sysreg
               - intel,lgm-syscon
+              - loongson,ls1b-dwmac-syscon
+              - loongson,ls1c-dwmac-syscon

Best regards,
Krzysztof

author maintainer
#3 lore raw

Re: [PATCH v2 1/4] dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon

Quoted 8 lines · Krzysztof Kozlowski
Quoted 1 line · Keguang Zhang

Add Loongson LS1B and LS1C compatibles for system controller.

I asked not to use the same compatible for different blocks. Compatible is dwmac, but are you still going to use for other blocks? Please write proper description of the hardware.

Sorry. I didn't make myself clear.
The SoC only has one syscon with two registers.
And Each register contains settings for multiple devices. Besides DWMAC, this syscon will be used for other devices. Should I keep using loongson,ls1b-syscon/loongson,ls1c-syscon?

Quoted 8 lines
Quoted 8 lines

---
V1 -> V2: Make the syscon compatibles more specific

 Documentation/devicetree/bindings/mfd/syscon.yaml | 2 ++
 1 file changed, 2 insertions(+)
Quoted 15 lines

Documentation/devicetree/bindings/mfd/syscon.yaml properties: · line 53

Quoted 10 lines
Documentation/devicetree/bindings/mfd/syscon.yaml +2 -0
index 8103154bbb52..d701fff02abe 100644
@@ -49,6 +49,8 @@ properties:
               - hisilicon,peri-subctrl
               - hpe,gxp-sysreg
               - intel,lgm-syscon
+              - loongson,ls1b-dwmac-syscon
+              - loongson,ls1c-dwmac-syscon

Best regards,
Krzysztof

--
Best regards,

Keguang Zhang

#4 lore raw

Re: [PATCH v2 1/4] dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon

Quoted 10 lines · Keguang Zhang
Quoted 8 lines · Krzysztof Kozlowski
Quoted 1 line · Keguang Zhang

Add Loongson LS1B and LS1C compatibles for system controller.

I asked not to use the same compatible for different blocks. Compatible is dwmac, but are you still going to use for other blocks? Please write proper description of the hardware.

Quoted 5 lines

Sorry. I didn't make myself clear.
The SoC only has one syscon with two registers.
And Each register contains settings for multiple devices. Besides DWMAC, this syscon will be used for other devices. Should I keep using loongson,ls1b-syscon/loongson,ls1c-syscon?

Ah, ok, then the naming of the compatible should reflect the name of this syscon block. If it does not have any name and it is the only syscon, then name like "loongson,ls1b-syscon" is good. If the block has some name - use it in compatible.

Best regards,
Krzysztof

author maintainer
#5 lore raw

PATCH v2 2/4 dt-bindings: net: Add Loongson-1 DWMAC glue layer

In reply to Keguang Zhang

Add devicetree binding document for Loongson-1 DWMAC glue layer.

---
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,ls1x-dwmac.yaml     | 98 +++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/loongson,ls1x-dwmac.yaml
Documentation/devicetree/bindings/net/loongson,ls1x-dwmac.yaml new file +98 -0
new file mode 100644
index 000000000000..cf5477450e29
@@ -0,0 +1,98 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/loongson,ls1x-dwmac.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Loongson-1 DWMAC glue layer
+
+maintainers:
+  - Keguang Zhang <[email protected]>
+
+select:
+  properties:
+    compatible:
+      contains:
+        enum:
+          - loongson,ls1b-dwmac
+          - loongson,ls1c-dwmac
+  required:
+    - compatible
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - loongson,ls1b-dwmac
+          - loongson,ls1c-dwmac
+      - 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,dwmac-syscon:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description:
+      Phandle to the syscon containing some extra configurations
+      including PHY interface mode.
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - interrupts
+  - interrupt-names
+  - loongson,dwmac-syscon
+
+allOf:
+  - $ref: snps,dwmac.yaml#
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/loongson,ls1x-clk.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    gmac0: ethernet@1fe10000 {
+        compatible = "loongson,ls1b-dwmac", "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,dwmac-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>;
+            };
+        };
+    };
Signature · 1 line
2.39.2
Reviewed-by on v2 2/4
#6 lore raw

Re: [PATCH v2 2/4] dt-bindings: net: Add Loongson-1 DWMAC glue layer

Quoted 20 lines · Keguang Zhang

Add devicetree binding document for Loongson-1 DWMAC glue layer.

---
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,ls1x-dwmac.yaml     | 98 +++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/loongson,ls1x-dwmac.yaml
Documentation/devicetree/bindings/net/loongson,ls1x-dwmac.yaml new file +0 -0
new file mode 100644
index 000000000000..cf5477450e29

Documentation/devicetree/bindings/net/loongson,ls1x-dwmac.yaml line 7

Quoted 7 lines
Documentation/devicetree/bindings/net/loongson,ls1x-dwmac.yaml new file +7 -0
@@ -0,0 +1,98 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/loongson,ls1x-dwmac.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Loongson-1 DWMAC glue layer

Please implement Serge's comments about title and description. Rest looks good:

Best regards,
Krzysztof

author maintainer
#7 lore raw

Re: [PATCH v2 2/4] dt-bindings: net: Add Loongson-1 DWMAC glue layer

Quoted 16 lines · Krzysztof Kozlowski
Quoted 14 lines · Keguang Zhang

Add devicetree binding document for Loongson-1 DWMAC glue layer.

---
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,ls1x-dwmac.yaml     | 98 +++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/loongson,ls1x-dwmac.yaml
Quoted 17 lines

Documentation/devicetree/bindings/net/loongson,ls1x-dwmac.yaml line 7

Quoted 13 lines
Documentation/devicetree/bindings/net/loongson,ls1x-dwmac.yaml new file +7 -0
new file mode 100644
index 000000000000..cf5477450e29
@@ -0,0 +1,98 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/loongson,ls1x-dwmac.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Loongson-1 DWMAC glue layer

Please implement Serge's comments about title and description. Rest looks good:

Will do.

Quoted 2 lines

As suggested by Serge, this file will be split into loongson,ls1b-gmac.yaml and loongson,ls1c-mac.yaml.
Due to this significant change, I'm not sure whether I should keep your Reviewed-by tag or not.

Thanks!

Quoted 3 lines

Best regards,
Krzysztof

--
Best regards,

Keguang Zhang

author maintainer
#8 lore raw

PATCH v2 3/4 net: stmmac: Add glue layer for Loongson-1 SoC

In reply to Keguang Zhang

This glue driver is created based on the arch-code implemented earlier with the platform-specific settings.

Use syscon for SYSCON register access.

Partialy based on the previous work by Serge Semin.

---
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 | 273 ++++++++++++++++++
 3 files changed, 285 insertions(+)
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
drivers/net/ethernet/stmicro/stmmac/Kconfig +11 -0
index 06c6871f8788..a2b9e289aa36 100644
@@ -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
drivers/net/ethernet/stmicro/stmmac/Makefile +1 -0
index 5b57aee19267..80e598bd4255 100644
@@ -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
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c new file +273 -0

273 lines not on this page · raw message

Signature · 1 line
2.39.2
reviewer
#9 lore raw

Re: [PATCH v2 3/4] net: stmmac: Add glue layer for Loongson-1 SoC

Quoted 6 lines · Keguang Zhang

This glue driver is created based on the arch-code implemented earlier with the platform-specific settings.

Use syscon for SYSCON register access.

Partialy based on the previous work by Serge Semin.

Hi Keguang Zhang,

as it looks like there will be a v3 for other reasons, a minor nit from my side: Partialy -> Partially

...

author maintainer
#10 lore raw

Re: [PATCH v2 3/4] net: stmmac: Add glue layer for Loongson-1 SoC

Quoted 5 lines · Simon Horman
Quoted 3 lines · Keguang Zhang

This glue driver is created based on the arch-code implemented earlier with the platform-specific settings.

Quoted 9 lines
Quoted 3 lines

Use syscon for SYSCON register access.

Partialy based on the previous work by Serge Semin.

Hi Keguang Zhang,

as it looks like there will be a v3 for other reasons, a minor nit from my side: Partialy -> Partially

Will do.
Thanks!

Quoted 1 line

...

Signature · 3 lines
Best regards,

Keguang Zhang
#11 lore raw

Re: [PATCH v2 3/4] net: stmmac: Add glue layer for Loongson-1 SoC

In reply to Keguang Zhang
Quoted 4 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c new file +4 -0
+static int ls1b_dwmac_syscon_init(struct plat_stmmacenet_data *plat)
+{
+	struct ls1x_dwmac *dwmac = plat->bsp_priv;
+	struct regmap_field **regmap_fields = dwmac->regmap_fields;

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c line 81

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c new file +10 -0
+
+	if (plat->bus_id) {
+		regmap_field_write(regmap_fields[GMAC1_USE_UART1], 1);
+		regmap_field_write(regmap_fields[GMAC1_USE_UART0], 1);
+
+		switch (plat->phy_interface) {
+		case PHY_INTERFACE_MODE_RGMII:
+			regmap_field_write(regmap_fields[GMAC1_USE_TXCLK], 0);
+			regmap_field_write(regmap_fields[GMAC1_USE_PWM23], 0);
+			break;

What about the other three RGMII modes? Plain rgmii is pretty unusual, rgmii-id is the most used.

Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c new file +7 -0
+		case PHY_INTERFACE_MODE_MII:
+			regmap_field_write(regmap_fields[GMAC1_USE_TXCLK], 1);
+			regmap_field_write(regmap_fields[GMAC1_USE_PWM23], 1);
+			break;
+		default:
+			dev_err(dwmac->dev, "Unsupported PHY mode %u\n",
+				plat->phy_interface);

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c line 98

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c new file +10 -0
+			return -EOPNOTSUPP;
+		}
+
+		regmap_field_write(regmap_fields[GMAC1_SHUT], 0);
+	} else {
+		switch (plat->phy_interface) {
+		case PHY_INTERFACE_MODE_RGMII:
+			regmap_field_write(regmap_fields[GMAC0_USE_TXCLK], 0);
+			regmap_field_write(regmap_fields[GMAC0_USE_PWM01], 0);
+			break;

same here.

Andrew

author maintainer
#12 lore raw

Re: [PATCH v2 3/4] net: stmmac: Add glue layer for Loongson-1 SoC

Quoted 10 lines · Andrew Lunn
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c new file +9 -0
+static int ls1b_dwmac_syscon_init(struct plat_stmmacenet_data *plat)
+{
+     struct ls1x_dwmac *dwmac = plat->bsp_priv;
+     struct regmap_field **regmap_fields = dwmac->regmap_fields;
+
+     if (plat->bus_id) {
+             regmap_field_write(regmap_fields[GMAC1_USE_UART1], 1);
+             regmap_field_write(regmap_fields[GMAC1_USE_UART0], 1);
+
Quoted 9 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c line 81

Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c new file +5 -0
+             switch (plat->phy_interface) {
+             case PHY_INTERFACE_MODE_RGMII:
+                     regmap_field_write(regmap_fields[GMAC1_USE_TXCLK], 0);
+                     regmap_field_write(regmap_fields[GMAC1_USE_PWM23], 0);
+                     break;

What about the other three RGMII modes? Plain rgmii is pretty unusual, rgmii-id is the most used.

According to the LS1B datasheet, only RGMII and MII are supported. And I can confirm that MII mode does work for LS1B.

Quoted 21 lines
Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c new file +7 -0
+             case PHY_INTERFACE_MODE_MII:
+                     regmap_field_write(regmap_fields[GMAC1_USE_TXCLK], 1);
+                     regmap_field_write(regmap_fields[GMAC1_USE_PWM23], 1);
+                     break;
+             default:
+                     dev_err(dwmac->dev, "Unsupported PHY mode %u\n",
+                             plat->phy_interface);

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c line 98

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c new file +10 -0
+                     return -EOPNOTSUPP;
+             }
+
+             regmap_field_write(regmap_fields[GMAC1_SHUT], 0);
+     } else {
+             switch (plat->phy_interface) {
+             case PHY_INTERFACE_MODE_RGMII:
+                     regmap_field_write(regmap_fields[GMAC0_USE_TXCLK], 0);
+                     regmap_field_write(regmap_fields[GMAC0_USE_PWM01], 0);
+                     break;

same here.

Andrew

Signature · 3 lines
Best regards,

Keguang Zhang
author maintainer
#13 lore raw

Re: [PATCH v2 3/4] net: stmmac: Add glue layer for Loongson-1 SoC

Quoted 21 lines · Keguang Zhang
Quoted 10 lines · Andrew Lunn
Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c new file +9 -0
+static int ls1b_dwmac_syscon_init(struct plat_stmmacenet_data *plat)
+{
+     struct ls1x_dwmac *dwmac = plat->bsp_priv;
+     struct regmap_field **regmap_fields = dwmac->regmap_fields;
+
+     if (plat->bus_id) {
+             regmap_field_write(regmap_fields[GMAC1_USE_UART1], 1);
+             regmap_field_write(regmap_fields[GMAC1_USE_UART0], 1);
+
Quoted 9 lines

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c line 81

Quoted 5 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c new file +5 -0
+             switch (plat->phy_interface) {
+             case PHY_INTERFACE_MODE_RGMII:
+                     regmap_field_write(regmap_fields[GMAC1_USE_TXCLK], 0);
+                     regmap_field_write(regmap_fields[GMAC1_USE_PWM23], 0);
+                     break;

What about the other three RGMII modes? Plain rgmii is pretty unusual, rgmii-id is the most used.

Quoted 3 lines

According to the LS1B datasheet, only RGMII and MII are supported. And I can confirm that MII mode does work for LS1B.

Sorry! The RGMII mode does work for LS1B.

Quoted 28 lines
Quoted 18 lines
Quoted 7 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c new file +7 -0
+             case PHY_INTERFACE_MODE_MII:
+                     regmap_field_write(regmap_fields[GMAC1_USE_TXCLK], 1);
+                     regmap_field_write(regmap_fields[GMAC1_USE_PWM23], 1);
+                     break;
+             default:
+                     dev_err(dwmac->dev, "Unsupported PHY mode %u\n",
+                             plat->phy_interface);

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c line 98

Quoted 10 lines
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c new file +10 -0
+                     return -EOPNOTSUPP;
+             }
+
+             regmap_field_write(regmap_fields[GMAC1_SHUT], 0);
+     } else {
+             switch (plat->phy_interface) {
+             case PHY_INTERFACE_MODE_RGMII:
+                     regmap_field_write(regmap_fields[GMAC0_USE_TXCLK], 0);
+                     regmap_field_write(regmap_fields[GMAC0_USE_PWM01], 0);
+                     break;
Quoted 3 lines

same here.

Andrew

--
Best regards,

Keguang Zhang

Signature · 3 lines
Best regards,

Keguang Zhang
#14 lore raw

Re: [PATCH v2 3/4] net: stmmac: Add glue layer for Loongson-1 SoC

Quoted 1 line

Sorry! The RGMII mode does work for LS1B.

and the question then is: How does it work?

Andrew

#15 lore raw

Re: [PATCH v2 3/4] net: stmmac: Add glue layer for Loongson-1 SoC

In reply to Keguang Zhang
Quoted 5 lines
Quoted 3 lines

What about the other three RGMII modes? Plain rgmii is pretty unusual, rgmii-id is the most used.

According to the LS1B datasheet, only RGMII and MII are supported. And I can confirm that MII mode does work for LS1B.

What does your device tree look like? What are you setting phy-mode to in the rgmii case? As i said, "rgmii" is pretty unusual, you normally need "rgmii-id".

Something in the system needs to add 2ns delays to the RGMII clock lines. Generally in device tree you pass phy-mode = "rgmii-id"; The MAC configures itself for RGMII, and passes PHY_INTERFACE_MODE_RGMII_ID to the PHY when it is attached. The PHY then inserts the delays.

What is inserting the delays in your system?

Andrew

author maintainer
#16 lore raw

Re: [PATCH v2 3/4] net: stmmac: Add glue layer for Loongson-1 SoC

Quoted 11 lines · Andrew Lunn
Quoted 6 lines
Quoted 4 lines

What about the other three RGMII modes? Plain rgmii is pretty unusual, rgmii-id is the most used.

According to the LS1B datasheet, only RGMII and MII are supported. And I can confirm that MII mode does work for LS1B.

What does your device tree look like? What are you setting phy-mode to in the rgmii case? As i said, "rgmii" is pretty unusual, you normally need "rgmii-id".

Quoted 8 lines

Something in the system needs to add 2ns delays to the RGMII clock lines. Generally in device tree you pass phy-mode = "rgmii-id"; The MAC configures itself for RGMII, and passes PHY_INTERFACE_MODE_RGMII_ID to the PHY when it is attached. The PHY then inserts the delays.

What is inserting the delays in your system?

I understand the delay issue of RGMII.
Just tried phy-mode = "rgmii-id", it still works.
I will use PHY_INTERFACE_MODE_RGMII_ID instead.
Thanks!

Quoted 2 lines

Andrew

Signature · 3 lines
Best regards,

Keguang Zhang
#17 lore raw

Re: [PATCH v2 3/4] net: stmmac: Add glue layer for Loongson-1 SoC

Quoted 2 lines

I understand the delay issue of RGMII.
Just tried phy-mode = "rgmii-id", it still works.

That indicates something is broken. Both "rgmii-id" and "rgmii" should not work, just one of them. What PHY driver are you using?

Andrew

author maintainer
#18 lore raw

Re: [PATCH v2 3/4] net: stmmac: Add glue layer for Loongson-1 SoC

Quoted 7 lines · Andrew Lunn
Quoted 3 lines

I understand the delay issue of RGMII.
Just tried phy-mode = "rgmii-id", it still works.

That indicates something is broken. Both "rgmii-id" and "rgmii" should not work, just one of them. What PHY driver are you using?

I used generic PHY driver.
Both "rgmii" and "rgmii-id" work with this driver. The PHY is RTL8211E.
So I switch the PHY driver to Realtek driver. Now only "rgmii-id" works.
Thanks!

Quoted 2 lines

Andrew

--
Best regards,

Keguang Zhang

author maintainer
#19 lore raw

PATCH v2 4/4 MAINTAINERS: Update MIPS/LOONGSON1 entry

In reply to Keguang Zhang

Add a new F: entry for Loongson1 DWMAC driver. Add a new F: entry for all Loongson-1 dt-bindings.

---
V1 -> V2: Improve the commit message

 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
index d8700b009e22..4621facb2cc8 100644
@@ -14313,9 +14313,11 @@ MIPS/LOONGSON1 ARCHITECTURE
 M:	Keguang Zhang <[email protected]>
 L:	[email protected]
 S:	Maintained
+F:	Documentation/devicetree/bindings/*/loongson,ls1x-*.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 <[email protected]>
Signature · 1 line
2.39.2