diff options
author | Xie Xiaobo <X.Xie@freescale.com> | 2013-04-07 08:29:32 (GMT) |
---|---|---|
committer | Fleming Andrew-AFLEMING <AFLEMING@freescale.com> | 2013-04-09 20:05:39 (GMT) |
commit | ed9118a6c9c75188464ae6b5dbb377ac47e1a751 (patch) | |
tree | 744a7aa21564e6096e3e312a465fb024e2cfe0f3 /drivers/net/ethernet/freescale/gianfar_sysfs.c | |
parent | 3746e4656cca2c81be1cea3cd15db230d50184ad (diff) | |
download | linux-fsl-qoriq-ed9118a6c9c75188464ae6b5dbb377ac47e1a751.tar.xz |
gianfar: Add IEEE 1588 V2 support
This patch integrates the IEEE 1588 specification v2 ioctls with
the gianfar driver. The user space application should be IXXAT
IEEE1588 stack v1.04 or above.
The IEEE 1588 driver can also be disabled/enabled via sysfs.
To enable 1588:
- echo 1 > /sys/*/ethN/ptp_1588
To disable 1588
- echo 0 > /sys/*/ethN/ptp_1588
Signed-off-by: Sandeep Gopalpet <sandeep.kumar@freescale.com>
Signed-off-by: Bhaskar Upadhaya <Bhaskar.Upadhaya@freescale.com>
Signed-off-by: Tang Yuantian <Yuantian.Tang@freescale.com>
Signed-off-by: Xie Xiaobo <X.Xie@freescale.com>
Change-Id: I3a1190eb6bce06417e0365aba06d73d3a9af5634
Reviewed-on: http://git.am.freescale.net:8181/866
Reviewed-by: Tang Yuantian-B29983 <yuantian.tang@freescale.com>
Reviewed-by: Manoil Claudiu-B08782 <claudiu.manoil@freescale.com>
Reviewed-by: Fleming Andrew-AFLEMING <AFLEMING@freescale.com>
Tested-by: Fleming Andrew-AFLEMING <AFLEMING@freescale.com>
Diffstat (limited to 'drivers/net/ethernet/freescale/gianfar_sysfs.c')
-rw-r--r-- | drivers/net/ethernet/freescale/gianfar_sysfs.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/drivers/net/ethernet/freescale/gianfar_sysfs.c b/drivers/net/ethernet/freescale/gianfar_sysfs.c index 0c420e8..15973ca 100644 --- a/drivers/net/ethernet/freescale/gianfar_sysfs.c +++ b/drivers/net/ethernet/freescale/gianfar_sysfs.c @@ -10,7 +10,7 @@ * Maintainer: Kumar Gala (galak@kernel.crashing.org) * Modifier: Sandeep Gopalpet <sandeep.kumar@freescale.com> * - * Copyright 2002-2009 Freescale Semiconductor, Inc. + * Copyright 2002-2009, 2012 Freescale Semiconductor, Inc. * * 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 @@ -391,6 +391,47 @@ static DEVICE_ATTR(recycle_target, 0644, gfar_show_recycle_target, gfar_set_recycle_target); +static ssize_t gfar_show_ptp_1588(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct gfar_private *priv = netdev_priv(to_net_dev(dev)); + + if (priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER) + return sprintf(buf, "1\n"); + else + return sprintf(buf, "0\n"); +} + +static ssize_t gfar_set_ptp_1588(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct net_device *ndev = to_net_dev(dev); + struct gfar_private *priv = netdev_priv(ndev); + unsigned int num; + unsigned long flags; + + if (kstrtouint(buf, 0, &num) < 0) + return -EINVAL; + + local_irq_save(flags); + lock_tx_qs(priv); + lock_rx_qs(priv); + + if (num) + gfar_1588_start(priv); + else + gfar_1588_stop(priv); + + unlock_rx_qs(priv); + unlock_tx_qs(priv); + local_irq_restore(flags); + + return count; +} + +static DEVICE_ATTR(ptp_1588, 0644, gfar_show_ptp_1588, gfar_set_ptp_1588); + void gfar_init_sysfs(struct net_device *dev) { struct gfar_private *priv = netdev_priv(dev); @@ -410,6 +451,7 @@ void gfar_init_sysfs(struct net_device *dev) rc |= device_create_file(&dev->dev, &dev_attr_fifo_starve_off); rc |= device_create_file(&dev->dev, &dev_attr_recycle); rc |= device_create_file(&dev->dev, &dev_attr_recycle_target); + rc |= device_create_file(&dev->dev, &dev_attr_ptp_1588); if (rc) dev_err(&dev->dev, "Error creating gianfar sysfs files.\n"); } |