Commit 3b251838 authored by Yongxu Wang's avatar Yongxu Wang Committed by Fabio Baltieri
Browse files

drivers: firmware: scmi: add cpu lpm interface api



Added scmi_cpu_pd_lpm_set api for nxp imx scmi interface

This api set the lpm setting for some peripherals applied
when cpu enter a low power mode, such as keep iMX95 wakeup mix
power on when M7 core enter suspend mode, scmi agent record and
deal with this request

Signed-off-by: default avatarYongxu Wang <yongxu.wang@nxp.com>
parent 480f01ec
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
@@ -51,3 +51,42 @@ int scmi_cpu_sleep_mode_set(struct scmi_cpu_sleep_mode_config *cfg)

	return 0;
}

int scmi_cpu_pd_lpm_set(struct scmi_cpu_pd_lpm_config *cfg)
{
	struct scmi_protocol *proto = &SCMI_PROTOCOL_NAME(SCMI_PROTOCOL_CPU_DOMAIN);
	struct scmi_message msg, reply;
	int status, ret;
	bool use_polling;

	/* sanity checks */
	if (!proto || !cfg) {
		return -EINVAL;
	}

	if (proto->id != SCMI_PROTOCOL_CPU_DOMAIN) {
		return -EINVAL;
	}

	msg.hdr = SCMI_MESSAGE_HDR_MAKE(SCMI_CPU_DOMAIN_MSG_CPU_PD_LPM_CONFIG_SET, SCMI_COMMAND,
					proto->id, 0x0);
	msg.len = sizeof(*cfg);
	msg.content = cfg;

	reply.hdr = msg.hdr;
	reply.len = sizeof(status);
	reply.content = &status;

	use_polling = true;

	ret = scmi_send_message(proto, &msg, &reply, use_polling);
	if (ret < 0) {
		return ret;
	}

	if (status != SCMI_SUCCESS) {
		return scmi_status_to_errno(status);
	}

	return 0;
}
+29 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@

#define SCMI_PROTOCOL_CPU_DOMAIN 130

#define SCMI_CPU_MAX_PDCONFIGS_T 7U

/**
 * @struct scmi_cpu_sleep_mode_config
 *
@@ -33,6 +35,23 @@ struct scmi_cpu_sleep_mode_config {
	uint32_t sleep_mode;
};

struct scmi_pd_lpm_settings {
	uint32_t domain_id;
	uint32_t lpm_setting;
	uint32_t ret_mask;
};

/**
 * @struct scmi_cpu_pd_lpm_config
 *
 * @brief Describes cpu power domain low power mode setting
 */
struct scmi_cpu_pd_lpm_config {
	uint32_t cpu_id;
	uint32_t num_cfg;
	struct scmi_pd_lpm_settings cfgs[SCMI_CPU_MAX_PDCONFIGS_T];
};

/**
 * @brief CPU domain protocol command message IDs
 */
@@ -64,4 +83,14 @@ enum scmi_cpu_domain_message {
 */
int scmi_cpu_sleep_mode_set(struct scmi_cpu_sleep_mode_config *cfg);

/**
 * @brief Send the SCMI_CPU_DOMAIN_MSG_CPU_PD_LPM_CONFIG_SET command and get its reply
 *
 * @param cfg pointer to structure containing configuration
 * to be set
 *
 * @retval 0 if successful
 * @retval negative errno if failure
 */
int scmi_cpu_pd_lpm_set(struct scmi_cpu_pd_lpm_config *cfg);
#endif /* _INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_SCMI_CPU_H_ */