drivers/soc/xilinx/zynqmp_power.c

Source file repositories/reference/linux-study-clean/drivers/soc/xilinx/zynqmp_power.c

File Facts

System
Linux kernel
Corpus path
drivers/soc/xilinx/zynqmp_power.c
Extension
.c
Size
11398 bytes
Lines
413
Domain
Driver Families
Bucket
drivers/soc
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 zynqmp_pm_work_struct {
	struct work_struct callback_work;
	u32 args[CB_ARG_CNT];
};

/**
 * struct zynqmp_pm_event_info - event related information
 * @cb_fun:	Function pointer to store the callback function.
 * @cb_type:	Type of callback from pm_api_cb_id,
 *			PM_NOTIFY_CB - for Error Events,
 *			PM_INIT_SUSPEND_CB - for suspend callback.
 * @node_id:	Node-Id related to event.
 * @event:	Event Mask for the Error Event.
 * @wake:	Flag specifying whether the subsystem should be woken upon
 *		event notification.
 */
struct zynqmp_pm_event_info {
	event_cb_func_t cb_fun;
	enum pm_api_cb_id cb_type;
	u32 node_id;
	u32 event;
	bool wake;
};

static struct zynqmp_pm_work_struct *zynqmp_pm_init_suspend_work, *zynqmp_pm_init_restart_work;
static struct mbox_chan *rx_chan;

enum pm_suspend_mode {
	PM_SUSPEND_MODE_FIRST = 0,
	PM_SUSPEND_MODE_STD = PM_SUSPEND_MODE_FIRST,
	PM_SUSPEND_MODE_POWER_OFF,
};

#define PM_SUSPEND_MODE_FIRST	PM_SUSPEND_MODE_STD

static const char *const suspend_modes[] = {
	[PM_SUSPEND_MODE_STD] = "standard",
	[PM_SUSPEND_MODE_POWER_OFF] = "power-off",
};

static enum pm_suspend_mode suspend_mode = PM_SUSPEND_MODE_STD;

static void zynqmp_pm_get_callback_data(u32 *buf)
{
	zynqmp_pm_invoke_fn(GET_CALLBACK_DATA, buf, 0);
}

static void subsystem_restart_event_callback(const u32 *payload, void *data)
{
	/* First element is callback API ID, others are callback arguments */
	if (work_pending(&zynqmp_pm_init_restart_work->callback_work))
		return;

	/* Copy callback arguments into work's structure */
	memcpy(zynqmp_pm_init_restart_work->args, &payload[0],
	       sizeof(zynqmp_pm_init_restart_work->args));

	queue_work(system_dfl_wq, &zynqmp_pm_init_restart_work->callback_work);
}

static void suspend_event_callback(const u32 *payload, void *data)
{
	/* First element is callback API ID, others are callback arguments */
	if (work_pending(&zynqmp_pm_init_suspend_work->callback_work))
		return;

	/* Copy callback arguments into work's structure */
	memcpy(zynqmp_pm_init_suspend_work->args, &payload[1],
	       sizeof(zynqmp_pm_init_suspend_work->args));

	queue_work(system_dfl_wq, &zynqmp_pm_init_suspend_work->callback_work);
}

static irqreturn_t zynqmp_pm_isr(int irq, void *data)
{
	u32 payload[CB_PAYLOAD_SIZE];

	zynqmp_pm_get_callback_data(payload);

	/* First element is callback API ID, others are callback arguments */
	if (payload[0] == PM_INIT_SUSPEND_CB) {
		switch (payload[1]) {
		case SUSPEND_SYSTEM_SHUTDOWN:
			orderly_poweroff(true);
			break;
		case SUSPEND_POWER_REQUEST:
			pm_suspend(PM_SUSPEND_MEM);
			break;
		default:
			pr_err("%s Unsupported InitSuspendCb reason code %d\n",

Annotation

Implementation Notes