From 58e725662d9c9f8a2ce8311ebb04306328633707 Mon Sep 17 00:00:00 2001 From: Pranav Madhu Date: Fri, 27 Dec 2024 17:33:37 +0530 Subject: [PATCH 01/22] scmi: add SCMI notification support In addition to messages, SCMI specification 3.x includes support for SCMI notifications as well. Enables the support for SCMI notifications, so that the SCMI module can forward the notification to the respective protcol's notification handler upon their arrival. Change-Id: I045df2bd8836c5cfcfe3a67e7e75c2b0cf7b9110 Signed-off-by: Pranav Madhu --- module/scmi/src/mod_scmi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/module/scmi/src/mod_scmi.c b/module/scmi/src/mod_scmi.c index dfaf441fb..1786accb8 100644 --- a/module/scmi/src/mod_scmi.c +++ b/module/scmi/src/mod_scmi.c @@ -1,6 +1,6 @@ /* * Arm SCP/MCP Software - * Copyright (c) 2015-2024, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2015-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause * @@ -956,6 +956,11 @@ static int scmi_bind(fwk_id_t id, unsigned int round) scmi_ctx.scmi_protocol_id_to_idx[scmi_protocol_id] = (uint8_t)(protocol_idx + PROTOCOL_TABLE_RESERVED_ENTRIES_COUNT); protocol->message_handler = protocol_api->message_handler; +#ifdef BUILD_HAS_SCMI_NOTIFICATIONS + if (protocol_api->notification_handler != NULL) { + protocol->notification_handler = protocol_api->notification_handler; + } +#endif } for (protocol_idx = 0; protocol_idx < scmi_ctx.protocol_requester_count; -- GitLab From 751044e1af3d676c1dd97cd01142bdc0ba3bb02d Mon Sep 17 00:00:00 2001 From: Pranav Madhu Date: Fri, 27 Dec 2024 19:04:12 +0530 Subject: [PATCH 02/22] nrd: add a minimal scmi_system_power module The scmi_system_power module is tightly coupled with power domains. This dependency makes the module unsuitable for subsystems like MCP, which lack access to power domains. The support for SCMI system power notifications is required at the MCP to handle system-wide power-down events. Add a new module which has the support only to handle SCMI system power notification. Change-Id: I6652ac185c926e1b3bd0b1a29ad6353b420d3c9c Signed-off-by: Pranav Madhu --- .../module/scmi_sys_power/CMakeLists.txt | 17 + .../module/scmi_sys_power/Module.cmake | 9 + .../include/internal/scmi_sys_power.h | 45 +++ .../include/mod_scmi_sys_power.h | 37 ++ .../scmi_sys_power/src/mod_scmi_sys_power.c | 359 ++++++++++++++++++ 5 files changed, 467 insertions(+) create mode 100644 product/neoverse-rd/module/scmi_sys_power/CMakeLists.txt create mode 100644 product/neoverse-rd/module/scmi_sys_power/Module.cmake create mode 100644 product/neoverse-rd/module/scmi_sys_power/include/internal/scmi_sys_power.h create mode 100644 product/neoverse-rd/module/scmi_sys_power/include/mod_scmi_sys_power.h create mode 100644 product/neoverse-rd/module/scmi_sys_power/src/mod_scmi_sys_power.c diff --git a/product/neoverse-rd/module/scmi_sys_power/CMakeLists.txt b/product/neoverse-rd/module/scmi_sys_power/CMakeLists.txt new file mode 100644 index 000000000..f834c8118 --- /dev/null +++ b/product/neoverse-rd/module/scmi_sys_power/CMakeLists.txt @@ -0,0 +1,17 @@ +# +# Arm SCP/MCP Software +# Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +add_library(${SCP_MODULE_TARGET} SCP_MODULE) + +target_include_directories(${SCP_MODULE_TARGET} + PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") + +target_sources( + ${SCP_MODULE_TARGET} + PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/mod_scmi_sys_power.c") + +target_link_libraries(${SCP_MODULE_TARGET} PRIVATE module-scmi) diff --git a/product/neoverse-rd/module/scmi_sys_power/Module.cmake b/product/neoverse-rd/module/scmi_sys_power/Module.cmake new file mode 100644 index 000000000..b3f3a6a95 --- /dev/null +++ b/product/neoverse-rd/module/scmi_sys_power/Module.cmake @@ -0,0 +1,9 @@ +# +# Arm SCP/MCP Software +# Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +set(SCP_MODULE "scmi-sys-power") +set(SCP_MODULE_TARGET "module-scmi-sys-power") diff --git a/product/neoverse-rd/module/scmi_sys_power/include/internal/scmi_sys_power.h b/product/neoverse-rd/module/scmi_sys_power/include/internal/scmi_sys_power.h new file mode 100644 index 000000000..7b4fa3cc9 --- /dev/null +++ b/product/neoverse-rd/module/scmi_sys_power/include/internal/scmi_sys_power.h @@ -0,0 +1,45 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef SCMI_SYSPWR_H +#define SCMI_SYSPWR_H + +#include + +#define SCMI_PROTOCOL_VERSION_SYS_POWER UINT32_C(0x10000) + +/* Notifications supported by SCMI system power protocol as per SCMI 3.2 spec */ +enum scmi_sys_power_notification_id { + SCMI_SYS_POWER_STATE_SET_NOTIFY = 0x000, + SCMI_SYS_POWER_NOTIFICATION_COUNT, +}; + +/* + * SYSTEM_POWER_STATE_NOTIFY + */ + +#define STATE_NOTIFY_FLAGS_MASK 0x1U + +struct scmi_sys_power_state_notify_a2p { + uint32_t flags; +}; + +struct scmi_sys_power_state_notify_p2a { + int32_t status; +}; + +/* + * SYSTEM_POWER_STATE_NOTIFIER + */ + +struct scmi_sys_power_state_notifier { + uint32_t agent_id; + uint32_t flags; + uint32_t system_state; +}; + +#endif /* SCMI_SYSPWR_H */ diff --git a/product/neoverse-rd/module/scmi_sys_power/include/mod_scmi_sys_power.h b/product/neoverse-rd/module/scmi_sys_power/include/mod_scmi_sys_power.h new file mode 100644 index 000000000..3acd47487 --- /dev/null +++ b/product/neoverse-rd/module/scmi_sys_power/include/mod_scmi_sys_power.h @@ -0,0 +1,37 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef MOD_SCMI_SYS_POWER_H +#define MOD_SCMI_SYS_POWER_H + +#include +#include + +#ifdef BUILD_HAS_SCMI_NOTIFICATIONS +# ifdef BUILD_HAS_NOTIFICATION +/*! + * \brief Indices of the notification sent by the module. + */ +enum mod_scmi_sys_power_notification_idx { + /*! Power state transition */ + MOD_SCMI_SYSTEM_POWER_NOTIFICATION_IDX_SYSTEM_POWER_DOWN, + + /*! Number of notifications defined */ + MOD_SCMI_SYSTEM_POWER_NOTIFICATION_COUNT +}; +# endif +#else +/*! + * \brief Indices of the notification sent by the module. + */ +enum mod_scmi_sys_power_notification_idx { + /*! Number of notifications defined */ + MOD_SCMI_SYSTEM_POWER_NOTIFICATION_COUNT = 0, +}; +#endif + +#endif /* MOD_SCMI_SYS_POWER_H */ diff --git a/product/neoverse-rd/module/scmi_sys_power/src/mod_scmi_sys_power.c b/product/neoverse-rd/module/scmi_sys_power/src/mod_scmi_sys_power.c new file mode 100644 index 000000000..0ca014be0 --- /dev/null +++ b/product/neoverse-rd/module/scmi_sys_power/src/mod_scmi_sys_power.c @@ -0,0 +1,359 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define INVALID_AGENT_ID UINT32_MAX + +struct mod_scmi_sys_power_ctx { + const struct mod_scmi_from_protocol_api *scmi_api; +}; + +static int scmi_sys_power_version_handler( + fwk_id_t service_id, + const uint32_t *payload); + +static int scmi_sys_power_attributes_handler( + fwk_id_t service_id, + const uint32_t *payload); + +static int scmi_sys_power_msg_attributes_handler( + fwk_id_t service_id, + const uint32_t *payload); + +#ifdef BUILD_HAS_SCMI_NOTIFICATIONS +static int scmi_sys_power_state_notifier_handler( + fwk_id_t service_id, + const uint32_t *payload); + +/* Notification for system power down */ +static const fwk_id_t mod_scmi_sys_power_notification_system_power_down = + FWK_ID_NOTIFICATION_INIT( + FWK_MODULE_IDX_SCMI_SYS_POWER, + MOD_SCMI_SYSTEM_POWER_NOTIFICATION_IDX_SYSTEM_POWER_DOWN); +#endif + +/* + * Internal variables + */ +static struct mod_scmi_sys_power_ctx scmi_sys_power_ctx; + +/* + * Add support for the three basic SCMI message: + * 1. protocol version + * 2. protocol attribute + * 3. protocol message attributes + * These three messages are common for all SCMI protocols. + */ +static int (*const message_handler_table[MOD_SCMI_SYS_POWER_COMMAND_COUNT])( + fwk_id_t, + const uint32_t *) = { + [MOD_SCMI_PROTOCOL_VERSION] = scmi_sys_power_version_handler, + [MOD_SCMI_PROTOCOL_ATTRIBUTES] = scmi_sys_power_attributes_handler, + [MOD_SCMI_PROTOCOL_MESSAGE_ATTRIBUTES] = + scmi_sys_power_msg_attributes_handler, +}; + +/* + * Input payload size of the basic SCMI messages as specified in SCMI v3.2 + */ +static const unsigned int + payload_size_table[MOD_SCMI_SYS_POWER_COMMAND_COUNT] = { + /* No input payload */ + [MOD_SCMI_PROTOCOL_VERSION] = 0, + /* No input payload */ + [MOD_SCMI_PROTOCOL_ATTRIBUTES] = 0, + /* payload specified in struct scmi_protocol_message_attributes_a2p */ + [MOD_SCMI_PROTOCOL_MESSAGE_ATTRIBUTES] = + (unsigned int)sizeof(struct scmi_protocol_message_attributes_a2p), + }; + +#ifdef BUILD_HAS_SCMI_NOTIFICATIONS +/* + * Support for SCMI system power protocol notification + */ +static int ( + *const notification_handler_table[SCMI_SYS_POWER_NOTIFICATION_COUNT])( + fwk_id_t, + const uint32_t *) = { + [SCMI_SYS_POWER_STATE_SET_NOTIFY] = scmi_sys_power_state_notifier_handler, +}; + +static const unsigned int + payload_size_table_notification[SCMI_SYS_POWER_NOTIFICATION_COUNT] = { + [SCMI_SYS_POWER_STATE_SET_NOTIFY] = + sizeof(struct scmi_sys_power_state_notifier), + }; +#endif + +/* + * PROTOCOL_VERSION + */ +static int scmi_sys_power_version_handler( + fwk_id_t service_id, + const uint32_t *payload) +{ + struct scmi_protocol_version_p2a return_values = { + .status = (int32_t)SCMI_SUCCESS, + .version = SCMI_PROTOCOL_VERSION_SYS_POWER, + }; + + return scmi_sys_power_ctx.scmi_api->respond( + service_id, &return_values, sizeof(return_values)); +} + +/* + * PROTOCOL_ATTRIBUTES + */ +static int scmi_sys_power_attributes_handler( + fwk_id_t service_id, + const uint32_t *payload) +{ + struct scmi_protocol_attributes_p2a return_values = { + .status = (int32_t)SCMI_SUCCESS, + .attributes = 0, + }; + + return scmi_sys_power_ctx.scmi_api->respond( + service_id, &return_values, sizeof(return_values)); +} + +/* + * PROTOCOL_MESSAGE_ATTRIBUTES + */ +static int scmi_sys_power_msg_attributes_handler( + fwk_id_t service_id, + const uint32_t *payload) +{ + struct scmi_protocol_message_attributes_p2a return_values; + + /* + * The module currently support only SCMI notification, not SCMI message, + * hence return SCMI_NOT_SUPPORTED for all message attribute query. + */ + return_values.status = (int32_t)SCMI_NOT_SUPPORTED; + + return scmi_sys_power_ctx.scmi_api->respond( + service_id, &return_values, sizeof(return_values.status)); +} + +/* + * SCMI module -> SCMI system power module interface + */ +static int scmi_sys_power_get_scmi_protocol_id( + fwk_id_t protocol_id, + uint8_t *scmi_protocol_id) +{ + *scmi_protocol_id = (uint8_t)MOD_SCMI_PROTOCOL_ID_SYS_POWER; + + return FWK_SUCCESS; +} + +/* + * Message handler for generic SCMI messages + */ +static int scmi_sys_power_message_handler( + fwk_id_t protocol_id, + fwk_id_t service_id, + const uint32_t *payload, + size_t payload_size, + unsigned int message_id) +{ + int32_t return_value; + + static_assert( + FWK_ARRAY_SIZE(message_handler_table) == + FWK_ARRAY_SIZE(payload_size_table), + "[SCMI] System power protocol table sizes not consistent"); + + fwk_assert(payload != NULL); + + if (message_id >= FWK_ARRAY_SIZE(message_handler_table)) { + return_value = (int32_t)SCMI_NOT_FOUND; + goto error; + } + + if (payload_size != payload_size_table[message_id]) { + /* Incorrect payload size or message is not supported */ + return_value = (int32_t)SCMI_PROTOCOL_ERROR; + goto error; + } + + return message_handler_table[message_id](service_id, payload); + +error: + return scmi_sys_power_ctx.scmi_api->respond( + service_id, &return_value, sizeof(return_value)); +} + +#ifdef BUILD_HAS_SCMI_NOTIFICATIONS +/* + * SYSTEM_POWER_STATE_NOTIFIER + */ +static int scmi_sys_power_state_notifier_handler( + fwk_id_t service_id, + const uint32_t *payload) +{ + int status = FWK_SUCCESS; + int32_t return_value; + const struct scmi_sys_power_state_notifier *parameters; +# ifdef BUILD_HAS_NOTIFICATION + unsigned int count; + struct fwk_event notification_event = { + .id = mod_scmi_sys_power_notification_system_power_down, + .response_requested = false, + .source_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_SCMI_SYS_POWER), + }; +# endif + + parameters = (const struct scmi_sys_power_state_notifier *)payload; + + if (parameters->flags & (uint32_t)(~STATE_NOTIFY_FLAGS_MASK)) { + return_value = (int32_t)SCMI_INVALID_PARAMETERS; + goto exit; + } + +# ifdef BUILD_HAS_NOTIFICATION + fwk_str_memcpy( + notification_event.params, + ¶meters->system_state, + sizeof(parameters->system_state)); + status = fwk_notification_notify(¬ification_event, &count); + if (status != FWK_SUCCESS) { + FWK_LOG_ERR( + "[SCMI_SYSTEM_POWER] failed to notify power state transition: %s", + fwk_status_str(status)); + return SCMI_DENIED; + } +# endif + +exit: + status = scmi_sys_power_ctx.scmi_api->respond( + service_id, &return_value, sizeof(return_value)); + + return status; +} + +/* + * Handler for SCMI system power notifications + */ +static int scmi_sys_power_notification_handler( + fwk_id_t protocol_id, + fwk_id_t service_id, + const uint32_t *payload, + size_t payload_size, + unsigned int notification_id) +{ + int32_t return_value; + + static_assert( + FWK_ARRAY_SIZE(notification_handler_table) == + FWK_ARRAY_SIZE(payload_size_table_notification), + "[SCMI] System power protocol notification table sizes not consistent"); + + fwk_assert(payload != NULL); + + if (notification_id >= FWK_ARRAY_SIZE(notification_handler_table)) { + return_value = (int32_t)SCMI_NOT_FOUND; + goto error; + } + + if (payload_size != payload_size_table_notification[notification_id]) { + /* Incorrect payload size or message is not supported */ + return_value = (int32_t)SCMI_PROTOCOL_ERROR; + goto error; + } + + return notification_handler_table[notification_id](service_id, payload); + +error: + return scmi_sys_power_ctx.scmi_api->respond( + service_id, &return_value, sizeof(return_value)); +} +#endif + +static struct mod_scmi_to_protocol_api scmi_sys_power_mod_scmi_to_protocol = { + .get_scmi_protocol_id = scmi_sys_power_get_scmi_protocol_id, + .message_handler = scmi_sys_power_message_handler, +#ifdef BUILD_HAS_SCMI_NOTIFICATIONS + .notification_handler = scmi_sys_power_notification_handler, +#endif +}; + +/* + * Framework handlers + */ +static int scmi_sys_power_init( + fwk_id_t module_id, + unsigned int element_count, + const void *data) +{ + return FWK_SUCCESS; +} + +static int scmi_sys_power_bind(fwk_id_t id, unsigned int round) +{ + int status; + + if (round != 0) { + return FWK_SUCCESS; + } + + /* Bind to SCMI module */ + status = fwk_module_bind( + FWK_ID_MODULE(FWK_MODULE_IDX_SCMI), + FWK_ID_API(FWK_MODULE_IDX_SCMI, MOD_SCMI_API_IDX_PROTOCOL), + &scmi_sys_power_ctx.scmi_api); + if (status != FWK_SUCCESS) { + return status; + } + + return FWK_SUCCESS; +} + +static int scmi_sys_power_process_bind_request( + fwk_id_t source_id, + fwk_id_t _target_id, + fwk_id_t api_id, + const void **api) +{ + if (!fwk_id_is_equal(source_id, FWK_ID_MODULE(FWK_MODULE_IDX_SCMI))) { + return FWK_E_ACCESS; + } + + *api = &scmi_sys_power_mod_scmi_to_protocol; + + return FWK_SUCCESS; +} + +const struct fwk_module module_scmi_sys_power = { + .api_count = 1, + .notification_count = MOD_SCMI_SYSTEM_POWER_NOTIFICATION_COUNT, + .type = FWK_MODULE_TYPE_PROTOCOL, + .init = scmi_sys_power_init, + .bind = scmi_sys_power_bind, + .process_bind_request = scmi_sys_power_process_bind_request, +}; + +const struct fwk_module_config config_scmi_sys_power = { 0 }; -- GitLab From 7a70cf4b84d602a1ea8aaea4c23baf0565e3c54d Mon Sep 17 00:00:00 2001 From: Pranav Madhu Date: Fri, 22 Mar 2024 17:49:35 +0530 Subject: [PATCH 03/22] nrd/rdv3: correct MCP timer interrupt number Correct the interrupt number for the generic physical timer present in MCP. Change-Id: I9cc1b965aa211aea38ff09543e2844f9a637179f Signed-off-by: Pranav Madhu --- product/neoverse-rd/rdv3/mcp_ramfw/include/fmw_cmsis.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/product/neoverse-rd/rdv3/mcp_ramfw/include/fmw_cmsis.h b/product/neoverse-rd/rdv3/mcp_ramfw/include/fmw_cmsis.h index fa34d14d2..ba78a5f71 100644 --- a/product/neoverse-rd/rdv3/mcp_ramfw/include/fmw_cmsis.h +++ b/product/neoverse-rd/rdv3/mcp_ramfw/include/fmw_cmsis.h @@ -1,6 +1,6 @@ /* * Arm SCP/MCP Software - * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -35,7 +35,7 @@ typedef enum IRQn { PendSV_IRQn = -2, SysTick_IRQn = -1, - REFCLK_GTIMER_IRQ = 31, /* MCP REFCLK Physical Timer interrupt */ + REFCLK_GTIMER_IRQ = 34, /* MCP REFCLK Physical Timer interrupt */ IRQn_MAX = INT16_MAX, } IRQn_Type; -- GitLab From 04943031426897261a40a0a6e989546b06b799bb Mon Sep 17 00:00:00 2001 From: Pranav Madhu Date: Mon, 18 Mar 2024 18:08:48 +0530 Subject: [PATCH 04/22] nrd/rdv3: define RD-V3 platform variants Add definitions to identity the various RD-V3 platform variants. These definitions will be used to enable or disable platform capabilities for these variants. Change-Id: I658eceac899265f3a089d709a30f903f170b006b Signed-off-by: Pranav Madhu --- .../rdv3/include/platform_variant.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 product/neoverse-rd/rdv3/include/platform_variant.h diff --git a/product/neoverse-rd/rdv3/include/platform_variant.h b/product/neoverse-rd/rdv3/include/platform_variant.h new file mode 100644 index 000000000..582005524 --- /dev/null +++ b/product/neoverse-rd/rdv3/include/platform_variant.h @@ -0,0 +1,18 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Description: + * RD-V3 platform variants. + */ + +#ifndef PLATFORM_VARIANT_H +#define PLATFORM_VARIANT_H + +#define RD_V3 0 +#define RD_V3_CFG1 1 +#define RD_V3_CFG2 2 + +#endif -- GitLab From 443f66e44dbe43082826b30642a67711e1cb0e0e Mon Sep 17 00:00:00 2001 From: Pranav Madhu Date: Wed, 28 Feb 2024 16:15:30 +0530 Subject: [PATCH 05/22] nrd/rdv3: correct RSM SRAM macro definition The RSM SRAM is a shared memory used by SCP, MCP, and RSS. In SCP platform, it is mapped to Address Translation Window 0. This patch renames SYSTEM_CONTROL_SRAM to SHARED_SRAM_RSM. This patch also introduces a new file, rsm_fw_mmap.h, to store memory information and carveouts for RSM SRAM. Change-Id: I2e70c464d96e1944a82385de1f3e16d43d8a3a51 Signed-off-by: Pranav Madhu --- product/neoverse-rd/rdv3/include/css_common.h | 6 +++++- product/neoverse-rd/rdv3/scp_ramfw/config_atu.c | 6 +++--- .../rdv3/scp_ramfw/include/scp_css_mmap.h | 16 ++++++++-------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/product/neoverse-rd/rdv3/include/css_common.h b/product/neoverse-rd/rdv3/include/css_common.h index 7cb0394da..7553a980b 100644 --- a/product/neoverse-rd/rdv3/include/css_common.h +++ b/product/neoverse-rd/rdv3/include/css_common.h @@ -1,6 +1,6 @@ /* * Arm SCP/MCP Software - * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause * @@ -22,4 +22,8 @@ */ #define SYSCNT_INCR 8 +/* RSM SRAM physical address and size at the AP memory map */ +#define RSM_SHARED_SRAM_BASE UINT32_C(0x2F000000) +#define RSM_SHARED_SRAM_SIZE (4 * FWK_MIB) + #endif /* CSS_COMMON_H */ diff --git a/product/neoverse-rd/rdv3/scp_ramfw/config_atu.c b/product/neoverse-rd/rdv3/scp_ramfw/config_atu.c index 4be17088d..00cfd45b9 100644 --- a/product/neoverse-rd/rdv3/scp_ramfw/config_atu.c +++ b/product/neoverse-rd/rdv3/scp_ramfw/config_atu.c @@ -74,9 +74,9 @@ static struct atu_region_map atu_regions[ATU_REGION_IDX_COUNT] = { }, [ATU_REGION_IDX_RSM_SRAM] = { .region_owner_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_SCP_PLATFORM), - .log_addr_base = SCP_ATW0_SYSTEM_CONTROL_SRAM_BASE, - .phy_addr_base = 0x2F000000, - .region_size = SCP_ATW0_SYSTEM_CONTROL_SRAM_SIZE, + .log_addr_base = SCP_ATW0_SHARED_SRAM_RSM_BASE, + .phy_addr_base = RSM_SHARED_SRAM_BASE, + .region_size = RSM_SHARED_SRAM_SIZE, .attributes = ATU_ENCODE_ATTRIBUTES_SECURE_PAS, }, }; diff --git a/product/neoverse-rd/rdv3/scp_ramfw/include/scp_css_mmap.h b/product/neoverse-rd/rdv3/scp_ramfw/include/scp_css_mmap.h index eb0c93691..2052d06aa 100644 --- a/product/neoverse-rd/rdv3/scp_ramfw/include/scp_css_mmap.h +++ b/product/neoverse-rd/rdv3/scp_ramfw/include/scp_css_mmap.h @@ -1,6 +1,6 @@ /* * Arm SCP/MCP Software - * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause * @@ -12,6 +12,8 @@ #ifndef SCP_CSS_MMAP_H #define SCP_CSS_MMAP_H +#include "css_common.h" + /* Base address and size of SCP's ITCM */ #define SCP_ITC_RAM_BASE (0x00000000) #define SCP_ITC_RAM_SIZE (256 * 1024) @@ -65,7 +67,6 @@ #define SCP_ATW0_LCP_AND_CLUSTER_UTILITY_SIZE (256 * FWK_MIB) #define SCP_ATW0_AP_PERIPHERAL_SRAM_SIZE (128 * FWK_MIB) #define SCP_ATW0_AP_PERIPHERAL_GPC_SMMU_SIZE (1 * FWK_MIB) -#define SCP_ATW0_SYSTEM_CONTROL_SRAM_SIZE (4 * FWK_MIB) #define SCP_ATW0_ATU_MMIO_SIZE (1 * FWK_MIB) #define SCP_ATW0_LCP_AND_CLUSTER_UTILITY_BASE \ @@ -75,11 +76,11 @@ SCP_ATW0_LCP_AND_CLUSTER_UTILITY_SIZE) #define SCP_ATW0_AP_PERIPHERAL_GPC_SMMU_BASE \ (SCP_ATW0_AP_PERIPHERAL_SRAM_BASE + SCP_ATW0_AP_PERIPHERAL_SRAM_SIZE) -#define SCP_ATW0_SYSTEM_CONTROL_SRAM_BASE \ +#define SCP_ATW0_SHARED_SRAM_RSM_BASE \ (SCP_ATW0_AP_PERIPHERAL_GPC_SMMU_BASE + \ SCP_ATW0_AP_PERIPHERAL_GPC_SMMU_SIZE) #define SCP_ATW0_ATU_MMIO_BASE \ - (SCP_ATW0_SYSTEM_CONTROL_SRAM_BASE + SCP_ATW0_SYSTEM_CONTROL_SRAM_SIZE) + (SCP_ATW0_SHARED_SRAM_RSM_BASE + RSM_SHARED_SRAM_SIZE) /* * Offsets within SCP's Address Translation Window1 @@ -162,11 +163,10 @@ (SCP_LCP_CONTROL(n) + SCP_LCP_CONTROL_CPU_WAIT_OFFSET) /* - * System Control SRAM (shared between RSS, MCP, SCP and AP) is mapped by ATU in - * the SCP address translation window 0 at the address 0x7800_0000. + * Shared RSM SRAM (shared between RSS, MCP, SCP) is mapped by ATU in + * the SCP address translation window 0. */ -#define SCP_SYSTEM_CONTROL_SRAM_BASE \ - (SCP_ADDRESS_TRANSLATION_WINDOW0_BASE + SCP_ATW0_SYSTEM_CONTROL_SRAM_OFFSET) +#define SCP_SHARED_SRAM_RSM_BASE (SCP_ATW0_SHARED_SRAM_RSM_BASE) /* CMN config space is mapped in the SCP address translation window 1 */ #define SCP_CMN_BASE SCP_ATW1_CMN_BASE -- GitLab From d3cf83ca56f9efe81f299485d9bd1fc76e33f606 Mon Sep 17 00:00:00 2001 From: Pranav Madhu Date: Thu, 2 Jan 2025 11:32:30 +0530 Subject: [PATCH 06/22] nrd/rdv3: add SCP-MCP MHU outband channel for powerdown Add bi-directional MHU outband channel between SCP and MCP. During a system-wide power-down, the SCP notifies the MCP through an SCMI notification. To receive this notification, the MCP must first subscribe to this notification by sending an SCMI request to the SCP, requesting system power-down notifications. The MCP uses MHU outband communication to transmit this request, with the SCP handling it via its receiver transport channel. Upon a system power-down event, the SCP sends the SCMI notification through its sender transport channel. Change-Id: Ibf840b7e28cf557993d455a8667cd0f323073c33 Signed-off-by: Pranav Madhu --- .../neoverse-rd/rdv3/include/rsm_fw_mmap.h | 39 ++++++++++++++ .../neoverse-rd/rdv3/scp_ramfw/config_mhu3.c | 22 +++++++- .../rdv3/scp_ramfw/config_transport.c | 51 ++++++++++++++++++- .../rdv3/scp_ramfw/include/fmw_cmsis.h | 4 +- .../rdv3/scp_ramfw/include/scp_cfgd_mhu3.h | 3 +- .../scp_ramfw/include/scp_cfgd_transport.h | 4 +- .../rdv3/scp_ramfw/include/scp_css_mmap.h | 2 + .../rdv3/scp_ramfw/include/scp_fw_mmap.h | 13 ++++- 8 files changed, 132 insertions(+), 6 deletions(-) create mode 100644 product/neoverse-rd/rdv3/include/rsm_fw_mmap.h diff --git a/product/neoverse-rd/rdv3/include/rsm_fw_mmap.h b/product/neoverse-rd/rdv3/include/rsm_fw_mmap.h new file mode 100644 index 000000000..a0aa38e7c --- /dev/null +++ b/product/neoverse-rd/rdv3/include/rsm_fw_mmap.h @@ -0,0 +1,39 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Description: + * Common RSM SRAM memory region mapping, shared across SCP, MCP and RSE. + */ + +#ifndef RSM_FW_MMAP_H +#define RSM_FW_MMAP_H + +#include + +// clang-format off + +/* + * [SCP_ATW0_SHARED_SRAM_RSM_BASE] + * +---------------------------------------+ SCP_MCP_SCMI_MSG_PAYLOAD_BASE + * | | + * | SCP-MCP SCMI payload | + * | (SCP_MCP_SCMI_MSG_PAYLOAD_SIZE bytes) | + * +---------------------------------------+ + * | | + * | | + * | Unused | + * | | + * | | + * +---------------------------------------+ [SCP_ATW0_SHARED_SRAM_RSM_BASE + + * RSM_SHARED_SRAM_SIZE] + */ + +#define SCP_MCP_SCMI_MSG_PAYLOAD_OFFSET UINT32_C(0x0) +#define SCP_MCP_SCMI_MSG_PAYLOAD_SIZE (128) + +// clang-format on + +#endif /* RSM_FW_MMAP_H */ diff --git a/product/neoverse-rd/rdv3/scp_ramfw/config_mhu3.c b/product/neoverse-rd/rdv3/scp_ramfw/config_mhu3.c index f6eebdc7a..3c99c7ac0 100644 --- a/product/neoverse-rd/rdv3/scp_ramfw/config_mhu3.c +++ b/product/neoverse-rd/rdv3/scp_ramfw/config_mhu3.c @@ -1,6 +1,6 @@ /* * Arm SCP/MCP Software - * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause * @@ -28,6 +28,9 @@ /* SCP<-->RSS Secure MHUv3 Doorbell channel count */ #define SCP2RSS_S_DBCH_COUNT 2 +/* SCP<-->MCP Secure MHUv3 Doorbell channel count */ +#define SCP2MCP_S_DBCH_COUNT 1 + /* AP<-->SCP Secure MHUv3 doorbell channel configuration */ struct mod_mhu3_channel_config scp2ap_s_dbch_config[SCP2AP_S_DBCH_COUNT] = { /* PBX CH 0, FLAG 0, MBX CH 0, FLAG 0 */ @@ -42,6 +45,13 @@ struct mod_mhu3_channel_config scp2rss_s_dbch_config[SCP2RSS_S_DBCH_COUNT] = { MOD_MHU3_INIT_DBCH(1, 0, 1, 0), }; +/* MCP<-->SCP Secure MHUv3 doorbell channel configuration */ +static struct mod_mhu3_channel_config + scp2mcp_s_dbch_config[SCP2MCP_S_DBCH_COUNT] = { + /* PBX CH 0, FLAG 0, MBX CH 0, FLAG 0 */ + MOD_MHU3_INIT_DBCH(0, 0, 0, 0), + }; + /* Module element table */ static const struct fwk_element mhu_element_table[MOD_MHU3_ELEMENT_COUNT] = { [SCP_CFGD_MOD_MHU3_EIDX_SCP_AP_S_CLUS0] = { @@ -64,6 +74,16 @@ static const struct fwk_element mhu_element_table[MOD_MHU3_ELEMENT_COUNT] = { .channels = &scp2rss_s_dbch_config[0], }, }, + [SCP_CFGD_MOD_MHU3_EIDX_SCP_MCP_S] = { + .name = "SCP2MCP_S_MHU_DBCH", + .sub_element_count = 1, + .data = &(struct mod_mhu3_device_config) { + .irq = (unsigned int) MHU3_MCP2SCP_IRQ_S, + .in = SCP_MCP2SCP_MHUV3_RCV_S_BASE, + .out = SCP_SCP2MCP_MHUV3_SEND_S_BASE, + .channels = &scp2mcp_s_dbch_config[0], + }, + }, [SCP_CFGD_MOD_MHU3_EIDX_COUNT] = { 0 }, }; diff --git a/product/neoverse-rd/rdv3/scp_ramfw/config_transport.c b/product/neoverse-rd/rdv3/scp_ramfw/config_transport.c index 9e436996e..4d22217b5 100644 --- a/product/neoverse-rd/rdv3/scp_ramfw/config_transport.c +++ b/product/neoverse-rd/rdv3/scp_ramfw/config_transport.c @@ -1,6 +1,6 @@ /* * Arm SCP/MCP Software - * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause * @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -89,6 +90,54 @@ static const struct fwk_element element_table[MOD_TRANSPORT_ELEMENT_COUNT] = { MOD_MHU3_API_IDX_TRANSPORT_DRIVER), }), }, + [SCP_CFGD_MOD_TRANSPORT_EIDX_MCP_SCMI_MSG_SEND_CH] = { + .name = "SCP_MCP_SCMI_MSG_SEND_CH", + .data = &(( + struct mod_transport_channel_config) { + .transport_type = MOD_TRANSPORT_CHANNEL_TRANSPORT_TYPE_OUT_BAND, + .policies = MOD_TRANSPORT_POLICY_INIT_MAILBOX | + MOD_TRANSPORT_POLICY_SECURE, + .channel_type = MOD_TRANSPORT_CHANNEL_TYPE_REQUESTER, + .out_band_mailbox_address = + (uintptr_t) SCP_MCP_SCMI_MSG_PAYLOAD_BASE, + .out_band_mailbox_size = SCP_MCP_SCMI_MSG_PAYLOAD_SIZE, + .signal_api_id = + FWK_ID_API_INIT( + FWK_MODULE_IDX_SCMI, + MOD_SCMI_API_IDX_TRANSPORT), + .driver_id = + FWK_ID_SUB_ELEMENT_INIT( + FWK_MODULE_IDX_MHU3, + SCP_CFGD_MOD_MHU3_EIDX_SCP_MCP_S, + 0), + .driver_api_id = + FWK_ID_API_INIT( + FWK_MODULE_IDX_MHU3, + MOD_MHU3_API_IDX_TRANSPORT_DRIVER), + }), + }, + [SCP_CFGD_MOD_TRANSPORT_EIDX_MCP_SCMI_MSG_RECV_CH] = { + .name = "SCP_MCP_SCMI_MSG_RECV_CH", + .data = &(( + struct mod_transport_channel_config) { + .transport_type = MOD_TRANSPORT_CHANNEL_TRANSPORT_TYPE_OUT_BAND, + .policies = MOD_TRANSPORT_POLICY_INIT_MAILBOX | + MOD_TRANSPORT_POLICY_SECURE, + .channel_type = MOD_TRANSPORT_CHANNEL_TYPE_COMPLETER, + .out_band_mailbox_address = + (uintptr_t) SCP_MCP_SCMI_MSG_PAYLOAD_BASE, + .out_band_mailbox_size = SCP_MCP_SCMI_MSG_PAYLOAD_SIZE, + .driver_id = + FWK_ID_SUB_ELEMENT_INIT( + FWK_MODULE_IDX_MHU3, + SCP_CFGD_MOD_MHU3_EIDX_SCP_MCP_S, + 0), + .driver_api_id = + FWK_ID_API_INIT( + FWK_MODULE_IDX_MHU3, + MOD_MHU3_API_IDX_TRANSPORT_DRIVER), + }), + }, [SCP_CFGD_MOD_TRANSPORT_EIDX_COUNT] = { 0 }, }; diff --git a/product/neoverse-rd/rdv3/scp_ramfw/include/fmw_cmsis.h b/product/neoverse-rd/rdv3/scp_ramfw/include/fmw_cmsis.h index c0d8c7032..09499e1de 100644 --- a/product/neoverse-rd/rdv3/scp_ramfw/include/fmw_cmsis.h +++ b/product/neoverse-rd/rdv3/scp_ramfw/include/fmw_cmsis.h @@ -1,6 +1,6 @@ /* * Arm SCP/MCP Software - * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -56,6 +56,8 @@ typedef enum IRQn { PPU_CLUSTERS3_IRQ = 62, /* MHUv3 secure IRQ between SCP and AP */ MHU3_AP2SCP_IRQ_S = 83, + /* MHUv3 secure IRQ between SCP and MCP */ + MHU3_MCP2SCP_IRQ_S = 85, /* MHUv3 secure IRQ between SCP and RSS */ MHU3_RSS2SCP_IRQ_S = 86, diff --git a/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_mhu3.h b/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_mhu3.h index b27b57587..75222842d 100644 --- a/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_mhu3.h +++ b/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_mhu3.h @@ -1,6 +1,6 @@ /* * Arm SCP/MCP Software - * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause * @@ -15,6 +15,7 @@ enum scp_cfgd_mod_mhu3_device_idx { SCP_CFGD_MOD_MHU3_EIDX_SCP_AP_S_CLUS0, SCP_CFGD_MOD_MHU3_EIDX_SCP_RSS_S, + SCP_CFGD_MOD_MHU3_EIDX_SCP_MCP_S, SCP_CFGD_MOD_MHU3_EIDX_COUNT }; diff --git a/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_transport.h b/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_transport.h index 3b1dc9f68..f10ca8d60 100644 --- a/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_transport.h +++ b/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_transport.h @@ -1,6 +1,6 @@ /* * Arm SCP/MCP Software - * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause * @@ -16,6 +16,8 @@ enum scp_cfgd_mod_transport_element_idx { SCP_CFGD_MOD_TRANSPORT_EIDX_PSCI, SCP_CFGD_MOD_TRANSPORT_EIDX_SYSTEM, + SCP_CFGD_MOD_TRANSPORT_EIDX_MCP_SCMI_MSG_SEND_CH, + SCP_CFGD_MOD_TRANSPORT_EIDX_MCP_SCMI_MSG_RECV_CH, SCP_CFGD_MOD_TRANSPORT_EIDX_COUNT, }; diff --git a/product/neoverse-rd/rdv3/scp_ramfw/include/scp_css_mmap.h b/product/neoverse-rd/rdv3/scp_ramfw/include/scp_css_mmap.h index 2052d06aa..21e27baa2 100644 --- a/product/neoverse-rd/rdv3/scp_ramfw/include/scp_css_mmap.h +++ b/product/neoverse-rd/rdv3/scp_ramfw/include/scp_css_mmap.h @@ -30,6 +30,8 @@ #define SCP_UART_BASE (0x44002000) #define SCP_SCP2AP_MHUV3_SEND_S_BASE (0x45020000) #define SCP_AP2SCP_MHUV3_RCV_S_BASE (0x45030000) +#define SCP_SCP2MCP_MHUV3_SEND_S_BASE (0x45800000) +#define SCP_MCP2SCP_MHUV3_RCV_S_BASE (0x45810000) #define SCP_SCP2RSS_MHUV3_SEND_S_BASE (0x46000000) #define SCP_RSS2SCP_MHUV3_RCV_S_BASE (0x46010000) #define SCP_POWER_CONTROL_BASE (0x50000000) diff --git a/product/neoverse-rd/rdv3/scp_ramfw/include/scp_fw_mmap.h b/product/neoverse-rd/rdv3/scp_ramfw/include/scp_fw_mmap.h index 6c3d1a3e8..a4dbfba67 100644 --- a/product/neoverse-rd/rdv3/scp_ramfw/include/scp_fw_mmap.h +++ b/product/neoverse-rd/rdv3/scp_ramfw/include/scp_fw_mmap.h @@ -1,6 +1,6 @@ /* * Arm SCP/MCP Software - * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause * @@ -12,6 +12,7 @@ #ifndef SCP_FW_MMAP_H #define SCP_FW_MMAP_H +#include "rsm_fw_mmap.h" #include "scp_css_mmap.h" #include @@ -62,4 +63,14 @@ #define SCP_SCMI_PAYLOAD_S_A2P_BASE (SCP_SDS_SECURE_BASE + SCP_SDS_SECURE_SIZE) #define SCP_SCMI_PAYLOAD_SIZE (128) +/* + * RSM SRAM in the AP memory map with base address of 0x2F000000 is mapped in + * the SCP's address translation window 0 (0x60000000 - 0x9FFFFFFF) at the + * offset 'SCP_ATW0_SHARED_SRAM_RSM_BASE' via ATU configuration. + */ + +/* SCP-MCP SCMI message payload base address (in RSM SRAM) */ +#define SCP_MCP_SCMI_MSG_PAYLOAD_BASE \ + (SCP_SHARED_SRAM_RSM_BASE + SCP_MCP_SCMI_MSG_PAYLOAD_OFFSET) + #endif /* SCP_FW_MMAP_H */ -- GitLab From 369e7325b7d9acd976e1175e8b9ee6cd0074ced4 Mon Sep 17 00:00:00 2001 From: Pranav Madhu Date: Fri, 27 Dec 2024 23:37:35 +0530 Subject: [PATCH 07/22] nrd/rdv3: add SCP-MCP SCMI sender channel for SCP Add an SCMI sender channel to allow SCP send SCMI messages to MCP. An example of such a SCMI message is to notify MCP of a system-wide power-down event using the SCMI system power notification. Change-Id: I8c0d8da29342ea5abddf19e3c97624603f4ce82c Signed-off-by: Pranav Madhu --- .../neoverse-rd/rdv3/scp_ramfw/config_scmi.c | 18 +++++++++++++++++- .../rdv3/scp_ramfw/include/scp_cfgd_scmi.h | 4 +++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/product/neoverse-rd/rdv3/scp_ramfw/config_scmi.c b/product/neoverse-rd/rdv3/scp_ramfw/config_scmi.c index d9084e9a7..154f78372 100644 --- a/product/neoverse-rd/rdv3/scp_ramfw/config_scmi.c +++ b/product/neoverse-rd/rdv3/scp_ramfw/config_scmi.c @@ -1,6 +1,6 @@ /* * Arm SCP/MCP Software - * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause * @@ -40,6 +40,22 @@ static const struct fwk_element service_table[MOD_SCMI_ELEMENT_COUNT] = { .scmi_p2a_id = FWK_ID_NONE_INIT, }), }, + [SCP_CFGD_MOD_SCMI_EIDX_MCP_SCMI_SEND] = { + .name = "SCP_MCP_SCMI_SEND", + .data = &((struct mod_scmi_service_config) { + .transport_id = FWK_ID_ELEMENT_INIT( + FWK_MODULE_IDX_TRANSPORT, + SCP_CFGD_MOD_TRANSPORT_EIDX_MCP_SCMI_MSG_SEND_CH), + .transport_api_id = FWK_ID_API_INIT( + FWK_MODULE_IDX_TRANSPORT, + MOD_TRANSPORT_API_IDX_SCMI_TO_TRANSPORT), + .transport_notification_init_id = FWK_ID_NOTIFICATION_INIT( + FWK_MODULE_IDX_TRANSPORT, + MOD_TRANSPORT_NOTIFICATION_IDX_INITIALIZED), + .scmi_agent_id = SCP_SCMI_AGENT_IDX_MCP, + .scmi_p2a_id = FWK_ID_NONE_INIT, + }), + }, [SCP_CFGD_MOD_SCMI_EIDX_COUNT] = { 0 } }; diff --git a/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_scmi.h b/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_scmi.h index 82775ade6..0c25222d6 100644 --- a/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_scmi.h +++ b/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_scmi.h @@ -1,6 +1,6 @@ /* * Arm SCP/MCP Software - * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause * @@ -15,12 +15,14 @@ enum scp_scmi_agent_idx { /* 0 is reserved for the platform */ SCP_SCMI_AGENT_IDX_PSCI = 1, + SCP_SCMI_AGENT_IDX_MCP, SCP_SCMI_AGENT_IDX_COUNT, }; /* Module 'scmi' element indexes (SCMI services supported) */ enum scp_cfgd_mod_scmi_element_idx { SCP_CFGD_MOD_SCMI_EIDX_PSCI, + SCP_CFGD_MOD_SCMI_EIDX_MCP_SCMI_SEND, SCP_CFGD_MOD_SCMI_EIDX_COUNT, }; -- GitLab From 42db21f4425023825b6eb8fd58706f5d1420767f Mon Sep 17 00:00:00 2001 From: Pranav Madhu Date: Tue, 13 Feb 2024 20:29:55 +0530 Subject: [PATCH 08/22] nrd/rdv3: add SCP-MCP SCMI receiver channel for SCP Add SCMI receiver channel for SCP from MCP. On boot, the MCP platform will use this channel to send SCMI system power notification subscription message to the SCP. Upon receiving this message, SCP will register the MCP as an agent requiring system power-down notifications. Additionally, the receiver channel configuration will provide information about the sender channel to be used for sending notifications via the '.scmi_p2a_id' field. Change-Id: I5dae35f67ff04574d378aafa81b8420d9600ec11 Signed-off-by: Pranav Madhu --- .../neoverse-rd/rdv3/scp_ramfw/config_scmi.c | 25 +++++++++++++++++++ .../rdv3/scp_ramfw/include/scp_cfgd_scmi.h | 9 +++++++ 2 files changed, 34 insertions(+) diff --git a/product/neoverse-rd/rdv3/scp_ramfw/config_scmi.c b/product/neoverse-rd/rdv3/scp_ramfw/config_scmi.c index 154f78372..3b70ef1b8 100644 --- a/product/neoverse-rd/rdv3/scp_ramfw/config_scmi.c +++ b/product/neoverse-rd/rdv3/scp_ramfw/config_scmi.c @@ -56,6 +56,26 @@ static const struct fwk_element service_table[MOD_SCMI_ELEMENT_COUNT] = { .scmi_p2a_id = FWK_ID_NONE_INIT, }), }, +#ifdef BUILD_HAS_SCMI_NOTIFICATIONS + [SCP_CFGD_MOD_SCMI_EIDX_MCP_SCMI_RECV] = { + .name = "SCP_MCP_SCMI_RECV", + .data = &((struct mod_scmi_service_config) { + .transport_id = FWK_ID_ELEMENT_INIT( + FWK_MODULE_IDX_TRANSPORT, + SCP_CFGD_MOD_TRANSPORT_EIDX_MCP_SCMI_MSG_RECV_CH), + .transport_api_id = FWK_ID_API_INIT( + FWK_MODULE_IDX_TRANSPORT, + MOD_TRANSPORT_API_IDX_SCMI_TO_TRANSPORT), + .transport_notification_init_id = FWK_ID_NOTIFICATION_INIT( + FWK_MODULE_IDX_TRANSPORT, + MOD_TRANSPORT_NOTIFICATION_IDX_INITIALIZED), + .scmi_agent_id = SCP_SCMI_AGENT_IDX_MCP, + .scmi_p2a_id = FWK_ID_ELEMENT_INIT( + FWK_MODULE_IDX_SCMI, + SCP_CFGD_MOD_SCMI_EIDX_MCP_SCMI_SEND), + }), + }, +#endif [SCP_CFGD_MOD_SCMI_EIDX_COUNT] = { 0 } }; @@ -69,12 +89,17 @@ static struct mod_scmi_agent agent_table[SCP_SCMI_AGENT_IDX_COUNT] = { .type = SCMI_AGENT_TYPE_PSCI, .name = "PSCI", }, + [SCP_SCMI_AGENT_IDX_MCP] = { + .type = SCMI_AGENT_TYPE_MANAGEMENT, + .name = "MCP", + }, }; const struct fwk_module_config config_scmi = { .data = &(struct mod_scmi_config){ .protocol_count_max = 4, + .protocol_requester_count_max = SCMI_PROTOCOL_REQUESTER_COUNT, .agent_count = FWK_ARRAY_SIZE(agent_table) - 1, .agent_table = agent_table, .vendor_identifier = "arm", diff --git a/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_scmi.h b/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_scmi.h index 0c25222d6..7004f14c6 100644 --- a/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_scmi.h +++ b/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_scmi.h @@ -23,7 +23,16 @@ enum scp_scmi_agent_idx { enum scp_cfgd_mod_scmi_element_idx { SCP_CFGD_MOD_SCMI_EIDX_PSCI, SCP_CFGD_MOD_SCMI_EIDX_MCP_SCMI_SEND, +#ifdef BUILD_HAS_SCMI_NOTIFICATIONS + SCP_CFGD_MOD_SCMI_EIDX_MCP_SCMI_RECV, +#endif SCP_CFGD_MOD_SCMI_EIDX_COUNT, }; +/* SCMI protocol requester agents */ +enum scmi_protocol_requester { + SCMI_PROTOCOL_REQUESTER_MCP, + SCMI_PROTOCOL_REQUESTER_COUNT +}; + #endif /* SCP_CFGD_SCMI_H */ -- GitLab From dfcb0590cf33abf525dd2edba810d5ca913a437b Mon Sep 17 00:00:00 2001 From: Pranav Madhu Date: Thu, 4 Jan 2024 17:05:49 +0530 Subject: [PATCH 09/22] nrd/rdv3: add MCP-SCP MHU outband communication for MCP Add bi-directional MHU outband communication between the MCP and SCP for MCP. During boot, the MCP platform sends an SCMI system power notification subscription request to the SCP over the sender transport channel to subscribe to system-wide power-down events. In the event of a system-wide power-down, the SCP sends an SCMI notification to the MCP, which receives it through the receiver transport channel. Change-Id: I08e11b66cb796b0c532a3877cf2527c3d1979c37 Signed-off-by: Pranav Madhu --- .../neoverse-rd/rdv3/mcp_ramfw/CMakeLists.txt | 4 +- .../neoverse-rd/rdv3/mcp_ramfw/Firmware.cmake | 6 +- .../neoverse-rd/rdv3/mcp_ramfw/config_mhu3.c | 50 ++++++++++ .../rdv3/mcp_ramfw/config_transport.c | 91 +++++++++++++++++++ .../rdv3/mcp_ramfw/include/fmw_cmsis.h | 1 + .../rdv3/mcp_ramfw/include/mcp_cfgd_mhu3.h | 19 ++++ .../mcp_ramfw/include/mcp_cfgd_transport.h | 22 +++++ .../rdv3/mcp_ramfw/include/mcp_css_mmap.h | 17 +++- .../rdv3/mcp_ramfw/include/mcp_fw_mmap.h | 28 ++++++ 9 files changed, 232 insertions(+), 6 deletions(-) create mode 100644 product/neoverse-rd/rdv3/mcp_ramfw/config_mhu3.c create mode 100644 product/neoverse-rd/rdv3/mcp_ramfw/config_transport.c create mode 100644 product/neoverse-rd/rdv3/mcp_ramfw/include/mcp_cfgd_mhu3.h create mode 100644 product/neoverse-rd/rdv3/mcp_ramfw/include/mcp_cfgd_transport.h create mode 100644 product/neoverse-rd/rdv3/mcp_ramfw/include/mcp_fw_mmap.h diff --git a/product/neoverse-rd/rdv3/mcp_ramfw/CMakeLists.txt b/product/neoverse-rd/rdv3/mcp_ramfw/CMakeLists.txt index 181d7a4bc..a408cdc71 100644 --- a/product/neoverse-rd/rdv3/mcp_ramfw/CMakeLists.txt +++ b/product/neoverse-rd/rdv3/mcp_ramfw/CMakeLists.txt @@ -45,7 +45,9 @@ target_sources( "${CMAKE_CURRENT_SOURCE_DIR}/config_clock.c" "${CMAKE_CURRENT_SOURCE_DIR}/config_pl011.c" "${CMAKE_CURRENT_SOURCE_DIR}/config_timer.c" - "${CMAKE_CURRENT_SOURCE_DIR}/config_gtimer.c") + "${CMAKE_CURRENT_SOURCE_DIR}/config_gtimer.c" + "${CMAKE_CURRENT_SOURCE_DIR}/config_mhu3.c" + "${CMAKE_CURRENT_SOURCE_DIR}/config_transport.c") # # Some of our firmware includes require CMSIS. diff --git a/product/neoverse-rd/rdv3/mcp_ramfw/Firmware.cmake b/product/neoverse-rd/rdv3/mcp_ramfw/Firmware.cmake index 8dcdedc4d..3c49ec43b 100644 --- a/product/neoverse-rd/rdv3/mcp_ramfw/Firmware.cmake +++ b/product/neoverse-rd/rdv3/mcp_ramfw/Firmware.cmake @@ -1,6 +1,6 @@ # # Arm SCP/MCP Software -# Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. +# Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause # @@ -26,6 +26,8 @@ set(SCP_ENABLE_IPO_INIT FALSE) set(SCP_ARCHITECTURE "arm-m") +set(SCP_ENABLE_OUTBAND_MSG_SUPPORT TRUE) + list(PREPEND SCP_MODULE_PATHS "${CMAKE_CURRENT_LIST_DIR}/../module/mcp_platform") @@ -38,4 +40,6 @@ list(APPEND SCP_MODULES "pl011") list(APPEND SCP_MODULES "clock") list(APPEND SCP_MODULES "timer") list(APPEND SCP_MODULES "gtimer") +list(APPEND SCP_MODULES "mhu3") +list(APPEND SCP_MODULES "transport") list(APPEND SCP_MODULES "mcp-platform") diff --git a/product/neoverse-rd/rdv3/mcp_ramfw/config_mhu3.c b/product/neoverse-rd/rdv3/mcp_ramfw/config_mhu3.c new file mode 100644 index 000000000..d180d72bb --- /dev/null +++ b/product/neoverse-rd/rdv3/mcp_ramfw/config_mhu3.c @@ -0,0 +1,50 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Description: + * Configuration data for module 'mhu3'. + */ + +#include "mcp_cfgd_mhu3.h" +#include "mcp_css_mmap.h" + +#include + +#include +#include +#include + +#include + +/* MCP<-->SCP Secure MHUv3 doorbell channel configuration */ +static struct mod_mhu3_channel_config mcp2scp_s_dbch_config[] = { + /* PBX CH 0, FLAG 0, MBX CH 0, FLAG 0 */ + MOD_MHU3_INIT_DBCH(0, 0, 0, 0), +}; + +/* Module element table */ +static const struct fwk_element element_table[] = { + [MCP_CFGD_MOD_MHU3_EIDX_MCP_SCP_S] = { + .name = "MCP2SCP_S_MHU_DBCH", + .sub_element_count = 1, + .data = &(struct mod_mhu3_device_config) { + .irq = (unsigned int) MHU3_SCP2MCP_IRQ_S, + .in = MCP_SCP2MCP_MHUV3_RCV_S_BASE, + .out = MCP_MCP2SCP_MHUV3_SEND_S_BASE, + .channels = &mcp2scp_s_dbch_config[0], + }, + }, + [MCP_CFGD_MOD_MHU3_EIDX_COUNT] = { 0 }, +}; + +static const struct fwk_element *get_element_table(fwk_id_t module_id) +{ + return element_table; +} + +struct fwk_module_config config_mhu3 = { + .elements = FWK_MODULE_DYNAMIC_ELEMENTS(get_element_table), +}; diff --git a/product/neoverse-rd/rdv3/mcp_ramfw/config_transport.c b/product/neoverse-rd/rdv3/mcp_ramfw/config_transport.c new file mode 100644 index 000000000..0f6e0408b --- /dev/null +++ b/product/neoverse-rd/rdv3/mcp_ramfw/config_transport.c @@ -0,0 +1,91 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Description: + * Configuration data for module 'transport'. + */ + +#include "mcp_cfgd_mhu3.h" +#include "mcp_cfgd_transport.h" +#include "mcp_fw_mmap.h" +#include "platform_variant.h" + +#include +#include + +#include +#include +#include +#include + +#include + +static const struct fwk_element transport_element_table[] = { + [MCP_CFGD_MOD_TRANSPORT_EIDX_SCP_SCMI_MSG_SEND_CH] = { + .name = "MCP_SCP_SCMI_MSG_SEND_CH", + .data = &(( + struct mod_transport_channel_config) { + .transport_type = MOD_TRANSPORT_CHANNEL_TRANSPORT_TYPE_OUT_BAND, +#if (PLATFORM_VARIANT == RD_V3_CFG2) + /* TODO: Enable shutdown/reboot support for multichip platform + * as well, once chip to chip SCP communicaiton is enabled */ + .policies = MOD_TRANSPORT_POLICY_NONE, +#else + .policies = MOD_TRANSPORT_POLICY_INIT_MAILBOX | + MOD_TRANSPORT_POLICY_SECURE, +#endif + .channel_type = MOD_TRANSPORT_CHANNEL_TYPE_REQUESTER, + .out_band_mailbox_address = + (uintptr_t) MCP_SCP_SCMI_MSG_PAYLOAD_BASE, + .out_band_mailbox_size = SCP_MCP_SCMI_MSG_PAYLOAD_SIZE, + .driver_id = + FWK_ID_SUB_ELEMENT_INIT( + FWK_MODULE_IDX_MHU3, + MCP_CFGD_MOD_MHU3_EIDX_MCP_SCP_S, + 0), + .driver_api_id = + FWK_ID_API_INIT( + FWK_MODULE_IDX_MHU3, + MOD_MHU3_API_IDX_TRANSPORT_DRIVER), + }), + }, + [MCP_CFGD_MOD_TRANSPORT_EIDX_SCP_SCMI_MSG_RECV_CH] = { + .name = "MCP_SCP_SCMI_MSG_RECV_CH", + .data = &(( + struct mod_transport_channel_config) { + .transport_type = MOD_TRANSPORT_CHANNEL_TRANSPORT_TYPE_OUT_BAND, +#if (PLATFORM_VARIANT == RD_V3_CFG2) + .policies = MOD_TRANSPORT_POLICY_NONE, +#else + .policies = MOD_TRANSPORT_POLICY_INIT_MAILBOX | + MOD_TRANSPORT_POLICY_SECURE, +#endif + .channel_type = MOD_TRANSPORT_CHANNEL_TYPE_COMPLETER, + .out_band_mailbox_address = + (uintptr_t) MCP_SCP_SCMI_MSG_PAYLOAD_BASE, + .out_band_mailbox_size = SCP_MCP_SCMI_MSG_PAYLOAD_SIZE, + .driver_id = + FWK_ID_SUB_ELEMENT_INIT( + FWK_MODULE_IDX_MHU3, + MCP_CFGD_MOD_MHU3_EIDX_MCP_SCP_S, + 0), + .driver_api_id = + FWK_ID_API_INIT( + FWK_MODULE_IDX_MHU3, + MOD_MHU3_API_IDX_TRANSPORT_DRIVER), + }), + }, + [MCP_CFGD_MOD_TRANSPORT_EIDX_COUNT] = { 0 }, +}; + +static const struct fwk_element *transport_get_element_table(fwk_id_t module_id) +{ + return transport_element_table; +} + +const struct fwk_module_config config_transport = { + .elements = FWK_MODULE_DYNAMIC_ELEMENTS(transport_get_element_table), +}; diff --git a/product/neoverse-rd/rdv3/mcp_ramfw/include/fmw_cmsis.h b/product/neoverse-rd/rdv3/mcp_ramfw/include/fmw_cmsis.h index ba78a5f71..27c2036aa 100644 --- a/product/neoverse-rd/rdv3/mcp_ramfw/include/fmw_cmsis.h +++ b/product/neoverse-rd/rdv3/mcp_ramfw/include/fmw_cmsis.h @@ -36,6 +36,7 @@ typedef enum IRQn { SysTick_IRQn = -1, REFCLK_GTIMER_IRQ = 34, /* MCP REFCLK Physical Timer interrupt */ + MHU3_SCP2MCP_IRQ_S = 84, /* SCP to MCP Secure MHUv3 IRQ */ IRQn_MAX = INT16_MAX, } IRQn_Type; diff --git a/product/neoverse-rd/rdv3/mcp_ramfw/include/mcp_cfgd_mhu3.h b/product/neoverse-rd/rdv3/mcp_ramfw/include/mcp_cfgd_mhu3.h new file mode 100644 index 000000000..8f4d369be --- /dev/null +++ b/product/neoverse-rd/rdv3/mcp_ramfw/include/mcp_cfgd_mhu3.h @@ -0,0 +1,19 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Description: + * Definitions for MHUv3 module configuration data in MCP firmware. + */ + +#ifndef MCP_CFGD_MHU3_H +#define MCP_CFGD_MHU3_H + +enum mcp_cfgd_mod_mhu3_device_idx { + MCP_CFGD_MOD_MHU3_EIDX_MCP_SCP_S, + MCP_CFGD_MOD_MHU3_EIDX_COUNT +}; + +#endif /* MCP_CFGD_MHU3_H */ diff --git a/product/neoverse-rd/rdv3/mcp_ramfw/include/mcp_cfgd_transport.h b/product/neoverse-rd/rdv3/mcp_ramfw/include/mcp_cfgd_transport.h new file mode 100644 index 000000000..4fe68f0c0 --- /dev/null +++ b/product/neoverse-rd/rdv3/mcp_ramfw/include/mcp_cfgd_transport.h @@ -0,0 +1,22 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Description: + * Definitions for transport module configuration data in MCP + * firmware. + */ + +#ifndef MCP_CFGD_TRANSPORT_H +#define MCP_CFGD_TRANSPORT_H + +/* Module 'transport' element indexes */ +enum mcp_cfgd_mod_transport_element_idx { + MCP_CFGD_MOD_TRANSPORT_EIDX_SCP_SCMI_MSG_SEND_CH, + MCP_CFGD_MOD_TRANSPORT_EIDX_SCP_SCMI_MSG_RECV_CH, + MCP_CFGD_MOD_TRANSPORT_EIDX_COUNT, +}; + +#endif /* MCP_CFGD_TRANSPORT_H */ diff --git a/product/neoverse-rd/rdv3/mcp_ramfw/include/mcp_css_mmap.h b/product/neoverse-rd/rdv3/mcp_ramfw/include/mcp_css_mmap.h index a85dda00f..9667e72f7 100644 --- a/product/neoverse-rd/rdv3/mcp_ramfw/include/mcp_css_mmap.h +++ b/product/neoverse-rd/rdv3/mcp_ramfw/include/mcp_css_mmap.h @@ -1,6 +1,6 @@ /* * Arm SCP/MCP Software - * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause * @@ -21,11 +21,14 @@ #define MCP_DTC_RAM_SIZE (256 * 1024) /* SCP sub-system peripherals */ -#define MCP_REFCLK_CNTCTL_BASE (0x4C000000) -#define MCP_REFCLK_CNTBASE0_BASE (0x4C001000) -#define MCP_UART_BASE (0x4C002000) +#define MCP_MCP2SCP_MHUV3_SEND_S_BASE UINT32_C(0x45600000) +#define MCP_SCP2MCP_MHUV3_RCV_S_BASE UINT32_C(0x45610000) +#define MCP_REFCLK_CNTCTL_BASE (0x4C000000) +#define MCP_REFCLK_CNTBASE0_BASE (0x4C001000) +#define MCP_UART_BASE (0x4C002000) /* MCP addresses translation window base addresses */ +#define MCP_ADDRESS_TRANSLATION_WINDOW0_BASE (0x60000000) #define MCP_ADDRESS_TRANSLATION_WINDOW1_BASE (0xA0000000) /* Offsets within MCP's Address Translation Window0 */ @@ -35,4 +38,10 @@ #define MCP_REFCLK_CNTCONTROL_BASE \ (MCP_ADDRESS_TRANSLATION_WINDOW1_BASE + MCP_ATW1_REFCLK_CNTCONTROL_OFFSET) +/* + * RSM memory region (shared between RSS, MCP, SCP) is mapped by ATU in + * the MCP address translation window 0. + */ +#define MCP_SHARED_SRAM_RSM_BASE (MCP_ADDRESS_TRANSLATION_WINDOW0_BASE) + #endif /* MCP_CSS_MMAP_H */ diff --git a/product/neoverse-rd/rdv3/mcp_ramfw/include/mcp_fw_mmap.h b/product/neoverse-rd/rdv3/mcp_ramfw/include/mcp_fw_mmap.h new file mode 100644 index 000000000..a2945c259 --- /dev/null +++ b/product/neoverse-rd/rdv3/mcp_ramfw/include/mcp_fw_mmap.h @@ -0,0 +1,28 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Description: + * Base address and size definitions for the various MCP's firmware defined + * memory carveouts. + */ + +#ifndef MCP_FW_MMAP_H +#define MCP_FW_MMAP_H + +#include "mcp_css_mmap.h" +#include "rsm_fw_mmap.h" + +/* + * RSM SRAM in the AP memory map with base address of 0x2F000000 is mapped in + * the MCP's address translation window 0 (0x60000000 - 0x9FFFFFFF) at the + * offset 'MCP_SHARED_SRAM_RSM_BASE' via ATU configuration. + */ + +/* MCP-SCP SCMI message payload base address (in RSM SRAM) */ +#define MCP_SCP_SCMI_MSG_PAYLOAD_BASE \ + (MCP_SHARED_SRAM_RSM_BASE + SCP_MCP_SCMI_MSG_PAYLOAD_OFFSET) + +#endif /* MCP_FW_MMAP_H */ -- GitLab From 5360043b97e8d655a4e2a4a0a139672453a39378 Mon Sep 17 00:00:00 2001 From: Pranav Madhu Date: Thu, 2 Jan 2025 14:08:08 +0530 Subject: [PATCH 10/22] nrd/rdv3: add SCMI and SCMI system power min to MCP build Add a bi-directional SCMI channel between SCP and MCP to facilitate system power-down messages. Additionally, include the SCMI system power minimal module in the MCP build to handle power-down notifications originating from the SCP. Change-Id: I84d383ab5442596a82ec978add57afb84834ce77 Signed-off-by: Pranav Madhu --- .../neoverse-rd/rdv3/mcp_ramfw/CMakeLists.txt | 3 +- .../neoverse-rd/rdv3/mcp_ramfw/Firmware.cmake | 3 + .../neoverse-rd/rdv3/mcp_ramfw/config_scmi.c | 104 ++++++++++++++++++ .../rdv3/mcp_ramfw/config_transport.c | 5 + .../rdv3/mcp_ramfw/include/mcp_cfgd_scmi.h | 30 +++++ 5 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 product/neoverse-rd/rdv3/mcp_ramfw/config_scmi.c create mode 100644 product/neoverse-rd/rdv3/mcp_ramfw/include/mcp_cfgd_scmi.h diff --git a/product/neoverse-rd/rdv3/mcp_ramfw/CMakeLists.txt b/product/neoverse-rd/rdv3/mcp_ramfw/CMakeLists.txt index a408cdc71..45547f021 100644 --- a/product/neoverse-rd/rdv3/mcp_ramfw/CMakeLists.txt +++ b/product/neoverse-rd/rdv3/mcp_ramfw/CMakeLists.txt @@ -47,7 +47,8 @@ target_sources( "${CMAKE_CURRENT_SOURCE_DIR}/config_timer.c" "${CMAKE_CURRENT_SOURCE_DIR}/config_gtimer.c" "${CMAKE_CURRENT_SOURCE_DIR}/config_mhu3.c" - "${CMAKE_CURRENT_SOURCE_DIR}/config_transport.c") + "${CMAKE_CURRENT_SOURCE_DIR}/config_transport.c" + "${CMAKE_CURRENT_SOURCE_DIR}/config_scmi") # # Some of our firmware includes require CMSIS. diff --git a/product/neoverse-rd/rdv3/mcp_ramfw/Firmware.cmake b/product/neoverse-rd/rdv3/mcp_ramfw/Firmware.cmake index 3c49ec43b..38c17e6c9 100644 --- a/product/neoverse-rd/rdv3/mcp_ramfw/Firmware.cmake +++ b/product/neoverse-rd/rdv3/mcp_ramfw/Firmware.cmake @@ -29,6 +29,7 @@ set(SCP_ARCHITECTURE "arm-m") set(SCP_ENABLE_OUTBAND_MSG_SUPPORT TRUE) list(PREPEND SCP_MODULE_PATHS + "${CMAKE_SOURCE_DIR}/product/neoverse-rd/module/scmi_sys_power" "${CMAKE_CURRENT_LIST_DIR}/../module/mcp_platform") # The order of the modules in the following list is the order in which the @@ -42,4 +43,6 @@ list(APPEND SCP_MODULES "timer") list(APPEND SCP_MODULES "gtimer") list(APPEND SCP_MODULES "mhu3") list(APPEND SCP_MODULES "transport") +list(APPEND SCP_MODULES "scmi") +list(APPEND SCP_MODULES "scmi-sys-power") list(APPEND SCP_MODULES "mcp-platform") diff --git a/product/neoverse-rd/rdv3/mcp_ramfw/config_scmi.c b/product/neoverse-rd/rdv3/mcp_ramfw/config_scmi.c new file mode 100644 index 000000000..8640f18a6 --- /dev/null +++ b/product/neoverse-rd/rdv3/mcp_ramfw/config_scmi.c @@ -0,0 +1,104 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Description: + * Configuration data for module 'scmi'. + */ + +#include "mcp_cfgd_scmi.h" +#include "mcp_cfgd_transport.h" + +#include +#include + +#include +#include +#include +#include +#include + +/* Module 'scmi' element count */ +#define MOD_SCMI_ELEMENT_COUNT (MCP_CFGD_MOD_SCMI_EIDX_COUNT + 1) + +static const struct fwk_element service_table[MOD_SCMI_ELEMENT_COUNT] = { +#ifdef BUILD_HAS_SCMI_NOTIFICATIONS + [MCP_CFGD_MOD_SCMI_EIDX_SCP_SCMI_SEND] = { + .name = "MCP_SCP_SCMI_SEND", + .data = &((struct mod_scmi_service_config) { + .transport_id = FWK_ID_ELEMENT_INIT( + FWK_MODULE_IDX_TRANSPORT, + MCP_CFGD_MOD_TRANSPORT_EIDX_SCP_SCMI_MSG_SEND_CH), + .transport_api_id = FWK_ID_API_INIT( + FWK_MODULE_IDX_TRANSPORT, + MOD_TRANSPORT_API_IDX_SCMI_TO_TRANSPORT), + .transport_notification_init_id = FWK_ID_NOTIFICATION_INIT( + FWK_MODULE_IDX_TRANSPORT, + MOD_TRANSPORT_NOTIFICATION_IDX_INITIALIZED), + .scmi_agent_id = MCP_SCMI_AGENT_IDX_SCP, + .scmi_p2a_id = FWK_ID_ELEMENT_INIT( + FWK_MODULE_IDX_SCMI, + MCP_CFGD_MOD_SCMI_EIDX_SCP_SCMI_RECV), + }), + }, +#endif + [MCP_CFGD_MOD_SCMI_EIDX_SCP_SCMI_RECV] = { + .name = "MCP_SCP_SCMI_RECV", + .data = &((struct mod_scmi_service_config) { + .transport_id = FWK_ID_ELEMENT_INIT( + FWK_MODULE_IDX_TRANSPORT, + MCP_CFGD_MOD_TRANSPORT_EIDX_SCP_SCMI_MSG_RECV_CH), + .transport_api_id = FWK_ID_API_INIT( + FWK_MODULE_IDX_TRANSPORT, + MOD_TRANSPORT_API_IDX_SCMI_TO_TRANSPORT), + .transport_notification_init_id = FWK_ID_NOTIFICATION_INIT( + FWK_MODULE_IDX_TRANSPORT, + MOD_TRANSPORT_NOTIFICATION_IDX_INITIALIZED), + .scmi_agent_id = MCP_SCMI_AGENT_IDX_SCP, +#ifdef BUILD_HAS_SCMI_NOTIFICATIONS + .scmi_p2a_id = FWK_ID_ELEMENT_INIT( + FWK_MODULE_IDX_SCMI, + MCP_CFGD_MOD_SCMI_EIDX_SCP_SCMI_SEND), +#else + .scmi_p2a_id = FWK_ID_NONE_INIT, +#endif + }), + }, + [MCP_CFGD_MOD_SCMI_EIDX_COUNT] = { 0 } +}; + +static const struct fwk_element *get_service_table(fwk_id_t module_id) +{ + return service_table; +} + +/* SCMI agent descriptor */ +static struct mod_scmi_agent agent_table[MCP_SCMI_AGENT_IDX_COUNT] = { + [MCP_SCMI_AGENT_IDX_SCP] = { + .type = SCMI_AGENT_TYPE_MANAGEMENT, + .name = "SCP", + }, +}; + +/* SCMI protocols used by MCP platform */ +enum mcp_scmi_protocol_count { MCP_SCMI_SYS_POWER_PROT, MCP_SCMI_PROT_CNT }; + +/* SCMI protocols requesters in MCP platform */ +enum mcp_scmi_protocol_req_count { MCP_PLATFORM_SYSTEM, MCP_SCMI_PROT_REQ_CNT }; + +/* SCMI module configuration */ +const struct fwk_module_config config_scmi = { + .data = + &(struct mod_scmi_config){ + .protocol_count_max = MCP_SCMI_PROT_CNT, + .protocol_requester_count_max = MCP_SCMI_PROT_REQ_CNT, + .agent_count = FWK_ARRAY_SIZE(agent_table) - 1, + .agent_table = agent_table, + .vendor_identifier = "arm", + .sub_vendor_identifier = "arm", + }, + + .elements = FWK_MODULE_DYNAMIC_ELEMENTS(get_service_table), +}; diff --git a/product/neoverse-rd/rdv3/mcp_ramfw/config_transport.c b/product/neoverse-rd/rdv3/mcp_ramfw/config_transport.c index 0f6e0408b..cb253b029 100644 --- a/product/neoverse-rd/rdv3/mcp_ramfw/config_transport.c +++ b/product/neoverse-rd/rdv3/mcp_ramfw/config_transport.c @@ -14,6 +14,7 @@ #include "platform_variant.h" #include +#include #include #include @@ -41,6 +42,10 @@ static const struct fwk_element transport_element_table[] = { .out_band_mailbox_address = (uintptr_t) MCP_SCP_SCMI_MSG_PAYLOAD_BASE, .out_band_mailbox_size = SCP_MCP_SCMI_MSG_PAYLOAD_SIZE, + .signal_api_id = + FWK_ID_API_INIT( + FWK_MODULE_IDX_SCMI, + MOD_SCMI_API_IDX_TRANSPORT), .driver_id = FWK_ID_SUB_ELEMENT_INIT( FWK_MODULE_IDX_MHU3, diff --git a/product/neoverse-rd/rdv3/mcp_ramfw/include/mcp_cfgd_scmi.h b/product/neoverse-rd/rdv3/mcp_ramfw/include/mcp_cfgd_scmi.h new file mode 100644 index 000000000..aa7c8666f --- /dev/null +++ b/product/neoverse-rd/rdv3/mcp_ramfw/include/mcp_cfgd_scmi.h @@ -0,0 +1,30 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Description: + * Definitions for SCMI module configuration data in MCP firmware. + */ + +#ifndef MCP_CFGD_SCMI_H +#define MCP_CFGD_SCMI_H + +/* SCMI agent identifier indexes in the SCMI agent table */ +enum mcp_scmi_agent_idx { + /* 0 is reserved for the platform */ + MCP_SCMI_AGENT_IDX_SCP = 1, + MCP_SCMI_AGENT_IDX_COUNT, +}; + +/* Module 'scmi' element indexes (SCMI services supported) */ +enum mcp_cfgd_mod_scmi_element_idx { +#ifdef BUILD_HAS_SCMI_NOTIFICATIONS + MCP_CFGD_MOD_SCMI_EIDX_SCP_SCMI_SEND, +#endif + MCP_CFGD_MOD_SCMI_EIDX_SCP_SCMI_RECV, + MCP_CFGD_MOD_SCMI_EIDX_COUNT, +}; + +#endif /* MCP_CFGD_SCMI_H */ -- GitLab From f51ba0efe9b685cd38fd660611e25a85b9843666 Mon Sep 17 00:00:00 2001 From: Pranav Madhu Date: Thu, 9 Jan 2025 12:00:21 +0530 Subject: [PATCH 11/22] nrd/rdv3: define SCP timer elements Add enum for timer elements used by SCP firmware. Change-Id: I14e98996f7e6423ada9646c09a71632fc50e018e Signed-off-by: Pranav Madhu --- product/neoverse-rd/rdv3/scp_ramfw/config_timer.c | 11 ++++++----- .../rdv3/scp_ramfw/include/scp_cfgd_timer.h | 8 +++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/product/neoverse-rd/rdv3/scp_ramfw/config_timer.c b/product/neoverse-rd/rdv3/scp_ramfw/config_timer.c index 13231e615..1b296b216 100644 --- a/product/neoverse-rd/rdv3/scp_ramfw/config_timer.c +++ b/product/neoverse-rd/rdv3/scp_ramfw/config_timer.c @@ -1,6 +1,6 @@ /* * Arm SCP/MCP Software - * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause * @@ -20,20 +20,21 @@ #include /* Module 'timer' element count */ -#define MOD_TIMER_ELEMENT_COUNT 2 +#define MOD_TIMER_ELEMENT_COUNT (SCP_TIMER_ELEMENT_COUNT + 1) /* Timer HAL config */ static const struct fwk_element timer_dev_table[MOD_TIMER_ELEMENT_COUNT] = { - [0] = { + [SCP_TIMER_ALARM_EIDX] = { .name = "REFCLK", .data = &((struct mod_timer_dev_config) { - .id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_GTIMER, 0), + .id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_GTIMER, + SCP_TIMER_ALARM_EIDX), .timer_irq = REFCLK_GTIMER_IRQ, }), .sub_element_count = SCP_CFGD_MOD_TIMER_ALARM_IDX_COUNT, /* Number of alarms */ }, - [1] = { 0 }, + [SCP_TIMER_ELEMENT_COUNT] = { 0 }, }; static const struct fwk_element *timer_get_dev_table(fwk_id_t module_id) diff --git a/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_timer.h b/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_timer.h index a8ed5a635..f403914c1 100644 --- a/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_timer.h +++ b/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_timer.h @@ -1,6 +1,6 @@ /* * Arm SCP/MCP Software - * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause * @@ -11,6 +11,12 @@ #ifndef SCP_CFGD_TIMER_H #define SCP_CFGD_TIMER_H +/* Element indexes for SCP timer device */ +enum scp_cfgd_mod_timer_element_idx { + SCP_TIMER_ALARM_EIDX, + SCP_TIMER_ELEMENT_COUNT +}; + /* Sub-element indexes (alarms) for SCP timer device */ enum scp_cfgd_mod_timer_alarm_idx { SCP_CFGD_MOD_TIMER_ALARM_IDX_COUNT, -- GitLab From 8e7054ab7c3e293d4d21254540ca289f411ad770 Mon Sep 17 00:00:00 2001 From: Pranav Madhu Date: Fri, 22 Mar 2024 20:15:23 +0530 Subject: [PATCH 12/22] nrd/rdv3: enable scmi system power notification at SCP Enable SCMI notifications for the RD-V3 platform. After sending a notification, the SCP waits for a predefined graceful timeout to allow the receiver agent to complete the required action. This patch also defines the duration of the graceful timeout used for notifications. Change-Id: Ide276ecc4aabae0319ceadc7ce0a74c18f61de8e Signed-off-by: Pranav Madhu --- product/neoverse-rd/rdv3/scp_ramfw/Firmware.cmake | 4 +++- .../rdv3/scp_ramfw/config_scmi_system_power.c | 11 ++++++++++- .../rdv3/scp_ramfw/include/scp_cfgd_timer.h | 3 +++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/product/neoverse-rd/rdv3/scp_ramfw/Firmware.cmake b/product/neoverse-rd/rdv3/scp_ramfw/Firmware.cmake index 18e3bf38b..13ebf6f0d 100644 --- a/product/neoverse-rd/rdv3/scp_ramfw/Firmware.cmake +++ b/product/neoverse-rd/rdv3/scp_ramfw/Firmware.cmake @@ -1,6 +1,6 @@ # # Arm SCP/MCP Software -# Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. +# Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause # @@ -30,6 +30,8 @@ set(SCP_ENABLE_OUTBAND_MSG_SUPPORT TRUE) set(SCP_ENABLE_ATU_MANAGE TRUE) +set(SCP_ENABLE_SCMI_NOTIFICATIONS TRUE) + list(PREPEND SCP_MODULE_PATHS "${CMAKE_CURRENT_LIST_DIR}/../module/scp_platform") diff --git a/product/neoverse-rd/rdv3/scp_ramfw/config_scmi_system_power.c b/product/neoverse-rd/rdv3/scp_ramfw/config_scmi_system_power.c index 3abc63db9..b95446540 100644 --- a/product/neoverse-rd/rdv3/scp_ramfw/config_scmi_system_power.c +++ b/product/neoverse-rd/rdv3/scp_ramfw/config_scmi_system_power.c @@ -1,6 +1,6 @@ /* * Arm SCP/MCP Software - * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause * @@ -8,6 +8,8 @@ * Configuration data for module 'scmi_system_power'. */ +#include "scp_cfgd_timer.h" + #include #include @@ -17,5 +19,12 @@ const struct fwk_module_config config_scmi_system_power = { .data = &((struct mod_scmi_system_power_config){ .system_view = MOD_SCMI_SYSTEM_VIEW_FULL, .system_suspend_state = MOD_SYSTEM_POWER_POWER_STATE_SLEEP0, +#ifdef BUILD_HAS_SCMI_NOTIFICATIONS + .alarm_id = FWK_ID_SUB_ELEMENT_INIT( + FWK_MODULE_IDX_TIMER, + SCP_TIMER_ALARM_EIDX, + SCP_CFGD_SCMI_SYSPWR_MGMT_NOTIFY_ALARM_IDX), + .graceful_timeout = 1000, /* ms */ +#endif }), }; diff --git a/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_timer.h b/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_timer.h index f403914c1..9432ac854 100644 --- a/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_timer.h +++ b/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_timer.h @@ -19,6 +19,9 @@ enum scp_cfgd_mod_timer_element_idx { /* Sub-element indexes (alarms) for SCP timer device */ enum scp_cfgd_mod_timer_alarm_idx { +#ifdef BUILD_HAS_SCMI_NOTIFICATIONS + SCP_CFGD_SCMI_SYSPWR_MGMT_NOTIFY_ALARM_IDX, +#endif SCP_CFGD_MOD_TIMER_ALARM_IDX_COUNT, }; -- GitLab From d0755cb37021bc37b9044612e2fa2887afb7b4f8 Mon Sep 17 00:00:00 2001 From: Pranav Madhu Date: Thu, 4 Jan 2024 16:48:11 +0530 Subject: [PATCH 13/22] nrd/rdv3: add ATU configuration to map RSM SRAM with MCP The RSM SRAM is used for SCP-MCP out-band communication for transmitting the payload. Add ATU configuration for MCP to map the RSM SRAM shared across SCP, MCP and RSS to MCP system access port. Change-Id: Ia578b57eb2aeae66513631d3ce0fe5341bb77691 Signed-off-by: Pranav Madhu --- .../neoverse-rd/rdv3/mcp_ramfw/config_atu.c | 68 +++++++++++++++++++ .../rdv3/mcp_ramfw/include/mcp_css_mmap.h | 1 + 2 files changed, 69 insertions(+) create mode 100644 product/neoverse-rd/rdv3/mcp_ramfw/config_atu.c diff --git a/product/neoverse-rd/rdv3/mcp_ramfw/config_atu.c b/product/neoverse-rd/rdv3/mcp_ramfw/config_atu.c new file mode 100644 index 000000000..019823e36 --- /dev/null +++ b/product/neoverse-rd/rdv3/mcp_ramfw/config_atu.c @@ -0,0 +1,68 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Description: + * Configuration data for module 'atu'. + */ + +#include "mcp_css_mmap.h" +#include "rsm_fw_mmap.h" + +#include + +#include +#include +#include +#include +#include + +/* Indices for ATU module elements */ +enum cfgd_mod_atu_element_idx { + CFGD_MOD_ATU_EIDX_ATU0, + CFGD_MOD_ATU_EIDX_COUNT +}; + +#define MOD_MCP_ATU_ELEMENT_COUNT (CFGD_MOD_ATU_EIDX_COUNT + 1) + +/* Indices for translation regions to be configured in the ATU */ +enum atu_regions_idx { + /* ATU region to access shared RSM SRAM */ + ATU_REGION_IDX_SHARED_SRAM_RSM, + /* ATU region count */ + ATU_REGION_IDX_COUNT, +}; + +static struct atu_region_map atu_regions[ATU_REGION_IDX_COUNT] = { + [ATU_REGION_IDX_SHARED_SRAM_RSM] = { + .region_owner_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_MCP_PLATFORM), + .log_addr_base = MCP_SHARED_SRAM_RSM_BASE, + .phy_addr_base = RSM_SHARED_SRAM_BASE, + .region_size = RSM_SHARED_SRAM_SIZE, + .attributes = ATU_ENCODE_ATTRIBUTES_SECURE_PAS, + }, +}; + +static const struct fwk_element element_table[MOD_MCP_ATU_ELEMENT_COUNT] = { + [CFGD_MOD_ATU_EIDX_ATU0] = { + .name = "MCP_ATU", + .data = &(struct mod_atu_device_config) { + .is_atu_delegated = false, + .atu_base = MCP_ATU_BASE, + .atu_region_config_table = atu_regions, + .atu_region_count = FWK_ARRAY_SIZE(atu_regions), + }, + }, + [CFGD_MOD_ATU_EIDX_COUNT] = { 0 }, +}; + +static const struct fwk_element *get_element_table(fwk_id_t module_id) +{ + return element_table; +} + +struct fwk_module_config config_atu = { + .elements = FWK_MODULE_DYNAMIC_ELEMENTS(get_element_table), +}; diff --git a/product/neoverse-rd/rdv3/mcp_ramfw/include/mcp_css_mmap.h b/product/neoverse-rd/rdv3/mcp_ramfw/include/mcp_css_mmap.h index 9667e72f7..89293aabe 100644 --- a/product/neoverse-rd/rdv3/mcp_ramfw/include/mcp_css_mmap.h +++ b/product/neoverse-rd/rdv3/mcp_ramfw/include/mcp_css_mmap.h @@ -26,6 +26,7 @@ #define MCP_REFCLK_CNTCTL_BASE (0x4C000000) #define MCP_REFCLK_CNTBASE0_BASE (0x4C001000) #define MCP_UART_BASE (0x4C002000) +#define MCP_ATU_BASE UINT32_C(0x50010000) /* MCP addresses translation window base addresses */ #define MCP_ADDRESS_TRANSLATION_WINDOW0_BASE (0x60000000) -- GitLab From 662de96c43f4e877013a1a6ad7c754e2416fdff1 Mon Sep 17 00:00:00 2001 From: Pranav Madhu Date: Thu, 4 Jan 2024 16:50:40 +0530 Subject: [PATCH 14/22] nrd/rdv3: add ATU module to MCP in manage mode The ATU present in MCP supports two modes, the deligated mode and manage mode. Add ATU module support to MCP in manage mode. In manage mode, the ATU module has the full control for configuring the ATU, without the need for a supervisory controller to do the configurations. Change-Id: I8dc9ef592861a72f1c8cce574757b884f86980e2 Signed-off-by: Pranav Madhu --- product/neoverse-rd/rdv3/mcp_ramfw/CMakeLists.txt | 3 +++ product/neoverse-rd/rdv3/mcp_ramfw/Firmware.cmake | 4 ++++ product/neoverse-rd/rdv3/mcp_ramfw/config_atu.c | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/product/neoverse-rd/rdv3/mcp_ramfw/CMakeLists.txt b/product/neoverse-rd/rdv3/mcp_ramfw/CMakeLists.txt index 45547f021..d85b792ab 100644 --- a/product/neoverse-rd/rdv3/mcp_ramfw/CMakeLists.txt +++ b/product/neoverse-rd/rdv3/mcp_ramfw/CMakeLists.txt @@ -33,6 +33,8 @@ else() "'2' for RD-V3-Cfg2\n") endif() +target_compile_definitions(rdv3-mcp-bl2 PRIVATE BUILD_HAS_ATU_MANAGE) + target_include_directories( rdv3-mcp-bl2 PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" @@ -42,6 +44,7 @@ target_include_directories( target_sources( rdv3-mcp-bl2 PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/config_armv7m_mpu.c" + "${CMAKE_CURRENT_SOURCE_DIR}/config_atu.c" "${CMAKE_CURRENT_SOURCE_DIR}/config_clock.c" "${CMAKE_CURRENT_SOURCE_DIR}/config_pl011.c" "${CMAKE_CURRENT_SOURCE_DIR}/config_timer.c" diff --git a/product/neoverse-rd/rdv3/mcp_ramfw/Firmware.cmake b/product/neoverse-rd/rdv3/mcp_ramfw/Firmware.cmake index 38c17e6c9..b939f4e2d 100644 --- a/product/neoverse-rd/rdv3/mcp_ramfw/Firmware.cmake +++ b/product/neoverse-rd/rdv3/mcp_ramfw/Firmware.cmake @@ -28,6 +28,9 @@ set(SCP_ARCHITECTURE "arm-m") set(SCP_ENABLE_OUTBAND_MSG_SUPPORT TRUE) +set(SCP_ENABLE_ATU_DELEGATE FALSE) +set(SCP_ENABLE_ATU_MANAGE TRUE) + list(PREPEND SCP_MODULE_PATHS "${CMAKE_SOURCE_DIR}/product/neoverse-rd/module/scmi_sys_power" "${CMAKE_CURRENT_LIST_DIR}/../module/mcp_platform") @@ -38,6 +41,7 @@ list(PREPEND SCP_MODULE_PATHS list(APPEND SCP_MODULES "armv7m-mpu") list(APPEND SCP_MODULES "pl011") +list(APPEND SCP_MODULES "atu") list(APPEND SCP_MODULES "clock") list(APPEND SCP_MODULES "timer") list(APPEND SCP_MODULES "gtimer") diff --git a/product/neoverse-rd/rdv3/mcp_ramfw/config_atu.c b/product/neoverse-rd/rdv3/mcp_ramfw/config_atu.c index 019823e36..fb712a02c 100644 --- a/product/neoverse-rd/rdv3/mcp_ramfw/config_atu.c +++ b/product/neoverse-rd/rdv3/mcp_ramfw/config_atu.c @@ -8,8 +8,8 @@ * Configuration data for module 'atu'. */ +#include "css_common.h" #include "mcp_css_mmap.h" -#include "rsm_fw_mmap.h" #include -- GitLab From ac93939dc4a048768389239052b8852bb884ff82 Mon Sep 17 00:00:00 2001 From: Pranav Madhu Date: Fri, 22 Mar 2024 23:06:18 +0530 Subject: [PATCH 15/22] nrd/rdv3: MCP request system power state change notification MCP binds to SCMI power management protocol, and requesting SCP to notify power state changes using SCMI system power state notify message. On a system wide power state transition, SCP informs MCP of transitions via 'system power state notifier' notifications. Change-Id: Ib3580bbd736a59b56808721c1bb912ce9535b8d0 Signed-off-by: Pranav Madhu --- product/neoverse-rd/common/include/nrd_scmi.h | 30 ++++ .../rdv3/module/mcp_platform/CMakeLists.txt | 6 + .../mcp_platform/include/mod_mcp_platform.h | 41 ++++++ .../mcp_platform/src/mod_mcp_platform.c | 135 +++++++++++++++++- 4 files changed, 211 insertions(+), 1 deletion(-) create mode 100644 product/neoverse-rd/common/include/nrd_scmi.h create mode 100644 product/neoverse-rd/rdv3/module/mcp_platform/include/mod_mcp_platform.h diff --git a/product/neoverse-rd/common/include/nrd_scmi.h b/product/neoverse-rd/common/include/nrd_scmi.h new file mode 100644 index 000000000..514b6bd77 --- /dev/null +++ b/product/neoverse-rd/common/include/nrd_scmi.h @@ -0,0 +1,30 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Description: + * SCMI payload configuration data for Neoverse RD platform. + */ + +#ifndef NRD_SCMI_H +#define NRD_SCMI_H + +#include + +// clang-format off + +#ifdef BUILD_HAS_SCMI_NOTIFICATIONS +/* + * SCMI payload for scmi sytem power protocol, message id + * SYSTEM_POWER_STATE_NOTIFY + */ +struct mcp_cfgd_scmi_sys_power_state_notify_payload { + uint32_t flags; +}; +#endif + +// clang-format on + +#endif /* NRD_SCMI_H */ diff --git a/product/neoverse-rd/rdv3/module/mcp_platform/CMakeLists.txt b/product/neoverse-rd/rdv3/module/mcp_platform/CMakeLists.txt index 3f1530c2d..96160f46d 100644 --- a/product/neoverse-rd/rdv3/module/mcp_platform/CMakeLists.txt +++ b/product/neoverse-rd/rdv3/module/mcp_platform/CMakeLists.txt @@ -27,5 +27,11 @@ else() "'2' for RD-V3-Cfg2\n") endif() +target_include_directories(${SCP_MODULE_TARGET} + PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") + target_sources(${SCP_MODULE_TARGET} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/mod_mcp_platform.c") + +target_link_libraries(${SCP_MODULE_TARGET} + PRIVATE module-scmi module-scmi-sys-power) diff --git a/product/neoverse-rd/rdv3/module/mcp_platform/include/mod_mcp_platform.h b/product/neoverse-rd/rdv3/module/mcp_platform/include/mod_mcp_platform.h new file mode 100644 index 000000000..3e39a3d83 --- /dev/null +++ b/product/neoverse-rd/rdv3/module/mcp_platform/include/mod_mcp_platform.h @@ -0,0 +1,41 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Description: + * MCP Platform Support + */ + +#ifndef MOD_MCP_PLATFORM_H +#define MOD_MCP_PLATFORM_H + +/*! + * \addtogroup GroupPLATFORMModule PLATFORM Product Modules + * @{ + */ + +/*! + * \defgroup GroupMCPPlatform MCP Platform Support + * @{ + */ + +#ifdef BUILD_HAS_SCMI_NOTIFICATIONS +/*! + * \brief Indices of the interfaces exposed by the module. + */ +enum mod_mcp_platform_api_idx { + /*! API index for the powerdown interface of SCMI module */ + MOD_MCP_PLATFORM_API_IDX_SCMI_POWER_DOWN, + + /*! Number of exposed interfaces */ + MOD_MCP_PLATFORM_API_COUNT +}; +#endif + +/*! + * @} + */ + +#endif /* MOD_MCP_PLATFORM_H */ diff --git a/product/neoverse-rd/rdv3/module/mcp_platform/src/mod_mcp_platform.c b/product/neoverse-rd/rdv3/module/mcp_platform/src/mod_mcp_platform.c index ff784db20..2adb2db4a 100644 --- a/product/neoverse-rd/rdv3/module/mcp_platform/src/mod_mcp_platform.c +++ b/product/neoverse-rd/rdv3/module/mcp_platform/src/mod_mcp_platform.c @@ -1,10 +1,17 @@ /* * Arm SCP/MCP Software - * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ +#include "mcp_cfgd_scmi.h" +#include "mod_mcp_platform.h" +#include "nrd_scmi.h" + +#include +#include + #include #include #include @@ -12,6 +19,17 @@ #define MOD_NAME "[MCP_PLATFORM] " +#ifdef BUILD_HAS_SCMI_NOTIFICATIONS +/* Module context */ +struct mcp_platform_ctx { + /*! SCMI protocol API */ + const struct mod_scmi_from_protocol_req_api *scmi_protocol_req_api; +}; + +/* Module context data */ +struct mcp_platform_ctx mcp_platform_ctx; +#endif + /* * Framework handlers. */ @@ -23,8 +41,119 @@ static int mod_mcp_platform_init( return FWK_SUCCESS; } +#ifdef BUILD_HAS_SCMI_NOTIFICATIONS +static int mod_mcp_platform_bind(fwk_id_t id, unsigned int round) +{ + int status = FWK_SUCCESS; + + if (round == 0) { + /* Bind to SCMI module for SCP communication */ + status = fwk_module_bind( + FWK_ID_MODULE(FWK_MODULE_IDX_SCMI), + FWK_ID_API(FWK_MODULE_IDX_SCMI, MOD_SCMI_API_IDX_PROTOCOL_REQ), + &mcp_platform_ctx.scmi_protocol_req_api); + if (status != FWK_SUCCESS) { + return status; + } + } + + return status; +} + +/* + * SCMI module -> MCP platform module interface + */ +static int platform_system_get_scmi_protocol_id( + fwk_id_t protocol_id, + uint8_t *scmi_protocol_id) +{ + *scmi_protocol_id = (uint8_t)MOD_SCMI_PROTOCOL_ID_SYS_POWER; + + return FWK_SUCCESS; +} + +/* + * Upon binding the mcp_platform module to the SCMI module, the SCMI module + * will also bind back to the mcp_platform module, anticipating the presence of + * .get_scmi_protocol_id() and .message_handler() APIs. + * + * In the current implementation of mcp_platform module, only sending SCMI + * message is implemented, and the mcp_platform module is not intended to + * receive any SCMI messages. Therefore, it is necessary to include a minimal + * .message_handler() API to ensure the successful binding of the SCMI module. + */ +static int platform_system_scmi_message_handler( + fwk_id_t protocol_id, + fwk_id_t service_id, + const uint32_t *payload, + size_t payload_size, + unsigned int message_id) +{ + return FWK_SUCCESS; +} + +/* SCMI driver interface */ +const struct mod_scmi_to_protocol_api platform_system_scmi_api = { + .get_scmi_protocol_id = platform_system_get_scmi_protocol_id, + .message_handler = platform_system_scmi_message_handler, +}; + +static int mod_mcp_platform_process_bind( + fwk_id_t requester_id, + fwk_id_t target_id, + fwk_id_t api_id, + const void **api) +{ + int status; + enum mod_mcp_platform_api_idx api_id_type; + + api_id_type = (enum mod_mcp_platform_api_idx)fwk_id_get_api_idx(api_id); + + switch (api_id_type) { + case MOD_MCP_PLATFORM_API_IDX_SCMI_POWER_DOWN: + *api = &platform_system_scmi_api; + status = FWK_SUCCESS; + break; + + default: + status = FWK_E_PARAM; + } + + return status; +} +#endif + static int mod_mcp_platform_start(fwk_id_t id) { +#ifdef BUILD_HAS_SCMI_NOTIFICATIONS + /* + * TODO: Need to sent the SCMI message only after SCP has completed the SCMI + * initialization. + */ + int status; + + fwk_id_t mcp_scmi_prot_id = FWK_ID_ELEMENT( + FWK_MODULE_IDX_SCMI, MCP_CFGD_MOD_SCMI_EIDX_SCP_SCMI_SEND); + struct mcp_cfgd_scmi_sys_power_state_notify_payload mcp_scmi_payload; + + mcp_scmi_payload.flags = 1; + + status = mcp_platform_ctx.scmi_protocol_req_api->scmi_send_message( + MOD_SCMI_SYS_POWER_STATE_NOTIFY, + MOD_SCMI_PROTOCOL_ID_SYS_POWER, + 0, + mcp_scmi_prot_id, + (void *)&mcp_scmi_payload, + sizeof(mcp_scmi_payload), + false); + + if (status != FWK_SUCCESS) { + FWK_LOG_ERR(MOD_NAME + "Failed to subscribe SCMI power state change notofication"); + return status; + } +#endif + FWK_LOG_INFO(MOD_NAME "MCP RAM firmware initialized"); return FWK_SUCCESS; } @@ -32,6 +161,10 @@ static int mod_mcp_platform_start(fwk_id_t id) const struct fwk_module module_mcp_platform = { .type = FWK_MODULE_TYPE_SERVICE, .init = mod_mcp_platform_init, +#ifdef BUILD_HAS_SCMI_NOTIFICATIONS + .bind = mod_mcp_platform_bind, + .process_bind_request = mod_mcp_platform_process_bind, +#endif .start = mod_mcp_platform_start, }; -- GitLab From 0580241de04c300583cd69b8671ab03da349bca9 Mon Sep 17 00:00:00 2001 From: Pranav Madhu Date: Fri, 22 Mar 2024 23:25:37 +0530 Subject: [PATCH 16/22] nrd/rdv3: MCP platform to subscribe to power state change Upon receiving the SCMI notification 'system power state notifier', the SCMI power management module broadcasts it as a framework notification. The MCP platform subscribes to this framework notification and initiates MCP power down process upon reception. Change-Id: I0f82e1f0f1dd082ffc56061b1cda7e8dfd684ef9 Signed-off-by: Pranav Madhu --- product/neoverse-rd/common/include/nrd_scmi.h | 10 ++++ .../mcp_platform/src/mod_mcp_platform.c | 54 +++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/product/neoverse-rd/common/include/nrd_scmi.h b/product/neoverse-rd/common/include/nrd_scmi.h index 514b6bd77..0bd7c97e7 100644 --- a/product/neoverse-rd/common/include/nrd_scmi.h +++ b/product/neoverse-rd/common/include/nrd_scmi.h @@ -16,6 +16,16 @@ // clang-format off #ifdef BUILD_HAS_SCMI_NOTIFICATIONS +/* + * System power states for Neoverse RD platform + */ +enum nrd_scmi_system_state { + NRD_SCMI_SYSTEM_STATE_SHUTDOWN, + NRD_SCMI_SYSTEM_STATE_COLD_RESET, + NRD_SCMI_SYSTEM_STATE_WARM_RESET, + NRD_SCMI_SYSTEM_STATE_COUNT, +}; + /* * SCMI payload for scmi sytem power protocol, message id * SYSTEM_POWER_STATE_NOTIFY diff --git a/product/neoverse-rd/rdv3/module/mcp_platform/src/mod_mcp_platform.c b/product/neoverse-rd/rdv3/module/mcp_platform/src/mod_mcp_platform.c index 2adb2db4a..5376ea569 100644 --- a/product/neoverse-rd/rdv3/module/mcp_platform/src/mod_mcp_platform.c +++ b/product/neoverse-rd/rdv3/module/mcp_platform/src/mod_mcp_platform.c @@ -15,8 +15,11 @@ #include #include #include +#include #include +#include + #define MOD_NAME "[MCP_PLATFORM] " #ifdef BUILD_HAS_SCMI_NOTIFICATIONS @@ -28,6 +31,12 @@ struct mcp_platform_ctx { /* Module context data */ struct mcp_platform_ctx mcp_platform_ctx; + +/* Notification for system power down */ +static const fwk_id_t mod_scmi_sys_power_notification_system_power_down = + FWK_ID_NOTIFICATION_INIT( + FWK_MODULE_IDX_SCMI_SYS_POWER, + MOD_SCMI_SYSTEM_POWER_NOTIFICATION_IDX_SYSTEM_POWER_DOWN); #endif /* @@ -152,12 +161,54 @@ static int mod_mcp_platform_start(fwk_id_t id) "Failed to subscribe SCMI power state change notofication"); return status; } + +# ifdef BUILD_HAS_NOTIFICATION + status = fwk_notification_subscribe( + mod_scmi_sys_power_notification_system_power_down, + FWK_ID_MODULE(FWK_MODULE_IDX_SCMI_SYS_POWER), + id); + if (status != FWK_SUCCESS) { + FWK_LOG_ERR(MOD_NAME "Failed to subscribe to power down notification"); + return status; + } +# endif #endif FWK_LOG_INFO(MOD_NAME "MCP RAM firmware initialized"); return FWK_SUCCESS; } +#ifdef BUILD_HAS_NOTIFICATION +static int mcp_platform_process_notification( + const struct fwk_event *event, + struct fwk_event *resp_event) +{ +# ifdef BUILD_HAS_SCMI_NOTIFICATIONS + unsigned int *power_down; + + /* Notification handler for system wide power down. */ + if (fwk_id_is_equal( + event->id, mod_scmi_sys_power_notification_system_power_down)) { + power_down = (unsigned int *)event->params; + + if (*power_down == NRD_SCMI_SYSTEM_STATE_SHUTDOWN) { + FWK_LOG_INFO(MOD_NAME "System shutting down!"); + } else if (*power_down == NRD_SCMI_SYSTEM_STATE_COLD_RESET) { + FWK_LOG_INFO(MOD_NAME "System rebooting!"); + } else { + FWK_LOG_ERR(MOD_NAME "Invalid power mode"); + } + + __WFI(); + } else { + return FWK_E_PARAM; + } +# endif + + return FWK_SUCCESS; +} +#endif + const struct fwk_module module_mcp_platform = { .type = FWK_MODULE_TYPE_SERVICE, .init = mod_mcp_platform_init, @@ -166,6 +217,9 @@ const struct fwk_module module_mcp_platform = { .process_bind_request = mod_mcp_platform_process_bind, #endif .start = mod_mcp_platform_start, +#ifdef BUILD_HAS_NOTIFICATION + .process_notification = mcp_platform_process_notification, +#endif }; const struct fwk_module_config config_mcp_platform = { 0 }; -- GitLab From 4d66ad769099f2bd360bc1e30aa517f10f350d87 Mon Sep 17 00:00:00 2001 From: Pranav Madhu Date: Fri, 22 Mar 2024 23:35:45 +0530 Subject: [PATCH 17/22] nrd/rdv3: enable SCMI notification for MCP Enable SCMI notificaiton for MCP platform. Change-Id: Ic522de243016bc7fac0762f0cdfd39813f42c751 Signed-off-by: Pranav Madhu --- product/neoverse-rd/rdv3/mcp_ramfw/Firmware.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/product/neoverse-rd/rdv3/mcp_ramfw/Firmware.cmake b/product/neoverse-rd/rdv3/mcp_ramfw/Firmware.cmake index b939f4e2d..97f9691ba 100644 --- a/product/neoverse-rd/rdv3/mcp_ramfw/Firmware.cmake +++ b/product/neoverse-rd/rdv3/mcp_ramfw/Firmware.cmake @@ -31,6 +31,8 @@ set(SCP_ENABLE_OUTBAND_MSG_SUPPORT TRUE) set(SCP_ENABLE_ATU_DELEGATE FALSE) set(SCP_ENABLE_ATU_MANAGE TRUE) +set(SCP_ENABLE_SCMI_NOTIFICATIONS TRUE) + list(PREPEND SCP_MODULE_PATHS "${CMAKE_SOURCE_DIR}/product/neoverse-rd/module/scmi_sys_power" "${CMAKE_CURRENT_LIST_DIR}/../module/mcp_platform") -- GitLab From 745fc24f5ca284f35688cb76c406b6aef98c6ac6 Mon Sep 17 00:00:00 2001 From: Pranav Madhu Date: Wed, 20 Dec 2023 12:09:35 +0530 Subject: [PATCH 18/22] nrd/rdv3: add new SCP-RSE MHU outband channel Add new MHU outband channel between SCP and RSE. This channel will be used by SCP to inform RSE regarding system shutdown and cold reboot. Change-Id: Ia875fd50e885ab66567e8555f063060eb507ce4b Signed-off-by: Pranav Madhu --- .../neoverse-rd/rdv3/include/rsm_fw_mmap.h | 8 ++++ .../neoverse-rd/rdv3/scp_ramfw/config_mhu3.c | 6 ++- .../rdv3/scp_ramfw/config_transport.c | 48 +++++++++++++++++++ .../scp_ramfw/include/scp_cfgd_transport.h | 2 + .../rdv3/scp_ramfw/include/scp_fw_mmap.h | 4 ++ 5 files changed, 66 insertions(+), 2 deletions(-) diff --git a/product/neoverse-rd/rdv3/include/rsm_fw_mmap.h b/product/neoverse-rd/rdv3/include/rsm_fw_mmap.h index a0aa38e7c..3093d3c56 100644 --- a/product/neoverse-rd/rdv3/include/rsm_fw_mmap.h +++ b/product/neoverse-rd/rdv3/include/rsm_fw_mmap.h @@ -21,6 +21,10 @@ * | | * | SCP-MCP SCMI payload | * | (SCP_MCP_SCMI_MSG_PAYLOAD_SIZE bytes) | + * +---------------------------------------+ [SCP_RSE_SCMI_MSG_PAYLOAD_BASE] + * | | + * | SCP-RSE SCMI payload | + * | (SCP_RSE_SCMI_MSG_PAYLOAD_SIZE bytes) | * +---------------------------------------+ * | | * | | @@ -34,6 +38,10 @@ #define SCP_MCP_SCMI_MSG_PAYLOAD_OFFSET UINT32_C(0x0) #define SCP_MCP_SCMI_MSG_PAYLOAD_SIZE (128) +#define SCP_RSE_SCMI_MSG_PAYLOAD_OFFSET \ + (SCP_MCP_SCMI_MSG_PAYLOAD_OFFSET + SCP_MCP_SCMI_MSG_PAYLOAD_SIZE) +#define SCP_RSE_SCMI_MSG_PAYLOAD_SIZE (128) + // clang-format on #endif /* RSM_FW_MMAP_H */ diff --git a/product/neoverse-rd/rdv3/scp_ramfw/config_mhu3.c b/product/neoverse-rd/rdv3/scp_ramfw/config_mhu3.c index 3c99c7ac0..51587f4a5 100644 --- a/product/neoverse-rd/rdv3/scp_ramfw/config_mhu3.c +++ b/product/neoverse-rd/rdv3/scp_ramfw/config_mhu3.c @@ -26,7 +26,7 @@ #define SCP2AP_S_DBCH_COUNT 1 /* SCP<-->RSS Secure MHUv3 Doorbell channel count */ -#define SCP2RSS_S_DBCH_COUNT 2 +#define SCP2RSS_S_DBCH_COUNT 3 /* SCP<-->MCP Secure MHUv3 Doorbell channel count */ #define SCP2MCP_S_DBCH_COUNT 1 @@ -43,6 +43,8 @@ struct mod_mhu3_channel_config scp2rss_s_dbch_config[SCP2RSS_S_DBCH_COUNT] = { MOD_MHU3_INIT_DBCH(0, 0, 0, 0), /* PBX CH 1, FLAG 0, MBX CH 1, FLAG 0 */ MOD_MHU3_INIT_DBCH(1, 0, 1, 0), + /* PBX CH 2, FLAG 0, MBX CH 2, FLAG 0, used by scp platform for shutdown */ + MOD_MHU3_INIT_DBCH(2, 0, 2, 0), }; /* MCP<-->SCP Secure MHUv3 doorbell channel configuration */ @@ -66,7 +68,7 @@ static const struct fwk_element mhu_element_table[MOD_MHU3_ELEMENT_COUNT] = { }, [SCP_CFGD_MOD_MHU3_EIDX_SCP_RSS_S] = { .name = "SCP2RSS_S_MHU_DBCH", - .sub_element_count = 2, + .sub_element_count = SCP2RSS_S_DBCH_COUNT, .data = &(struct mod_mhu3_device_config) { .irq = (unsigned int) MHU3_RSS2SCP_IRQ_S, .in = SCP_RSS2SCP_MHUV3_RCV_S_BASE, diff --git a/product/neoverse-rd/rdv3/scp_ramfw/config_transport.c b/product/neoverse-rd/rdv3/scp_ramfw/config_transport.c index 4d22217b5..5e1b11f9a 100644 --- a/product/neoverse-rd/rdv3/scp_ramfw/config_transport.c +++ b/product/neoverse-rd/rdv3/scp_ramfw/config_transport.c @@ -90,6 +90,54 @@ static const struct fwk_element element_table[MOD_TRANSPORT_ELEMENT_COUNT] = { MOD_MHU3_API_IDX_TRANSPORT_DRIVER), }), }, + [SCP_CFGD_MOD_TRANSPORT_EIDX_RSE_SCMI_MSG_SEND_CH] = { + .name = "SCP_RSE_SCMI_MSG_SEND_CH", + .data = &(( + struct mod_transport_channel_config) { + .transport_type = MOD_TRANSPORT_CHANNEL_TRANSPORT_TYPE_OUT_BAND, + .policies = MOD_TRANSPORT_POLICY_INIT_MAILBOX | + MOD_TRANSPORT_POLICY_SECURE, + .channel_type = MOD_TRANSPORT_CHANNEL_TYPE_REQUESTER, + .out_band_mailbox_address = + (uintptr_t) SCP_RSE_SCMI_MSG_PAYLOAD_BASE, + .out_band_mailbox_size = SCP_RSE_SCMI_MSG_PAYLOAD_SIZE, + .signal_api_id = + FWK_ID_API_INIT( + FWK_MODULE_IDX_SCMI, + MOD_SCMI_API_IDX_TRANSPORT), + .driver_id = + FWK_ID_SUB_ELEMENT_INIT( + FWK_MODULE_IDX_MHU3, + SCP_CFGD_MOD_MHU3_EIDX_SCP_RSS_S, + 2), + .driver_api_id = + FWK_ID_API_INIT( + FWK_MODULE_IDX_MHU3, + MOD_MHU3_API_IDX_TRANSPORT_DRIVER), + }), + }, + [SCP_CFGD_MOD_TRANSPORT_EIDX_RSE_SCMI_MSG_RECV_CH] = { + .name = "SCP_RSE_SCMI_MSG_RECV_CH", + .data = &(( + struct mod_transport_channel_config) { + .transport_type = MOD_TRANSPORT_CHANNEL_TRANSPORT_TYPE_OUT_BAND, + .policies = MOD_TRANSPORT_POLICY_INIT_MAILBOX | + MOD_TRANSPORT_POLICY_SECURE, + .channel_type = MOD_TRANSPORT_CHANNEL_TYPE_COMPLETER, + .out_band_mailbox_address = + (uintptr_t) SCP_RSE_SCMI_MSG_PAYLOAD_BASE, + .out_band_mailbox_size = SCP_RSE_SCMI_MSG_PAYLOAD_SIZE, + .driver_id = + FWK_ID_SUB_ELEMENT_INIT( + FWK_MODULE_IDX_MHU3, + SCP_CFGD_MOD_MHU3_EIDX_SCP_RSS_S, + 2), + .driver_api_id = + FWK_ID_API_INIT( + FWK_MODULE_IDX_MHU3, + MOD_MHU3_API_IDX_TRANSPORT_DRIVER), + }), + }, [SCP_CFGD_MOD_TRANSPORT_EIDX_MCP_SCMI_MSG_SEND_CH] = { .name = "SCP_MCP_SCMI_MSG_SEND_CH", .data = &(( diff --git a/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_transport.h b/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_transport.h index f10ca8d60..155b59a0a 100644 --- a/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_transport.h +++ b/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_transport.h @@ -16,6 +16,8 @@ enum scp_cfgd_mod_transport_element_idx { SCP_CFGD_MOD_TRANSPORT_EIDX_PSCI, SCP_CFGD_MOD_TRANSPORT_EIDX_SYSTEM, + SCP_CFGD_MOD_TRANSPORT_EIDX_RSE_SCMI_MSG_SEND_CH, + SCP_CFGD_MOD_TRANSPORT_EIDX_RSE_SCMI_MSG_RECV_CH, SCP_CFGD_MOD_TRANSPORT_EIDX_MCP_SCMI_MSG_SEND_CH, SCP_CFGD_MOD_TRANSPORT_EIDX_MCP_SCMI_MSG_RECV_CH, SCP_CFGD_MOD_TRANSPORT_EIDX_COUNT, diff --git a/product/neoverse-rd/rdv3/scp_ramfw/include/scp_fw_mmap.h b/product/neoverse-rd/rdv3/scp_ramfw/include/scp_fw_mmap.h index a4dbfba67..c3493909f 100644 --- a/product/neoverse-rd/rdv3/scp_ramfw/include/scp_fw_mmap.h +++ b/product/neoverse-rd/rdv3/scp_ramfw/include/scp_fw_mmap.h @@ -73,4 +73,8 @@ #define SCP_MCP_SCMI_MSG_PAYLOAD_BASE \ (SCP_SHARED_SRAM_RSM_BASE + SCP_MCP_SCMI_MSG_PAYLOAD_OFFSET) +/* Payload Area for SCP-RSE outband message */ +#define SCP_RSE_SCMI_MSG_PAYLOAD_BASE \ + (SCP_SHARED_SRAM_RSM_BASE + SCP_RSE_SCMI_MSG_PAYLOAD_OFFSET) + #endif /* SCP_FW_MMAP_H */ -- GitLab From 687047535b829c2a201dcbb7172b7b3504952799 Mon Sep 17 00:00:00 2001 From: Pranav Madhu Date: Tue, 13 Feb 2024 20:05:16 +0530 Subject: [PATCH 19/22] nrd/rdv3: add SCP-RSE SCMI channel Add SCMI channel between SCP and RSE. SCP will use this channel to inform shutdown/reboot request to RSE. Change-Id: I0d7a0292dc0340831d8dd5ff517a04c85308edb7 Signed-off-by: Pranav Madhu --- .../neoverse-rd/rdv3/scp_ramfw/config_scmi.c | 38 +++++++++++++++++++ .../rdv3/scp_ramfw/include/scp_cfgd_scmi.h | 6 +++ 2 files changed, 44 insertions(+) diff --git a/product/neoverse-rd/rdv3/scp_ramfw/config_scmi.c b/product/neoverse-rd/rdv3/scp_ramfw/config_scmi.c index 3b70ef1b8..5ba386354 100644 --- a/product/neoverse-rd/rdv3/scp_ramfw/config_scmi.c +++ b/product/neoverse-rd/rdv3/scp_ramfw/config_scmi.c @@ -40,6 +40,22 @@ static const struct fwk_element service_table[MOD_SCMI_ELEMENT_COUNT] = { .scmi_p2a_id = FWK_ID_NONE_INIT, }), }, + [SCP_CFGD_MOD_SCMI_EIDX_RSE_SCMI_SEND] = { + .name = "SCP_RSE_SCMI_SEND", + .data = &((struct mod_scmi_service_config) { + .transport_id = FWK_ID_ELEMENT_INIT( + FWK_MODULE_IDX_TRANSPORT, + SCP_CFGD_MOD_TRANSPORT_EIDX_RSE_SCMI_MSG_SEND_CH), + .transport_api_id = FWK_ID_API_INIT( + FWK_MODULE_IDX_TRANSPORT, + MOD_TRANSPORT_API_IDX_SCMI_TO_TRANSPORT), + .transport_notification_init_id = FWK_ID_NOTIFICATION_INIT( + FWK_MODULE_IDX_TRANSPORT, + MOD_TRANSPORT_NOTIFICATION_IDX_INITIALIZED), + .scmi_agent_id = SCP_SCMI_AGENT_IDX_RSE, + .scmi_p2a_id = FWK_ID_NONE_INIT, + }), + }, [SCP_CFGD_MOD_SCMI_EIDX_MCP_SCMI_SEND] = { .name = "SCP_MCP_SCMI_SEND", .data = &((struct mod_scmi_service_config) { @@ -57,6 +73,24 @@ static const struct fwk_element service_table[MOD_SCMI_ELEMENT_COUNT] = { }), }, #ifdef BUILD_HAS_SCMI_NOTIFICATIONS + [SCP_CFGD_MOD_SCMI_EIDX_RSE_SCMI_RECV] = { + .name = "SCP_RSE_SCMI_RECV", + .data = &((struct mod_scmi_service_config) { + .transport_id = FWK_ID_ELEMENT_INIT( + FWK_MODULE_IDX_TRANSPORT, + SCP_CFGD_MOD_TRANSPORT_EIDX_RSE_SCMI_MSG_RECV_CH), + .transport_api_id = FWK_ID_API_INIT( + FWK_MODULE_IDX_TRANSPORT, + MOD_TRANSPORT_API_IDX_SCMI_TO_TRANSPORT), + .transport_notification_init_id = FWK_ID_NOTIFICATION_INIT( + FWK_MODULE_IDX_TRANSPORT, + MOD_TRANSPORT_NOTIFICATION_IDX_INITIALIZED), + .scmi_agent_id = SCP_SCMI_AGENT_IDX_RSE, + .scmi_p2a_id = FWK_ID_ELEMENT_INIT( + FWK_MODULE_IDX_SCMI, + SCP_CFGD_MOD_SCMI_EIDX_RSE_SCMI_SEND), + }), + }, [SCP_CFGD_MOD_SCMI_EIDX_MCP_SCMI_RECV] = { .name = "SCP_MCP_SCMI_RECV", .data = &((struct mod_scmi_service_config) { @@ -89,6 +123,10 @@ static struct mod_scmi_agent agent_table[SCP_SCMI_AGENT_IDX_COUNT] = { .type = SCMI_AGENT_TYPE_PSCI, .name = "PSCI", }, + [SCP_SCMI_AGENT_IDX_RSE] = { + .type = SCMI_AGENT_TYPE_MANAGEMENT, + .name = "RSE", + }, [SCP_SCMI_AGENT_IDX_MCP] = { .type = SCMI_AGENT_TYPE_MANAGEMENT, .name = "MCP", diff --git a/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_scmi.h b/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_scmi.h index 7004f14c6..7d849e3ff 100644 --- a/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_scmi.h +++ b/product/neoverse-rd/rdv3/scp_ramfw/include/scp_cfgd_scmi.h @@ -11,10 +11,13 @@ #ifndef SCP_CFGD_SCMI_H #define SCP_CFGD_SCMI_H +#include + /* SCMI agent identifier indexes in the SCMI agent table */ enum scp_scmi_agent_idx { /* 0 is reserved for the platform */ SCP_SCMI_AGENT_IDX_PSCI = 1, + SCP_SCMI_AGENT_IDX_RSE, SCP_SCMI_AGENT_IDX_MCP, SCP_SCMI_AGENT_IDX_COUNT, }; @@ -23,8 +26,10 @@ enum scp_scmi_agent_idx { enum scp_cfgd_mod_scmi_element_idx { SCP_CFGD_MOD_SCMI_EIDX_PSCI, SCP_CFGD_MOD_SCMI_EIDX_MCP_SCMI_SEND, + SCP_CFGD_MOD_SCMI_EIDX_RSE_SCMI_SEND, #ifdef BUILD_HAS_SCMI_NOTIFICATIONS SCP_CFGD_MOD_SCMI_EIDX_MCP_SCMI_RECV, + SCP_CFGD_MOD_SCMI_EIDX_RSE_SCMI_RECV, #endif SCP_CFGD_MOD_SCMI_EIDX_COUNT, }; @@ -32,6 +37,7 @@ enum scp_cfgd_mod_scmi_element_idx { /* SCMI protocol requester agents */ enum scmi_protocol_requester { SCMI_PROTOCOL_REQUESTER_MCP, + SCMI_PROTOCOL_REQUESTER_RSE, SCMI_PROTOCOL_REQUESTER_COUNT }; -- GitLab From c14180549e8cc3409e868b5ebedbc5b50c55bdb4 Mon Sep 17 00:00:00 2001 From: Pranav Madhu Date: Tue, 13 Feb 2024 18:14:11 +0530 Subject: [PATCH 20/22] nrd/rdv3: platform module to bind with SCP-RSE SCMI channel SCP platform module to bind with SCP-RSE SCMI channel. SCP uses this channel to report shutdown and cold reboot requests to RSE. The current implementation of RSE do not support SCMI. This patch can be removed once SCMI support is enabled in RSE. In that scenario, RSE will subscribe to the system power-down notifications, which will then be handled directly by the SCP SCMI module. Change-Id: Ib912ddb668c88ed036d0876c0824ae743ff06bdd Signed-off-by: Pranav Madhu --- .../rdv3/module/scp_platform/CMakeLists.txt | 2 +- .../scp_platform/src/platform_power_mgmt.c | 20 ++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/product/neoverse-rd/rdv3/module/scp_platform/CMakeLists.txt b/product/neoverse-rd/rdv3/module/scp_platform/CMakeLists.txt index dd9fd41d0..3de394575 100644 --- a/product/neoverse-rd/rdv3/module/scp_platform/CMakeLists.txt +++ b/product/neoverse-rd/rdv3/module/scp_platform/CMakeLists.txt @@ -39,5 +39,5 @@ target_sources( target_link_libraries( ${SCP_MODULE_TARGET} - PRIVATE module-power-domain module-system-power + PRIVATE module-power-domain module-system-power module-scmi module-system-info module-transport module-timer) diff --git a/product/neoverse-rd/rdv3/module/scp_platform/src/platform_power_mgmt.c b/product/neoverse-rd/rdv3/module/scp_platform/src/platform_power_mgmt.c index b0053388d..177848b6d 100644 --- a/product/neoverse-rd/rdv3/module/scp_platform/src/platform_power_mgmt.c +++ b/product/neoverse-rd/rdv3/module/scp_platform/src/platform_power_mgmt.c @@ -1,6 +1,6 @@ /* * Arm SCP/MCP Software - * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause * @@ -8,9 +8,13 @@ * SCP Platform Support - Power Management */ +#include "scp_cfgd_scmi.h" + #include #include +#include +#include #include #include @@ -18,6 +22,9 @@ #include +/*! SCMI protocol API */ +static const struct mod_scmi_from_protocol_req_api *scmi_protocol_req_api; + /* Module 'power_domain' restricted API pointer */ static struct mod_pd_restricted_api *pd_restricted_api; @@ -43,6 +50,17 @@ const void *get_platform_system_power_driver_api(void) int platform_power_mgmt_bind(void) { + int status; + + /* Bind to SCMI module for RSE communication */ + status = fwk_module_bind( + FWK_ID_MODULE(FWK_MODULE_IDX_SCMI), + FWK_ID_API(FWK_MODULE_IDX_SCMI, MOD_SCMI_API_IDX_PROTOCOL_REQ), + &scmi_protocol_req_api); + if (status != FWK_SUCCESS) { + return status; + } + return fwk_module_bind( fwk_module_id_power_domain, mod_pd_api_id_restricted, -- GitLab From 0d0700c81203698bdd3a273018044480b8f4a496 Mon Sep 17 00:00:00 2001 From: Pranav Madhu Date: Tue, 13 Feb 2024 18:51:52 +0530 Subject: [PATCH 21/22] nrd/rdv3: SCMI module to bind back to SCP platform module When SCP platform module binds to SCMI module, SCMI module will try to bind back to platform module. Add support for the bind back APIs. The current implementation of RSE do not support SCMI. This patch can be removed once SCMI support is enabled in RSE. In that scenario, RSE will subscribe to the system power-down notifications, which will then be handled directly by the SCP SCMI module. Change-Id: Ib41a414f29797c9e9d7c5bade56f5f4cb6403c24 Signed-off-by: Pranav Madhu --- .../include/internal/scp_platform.h | 13 ++++++ .../scp_platform/include/mod_scp_platform.h | 5 ++- .../scp_platform/src/mod_scp_platform.c | 7 ++- .../scp_platform/src/platform_power_mgmt.c | 43 +++++++++++++++++++ 4 files changed, 66 insertions(+), 2 deletions(-) diff --git a/product/neoverse-rd/rdv3/module/scp_platform/include/internal/scp_platform.h b/product/neoverse-rd/rdv3/module/scp_platform/include/internal/scp_platform.h index f2074218c..2568f4174 100644 --- a/product/neoverse-rd/rdv3/module/scp_platform/include/internal/scp_platform.h +++ b/product/neoverse-rd/rdv3/module/scp_platform/include/internal/scp_platform.h @@ -92,6 +92,19 @@ int platform_setup_lcp(void); */ const void *get_platform_system_power_driver_api(void); +/* + * SCMI interface helper functions. + */ + +/*! + * \brief Helper function to return platform system SCMI API. + * + * \param None. + * + * \return Pointer to the SCP platform system SCMI API. + */ +const void *get_platform_scmi_power_down_api(void); + /*! * \brief Helper function to bind to power domain restricted API. * diff --git a/product/neoverse-rd/rdv3/module/scp_platform/include/mod_scp_platform.h b/product/neoverse-rd/rdv3/module/scp_platform/include/mod_scp_platform.h index 0743b3dfd..17d62ce26 100644 --- a/product/neoverse-rd/rdv3/module/scp_platform/include/mod_scp_platform.h +++ b/product/neoverse-rd/rdv3/module/scp_platform/include/mod_scp_platform.h @@ -1,6 +1,6 @@ /* * Arm SCP/MCP Software - * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause * @@ -31,6 +31,9 @@ * \brief Indices of the interfaces exposed by the module. */ enum mod_scp_platform_api_idx { + /*! API index for the powerdown interface of SCMI module */ + MOD_SCP_PLATFORM_API_IDX_SCMI_POWER_DOWN, + /*! API index for the driver interface of the SYSTEM POWER module */ MOD_SCP_PLATFORM_API_IDX_SYSTEM_POWER_DRIVER, diff --git a/product/neoverse-rd/rdv3/module/scp_platform/src/mod_scp_platform.c b/product/neoverse-rd/rdv3/module/scp_platform/src/mod_scp_platform.c index 56cdcad6a..74a4d8bae 100644 --- a/product/neoverse-rd/rdv3/module/scp_platform/src/mod_scp_platform.c +++ b/product/neoverse-rd/rdv3/module/scp_platform/src/mod_scp_platform.c @@ -1,6 +1,6 @@ /* * Arm SCP/MCP Software - * Copyright (c) 2025, Arm Limited and Contributors. All rights reserved. + * Copyright (c) 2024-2025, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause * @@ -110,6 +110,11 @@ static int scp_platform_process_bind_request( api_id_type = (enum mod_scp_platform_api_idx)fwk_id_get_api_idx(api_id); switch (api_id_type) { + case MOD_SCP_PLATFORM_API_IDX_SCMI_POWER_DOWN: + *api = get_platform_scmi_power_down_api(); + status = FWK_SUCCESS; + break; + case MOD_SCP_PLATFORM_API_IDX_SYSTEM_POWER_DRIVER: *api = get_platform_system_power_driver_api(); status = FWK_SUCCESS; diff --git a/product/neoverse-rd/rdv3/module/scp_platform/src/platform_power_mgmt.c b/product/neoverse-rd/rdv3/module/scp_platform/src/platform_power_mgmt.c index 177848b6d..7c78ef60d 100644 --- a/product/neoverse-rd/rdv3/module/scp_platform/src/platform_power_mgmt.c +++ b/product/neoverse-rd/rdv3/module/scp_platform/src/platform_power_mgmt.c @@ -48,6 +48,49 @@ const void *get_platform_system_power_driver_api(void) return &platform_system_pwr_drv_api; } +/* + * SCMI module -> SCP platform module interface + */ +static int platform_system_get_scmi_protocol_id( + fwk_id_t protocol_id, + uint8_t *scmi_protocol_id) +{ + *scmi_protocol_id = (uint8_t)MOD_SCMI_PROTOCOL_ID_SYS_POWER; + + return FWK_SUCCESS; +} + +/* + * Upon binding the scp_platform module to the SCMI module, the SCMI module + * will also bind back to the scp_platform module, anticipating the presence of + * .get_scmi_protocol_id() and .message_handler() APIs. + * + * In the current implementation of scp_platform module, only sending SCMI + * message is implemented, and the scp_platform module is not intended to + * receive any SCMI messages. Therefore, it is necessary to include a minimal + * .message_handler() API to ensure the successful binding of the SCMI module. + */ +static int platform_system_scmi_message_handler( + fwk_id_t protocol_id, + fwk_id_t service_id, + const uint32_t *payload, + size_t payload_size, + unsigned int message_id) +{ + return FWK_SUCCESS; +} + +/* SCMI driver interface */ +static const struct mod_scmi_to_protocol_api platform_system_scmi_api = { + .get_scmi_protocol_id = platform_system_get_scmi_protocol_id, + .message_handler = platform_system_scmi_message_handler, +}; + +const void *get_platform_scmi_power_down_api(void) +{ + return &platform_system_scmi_api; +} + int platform_power_mgmt_bind(void) { int status; -- GitLab From 3bf86376bfd5aea592bdebb56f26e5bf96425d42 Mon Sep 17 00:00:00 2001 From: Pranav Madhu Date: Thu, 21 Dec 2023 17:47:35 +0530 Subject: [PATCH 22/22] nrd/rdv3: report power down to RSE Add support in SCP to report a shutdown or cold reboot to RSE. SCP uses MHU outband communication, and uses SCMI messaging format to communicate with RSE. The current implementation of RSE do not support SCMI. This patch can be removed once SCMI support is enabled in RSE. In that scenario, RSE will subscribe to the system power-down notifications, which will then be handled directly by the SCP SCMI module. Change-Id: I8c7f75c7d5714e381ee8b60e1e86ccd2f93a19e9 Signed-off-by: Pranav Madhu --- product/neoverse-rd/common/include/nrd_scmi.h | 10 ++++++ .../scp_platform/src/platform_power_mgmt.c | 33 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/product/neoverse-rd/common/include/nrd_scmi.h b/product/neoverse-rd/common/include/nrd_scmi.h index 0bd7c97e7..b9b48cf4b 100644 --- a/product/neoverse-rd/common/include/nrd_scmi.h +++ b/product/neoverse-rd/common/include/nrd_scmi.h @@ -26,6 +26,16 @@ enum nrd_scmi_system_state { NRD_SCMI_SYSTEM_STATE_COUNT, }; +/* + * SCMI payload for scmi sytem power protocol, message id + * SYSTEM_POWER_STATE_SET + * This will be removed once SCMI support is enabled at RSE + */ +struct scp_cfgd_scmi_sys_power_state_set_payload { + uint32_t flags; + uint32_t system_state; +}; + /* * SCMI payload for scmi sytem power protocol, message id * SYSTEM_POWER_STATE_NOTIFY diff --git a/product/neoverse-rd/rdv3/module/scp_platform/src/platform_power_mgmt.c b/product/neoverse-rd/rdv3/module/scp_platform/src/platform_power_mgmt.c index 7c78ef60d..a238bd703 100644 --- a/product/neoverse-rd/rdv3/module/scp_platform/src/platform_power_mgmt.c +++ b/product/neoverse-rd/rdv3/module/scp_platform/src/platform_power_mgmt.c @@ -8,6 +8,7 @@ * SCP Platform Support - Power Management */ +#include "nrd_scmi.h" #include "scp_cfgd_scmi.h" #include @@ -17,6 +18,7 @@ #include #include +#include #include #include @@ -31,6 +33,37 @@ static struct mod_pd_restricted_api *pd_restricted_api; /* System shutdown function */ static int platform_shutdown(enum mod_pd_system_shutdown system_shutdown) { + int status; + fwk_id_t rse_scmi_prot_id = FWK_ID_ELEMENT( + FWK_MODULE_IDX_SCMI, SCP_CFGD_MOD_SCMI_EIDX_RSE_SCMI_SEND); + struct scp_cfgd_scmi_sys_power_state_set_payload scp_scmi_payload; + + scp_scmi_payload.flags = 0; + scp_scmi_payload.system_state = (uint32_t)system_shutdown; + + /* + * The current RSE firmware lacks SCMI support, preventing the RSE platform + * firmware from sending SCMI power state notify messages to the SCP or + * subscribing to SCMI notifications. To address this limitation, notify + * the RSE about system power down using the SCMI system power state set + * message. As this message can be decoded in the RSE firmware with minimal + * SCMI message parsing logic. + */ + status = scmi_protocol_req_api->scmi_send_message( + MOD_SCMI_SYS_POWER_STATE_SET, + MOD_SCMI_PROTOCOL_ID_SYS_POWER, + 0, + rse_scmi_prot_id, + (void *)&scp_scmi_payload, + sizeof(scp_scmi_payload), + false); + + if (status != FWK_SUCCESS) { + FWK_LOG_ERR( + "[SCP_PLATFORM] ERROR! Unable to send shutdown request to RSE"); + return status; + } + while (1) { __WFI(); } -- GitLab