Debian Codegraph @

drivers/net/dsa/hirschmann/hellcreek_hwtstamp.h

raw
1 /* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
2 /*
3 * DSA driver for:
4 * Hirschmann Hellcreek TSN switch.
5 *
6 * Copyright (C) 2019,2020 Hochschule Offenburg
7 * Copyright (C) 2019,2020 Linutronix GmbH
8 * Authors: Kurt Kanzenbach <[email protected]>
9 * Kamil Alkhouri <[email protected]>
10 */
11
12 #ifndef _HELLCREEK_HWTSTAMP_H_
13 #define _HELLCREEK_HWTSTAMP_H_
14
15 #include <net/dsa.h>
16 #include "hellcreek.h"
17
18 /* Timestamp Register */
19 #define PR_TS_RX_P1_STATUS_C (0x1d * 2)
20 #define PR_TS_RX_P1_DATA_C (0x1e * 2)
21 #define PR_TS_TX_P1_STATUS_C (0x1f * 2)
22 #define PR_TS_TX_P1_DATA_C (0x20 * 2)
23 #define PR_TS_RX_P2_STATUS_C (0x25 * 2)
24 #define PR_TS_RX_P2_DATA_C (0x26 * 2)
25 #define PR_TS_TX_P2_STATUS_C (0x27 * 2)
26 #define PR_TS_TX_P2_DATA_C (0x28 * 2)
27
28 #define PR_TS_STATUS_TS_AVAIL BIT(2)
29 #define PR_TS_STATUS_TS_LOST BIT(3)
30
31 #define SKB_PTP_TYPE(__skb) (*(unsigned int *)((__skb)->cb))
32
33 /* TX_TSTAMP_TIMEOUT: This limits the time spent polling for a TX
34 * timestamp. When working properly, hardware will produce a timestamp
35 * within 1ms. Software may enounter delays, so the timeout is set
36 * accordingly.
37 */
38 #define TX_TSTAMP_TIMEOUT msecs_to_jiffies(40)
39
40 int hellcreek_port_hwtstamp_set(struct dsa_switch *ds, int port,
41 struct kernel_hwtstamp_config *config,
42 struct netlink_ext_ack *extack);
43 int hellcreek_port_hwtstamp_get(struct dsa_switch *ds, int port,
44 struct kernel_hwtstamp_config *config);
45
46 bool hellcreek_port_rxtstamp(struct dsa_switch *ds, int port,
47 struct sk_buff *clone, unsigned int type);
48 void hellcreek_port_txtstamp(struct dsa_switch *ds, int port,
49 struct sk_buff *skb);
50
51 int hellcreek_get_ts_info(struct dsa_switch *ds, int port,
52 struct kernel_ethtool_ts_info *info);
53
54 long hellcreek_hwtstamp_work(struct ptp_clock_info *ptp);
55
56 int hellcreek_hwtstamp_setup(struct hellcreek *chip);
57 void hellcreek_hwtstamp_free(struct hellcreek *chip);
58
59 #endif /* _HELLCREEK_HWTSTAMP_H_ */