diff options
author | Shengzhou Liu <Shengzhou.Liu@freescale.com> | 2013-04-09 09:05:31 (GMT) |
---|---|---|
committer | Fleming Andrew-AFLEMING <AFLEMING@freescale.com> | 2013-04-16 15:39:24 (GMT) |
commit | cf620d252d9e85e6012dcd35ce7a38f73d903661 (patch) | |
tree | d5cec3947372a6b44ab1b6b976b0085f16dd5f3e | |
parent | ba3826a63a89a9efd73c984cc633bca4bdc2434c (diff) | |
download | linux-fsl-qoriq-cf620d252d9e85e6012dcd35ce7a38f73d903661.tar.xz |
powerpc/dpaa_1588: add sysfs support for ptp 1588
The dpaa 1588 can be disabled/enabled via sysfs in runtime.
By default, the dpaa 1588 is disabled, that means no 1588
action activated during the processing of ethernet frames.
To enable 1588:
echo 1 > /sys/devices/<DIR>/fmx-gby/ptp_1588
To disable 1588:
echo 0 > /sys/devices/<DIR>/fmx-gby/ptp_1588
Signed-off-by: Shengzhou Liu <Shengzhou.Liu@freescale.com>
Change-Id: I9f21f47c1f5eeb7b5f05e43e2ec6fe41fa3e697f
Reviewed-on: http://git.am.freescale.net:8181/1150
Reviewed-by: Hamciuc Bogdan-BHAMCIU1 <bogdan.hamciuc@freescale.com>
Reviewed-by: Fleming Andrew-AFLEMING <AFLEMING@freescale.com>
Tested-by: Fleming Andrew-AFLEMING <AFLEMING@freescale.com>
-rw-r--r-- | drivers/net/ethernet/freescale/dpa/dpaa_1588.c | 2 | ||||
-rw-r--r-- | drivers/net/ethernet/freescale/dpa/dpaa_eth.c | 2 | ||||
-rw-r--r-- | drivers/net/ethernet/freescale/dpa/dpaa_eth_sysfs.c | 49 |
3 files changed, 50 insertions, 3 deletions
diff --git a/drivers/net/ethernet/freescale/dpa/dpaa_1588.c b/drivers/net/ethernet/freescale/dpa/dpaa_1588.c index 89c7f15..51b8b85 100644 --- a/drivers/net/ethernet/freescale/dpa/dpaa_1588.c +++ b/drivers/net/ethernet/freescale/dpa/dpaa_1588.c @@ -589,7 +589,7 @@ int dpa_ptp_init(struct dpa_priv_s *priv) if (!tsu) return -ENOMEM; - tsu->valid = TRUE; + tsu->valid = FALSE; tsu->dpa_priv = priv; dpa_ptp_init_circ(&tsu->rx_timestamps, DEFAULT_PTP_RX_BUF_SZ); diff --git a/drivers/net/ethernet/freescale/dpa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpa/dpaa_eth.c index a4bd982..8662b57 100644 --- a/drivers/net/ethernet/freescale/dpa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpa/dpaa_eth.c @@ -3035,7 +3035,7 @@ dpa_mac_probe(struct platform_device *_of_dev) if (timer_node && (net_dev = dev_get_drvdata(dpa_dev))) { priv = netdev_priv(net_dev); if (!dpa_ptp_init(priv)) - dev_info(dev, "%s: ptp-timer enabled\n", + dev_info(dev, "%s: ptp 1588 is initialized.\n", mac_node->full_name); } } diff --git a/drivers/net/ethernet/freescale/dpa/dpaa_eth_sysfs.c b/drivers/net/ethernet/freescale/dpa/dpaa_eth_sysfs.c index 1aed378..24d64db 100644 --- a/drivers/net/ethernet/freescale/dpa/dpaa_eth_sysfs.c +++ b/drivers/net/ethernet/freescale/dpa/dpaa_eth_sysfs.c @@ -37,6 +37,9 @@ #include <linux/io.h> #include <linux/of_net.h> #include "dpaa_eth.h" +#ifdef CONFIG_FSL_DPA_1588 +#include "dpaa_1588.h" +#endif static ssize_t dpaa_eth_show_addr(struct device *dev, struct device_attribute *attr, char *buf) @@ -156,11 +159,55 @@ static ssize_t dpaa_eth_show_mac_regs(struct device *dev, return 0; } + +#ifdef CONFIG_FSL_DPA_1588 +static ssize_t dpaa_eth_show_ptp_1588(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct dpa_priv_s *priv = netdev_priv(to_net_dev(dev)); + + if (priv->tsu && priv->tsu->valid) + return sprintf(buf, "1\n"); + else + return sprintf(buf, "0\n"); +} + +static ssize_t dpaa_eth_set_ptp_1588(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct dpa_priv_s *priv = netdev_priv(to_net_dev(dev)); + unsigned int num; + unsigned long flags; + + if (kstrtouint(buf, 0, &num) < 0) + return -EINVAL; + + local_irq_save(flags); + + if (num) { + if (priv->tsu) + priv->tsu->valid = TRUE; + } else { + if (priv->tsu) + priv->tsu->valid = FALSE; + } + + local_irq_restore(flags); + + return count; +} +#endif + static struct device_attribute dpaa_eth_attrs[] = { __ATTR(device_addr, S_IRUGO, dpaa_eth_show_addr, NULL), __ATTR(fqids, S_IRUGO, dpaa_eth_show_fqids, NULL), __ATTR(dflt_bpid, S_IRUGO, dpaa_eth_show_dflt_bpid, NULL), - __ATTR(mac_regs, S_IRUGO, dpaa_eth_show_mac_regs, NULL) + __ATTR(mac_regs, S_IRUGO, dpaa_eth_show_mac_regs, NULL), +#ifdef CONFIG_FSL_DPA_1588 + __ATTR(ptp_1588, S_IRUGO | S_IWUSR, dpaa_eth_show_ptp_1588, + dpaa_eth_set_ptp_1588), +#endif }; void dpaa_eth_sysfs_init(struct device *dev) |