diff options
| author | Iyappan Subramanian <isubramanian@apm.com> | 2014-08-07 18:14:28 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2014-08-11 14:50:33 -0400 |
| commit | e6ad767305eb6ea80ce06c1eaa1b0977e8361998 (patch) | |
| tree | eb1973422d780d9295bddd2da617812cd1c73456 | |
| parent | 3d390425a649b9eb739e53d34cd891c1631b37cd (diff) | |
drivers: net: Add APM X-Gene SoC ethernet driver support.
This patch adds network driver for APM X-Gene SoC ethernet.
Signed-off-by: Iyappan Subramanian <isubramanian@apm.com>
Signed-off-by: Ravi Patel <rapatel@apm.com>
Signed-off-by: Keyur Chudgar <kchudgar@apm.com>
Signed-off-by: Dean Nelson <dnelson@redhat.com>
Reviewed-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | drivers/net/ethernet/Kconfig | 1 | ||||
| -rw-r--r-- | drivers/net/ethernet/Makefile | 1 | ||||
| -rw-r--r-- | drivers/net/ethernet/apm/Kconfig | 1 | ||||
| -rw-r--r-- | drivers/net/ethernet/apm/Makefile | 5 | ||||
| -rw-r--r-- | drivers/net/ethernet/apm/xgene/Kconfig | 9 | ||||
| -rw-r--r-- | drivers/net/ethernet/apm/xgene/Makefile | 6 | ||||
| -rw-r--r-- | drivers/net/ethernet/apm/xgene/xgene_enet_ethtool.c | 125 | ||||
| -rw-r--r-- | drivers/net/ethernet/apm/xgene/xgene_enet_hw.c | 728 | ||||
| -rw-r--r-- | drivers/net/ethernet/apm/xgene/xgene_enet_hw.h | 337 | ||||
| -rw-r--r-- | drivers/net/ethernet/apm/xgene/xgene_enet_main.c | 951 | ||||
| -rw-r--r-- | drivers/net/ethernet/apm/xgene/xgene_enet_main.h | 135 |
11 files changed, 2299 insertions, 0 deletions
diff --git a/drivers/net/ethernet/Kconfig b/drivers/net/ethernet/Kconfig index edb718661850..dc7406c81c45 100644 --- a/drivers/net/ethernet/Kconfig +++ b/drivers/net/ethernet/Kconfig | |||
| @@ -24,6 +24,7 @@ source "drivers/net/ethernet/allwinner/Kconfig" | |||
| 24 | source "drivers/net/ethernet/alteon/Kconfig" | 24 | source "drivers/net/ethernet/alteon/Kconfig" |
| 25 | source "drivers/net/ethernet/altera/Kconfig" | 25 | source "drivers/net/ethernet/altera/Kconfig" |
| 26 | source "drivers/net/ethernet/amd/Kconfig" | 26 | source "drivers/net/ethernet/amd/Kconfig" |
| 27 | source "drivers/net/ethernet/apm/Kconfig" | ||
| 27 | source "drivers/net/ethernet/apple/Kconfig" | 28 | source "drivers/net/ethernet/apple/Kconfig" |
| 28 | source "drivers/net/ethernet/arc/Kconfig" | 29 | source "drivers/net/ethernet/arc/Kconfig" |
| 29 | source "drivers/net/ethernet/atheros/Kconfig" | 30 | source "drivers/net/ethernet/atheros/Kconfig" |
diff --git a/drivers/net/ethernet/Makefile b/drivers/net/ethernet/Makefile index 58de3339ab3c..224a01877149 100644 --- a/drivers/net/ethernet/Makefile +++ b/drivers/net/ethernet/Makefile | |||
| @@ -10,6 +10,7 @@ obj-$(CONFIG_NET_VENDOR_ALLWINNER) += allwinner/ | |||
| 10 | obj-$(CONFIG_NET_VENDOR_ALTEON) += alteon/ | 10 | obj-$(CONFIG_NET_VENDOR_ALTEON) += alteon/ |
| 11 | obj-$(CONFIG_ALTERA_TSE) += altera/ | 11 | obj-$(CONFIG_ALTERA_TSE) += altera/ |
| 12 | obj-$(CONFIG_NET_VENDOR_AMD) += amd/ | 12 | obj-$(CONFIG_NET_VENDOR_AMD) += amd/ |
| 13 | obj-$(CONFIG_NET_XGENE) += apm/ | ||
| 13 | obj-$(CONFIG_NET_VENDOR_APPLE) += apple/ | 14 | obj-$(CONFIG_NET_VENDOR_APPLE) += apple/ |
| 14 | obj-$(CONFIG_NET_VENDOR_ARC) += arc/ | 15 | obj-$(CONFIG_NET_VENDOR_ARC) += arc/ |
| 15 | obj-$(CONFIG_NET_VENDOR_ATHEROS) += atheros/ | 16 | obj-$(CONFIG_NET_VENDOR_ATHEROS) += atheros/ |
diff --git a/drivers/net/ethernet/apm/Kconfig b/drivers/net/ethernet/apm/Kconfig new file mode 100644 index 000000000000..ec63d706d464 --- /dev/null +++ b/drivers/net/ethernet/apm/Kconfig | |||
| @@ -0,0 +1 @@ | |||
| source "drivers/net/ethernet/apm/xgene/Kconfig" | |||
diff --git a/drivers/net/ethernet/apm/Makefile b/drivers/net/ethernet/apm/Makefile new file mode 100644 index 000000000000..65ce32ad1b2c --- /dev/null +++ b/drivers/net/ethernet/apm/Makefile | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | # | ||
| 2 | # Makefile for APM X-GENE Ethernet driver. | ||
| 3 | # | ||
| 4 | |||
| 5 | obj-$(CONFIG_NET_XGENE) += xgene/ | ||
diff --git a/drivers/net/ethernet/apm/xgene/Kconfig b/drivers/net/ethernet/apm/xgene/Kconfig new file mode 100644 index 000000000000..616dff6d3f5f --- /dev/null +++ b/drivers/net/ethernet/apm/xgene/Kconfig | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | config NET_XGENE | ||
| 2 | tristate "APM X-Gene SoC Ethernet Driver" | ||
| 3 | select PHYLIB | ||
| 4 | help | ||
| 5 | This is the Ethernet driver for the on-chip ethernet interface on the | ||
| 6 | APM X-Gene SoC. | ||
| 7 | |||
| 8 | To compile this driver as a module, choose M here. This module will | ||
| 9 | be called xgene_enet. | ||
diff --git a/drivers/net/ethernet/apm/xgene/Makefile b/drivers/net/ethernet/apm/xgene/Makefile new file mode 100644 index 000000000000..c643e8a0a0dc --- /dev/null +++ b/drivers/net/ethernet/apm/xgene/Makefile | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | # | ||
| 2 | # Makefile for APM X-Gene Ethernet Driver. | ||
| 3 | # | ||
| 4 | |||
| 5 | xgene-enet-objs := xgene_enet_hw.o xgene_enet_main.o xgene_enet_ethtool.o | ||
| 6 | obj-$(CONFIG_NET_XGENE) += xgene-enet.o | ||
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_ethtool.c b/drivers/net/ethernet/apm/xgene/xgene_enet_ethtool.c new file mode 100644 index 000000000000..63f2aa54a594 --- /dev/null +++ b/drivers/net/ethernet/apm/xgene/xgene_enet_ethtool.c | |||
| @@ -0,0 +1,125 @@ | |||
| 1 | /* Applied Micro X-Gene SoC Ethernet Driver | ||
| 2 | * | ||
| 3 | * Copyright (c) 2014, Applied Micro Circuits Corporation | ||
| 4 | * Authors: Iyappan Subramanian <isubramanian@apm.com> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify it | ||
| 7 | * under the terms of the GNU General Public License as published by the | ||
| 8 | * Free Software Foundation; either version 2 of the License, or (at your | ||
| 9 | * option) any later version. | ||
| 10 | * | ||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 18 | */ | ||
| 19 | |||
| 20 | #include <linux/ethtool.h> | ||
| 21 | #include "xgene_enet_main.h" | ||
| 22 | |||
| 23 | struct xgene_gstrings_stats { | ||
| 24 | char name[ETH_GSTRING_LEN]; | ||
| 25 | int offset; | ||
| 26 | }; | ||
| 27 | |||
| 28 | #define XGENE_STAT(m) { #m, offsetof(struct xgene_enet_pdata, stats.m) } | ||
| 29 | |||
| 30 | static const struct xgene_gstrings_stats gstrings_stats[] = { | ||
| 31 | XGENE_STAT(rx_packets), | ||
| 32 | XGENE_STAT(tx_packets), | ||
| 33 | XGENE_STAT(rx_bytes), | ||
| 34 | XGENE_STAT(tx_bytes), | ||
| 35 | XGENE_STAT(rx_errors), | ||
| 36 | XGENE_STAT(tx_errors), | ||
| 37 | XGENE_STAT(rx_length_errors), | ||
| 38 | XGENE_STAT(rx_crc_errors), | ||
| 39 | XGENE_STAT(rx_frame_errors), | ||
| 40 | XGENE_STAT(rx_fifo_errors) | ||
| 41 | }; | ||
| 42 | |||
| 43 | #define XGENE_STATS_LEN ARRAY_SIZE(gstrings_stats) | ||
| 44 | |||
| 45 | static void xgene_get_drvinfo(struct net_device *ndev, | ||
| 46 | struct ethtool_drvinfo *info) | ||
| 47 | { | ||
| 48 | struct xgene_enet_pdata *pdata = netdev_priv(ndev); | ||
| 49 | struct platform_device *pdev = pdata->pdev; | ||
| 50 | |||
| 51 | strcpy(info->driver, "xgene_enet"); | ||
| 52 | strcpy(info->version, XGENE_DRV_VERSION); | ||
| 53 | snprintf(info->fw_version, ETHTOOL_FWVERS_LEN, "N/A"); | ||
| 54 | sprintf(info->bus_info, "%s", pdev->name); | ||
| 55 | } | ||
| 56 | |||
| 57 | static int xgene_get_settings(struct net_device *ndev, struct ethtool_cmd *cmd) | ||
| 58 | { | ||
| 59 | struct xgene_enet_pdata *pdata = netdev_priv(ndev); | ||
| 60 | struct phy_device *phydev = pdata->phy_dev; | ||
| 61 | |||
| 62 | if (phydev == NULL) | ||
| 63 | return -ENODEV; | ||
| 64 | |||
| 65 | return phy_ethtool_gset(phydev, cmd); | ||
| 66 | } | ||
| 67 | |||
| 68 | static int xgene_set_settings(struct net_device *ndev, struct ethtool_cmd *cmd) | ||
| 69 | { | ||
| 70 | struct xgene_enet_pdata *pdata = netdev_priv(ndev); | ||
| 71 | struct phy_device *phydev = pdata->phy_dev; | ||
| 72 | |||
| 73 | if (phydev == NULL) | ||
| 74 | return -ENODEV; | ||
| 75 | |||
| 76 | return phy_ethtool_sset(phydev, cmd); | ||
| 77 | } | ||
| 78 | |||
| 79 | static void xgene_get_strings(struct net_device *ndev, u32 stringset, u8 *data) | ||
| 80 | { | ||
| 81 | int i; | ||
| 82 | u8 *p = data; | ||
| 83 | |||
| 84 | if (stringset != ETH_SS_STATS) | ||
| 85 | return; | ||
| 86 | |||
| 87 | for (i = 0; i < XGENE_STATS_LEN; i++) { | ||
| 88 | memcpy(p, gstrings_stats[i].name, ETH_GSTRING_LEN); | ||
| 89 | p += ETH_GSTRING_LEN; | ||
| 90 | } | ||
| 91 | } | ||
| 92 | |||
| 93 | static int xgene_get_sset_count(struct net_device *ndev, int sset) | ||
| 94 | { | ||
| 95 | if (sset != ETH_SS_STATS) | ||
| 96 | return -EINVAL; | ||
| 97 | |||
| 98 | return XGENE_STATS_LEN; | ||
| 99 | } | ||
| 100 | |||
| 101 | static void xgene_get_ethtool_stats(struct net_device *ndev, | ||
| 102 | struct ethtool_stats *dummy, | ||
| 103 | u64 *data) | ||
| 104 | { | ||
| 105 | void *pdata = netdev_priv(ndev); | ||
| 106 | int i; | ||
| 107 | |||
| 108 | for (i = 0; i < XGENE_STATS_LEN; i++) | ||
| 109 | *data++ = *(u64 *)(pdata + gstrings_stats[i].offset); | ||
| 110 | } | ||
| 111 | |||
| 112 | static const struct ethtool_ops xgene_ethtool_ops = { | ||
| 113 | .get_drvinfo = xgene_get_drvinfo, | ||
| 114 | .get_settings = xgene_get_settings, | ||
