drivers/net/ethernet/microchip/lan743x_ptp.h

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/microchip/lan743x_ptp.h

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/microchip/lan743x_ptp.h
Extension
.h
Size
3219 bytes
Lines
106
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct lan743x_gpio {
	/* gpio_lock: used to prevent concurrent access to gpio settings */
	spinlock_t gpio_lock;

	int used_bits;
	int output_bits;
	int ptp_bits;
	u32 gpio_cfg0;
	u32 gpio_cfg1;
	u32 gpio_cfg2;
	u32 gpio_cfg3;
};

int lan743x_gpio_init(struct lan743x_adapter *adapter);

void lan743x_ptp_isr(void *context);
bool lan743x_ptp_request_tx_timestamp(struct lan743x_adapter *adapter);
void lan743x_ptp_unrequest_tx_timestamp(struct lan743x_adapter *adapter);
void lan743x_ptp_tx_timestamp_skb(struct lan743x_adapter *adapter,
				  struct sk_buff *skb, bool ignore_sync);
int lan743x_ptp_init(struct lan743x_adapter *adapter);
int lan743x_ptp_open(struct lan743x_adapter *adapter);
void lan743x_ptp_close(struct lan743x_adapter *adapter);
void lan743x_ptp_update_latency(struct lan743x_adapter *adapter,
				u32 link_speed);
int lan743x_ptp_hwtstamp_get(struct net_device *netdev,
			     struct kernel_hwtstamp_config *config);
int lan743x_ptp_hwtstamp_set(struct net_device *netdev,
			     struct kernel_hwtstamp_config *config,
			     struct netlink_ext_ack *extack);

#define LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS (4)

#define PTP_FLAG_PTP_CLOCK_REGISTERED		BIT(1)
#define PTP_FLAG_ISR_ENABLED			BIT(2)

struct lan743x_ptp_perout {
	int  event_ch;	/* PTP event channel (0=channel A, 1=channel B) */
	int  gpio_pin;	/* GPIO pin where output appears */
};

struct lan743x_extts {
	int flags;
	struct timespec64 ts;
};

struct lan743x_ptp {
	int flags;

	/* command_lock: used to prevent concurrent ptp commands */
	struct mutex	command_lock;

	struct ptp_clock *ptp_clock;
	struct ptp_clock_info ptp_clock_info;
	struct ptp_pin_desc pin_config[LAN743X_PTP_N_GPIO];

	unsigned long used_event_ch;
	struct lan743x_ptp_perout perout[LAN743X_PTP_N_PEROUT];
	int ptp_io_perout[LAN743X_PTP_N_PEROUT]; /* PTP event channel (0=channel A, 1=channel B) */
	struct lan743x_extts extts[LAN743X_PTP_N_EXTTS];

	bool leds_multiplexed;
	bool led_enabled[LAN7430_N_LED];

	/* tx_ts_lock: used to prevent concurrent access to timestamp arrays */
	spinlock_t	tx_ts_lock;
	int pending_tx_timestamps;
	struct sk_buff *tx_ts_skb_queue[LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS];
	unsigned int	tx_ts_ignore_sync_queue;
	int tx_ts_skb_queue_size;
	u32 tx_ts_seconds_queue[LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS];
	u32 tx_ts_nseconds_queue[LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS];
	u32 tx_ts_header_queue[LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS];
	int tx_ts_queue_size;
};

#endif /* _LAN743X_PTP_H */

Annotation

Implementation Notes