2 * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
4 * SPDX-License-Identifier: BSD-3-Clause
7 #include <arch_helpers.h>
11 #include "scmi_private.h"
14 * API to set the SCMI system power state
16 int scmi_sys_pwr_state_set(void *p
, uint32_t flags
, uint32_t system_state
)
18 mailbox_mem_t
*mbx_mem
;
20 scmi_channel_t
*ch
= (scmi_channel_t
*)p
;
22 validate_scmi_channel(ch
);
26 mbx_mem
= (mailbox_mem_t
*)(ch
->info
->scmi_mbx_mem
);
27 mbx_mem
->msg_header
= SCMI_MSG_CREATE(SCMI_SYS_PWR_PROTO_ID
,
28 SCMI_SYS_PWR_STATE_SET_MSG
, token
);
29 mbx_mem
->len
= SCMI_SYS_PWR_STATE_SET_MSG_LEN
;
30 mbx_mem
->flags
= SCMI_FLAG_RESP_POLL
;
31 SCMI_PAYLOAD_ARG2(mbx_mem
->payload
, flags
, system_state
);
33 scmi_send_sync_command(ch
);
35 /* Get the return values */
36 SCMI_PAYLOAD_RET_VAL1(mbx_mem
->payload
, ret
);
37 assert(mbx_mem
->len
== SCMI_SYS_PWR_STATE_SET_RESP_LEN
);
38 assert(token
== SCMI_MSG_GET_TOKEN(mbx_mem
->msg_header
));
46 * API to get the SCMI system power state
48 int scmi_sys_pwr_state_get(void *p
, uint32_t *system_state
)
50 mailbox_mem_t
*mbx_mem
;
52 scmi_channel_t
*ch
= (scmi_channel_t
*)p
;
54 validate_scmi_channel(ch
);
58 mbx_mem
= (mailbox_mem_t
*)(ch
->info
->scmi_mbx_mem
);
59 mbx_mem
->msg_header
= SCMI_MSG_CREATE(SCMI_SYS_PWR_PROTO_ID
,
60 SCMI_SYS_PWR_STATE_GET_MSG
, token
);
61 mbx_mem
->len
= SCMI_SYS_PWR_STATE_GET_MSG_LEN
;
62 mbx_mem
->flags
= SCMI_FLAG_RESP_POLL
;
64 scmi_send_sync_command(ch
);
66 /* Get the return values */
67 SCMI_PAYLOAD_RET_VAL2(mbx_mem
->payload
, ret
, *system_state
);
68 assert(mbx_mem
->len
== SCMI_SYS_PWR_STATE_GET_RESP_LEN
);
69 assert(token
== SCMI_MSG_GET_TOKEN(mbx_mem
->msg_header
));