Commit 2fdbfea5 authored by David S. Miller's avatar David S. Miller

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: default avatarDavid S. Miller <davem@davemloft.net>
parents 4daaab4f 318fd490
* Amlogic Meson DWMAC Ethernet controller
The device inherits all the properties of the dwmac/stmmac devices
described in the file net/stmmac.txt with the following changes.
Required properties:
- compatible: should be "amlogic,meson6-dwmac" along with "snps,dwmac"
and any applicable more detailed version number
described in net/stmmac.txt
- reg: should contain a register range for the dwmac controller and
another one for the Amlogic specific configuration
Example:
ethmac: ethernet@c9410000 {
compatible = "amlogic,meson6-dwmac", "snps,dwmac";
reg = <0xc9410000 0x10000
0xc1108108 0x4>;
interrupts = <0 8 1>;
interrupt-names = "macirq";
clocks = <&clk81>;
clock-names = "stmmaceth";
}
...@@ -26,6 +26,16 @@ config STMMAC_PLATFORM ...@@ -26,6 +26,16 @@ config STMMAC_PLATFORM
If unsure, say N. If unsure, say N.
config DWMAC_MESON
bool "Amlogic Meson dwmac support"
depends on STMMAC_PLATFORM && ARCH_MESON
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.
config DWMAC_SOCFPGA config DWMAC_SOCFPGA
bool "SOCFPGA dwmac support" bool "SOCFPGA dwmac support"
depends on STMMAC_PLATFORM && MFD_SYSCON && (ARCH_SOCFPGA || COMPILE_TEST) depends on STMMAC_PLATFORM && MFD_SYSCON && (ARCH_SOCFPGA || COMPILE_TEST)
......
obj-$(CONFIG_STMMAC_ETH) += stmmac.o obj-$(CONFIG_STMMAC_ETH) += stmmac.o
stmmac-$(CONFIG_STMMAC_PLATFORM) += stmmac_platform.o stmmac-$(CONFIG_STMMAC_PLATFORM) += stmmac_platform.o
stmmac-$(CONFIG_STMMAC_PCI) += stmmac_pci.o stmmac-$(CONFIG_STMMAC_PCI) += stmmac_pci.o
stmmac-$(CONFIG_DWMAC_MESON) += dwmac-meson.o
stmmac-$(CONFIG_DWMAC_SUNXI) += dwmac-sunxi.o stmmac-$(CONFIG_DWMAC_SUNXI) += dwmac-sunxi.o
stmmac-$(CONFIG_DWMAC_STI) += dwmac-sti.o stmmac-$(CONFIG_DWMAC_STI) += dwmac-sti.o
stmmac-$(CONFIG_DWMAC_SOCFPGA) += dwmac-socfpga.o stmmac-$(CONFIG_DWMAC_SOCFPGA) += dwmac-socfpga.o
......
/*
* Amlogic Meson DWMAC glue layer
*
* Copyright (C) 2014 Beniamino Galvani <b.galvani@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <linux/device.h>
#include <linux/ethtool.h>
#include <linux/io.h>
#include <linux/ioport.h>
#include <linux/platform_device.h>
#include <linux/stmmac.h>
#define ETHMAC_SPEED_100 BIT(1)
struct meson_dwmac {
struct device *dev;
void __iomem *reg;
};
static void meson6_dwmac_fix_mac_speed(void *priv, unsigned int speed)
{
struct meson_dwmac *dwmac = priv;
unsigned int val;
val = readl(dwmac->reg);
switch (speed) {
case SPEED_10:
val &= ~ETHMAC_SPEED_100;
break;
case SPEED_100:
val |= ETHMAC_SPEED_100;
break;
}
writel(val, dwmac->reg);
}
static void *meson6_dwmac_setup(struct platform_device *pdev)
{
struct meson_dwmac *dwmac;
struct resource *res;
dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
if (!dwmac)
return ERR_PTR(-ENOMEM);
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
dwmac->reg = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(dwmac->reg))
return dwmac->reg;
return dwmac;
}
const struct stmmac_of_data meson6_dwmac_data = {
.setup = meson6_dwmac_setup,
.fix_mac_speed = meson6_dwmac_fix_mac_speed,
};
...@@ -137,6 +137,9 @@ void stmmac_disable_eee_mode(struct stmmac_priv *priv); ...@@ -137,6 +137,9 @@ void stmmac_disable_eee_mode(struct stmmac_priv *priv);
bool stmmac_eee_init(struct stmmac_priv *priv); bool stmmac_eee_init(struct stmmac_priv *priv);
#ifdef CONFIG_STMMAC_PLATFORM #ifdef CONFIG_STMMAC_PLATFORM
#ifdef CONFIG_DWMAC_MESON
extern const struct stmmac_of_data meson6_dwmac_data;
#endif
#ifdef CONFIG_DWMAC_SUNXI #ifdef CONFIG_DWMAC_SUNXI
extern const struct stmmac_of_data sun7i_gmac_data; extern const struct stmmac_of_data sun7i_gmac_data;
#endif #endif
......
...@@ -30,6 +30,9 @@ ...@@ -30,6 +30,9 @@
#include "stmmac.h" #include "stmmac.h"
static const struct of_device_id stmmac_dt_ids[] = { static const struct of_device_id stmmac_dt_ids[] = {
#ifdef CONFIG_DWMAC_MESON
{ .compatible = "amlogic,meson6-dwmac", .data = &meson6_dwmac_data},
#endif
#ifdef CONFIG_DWMAC_SUNXI #ifdef CONFIG_DWMAC_SUNXI
{ .compatible = "allwinner,sun7i-a20-gmac", .data = &sun7i_gmac_data}, { .compatible = "allwinner,sun7i-a20-gmac", .data = &sun7i_gmac_data},
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment