drivers/misc/mei/platform-vsc.c

Source file repositories/reference/linux-study-clean/drivers/misc/mei/platform-vsc.c

File Facts

System
Linux kernel
Corpus path
drivers/misc/mei/platform-vsc.c
Extension
.c
Size
10234 bytes
Lines
460
Domain
Driver Families
Bucket
drivers/misc
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 mei_vsc_host_timestamp {
	u64 realtime;
	u64 boottime;
};

struct mei_vsc_hw {
	struct vsc_tp *tp;

	bool fw_ready;
	bool host_ready;

	atomic_t write_lock_cnt;

	u32 rx_len;
	u32 rx_hdr;

	/* buffer for tx */
	char tx_buf[MEI_VSC_MAX_MSG_SIZE + sizeof(struct mei_msg_hdr)] ____cacheline_aligned;
	/* buffer for rx */
	char rx_buf[MEI_VSC_MAX_MSG_SIZE + sizeof(struct mei_msg_hdr)] ____cacheline_aligned;
};

static int mei_vsc_read_helper(struct mei_vsc_hw *hw, u8 *buf,
			       u32 max_len)
{
	struct mei_vsc_host_timestamp ts = {
		.realtime = ktime_to_ns(ktime_get_real()),
		.boottime = ktime_to_ns(ktime_get_boottime()),
	};

	return vsc_tp_xfer(hw->tp, VSC_TP_CMD_READ, &ts, sizeof(ts),
			   buf, max_len);
}

static int mei_vsc_write_helper(struct mei_vsc_hw *hw, u8 *buf, u32 len)
{
	u8 status;

	return vsc_tp_xfer(hw->tp, VSC_TP_CMD_WRITE, buf, len, &status,
			   sizeof(status));
}

static int mei_vsc_fw_status(struct mei_device *mei_dev,
			     struct mei_fw_status *fw_status)
{
	if (!fw_status)
		return -EINVAL;

	fw_status->count = 0;

	return 0;
}

static inline enum mei_pg_state mei_vsc_pg_state(struct mei_device *mei_dev)
{
	return MEI_PG_OFF;
}

static void mei_vsc_intr_enable(struct mei_device *mei_dev)
{
	struct mei_vsc_hw *hw = mei_dev_to_vsc_hw(mei_dev);

	vsc_tp_intr_enable(hw->tp);
}

static void mei_vsc_intr_disable(struct mei_device *mei_dev)
{
	struct mei_vsc_hw *hw = mei_dev_to_vsc_hw(mei_dev);

	vsc_tp_intr_disable(hw->tp);
}

/* mei framework requires this ops */
static void mei_vsc_intr_clear(struct mei_device *mei_dev)
{
}

/* wait for pending irq handler */
static void mei_vsc_synchronize_irq(struct mei_device *mei_dev)
{
	struct mei_vsc_hw *hw = mei_dev_to_vsc_hw(mei_dev);

	vsc_tp_intr_synchronize(hw->tp);
}

static int mei_vsc_hw_config(struct mei_device *mei_dev)
{
	return 0;
}

Annotation

Implementation Notes