1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /* Copyright (C) 2018 Microchip Technology Inc. */
7 #include "linux/ptp_clock_kernel.h"
8 #include "linux/netdevice.h"
10 struct lan743x_adapter
;
14 /* gpio_lock: used to prevent concurrent access to gpio settings */
26 int lan743x_gpio_init(struct lan743x_adapter
*adapter
);
28 void lan743x_ptp_isr(void *context
);
29 bool lan743x_ptp_request_tx_timestamp(struct lan743x_adapter
*adapter
);
30 void lan743x_ptp_unrequest_tx_timestamp(struct lan743x_adapter
*adapter
);
31 void lan743x_ptp_tx_timestamp_skb(struct lan743x_adapter
*adapter
,
32 struct sk_buff
*skb
, bool ignore_sync
);
33 int lan743x_ptp_init(struct lan743x_adapter
*adapter
);
34 int lan743x_ptp_open(struct lan743x_adapter
*adapter
);
35 void lan743x_ptp_close(struct lan743x_adapter
*adapter
);
36 void lan743x_ptp_update_latency(struct lan743x_adapter
*adapter
,
39 int lan743x_ptp_ioctl(struct net_device
*netdev
, struct ifreq
*ifr
, int cmd
);
41 #define LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS (4)
43 #define PTP_FLAG_PTP_CLOCK_REGISTERED BIT(1)
44 #define PTP_FLAG_ISR_ENABLED BIT(2)
49 /* command_lock: used to prevent concurrent ptp commands */
50 struct mutex command_lock
;
52 struct ptp_clock
*ptp_clock
;
53 struct ptp_clock_info ptp_clock_info
;
54 struct ptp_pin_desc pin_config
[1];
56 #define LAN743X_PTP_NUMBER_OF_EVENT_CHANNELS (2)
57 unsigned long used_event_ch
;
62 /* tx_ts_lock: used to prevent concurrent access to timestamp arrays */
63 spinlock_t tx_ts_lock
;
64 int pending_tx_timestamps
;
65 struct sk_buff
*tx_ts_skb_queue
[LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS
];
66 unsigned int tx_ts_ignore_sync_queue
;
67 int tx_ts_skb_queue_size
;
68 u32 tx_ts_seconds_queue
[LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS
];
69 u32 tx_ts_nseconds_queue
[LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS
];
70 u32 tx_ts_header_queue
[LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS
];
74 #endif /* _LAN743X_PTP_H */