drivers/firmware/arm_scmi/vendors/imx/imx-sm-bbm.c

Source file repositories/reference/linux-study-clean/drivers/firmware/arm_scmi/vendors/imx/imx-sm-bbm.c

File Facts

System
Linux kernel
Corpus path
drivers/firmware/arm_scmi/vendors/imx/imx-sm-bbm.c
Extension
.c
Size
9079 bytes
Lines
379
Domain
Driver Families
Bucket
drivers/firmware
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 scmi_imx_bbm_info {
	int nr_rtc;
	int nr_gpr;
};

struct scmi_msg_imx_bbm_protocol_attributes {
	__le32 attributes;
};

struct scmi_imx_bbm_set_time {
	__le32 id;
	__le32 flags;
	__le32 value_low;
	__le32 value_high;
};

struct scmi_imx_bbm_get_time {
	__le32 id;
	__le32 flags;
};

struct scmi_imx_bbm_alarm_time {
	__le32 id;
	__le32 flags;
	__le32 value_low;
	__le32 value_high;
};

struct scmi_msg_imx_bbm_rtc_notify {
	__le32 rtc_id;
	__le32 flags;
};

struct scmi_msg_imx_bbm_button_notify {
	__le32 flags;
};

struct scmi_imx_bbm_notify_payld {
	__le32 flags;
};

static int scmi_imx_bbm_attributes_get(const struct scmi_protocol_handle *ph,
				       struct scmi_imx_bbm_info *pi)
{
	int ret;
	struct scmi_xfer *t;
	struct scmi_msg_imx_bbm_protocol_attributes *attr;

	ret = ph->xops->xfer_get_init(ph, PROTOCOL_ATTRIBUTES, 0, sizeof(*attr), &t);
	if (ret)
		return ret;

	attr = t->rx.buf;

	ret = ph->xops->do_xfer(ph, t);
	if (!ret) {
		pi->nr_rtc = GET_RTCS_NR(attr->attributes);
		pi->nr_gpr = GET_GPRS_NR(attr->attributes);
	}

	ph->xops->xfer_put(ph, t);

	return ret;
}

static int scmi_imx_bbm_notify(const struct scmi_protocol_handle *ph,
			       u32 src_id, int message_id, bool enable)
{
	int ret;
	struct scmi_xfer *t;

	if (message_id == IMX_BBM_RTC_NOTIFY) {
		struct scmi_msg_imx_bbm_rtc_notify *rtc_notify;

		ret = ph->xops->xfer_get_init(ph, message_id,
					      sizeof(*rtc_notify), 0, &t);
		if (ret)
			return ret;

		rtc_notify = t->tx.buf;
		rtc_notify->rtc_id = cpu_to_le32(0);
		rtc_notify->flags =
			cpu_to_le32(enable ? SCMI_IMX_BBM_NOTIFY_RTC_FLAG : 0);
	} else if (message_id == IMX_BBM_BUTTON_NOTIFY) {
		struct scmi_msg_imx_bbm_button_notify *button_notify;

		ret = ph->xops->xfer_get_init(ph, message_id,
					      sizeof(*button_notify), 0, &t);
		if (ret)
			return ret;

Annotation

Implementation Notes