Skip to content

Commit 3c10388

Browse files
committed
drivers: scmi: add cpu lpm interface api
add scmi_cpu_pd_lpm_set api for nxp imx scmi interface Signed-off-by: Yongxu Wang <[email protected]>
1 parent 94f3ca1 commit 3c10388

File tree

2 files changed

+65
-0
lines changed
  • drivers/firmware/scmi/nxp
  • include/zephyr/drivers/firmware/scmi/nxp

2 files changed

+65
-0
lines changed

drivers/firmware/scmi/nxp/cpu.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,39 @@ int scmi_cpu_sleep_mode_set(struct scmi_cpu_sleep_mode_config *cfg)
4545

4646
return 0;
4747
}
48+
49+
int scmi_cpu_pd_lpm_set(struct scmi_cpu_pd_lpm_config *cfg)
50+
{
51+
struct scmi_protocol *proto = &SCMI_PROTOCOL_NAME(SCMI_PROTOCOL_CPU_DOMAIN);
52+
struct scmi_message msg, reply;
53+
int status, ret;
54+
55+
/* sanity checks */
56+
if (!proto || !cfg) {
57+
return -EINVAL;
58+
}
59+
60+
if (proto->id != SCMI_PROTOCOL_CPU_DOMAIN) {
61+
return -EINVAL;
62+
}
63+
64+
msg.hdr = SCMI_MESSAGE_HDR_MAKE(SCMI_CPU_DOMAIN_MSG_CPU_PD_LPM_CONFIG_SET, SCMI_COMMAND,
65+
proto->id, 0x0);
66+
msg.len = sizeof(*cfg);
67+
msg.content = cfg;
68+
69+
reply.hdr = msg.hdr;
70+
reply.len = sizeof(status);
71+
reply.content = &status;
72+
73+
ret = scmi_send_message(proto, &msg, &reply, true);
74+
if (ret < 0) {
75+
return ret;
76+
}
77+
78+
if (status != SCMI_SUCCESS) {
79+
return scmi_status_to_errno(status);
80+
}
81+
82+
return 0;
83+
}

include/zephyr/drivers/firmware/scmi/nxp/cpu.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
#define SCMI_PROTOCOL_CPU_DOMAIN 130
2323

24+
#define SCMI_CPU_MAX_PDCONFIGS_T 7U
25+
2426
/**
2527
* @struct scmi_cpu_sleep_mode_config
2628
*
@@ -33,6 +35,23 @@ struct scmi_cpu_sleep_mode_config {
3335
uint32_t sleep_mode;
3436
};
3537

38+
struct scmi_pd_lpm_settings {
39+
uint32_t domainId;
40+
uint32_t lpmSetting;
41+
uint32_t retMask;
42+
};
43+
44+
/**
45+
* @struct scmi_cpu_pd_lpm_config
46+
*
47+
* @brief Describes cpu power domain low power mode setting
48+
*/
49+
struct scmi_cpu_pd_lpm_config {
50+
uint32_t cpu_id;
51+
uint32_t num_cfg;
52+
struct scmi_pd_lpm_settings cfgs[SCMI_CPU_MAX_PDCONFIGS_T];
53+
};
54+
3655
/**
3756
* @brief CPU domain protocol command message IDs
3857
*/
@@ -64,4 +83,14 @@ enum scmi_cpu_domain_message {
6483
*/
6584
int scmi_cpu_sleep_mode_set(struct scmi_cpu_sleep_mode_config *cfg);
6685

86+
/**
87+
* @brief Send the SCMI_CPU_DOMAIN_MSG_CPU_PD_LPM_CONFIG_SET command and get its reply
88+
*
89+
* @param cfg pointer to structure containing configuration
90+
* to be set
91+
*
92+
* @retval 0 if successful
93+
* @retval negative errno if failure
94+
*/
95+
int scmi_cpu_pd_lpm_set(struct scmi_cpu_pd_lpm_config *cfg);
6796
#endif /* _INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_SCMI_CPU_H_ */

0 commit comments

Comments
 (0)