Skip to content

Commit 28b98c9

Browse files
yongxu-wang15kartben
authored andcommitted
drivers: firmware: scmi: add reset vector interface
Add scmi_cpu_reset_vector API for NXP SCMI CPU domain protocol. This API allows setting CPU reset vector addresses using the CPU_RESET_VECTOR_SET command. The vector address must point to the initial address of the vector table Supports 64-bit addresses and boot/start/resume vector flags. Signed-off-by: Yongxu Wang <yongxu.wang@nxp.com>
1 parent 620b7fe commit 28b98c9

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: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,35 @@ int scmi_cpu_set_irq_mask(struct scmi_cpu_irq_mask_config *cfg)
114114

115115
return scmi_status_to_errno(status);
116116
}
117+
118+
int scmi_cpu_reset_vector(struct scmi_cpu_vector_config *cfg)
119+
{
120+
struct scmi_protocol *proto = &SCMI_PROTOCOL_NAME(SCMI_PROTOCOL_CPU_DOMAIN);
121+
struct scmi_message msg, reply;
122+
int status, ret;
123+
124+
/* sanity checks */
125+
if (!proto || !cfg) {
126+
return -EINVAL;
127+
}
128+
129+
if (proto->id != SCMI_PROTOCOL_CPU_DOMAIN) {
130+
return -EINVAL;
131+
}
132+
133+
msg.hdr = SCMI_MESSAGE_HDR_MAKE(SCMI_CPU_DOMAIN_MSG_CPU_RESET_VECTOR_SET, SCMI_COMMAND,
134+
proto->id, 0x0);
135+
msg.len = sizeof(*cfg);
136+
msg.content = cfg;
137+
138+
reply.hdr = msg.hdr;
139+
reply.len = sizeof(status);
140+
reply.content = &status;
141+
142+
ret = scmi_send_message(proto, &msg, &reply, true);
143+
if (ret < 0) {
144+
return ret;
145+
}
146+
147+
return scmi_status_to_errno(status);
148+
}

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@
2525

2626
#define SCMI_CPU_IRQ_WAKE_NUM 22U
2727

28+
/** CPU vector flag: Boot address (cold boot/reset) */
29+
#define SCMI_CPU_VEC_FLAGS_BOOT BIT(29)
30+
31+
/** CPU vector flag: Start address (warm start) */
32+
#define SCMI_CPU_VEC_FLAGS_START BIT(30)
33+
34+
/** CPU vector flag: Resume address (exit from suspend) */
35+
#define SCMI_CPU_VEC_FLAGS_RESUME BIT(31)
36+
2837
/**
2938
* @struct scmi_cpu_sleep_mode_config
3039
*
@@ -66,6 +75,18 @@ struct scmi_cpu_irq_mask_config {
6675
uint32_t mask[SCMI_CPU_IRQ_WAKE_NUM];
6776
};
6877

78+
/**
79+
* @struct scmi_cpu_vector_config
80+
*
81+
* @brief Describes the parameters for the CPU_RESET_VECTOR_SET command
82+
*/
83+
struct scmi_cpu_vector_config {
84+
uint32_t cpu_id;
85+
uint32_t flags;
86+
uint32_t vector_low;
87+
uint32_t vector_high;
88+
};
89+
6990
/**
7091
* @brief CPU domain protocol command message IDs
7192
*/
@@ -117,4 +138,14 @@ int scmi_cpu_pd_lpm_set(struct scmi_cpu_pd_lpm_config *cfg);
117138
* @retval negative errno if failure
118139
*/
119140
int scmi_cpu_set_irq_mask(struct scmi_cpu_irq_mask_config *cfg);
141+
142+
/**
143+
* @brief Send the CPU_RESET_VECTOR_SET command and get its reply
144+
*
145+
* @param cfg pointer to structure containing configuration to be set
146+
*
147+
* @retval 0 if successful
148+
* @retval negative errno if failure
149+
*/
150+
int scmi_cpu_reset_vector(struct scmi_cpu_vector_config *cfg);
120151
#endif /* _INCLUDE_ZEPHYR_DRIVERS_FIRMWARE_SCMI_CPU_H_ */

0 commit comments

Comments
 (0)