* [PATCH v2 0/4] Move Loongson1 MAC arch-code to the driver dir
@ 2023-08-16 11:13 Keguang Zhang
2023-08-16 11:13 ` [PATCH v2 1/4] dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon Keguang Zhang
` (3 more replies)
0 siblings, 4 replies; 20+ messages in thread
From: Keguang Zhang @ 2023-08-16 11:13 UTC (permalink / raw)
To: netdev, devicetree, linux-mips, linux-kernel
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
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
--
2.39.2
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v2 1/4] dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon
2023-08-16 11:13 [PATCH v2 0/4] Move Loongson1 MAC arch-code to the driver dir Keguang Zhang
@ 2023-08-16 11:13 ` Keguang Zhang
2023-08-19 14:23 ` Krzysztof Kozlowski
2023-08-16 11:13 ` [PATCH v2 2/4] dt-bindings: net: Add Loongson-1 DWMAC glue layer Keguang Zhang
` (2 subsequent siblings)
3 siblings, 1 reply; 20+ messages in thread
From: Keguang Zhang @ 2023-08-16 11:13 UTC (permalink / raw)
To: netdev, devicetree, linux-mips, linux-kernel
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
Add Loongson LS1B and LS1C compatibles for system controller.
Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
---
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..d701fff02abe 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-dwmac-syscon
+ - loongson,ls1c-dwmac-syscon
- marvell,armada-3700-usb2-host-misc
- mediatek,mt8135-pctl-a-syscfg
- mediatek,mt8135-pctl-b-syscfg
--
2.39.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v2 2/4] dt-bindings: net: Add Loongson-1 DWMAC glue layer
2023-08-16 11:13 [PATCH v2 0/4] Move Loongson1 MAC arch-code to the driver dir Keguang Zhang
2023-08-16 11:13 ` [PATCH v2 1/4] dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon Keguang Zhang
@ 2023-08-16 11:13 ` Keguang Zhang
2023-08-19 14:26 ` Krzysztof Kozlowski
2023-08-16 11:13 ` [PATCH v2 3/4] net: stmmac: Add glue layer for Loongson-1 SoC Keguang Zhang
2023-08-16 11:13 ` [PATCH v2 4/4] MAINTAINERS: Update MIPS/LOONGSON1 entry Keguang Zhang
3 siblings, 1 reply; 20+ messages in thread
From: Keguang Zhang @ 2023-08-16 11:13 UTC (permalink / raw)
To: netdev, devicetree, linux-mips, linux-kernel
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
Add devicetree binding document for Loongson-1 DWMAC glue layer.
Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
---
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
diff --git a/Documentation/devicetree/bindings/net/loongson,ls1x-dwmac.yaml b/Documentation/devicetree/bindings/net/loongson,ls1x-dwmac.yaml
new file mode 100644
index 000000000000..cf5477450e29
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/loongson,ls1x-dwmac.yaml
@@ -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 <keguang.zhang@gmail.com>
+
+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>;
+ };
+ };
+ };
--
2.39.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v2 3/4] net: stmmac: Add glue layer for Loongson-1 SoC
2023-08-16 11:13 [PATCH v2 0/4] Move Loongson1 MAC arch-code to the driver dir Keguang Zhang
2023-08-16 11:13 ` [PATCH v2 1/4] dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon Keguang Zhang
2023-08-16 11:13 ` [PATCH v2 2/4] dt-bindings: net: Add Loongson-1 DWMAC glue layer Keguang Zhang
@ 2023-08-16 11:13 ` Keguang Zhang
2023-08-19 19:05 ` Simon Horman
2023-08-20 19:04 ` Andrew Lunn
2023-08-16 11:13 ` [PATCH v2 4/4] MAINTAINERS: Update MIPS/LOONGSON1 entry Keguang Zhang
3 siblings, 2 replies; 20+ messages in thread
From: Keguang Zhang @ 2023-08-16 11:13 UTC (permalink / raw)
To: netdev, devicetree, linux-mips, linux-kernel
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
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.
Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
---
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
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..5210b5e8ae47
--- /dev/null
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
@@ -0,0 +1,273 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Loongson-1 DWMAC glue layer
+ *
+ * Copyright (C) 2011-2023 Keguang Zhang <keguang.zhang@gmail.com>
+ */
+
+#include <linux/mfd/syscon.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/phy.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+
+#include "stmmac.h"
+#include "stmmac_platform.h"
+
+/* Loongson-1 SYSCON Registers */
+#define LS1X_SYSCON0 (0x0)
+#define LS1X_SYSCON1 (0x4)
+
+struct ls1x_dwmac_syscon {
+ const struct reg_field *reg_fields;
+ unsigned int nr_reg_fields;
+ int (*syscon_init)(struct plat_stmmacenet_data *plat);
+};
+
+struct ls1x_dwmac {
+ struct device *dev;
+ struct plat_stmmacenet_data *plat_dat;
+ const struct ls1x_dwmac_syscon *syscon;
+ struct regmap *regmap;
+ struct regmap_field *regmap_fields[];
+};
+
+enum ls1b_dwmac_syscon_regfield {
+ GMAC1_USE_UART1,
+ GMAC1_USE_UART0,
+ GMAC1_SHUT,
+ GMAC0_SHUT,
+ GMAC1_USE_TXCLK,
+ GMAC0_USE_TXCLK,
+ GMAC1_USE_PWM23,
+ GMAC0_USE_PWM01,
+};
+
+enum ls1c_dwmac_syscon_regfield {
+ GMAC_SHUT,
+ PHY_INTF_SELI,
+};
+
+static const struct reg_field ls1b_dwmac_syscon_regfields[] = {
+ [GMAC1_USE_UART1] = REG_FIELD(LS1X_SYSCON0, 4, 4),
+ [GMAC1_USE_UART0] = REG_FIELD(LS1X_SYSCON0, 3, 3),
+ [GMAC1_SHUT] = REG_FIELD(LS1X_SYSCON1, 13, 13),
+ [GMAC0_SHUT] = REG_FIELD(LS1X_SYSCON1, 12, 12),
+ [GMAC1_USE_TXCLK] = REG_FIELD(LS1X_SYSCON1, 3, 3),
+ [GMAC0_USE_TXCLK] = REG_FIELD(LS1X_SYSCON1, 2, 2),
+ [GMAC1_USE_PWM23] = REG_FIELD(LS1X_SYSCON1, 1, 1),
+ [GMAC0_USE_PWM01] = REG_FIELD(LS1X_SYSCON1, 0, 0)
+};
+
+static const struct reg_field ls1c_dwmac_syscon_regfields[] = {
+ [GMAC_SHUT] = REG_FIELD(LS1X_SYSCON0, 6, 6),
+ [PHY_INTF_SELI] = REG_FIELD(LS1X_SYSCON1, 28, 30)
+};
+
+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);
+
+ 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;
+ 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);
+ 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;
+ case PHY_INTERFACE_MODE_MII:
+ regmap_field_write(regmap_fields[GMAC0_USE_TXCLK], 1);
+ regmap_field_write(regmap_fields[GMAC0_USE_PWM01], 1);
+ break;
+ default:
+ dev_err(dwmac->dev, "Unsupported PHY mode %u\n",
+ plat->phy_interface);
+ return -EOPNOTSUPP;
+ }
+
+ regmap_field_write(regmap_fields[GMAC0_SHUT], 0);
+ }
+
+ return 0;
+}
+
+static int ls1c_dwmac_syscon_init(struct plat_stmmacenet_data *plat)
+{
+ struct ls1x_dwmac *dwmac = plat->bsp_priv;
+ struct regmap_field **regmap_fields = dwmac->regmap_fields;
+
+ switch (plat->phy_interface) {
+ case PHY_INTERFACE_MODE_MII:
+ regmap_field_write(regmap_fields[PHY_INTF_SELI], 0);
+ break;
+ case PHY_INTERFACE_MODE_RMII:
+ regmap_field_write(regmap_fields[PHY_INTF_SELI], 4);
+ break;
+ default:
+ dev_err(dwmac->dev, "Unsupported PHY-mode %u\n",
+ plat->phy_interface);
+ return -EOPNOTSUPP;
+ }
+
+ regmap_field_write(regmap_fields[GMAC_SHUT], 0);
+
+ return 0;
+}
+
+static const struct ls1x_dwmac_syscon ls1b_dwmac_syscon = {
+ .reg_fields = ls1b_dwmac_syscon_regfields,
+ .nr_reg_fields = ARRAY_SIZE(ls1b_dwmac_syscon_regfields),
+ .syscon_init = ls1b_dwmac_syscon_init,
+};
+
+static const struct ls1x_dwmac_syscon ls1c_dwmac_syscon = {
+ .reg_fields = ls1c_dwmac_syscon_regfields,
+ .nr_reg_fields = ARRAY_SIZE(ls1c_dwmac_syscon_regfields),
+ .syscon_init = ls1c_dwmac_syscon_init,
+};
+
+static int ls1x_dwmac_init(struct platform_device *pdev, void *priv)
+{
+ struct ls1x_dwmac *dwmac = priv;
+ int ret;
+
+ ret = devm_regmap_field_bulk_alloc(dwmac->dev, dwmac->regmap,
+ dwmac->regmap_fields,
+ dwmac->syscon->reg_fields,
+ dwmac->syscon->nr_reg_fields);
+ if (ret)
+ return ret;
+
+ if (dwmac->syscon->syscon_init) {
+ ret = dwmac->syscon->syscon_init(dwmac->plat_dat);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+static const struct of_device_id ls1x_dwmac_syscon_match[] = {
+ {
+ .compatible = "loongson,ls1b-dwmac-syscon",
+ .data = &ls1b_dwmac_syscon,
+ },
+ {
+ .compatible = "loongson,ls1c-dwmac-syscon",
+ .data = &ls1c_dwmac_syscon,
+ },
+ { }
+};
+
+static int ls1x_dwmac_probe(struct platform_device *pdev)
+{
+ struct plat_stmmacenet_data *plat_dat;
+ struct stmmac_resources stmmac_res;
+ struct device_node *syscon_np;
+ const struct of_device_id *match;
+ struct regmap *regmap;
+ struct ls1x_dwmac *dwmac;
+ const struct ls1x_dwmac_syscon *syscon;
+ size_t size;
+ int ret;
+
+ ret = stmmac_get_platform_resources(pdev, &stmmac_res);
+ if (ret)
+ return ret;
+
+ /* Probe syscon */
+ syscon_np =
+ of_parse_phandle(pdev->dev.of_node, "loongson,dwmac-syscon", 0);
+ if (!syscon_np) {
+ dev_err(&pdev->dev, "missing loongson,dwmac-syscon property\n");
+ return -ENODEV;
+ }
+
+ match = of_match_node(ls1x_dwmac_syscon_match, syscon_np);
+ if (!match) {
+ dev_err(&pdev->dev, "no matching node found in dtb\n");
+ of_node_put(syscon_np);
+ return -EINVAL;
+ }
+ syscon = (const struct ls1x_dwmac_syscon *)match->data;
+
+ regmap = syscon_node_to_regmap(syscon_np);
+ of_node_put(syscon_np);
+ if (IS_ERR(regmap)) {
+ ret = PTR_ERR(regmap);
+ dev_err(&pdev->dev, "Unable to map syscon: %d\n", ret);
+ return ret;
+ }
+
+ size = syscon->nr_reg_fields * sizeof(struct regmap_field *);
+ dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac) + size, 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:
+ if (pdev->dev.of_node)
+ stmmac_remove_config_dt(pdev, plat_dat);
+
+ return ret;
+}
+
+static const struct of_device_id ls1x_dwmac_match[] = {
+ { .compatible = "loongson,ls1b-dwmac" },
+ { .compatible = "loongson,ls1c-dwmac" },
+ { }
+};
+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 <keguang.zhang@gmail.com>");
+MODULE_DESCRIPTION("Loongson1 DWMAC glue layer");
+MODULE_LICENSE("GPL");
--
2.39.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v2 4/4] MAINTAINERS: Update MIPS/LOONGSON1 entry
2023-08-16 11:13 [PATCH v2 0/4] Move Loongson1 MAC arch-code to the driver dir Keguang Zhang
` (2 preceding siblings ...)
2023-08-16 11:13 ` [PATCH v2 3/4] net: stmmac: Add glue layer for Loongson-1 SoC Keguang Zhang
@ 2023-08-16 11:13 ` Keguang Zhang
3 siblings, 0 replies; 20+ messages in thread
From: Keguang Zhang @ 2023-08-16 11:13 UTC (permalink / raw)
To: netdev, devicetree, linux-mips, linux-kernel
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
Add a new F: entry for Loongson1 DWMAC driver.
Add a new F: entry for all Loongson-1 dt-bindings.
Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
---
V1 -> V2: Improve the commit message
MAINTAINERS | 2 ++
1 file changed, 2 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index d8700b009e22..4621facb2cc8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -14313,9 +14313,11 @@ MIPS/LOONGSON1 ARCHITECTURE
M: Keguang Zhang <keguang.zhang@gmail.com>
L: linux-mips@vger.kernel.org
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 <jiaxun.yang@flygoat.com>
--
2.39.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH v2 1/4] dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon
2023-08-16 11:13 ` [PATCH v2 1/4] dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon Keguang Zhang
@ 2023-08-19 14:23 ` Krzysztof Kozlowski
2023-08-21 11:00 ` Keguang Zhang
0 siblings, 1 reply; 20+ messages in thread
From: Krzysztof Kozlowski @ 2023-08-19 14:23 UTC (permalink / raw)
To: Keguang Zhang, netdev, devicetree, linux-mips, linux-kernel
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
On 16/08/2023 13:13, Keguang Zhang wrote:
> 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.
>
> Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
> ---
> 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..d701fff02abe 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-dwmac-syscon
> + - loongson,ls1c-dwmac-syscon
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 2/4] dt-bindings: net: Add Loongson-1 DWMAC glue layer
2023-08-16 11:13 ` [PATCH v2 2/4] dt-bindings: net: Add Loongson-1 DWMAC glue layer Keguang Zhang
@ 2023-08-19 14:26 ` Krzysztof Kozlowski
2023-08-21 13:26 ` Keguang Zhang
0 siblings, 1 reply; 20+ messages in thread
From: Krzysztof Kozlowski @ 2023-08-19 14:26 UTC (permalink / raw)
To: Keguang Zhang, netdev, devicetree, linux-mips, linux-kernel
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
On 16/08/2023 13:13, Keguang Zhang wrote:
> Add devicetree binding document for Loongson-1 DWMAC glue layer.
>
> Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
> ---
> 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
>
> diff --git a/Documentation/devicetree/bindings/net/loongson,ls1x-dwmac.yaml b/Documentation/devicetree/bindings/net/loongson,ls1x-dwmac.yaml
> new file mode 100644
> index 000000000000..cf5477450e29
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/loongson,ls1x-dwmac.yaml
> @@ -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:
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 3/4] net: stmmac: Add glue layer for Loongson-1 SoC
2023-08-16 11:13 ` [PATCH v2 3/4] net: stmmac: Add glue layer for Loongson-1 SoC Keguang Zhang
@ 2023-08-19 19:05 ` Simon Horman
2023-08-21 13:27 ` Keguang Zhang
2023-08-20 19:04 ` Andrew Lunn
1 sibling, 1 reply; 20+ messages in thread
From: Simon Horman @ 2023-08-19 19:05 UTC (permalink / raw)
To: Keguang Zhang
Cc: netdev, devicetree, linux-mips, linux-kernel, 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
On Wed, Aug 16, 2023 at 07:13:09PM +0800, Keguang Zhang wrote:
> 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
...
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 3/4] net: stmmac: Add glue layer for Loongson-1 SoC
2023-08-16 11:13 ` [PATCH v2 3/4] net: stmmac: Add glue layer for Loongson-1 SoC Keguang Zhang
2023-08-19 19:05 ` Simon Horman
@ 2023-08-20 19:04 ` Andrew Lunn
2023-08-22 9:47 ` Keguang Zhang
1 sibling, 1 reply; 20+ messages in thread
From: Andrew Lunn @ 2023-08-20 19:04 UTC (permalink / raw)
To: Keguang Zhang
Cc: netdev, devicetree, linux-mips, linux-kernel, 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
> +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);
> +
> + 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.
> + 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);
> + 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
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 1/4] dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon
2023-08-19 14:23 ` Krzysztof Kozlowski
@ 2023-08-21 11:00 ` Keguang Zhang
2023-08-21 12:06 ` Krzysztof Kozlowski
0 siblings, 1 reply; 20+ messages in thread
From: Keguang Zhang @ 2023-08-21 11:00 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: netdev, devicetree, linux-mips, linux-kernel, 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
On Sat, Aug 19, 2023 at 10:23 PM Krzysztof Kozlowski
<krzysztof.kozlowski@linaro.org> wrote:
>
> On 16/08/2023 13:13, Keguang Zhang wrote:
> > 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?
> >
> > Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
> > ---
> > 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..d701fff02abe 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-dwmac-syscon
> > + - loongson,ls1c-dwmac-syscon
>
>
> Best regards,
> Krzysztof
>
--
Best regards,
Keguang Zhang
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 1/4] dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon
2023-08-21 11:00 ` Keguang Zhang
@ 2023-08-21 12:06 ` Krzysztof Kozlowski
0 siblings, 0 replies; 20+ messages in thread
From: Krzysztof Kozlowski @ 2023-08-21 12:06 UTC (permalink / raw)
To: Keguang Zhang
Cc: netdev, devicetree, linux-mips, linux-kernel, 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
On 21/08/2023 13:00, Keguang Zhang wrote:
> On Sat, Aug 19, 2023 at 10:23 PM Krzysztof Kozlowski
> <krzysztof.kozlowski@linaro.org> wrote:
>>
>> On 16/08/2023 13:13, Keguang Zhang wrote:
>>> 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?
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
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 2/4] dt-bindings: net: Add Loongson-1 DWMAC glue layer
2023-08-19 14:26 ` Krzysztof Kozlowski
@ 2023-08-21 13:26 ` Keguang Zhang
0 siblings, 0 replies; 20+ messages in thread
From: Keguang Zhang @ 2023-08-21 13:26 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: netdev, devicetree, linux-mips, linux-kernel, 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
On Sat, Aug 19, 2023 at 10:26 PM Krzysztof Kozlowski
<krzysztof.kozlowski@linaro.org> wrote:
>
> On 16/08/2023 13:13, Keguang Zhang wrote:
> > Add devicetree binding document for Loongson-1 DWMAC glue layer.
> >
> > Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
> > ---
> > 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
> >
> > diff --git a/Documentation/devicetree/bindings/net/loongson,ls1x-dwmac.yaml b/Documentation/devicetree/bindings/net/loongson,ls1x-dwmac.yaml
> > new file mode 100644
> > index 000000000000..cf5477450e29
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/net/loongson,ls1x-dwmac.yaml
> > @@ -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.
> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
>
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!
> Best regards,
> Krzysztof
>
--
Best regards,
Keguang Zhang
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 3/4] net: stmmac: Add glue layer for Loongson-1 SoC
2023-08-19 19:05 ` Simon Horman
@ 2023-08-21 13:27 ` Keguang Zhang
0 siblings, 0 replies; 20+ messages in thread
From: Keguang Zhang @ 2023-08-21 13:27 UTC (permalink / raw)
To: Simon Horman
Cc: netdev, devicetree, linux-mips, linux-kernel, 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
On Sun, Aug 20, 2023 at 3:05 AM Simon Horman <horms@kernel.org> wrote:
>
> On Wed, Aug 16, 2023 at 07:13:09PM +0800, Keguang Zhang wrote:
> > 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
>
Will do.
Thanks!
> ...
--
Best regards,
Keguang Zhang
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 3/4] net: stmmac: Add glue layer for Loongson-1 SoC
2023-08-20 19:04 ` Andrew Lunn
@ 2023-08-22 9:47 ` Keguang Zhang
2023-08-22 9:49 ` Keguang Zhang
2023-08-22 15:20 ` Andrew Lunn
0 siblings, 2 replies; 20+ messages in thread
From: Keguang Zhang @ 2023-08-22 9:47 UTC (permalink / raw)
To: Andrew Lunn
Cc: netdev, devicetree, linux-mips, linux-kernel, 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
On Mon, Aug 21, 2023 at 3:04 AM Andrew Lunn <andrew@lunn.ch> wrote:
>
> > +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);
> > +
> > + 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.
> > + 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);
> > + 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
--
Best regards,
Keguang Zhang
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 3/4] net: stmmac: Add glue layer for Loongson-1 SoC
2023-08-22 9:47 ` Keguang Zhang
@ 2023-08-22 9:49 ` Keguang Zhang
2023-08-22 15:21 ` Andrew Lunn
2023-08-22 15:20 ` Andrew Lunn
1 sibling, 1 reply; 20+ messages in thread
From: Keguang Zhang @ 2023-08-22 9:49 UTC (permalink / raw)
To: Andrew Lunn
Cc: netdev, devicetree, linux-mips, linux-kernel, 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
On Tue, Aug 22, 2023 at 5:47 PM Keguang Zhang <keguang.zhang@gmail.com> wrote:
>
> On Mon, Aug 21, 2023 at 3:04 AM Andrew Lunn <andrew@lunn.ch> wrote:
> >
> > > +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);
> > > +
> > > + 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.
>
Sorry! The RGMII mode does work for LS1B.
> > > + 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);
> > > + 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
>
>
>
> --
> Best regards,
>
> Keguang Zhang
--
Best regards,
Keguang Zhang
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 3/4] net: stmmac: Add glue layer for Loongson-1 SoC
2023-08-22 9:47 ` Keguang Zhang
2023-08-22 9:49 ` Keguang Zhang
@ 2023-08-22 15:20 ` Andrew Lunn
2023-08-23 2:47 ` Keguang Zhang
1 sibling, 1 reply; 20+ messages in thread
From: Andrew Lunn @ 2023-08-22 15:20 UTC (permalink / raw)
To: Keguang Zhang
Cc: netdev, devicetree, linux-mips, linux-kernel, 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
> > 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
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 3/4] net: stmmac: Add glue layer for Loongson-1 SoC
2023-08-22 9:49 ` Keguang Zhang
@ 2023-08-22 15:21 ` Andrew Lunn
0 siblings, 0 replies; 20+ messages in thread
From: Andrew Lunn @ 2023-08-22 15:21 UTC (permalink / raw)
To: Keguang Zhang
Cc: netdev, devicetree, linux-mips, linux-kernel, 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
> Sorry! The RGMII mode does work for LS1B.
and the question then is: How does it work?
Andrew
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 3/4] net: stmmac: Add glue layer for Loongson-1 SoC
2023-08-22 15:20 ` Andrew Lunn
@ 2023-08-23 2:47 ` Keguang Zhang
2023-08-23 3:46 ` Andrew Lunn
0 siblings, 1 reply; 20+ messages in thread
From: Keguang Zhang @ 2023-08-23 2:47 UTC (permalink / raw)
To: Andrew Lunn
Cc: netdev, devicetree, linux-mips, linux-kernel, 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
On Tue, Aug 22, 2023 at 11:20 PM Andrew Lunn <andrew@lunn.ch> wrote:
>
> > > 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?
>
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!
> Andrew
>
--
Best regards,
Keguang Zhang
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 3/4] net: stmmac: Add glue layer for Loongson-1 SoC
2023-08-23 2:47 ` Keguang Zhang
@ 2023-08-23 3:46 ` Andrew Lunn
2023-08-23 4:40 ` Keguang Zhang
0 siblings, 1 reply; 20+ messages in thread
From: Andrew Lunn @ 2023-08-23 3:46 UTC (permalink / raw)
To: Keguang Zhang
Cc: netdev, devicetree, linux-mips, linux-kernel, 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
> 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
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v2 3/4] net: stmmac: Add glue layer for Loongson-1 SoC
2023-08-23 3:46 ` Andrew Lunn
@ 2023-08-23 4:40 ` Keguang Zhang
0 siblings, 0 replies; 20+ messages in thread
From: Keguang Zhang @ 2023-08-23 4:40 UTC (permalink / raw)
To: Andrew Lunn
Cc: netdev, devicetree, linux-mips, linux-kernel, 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
On Wed, Aug 23, 2023 at 11:46 AM Andrew Lunn <andrew@lunn.ch> wrote:
>
> > 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!
> Andrew
>
--
Best regards,
Keguang Zhang
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2023-08-23 4:41 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-16 11:13 [PATCH v2 0/4] Move Loongson1 MAC arch-code to the driver dir Keguang Zhang
2023-08-16 11:13 ` [PATCH v2 1/4] dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon Keguang Zhang
2023-08-19 14:23 ` Krzysztof Kozlowski
2023-08-21 11:00 ` Keguang Zhang
2023-08-21 12:06 ` Krzysztof Kozlowski
2023-08-16 11:13 ` [PATCH v2 2/4] dt-bindings: net: Add Loongson-1 DWMAC glue layer Keguang Zhang
2023-08-19 14:26 ` Krzysztof Kozlowski
2023-08-21 13:26 ` Keguang Zhang
2023-08-16 11:13 ` [PATCH v2 3/4] net: stmmac: Add glue layer for Loongson-1 SoC Keguang Zhang
2023-08-19 19:05 ` Simon Horman
2023-08-21 13:27 ` Keguang Zhang
2023-08-20 19:04 ` Andrew Lunn
2023-08-22 9:47 ` Keguang Zhang
2023-08-22 9:49 ` Keguang Zhang
2023-08-22 15:21 ` Andrew Lunn
2023-08-22 15:20 ` Andrew Lunn
2023-08-23 2:47 ` Keguang Zhang
2023-08-23 3:46 ` Andrew Lunn
2023-08-23 4:40 ` Keguang Zhang
2023-08-16 11:13 ` [PATCH v2 4/4] MAINTAINERS: Update MIPS/LOONGSON1 entry Keguang Zhang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).