* [PATCH v5 0/3] Move Loongson1 MAC arch-code to the driver dir
@ 2023-09-14 11:44 Keguang Zhang
2023-09-14 11:44 ` [PATCH v5 1/3] dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon Keguang Zhang
` (4 more replies)
0 siblings, 5 replies; 12+ messages in thread
From: Keguang Zhang @ 2023-09-14 11:44 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
V4 -> V5: Replace stmmac_probe_config_dt() with devm_stmmac_probe_config_dt()
Replace stmmac_pltfr_probe() with devm_stmmac_pltfr_probe()
Squash patch 4 into patch 2 and 3
V3 -> V4: Add Acked-by tag from Krzysztof Kozlowski
Add "|" to description part
Amend "phy-mode" property
Drop ls1x_dwmac_syscon definition and its instances
Drop three redundant fields from the ls1x_dwmac structure
Drop the ls1x_dwmac_init() method.
Update the dt-binding document entry of Loongson1 Ethernet
Some minor improvements
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
Change compatibles back to loongson,ls1b-syscon
and loongson,ls1c-syscon
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
Update the entries of MAINTAINERS
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 (3):
dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon
dt-bindings: net: Add Loongson-1 Ethernet Controller
net: stmmac: Add glue layer for Loongson-1 SoC
.../devicetree/bindings/mfd/syscon.yaml | 2 +
.../bindings/net/loongson,ls1b-gmac.yaml | 114 ++++++++++
.../bindings/net/loongson,ls1c-emac.yaml | 113 ++++++++++
MAINTAINERS | 2 +
drivers/net/ethernet/stmicro/stmmac/Kconfig | 11 +
drivers/net/ethernet/stmicro/stmmac/Makefile | 1 +
.../ethernet/stmicro/stmmac/dwmac-loongson1.c | 209 ++++++++++++++++++
7 files changed, 452 insertions(+)
create mode 100644 Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml
create mode 100644 Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml
create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
base-commit: 98897dc735cf6635f0966f76eb0108354168fb15
--
2.39.2
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v5 1/3] dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon
2023-09-14 11:44 [PATCH v5 0/3] Move Loongson1 MAC arch-code to the driver dir Keguang Zhang
@ 2023-09-14 11:44 ` Keguang Zhang
2023-09-15 9:56 ` Serge Semin
2023-09-20 13:46 ` (subset) " Lee Jones
2023-09-14 11:44 ` [PATCH v5 2/3] dt-bindings: net: Add Loongson-1 Ethernet Controller Keguang Zhang
` (3 subsequent siblings)
4 siblings, 2 replies; 12+ messages in thread
From: Keguang Zhang @ 2023-09-14 11:44 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, Krzysztof Kozlowski
Add Loongson LS1B and LS1C compatibles for system controller.
Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
V4 -> V5: None
V3 -> V4: Add Acked-by tag from 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
--
2.39.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v5 2/3] dt-bindings: net: Add Loongson-1 Ethernet Controller
2023-09-14 11:44 [PATCH v5 0/3] Move Loongson1 MAC arch-code to the driver dir Keguang Zhang
2023-09-14 11:44 ` [PATCH v5 1/3] dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon Keguang Zhang
@ 2023-09-14 11:44 ` Keguang Zhang
2023-09-15 9:56 ` Serge Semin
2023-09-14 11:44 ` [PATCH v5 3/3] net: stmmac: Add glue layer for Loongson-1 SoC Keguang Zhang
` (2 subsequent siblings)
4 siblings, 1 reply; 12+ messages in thread
From: Keguang Zhang @ 2023-09-14 11:44 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, Krzysztof Kozlowski
Add devicetree binding document for Loongson-1 Ethernet controller.
And modify MAINTAINERS to add a new F: entry for
Loongson1 dt-binding documents.
Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
V4 -> V5: Add a new F: entry for Loongson1 dt-binding documents
V3 -> V4: Add "|" to description part
Amend "phy-mode" property
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 | 114 ++++++++++++++++++
.../bindings/net/loongson,ls1c-emac.yaml | 113 +++++++++++++++++
MAINTAINERS | 1 +
3 files changed, 228 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..c4f3224bad38
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/loongson,ls1b-gmac.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,ls1b-gmac.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Loongson-1B Gigabit Ethernet MAC Controller
+
+maintainers:
+ - Keguang Zhang <keguang.zhang@gmail.com>
+
+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:
+ 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 <dt-bindings/clock/loongson,ls1x-clk.h>
+ #include <dt-bindings/interrupt-controller/irq.h>
+
+ 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..99001b940b83
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml
@@ -0,0 +1,113 @@
+# 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 <keguang.zhang@gmail.com>
+
+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:
+ enum:
+ - mii
+ - rmii
+
+required:
+ - compatible
+ - reg
+ - clocks
+ - clock-names
+ - interrupts
+ - interrupt-names
+ - loongson,ls1-syscon
+
+allOf:
+ - $ref: snps,dwmac.yaml#
+
+unevaluatedProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/clock/loongson,ls1x-clk.h>
+ #include <dt-bindings/interrupt-controller/irq.h>
+
+ 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>;
+ };
+ };
+ };
diff --git a/MAINTAINERS b/MAINTAINERS
index fa7487b7729b..e514b53fb225 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -14379,6 +14379,7 @@ MIPS/LOONGSON1 ARCHITECTURE
M: Keguang Zhang <keguang.zhang@gmail.com>
L: linux-mips@vger.kernel.org
S: Maintained
+F: Documentation/devicetree/bindings/*/loongson,ls1*.yaml
F: arch/mips/include/asm/mach-loongson32/
F: arch/mips/loongson32/
F: drivers/*/*loongson1*
--
2.39.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v5 3/3] net: stmmac: Add glue layer for Loongson-1 SoC
2023-09-14 11:44 [PATCH v5 0/3] Move Loongson1 MAC arch-code to the driver dir Keguang Zhang
2023-09-14 11:44 ` [PATCH v5 1/3] dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon Keguang Zhang
2023-09-14 11:44 ` [PATCH v5 2/3] dt-bindings: net: Add Loongson-1 Ethernet Controller Keguang Zhang
@ 2023-09-14 11:44 ` Keguang Zhang
2023-09-15 9:57 ` Serge Semin
2023-09-15 9:55 ` [PATCH v5 0/3] Move Loongson1 MAC arch-code to the driver dir Serge Semin
2023-09-16 10:50 ` patchwork-bot+netdevbpf
4 siblings, 1 reply; 12+ messages in thread
From: Keguang Zhang @ 2023-09-14 11:44 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.
And modify MAINTAINERS to add a new F: entry for this driver.
Partially based on the previous work by Serge Semin.
Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
---
V4 -> V5: Replace stmmac_probe_config_dt() with devm_stmmac_probe_config_dt()
Replace stmmac_pltfr_probe() with devm_stmmac_pltfr_probe()
Add a new F: entry for this driver.
V3 -> V4: Drop ls1x_dwmac_syscon definition and its instances
Drop three redundant fields from the ls1x_dwmac structure
Drop the ls1x_dwmac_init() method.
Some minor improvements
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
MAINTAINERS | 1 +
drivers/net/ethernet/stmicro/stmmac/Kconfig | 11 +
drivers/net/ethernet/stmicro/stmmac/Makefile | 1 +
.../ethernet/stmicro/stmmac/dwmac-loongson1.c | 209 ++++++++++++++++++
4 files changed, 222 insertions(+)
create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
diff --git a/MAINTAINERS b/MAINTAINERS
index e514b53fb225..b71aff479a8c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -14383,6 +14383,7 @@ F: Documentation/devicetree/bindings/*/loongson,ls1*.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>
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..3e86810717d3
--- /dev/null
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
@@ -0,0 +1,209 @@
+// 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"
+
+#define LS1B_GMAC0_BASE (0x1fe10000)
+#define LS1B_GMAC1_BASE (0x1fe20000)
+
+/* 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_MII FIELD_PREP(PHY_INTF_SELI, 0)
+#define PHY_INTF_RMII FIELD_PREP(PHY_INTF_SELI, 4)
+
+struct ls1x_dwmac {
+ struct plat_stmmacenet_data *plat_dat;
+ struct regmap *regmap;
+};
+
+static int ls1b_dwmac_syscon_init(struct platform_device *pdev, void *priv)
+{
+ struct ls1x_dwmac *dwmac = priv;
+ struct plat_stmmacenet_data *plat = dwmac->plat_dat;
+ struct regmap *regmap = dwmac->regmap;
+ struct resource *res;
+ unsigned long reg_base;
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res) {
+ dev_err(&pdev->dev, "Could not get IO_MEM resources\n");
+ return -EINVAL;
+ }
+ reg_base = (unsigned long)res->start;
+
+ if (reg_base == LS1B_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(&pdev->dev, "Unsupported PHY mode %u\n",
+ plat->phy_interface);
+ return -EOPNOTSUPP;
+ }
+
+ regmap_update_bits(regmap, LS1X_SYSCON0, GMAC0_SHUT, 0);
+ } else if (reg_base == LS1B_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(&pdev->dev, "Unsupported PHY mode %u\n",
+ plat->phy_interface);
+ return -EOPNOTSUPP;
+ }
+
+ regmap_update_bits(regmap, LS1X_SYSCON1, GMAC1_SHUT, 0);
+ } else {
+ dev_err(&pdev->dev, "Invalid Ethernet MAC base address %lx",
+ reg_base);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int ls1c_dwmac_syscon_init(struct platform_device *pdev, void *priv)
+{
+ struct ls1x_dwmac *dwmac = priv;
+ struct plat_stmmacenet_data *plat = dwmac->plat_dat;
+ struct regmap *regmap = dwmac->regmap;
+
+ switch (plat->phy_interface) {
+ case PHY_INTERFACE_MODE_MII:
+ regmap_update_bits(regmap, LS1X_SYSCON1, PHY_INTF_SELI,
+ PHY_INTF_MII);
+ break;
+ case PHY_INTERFACE_MODE_RMII:
+ regmap_update_bits(regmap, LS1X_SYSCON1, PHY_INTF_SELI,
+ PHY_INTF_RMII);
+ break;
+ default:
+ dev_err(&pdev->dev, "Unsupported PHY-mode %u\n",
+ plat->phy_interface);
+ return -EOPNOTSUPP;
+ }
+
+ regmap_update_bits(regmap, LS1X_SYSCON0, GMAC0_SHUT, 0);
+
+ 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;
+ int (*init)(struct platform_device *pdev, void *priv);
+ 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))
+ return dev_err_probe(&pdev->dev, PTR_ERR(regmap),
+ "Unable to find syscon\n");
+
+ init = of_device_get_match_data(&pdev->dev);
+ if (!init) {
+ 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 = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
+ if (IS_ERR(plat_dat))
+ return dev_err_probe(&pdev->dev, PTR_ERR(plat_dat),
+ "dt configuration failed\n");
+
+ plat_dat->bsp_priv = dwmac;
+ plat_dat->init = init;
+ dwmac->plat_dat = plat_dat;
+ dwmac->regmap = regmap;
+
+ return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
+}
+
+static const struct of_device_id ls1x_dwmac_match[] = {
+ {
+ .compatible = "loongson,ls1b-gmac",
+ .data = &ls1b_dwmac_syscon_init,
+ },
+ {
+ .compatible = "loongson,ls1c-emac",
+ .data = &ls1c_dwmac_syscon_init,
+ },
+ { }
+};
+MODULE_DEVICE_TABLE(of, ls1x_dwmac_match);
+
+static struct platform_driver ls1x_dwmac_driver = {
+ .probe = ls1x_dwmac_probe,
+ .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("Loongson-1 DWMAC glue layer");
+MODULE_LICENSE("GPL");
--
2.39.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v5 0/3] Move Loongson1 MAC arch-code to the driver dir
2023-09-14 11:44 [PATCH v5 0/3] Move Loongson1 MAC arch-code to the driver dir Keguang Zhang
` (2 preceding siblings ...)
2023-09-14 11:44 ` [PATCH v5 3/3] net: stmmac: Add glue layer for Loongson-1 SoC Keguang Zhang
@ 2023-09-15 9:55 ` Serge Semin
2023-09-15 13:23 ` Philippe Mathieu-Daudé
2023-09-16 10:50 ` patchwork-bot+netdevbpf
4 siblings, 1 reply; 12+ messages in thread
From: Serge Semin @ 2023-09-15 9:55 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
Hi Keguang
On Thu, Sep 14, 2023 at 07:44:32PM +0800, Keguang Zhang wrote:
> 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.
No more comments from my side. Thank you for the patches and
especially for the patience in the review process.
For the entire series:
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
* I'll also send individual Rb tags to each patch so b4 would be able
* to take it into account.
-Serge(y)
>
> Changelog
> V4 -> V5: Replace stmmac_probe_config_dt() with devm_stmmac_probe_config_dt()
> Replace stmmac_pltfr_probe() with devm_stmmac_pltfr_probe()
> Squash patch 4 into patch 2 and 3
> V3 -> V4: Add Acked-by tag from Krzysztof Kozlowski
> Add "|" to description part
> Amend "phy-mode" property
> Drop ls1x_dwmac_syscon definition and its instances
> Drop three redundant fields from the ls1x_dwmac structure
> Drop the ls1x_dwmac_init() method.
> Update the dt-binding document entry of Loongson1 Ethernet
> Some minor improvements
> 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
> Change compatibles back to loongson,ls1b-syscon
> and loongson,ls1c-syscon
> 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
> Update the entries of MAINTAINERS
> 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 (3):
> dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon
> dt-bindings: net: Add Loongson-1 Ethernet Controller
> net: stmmac: Add glue layer for Loongson-1 SoC
>
> .../devicetree/bindings/mfd/syscon.yaml | 2 +
> .../bindings/net/loongson,ls1b-gmac.yaml | 114 ++++++++++
> .../bindings/net/loongson,ls1c-emac.yaml | 113 ++++++++++
> MAINTAINERS | 2 +
> drivers/net/ethernet/stmicro/stmmac/Kconfig | 11 +
> drivers/net/ethernet/stmicro/stmmac/Makefile | 1 +
> .../ethernet/stmicro/stmmac/dwmac-loongson1.c | 209 ++++++++++++++++++
> 7 files changed, 452 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/net/loongson,ls1b-gmac.yaml
> create mode 100644 Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml
> create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
>
>
> base-commit: 98897dc735cf6635f0966f76eb0108354168fb15
> --
> 2.39.2
>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v5 1/3] dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon
2023-09-14 11:44 ` [PATCH v5 1/3] dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon Keguang Zhang
@ 2023-09-15 9:56 ` Serge Semin
2023-09-20 13:46 ` (subset) " Lee Jones
1 sibling, 0 replies; 12+ messages in thread
From: Serge Semin @ 2023-09-15 9:56 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,
Krzysztof Kozlowski
On Thu, Sep 14, 2023 at 07:44:33PM +0800, Keguang Zhang wrote:
> Add Loongson LS1B and LS1C compatibles for system controller.
>
> Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
> Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
-Serge(y)
> ---
> V4 -> V5: None
> V3 -> V4: Add Acked-by tag from 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
> --
> 2.39.2
>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v5 2/3] dt-bindings: net: Add Loongson-1 Ethernet Controller
2023-09-14 11:44 ` [PATCH v5 2/3] dt-bindings: net: Add Loongson-1 Ethernet Controller Keguang Zhang
@ 2023-09-15 9:56 ` Serge Semin
0 siblings, 0 replies; 12+ messages in thread
From: Serge Semin @ 2023-09-15 9:56 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,
Krzysztof Kozlowski
On Thu, Sep 14, 2023 at 07:44:34PM +0800, Keguang Zhang wrote:
> Add devicetree binding document for Loongson-1 Ethernet controller.
> And modify MAINTAINERS to add a new F: entry for
> Loongson1 dt-binding documents.
>
> Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
-Serge(y)
> ---
> V4 -> V5: Add a new F: entry for Loongson1 dt-binding documents
> V3 -> V4: Add "|" to description part
> Amend "phy-mode" property
> 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 | 114 ++++++++++++++++++
> .../bindings/net/loongson,ls1c-emac.yaml | 113 +++++++++++++++++
> MAINTAINERS | 1 +
> 3 files changed, 228 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..c4f3224bad38
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/loongson,ls1b-gmac.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,ls1b-gmac.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Loongson-1B Gigabit Ethernet MAC Controller
> +
> +maintainers:
> + - Keguang Zhang <keguang.zhang@gmail.com>
> +
> +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:
> + 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 <dt-bindings/clock/loongson,ls1x-clk.h>
> + #include <dt-bindings/interrupt-controller/irq.h>
> +
> + 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..99001b940b83
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/loongson,ls1c-emac.yaml
> @@ -0,0 +1,113 @@
> +# 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 <keguang.zhang@gmail.com>
> +
> +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:
> + enum:
> + - mii
> + - rmii
> +
> +required:
> + - compatible
> + - reg
> + - clocks
> + - clock-names
> + - interrupts
> + - interrupt-names
> + - loongson,ls1-syscon
> +
> +allOf:
> + - $ref: snps,dwmac.yaml#
> +
> +unevaluatedProperties: false
> +
> +examples:
> + - |
> + #include <dt-bindings/clock/loongson,ls1x-clk.h>
> + #include <dt-bindings/interrupt-controller/irq.h>
> +
> + 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>;
> + };
> + };
> + };
> diff --git a/MAINTAINERS b/MAINTAINERS
> index fa7487b7729b..e514b53fb225 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -14379,6 +14379,7 @@ MIPS/LOONGSON1 ARCHITECTURE
> M: Keguang Zhang <keguang.zhang@gmail.com>
> L: linux-mips@vger.kernel.org
> S: Maintained
> +F: Documentation/devicetree/bindings/*/loongson,ls1*.yaml
> F: arch/mips/include/asm/mach-loongson32/
> F: arch/mips/loongson32/
> F: drivers/*/*loongson1*
> --
> 2.39.2
>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v5 3/3] net: stmmac: Add glue layer for Loongson-1 SoC
2023-09-14 11:44 ` [PATCH v5 3/3] net: stmmac: Add glue layer for Loongson-1 SoC Keguang Zhang
@ 2023-09-15 9:57 ` Serge Semin
0 siblings, 0 replies; 12+ messages in thread
From: Serge Semin @ 2023-09-15 9:57 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 Thu, Sep 14, 2023 at 07:44:35PM +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.
>
> And modify MAINTAINERS to add a new F: entry for this driver.
>
> Partially based on the previous work by Serge Semin.
>
> Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
-Serge(y)
> ---
> V4 -> V5: Replace stmmac_probe_config_dt() with devm_stmmac_probe_config_dt()
> Replace stmmac_pltfr_probe() with devm_stmmac_pltfr_probe()
> Add a new F: entry for this driver.
> V3 -> V4: Drop ls1x_dwmac_syscon definition and its instances
> Drop three redundant fields from the ls1x_dwmac structure
> Drop the ls1x_dwmac_init() method.
> Some minor improvements
> 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
>
> MAINTAINERS | 1 +
> drivers/net/ethernet/stmicro/stmmac/Kconfig | 11 +
> drivers/net/ethernet/stmicro/stmmac/Makefile | 1 +
> .../ethernet/stmicro/stmmac/dwmac-loongson1.c | 209 ++++++++++++++++++
> 4 files changed, 222 insertions(+)
> create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index e514b53fb225..b71aff479a8c 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -14383,6 +14383,7 @@ F: Documentation/devicetree/bindings/*/loongson,ls1*.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>
> 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..3e86810717d3
> --- /dev/null
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c
> @@ -0,0 +1,209 @@
> +// 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"
> +
> +#define LS1B_GMAC0_BASE (0x1fe10000)
> +#define LS1B_GMAC1_BASE (0x1fe20000)
> +
> +/* 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_MII FIELD_PREP(PHY_INTF_SELI, 0)
> +#define PHY_INTF_RMII FIELD_PREP(PHY_INTF_SELI, 4)
> +
> +struct ls1x_dwmac {
> + struct plat_stmmacenet_data *plat_dat;
> + struct regmap *regmap;
> +};
> +
> +static int ls1b_dwmac_syscon_init(struct platform_device *pdev, void *priv)
> +{
> + struct ls1x_dwmac *dwmac = priv;
> + struct plat_stmmacenet_data *plat = dwmac->plat_dat;
> + struct regmap *regmap = dwmac->regmap;
> + struct resource *res;
> + unsigned long reg_base;
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + if (!res) {
> + dev_err(&pdev->dev, "Could not get IO_MEM resources\n");
> + return -EINVAL;
> + }
> + reg_base = (unsigned long)res->start;
> +
> + if (reg_base == LS1B_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(&pdev->dev, "Unsupported PHY mode %u\n",
> + plat->phy_interface);
> + return -EOPNOTSUPP;
> + }
> +
> + regmap_update_bits(regmap, LS1X_SYSCON0, GMAC0_SHUT, 0);
> + } else if (reg_base == LS1B_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(&pdev->dev, "Unsupported PHY mode %u\n",
> + plat->phy_interface);
> + return -EOPNOTSUPP;
> + }
> +
> + regmap_update_bits(regmap, LS1X_SYSCON1, GMAC1_SHUT, 0);
> + } else {
> + dev_err(&pdev->dev, "Invalid Ethernet MAC base address %lx",
> + reg_base);
> + return -EINVAL;
> + }
> +
> + return 0;
> +}
> +
> +static int ls1c_dwmac_syscon_init(struct platform_device *pdev, void *priv)
> +{
> + struct ls1x_dwmac *dwmac = priv;
> + struct plat_stmmacenet_data *plat = dwmac->plat_dat;
> + struct regmap *regmap = dwmac->regmap;
> +
> + switch (plat->phy_interface) {
> + case PHY_INTERFACE_MODE_MII:
> + regmap_update_bits(regmap, LS1X_SYSCON1, PHY_INTF_SELI,
> + PHY_INTF_MII);
> + break;
> + case PHY_INTERFACE_MODE_RMII:
> + regmap_update_bits(regmap, LS1X_SYSCON1, PHY_INTF_SELI,
> + PHY_INTF_RMII);
> + break;
> + default:
> + dev_err(&pdev->dev, "Unsupported PHY-mode %u\n",
> + plat->phy_interface);
> + return -EOPNOTSUPP;
> + }
> +
> + regmap_update_bits(regmap, LS1X_SYSCON0, GMAC0_SHUT, 0);
> +
> + 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;
> + int (*init)(struct platform_device *pdev, void *priv);
> + 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))
> + return dev_err_probe(&pdev->dev, PTR_ERR(regmap),
> + "Unable to find syscon\n");
> +
> + init = of_device_get_match_data(&pdev->dev);
> + if (!init) {
> + 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 = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
> + if (IS_ERR(plat_dat))
> + return dev_err_probe(&pdev->dev, PTR_ERR(plat_dat),
> + "dt configuration failed\n");
> +
> + plat_dat->bsp_priv = dwmac;
> + plat_dat->init = init;
> + dwmac->plat_dat = plat_dat;
> + dwmac->regmap = regmap;
> +
> + return devm_stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
> +}
> +
> +static const struct of_device_id ls1x_dwmac_match[] = {
> + {
> + .compatible = "loongson,ls1b-gmac",
> + .data = &ls1b_dwmac_syscon_init,
> + },
> + {
> + .compatible = "loongson,ls1c-emac",
> + .data = &ls1c_dwmac_syscon_init,
> + },
> + { }
> +};
> +MODULE_DEVICE_TABLE(of, ls1x_dwmac_match);
> +
> +static struct platform_driver ls1x_dwmac_driver = {
> + .probe = ls1x_dwmac_probe,
> + .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("Loongson-1 DWMAC glue layer");
> +MODULE_LICENSE("GPL");
> --
> 2.39.2
>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v5 0/3] Move Loongson1 MAC arch-code to the driver dir
2023-09-15 9:55 ` [PATCH v5 0/3] Move Loongson1 MAC arch-code to the driver dir Serge Semin
@ 2023-09-15 13:23 ` Philippe Mathieu-Daudé
2023-09-15 14:19 ` Serge Semin
0 siblings, 1 reply; 12+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-09-15 13:23 UTC (permalink / raw)
To: Serge Semin, 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 15/9/23 11:55, Serge Semin wrote:
> Hi Keguang
>
> On Thu, Sep 14, 2023 at 07:44:32PM +0800, Keguang Zhang wrote:
>> 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.
>
> No more comments from my side. Thank you for the patches and
> especially for the patience in the review process.
>
> For the entire series:
> Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
>
> * I'll also send individual Rb tags to each patch so b4 would be able
> * to take it into account.
Maintainers using b4 should use the '-t' option, then you don't need
to do that:
-t, --apply-cover-trailers
By default, b4 will not apply any code review trailers sent to
the cover letter (but will let you know when it finds those).
This lets you automatically apply these trailers to all commits
in the series. This will become the default in a future version
of b4.
https://b4.docs.kernel.org/en/latest/maintainer/am-shazam.html#common-flags
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v5 0/3] Move Loongson1 MAC arch-code to the driver dir
2023-09-15 13:23 ` Philippe Mathieu-Daudé
@ 2023-09-15 14:19 ` Serge Semin
0 siblings, 0 replies; 12+ messages in thread
From: Serge Semin @ 2023-09-15 14:19 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Keguang Zhang, 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 Fri, Sep 15, 2023 at 03:23:44PM +0200, Philippe Mathieu-Daudé wrote:
> On 15/9/23 11:55, Serge Semin wrote:
> > Hi Keguang
> >
> > On Thu, Sep 14, 2023 at 07:44:32PM +0800, Keguang Zhang wrote:
> > > 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.
> >
> > No more comments from my side. Thank you for the patches and
> > especially for the patience in the review process.
> >
> > For the entire series:
> > Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
> >
> > * I'll also send individual Rb tags to each patch so b4 would be able
> > * to take it into account.
>
> Maintainers using b4 should use the '-t' option, then you don't need
> to do that:
>
> -t, --apply-cover-trailers
>
> By default, b4 will not apply any code review trailers sent to
> the cover letter (but will let you know when it finds those).
> This lets you automatically apply these trailers to all commits
> in the series. This will become the default in a future version
> of b4.
>
> https://b4.docs.kernel.org/en/latest/maintainer/am-shazam.html#common-flags
Oh, got it. Can't believe I didn't figure out to take a closer look at
the help-page. Thanks for pointing it out to me.
-Serge(y)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v5 0/3] Move Loongson1 MAC arch-code to the driver dir
2023-09-14 11:44 [PATCH v5 0/3] Move Loongson1 MAC arch-code to the driver dir Keguang Zhang
` (3 preceding siblings ...)
2023-09-15 9:55 ` [PATCH v5 0/3] Move Loongson1 MAC arch-code to the driver dir Serge Semin
@ 2023-09-16 10:50 ` patchwork-bot+netdevbpf
4 siblings, 0 replies; 12+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-09-16 10:50 UTC (permalink / raw)
To: Keguang Zhang
Cc: netdev, devicetree, linux-mips, linux-kernel, lee, robh+dt,
krzysztof.kozlowski+dt, conor+dt, davem, edumazet, kuba, pabeni,
tsbogend, peppe.cavallaro, alexandre.torgue, joabreu,
Sergey.Semin
Hello:
This series was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:
On Thu, 14 Sep 2023 19:44:32 +0800 you wrote:
> 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.
>
> [...]
Here is the summary with links:
- [v5,1/3] dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon
https://git.kernel.org/netdev/net-next/c/7e10088bc4e4
- [v5,2/3] dt-bindings: net: Add Loongson-1 Ethernet Controller
https://git.kernel.org/netdev/net-next/c/2af21077fa9f
- [v5,3/3] net: stmmac: Add glue layer for Loongson-1 SoC
https://git.kernel.org/netdev/net-next/c/d301c66b35b4
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: (subset) [PATCH v5 1/3] dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon
2023-09-14 11:44 ` [PATCH v5 1/3] dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon Keguang Zhang
2023-09-15 9:56 ` Serge Semin
@ 2023-09-20 13:46 ` Lee Jones
1 sibling, 0 replies; 12+ messages in thread
From: Lee Jones @ 2023-09-20 13:46 UTC (permalink / raw)
To: netdev, devicetree, linux-mips, linux-kernel, Keguang Zhang
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, Krzysztof Kozlowski
On Thu, 14 Sep 2023 19:44:33 +0800, Keguang Zhang wrote:
> Add Loongson LS1B and LS1C compatibles for system controller.
>
>
Applied, thanks!
[1/3] dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon
commit: d6e3854f720f13bad60c086d3cb4ea2c1958214a
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2023-09-20 13:47 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-14 11:44 [PATCH v5 0/3] Move Loongson1 MAC arch-code to the driver dir Keguang Zhang
2023-09-14 11:44 ` [PATCH v5 1/3] dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon Keguang Zhang
2023-09-15 9:56 ` Serge Semin
2023-09-20 13:46 ` (subset) " Lee Jones
2023-09-14 11:44 ` [PATCH v5 2/3] dt-bindings: net: Add Loongson-1 Ethernet Controller Keguang Zhang
2023-09-15 9:56 ` Serge Semin
2023-09-14 11:44 ` [PATCH v5 3/3] net: stmmac: Add glue layer for Loongson-1 SoC Keguang Zhang
2023-09-15 9:57 ` Serge Semin
2023-09-15 9:55 ` [PATCH v5 0/3] Move Loongson1 MAC arch-code to the driver dir Serge Semin
2023-09-15 13:23 ` Philippe Mathieu-Daudé
2023-09-15 14:19 ` Serge Semin
2023-09-16 10:50 ` patchwork-bot+netdevbpf
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).