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 power domain power state.
16 int scmi_pwr_state_set(void *p
, uint32_t domain_id
,
17 uint32_t scmi_pwr_state
)
19 mailbox_mem_t
*mbx_mem
;
23 * Only asynchronous mode of `set power state` command is allowed on
24 * application processors.
26 uint32_t pwr_state_set_msg_flag
= SCMI_PWR_STATE_SET_FLAG_ASYNC
;
27 scmi_channel_t
*ch
= (scmi_channel_t
*)p
;
29 validate_scmi_channel(ch
);
33 mbx_mem
= (mailbox_mem_t
*)(ch
->info
->scmi_mbx_mem
);
34 mbx_mem
->msg_header
= SCMI_MSG_CREATE(SCMI_PWR_DMN_PROTO_ID
,
35 SCMI_PWR_STATE_SET_MSG
, token
);
36 mbx_mem
->len
= SCMI_PWR_STATE_SET_MSG_LEN
;
37 mbx_mem
->flags
= SCMI_FLAG_RESP_POLL
;
38 SCMI_PAYLOAD_ARG3(mbx_mem
->payload
, pwr_state_set_msg_flag
,
39 domain_id
, scmi_pwr_state
);
41 scmi_send_sync_command(ch
);
43 /* Get the return values */
44 SCMI_PAYLOAD_RET_VAL1(mbx_mem
->payload
, ret
);
45 assert(mbx_mem
->len
== SCMI_PWR_STATE_SET_RESP_LEN
);
46 assert(token
== SCMI_MSG_GET_TOKEN(mbx_mem
->msg_header
));
54 * API to get the SCMI power domain power state.
56 int scmi_pwr_state_get(void *p
, uint32_t domain_id
,
57 uint32_t *scmi_pwr_state
)
59 mailbox_mem_t
*mbx_mem
;
61 scmi_channel_t
*ch
= (scmi_channel_t
*)p
;
63 validate_scmi_channel(ch
);
67 mbx_mem
= (mailbox_mem_t
*)(ch
->info
->scmi_mbx_mem
);
68 mbx_mem
->msg_header
= SCMI_MSG_CREATE(SCMI_PWR_DMN_PROTO_ID
,
69 SCMI_PWR_STATE_GET_MSG
, token
);
70 mbx_mem
->len
= SCMI_PWR_STATE_GET_MSG_LEN
;
71 mbx_mem
->flags
= SCMI_FLAG_RESP_POLL
;
72 SCMI_PAYLOAD_ARG1(mbx_mem
->payload
, domain_id
);
74 scmi_send_sync_command(ch
);
76 /* Get the return values */
77 SCMI_PAYLOAD_RET_VAL2(mbx_mem
->payload
, ret
, *scmi_pwr_state
);
78 assert(mbx_mem
->len
== SCMI_PWR_STATE_GET_RESP_LEN
);
79 assert(token
== SCMI_MSG_GET_TOKEN(mbx_mem
->msg_header
));