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