Skip to content

Commit ce258bb

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 ce258bb

File tree

2 files changed

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

2 files changed

+64
-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: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,24 @@ struct scmi_cpu_sleep_mode_config {
3333
uint32_t sleep_mode;
3434
};
3535

36+
struct scmi_pd_lpm_settings {
37+
uint32_t domainId;
38+
uint32_t lpmSetting;
39+
uint32_t retMask;
40+
};
41+
42+
/**
43+
* @struct scmi_cpu_pd_lpm_config
44+
*
45+
* @brief Describes cpu power domain low power mode setting, the SCMI_CPU_MAX_PDCONFIGS_T
46+
* is defined in soc level
47+
*/
48+
struct scmi_cpu_pd_lpm_config {
49+
uint32_t cpu_id;
50+
uint32_t num_cfg;
51+
struct scmi_pd_lpm_settings cfgs[SCMI_CPU_MAX_PDCONFIGS_T];
52+
};
53+
3654
/**
3755
* @brief CPU domain protocol command message IDs
3856
*/
@@ -64,4 +82,14 @@ enum scmi_cpu_domain_message {
6482
*/
6583
int scmi_cpu_sleep_mode_set(struct scmi_cpu_sleep_mode_config *cfg);
6684

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

0 commit comments

Comments
 (0)