drivers/ptp/ptp_ines.c

Source file repositories/reference/linux-study-clean/drivers/ptp/ptp_ines.c

File Facts

System
Linux kernel
Corpus path
drivers/ptp/ptp_ines.c
Extension
.c
Size
19616 bytes
Lines
815
Domain
Driver Families
Bucket
drivers/ptp
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 ines_global_regs {
	u32 id;
	u32 test;
	u32 global;
	u32 version;
	u32 test2;
	u32 int_stat;
	u32 int_msk;
	u32 buf_stat;
};

struct ines_port_registers {
	u32 port_conf;
	u32 p_delay;
	u32 ts_stat_tx;
	u32 ts_stat_rx;
	u32 ts_tx;
	u32 ts_rx;
};

struct ines_timestamp {
	struct list_head list;
	unsigned long	tmo;
	u16		tag;
	u64		sec;
	u64		nsec;
	u64		clkid;
	u16		portnum;
	u16		seqid;
};

struct ines_port {
	struct ines_port_registers	*regs;
	struct mii_timestamper		mii_ts;
	struct ines_clock		*clock;
	bool				rxts_enabled;
	bool				txts_enabled;
	unsigned int			index;
	struct delayed_work		ts_work;
	/* lock protects event list and tx_skb */
	spinlock_t			lock;
	struct sk_buff			*tx_skb;
	struct list_head		events;
	struct list_head		pool;
	struct ines_timestamp		pool_data[INES_MAX_EVENTS];
};

struct ines_clock {
	struct ines_port		port[INES_N_PORTS];
	struct ines_global_regs __iomem	*regs;
	void __iomem			*base;
	struct device_node		*node;
	struct device			*dev;
	struct list_head		list;
};

static bool ines_match(struct sk_buff *skb, unsigned int ptp_class,
		       struct ines_timestamp *ts, struct device *dev);
static int ines_rxfifo_read(struct ines_port *port);
static u64 ines_rxts64(struct ines_port *port, unsigned int words);
static bool ines_timestamp_expired(struct ines_timestamp *ts);
static u64 ines_txts64(struct ines_port *port, unsigned int words);
static void ines_txtstamp_work(struct work_struct *work);
static bool is_sync_pdelay_resp(struct sk_buff *skb, int type);
static u8 tag_to_msgtype(u8 tag);

static void ines_clock_cleanup(struct ines_clock *clock)
{
	struct ines_port *port;
	int i;

	for (i = 0; i < INES_N_PORTS; i++) {
		port = &clock->port[i];
		cancel_delayed_work_sync(&port->ts_work);
	}
}

static int ines_clock_init(struct ines_clock *clock, struct device *device,
			   void __iomem *addr)
{
	struct device_node *node = device->of_node;
	unsigned long port_addr;
	struct ines_port *port;
	int i, j;

	INIT_LIST_HEAD(&clock->list);
	clock->node = node;
	clock->dev  = device;
	clock->base = addr;
	clock->regs = clock->base;

Annotation

Implementation Notes