arm-trusted-firmware/drivers/st/scmi-msg/entry.c
Etienne Carriere 6cc2c1cbed drivers/scmi-msg: support for reset domain protocol
Adds SCMI reset domain protocol support in the SCMI message drivers
as defined in SCMI specification v2.0 [1]. Not all the messages
defined in the specification are supported.

scmi_msg_get_rd_handler() sanitizes the message_id value
against any speculative use of reset domain ID as a index since by
SCMI specification, IDs are indices.

This implementation is based on the OP-TEE project implementation [2]
itself based on the SCP-firmware implementation [3] of the SCMI
protocol server side.

Link: [1] http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/DEN0056A_System_Control_and_Management_Interface.pdf
Link: [2] 56a1f10ed9
Link: [3] https://github.com/ARM-software/SCP-firmware.git

Change-Id: If7cf13de40a815dedb40dcd5af8b6bb6725d9078
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
2020-06-17 11:07:11 +02:00

64 lines
1.5 KiB
C

// SPDX-License-Identifier: BSD-3-Clause
/*
* Copyright (c) 2015-2020, Arm Limited and Contributors. All rights reserved.
* Copyright (c) 2019-2020, Linaro Limited
*/
#include <assert.h>
#include <drivers/st/scmi-msg.h>
#include <drivers/st/scmi.h>
#include "common.h"
void scmi_status_response(struct scmi_msg *msg, int32_t status)
{
assert(msg->out && msg->out_size >= sizeof(int32_t));
memcpy(msg->out, &status, sizeof(int32_t));
msg->out_size_out = sizeof(int32_t);
}
void scmi_write_response(struct scmi_msg *msg, void *payload, size_t size)
{
/*
* Output payload shall be at least the size of the status
* Output buffer shall be at least be the size of the status
* Output paylaod shall fit in output buffer
*/
assert(payload && size >= sizeof(int32_t) && size <= msg->out_size &&
msg->out && msg->out_size >= sizeof(int32_t));
memcpy(msg->out, payload, size);
msg->out_size_out = size;
}
void scmi_process_message(struct scmi_msg *msg)
{
scmi_msg_handler_t handler = NULL;
switch (msg->protocol_id) {
case SCMI_PROTOCOL_ID_BASE:
handler = scmi_msg_get_base_handler(msg);
break;
case SCMI_PROTOCOL_ID_CLOCK:
handler = scmi_msg_get_clock_handler(msg);
break;
case SCMI_PROTOCOL_ID_RESET_DOMAIN:
handler = scmi_msg_get_rstd_handler(msg);
break;
default:
break;
}
if (handler) {
handler(msg);
return;
}
ERROR("Agent %u Protocol 0x%x Message 0x%x: not supported",
msg->agent_id, msg->protocol_id, msg->message_id);
scmi_status_response(msg, SCMI_NOT_SUPPORTED);
}