Skip to contentSkip to conversation

convert stmmac glue layers into platform drivers

PATCH In review Joachim Eastwood 6 participants 18 messages May 14, 2015 – May 15, 2015 2 messages not in the archive

Subsystems (10)
lore
Share & tools
lore
#0 lore raw

cover convert stmmac glue layers into platform drivers

This patch set aims to convert the current dwmac glue layers into proper platform drivers as request by Arnd[1]. These changes start from patch 3 and onwards.

Overview:
Platform driver functions like probe and remove are exported from the stmmac platform and then used in subsequent glue later conversions. The conversion involes adding the platform driver boiler plate code and adding it to the build system. The last patch removes the driver from the stmmac platform code thus making it into a library for common platform driver functions.

The two first patches adds glue layer for my platform. I chose to first add old style glue layer and then convert it. The churn this creates is just 3 lines.

I would be very nice if people could test this patch set on their respective platform. My testing has been limited to compiling and testing on my (LPC18xx) platform. Thanks!

Next I will look into cleaning up the stmmac platform code.

[1] http://marc.info/?l=linux-arm-kernel&m=143059524606459&w=2

Joachim Eastwood (11):
stmmac: add dwmac glue for NXP 18xx/43xx family
doc: dt: add documentation for nxp,lpc1850-dwmac
stmmac: prepare stmmac platform to support stand alone drivers
stmmac: add a generic dwmac driver
stmmac: convert dwmac-lpc18xx to a platform driver
stmmac: convert dwmac-meson to platform driver
stmmac: convert dwmac-rk to platform driver
stmmac: convert dwmac-socfpga to platform driver
stmmac: convert dwmac-sti to platform driver
stmmac: convert dwmac-sunxi to platform driver
stmmac: drop driver from stmmac platform code

 .../devicetree/bindings/net/nxp,lpc1850-dwmac.txt  | 20 +++++
 drivers/net/ethernet/stmicro/stmmac/Kconfig        | 76 +++++++++++++++++
 drivers/net/ethernet/stmicro/stmmac/Makefile       | 13 ++-
 .../net/ethernet/stmicro/stmmac/dwmac-generic.c    | 41 +++++++++
 .../net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c    | 99 ++++++++++++++++++++++
 drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c  | 24 +++++-
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c     | 27 +++++-
 .../net/ethernet/stmicro/stmmac/dwmac-socfpga.c    | 21 ++++-
 drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c    | 29 ++++++-
 drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c  | 25 +++++-
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  | 49 ++---------
 .../net/ethernet/stmicro/stmmac/stmmac_platform.h  |  9 +-
 12 files changed, 378 insertions(+), 55 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/nxp,lpc1850-dwmac.txt
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c
Signature · 1 line
1.8.0
#1 lore raw

PATCH 1/11 stmmac: add dwmac glue for NXP 18xx/43xx family

Add support for Ethernet on NXP LPC18xx and LPC43xx using the dwmac driver. This glue is required to setup phy interface mode, MII or RMII, on the SoC.

---
 drivers/net/ethernet/stmicro/stmmac/Makefile       |  3 +-
 .../net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c    | 74 ++++++++++++++++++++++
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |  1 +
 .../net/ethernet/stmicro/stmmac/stmmac_platform.h  |  1 +
 4 files changed, 78 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c
drivers/net/ethernet/stmicro/stmmac/Makefile +2 -1
index 73c2715a27f3..5c165d8d7004 100644
@@ -6,7 +6,8 @@ stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o ring_mode.o	\
 
 obj-$(CONFIG_STMMAC_PLATFORM) += stmmac-platform.o
 stmmac-platform-objs:= stmmac_platform.o dwmac-meson.o dwmac-sunxi.o	\
-		       dwmac-sti.o dwmac-socfpga.o dwmac-rk.o
+		       dwmac-sti.o dwmac-socfpga.o dwmac-rk.o		\
+		       dwmac-lpc18xx.o
 
 obj-$(CONFIG_STMMAC_PCI) += stmmac-pci.o
 stmmac-pci-objs:= stmmac_pci.o
drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c new file +74 -0

74 lines not on this page · raw message

drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +1 -0
index 68aec5c460db..1ac7c8a2c631 100644
@@ -37,6 +37,7 @@ static const struct of_device_id stmmac_dt_ids[] = {
 	{ .compatible = "rockchip,rk3288-gmac", .data = &rk3288_gmac_data},
 	{ .compatible = "amlogic,meson6-dwmac", .data = &meson6_dwmac_data},
 	{ .compatible = "allwinner,sun7i-a20-gmac", .data = &sun7i_gmac_data},
+	{ .compatible = "nxp,lpc1850-dwmac", .data = &lpc18xx_dwmac_data},
 	{ .compatible = "st,stih415-dwmac", .data = &stih4xx_dwmac_data},
 	{ .compatible = "st,stih416-dwmac", .data = &stih4xx_dwmac_data},
 	{ .compatible = "st,stid127-dwmac", .data = &stid127_dwmac_data},
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h +1 -0
index 093eb99e5ffd..59fe8fb46a48 100644
@@ -19,6 +19,7 @@
 #ifndef __STMMAC_PLATFORM_H__
 #define __STMMAC_PLATFORM_H__
 
+extern const struct stmmac_of_data lpc18xx_dwmac_data;
 extern const struct stmmac_of_data meson6_dwmac_data;
 extern const struct stmmac_of_data sun7i_gmac_data;
 extern const struct stmmac_of_data stih4xx_dwmac_data;
Signature · 1 line
1.8.0
#2 lore raw

PATCH 2/11 doc: dt: add documentation for nxp,lpc1850-dwmac

In reply to Joachim Eastwood

Add device tree binding documentation for nxp,lpc1850-dwmac.

---
 .../devicetree/bindings/net/nxp,lpc1850-dwmac.txt    | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/nxp,lpc1850-dwmac.txt
Documentation/devicetree/bindings/net/nxp,lpc1850-dwmac.txt new file +20 -0
new file mode 100644
index 000000000000..7edba1264f6f
@@ -0,0 +1,20 @@
+* NXP LPC1850 GMAC ethernet controller
+
+This device is a platform glue layer for stmmac.
+Please see stmmac.txt for the other unchanged properties.
+
+Required properties:
+ - compatible:  Should contain "nxp,lpc1850-dwmac"
+
+Examples:
+
+mac: ethernet at 40010000 {
+	compatible = "nxp,lpc1850-dwmac", "snps,dwmac-3.611", "snps,dwmac";
+	reg = <0x40010000 0x2000>;
+	interrupts = <5>;
+	interrupt-names = "macirq";
+	clocks = <&ccu1 CLK_CPU_ETHERNET>;
+	clock-names = "stmmaceth";
+	resets = <&rgu 22>;
+	reset-names = "stmmaceth";
+}
Signature · 1 line
1.8.0
#3 lore raw

PATCH 3/11 stmmac: prepare stmmac platform to support stand alone drivers

In reply to Joachim Eastwood

Prepare the stmmac platform code to support standalone drivers by exporting the need functions and having of_match_device use the match table reference already present in the driver struct.

This will allow us to reuse the platform driver functions from this code easily in other stand alone platform drivers.

---
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 14 +++++++++-----
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h |  4 ++++
 2 files changed, 13 insertions(+), 5 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +9 -5
index 1ac7c8a2c631..0d1f1ec96bc0 100644
@@ -130,11 +130,12 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
 	struct device_node *np = pdev->dev.of_node;
 	struct stmmac_dma_cfg *dma_cfg;
 	const struct of_device_id *device;
+	struct device *dev = &pdev->dev;
 
 	if (!np)
 		return -ENODEV;
 
-	device = of_match_device(stmmac_dt_ids, &pdev->dev);
+	device = of_match_device(dev->driver->of_match_table, dev);
 	if (!device)
 		return -ENODEV;
 
@@ -269,7 +270,7 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
  * the necessary platform resources, invoke custom helper (if required) and
  * invoke the main probe function.
  */
-static int stmmac_pltfr_probe(struct platform_device *pdev)
+int stmmac_pltfr_probe(struct platform_device *pdev)
 {
 	int ret = 0;
 	struct resource *res;
@@ -375,6 +376,7 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(stmmac_pltfr_probe);
 
 /**
  * stmmac_pltfr_remove
@@ -382,7 +384,7 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
  * Description: this function calls the main to free the net resources
  * and calls the platforms hook and release the resources (e.g. mem).
  */
-static int stmmac_pltfr_remove(struct platform_device *pdev)
+int stmmac_pltfr_remove(struct platform_device *pdev)
 {
 	struct net_device *ndev = platform_get_drvdata(pdev);
 	struct stmmac_priv *priv = netdev_priv(ndev);
@@ -396,6 +398,7 @@ static int stmmac_pltfr_remove(struct platform_device *pdev)
 
 	return ret;
 }
+EXPORT_SYMBOL_GPL(stmmac_pltfr_remove);
 
 #ifdef CONFIG_PM_SLEEP
 /**
@@ -439,8 +442,9 @@ static int stmmac_pltfr_resume(struct device *dev)
 }
 #endif /* CONFIG_PM_SLEEP */
 
-static SIMPLE_DEV_PM_OPS(stmmac_pltfr_pm_ops,
-			 stmmac_pltfr_suspend, stmmac_pltfr_resume);
+SIMPLE_DEV_PM_OPS(stmmac_pltfr_pm_ops, stmmac_pltfr_suspend,
+				       stmmac_pltfr_resume);
+EXPORT_SYMBOL_GPL(stmmac_pltfr_pm_ops);
 
 static struct platform_driver stmmac_pltfr_driver = {
 	.probe = stmmac_pltfr_probe,
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h +4 -0
index 59fe8fb46a48..5be0b101bffd 100644
@@ -19,6 +19,10 @@
 #ifndef __STMMAC_PLATFORM_H__
 #define __STMMAC_PLATFORM_H__
 
+int stmmac_pltfr_probe(struct platform_device *pdev);
+int stmmac_pltfr_remove(struct platform_device *pdev);
+extern const struct dev_pm_ops stmmac_pltfr_pm_ops;
+
 extern const struct stmmac_of_data lpc18xx_dwmac_data;
 extern const struct stmmac_of_data meson6_dwmac_data;
 extern const struct stmmac_of_data sun7i_gmac_data;
Signature · 1 line
1.8.0
#4 lore raw

PATCH 4/11 stmmac: add a generic dwmac driver

In reply to Joachim Eastwood

Create a new driver around the generic device tree match strings in the stmmac platform code. This driver is intended to be used by all platforms that doesn't require any platform specific code to function or is using platform data.

---
 drivers/net/ethernet/stmicro/stmmac/Kconfig        | 12 +++++++
 drivers/net/ethernet/stmicro/stmmac/Makefile       |  4 ++-
 .../net/ethernet/stmicro/stmmac/dwmac-generic.c    | 39 ++++++++++++++++++++++
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |  5 ---
 4 files changed, 54 insertions(+), 6 deletions(-)
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c
drivers/net/ethernet/stmicro/stmmac/Kconfig +12 -0
index 7d3af190be55..d4ed2ac3829b 100644
@@ -26,6 +26,18 @@ config STMMAC_PLATFORM
 
 	  If unsure, say N.
 
+if STMMAC_PLATFORM
+
+config DWMAC_GENERIC
+	tristate "Generic driver for DWMAC"
+	default STMMAC_PLATFORM
+	---help---
+	  Generic DWMAC driver for platforms that don't require any
+	  platform specific code to function or is using platform
+	  data for setup.
+
+endif
+
 config STMMAC_PCI
 	tristate "STMMAC PCI bus support"
 	depends on STMMAC_ETH && PCI
drivers/net/ethernet/stmicro/stmmac/Makefile +3 -1
index 5c165d8d7004..89a353450182 100644
@@ -4,7 +4,9 @@ stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o ring_mode.o	\
 	      dwmac100_core.o dwmac100_dma.o enh_desc.o norm_desc.o	\
 	      mmc_core.o stmmac_hwtstamp.o stmmac_ptp.o $(stmmac-y)
 
-obj-$(CONFIG_STMMAC_PLATFORM) += stmmac-platform.o
+# Ordering matters. Generic driver must be last.
+obj-$(CONFIG_STMMAC_PLATFORM)	+= stmmac-platform.o
+obj-$(CONFIG_DWMAC_GENERIC)	+= dwmac-generic.o
 stmmac-platform-objs:= stmmac_platform.o dwmac-meson.o dwmac-sunxi.o	\
 		       dwmac-sti.o dwmac-socfpga.o dwmac-rk.o		\
 		       dwmac-lpc18xx.o
drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c new file +39 -0
new file mode 100644
index 000000000000..fb9623744e41
@@ -0,0 +1,39 @@
+/*
+ * Generic DWMAC platform driver
+ *
+ * Copyright (C) 2015 Joachim Eastwood <[email protected]>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+
+#include "stmmac_platform.h"
+
+static const struct of_device_id dwmac_generic_match[] = {
+	{ .compatible = "st,spear600-gmac"},
+	{ .compatible = "snps,dwmac-3.610"},
+	{ .compatible = "snps,dwmac-3.70a"},
+	{ .compatible = "snps,dwmac-3.710"},
+	{ .compatible = "snps,dwmac"},
+	{ }
+};
+MODULE_DEVICE_TABLE(of, dwmac_generic_match);
+
+static struct platform_driver dwmac_generic_driver = {
+	.probe  = stmmac_pltfr_probe,
+	.remove = stmmac_pltfr_remove,
+	.driver = {
+		.name           = "dwmac-generic",
+		.pm		= &stmmac_pltfr_pm_ops,
+		.of_match_table = of_match_ptr(dwmac_generic_match),
+	},
+};
+module_platform_driver(dwmac_generic_driver);
+
+MODULE_DESCRIPTION("Generic dwmac driver");
+MODULE_LICENSE("GPL v2");
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +0 -5
index 0d1f1ec96bc0..1777e7124d3e 100644
@@ -43,11 +43,6 @@ static const struct of_device_id stmmac_dt_ids[] = {
 	{ .compatible = "st,stid127-dwmac", .data = &stid127_dwmac_data},
 	{ .compatible = "st,stih407-dwmac", .data = &stih4xx_dwmac_data},
 	{ .compatible = "altr,socfpga-stmmac", .data = &socfpga_gmac_data },
-	{ .compatible = "st,spear600-gmac"},
-	{ .compatible = "snps,dwmac-3.610"},
-	{ .compatible = "snps,dwmac-3.70a"},
-	{ .compatible = "snps,dwmac-3.710"},
-	{ .compatible = "snps,dwmac"},
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, stmmac_dt_ids);
Signature · 1 line
1.8.0
#5 lore raw

PATCH 5/11 stmmac: convert dwmac-lpc18xx to a platform driver

In reply to Joachim Eastwood

Convert platform glue layer into a proper platform driver and add it to the build system.

---
 drivers/net/ethernet/stmicro/stmmac/Kconfig        |  8 +++++++
 drivers/net/ethernet/stmicro/stmmac/Makefile       |  2 +-
 .../net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c    | 27 +++++++++++++++++++++-
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |  1 -
 .../net/ethernet/stmicro/stmmac/stmmac_platform.h  |  1 -
 5 files changed, 35 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/Kconfig +8 -0
index d4ed2ac3829b..aa03e26437e2 100644
@@ -36,6 +36,14 @@ config DWMAC_GENERIC
 	  platform specific code to function or is using platform
 	  data for setup.
 
+config DWMAC_LPC18XX
+	tristate "NXP LPC18xx/43xx DWMAC support"
+	default ARCH_LPC18XX
+	depends on OF
+	select MFD_SYSCON
+	---help---
+	  Support for NXP LPC18xx/43xx DWMAC Ethernet.
+
 endif
 
 config STMMAC_PCI
drivers/net/ethernet/stmicro/stmmac/Makefile +1 -1
index 89a353450182..96a3abfc15bb 100644
@@ -6,10 +6,10 @@ stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o ring_mode.o	\
 
 # Ordering matters. Generic driver must be last.
 obj-$(CONFIG_STMMAC_PLATFORM)	+= stmmac-platform.o
+obj-$(CONFIG_DWMAC_LPC18XX)	+= dwmac-lpc18xx.o
 obj-$(CONFIG_DWMAC_GENERIC)	+= dwmac-generic.o
 stmmac-platform-objs:= stmmac_platform.o dwmac-meson.o dwmac-sunxi.o	\
 		       dwmac-sti.o dwmac-socfpga.o dwmac-rk.o		\
-		       dwmac-lpc18xx.o
 
 obj-$(CONFIG_STMMAC_PCI) += stmmac-pci.o
 stmmac-pci-objs:= stmmac_pci.o
drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c +26 -1
index be02b6a1475f..cb888d3ebbdc 100644
@@ -9,12 +9,16 @@
  */
 
 #include <linux/mfd/syscon.h>
+#include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_net.h>
 #include <linux/phy.h>
+#include <linux/platform_device.h>
 #include <linux/regmap.h>
 #include <linux/stmmac.h>
 
+#include "stmmac_platform.h"
+
 /* Register defines for CREG syscon */
 #define LPC18XX_CREG_CREG6			0x12c
 # define LPC18XX_CREG_CREG6_ETHMODE_MASK	0x7
@@ -67,8 +71,29 @@ static int lpc18xx_dwmac_init(struct platform_device *pdev, void *priv)
 	return 0;
 }
 
-const struct stmmac_of_data lpc18xx_dwmac_data = {
+static const struct stmmac_of_data lpc18xx_dwmac_data = {
 	.has_gmac = 1,
 	.setup = lpc18xx_dwmac_setup,
 	.init = lpc18xx_dwmac_init,
 };
+
+static const struct of_device_id lpc18xx_dwmac_match[] = {
+	{ .compatible = "nxp,lpc1850-dwmac", .data = &lpc18xx_dwmac_data },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, lpc18xx_dwmac_match);
+
+static struct platform_driver lpc18xx_dwmac_driver = {
+	.probe  = stmmac_pltfr_probe,
+	.remove = stmmac_pltfr_remove,
+	.driver = {
+		.name           = "lpc18xx-dwmac",
+		.pm		= &stmmac_pltfr_pm_ops,
+		.of_match_table = lpc18xx_dwmac_match,
+	},
+};
+module_platform_driver(lpc18xx_dwmac_driver);
+
+MODULE_AUTHOR("Joachim Eastwood <[email protected]>");
+MODULE_DESCRIPTION("DWMAC glue for LPC18xx/43xx Ethernet");
+MODULE_LICENSE("GPL v2");
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +0 -1
index 1777e7124d3e..1fd65e780a05 100644
@@ -37,7 +37,6 @@ static const struct of_device_id stmmac_dt_ids[] = {
 	{ .compatible = "rockchip,rk3288-gmac", .data = &rk3288_gmac_data},
 	{ .compatible = "amlogic,meson6-dwmac", .data = &meson6_dwmac_data},
 	{ .compatible = "allwinner,sun7i-a20-gmac", .data = &sun7i_gmac_data},
-	{ .compatible = "nxp,lpc1850-dwmac", .data = &lpc18xx_dwmac_data},
 	{ .compatible = "st,stih415-dwmac", .data = &stih4xx_dwmac_data},
 	{ .compatible = "st,stih416-dwmac", .data = &stih4xx_dwmac_data},
 	{ .compatible = "st,stid127-dwmac", .data = &stid127_dwmac_data},
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h +0 -1
index 5be0b101bffd..23d10f6e8846 100644
@@ -23,7 +23,6 @@ int stmmac_pltfr_probe(struct platform_device *pdev);
 int stmmac_pltfr_remove(struct platform_device *pdev);
 extern const struct dev_pm_ops stmmac_pltfr_pm_ops;
 
-extern const struct stmmac_of_data lpc18xx_dwmac_data;
 extern const struct stmmac_of_data meson6_dwmac_data;
 extern const struct stmmac_of_data sun7i_gmac_data;
 extern const struct stmmac_of_data stih4xx_dwmac_data;
Signature · 1 line
1.8.0
#6 lore raw

PATCH 6/11 stmmac: convert dwmac-meson to platform driver

In reply to Joachim Eastwood

Convert platform glue layer into a proper platform driver and add it to the build system.

---
 drivers/net/ethernet/stmicro/stmmac/Kconfig        | 11 ++++++++++
 drivers/net/ethernet/stmicro/stmmac/Makefile       |  3 ++-
 drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c  | 24 +++++++++++++++++++++-
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |  1 -
 .../net/ethernet/stmicro/stmmac/stmmac_platform.h  |  1 -
 5 files changed, 36 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/Kconfig +11 -0
index aa03e26437e2..a5a56217a845 100644
@@ -44,6 +44,17 @@ config DWMAC_LPC18XX
 	---help---
 	  Support for NXP LPC18xx/43xx DWMAC Ethernet.
 
+config DWMAC_MESON
+	tristate "Amlogic Meson dwmac support"
+	default ARCH_MESON
+	depends on OF
+	help
+	  Support for Ethernet controller on Amlogic Meson SoCs.
+
+	  This selects the Amlogic Meson SoC glue layer support for
+	  the stmmac device driver. This driver is used for Meson6 and
+	  Meson8 SoCs.
+
 endif
 
 config STMMAC_PCI
drivers/net/ethernet/stmicro/stmmac/Makefile +2 -1
index 96a3abfc15bb..69cc046afd8c 100644
@@ -7,8 +7,9 @@ stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o ring_mode.o	\
 # Ordering matters. Generic driver must be last.
 obj-$(CONFIG_STMMAC_PLATFORM)	+= stmmac-platform.o
 obj-$(CONFIG_DWMAC_LPC18XX)	+= dwmac-lpc18xx.o
+obj-$(CONFIG_DWMAC_MESON)	+= dwmac-meson.o
 obj-$(CONFIG_DWMAC_GENERIC)	+= dwmac-generic.o
-stmmac-platform-objs:= stmmac_platform.o dwmac-meson.o dwmac-sunxi.o	\
+stmmac-platform-objs:= stmmac_platform.o dwmac-sunxi.o \
 		       dwmac-sti.o dwmac-socfpga.o dwmac-rk.o		\
 
 obj-$(CONFIG_STMMAC_PCI) += stmmac-pci.o
drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c +23 -1
index cca028d632f6..61a324a87d09 100644
@@ -15,6 +15,7 @@
 #include <linux/ethtool.h>
 #include <linux/io.h>
 #include <linux/ioport.h>
+#include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/stmmac.h>
 
@@ -63,7 +64,28 @@ static void *meson6_dwmac_setup(struct platform_device *pdev)
 	return dwmac;
 }
 
-const struct stmmac_of_data meson6_dwmac_data = {
+static const struct stmmac_of_data meson6_dwmac_data = {
 	.setup		= meson6_dwmac_setup,
 	.fix_mac_speed	= meson6_dwmac_fix_mac_speed,
 };
+
+static const struct of_device_id meson6_dwmac_match[] = {
+	{ .compatible = "amlogic,meson6-dwmac", .data = &meson6_dwmac_data},
+	{ }
+};
+MODULE_DEVICE_TABLE(of, meson6_dwmac_match);
+
+static struct platform_driver meson6_dwmac_driver = {
+	.probe  = stmmac_pltfr_probe,
+	.remove = stmmac_pltfr_remove,
+	.driver = {
+		.name           = "meson6-dwmac",
+		.pm		= &stmmac_pltfr_pm_ops,
+		.of_match_table = meson6_dwmac_match,
+	},
+};
+module_platform_driver(meson6_dwmac_driver);
+
+MODULE_AUTHOR("Beniamino Galvani <[email protected]>");
+MODULE_DESCRIPTION("Amlogic Meson DWMAC glue layer");
+MODULE_LICENSE("GPL v2");
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +0 -1
index 1fd65e780a05..bed31e4db7e3 100644
@@ -35,7 +35,6 @@
 static const struct of_device_id stmmac_dt_ids[] = {
 	/* SoC specific glue layers should come before generic bindings */
 	{ .compatible = "rockchip,rk3288-gmac", .data = &rk3288_gmac_data},
-	{ .compatible = "amlogic,meson6-dwmac", .data = &meson6_dwmac_data},
 	{ .compatible = "allwinner,sun7i-a20-gmac", .data = &sun7i_gmac_data},
 	{ .compatible = "st,stih415-dwmac", .data = &stih4xx_dwmac_data},
 	{ .compatible = "st,stih416-dwmac", .data = &stih4xx_dwmac_data},
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h +0 -1
index 23d10f6e8846..be3e137efc55 100644
@@ -23,7 +23,6 @@ int stmmac_pltfr_probe(struct platform_device *pdev);
 int stmmac_pltfr_remove(struct platform_device *pdev);
 extern const struct dev_pm_ops stmmac_pltfr_pm_ops;
 
-extern const struct stmmac_of_data meson6_dwmac_data;
 extern const struct stmmac_of_data sun7i_gmac_data;
 extern const struct stmmac_of_data stih4xx_dwmac_data;
 extern const struct stmmac_of_data stid127_dwmac_data;
Signature · 1 line
1.8.0
#7 lore raw

PATCH 7/11 stmmac: convert dwmac-rk to platform driver

In reply to Joachim Eastwood

Convert platform glue layer into a proper platform driver and add it to the build system.

---
 drivers/net/ethernet/stmicro/stmmac/Kconfig        | 11 +++++++++
 drivers/net/ethernet/stmicro/stmmac/Makefile       |  3 ++-
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c     | 27 +++++++++++++++++++++-
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |  1 -
 .../net/ethernet/stmicro/stmmac/stmmac_platform.h  |  1 -
 5 files changed, 39 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/Kconfig +11 -0
index a5a56217a845..cb984606a819 100644
@@ -55,6 +55,17 @@ config DWMAC_MESON
 	  the stmmac device driver. This driver is used for Meson6 and
 	  Meson8 SoCs.
 
+config DWMAC_ROCKCHIP
+	tristate "Rockchip dwmac support"
+	default ARCH_ROCKCHIP
+	depends on OF
+	select MFD_SYSCON
+	help
+	  Support for Ethernet controller on Rockchip RK3288 SoC.
+
+	  This selects the Rockchip RK3288 SoC glue layer support for
+	  the stmmac device driver.
+
 endif
 
 config STMMAC_PCI
drivers/net/ethernet/stmicro/stmmac/Makefile +2 -1
index 69cc046afd8c..e67dea423324 100644
@@ -8,9 +8,10 @@ stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o ring_mode.o	\
 obj-$(CONFIG_STMMAC_PLATFORM)	+= stmmac-platform.o
 obj-$(CONFIG_DWMAC_LPC18XX)	+= dwmac-lpc18xx.o
 obj-$(CONFIG_DWMAC_MESON)	+= dwmac-meson.o
+obj-$(CONFIG_DWMAC_ROCKCHIP)	+= dwmac-rk.o
 obj-$(CONFIG_DWMAC_GENERIC)	+= dwmac-generic.o
 stmmac-platform-objs:= stmmac_platform.o dwmac-sunxi.o \
-		       dwmac-sti.o dwmac-socfpga.o dwmac-rk.o		\
+		       dwmac-sti.o dwmac-socfpga.o
 
 obj-$(CONFIG_STMMAC_PCI) += stmmac-pci.o
 stmmac-pci-objs:= stmmac_pci.o
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +26 -1
index 6249a4ec08f0..30e28f0d9a60 100644
@@ -22,13 +22,17 @@
 #include <linux/phy.h>
 #include <linux/of_net.h>
 #include <linux/gpio.h>
+#include <linux/module.h>
 #include <linux/of_gpio.h>
 #include <linux/of_device.h>
+#include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
 #include <linux/delay.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
 
+#include "stmmac_platform.h"
+
 struct rk_priv_data {
 	struct platform_device *pdev;
 	int phy_iface;
@@ -428,10 +432,31 @@ static void rk_fix_speed(void *priv, unsigned int speed)
 		dev_err(dev, "unsupported interface %d", bsp_priv->phy_iface);
 }
 
-const struct stmmac_of_data rk3288_gmac_data = {
+static const struct stmmac_of_data rk3288_gmac_data = {
 	.has_gmac = 1,
 	.fix_mac_speed = rk_fix_speed,
 	.setup = rk_gmac_setup,
 	.init = rk_gmac_init,
 	.exit = rk_gmac_exit,
 };
+
+static const struct of_device_id rk_gmac_dwmac_match[] = {
+	{ .compatible = "rockchip,rk3288-gmac", .data = &rk3288_gmac_data},
+	{ }
+};
+MODULE_DEVICE_TABLE(of, rk_gmac_dwmac_match);
+
+static struct platform_driver rk_gmac_dwmac_driver = {
+	.probe  = stmmac_pltfr_probe,
+	.remove = stmmac_pltfr_remove,
+	.driver = {
+		.name           = "rk_gmac-dwmac",
+		.pm		= &stmmac_pltfr_pm_ops,
+		.of_match_table = rk_gmac_dwmac_match,
+	},
+};
+module_platform_driver(rk_gmac_dwmac_driver);
+
+MODULE_AUTHOR("Chen-Zhi (Roger Chen) <[email protected]>");
+MODULE_DESCRIPTION("Rockchip RK3288 DWMAC specific glue layer");
+MODULE_LICENSE("GPL");
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +0 -1
index bed31e4db7e3..674f7bd1641a 100644
@@ -34,7 +34,6 @@
 
 static const struct of_device_id stmmac_dt_ids[] = {
 	/* SoC specific glue layers should come before generic bindings */
-	{ .compatible = "rockchip,rk3288-gmac", .data = &rk3288_gmac_data},
 	{ .compatible = "allwinner,sun7i-a20-gmac", .data = &sun7i_gmac_data},
 	{ .compatible = "st,stih415-dwmac", .data = &stih4xx_dwmac_data},
 	{ .compatible = "st,stih416-dwmac", .data = &stih4xx_dwmac_data},
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h +0 -1
index be3e137efc55..fff2a885ffd8 100644
@@ -27,6 +27,5 @@ extern const struct stmmac_of_data sun7i_gmac_data;
 extern const struct stmmac_of_data stih4xx_dwmac_data;
 extern const struct stmmac_of_data stid127_dwmac_data;
 extern const struct stmmac_of_data socfpga_gmac_data;
-extern const struct stmmac_of_data rk3288_gmac_data;
 
 #endif /* __STMMAC_PLATFORM_H__ */
Signature · 1 line
1.8.0
#8 lore raw

PATCH 8/11 stmmac: convert dwmac-socfpga to platform driver

In reply to Joachim Eastwood

Convert platform glue layer into a proper platform driver and add it to the build system.

---
 drivers/net/ethernet/stmicro/stmmac/Kconfig         | 12 ++++++++++++
 drivers/net/ethernet/stmicro/stmmac/Makefile        |  3 ++-
 drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c | 21 ++++++++++++++++++++-
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c   |  1 -
 .../net/ethernet/stmicro/stmmac/stmmac_platform.h   |  1 -
 5 files changed, 34 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/Kconfig +12 -0
index cb984606a819..f103e57e3ac0 100644
@@ -66,6 +66,18 @@ config DWMAC_ROCKCHIP
 	  This selects the Rockchip RK3288 SoC glue layer support for
 	  the stmmac device driver.
 
+config DWMAC_SOCFPGA
+	tristate "SOCFPGA dwmac support"
+	default ARCH_SOCFPGA
+	depends on OF
+	select MFD_SYSCON
+	help
+	  Support for ethernet controller on Altera SOCFPGA
+
+	  This selects the Altera SOCFPGA SoC glue layer support
+	  for the stmmac device driver. This driver is used for
+	  arria5 and cyclone5 FPGA SoCs.
+
 endif
 
 config STMMAC_PCI
drivers/net/ethernet/stmicro/stmmac/Makefile +2 -1
index e67dea423324..690741d6fc10 100644
@@ -9,9 +9,10 @@ obj-$(CONFIG_STMMAC_PLATFORM)	+= stmmac-platform.o
 obj-$(CONFIG_DWMAC_LPC18XX)	+= dwmac-lpc18xx.o
 obj-$(CONFIG_DWMAC_MESON)	+= dwmac-meson.o
 obj-$(CONFIG_DWMAC_ROCKCHIP)	+= dwmac-rk.o
+obj-$(CONFIG_DWMAC_SOCFPGA)	+= dwmac-socfpga.o
 obj-$(CONFIG_DWMAC_GENERIC)	+= dwmac-generic.o
 stmmac-platform-objs:= stmmac_platform.o dwmac-sunxi.o \
-		       dwmac-sti.o dwmac-socfpga.o
+		       dwmac-sti.o
 
 obj-$(CONFIG_STMMAC_PCI) += stmmac-pci.o
 stmmac-pci-objs:= stmmac_pci.o
drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c +20 -1
index 5a36bd2c7837..8141c5b844ae 100644
@@ -257,9 +257,28 @@ static int socfpga_dwmac_init(struct platform_device *pdev, void *priv)
 	return ret;
 }
 
-const struct stmmac_of_data socfpga_gmac_data = {
+static const struct stmmac_of_data socfpga_gmac_data = {
 	.setup = socfpga_dwmac_probe,
 	.init = socfpga_dwmac_init,
 	.exit = socfpga_dwmac_exit,
 	.fix_mac_speed = socfpga_dwmac_fix_mac_speed,
 };
+
+static const struct of_device_id socfpga_dwmac_match[] = {
+	{ .compatible = "altr,socfpga-stmmac", .data = &socfpga_gmac_data },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, socfpga_dwmac_match);
+
+static struct platform_driver socfpga_dwmac_driver = {
+	.probe  = stmmac_pltfr_probe,
+	.remove = stmmac_pltfr_remove,
+	.driver = {
+		.name           = "socfpga-dwmac",
+		.pm		= &stmmac_pltfr_pm_ops,
+		.of_match_table = socfpga_dwmac_match,
+	},
+};
+module_platform_driver(socfpga_dwmac_driver);
+
+MODULE_LICENSE("GPL v2");
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +0 -1
index 674f7bd1641a..4553b50833ea 100644
@@ -39,7 +39,6 @@ static const struct of_device_id stmmac_dt_ids[] = {
 	{ .compatible = "st,stih416-dwmac", .data = &stih4xx_dwmac_data},
 	{ .compatible = "st,stid127-dwmac", .data = &stid127_dwmac_data},
 	{ .compatible = "st,stih407-dwmac", .data = &stih4xx_dwmac_data},
-	{ .compatible = "altr,socfpga-stmmac", .data = &socfpga_gmac_data },
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, stmmac_dt_ids);
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h +0 -1
index fff2a885ffd8..3c8d7088361f 100644
@@ -26,6 +26,5 @@ extern const struct dev_pm_ops stmmac_pltfr_pm_ops;
 extern const struct stmmac_of_data sun7i_gmac_data;
 extern const struct stmmac_of_data stih4xx_dwmac_data;
 extern const struct stmmac_of_data stid127_dwmac_data;
-extern const struct stmmac_of_data socfpga_gmac_data;
 
 #endif /* __STMMAC_PLATFORM_H__ */
Signature · 1 line
1.8.0
#9 lore raw

PATCH 9/11 stmmac: convert dwmac-sti to platform driver

In reply to Joachim Eastwood

Convert platform glue layer into a proper platform driver and add it to the build system.

---
 drivers/net/ethernet/stmicro/stmmac/Kconfig        | 12 +++++++++
 drivers/net/ethernet/stmicro/stmmac/Makefile       |  2 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c    | 29 ++++++++++++++++++++--
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |  4 ---
 .../net/ethernet/stmicro/stmmac/stmmac_platform.h  |  2 --
 5 files changed, 40 insertions(+), 9 deletions(-)
drivers/net/ethernet/stmicro/stmmac/Kconfig +12 -0
index f103e57e3ac0..f5b9f051337d 100644
@@ -78,6 +78,18 @@ config DWMAC_SOCFPGA
 	  for the stmmac device driver. This driver is used for
 	  arria5 and cyclone5 FPGA SoCs.
 
+config DWMAC_STI
+	tristate "STi GMAC support"
+	default ARCH_STI
+	depends on OF
+	select MFD_SYSCON
+	---help---
+	  Support for ethernet controller on STi SOCs.
+
+	  This selects STi SoC glue layer support for the stmmac
+	  device driver. This driver is used on for the STi series
+	  SOCs GMAC ethernet controller.
+
 endif
 
 config STMMAC_PCI
drivers/net/ethernet/stmicro/stmmac/Makefile +1 -1
index 690741d6fc10..f8e5ddba7fd2 100644
@@ -10,9 +10,9 @@ obj-$(CONFIG_DWMAC_LPC18XX)	+= dwmac-lpc18xx.o
 obj-$(CONFIG_DWMAC_MESON)	+= dwmac-meson.o
 obj-$(CONFIG_DWMAC_ROCKCHIP)	+= dwmac-rk.o
 obj-$(CONFIG_DWMAC_SOCFPGA)	+= dwmac-socfpga.o
+obj-$(CONFIG_DWMAC_STI)		+= dwmac-sti.o
 obj-$(CONFIG_DWMAC_GENERIC)	+= dwmac-generic.o
 stmmac-platform-objs:= stmmac_platform.o dwmac-sunxi.o \
-		       dwmac-sti.o
 
 obj-$(CONFIG_STMMAC_PCI) += stmmac-pci.o
 stmmac-pci-objs:= stmmac_pci.o
drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c +27 -2
index bb6e2dc61bec..a2e8111c5d14 100644
@@ -17,6 +17,7 @@
 #include <linux/stmmac.h>
 #include <linux/phy.h>
 #include <linux/mfd/syscon.h>
+#include <linux/module.h>
 #include <linux/regmap.h>
 #include <linux/clk.h>
 #include <linux/of.h>
@@ -351,16 +352,40 @@ static void *sti_dwmac_setup(struct platform_device *pdev)
 	return dwmac;
 }
 
-const struct stmmac_of_data stih4xx_dwmac_data = {
+static const struct stmmac_of_data stih4xx_dwmac_data = {
 	.fix_mac_speed = stih4xx_fix_retime_src,
 	.setup = sti_dwmac_setup,
 	.init = stix4xx_init,
 	.exit = sti_dwmac_exit,
 };
 
-const struct stmmac_of_data stid127_dwmac_data = {
+static const struct stmmac_of_data stid127_dwmac_data = {
 	.fix_mac_speed = stid127_fix_retime_src,
 	.setup = sti_dwmac_setup,
 	.init = stid127_init,
 	.exit = sti_dwmac_exit,
 };
+
+static const struct of_device_id sti_dwmac_match[] = {
+	{ .compatible = "st,stih415-dwmac", .data = &stih4xx_dwmac_data},
+	{ .compatible = "st,stih416-dwmac", .data = &stih4xx_dwmac_data},
+	{ .compatible = "st,stid127-dwmac", .data = &stid127_dwmac_data},
+	{ .compatible = "st,stih407-dwmac", .data = &stih4xx_dwmac_data},
+	{ }
+};
+MODULE_DEVICE_TABLE(of, sti_dwmac_match);
+
+static struct platform_driver sti_dwmac_driver = {
+	.probe  = stmmac_pltfr_probe,
+	.remove = stmmac_pltfr_remove,
+	.driver = {
+		.name           = "sti-dwmac",
+		.pm		= &stmmac_pltfr_pm_ops,
+		.of_match_table = sti_dwmac_match,
+	},
+};
+module_platform_driver(sti_dwmac_driver);
+
+MODULE_AUTHOR("Srinivas Kandagatla <[email protected]>");
+MODULE_DESCRIPTION("STMicroelectronics DWMAC Specific Glue layer");
+MODULE_LICENSE("GPL");
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +0 -4
index 4553b50833ea..21a3a2c05740 100644
@@ -35,10 +35,6 @@
 static const struct of_device_id stmmac_dt_ids[] = {
 	/* SoC specific glue layers should come before generic bindings */
 	{ .compatible = "allwinner,sun7i-a20-gmac", .data = &sun7i_gmac_data},
-	{ .compatible = "st,stih415-dwmac", .data = &stih4xx_dwmac_data},
-	{ .compatible = "st,stih416-dwmac", .data = &stih4xx_dwmac_data},
-	{ .compatible = "st,stid127-dwmac", .data = &stid127_dwmac_data},
-	{ .compatible = "st,stih407-dwmac", .data = &stih4xx_dwmac_data},
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, stmmac_dt_ids);
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h +0 -2
index 3c8d7088361f..7eb2fa8d97f3 100644
@@ -24,7 +24,5 @@ int stmmac_pltfr_remove(struct platform_device *pdev);
 extern const struct dev_pm_ops stmmac_pltfr_pm_ops;
 
 extern const struct stmmac_of_data sun7i_gmac_data;
-extern const struct stmmac_of_data stih4xx_dwmac_data;
-extern const struct stmmac_of_data stid127_dwmac_data;
 
 #endif /* __STMMAC_PLATFORM_H__ */
Signature · 1 line
1.8.0
#10 lore raw

PATCH 10/11 stmmac: convert dwmac-sunxi to platform driver

In reply to Joachim Eastwood

Convert platform glue layer into a proper platform driver and add it to the build system.

---
 drivers/net/ethernet/stmicro/stmmac/Kconfig        | 10 +++++++++
 drivers/net/ethernet/stmicro/stmmac/Makefile       |  3 ++-
 drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c  | 25 +++++++++++++++++++++-
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |  1 -
 .../net/ethernet/stmicro/stmmac/stmmac_platform.h  |  2 --
 5 files changed, 36 insertions(+), 5 deletions(-)
drivers/net/ethernet/stmicro/stmmac/Kconfig +10 -0
index f5b9f051337d..731e0453a7d4 100644
@@ -90,6 +90,16 @@ config DWMAC_STI
 	  device driver. This driver is used on for the STi series
 	  SOCs GMAC ethernet controller.
 
+config DWMAC_SUNXI
+	tristate "Allwinner GMAC support"
+	default ARCH_SUNXI
+	depends on OF
+	---help---
+	  Support for Allwinner A20/A31 GMAC ethernet controllers.
+
+	  This selects Allwinner SoC glue layer support for the
+	  stmmac device driver. This driver is used for A20/A31
+	  GMAC ethernet controller.
 endif
 
 config STMMAC_PCI
drivers/net/ethernet/stmicro/stmmac/Makefile +2 -1
index f8e5ddba7fd2..92e714a48367 100644
@@ -11,8 +11,9 @@ obj-$(CONFIG_DWMAC_MESON)	+= dwmac-meson.o
 obj-$(CONFIG_DWMAC_ROCKCHIP)	+= dwmac-rk.o
 obj-$(CONFIG_DWMAC_SOCFPGA)	+= dwmac-socfpga.o
 obj-$(CONFIG_DWMAC_STI)		+= dwmac-sti.o
+obj-$(CONFIG_DWMAC_SUNXI)	+= dwmac-sunxi.o
 obj-$(CONFIG_DWMAC_GENERIC)	+= dwmac-generic.o
-stmmac-platform-objs:= stmmac_platform.o dwmac-sunxi.o \
+stmmac-platform-objs:= stmmac_platform.o
 
 obj-$(CONFIG_STMMAC_PCI) += stmmac-pci.o
 stmmac-pci-objs:= stmmac_pci.o
drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c +24 -1
index c5ea9ab75b03..15048ca39759 100644
@@ -18,7 +18,9 @@
 
 #include <linux/stmmac.h>
 #include <linux/clk.h>
+#include <linux/module.h>
 #include <linux/phy.h>
+#include <linux/platform_device.h>
 #include <linux/of_net.h>
 #include <linux/regulator/consumer.h>
 
@@ -132,7 +134,7 @@ static void sun7i_fix_speed(void *priv, unsigned int speed)
 
 /* of_data specifying hardware features and callbacks.
  * hardware features were copied from Allwinner drivers. */
-const struct stmmac_of_data sun7i_gmac_data = {
+static const struct stmmac_of_data sun7i_gmac_data = {
 	.has_gmac = 1,
 	.tx_coe = 1,
 	.fix_mac_speed = sun7i_fix_speed,
@@ -140,3 +142,24 @@ const struct stmmac_of_data sun7i_gmac_data = {
 	.init = sun7i_gmac_init,
 	.exit = sun7i_gmac_exit,
 };
+
+static const struct of_device_id sun7i_dwmac_match[] = {
+	{ .compatible = "allwinner,sun7i-a20-gmac", .data = &sun7i_gmac_data},
+	{ }
+};
+MODULE_DEVICE_TABLE(of, sun7i_dwmac_match);
+
+static struct platform_driver sun7i_dwmac_driver = {
+	.probe  = stmmac_pltfr_probe,
+	.remove = stmmac_pltfr_remove,
+	.driver = {
+		.name           = "sun7i-dwmac",
+		.pm		= &stmmac_pltfr_pm_ops,
+		.of_match_table = sun7i_dwmac_match,
+	},
+};
+module_platform_driver(sun7i_dwmac_driver);
+
+MODULE_AUTHOR("Chen-Yu Tsai <[email protected]>");
+MODULE_DESCRIPTION("Allwinner sunxi DWMAC specific glue layer");
+MODULE_LICENSE("GPL");
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +0 -1
index 21a3a2c05740..e3a3c2bff86e 100644
@@ -34,7 +34,6 @@
 
 static const struct of_device_id stmmac_dt_ids[] = {
 	/* SoC specific glue layers should come before generic bindings */
-	{ .compatible = "allwinner,sun7i-a20-gmac", .data = &sun7i_gmac_data},
 	{ /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, stmmac_dt_ids);
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h +0 -2
index 7eb2fa8d97f3..71da86d7bd00 100644
@@ -23,6 +23,4 @@ int stmmac_pltfr_probe(struct platform_device *pdev);
 int stmmac_pltfr_remove(struct platform_device *pdev);
 extern const struct dev_pm_ops stmmac_pltfr_pm_ops;
 
-extern const struct stmmac_of_data sun7i_gmac_data;
-
 #endif /* __STMMAC_PLATFORM_H__ */
Signature · 1 line
1.8.0
#11 lore raw

PATCH 11/11 stmmac: drop driver from stmmac platform code

In reply to Joachim Eastwood

The dwmac-generic replaces the driver inside the stmmac platform code. This turns stmmac platform into a library used by drivers for common platform driver functions.

---
 .../net/ethernet/stmicro/stmmac/dwmac-generic.c    |  4 +++-
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  | 22 ----------------------
 2 files changed, 3 insertions(+), 23 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c +3 -1
index fb9623744e41..e817a1a44379 100644
@@ -1,6 +1,7 @@
 /*
  * Generic DWMAC platform driver
  *
+ * Copyright (C) 2007-2011  STMicroelectronics Ltd
  * Copyright (C) 2015 Joachim Eastwood <[email protected]>
  *
  * This file is licensed under the terms of the GNU General Public
@@ -12,6 +13,7 @@
 #include <linux/of.h>
 #include <linux/platform_device.h>
 
+#include "stmmac.h"
 #include "stmmac_platform.h"
 
 static const struct of_device_id dwmac_generic_match[] = {
@@ -28,7 +30,7 @@ static struct platform_driver dwmac_generic_driver = {
 	.probe  = stmmac_pltfr_probe,
 	.remove = stmmac_pltfr_remove,
 	.driver = {
-		.name           = "dwmac-generic",
+		.name           = STMMAC_RESOURCE_NAME,
 		.pm		= &stmmac_pltfr_pm_ops,
 		.of_match_table = of_match_ptr(dwmac_generic_match),
 	},
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +0 -22
index e3a3c2bff86e..3e194c3ca297 100644
@@ -32,12 +32,6 @@
 #include "stmmac.h"
 #include "stmmac_platform.h"
 
-static const struct of_device_id stmmac_dt_ids[] = {
-	/* SoC specific glue layers should come before generic bindings */
-	{ /* sentinel */ }
-};
-MODULE_DEVICE_TABLE(of, stmmac_dt_ids);
-
 #ifdef CONFIG_OF
 
 /**
@@ -431,19 +425,3 @@ static int stmmac_pltfr_resume(struct device *dev)
 SIMPLE_DEV_PM_OPS(stmmac_pltfr_pm_ops, stmmac_pltfr_suspend,
 				       stmmac_pltfr_resume);
 EXPORT_SYMBOL_GPL(stmmac_pltfr_pm_ops);
-
-static struct platform_driver stmmac_pltfr_driver = {
-	.probe = stmmac_pltfr_probe,
-	.remove = stmmac_pltfr_remove,
-	.driver = {
-		   .name = STMMAC_RESOURCE_NAME,
-		   .pm = &stmmac_pltfr_pm_ops,
-		   .of_match_table = of_match_ptr(stmmac_dt_ids),
-	},
-};
-
-module_platform_driver(stmmac_pltfr_driver);
-
-MODULE_DESCRIPTION("STMMAC 10/100/1000 Ethernet PLATFORM driver");
-MODULE_AUTHOR("Giuseppe Cavallaro <[email protected]>");
-MODULE_LICENSE("GPL");
Signature · 1 line
1.8.0
Tested-by on the v1 series
#12 lore raw
In reply to Joachim Eastwood
Quoted 12 lines · Joachim Eastwood

This patch set aims to convert the current dwmac glue layers into proper platform drivers as request by Arnd[1]. These changes start from patch 3 and onwards.

Overview:
Platform driver functions like probe and remove are exported from the stmmac platform and then used in subsequent glue later conversions. The conversion involes adding the platform driver boiler plate code and adding it to the build system. The last patch removes the driver from the stmmac platform code thus making it into a library for common platform driver functions.

Quoted 7 lines

The two first patches adds glue layer for my platform. I chose to first add old style glue layer and then convert it. The churn this creates is just 3 lines.

I would be very nice if people could test this patch set on their respective platform. My testing has been limited to compiling and testing on my (LPC18xx) platform. Thanks!

on sunxi boards Cubietruck and Hummingbird A31.

Quoted 37 lines

Next I will look into cleaning up the stmmac platform code.

[1] http://marc.info/?l=linux-arm-kernel&m=143059524606459&w=2

Joachim Eastwood (11):
stmmac: add dwmac glue for NXP 18xx/43xx family
doc: dt: add documentation for nxp,lpc1850-dwmac
stmmac: prepare stmmac platform to support stand alone drivers
stmmac: add a generic dwmac driver
stmmac: convert dwmac-lpc18xx to a platform driver
stmmac: convert dwmac-meson to platform driver
stmmac: convert dwmac-rk to platform driver
stmmac: convert dwmac-socfpga to platform driver
stmmac: convert dwmac-sti to platform driver
stmmac: convert dwmac-sunxi to platform driver
stmmac: drop driver from stmmac platform code

 .../devicetree/bindings/net/nxp,lpc1850-dwmac.txt  | 20 +++++
 drivers/net/ethernet/stmicro/stmmac/Kconfig        | 76 +++++++++++++++++
 drivers/net/ethernet/stmicro/stmmac/Makefile       | 13 ++-
 .../net/ethernet/stmicro/stmmac/dwmac-generic.c    | 41 +++++++++
 .../net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c    | 99 ++++++++++++++++++++++
 drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c  | 24 +++++-
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c     | 27 +++++-
 .../net/ethernet/stmicro/stmmac/dwmac-socfpga.c    | 21 ++++-
 drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c    | 29 ++++++-
 drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c  | 25 +++++-
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  | 49 ++---------
 .../net/ethernet/stmicro/stmmac/stmmac_platform.h  |  9 +-
 12 files changed, 378 insertions(+), 55 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/nxp,lpc1850-dwmac.txt
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c

--
1.8.0

Tested-by on the v1 series
#18 lore raw
In reply to Joachim Eastwood
Quoted 37 lines · Joachim Eastwood

This patch set aims to convert the current dwmac glue layers into proper platform drivers as request by Arnd[1]. These changes start from patch 3 and onwards.

Overview:
Platform driver functions like probe and remove are exported from the stmmac platform and then used in subsequent glue later conversions. The conversion involes adding the platform driver boiler plate code and adding it to the build system. The last patch removes the driver from the stmmac platform code thus making it into a library for common platform driver functions.

The two first patches adds glue layer for my platform. I chose to first add old style glue layer and then convert it. The churn this creates is just 3 lines.

I would be very nice if people could test this patch set on their respective platform. My testing has been limited to compiling and testing on my (LPC18xx) platform. Thanks!

Next I will look into cleaning up the stmmac platform code.

[1] http://marc.info/?l=linux-arm-kernel&m=143059524606459&w=2

Joachim Eastwood (11):
stmmac: add dwmac glue for NXP 18xx/43xx family
doc: dt: add documentation for nxp,lpc1850-dwmac
stmmac: prepare stmmac platform to support stand alone drivers
stmmac: add a generic dwmac driver
stmmac: convert dwmac-lpc18xx to a platform driver
stmmac: convert dwmac-meson to platform driver
stmmac: convert dwmac-rk to platform driver
stmmac: convert dwmac-socfpga to platform driver
stmmac: convert dwmac-sti to platform driver
stmmac: convert dwmac-sunxi to platform driver
stmmac: drop driver from stmmac platform code

Quoted 17 lines
 .../devicetree/bindings/net/nxp,lpc1850-dwmac.txt  | 20 +++++
 drivers/net/ethernet/stmicro/stmmac/Kconfig        | 76 +++++++++++++++++
 drivers/net/ethernet/stmicro/stmmac/Makefile       | 13 ++-
 .../net/ethernet/stmicro/stmmac/dwmac-generic.c    | 41 +++++++++
 .../net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c    | 99 ++++++++++++++++++++++
 drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c  | 24 +++++-
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c     | 27 +++++-
 .../net/ethernet/stmicro/stmmac/dwmac-socfpga.c    | 21 ++++-
 drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c    | 29 ++++++-
 drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c  | 25 +++++-
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  | 49 ++---------
 .../net/ethernet/stmicro/stmmac/stmmac_platform.h  |  9 +-
 12 files changed, 378 insertions(+), 55 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/nxp,lpc1850-dwmac.txt
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c
 create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c

on SoCFPGA devkit.

Thanks,
Dinh

#14 lore raw
In reply to a message not in the archive

Hello

Quoted 13 lines · Chen-Yu Tsai
Quoted 12 lines · Joachim Eastwood

This patch set aims to convert the current dwmac glue layers into proper platform drivers as request by Arnd[1]. These changes start from patch 3 and onwards.

Overview:
Platform driver functions like probe and remove are exported from the stmmac platform and then used in subsequent glue later conversions. The conversion involes adding the platform driver boiler plate code and adding it to the build system. The last patch removes the driver from the stmmac platform code thus making it into a library for common platform driver functions.

Quoted 7 lines
Quoted 7 lines

The two first patches adds glue layer for my platform. I chose to first add old style glue layer and then convert it. The churn this creates is just 3 lines.

I would be very nice if people could test this patch set on their respective platform. My testing has been limited to compiling and testing on my (LPC18xx) platform. Thanks!

I wonder if this will make the compatibility with old platforms (like SH4) not based on DT, where there was not used any glue-logic around the driver and just the platform was the reference.

To be honest, I prefer to not have the Kconfig options. The device-tree compatibility will select the glue-logic needed and we will just pay some bytes when compile.

In my opinion, the Koption(s) introduce a problem when touch the driver and we want to guarantee that, at least, all its parts build fine on all the platforms.

Regards,
Peppe

Quoted 43 lines

on sunxi boards Cubietruck and Hummingbird A31.

Quoted 37 lines

Next I will look into cleaning up the stmmac platform code.

[1] http://marc.info/?l=linux-arm-kernel&m=143059524606459&w=2

Joachim Eastwood (11):
stmmac: add dwmac glue for NXP 18xx/43xx family
doc: dt: add documentation for nxp,lpc1850-dwmac
stmmac: prepare stmmac platform to support stand alone drivers
stmmac: add a generic dwmac driver
stmmac: convert dwmac-lpc18xx to a platform driver
stmmac: convert dwmac-meson to platform driver
stmmac: convert dwmac-rk to platform driver
stmmac: convert dwmac-socfpga to platform driver
stmmac: convert dwmac-sti to platform driver
stmmac: convert dwmac-sunxi to platform driver
stmmac: drop driver from stmmac platform code

  .../devicetree/bindings/net/nxp,lpc1850-dwmac.txt  | 20 +++++
  drivers/net/ethernet/stmicro/stmmac/Kconfig        | 76 +++++++++++++++++
  drivers/net/ethernet/stmicro/stmmac/Makefile       | 13 ++-
  .../net/ethernet/stmicro/stmmac/dwmac-generic.c    | 41 +++++++++
  .../net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c    | 99 ++++++++++++++++++++++
  drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c  | 24 +++++-
  drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c     | 27 +++++-
  .../net/ethernet/stmicro/stmmac/dwmac-socfpga.c    | 21 ++++-
  drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c    | 29 ++++++-
  drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c  | 25 +++++-
  .../net/ethernet/stmicro/stmmac/stmmac_platform.c  | 49 ++---------
  .../net/ethernet/stmicro/stmmac/stmmac_platform.h  |  9 +-
  12 files changed, 378 insertions(+), 55 deletions(-)

create mode 100644 Documentation/devicetree/bindings/net/nxp,lpc1850-dwmac.txt create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-lpc18xx.c

--
1.8.0

#16 lore raw
In reply to a message not in the archive
Quoted 20 lines · On Friday 15 May 2015 09:45:47 Giuseppe CAVALLARO wrote:

Hello

Quoted 17 lines · Chen-Yu Tsai
Quoted 16 lines · Joachim Eastwood

This patch set aims to convert the current dwmac glue layers into proper platform drivers as request by Arnd[1]. These changes start from patch 3 and onwards.

Overview:
Platform driver functions like probe and remove are exported from the stmmac platform and then used in subsequent glue later conversions. The conversion involes adding the platform driver boiler plate code and adding it to the build system. The last patch removes the driver from the stmmac platform code thus making it into a library for common platform driver functions.

The two first patches adds glue layer for my platform. I chose to first add old style glue layer and then convert it. The churn this creates is just 3 lines.

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

I would be very nice if people could test this patch set on their respective platform. My testing has been limited to compiling and testing on my (LPC18xx) platform. Thanks!

I wonder if this will make the compatibility with old platforms (like SH4) not based on DT, where there was not used any glue-logic around the driver and just the platform was the reference.

With patch 11, this gets handled by the dwmac-generic driver.

Quoted 7 lines

To be honest, I prefer to not have the Kconfig options. The device-tree compatibility will select the glue-logic needed and we will just pay some bytes when compile.

In my opinion, the Koption(s) introduce a problem when touch the driver and we want to guarantee that, at least, all its parts build fine on all the platforms.

The current model is not scalable and requires modifying the base driver for each variation, and the change brings the driver in line with how we do things for other platform drivers.

We should always be able to build all soc-specific glue drivers with 'allmodconfig' for build testing, and a lot of us run that frequently to find regressions.

Arnd

#17 lore raw

Hi Arnd

Quoted 25 lines · Arnd Bergmann
Quoted 24 lines · On Friday 15 May 2015 09:45:47 Giuseppe CAVALLARO wrote:

Hello

Quoted 20 lines · Chen-Yu Tsai
Quoted 19 lines · Joachim Eastwood

This patch set aims to convert the current dwmac glue layers into proper platform drivers as request by Arnd[1]. These changes start from patch 3 and onwards.

Overview:
Platform driver functions like probe and remove are exported from the stmmac platform and then used in subsequent glue later conversions. The conversion involes adding the platform driver boiler plate code and adding it to the build system. The last patch removes the driver from the stmmac platform code thus making it into a library for common platform driver functions.

The two first patches adds glue layer for my platform. I chose to first add old style glue layer and then convert it. The churn this creates is just 3 lines.

I would be very nice if people could test this patch set on their respective platform. My testing has been limited to compiling and testing on my (LPC18xx) platform. Thanks!

Quoted 6 lines
Quoted 4 lines

I wonder if this will make the compatibility with old platforms (like SH4) not based on DT, where there was not used any glue-logic around the driver and just the platform was the reference.

With patch 11, this gets handled by the dwmac-generic driver.

ok

Quoted 9 lines
Quoted 8 lines

To be honest, I prefer to not have the Kconfig options. The device-tree compatibility will select the glue-logic needed and we will just pay some bytes when compile.

In my opinion, the Koption(s) introduce a problem when touch the driver and we want to guarantee that, at least, all its parts build fine on all the platforms.

Quoted 7 lines

The current model is not scalable and requires modifying the base driver for each variation, and the change brings the driver in line with how we do things for other platform drivers.

We should always be able to build all soc-specific glue drivers with 'allmodconfig' for build testing, and a lot of us run that frequently to find regressions.

thx for your prompt feedback

Peppe

Quoted 4 lines

Arnd

#19 lore raw
In reply to Joachim Eastwood

From: Joachim Eastwood <[email protected]>
Date: Thu, 14 May 2015 12:10:55 +0200

Quoted 16 lines

This patch set aims to convert the current dwmac glue layers into proper platform drivers as request by Arnd[1]. These changes start from patch 3 and onwards.

Overview:
Platform driver functions like probe and remove are exported from the stmmac platform and then used in subsequent glue later conversions. The conversion involes adding the platform driver boiler plate code and adding it to the build system. The last patch removes the driver from the stmmac platform code thus making it into a library for common platform driver functions.

The two first patches adds glue layer for my platform. I chose to first add old style glue layer and then convert it. The churn this creates is just 3 lines.

Quoted 7 lines

I would be very nice if people could test this patch set on their respective platform. My testing has been limited to compiling and testing on my (LPC18xx) platform. Thanks!

Next I will look into cleaning up the stmmac platform code.

[1] http://marc.info/?l=linux-arm-kernel&m=143059524606459&w=2

Series applied, thanks Joachim.