Commit 0fab782a authored by Yangbo Lu's avatar Yangbo Lu Committed by David S. Miller

fsl/fman: add set_tstamp interface

This patch is to add set_tstamp interface for memac,
dtsec, and 10GEC controllers to configure HW timestamping.
Signed-off-by: default avatarYangbo Lu <yangbo.lu@nxp.com>
Acked-by: default avatarRichard Cochran <richardcochran@gmail.com>
Acked-by: default avatarMadalin Bucur <madalin.bucur@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9cd19b52
...@@ -123,11 +123,13 @@ ...@@ -123,11 +123,13 @@
#define DTSEC_ECNTRL_R100M 0x00000008 #define DTSEC_ECNTRL_R100M 0x00000008
#define DTSEC_ECNTRL_QSGMIIM 0x00000001 #define DTSEC_ECNTRL_QSGMIIM 0x00000001
#define TCTRL_TTSE 0x00000040
#define TCTRL_GTS 0x00000020 #define TCTRL_GTS 0x00000020
#define RCTRL_PAL_MASK 0x001f0000 #define RCTRL_PAL_MASK 0x001f0000
#define RCTRL_PAL_SHIFT 16 #define RCTRL_PAL_SHIFT 16
#define RCTRL_GHTX 0x00000400 #define RCTRL_GHTX 0x00000400
#define RCTRL_RTSE 0x00000040
#define RCTRL_GRS 0x00000020 #define RCTRL_GRS 0x00000020
#define RCTRL_MPROM 0x00000008 #define RCTRL_MPROM 0x00000008
#define RCTRL_RSF 0x00000004 #define RCTRL_RSF 0x00000004
...@@ -1136,6 +1138,31 @@ int dtsec_set_allmulti(struct fman_mac *dtsec, bool enable) ...@@ -1136,6 +1138,31 @@ int dtsec_set_allmulti(struct fman_mac *dtsec, bool enable)
return 0; return 0;
} }
int dtsec_set_tstamp(struct fman_mac *dtsec, bool enable)
{
struct dtsec_regs __iomem *regs = dtsec->regs;
u32 rctrl, tctrl;
if (!is_init_done(dtsec->dtsec_drv_param))
return -EINVAL;
rctrl = ioread32be(&regs->rctrl);
tctrl = ioread32be(&regs->tctrl);
if (enable) {
rctrl |= RCTRL_RTSE;
tctrl |= TCTRL_TTSE;
} else {
rctrl &= ~RCTRL_RTSE;
tctrl &= ~TCTRL_TTSE;
}
iowrite32be(rctrl, &regs->rctrl);
iowrite32be(tctrl, &regs->tctrl);
return 0;
}
int dtsec_del_hash_mac_address(struct fman_mac *dtsec, enet_addr_t *eth_addr) int dtsec_del_hash_mac_address(struct fman_mac *dtsec, enet_addr_t *eth_addr)
{ {
struct dtsec_regs __iomem *regs = dtsec->regs; struct dtsec_regs __iomem *regs = dtsec->regs;
......
...@@ -56,5 +56,6 @@ int dtsec_add_hash_mac_address(struct fman_mac *dtsec, enet_addr_t *eth_addr); ...@@ -56,5 +56,6 @@ int dtsec_add_hash_mac_address(struct fman_mac *dtsec, enet_addr_t *eth_addr);
int dtsec_del_hash_mac_address(struct fman_mac *dtsec, enet_addr_t *eth_addr); int dtsec_del_hash_mac_address(struct fman_mac *dtsec, enet_addr_t *eth_addr);
int dtsec_get_version(struct fman_mac *dtsec, u32 *mac_version); int dtsec_get_version(struct fman_mac *dtsec, u32 *mac_version);
int dtsec_set_allmulti(struct fman_mac *dtsec, bool enable); int dtsec_set_allmulti(struct fman_mac *dtsec, bool enable);
int dtsec_set_tstamp(struct fman_mac *dtsec, bool enable);
#endif /* __DTSEC_H */ #endif /* __DTSEC_H */
...@@ -964,6 +964,11 @@ int memac_set_allmulti(struct fman_mac *memac, bool enable) ...@@ -964,6 +964,11 @@ int memac_set_allmulti(struct fman_mac *memac, bool enable)
return 0; return 0;
} }
int memac_set_tstamp(struct fman_mac *memac, bool enable)
{
return 0; /* Always enabled. */
}
int memac_del_hash_mac_address(struct fman_mac *memac, enet_addr_t *eth_addr) int memac_del_hash_mac_address(struct fman_mac *memac, enet_addr_t *eth_addr)
{ {
struct memac_regs __iomem *regs = memac->regs; struct memac_regs __iomem *regs = memac->regs;
......
...@@ -58,5 +58,6 @@ int memac_set_exception(struct fman_mac *memac, ...@@ -58,5 +58,6 @@ int memac_set_exception(struct fman_mac *memac,
int memac_add_hash_mac_address(struct fman_mac *memac, enet_addr_t *eth_addr); int memac_add_hash_mac_address(struct fman_mac *memac, enet_addr_t *eth_addr);
int memac_del_hash_mac_address(struct fman_mac *memac, enet_addr_t *eth_addr); int memac_del_hash_mac_address(struct fman_mac *memac, enet_addr_t *eth_addr);
int memac_set_allmulti(struct fman_mac *memac, bool enable); int memac_set_allmulti(struct fman_mac *memac, bool enable);
int memac_set_tstamp(struct fman_mac *memac, bool enable);
#endif /* __MEMAC_H */ #endif /* __MEMAC_H */
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#define TGEC_TX_IPG_LENGTH_MASK 0x000003ff #define TGEC_TX_IPG_LENGTH_MASK 0x000003ff
/* Command and Configuration Register (COMMAND_CONFIG) */ /* Command and Configuration Register (COMMAND_CONFIG) */
#define CMD_CFG_EN_TIMESTAMP 0x00100000
#define CMD_CFG_NO_LEN_CHK 0x00020000 #define CMD_CFG_NO_LEN_CHK 0x00020000
#define CMD_CFG_PAUSE_IGNORE 0x00000100 #define CMD_CFG_PAUSE_IGNORE 0x00000100
#define CMF_CFG_CRC_FWD 0x00000040 #define CMF_CFG_CRC_FWD 0x00000040
...@@ -588,6 +589,26 @@ int tgec_set_allmulti(struct fman_mac *tgec, bool enable) ...@@ -588,6 +589,26 @@ int tgec_set_allmulti(struct fman_mac *tgec, bool enable)
return 0; return 0;
} }
int tgec_set_tstamp(struct fman_mac *tgec, bool enable)
{
struct tgec_regs __iomem *regs = tgec->regs;
u32 tmp;
if (!is_init_done(tgec->cfg))
return -EINVAL;
tmp = ioread32be(&regs->command_config);
if (enable)
tmp |= CMD_CFG_EN_TIMESTAMP;
else
tmp &= ~CMD_CFG_EN_TIMESTAMP;
iowrite32be(tmp, &regs->command_config);
return 0;
}
int tgec_del_hash_mac_address(struct fman_mac *tgec, enet_addr_t *eth_addr) int tgec_del_hash_mac_address(struct fman_mac *tgec, enet_addr_t *eth_addr)
{ {
struct tgec_regs __iomem *regs = tgec->regs; struct tgec_regs __iomem *regs = tgec->regs;
......
...@@ -52,5 +52,6 @@ int tgec_add_hash_mac_address(struct fman_mac *tgec, enet_addr_t *eth_addr); ...@@ -52,5 +52,6 @@ int tgec_add_hash_mac_address(struct fman_mac *tgec, enet_addr_t *eth_addr);
int tgec_del_hash_mac_address(struct fman_mac *tgec, enet_addr_t *eth_addr); int tgec_del_hash_mac_address(struct fman_mac *tgec, enet_addr_t *eth_addr);
int tgec_get_version(struct fman_mac *tgec, u32 *mac_version); int tgec_get_version(struct fman_mac *tgec, u32 *mac_version);
int tgec_set_allmulti(struct fman_mac *tgec, bool enable); int tgec_set_allmulti(struct fman_mac *tgec, bool enable);
int tgec_set_tstamp(struct fman_mac *tgec, bool enable);
#endif /* __TGEC_H */ #endif /* __TGEC_H */
...@@ -471,6 +471,7 @@ static void setup_dtsec(struct mac_device *mac_dev) ...@@ -471,6 +471,7 @@ static void setup_dtsec(struct mac_device *mac_dev)
mac_dev->set_rx_pause = dtsec_accept_rx_pause_frames; mac_dev->set_rx_pause = dtsec_accept_rx_pause_frames;
mac_dev->set_exception = dtsec_set_exception; mac_dev->set_exception = dtsec_set_exception;
mac_dev->set_allmulti = dtsec_set_allmulti; mac_dev->set_allmulti = dtsec_set_allmulti;
mac_dev->set_tstamp = dtsec_set_tstamp;
mac_dev->set_multi = set_multi; mac_dev->set_multi = set_multi;
mac_dev->start = start; mac_dev->start = start;
mac_dev->stop = stop; mac_dev->stop = stop;
...@@ -490,6 +491,7 @@ static void setup_tgec(struct mac_device *mac_dev) ...@@ -490,6 +491,7 @@ static void setup_tgec(struct mac_device *mac_dev)
mac_dev->set_rx_pause = tgec_accept_rx_pause_frames; mac_dev->set_rx_pause = tgec_accept_rx_pause_frames;
mac_dev->set_exception = tgec_set_exception; mac_dev->set_exception = tgec_set_exception;
mac_dev->set_allmulti = tgec_set_allmulti; mac_dev->set_allmulti = tgec_set_allmulti;
mac_dev->set_tstamp = tgec_set_tstamp;
mac_dev->set_multi = set_multi; mac_dev->set_multi = set_multi;
mac_dev->start = start; mac_dev->start = start;
mac_dev->stop = stop; mac_dev->stop = stop;
...@@ -509,6 +511,7 @@ static void setup_memac(struct mac_device *mac_dev) ...@@ -509,6 +511,7 @@ static void setup_memac(struct mac_device *mac_dev)
mac_dev->set_rx_pause = memac_accept_rx_pause_frames; mac_dev->set_rx_pause = memac_accept_rx_pause_frames;
mac_dev->set_exception = memac_set_exception; mac_dev->set_exception = memac_set_exception;
mac_dev->set_allmulti = memac_set_allmulti; mac_dev->set_allmulti = memac_set_allmulti;
mac_dev->set_tstamp = memac_set_tstamp;
mac_dev->set_multi = set_multi; mac_dev->set_multi = set_multi;
mac_dev->start = start; mac_dev->start = start;
mac_dev->stop = stop; mac_dev->stop = stop;
......
...@@ -68,6 +68,7 @@ struct mac_device { ...@@ -68,6 +68,7 @@ struct mac_device {
int (*set_promisc)(struct fman_mac *mac_dev, bool enable); int (*set_promisc)(struct fman_mac *mac_dev, bool enable);
int (*change_addr)(struct fman_mac *mac_dev, enet_addr_t *enet_addr); int (*change_addr)(struct fman_mac *mac_dev, enet_addr_t *enet_addr);
int (*set_allmulti)(struct fman_mac *mac_dev, bool enable); int (*set_allmulti)(struct fman_mac *mac_dev, bool enable);
int (*set_tstamp)(struct fman_mac *mac_dev, bool enable);
int (*set_multi)(struct net_device *net_dev, int (*set_multi)(struct net_device *net_dev,
struct mac_device *mac_dev); struct mac_device *mac_dev);
int (*set_rx_pause)(struct fman_mac *mac_dev, bool en); int (*set_rx_pause)(struct fman_mac *mac_dev, bool en);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment