Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+109
+25
Documentation/devicetree/bindings/net/meson-dwmac.txt
··· 1 + * Amlogic Meson DWMAC Ethernet controller 2 + 3 + The device inherits all the properties of the dwmac/stmmac devices 4 + described in the file net/stmmac.txt with the following changes. 5 + 6 + Required 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 + 15 + Example: 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 + }
+10
drivers/net/ethernet/stmicro/stmmac/Kconfig
··· 26 26 27 27 If unsure, say N. 28 28 29 + config 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 + 29 39 config DWMAC_SOCFPGA 30 40 bool "SOCFPGA dwmac support" 31 41 depends on STMMAC_PLATFORM && MFD_SYSCON && (ARCH_SOCFPGA || COMPILE_TEST)
+1
drivers/net/ethernet/stmicro/stmmac/Makefile
··· 1 1 obj-$(CONFIG_STMMAC_ETH) += stmmac.o 2 2 stmmac-$(CONFIG_STMMAC_PLATFORM) += stmmac_platform.o 3 3 stmmac-$(CONFIG_STMMAC_PCI) += stmmac_pci.o 4 + stmmac-$(CONFIG_DWMAC_MESON) += dwmac-meson.o 4 5 stmmac-$(CONFIG_DWMAC_SUNXI) += dwmac-sunxi.o 5 6 stmmac-$(CONFIG_DWMAC_STI) += dwmac-sti.o 6 7 stmmac-$(CONFIG_DWMAC_SOCFPGA) += dwmac-socfpga.o
+67
drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c
··· 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 + 23 + struct meson_dwmac { 24 + struct device *dev; 25 + void __iomem *reg; 26 + }; 27 + 28 + static 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 + 47 + static 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 + 64 + const struct stmmac_of_data meson6_dwmac_data = { 65 + .setup = meson6_dwmac_setup, 66 + .fix_mac_speed = meson6_dwmac_fix_mac_speed, 67 + };
+3
drivers/net/ethernet/stmicro/stmmac/stmmac.h
··· 137 137 bool stmmac_eee_init(struct stmmac_priv *priv); 138 138 139 139 #ifdef CONFIG_STMMAC_PLATFORM 140 + #ifdef CONFIG_DWMAC_MESON 141 + extern const struct stmmac_of_data meson6_dwmac_data; 142 + #endif 140 143 #ifdef CONFIG_DWMAC_SUNXI 141 144 extern const struct stmmac_of_data sun7i_gmac_data; 142 145 #endif
+3
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
··· 30 30 #include "stmmac.h" 31 31 32 32 static 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 36 #ifdef CONFIG_DWMAC_SUNXI 34 37 { .compatible = "allwinner,sun7i-a20-gmac", .data = &sun7i_gmac_data}, 35 38 #endif