hellcreek_hwtstamp.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. #ifndef _HELLCREEK_HWTSTAMP_H_
  12. #define _HELLCREEK_HWTSTAMP_H_
  13. #include <net/dsa.h>
  14. #include "hellcreek.h"
  15. /* Timestamp Register */
  16. #define PR_TS_RX_P1_STATUS_C (0x1d * 2)
  17. #define PR_TS_RX_P1_DATA_C (0x1e * 2)
  18. #define PR_TS_TX_P1_STATUS_C (0x1f * 2)
  19. #define PR_TS_TX_P1_DATA_C (0x20 * 2)
  20. #define PR_TS_RX_P2_STATUS_C (0x25 * 2)
  21. #define PR_TS_RX_P2_DATA_C (0x26 * 2)
  22. #define PR_TS_TX_P2_STATUS_C (0x27 * 2)
  23. #define PR_TS_TX_P2_DATA_C (0x28 * 2)
  24. #define PR_TS_STATUS_TS_AVAIL BIT(2)
  25. #define PR_TS_STATUS_TS_LOST BIT(3)
  26. #define SKB_PTP_TYPE(__skb) (*(unsigned int *)((__skb)->cb))
  27. /* TX_TSTAMP_TIMEOUT: This limits the time spent polling for a TX
  28. * timestamp. When working properly, hardware will produce a timestamp
  29. * within 1ms. Software may enounter delays, so the timeout is set
  30. * accordingly.
  31. */
  32. #define TX_TSTAMP_TIMEOUT msecs_to_jiffies(40)
  33. int hellcreek_port_hwtstamp_set(struct dsa_switch *ds, int port,
  34. struct ifreq *ifr);
  35. int hellcreek_port_hwtstamp_get(struct dsa_switch *ds, int port,
  36. struct ifreq *ifr);
  37. bool hellcreek_port_rxtstamp(struct dsa_switch *ds, int port,
  38. struct sk_buff *clone, unsigned int type);
  39. void hellcreek_port_txtstamp(struct dsa_switch *ds, int port,
  40. struct sk_buff *skb);
  41. int hellcreek_get_ts_info(struct dsa_switch *ds, int port,
  42. struct ethtool_ts_info *info);
  43. long hellcreek_hwtstamp_work(struct ptp_clock_info *ptp);
  44. int hellcreek_hwtstamp_setup(struct hellcreek *chip);
  45. void hellcreek_hwtstamp_free(struct hellcreek *chip);
  46. #endif /* _HELLCREEK_HWTSTAMP_H_ */