blob: 5941b87f32aa7b83d904b78dbd123d983de432c2 [file] [log] [blame]
Dimitris Papastamosaeaf1f02018-04-03 14:58:17 +01001/*
Ambroise Vincenta88a35d2019-02-14 09:48:21 +00002 * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
Dimitris Papastamosaeaf1f02018-04-03 14:58:17 +01003 *
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;
Ambroise Vincenta88a35d2019-02-14 09:48:21 +000021 unsigned int token = 0;
22 int ret;
Dimitris Papastamosaeaf1f02018-04-03 14:58:17 +010023 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 */
52int scmi_ap_core_get_reset_addr(void *p, uint64_t *reset_addr, uint32_t *attr)
53{
54 mailbox_mem_t *mbx_mem;
Ambroise Vincenta88a35d2019-02-14 09:48:21 +000055 unsigned int token = 0;
56 int ret;
Dimitris Papastamosaeaf1f02018-04-03 14:58:17 +010057 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}