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
 
 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
 
 
 #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>
 
 
 /* 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,
        .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 <wens@csie.org>");
+MODULE_DESCRIPTION("Allwinner sunxi DWMAC specific glue layer");
+MODULE_LICENSE("GPL");
 
 
 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);