File Index
Files and directories
Sign in
FILE

ksz_ptp.h

File preview with syntax highlighting.

linux-6.19.14/drivers/net/dsa/microchip/ksz_ptp.h C
 1/* SPDX-License-Identifier: GPL-2.0 */
 2/* Microchip KSZ PTP Implementation
 3 *
 4 * Copyright (C) 2020 ARRI Lighting
 5 * Copyright (C) 2022 Microchip Technology Inc.
 6 */
 7
 8#ifndef _NET_DSA_DRIVERS_KSZ_PTP_H
 9#define _NET_DSA_DRIVERS_KSZ_PTP_H
10
11#if IS_ENABLED(CONFIG_NET_DSA_MICROCHIP_KSZ_PTP)
12
13#include <linux/ptp_clock_kernel.h>
14
15#define KSZ_PTP_N_GPIO		2
16
17enum ksz_ptp_tou_mode {
18	KSZ_PTP_TOU_IDLE,
19	KSZ_PTP_TOU_PEROUT,
20};
21
22struct ksz_ptp_data {
23	struct ptp_clock_info caps;
24	struct ptp_clock *clock;
25	struct ptp_pin_desc pin_config[KSZ_PTP_N_GPIO];
26	/* Serializes all operations on the PTP hardware clock */
27	struct mutex lock;
28	/* lock for accessing the clock_time */
29	spinlock_t clock_lock;
30	struct timespec64 clock_time;
31	enum ksz_ptp_tou_mode tou_mode;
32	struct timespec64 perout_target_time_first;  /* start of first pulse */
33	struct timespec64 perout_period;
34};
35
36int ksz_ptp_clock_register(struct dsa_switch *ds);
37
38void ksz_ptp_clock_unregister(struct dsa_switch *ds);
39
40int ksz_get_ts_info(struct dsa_switch *ds, int port,
41		    struct kernel_ethtool_ts_info *ts);
42int ksz_hwtstamp_get(struct dsa_switch *ds, int port,
43		     struct kernel_hwtstamp_config *config);
44int ksz_hwtstamp_set(struct dsa_switch *ds, int port,
45		     struct kernel_hwtstamp_config *config,
46		     struct netlink_ext_ack *extack);
47void ksz_port_txtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb);
48void ksz_port_deferred_xmit(struct kthread_work *work);
49bool ksz_port_rxtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb,
50		       unsigned int type);
51int ksz_ptp_irq_setup(struct dsa_switch *ds, u8 p);
52void ksz_ptp_irq_free(struct dsa_switch *ds, u8 p);
53
54#else
55
56struct ksz_ptp_data {
57	/* Serializes all operations on the PTP hardware clock */
58	struct mutex lock;
59};
60
61static inline int ksz_ptp_clock_register(struct dsa_switch *ds)
62{
63	return 0;
64}
65
66static inline void ksz_ptp_clock_unregister(struct dsa_switch *ds) { }
67
68static inline int ksz_ptp_irq_setup(struct dsa_switch *ds, u8 p)
69{
70	return 0;
71}
72
73static inline void ksz_ptp_irq_free(struct dsa_switch *ds, u8 p) {}
74
75#define ksz_get_ts_info NULL
76
77#define ksz_hwtstamp_get NULL
78
79#define ksz_hwtstamp_set NULL
80
81#define ksz_port_rxtstamp NULL
82
83#define ksz_port_txtstamp NULL
84
85#define ksz_port_deferred_xmit NULL
86
87#endif	/* End of CONFIG_NET_DSA_MICROCHIP_KSZ_PTP */
88
89#endif
~/ Read-only file preview.