forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Iyappan Subramanian says: ==================== net: Add APM X-Gene SoC Ethernet driver support Adding APM X-Gene SoC Ethernet driver. v10: Address comments from v9 review * Documentation: aligned descriptions * simplified struct platform_driver initialization * fixed xgene_enet_mdio_config error path * fixed xgene_enet_init_hw error path * removed statistics spin_lock as it is not required * changed raw_desc fields to type __le64 * defined helper macros for set/get raw_descriptor fields v9: Address comments from v8 review * changed to direct read/write, byteswap into raw descriptor * fixed xgene_enet_create_desc_ring() error handling * removed references to IS_ERR_OR_NULL * disabled half duplex on phy_devce supported/advertising * simplified xgene_enet_adjust_link() function * fixed sparse tool compilation warnings v8: Address comments from v7 review * changed angle bracket to double quotes in header file include. v7: Address comments from v6 review * fixed skb memory leak when dma_map_single fails in xmit. v6: Address comments from v5 review * added basic ethtool support * added ndo_get_stats64 call back * deleted priting Rx error messages * renamed set_bits to xgene_set_bits to fix kbuild error (make ARCH=powerpc) v5: Address comments from v4 review * Documentation: Added phy-handle, reg-names and changed mdio part * dtb: Added reg-names supplemental property * changed platform_get_resource to platform_get_resource_byname * added separate tx/rx set_desc/get_desc functions to do raw_write/raw_read * removed set_desc/get_desc table lookup logic * added error handling logic based on per packet descriptor bits * added software managed Rx packet and error counters * added busy wait for register read/writes * changed mdio_bus->id to avoid conflict * fixed mdio_bus leak in case of mdio_config error * changed phy reg hard coded value to MII_BMSR * changed phy addr hard coded value to phy_device->addr * added paranthesis around macro arguments * converted helper macros to inline functions * changed use of goto's only to common work such as cleanup v4: Address comments from v3 review * MAINTAINERS: changed status to supported * Kconfig: made default to no * changed to bool data type wherever applicable * cleaned up single bit set and masking code * removed statistics counters masking * removed unnecessary OOM message printing * fixed dma_map_single and dma_unmap_single size parameter * changed set bits macro body using new set_bits function v3: Address comments from v2 review * cleaned up set_desc and get_desc functions * added dtb mdio node and phy-handle subnode * renamed dtb phy-mode to phy-connection-type * added of_phy_connect call to connec to PHY * added empty line after last local variable declaration * removed type casting when not required * removed inline keyword from source files * removed CONFIG_CPU_BIG_ENDIAN ifdef v2 * Completely redesigned ethernet driver * Added support to work with big endian kernel * Renamed dtb phyid entry to phy_addr * Changed dtb local-mac-address entry to byte string format * Renamed dtb eth8clk entry to menetclk v1 * Initial version ==================== Signed-off-by: Iyappan Subramanian <[email protected]> Signed-off-by: Ravi Patel <[email protected]> Signed-off-by: Keyur Chudgar <[email protected]> Signed-off-by: David S. Miller <[email protected]>
- Loading branch information
Showing
15 changed files
with
2,404 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
APM X-Gene SoC Ethernet nodes | ||
|
||
Ethernet nodes are defined to describe on-chip ethernet interfaces in | ||
APM X-Gene SoC. | ||
|
||
Required properties: | ||
- compatible: Should be "apm,xgene-enet" | ||
- reg: Address and length of the register set for the device. It contains the | ||
information of registers in the same order as described by reg-names | ||
- reg-names: Should contain the register set names | ||
- "enet_csr": Ethernet control and status register address space | ||
- "ring_csr": Descriptor ring control and status register address space | ||
- "ring_cmd": Descriptor ring command register address space | ||
- interrupts: Ethernet main interrupt | ||
- clocks: Reference to the clock entry. | ||
- local-mac-address: MAC address assigned to this device | ||
- phy-connection-type: Interface type between ethernet device and PHY device | ||
- phy-handle: Reference to a PHY node connected to this device | ||
|
||
- mdio: Device tree subnode with the following required properties: | ||
- compatible: Must be "apm,xgene-mdio". | ||
- #address-cells: Must be <1>. | ||
- #size-cells: Must be <0>. | ||
|
||
For the phy on the mdio bus, there must be a node with the following fields: | ||
- compatible: PHY identifier. Please refer ./phy.txt for the format. | ||
- reg: The ID number for the phy. | ||
|
||
Optional properties: | ||
- status: Should be "ok" or "disabled" for enabled/disabled. Default is "ok". | ||
|
||
Example: | ||
menetclk: menetclk { | ||
compatible = "apm,xgene-device-clock"; | ||
clock-output-names = "menetclk"; | ||
status = "ok"; | ||
}; | ||
|
||
menet: ethernet@17020000 { | ||
compatible = "apm,xgene-enet"; | ||
status = "disabled"; | ||
reg = <0x0 0x17020000 0x0 0xd100>, | ||
<0x0 0X17030000 0x0 0X400>, | ||
<0x0 0X10000000 0x0 0X200>; | ||
reg-names = "enet_csr", "ring_csr", "ring_cmd"; | ||
interrupts = <0x0 0x3c 0x4>; | ||
clocks = <&menetclk 0>; | ||
local-mac-address = [00 01 73 00 00 01]; | ||
phy-connection-type = "rgmii"; | ||
phy-handle = <&menetphy>; | ||
mdio { | ||
compatible = "apm,xgene-mdio"; | ||
#address-cells = <1>; | ||
#size-cells = <0>; | ||
menetphy: menetphy@3 { | ||
compatible = "ethernet-phy-id001c.c915"; | ||
reg = <0x3>; | ||
}; | ||
|
||
}; | ||
}; | ||
|
||
/* Board-specific peripheral configurations */ | ||
&menet { | ||
status = "ok"; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -719,6 +719,14 @@ S: Maintained | |
F: drivers/net/appletalk/ | ||
F: net/appletalk/ | ||
|
||
APPLIED MICRO (APM) X-GENE SOC ETHERNET DRIVER | ||
M: Iyappan Subramanian <[email protected]> | ||
M: Keyur Chudgar <[email protected]> | ||
M: Ravi Patel <[email protected]> | ||
S: Supported | ||
F: drivers/net/ethernet/apm/xgene/ | ||
F: Documentation/devicetree/bindings/net/apm-xgene-enet.txt | ||
|
||
APTINA CAMERA SENSOR PLL | ||
M: Laurent Pinchart <[email protected]> | ||
L: [email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,7 @@ | |
&serial0 { | ||
status = "ok"; | ||
}; | ||
|
||
&menet { | ||
status = "ok"; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
source "drivers/net/ethernet/apm/xgene/Kconfig" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# | ||
# Makefile for APM X-GENE Ethernet driver. | ||
# | ||
|
||
obj-$(CONFIG_NET_XGENE) += xgene/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
config NET_XGENE | ||
tristate "APM X-Gene SoC Ethernet Driver" | ||
select PHYLIB | ||
help | ||
This is the Ethernet driver for the on-chip ethernet interface on the | ||
APM X-Gene SoC. | ||
|
||
To compile this driver as a module, choose M here. This module will | ||
be called xgene_enet. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# | ||
# Makefile for APM X-Gene Ethernet Driver. | ||
# | ||
|
||
xgene-enet-objs := xgene_enet_hw.o xgene_enet_main.o xgene_enet_ethtool.o | ||
obj-$(CONFIG_NET_XGENE) += xgene-enet.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
/* Applied Micro X-Gene SoC Ethernet Driver | ||
* | ||
* Copyright (c) 2014, Applied Micro Circuits Corporation | ||
* Authors: Iyappan Subramanian <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation; either version 2 of the License, or (at your | ||
* option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* 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/ethtool.h> | ||
#include "xgene_enet_main.h" | ||
|
||
struct xgene_gstrings_stats { | ||
char name[ETH_GSTRING_LEN]; | ||
int offset; | ||
}; | ||
|
||
#define XGENE_STAT(m) { #m, offsetof(struct xgene_enet_pdata, stats.m) } | ||
|
||
static const struct xgene_gstrings_stats gstrings_stats[] = { | ||
XGENE_STAT(rx_packets), | ||
XGENE_STAT(tx_packets), | ||
XGENE_STAT(rx_bytes), | ||
XGENE_STAT(tx_bytes), | ||
XGENE_STAT(rx_errors), | ||
XGENE_STAT(tx_errors), | ||
XGENE_STAT(rx_length_errors), | ||
XGENE_STAT(rx_crc_errors), | ||
XGENE_STAT(rx_frame_errors), | ||
XGENE_STAT(rx_fifo_errors) | ||
}; | ||
|
||
#define XGENE_STATS_LEN ARRAY_SIZE(gstrings_stats) | ||
|
||
static void xgene_get_drvinfo(struct net_device *ndev, | ||
struct ethtool_drvinfo *info) | ||
{ | ||
struct xgene_enet_pdata *pdata = netdev_priv(ndev); | ||
struct platform_device *pdev = pdata->pdev; | ||
|
||
strcpy(info->driver, "xgene_enet"); | ||
strcpy(info->version, XGENE_DRV_VERSION); | ||
snprintf(info->fw_version, ETHTOOL_FWVERS_LEN, "N/A"); | ||
sprintf(info->bus_info, "%s", pdev->name); | ||
} | ||
|
||
static int xgene_get_settings(struct net_device *ndev, struct ethtool_cmd *cmd) | ||
{ | ||
struct xgene_enet_pdata *pdata = netdev_priv(ndev); | ||
struct phy_device *phydev = pdata->phy_dev; | ||
|
||
if (phydev == NULL) | ||
return -ENODEV; | ||
|
||
return phy_ethtool_gset(phydev, cmd); | ||
} | ||
|
||
static int xgene_set_settings(struct net_device *ndev, struct ethtool_cmd *cmd) | ||
{ | ||
struct xgene_enet_pdata *pdata = netdev_priv(ndev); | ||
struct phy_device *phydev = pdata->phy_dev; | ||
|
||
if (phydev == NULL) | ||
return -ENODEV; | ||
|
||
return phy_ethtool_sset(phydev, cmd); | ||
} | ||
|
||
static void xgene_get_strings(struct net_device *ndev, u32 stringset, u8 *data) | ||
{ | ||
int i; | ||
u8 *p = data; | ||
|
||
if (stringset != ETH_SS_STATS) | ||
return; | ||
|
||
for (i = 0; i < XGENE_STATS_LEN; i++) { | ||
memcpy(p, gstrings_stats[i].name, ETH_GSTRING_LEN); | ||
p += ETH_GSTRING_LEN; | ||
} | ||
} | ||
|
||
static int xgene_get_sset_count(struct net_device *ndev, int sset) | ||
{ | ||
if (sset != ETH_SS_STATS) | ||
return -EINVAL; | ||
|
||
return XGENE_STATS_LEN; | ||
} | ||
|
||
static void xgene_get_ethtool_stats(struct net_device *ndev, | ||
struct ethtool_stats *dummy, | ||
u64 *data) | ||
{ | ||
void *pdata = netdev_priv(ndev); | ||
int i; | ||
|
||
for (i = 0; i < XGENE_STATS_LEN; i++) | ||
*data++ = *(u64 *)(pdata + gstrings_stats[i].offset); | ||
} | ||
|
||
static const struct ethtool_ops xgene_ethtool_ops = { | ||
.get_drvinfo = xgene_get_drvinfo, | ||
.get_settings = xgene_get_settings, | ||
.set_settings = xgene_set_settings, | ||
.get_link = ethtool_op_get_link, | ||
.get_strings = xgene_get_strings, | ||
.get_sset_count = xgene_get_sset_count, | ||
.get_ethtool_stats = xgene_get_ethtool_stats | ||
}; | ||
|
||
void xgene_enet_set_ethtool_ops(struct net_device *ndev) | ||
{ | ||
ndev->ethtool_ops = &xgene_ethtool_ops; | ||
} |
Oops, something went wrong.