• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <assert.h>
8 
9 #include <arch_helpers.h>
10 #include <common/debug.h>
11 #include <drivers/arm/css/scmi.h>
12 
13 #include "scmi_private.h"
14 
15 /*
16  * API to set the SCMI AP core reset address and attributes
17  */
scmi_ap_core_set_reset_addr(void * p,uint64_t reset_addr,uint32_t attr)18 int scmi_ap_core_set_reset_addr(void *p, uint64_t reset_addr, uint32_t attr)
19 {
20 	mailbox_mem_t *mbx_mem;
21 	unsigned int token = 0;
22 	int ret;
23 	scmi_channel_t *ch = (scmi_channel_t *)p;
24 
25 	validate_scmi_channel(ch);
26 
27 	scmi_get_channel(ch);
28 
29 	mbx_mem = (mailbox_mem_t *)(ch->info->scmi_mbx_mem);
30 	mbx_mem->msg_header = SCMI_MSG_CREATE(SCMI_AP_CORE_PROTO_ID,
31 			SCMI_AP_CORE_RESET_ADDR_SET_MSG, token);
32 	mbx_mem->len = SCMI_AP_CORE_RESET_ADDR_SET_MSG_LEN;
33 	mbx_mem->flags = SCMI_FLAG_RESP_POLL;
34 	SCMI_PAYLOAD_ARG3(mbx_mem->payload, reset_addr & 0xffffffff,
35 		reset_addr >> 32, attr);
36 
37 	scmi_send_sync_command(ch);
38 
39 	/* Get the return values */
40 	SCMI_PAYLOAD_RET_VAL1(mbx_mem->payload, ret);
41 	assert(mbx_mem->len == SCMI_AP_CORE_RESET_ADDR_SET_RESP_LEN);
42 	assert(token == SCMI_MSG_GET_TOKEN(mbx_mem->msg_header));
43 
44 	scmi_put_channel(ch);
45 
46 	return ret;
47 }
48 
49 /*
50  * API to get the SCMI AP core reset address and attributes
51  */
scmi_ap_core_get_reset_addr(void * p,uint64_t * reset_addr,uint32_t * attr)52 int scmi_ap_core_get_reset_addr(void *p, uint64_t *reset_addr, uint32_t *attr)
53 {
54 	mailbox_mem_t *mbx_mem;
55 	unsigned int token = 0;
56 	int ret;
57 	scmi_channel_t *ch = (scmi_channel_t *)p;
58 	uint32_t lo_addr, hi_addr;
59 
60 	validate_scmi_channel(ch);
61 
62 	scmi_get_channel(ch);
63 
64 	mbx_mem = (mailbox_mem_t *)(ch->info->scmi_mbx_mem);
65 	mbx_mem->msg_header = SCMI_MSG_CREATE(SCMI_AP_CORE_PROTO_ID,
66 			SCMI_AP_CORE_RESET_ADDR_GET_MSG, token);
67 	mbx_mem->len = SCMI_AP_CORE_RESET_ADDR_GET_MSG_LEN;
68 	mbx_mem->flags = SCMI_FLAG_RESP_POLL;
69 
70 	scmi_send_sync_command(ch);
71 
72 	/* Get the return values */
73 	SCMI_PAYLOAD_RET_VAL4(mbx_mem->payload, ret, lo_addr, hi_addr, *attr);
74 	*reset_addr = lo_addr | (uint64_t)hi_addr << 32;
75 	assert(mbx_mem->len == SCMI_AP_CORE_RESET_ADDR_GET_RESP_LEN);
76 	assert(token == SCMI_MSG_GET_TOKEN(mbx_mem->msg_header));
77 
78 	scmi_put_channel(ch);
79 
80 	return ret;
81 }
82