Linux Audio

Check our new training course

Loading...
v6.8
  1/* SPDX-License-Identifier: GPL-2.0+ */
  2/* Copyright (C) 2018 Microchip Technology Inc. */
  3
  4#ifndef _LAN743X_PTP_H
  5#define _LAN743X_PTP_H
  6
  7#include "linux/ptp_clock_kernel.h"
  8#include "linux/netdevice.h"
  9
 10#define LAN7430_N_LED			4
 11#define LAN7430_N_GPIO			4	/* multiplexed with PHY LEDs */
 12#define LAN7431_N_GPIO			12
 13
 14#define LAN743X_PTP_N_GPIO		LAN7431_N_GPIO
 15
 16/* the number of periodic outputs is limited by number of
 17 * PTP clock event channels
 18 */
 19#define LAN743X_PTP_N_EVENT_CHAN	2
 20#define LAN743X_PTP_N_PEROUT		LAN743X_PTP_N_EVENT_CHAN
 21#define LAN743X_PTP_N_EXTTS		4
 22#define LAN743X_PTP_N_PPS		0
 23#define PCI11X1X_PTP_IO_MAX_CHANNELS	8
 24
 25struct lan743x_adapter;
 26
 27/* GPIO */
 28struct lan743x_gpio {
 29	/* gpio_lock: used to prevent concurrent access to gpio settings */
 30	spinlock_t gpio_lock;
 31
 32	int used_bits;
 33	int output_bits;
 34	int ptp_bits;
 35	u32 gpio_cfg0;
 36	u32 gpio_cfg1;
 37	u32 gpio_cfg2;
 38	u32 gpio_cfg3;
 39};
 40
 41int lan743x_gpio_init(struct lan743x_adapter *adapter);
 42
 43void lan743x_ptp_isr(void *context);
 44bool lan743x_ptp_request_tx_timestamp(struct lan743x_adapter *adapter);
 45void lan743x_ptp_unrequest_tx_timestamp(struct lan743x_adapter *adapter);
 46void lan743x_ptp_tx_timestamp_skb(struct lan743x_adapter *adapter,
 47				  struct sk_buff *skb, bool ignore_sync);
 48int lan743x_ptp_init(struct lan743x_adapter *adapter);
 49int lan743x_ptp_open(struct lan743x_adapter *adapter);
 50void lan743x_ptp_close(struct lan743x_adapter *adapter);
 51void lan743x_ptp_update_latency(struct lan743x_adapter *adapter,
 52				u32 link_speed);
 53
 54int lan743x_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
 55
 56#define LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS (4)
 57
 58#define PTP_FLAG_PTP_CLOCK_REGISTERED		BIT(1)
 59#define PTP_FLAG_ISR_ENABLED			BIT(2)
 60
 61struct lan743x_ptp_perout {
 62	int  event_ch;	/* PTP event channel (0=channel A, 1=channel B) */
 63	int  gpio_pin;	/* GPIO pin where output appears */
 64};
 65
 66struct lan743x_extts {
 67	int flags;
 68	struct timespec64 ts;
 69};
 70
 71struct lan743x_ptp {
 72	int flags;
 73
 74	/* command_lock: used to prevent concurrent ptp commands */
 75	struct mutex	command_lock;
 76
 77	struct ptp_clock *ptp_clock;
 78	struct ptp_clock_info ptp_clock_info;
 79	struct ptp_pin_desc pin_config[LAN743X_PTP_N_GPIO];
 80
 
 81	unsigned long used_event_ch;
 82	struct lan743x_ptp_perout perout[LAN743X_PTP_N_PEROUT];
 83	int ptp_io_perout[LAN743X_PTP_N_PEROUT]; /* PTP event channel (0=channel A, 1=channel B) */
 84	struct lan743x_extts extts[LAN743X_PTP_N_EXTTS];
 85
 86	bool leds_multiplexed;
 87	bool led_enabled[LAN7430_N_LED];
 88
 89	/* tx_ts_lock: used to prevent concurrent access to timestamp arrays */
 90	spinlock_t	tx_ts_lock;
 91	int pending_tx_timestamps;
 92	struct sk_buff *tx_ts_skb_queue[LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS];
 93	unsigned int	tx_ts_ignore_sync_queue;
 94	int tx_ts_skb_queue_size;
 95	u32 tx_ts_seconds_queue[LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS];
 96	u32 tx_ts_nseconds_queue[LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS];
 97	u32 tx_ts_header_queue[LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS];
 98	int tx_ts_queue_size;
 99};
100
101#endif /* _LAN743X_PTP_H */
v5.4
 1/* SPDX-License-Identifier: GPL-2.0+ */
 2/* Copyright (C) 2018 Microchip Technology Inc. */
 3
 4#ifndef _LAN743X_PTP_H
 5#define _LAN743X_PTP_H
 6
 7#include "linux/ptp_clock_kernel.h"
 8#include "linux/netdevice.h"
 9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10struct lan743x_adapter;
11
12/* GPIO */
13struct lan743x_gpio {
14	/* gpio_lock: used to prevent concurrent access to gpio settings */
15	spinlock_t gpio_lock;
16
17	int used_bits;
18	int output_bits;
19	int ptp_bits;
20	u32 gpio_cfg0;
21	u32 gpio_cfg1;
22	u32 gpio_cfg2;
23	u32 gpio_cfg3;
24};
25
26int lan743x_gpio_init(struct lan743x_adapter *adapter);
27
28void lan743x_ptp_isr(void *context);
29bool lan743x_ptp_request_tx_timestamp(struct lan743x_adapter *adapter);
30void lan743x_ptp_unrequest_tx_timestamp(struct lan743x_adapter *adapter);
31void lan743x_ptp_tx_timestamp_skb(struct lan743x_adapter *adapter,
32				  struct sk_buff *skb, bool ignore_sync);
33int lan743x_ptp_init(struct lan743x_adapter *adapter);
34int lan743x_ptp_open(struct lan743x_adapter *adapter);
35void lan743x_ptp_close(struct lan743x_adapter *adapter);
36void lan743x_ptp_update_latency(struct lan743x_adapter *adapter,
37				u32 link_speed);
38
39int lan743x_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
40
41#define LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS (4)
42
43#define PTP_FLAG_PTP_CLOCK_REGISTERED	BIT(1)
44#define PTP_FLAG_ISR_ENABLED			BIT(2)
45
 
 
 
 
 
 
 
 
 
 
46struct lan743x_ptp {
47	int flags;
48
49	/* command_lock: used to prevent concurrent ptp commands */
50	struct mutex	command_lock;
51
52	struct ptp_clock *ptp_clock;
53	struct ptp_clock_info ptp_clock_info;
54	struct ptp_pin_desc pin_config[1];
55
56#define LAN743X_PTP_NUMBER_OF_EVENT_CHANNELS (2)
57	unsigned long used_event_ch;
 
 
 
58
59	int perout_event_ch;
60	int perout_gpio_bit;
61
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];
71	int tx_ts_queue_size;
72};
73
74#endif /* _LAN743X_PTP_H */