drivers/accel/qaic/qaic_timesync.c

Source file repositories/reference/linux-study-clean/drivers/accel/qaic/qaic_timesync.c

File Facts

System
Linux kernel
Corpus path
drivers/accel/qaic/qaic_timesync.c
Extension
.c
Size
10706 bytes
Lines
406
Domain
Driver Families
Bucket
drivers/accel
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 qts_hdr {
	__le16	signature;
	__le16	reserved_1;
	u8	reserved_2;
	u8	msg_type;
	__le16	reserved_3;
} __packed;

/**
 * struct qts_timeval - Structure to carry time information.
 * @tv_sec: Seconds part of the time.
 * @tv_usec: uS (microseconds) part of the time.
 */
struct qts_timeval {
	__le64	tv_sec;
	__le64	tv_usec;
} __packed;

/**
 * struct qts_host_time_sync_msg_data - Structure to denote the timesync message.
 * @header: Header of the timesync message.
 * @data: Time information.
 */
struct qts_host_time_sync_msg_data {
	struct	qts_hdr header;
	struct	qts_timeval data;
} __packed;

/**
 * struct mqts_dev - MHI QAIC Timesync Control device.
 * @qdev: Pointer to the root device struct driven by QAIC driver.
 * @mhi_dev: Pointer to associated MHI device.
 * @timer: Timer handle used for timesync.
 * @qtimer_addr: Device QTimer register pointer.
 * @buff_in_use: atomic variable to track if the sync_msg buffer is in use.
 * @dev: Device pointer to qdev->pdev->dev stored for easy access.
 * @sync_msg: Buffer used to send timesync message over MHI.
 */
struct mqts_dev {
	struct qaic_device *qdev;
	struct mhi_device *mhi_dev;
	struct timer_list timer;
	void __iomem *qtimer_addr;
	atomic_t buff_in_use;
	struct device *dev;
	struct qts_host_time_sync_msg_data *sync_msg;
};

struct qts_resp_msg {
	struct qts_hdr	hdr;
} __packed;

struct qts_resp {
	struct qts_resp_msg	data;
	struct work_struct	work;
	struct qaic_device	*qdev;
};

#ifdef readq
static u64 read_qtimer(const volatile void __iomem *addr)
{
	return readq(addr);
}
#else
static u64 read_qtimer(const volatile void __iomem *addr)
{
	u64 low, high;

	low = readl(addr);
	high = readl(addr + sizeof(u32));
	return low | (high << 32);
}
#endif

static void qaic_timesync_ul_xfer_cb(struct mhi_device *mhi_dev, struct mhi_result *mhi_result)
{
	struct mqts_dev *mqtsdev = dev_get_drvdata(&mhi_dev->dev);

	dev_dbg(mqtsdev->dev, "%s status: %d xfer_len: %zu\n", __func__,
		mhi_result->transaction_status, mhi_result->bytes_xferd);

	atomic_set(&mqtsdev->buff_in_use, 0);
}

static void qaic_timesync_dl_xfer_cb(struct mhi_device *mhi_dev, struct mhi_result *mhi_result)
{
	struct mqts_dev *mqtsdev = dev_get_drvdata(&mhi_dev->dev);

	dev_err(mqtsdev->dev, "%s no data expected on dl channel\n", __func__);
}

Annotation

Implementation Notes