aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2014-09-26 00:13:06 -0400
committerDavid S. Miller <davem@davemloft.net>2014-09-26 00:13:06 -0400
commit2fdbfea5735d3deb30a8782c57f7210cb034e69d (patch)
tree2e1bdb8fb62b9a86b9a72897099dab71e30435ca
parent4daaab4f0c2b55adccab08da06e17acc270cb84a (diff)
parent318fd4909dcb7dc43a869132c2f38b769ed92d6a (diff)
Merge branch 'stmmac'
Beniamino Galvani says: ==================== net: stmmac glue layer for Amlogic Meson SoCs the Ethernet controller available in Amlogic Meson6 and Meson8 SoCs is a Synopsys DesignWare MAC IP core, already supported by the stmmac driver. These patches add a glue layer to the driver for the platform-specific settings required by the Amlogic variant. This has been tested on a Amlogic S802 device with the initial Meson support submitted by Carlo Caione [1]. [1] http://lwn.net/Articles/612000/ ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--Documentation/devicetree/bindings/net/meson-dwmac.txt25
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/Kconfig10
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/Makefile1
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c67
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac.h3
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c3
6 files changed, 109 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/net/meson-dwmac.txt b/Documentation/devicetree/bindings/net/meson-dwmac.txt
new file mode 100644
index 000000000000..ec633d74a8a8
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/meson-dwmac.txt
@@ -0,0 +1,25 @@
1* Amlogic Meson DWMAC Ethernet controller
2
3The device inherits all the properties of the dwmac/stmmac devices
4described in the file net/stmmac.txt with the following changes.
5
6Required properties:
7
8- compatible: should be "amlogic,meson6-dwmac" along with "snps,dwmac"
9 and any applicable more detailed version number
10 described in net/stmmac.txt
11
12- reg: should contain a register range for the dwmac controller and
13 another one for the Amlogic specific configuration
14
15Example:
16
17 ethmac: ethernet@c9410000 {
18 compatible = "amlogic,meson6-dwmac", "snps,dwmac";
19 reg = <0xc9410000 0x10000
20 0xc1108108 0x4>;
21 interrupts = <0 8 1>;
22 interrupt-names = "macirq";
23 clocks = <&clk81>;
24 clock-names = "stmmaceth";
25 }
diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
index 2d09c116cbc8..b02d4a3ffa37 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
+++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
@@ -26,6 +26,16 @@ config STMMAC_PLATFORM
26 26
27 If unsure, say N. 27 If unsure, say N.
28 28
29config DWMAC_MESON
30 bool "Amlogic Meson dwmac support"
31 depends on STMMAC_PLATFORM && ARCH_MESON
32 help
33 Support for Ethernet controller on Amlogic Meson SoCs.
34
35 This selects the Amlogic Meson SoC glue layer support for
36 the stmmac device driver. This driver is used for Meson6 and
37 Meson8 SoCs.
38
29config DWMAC_SOCFPGA 39config DWMAC_SOCFPGA
30 bool "SOCFPGA dwmac support" 40 bool "SOCFPGA dwmac support"
31 depends on STMMAC_PLATFORM && MFD_SYSCON && (ARCH_SOCFPGA || COMPILE_TEST) 41 depends on STMMAC_PLATFORM && MFD_SYSCON && (ARCH_SOCFPGA || COMPILE_TEST)
diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile
index 18695ebef7e4..0533d0ba783d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Makefile
+++ b/drivers/net/ethernet/stmicro/stmmac/Makefile
@@ -1,6 +1,7 @@
1obj-$(CONFIG_STMMAC_ETH) += stmmac.o 1obj-$(CONFIG_STMMAC_ETH) += stmmac.o
2stmmac-$(CONFIG_STMMAC_PLATFORM) += stmmac_platform.o 2stmmac-$(CONFIG_STMMAC_PLATFORM) += stmmac_platform.o
3stmmac-$(CONFIG_STMMAC_PCI) += stmmac_pci.o 3stmmac-$(CONFIG_STMMAC_PCI) += stmmac_pci.o
4stmmac-$(CONFIG_DWMAC_MESON) += dwmac-meson.o
4stmmac-$(CONFIG_DWMAC_SUNXI) += dwmac-sunxi.o 5stmmac-$(CONFIG_DWMAC_SUNXI) += dwmac-sunxi.o
5stmmac-$(CONFIG_DWMAC_STI) += dwmac-sti.o 6stmmac-$(CONFIG_DWMAC_STI) += dwmac-sti.o
6stmmac-$(CONFIG_DWMAC_SOCFPGA) += dwmac-socfpga.o 7stmmac-$(CONFIG_DWMAC_SOCFPGA) += dwmac-socfpga.o
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c
new file mode 100644
index 000000000000..d225a603e604
--- /dev/null
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c
@@ -0,0 +1,67 @@
1/*
2 * Amlogic Meson DWMAC glue layer
3 *
4 * Copyright (C) 2014 Beniamino Galvani <b.galvani@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * You should have received a copy of the GNU General Public License
11 * along with this program. If not, see <http://www.gnu.org/licenses/>.
12 */
13
14#include <linux/device.h>
15#include <linux/ethtool.h>
16#include <linux/io.h>
17#include <linux/ioport.h>
18#include <linux/platform_device.h>
19#include <linux/stmmac.h>
20
21#define ETHMAC_SPEED_100 BIT(1)
22
23struct meson_dwmac {
24 struct device *dev;
25 void __iomem *reg;
26};
27
28static void meson6_dwmac_fix_mac_speed(void *priv, unsigned int speed)
29{
30 struct meson_dwmac *dwmac = priv;
31 unsigned int val;
32
33 val = readl(dwmac->reg);
34
35 switch (speed) {
36 case SPEED_10:
37 val &= ~ETHMAC_SPEED_100;
38 break;
39 case SPEED_100:
40 val |= ETHMAC_SPEED_100;
41 break;
42 }
43
44 writel(val, dwmac->reg);
45}
46
47static void *meson6_dwmac_setup(struct platform_device *pdev)
48{
49 struct meson_dwmac *dwmac;
50 struct resource *res;
51
52 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
53 if (!dwmac)
54 return ERR_PTR(-ENOMEM);
55
56 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
57 dwmac->reg = devm_ioremap_resource(&pdev->dev, res);
58 if (IS_ERR(dwmac->reg))
59 return dwmac->reg;
60
61 return dwmac;
62}
63
64const struct stmmac_of_data meson6_dwmac_data = {
65 .setup = meson6_dwmac_setup,
66 .fix_mac_speed = meson6_dwmac_fix_mac_speed,
67};
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index 58097c0e2ad5..44528896355d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -137,6 +137,9 @@ void stmmac_disable_eee_mode(struct stmmac_priv *priv);
137bool stmmac_eee_init(struct stmmac_priv *priv); 137bool stmmac_eee_init(struct stmmac_priv *priv);
138 138
139#ifdef CONFIG_STMMAC_PLATFORM 139#ifdef CONFIG_STMMAC_PLATFORM
140#ifdef CONFIG_DWMAC_MESON
141extern const struct stmmac_of_data meson6_dwmac_data;
142#endif
140#ifdef CONFIG_DWMAC_SUNXI 143#ifdef CONFIG_DWMAC_SUNXI
141extern const struct stmmac_of_data sun7i_gmac_data; 144extern const struct stmmac_of_data sun7i_gmac_data;
142#endif 145#endif
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index bb524a932be4..652171706258 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -30,6 +30,9 @@
30#include "stmmac.h" 30#include "stmmac.h"
31 31
32static const struct of_device_id stmmac_dt_ids[] = { 32static const struct of_device_id stmmac_dt_ids[] = {
33#ifdef CONFIG_DWMAC_MESON
34 { .compatible = "amlogic,meson6-dwmac", .data = &meson6_dwmac_data},
35#endif
33#ifdef CONFIG_DWMAC_SUNXI 36#ifdef CONFIG_DWMAC_SUNXI
34 { .compatible = "allwinner,sun7i-a20-gmac", .data = &sun7i_gmac_data}, 37 { .compatible = "allwinner,sun7i-a20-gmac", .data = &sun7i_gmac_data},
35#endif 38#endif