drivers/rpmsg/qcom_smd.c

Source file repositories/reference/linux-study-clean/drivers/rpmsg/qcom_smd.c

File Facts

System
Linux kernel
Corpus path
drivers/rpmsg/qcom_smd.c
Extension
.c
Size
42001 bytes
Lines
1623
Domain
Driver Families
Bucket
drivers/rpmsg
Inferred role
Driver Families: exported/initcall integration point
Status
integration 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 qcom_smd_edge {
	struct device dev;

	const char *name;

	struct device_node *of_node;
	unsigned edge_id;
	unsigned remote_pid;

	int irq;

	struct regmap *ipc_regmap;
	int ipc_offset;
	int ipc_bit;

	struct mbox_client mbox_client;
	struct mbox_chan *mbox_chan;

	struct list_head channels;
	spinlock_t channels_lock;

	DECLARE_BITMAP(allocated[SMD_ALLOC_TBL_COUNT], SMD_ALLOC_TBL_SIZE);

	unsigned smem_available;

	wait_queue_head_t new_channel_event;

	struct work_struct scan_work;
	struct work_struct state_work;
};

/*
 * SMD channel states.
 */
enum smd_channel_state {
	SMD_CHANNEL_CLOSED,
	SMD_CHANNEL_OPENING,
	SMD_CHANNEL_OPENED,
	SMD_CHANNEL_FLUSHING,
	SMD_CHANNEL_CLOSING,
	SMD_CHANNEL_RESET,
	SMD_CHANNEL_RESET_OPENING
};

struct qcom_smd_device {
	struct rpmsg_device rpdev;

	struct qcom_smd_edge *edge;
};

struct qcom_smd_endpoint {
	struct rpmsg_endpoint ept;

	struct qcom_smd_channel *qsch;
};

#define to_smd_device(r)	container_of(r, struct qcom_smd_device, rpdev)
#define to_smd_edge(d)		container_of(d, struct qcom_smd_edge, dev)
#define to_smd_endpoint(e)	container_of(e, struct qcom_smd_endpoint, ept)

/**
 * struct qcom_smd_channel - smd channel struct
 * @edge:		qcom_smd_edge this channel is living on
 * @qsept:		reference to a associated smd endpoint
 * @registered:		flag to indicate if the channel is registered
 * @name:		name of the channel
 * @state:		local state of the channel
 * @remote_state:	remote state of the channel
 * @state_change_event:	state change event
 * @info:		byte aligned outgoing/incoming channel info
 * @info_word:		word aligned outgoing/incoming channel info
 * @tx_lock:		lock to make writes to the channel mutually exclusive
 * @fblockread_event:	wakeup event tied to tx fBLOCKREADINTR
 * @tx_fifo:		pointer to the outgoing ring buffer
 * @rx_fifo:		pointer to the incoming ring buffer
 * @fifo_size:		size of each ring buffer
 * @bounce_buffer:	bounce buffer for reading wrapped packets
 * @cb:			callback function registered for this channel
 * @recv_lock:		guard for rx info modifications and cb pointer
 * @pkt_size:		size of the currently handled packet
 * @drvdata:		driver private data
 * @list:		lite entry for @channels in qcom_smd_edge
 */
struct qcom_smd_channel {
	struct qcom_smd_edge *edge;

	struct qcom_smd_endpoint *qsept;
	bool registered;

	char *name;

Annotation

Implementation Notes