diff options
author | Ben Hutchings <bhutchings@solarflare.com> | 2013-11-18 18:23:40 -0500 |
---|---|---|
committer | Ben Hutchings <bhutchings@solarflare.com> | 2013-11-21 12:17:42 -0500 |
commit | a5b4145ba937b76dd698ad6fe5c5f37e0edbac43 (patch) | |
tree | 336a4ab6d4773e6dd5f38fd1ebd0b7dfa5d7e702 /drivers/net/ethernet/ti | |
parent | 450e55e996e714250baee79e334e879ee659bd11 (diff) |
ti_cpsw: Implement the SIOCGHWTSTAMP ioctl
This is untested.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Diffstat (limited to 'drivers/net/ethernet/ti')
-rw-r--r-- | drivers/net/ethernet/ti/cpsw.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 7536a4c01293..bc0cb154fc53 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c | |||
@@ -1322,7 +1322,7 @@ static void cpsw_hwtstamp_v2(struct cpsw_priv *priv) | |||
1322 | __raw_writel(ETH_P_1588, &priv->regs->ts_ltype); | 1322 | __raw_writel(ETH_P_1588, &priv->regs->ts_ltype); |
1323 | } | 1323 | } |
1324 | 1324 | ||
1325 | static int cpsw_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr) | 1325 | static int cpsw_hwtstamp_set(struct net_device *dev, struct ifreq *ifr) |
1326 | { | 1326 | { |
1327 | struct cpsw_priv *priv = netdev_priv(dev); | 1327 | struct cpsw_priv *priv = netdev_priv(dev); |
1328 | struct cpts *cpts = priv->cpts; | 1328 | struct cpts *cpts = priv->cpts; |
@@ -1383,6 +1383,24 @@ static int cpsw_hwtstamp_ioctl(struct net_device *dev, struct ifreq *ifr) | |||
1383 | return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; | 1383 | return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; |
1384 | } | 1384 | } |
1385 | 1385 | ||
1386 | static int cpsw_hwtstamp_get(struct net_device *dev, struct ifreq *ifr) | ||
1387 | { | ||
1388 | struct cpsw_priv *priv = netdev_priv(dev); | ||
1389 | struct cpts *cpts = priv->cpts; | ||
1390 | struct hwtstamp_config cfg; | ||
1391 | |||
1392 | if (priv->version != CPSW_VERSION_1 && | ||
1393 | priv->version != CPSW_VERSION_2) | ||
1394 | return -EOPNOTSUPP; | ||
1395 | |||
1396 | cfg.flags = 0; | ||
1397 | cfg.tx_type = cpts->tx_enable ? HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF; | ||
1398 | cfg.rx_filter = (cpts->rx_enable ? | ||
1399 | HWTSTAMP_FILTER_PTP_V2_EVENT : HWTSTAMP_FILTER_NONE); | ||
1400 | |||
1401 | return copy_to_user(ifr->ifr_data, &cfg, sizeof(cfg)) ? -EFAULT : 0; | ||
1402 | } | ||
1403 | |||
1386 | #endif /*CONFIG_TI_CPTS*/ | 1404 | #endif /*CONFIG_TI_CPTS*/ |
1387 | 1405 | ||
1388 | static int cpsw_ndo_ioctl(struct net_device *dev, struct ifreq *req, int cmd) | 1406 | static int cpsw_ndo_ioctl(struct net_device *dev, struct ifreq *req, int cmd) |
@@ -1397,7 +1415,9 @@ static int cpsw_ndo_ioctl(struct net_device *dev, struct ifreq *req, int cmd) | |||
1397 | switch (cmd) { | 1415 | switch (cmd) { |
1398 | #ifdef CONFIG_TI_CPTS | 1416 | #ifdef CONFIG_TI_CPTS |
1399 | case SIOCSHWTSTAMP: | 1417 | case SIOCSHWTSTAMP: |
1400 | return cpsw_hwtstamp_ioctl(dev, req); | 1418 | return cpsw_hwtstamp_set(dev, req); |
1419 | case SIOCGHWTSTAMP: | ||
1420 | return cpsw_hwtstamp_get(dev, req); | ||
1401 | #endif | 1421 | #endif |
1402 | case SIOCGMIIPHY: | 1422 | case SIOCGMIIPHY: |
1403 | data->phy_id = priv->slaves[slave_no].phy->addr; | 1423 | data->phy_id = priv->slaves[slave_no].phy->addr; |