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