lan743x_ptp.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /* Copyright (C) 2018 Microchip Technology Inc. */
  3. #ifndef _LAN743X_PTP_H
  4. #define _LAN743X_PTP_H
  5. #include "linux/ptp_clock_kernel.h"
  6. #include "linux/netdevice.h"
  7. struct lan743x_adapter;
  8. /* GPIO */
  9. struct lan743x_gpio {
  10. /* gpio_lock: used to prevent concurrent access to gpio settings */
  11. spinlock_t gpio_lock;
  12. int used_bits;
  13. int output_bits;
  14. int ptp_bits;
  15. u32 gpio_cfg0;
  16. u32 gpio_cfg1;
  17. u32 gpio_cfg2;
  18. u32 gpio_cfg3;
  19. };
  20. int lan743x_gpio_init(struct lan743x_adapter *adapter);
  21. void lan743x_ptp_isr(void *context);
  22. bool lan743x_ptp_request_tx_timestamp(struct lan743x_adapter *adapter);
  23. void lan743x_ptp_unrequest_tx_timestamp(struct lan743x_adapter *adapter);
  24. void lan743x_ptp_tx_timestamp_skb(struct lan743x_adapter *adapter,
  25. struct sk_buff *skb, bool ignore_sync);
  26. int lan743x_ptp_init(struct lan743x_adapter *adapter);
  27. int lan743x_ptp_open(struct lan743x_adapter *adapter);
  28. void lan743x_ptp_close(struct lan743x_adapter *adapter);
  29. void lan743x_ptp_update_latency(struct lan743x_adapter *adapter,
  30. u32 link_speed);
  31. int lan743x_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
  32. #define LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS (4)
  33. #define PTP_FLAG_PTP_CLOCK_REGISTERED BIT(1)
  34. #define PTP_FLAG_ISR_ENABLED BIT(2)
  35. struct lan743x_ptp {
  36. int flags;
  37. /* command_lock: used to prevent concurrent ptp commands */
  38. struct mutex command_lock;
  39. struct ptp_clock *ptp_clock;
  40. struct ptp_clock_info ptp_clock_info;
  41. struct ptp_pin_desc pin_config[1];
  42. #define LAN743X_PTP_NUMBER_OF_EVENT_CHANNELS (2)
  43. unsigned long used_event_ch;
  44. int perout_event_ch;
  45. int perout_gpio_bit;
  46. /* tx_ts_lock: used to prevent concurrent access to timestamp arrays */
  47. spinlock_t tx_ts_lock;
  48. int pending_tx_timestamps;
  49. struct sk_buff *tx_ts_skb_queue[LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS];
  50. unsigned int tx_ts_ignore_sync_queue;
  51. int tx_ts_skb_queue_size;
  52. u32 tx_ts_seconds_queue[LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS];
  53. u32 tx_ts_nseconds_queue[LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS];
  54. u32 tx_ts_header_queue[LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS];
  55. int tx_ts_queue_size;
  56. };
  57. #endif /* _LAN743X_PTP_H */