Skip to content

Commit dfe2c26

Browse files
yongxu-wang15kartben
authored andcommitted
drivers: firmware: scmi: add cpu info get interface
Add scmi_cpu_info_get API to query CPU information via NXP SCMI CPU domain protocol. Retrieves run mode, sleep mode, and reset vector addresses for the specified CPU ID using CPU_INFO_GET command. Signed-off-by: Yongxu Wang <yongxu.wang@nxp.com>
1 parent 28b98c9 commit dfe2c26

File tree

2 files changed

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

2 files changed

+63
-0
lines changed

drivers/firmware/scmi/nxp/cpu.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010

1111
DT_SCMI_PROTOCOL_DEFINE_NODEV(DT_INST(0, nxp_scmi_cpu), NULL);
1212

13+
struct scmi_cpu_info_get_reply {
14+
int32_t status;
15+
struct scmi_cpu_info data;
16+
};
17+
1318
int scmi_cpu_sleep_mode_set(struct scmi_cpu_sleep_mode_config *cfg)
1419
{
1520
struct scmi_protocol *proto = &SCMI_PROTOCOL_NAME(SCMI_PROTOCOL_CPU_DOMAIN);
@@ -146,3 +151,38 @@ int scmi_cpu_reset_vector(struct scmi_cpu_vector_config *cfg)
146151

147152
return scmi_status_to_errno(status);
148153
}
154+
155+
int scmi_cpu_info_get(uint32_t cpu_id, struct scmi_cpu_info *cfg)
156+
{
157+
struct scmi_protocol *proto = &SCMI_PROTOCOL_NAME(SCMI_PROTOCOL_CPU_DOMAIN);
158+
struct scmi_message msg, reply;
159+
struct scmi_cpu_info_get_reply reply_buffer;
160+
int ret;
161+
162+
/* sanity checks */
163+
if (!proto || !cfg) {
164+
return -EINVAL;
165+
}
166+
167+
if (proto->id != SCMI_PROTOCOL_CPU_DOMAIN) {
168+
return -EINVAL;
169+
}
170+
171+
msg.hdr = SCMI_MESSAGE_HDR_MAKE(SCMI_CPU_DOMAIN_MSG_CPU_INFO_GET, SCMI_COMMAND,
172+
proto->id, 0x0);
173+
msg.len = sizeof(uint32_t);
174+
msg.content = &cpu_id;
175+
176+
reply.hdr = msg.hdr;
177+
reply.len = sizeof(reply_buffer);
178+
reply.content = &reply_buffer;
179+
180+
ret = scmi_send_message(proto, &msg, &reply, true);
181+
if (ret < 0) {
182+
return ret;
183+
}
184+
185+
*cfg = reply_buffer.data;
186+
187+
return scmi_status_to_errno(reply_buffer.status);
188+
}

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,18 @@ struct scmi_cpu_vector_config {
8787
uint32_t vector_high;
8888
};
8989

90+
/**
91+
* @struct scmi_cpu_info
92+
*
93+
* @brief Describes the parameters for the CPU_INFO_GET command
94+
*/
95+
struct scmi_cpu_info {
96+
uint32_t run_mode;
97+
uint32_t sleep_mode;
98+
uint32_t vector_low;
99+
uint32_t vector_high;
100+
};
101+
90102
/**
91103
* @brief CPU domain protocol command message IDs
92104
*/
@@ -148,4 +160,15 @@ int scmi_cpu_set_irq_mask(struct scmi_cpu_irq_mask_config *cfg);
148160
* @retval negative errno if failure
149161
*/
150162
int scmi_cpu_reset_vector(struct scmi_cpu_vector_config *cfg);
163+
164+
/**
165+
* @brief Send the CPU_INFO_GET command and get its reply
166+
*
167+
* @param cpu_id CPU ID to query (input)
168+
* @param cfg pointer to structure to receive CPU information (output)
169+
*
170+
* @retval 0 if successful
171+
* @retval negative errno if failure
172+
*/
173+
int scmi_cpu_info_get(uint32_t cpu_id, struct scmi_cpu_info *cfg);
151174
#endif /* _INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_SCMI_CPU_H_ */

0 commit comments

Comments
 (0)