From fc07dd9a33bdee931b9689c2f3d5d4d437e24aff Mon Sep 17 00:00:00 2001 From: Vijayenthiran Subramaniam Date: Tue, 29 Jan 2019 15:22:22 +0530 Subject: [PATCH 1/8] sid: add node-number and multi-chip mode to module info In order to uniquely identify every chip or socket on a multi-chip platform, the SID controller provides information about the muti-chip mode and node-number (chip-id). Add support in SID module to include node-number and multi-chip mode in the exported module info. Change-Id: Ie0ddae4366f52467308553cae9905720df8ecfd3 Signed-off-by: Vijayenthiran Subramaniam --- module/sid/include/mod_sid.h | 7 +++++-- module/sid/src/mod_sid.c | 5 ++++- module/sid/src/sid_reg.h | 4 +++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/module/sid/include/mod_sid.h b/module/sid/include/mod_sid.h index 655bea3b6..b79cf027e 100644 --- a/module/sid/include/mod_sid.h +++ b/module/sid/include/mod_sid.h @@ -55,8 +55,11 @@ struct mod_sid_info { /*! Part number of the SoC */ unsigned int soc_part_number; - /*! ID for the node when there are multiple sockets */ - unsigned int node_id; + /*! Multi-chip mode tie-off value - enabled or disabled */ + bool multi_chip_mode; + + /*! Node number indicating the chip id in multi socket system */ + uint8_t node_number; /*! Configuration number of the subsystem */ unsigned int config_number; diff --git a/module/sid/src/mod_sid.c b/module/sid/src/mod_sid.c index c6d7a4b3a..80de6c1bb 100644 --- a/module/sid/src/mod_sid.c +++ b/module/sid/src/mod_sid.c @@ -74,8 +74,11 @@ static int sid_init( info.soc_part_number = sid_reg->SOC_ID & SID_SYS_SOC_ID_PART_NUMBER_MASK; + info.multi_chip_mode = (sid_reg->NODE_ID & SID_SYS_MULTI_CHIP_MODE_MASK) + >> SID_SYS_MULTI_CHIP_MODE_POS; + info.node_number = sid_reg->NODE_ID & SID_SYS_NODE_NUMBER_MASK; + info.config_number = sid_reg->SYSTEM_CFG; - info.node_id = sid_reg->NODE_ID & SID_SYS_NODE_ID_IDENTIFIER_MASK; return FWK_SUCCESS; } diff --git a/module/sid/src/sid_reg.h b/module/sid/src/sid_reg.h index f24f8cd37..bfeb97a90 100644 --- a/module/sid/src/sid_reg.h +++ b/module/sid/src/sid_reg.h @@ -36,6 +36,8 @@ struct sid_reg { #define SID_SYS_SOC_ID_MAJOR_REVISION_MASK UINT32_C(0xF000000) #define SID_SYS_SOC_ID_MAJOR_REVISION_POS UINT32_C(24) -#define SID_SYS_NODE_ID_IDENTIFIER_MASK UINT32_C(0xFF) +#define SID_SYS_NODE_NUMBER_MASK UINT32_C(0xFF) +#define SID_SYS_MULTI_CHIP_MODE_MASK UINT32_C(0x100) +#define SID_SYS_MULTI_CHIP_MODE_POS UINT32_C(8) #endif /* SID_REG_H */ -- GitLab From d575e6177986ee6bf0d1400b217c096174c1df88 Mon Sep 17 00:00:00 2001 From: Vijayenthiran Subramaniam Date: Wed, 16 Oct 2019 22:22:34 +0530 Subject: [PATCH 2/8] module: add system id information module Add System ID Information hardware abstraction module which provides an generic interface for modules that generate the System ID information and modules that consume this information. This module expects one register interface driver module (like SID or SSC) to provide a generic information about the system. A module requesting for system information can bind to this module to get that information. Change-Id: Ifd2ada0b8f8278043dd89d5ef0be0ca7f1f0edad Signed-off-by: Vijayenthiran Subramaniam --- module/system_info/include/mod_system_info.h | 124 +++++++++++++++++++ module/system_info/src/Makefile | 11 ++ module/system_info/src/mod_system_info.c | 105 ++++++++++++++++ 3 files changed, 240 insertions(+) create mode 100644 module/system_info/include/mod_system_info.h create mode 100644 module/system_info/src/Makefile create mode 100644 module/system_info/src/mod_system_info.c diff --git a/module/system_info/include/mod_system_info.h b/module/system_info/include/mod_system_info.h new file mode 100644 index 000000000..a212a816e --- /dev/null +++ b/module/system_info/include/mod_system_info.h @@ -0,0 +1,124 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef MOD_SYSTEM_INFO_H +#define MOD_SYSTEM_INFO_H + +#include + +/*! + * \addtogroup GroupModules Modules + * @{ + */ + +/*! + * \defgroup GroupModuleSystemInfo System Information Abstraction Module + * + * \brief HAL Module used to get System Information. + * + * \details This module provides an abstraction layer to the modules which + * need System Information. This module binds to the register interface + * driver module to obtain a pointer to the system information data. Module + * which requires system information data then can use the api provided + * by this module to get the generic system information. + * @{ + */ + +/*! + * \brief Generic System Information + * + * \details This structure holds the generic information about the current + * system. The register interface module should define this structure + * and provide a pointer to this module. + */ +struct mod_system_info { + /*! Product identification number of the system */ + uint32_t product_id; + + /*! Configuration number of the system */ + uint32_t config_id; + + /*! Multi-chip mode tie-off value - enabled or disabled */ + bool multi_chip_mode; + + /*! + * Chip id indicating unique identifier of the chip in a multi socket system + */ + uint8_t chip_id; + + /*! Name of the system */ + const char *name; +}; + +/*! + * \brief System Information configuration data + */ +struct mod_system_info_config { + /*! + * Module ID of the register interface driver module which provides a + * pointer to system information data. If the product does not support any + * driver, this can be set to FWK_ID_NONE. + */ + fwk_id_t system_info_driver_module_id; + + /*! API ID for getting the system information data from the driver module */ + fwk_id_t system_info_driver_data_api_id; +}; + +/*! + * \brief API structure to be defined by the driver module. + */ +struct mod_system_info_get_driver_data_api { + /*! + * \brief Get the system information data populated by the driver module. + * + * \details API to be implemented by the driver module which provides a + * pointer to the system information data. + * + * \retval NULL if the driver data is not initialized yet. + * \return Pointer to the system information driver data. + */ + struct mod_system_info *(*get_driver_data)(void); +}; + +/*! + * \brief API structure used by the modules requesting for the system + * information data. + */ +struct mod_system_info_get_info_api { + /*! + * \brief Get system information data. + * + * \details API to be used by the module requesting for the system + * information data. + * + * \param[out] sys_info Pointer to the system information data. + * + * \retval FWK_SUCCESS if the sys_info pointer has been successfully set. + * \retval FWK_E_SUPPORT if the system information is not supported by the + * product. + */ + int (*get_system_info)(const struct mod_system_info **sys_info); +}; + +/*! + * \brief Module API indicies. + */ +enum mod_system_info_api_idx { + MOD_SYSTEM_INFO_GET_API_IDX, + MOD_SYSTEM_INFO_API_COUNT +}; + +/*! + * @} + */ + +/*! + * @} + */ + +#endif /* MOD_SYSTEM_INFO_H */ diff --git a/module/system_info/src/Makefile b/module/system_info/src/Makefile new file mode 100644 index 000000000..d1e96d1ca --- /dev/null +++ b/module/system_info/src/Makefile @@ -0,0 +1,11 @@ +# +# Arm SCP/MCP Software +# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +BS_LIB_NAME := SYSTEM INFORMATION HAL +BS_LIB_SOURCES := mod_system_info.c + +include $(BS_DIR)/lib.mk diff --git a/module/system_info/src/mod_system_info.c b/module/system_info/src/mod_system_info.c new file mode 100644 index 000000000..581e4d8a5 --- /dev/null +++ b/module/system_info/src/mod_system_info.c @@ -0,0 +1,105 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * Description: + * System Information Hardware Abstraction module. + */ + +#include +#include +#include +#include +#include +#include + +/* Pointer to the config data for module use. */ +static const struct mod_system_info_config *config; + +/* Pointer to the data provided by the driver module. */ +static struct mod_system_info *system_info; + +/* Pointer to the driver function which provides the system info data. */ +static struct mod_system_info_get_driver_data_api *get_driver_data; + +static int get_system_info(const struct mod_system_info **sys_info) +{ + if (system_info == NULL) { + system_info = get_driver_data->get_driver_data(); + if (system_info == NULL) + return FWK_E_SUPPORT; + } + + *sys_info = system_info; + return FWK_SUCCESS; +} + +/* + * API to be used by the modules that need a copy of the system ID information + * data. + */ +static struct mod_system_info_get_info_api get_system_info_api = { + .get_system_info = get_system_info, +}; + +/* + * Framework handlers + */ +static int system_info_init(fwk_id_t module_id, unsigned int element_count, + const void *data) +{ + fwk_assert(data != NULL); + + /* No elements support */ + if (element_count > 0) + return FWK_E_DATA; + + config = data; + return FWK_SUCCESS; +} + +static int system_info_bind(fwk_id_t id, unsigned int round) +{ + int status = FWK_SUCCESS; + + if (round == 1) { + if (!fwk_id_is_equal(config->system_info_driver_module_id, + FWK_ID_NONE)) { + + /* If module ID is provided, API ID shouldn't be NONE */ + fwk_assert(!fwk_id_is_equal(config->system_info_driver_data_api_id, + FWK_ID_NONE)); + + status = fwk_module_bind(config->system_info_driver_module_id, + config->system_info_driver_data_api_id, + &get_driver_data); + if (status != FWK_SUCCESS) + return FWK_E_PANIC; + } + } + return status; +} + +static int system_info_process_bind_request(fwk_id_t requester_id, + fwk_id_t targer_id, fwk_id_t api_id, const void **api) +{ + switch (fwk_id_get_api_idx(api_id)) { + case MOD_SYSTEM_INFO_GET_API_IDX: + *api = &get_system_info_api; + break; + default: + return FWK_E_PARAM; + } + return FWK_SUCCESS; +} + +const struct fwk_module module_system_info = { + .name = "SYSTEM ID INFORMATION", + .type = FWK_MODULE_TYPE_HAL, + .init = system_info_init, + .bind = system_info_bind, + .process_bind_request = system_info_process_bind_request, + .api_count = MOD_SYSTEM_INFO_API_COUNT, +}; -- GitLab From 247309b362760bd5ae7b55cb38d0de864a24fa9e Mon Sep 17 00:00:00 2001 From: Vijayenthiran Subramaniam Date: Mon, 3 Feb 2020 13:43:15 +0530 Subject: [PATCH 3/8] sid: add api to retrieve system info data Add support for a new API that allows system_info module to retrieve the system information data. For platforms using SID module, add configuration data for system information module in order to retrieve the driver data from the SID module. Change-Id: I52bc2d76256b825816ead075933d39dfbb67abe0 Signed-off-by: Vijayenthiran Subramaniam --- module/sid/include/mod_sid.h | 8 +++++ module/sid/src/mod_sid.c | 42 +++++++++++++++++++++++ product/rddaniel/scp_ramfw/firmware.mk | 2 ++ product/rddaniel/scp_romfw/firmware.mk | 2 ++ product/rddaniel/src/config_system_info.c | 23 +++++++++++++ product/rdn1e1/scp_ramfw/firmware.mk | 2 ++ product/rdn1e1/scp_romfw/firmware.mk | 2 ++ product/rdn1e1/src/config_system_info.c | 23 +++++++++++++ product/sgm776/scp_ramfw/firmware.mk | 4 ++- product/sgm776/scp_romfw/firmware.mk | 4 ++- product/sgm776/src/config_system_info.c | 23 +++++++++++++ 11 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 product/rddaniel/src/config_system_info.c create mode 100644 product/rdn1e1/src/config_system_info.c create mode 100644 product/sgm776/src/config_system_info.c diff --git a/module/sid/include/mod_sid.h b/module/sid/include/mod_sid.h index b79cf027e..1484b16ce 100644 --- a/module/sid/include/mod_sid.h +++ b/module/sid/include/mod_sid.h @@ -103,6 +103,14 @@ struct mod_sid_subsystem_config { */ int mod_sid_get_system_info(const struct mod_sid_info **system_info); +/*! + * \brief Module API indices. + */ +enum mod_sid_api_idx { + MOD_SID_SYSTEM_INFO_DRIVER_DATA_API_IDX, + MOD_SID_API_COUNT +}; + /*! * @} */ diff --git a/module/sid/src/mod_sid.c b/module/sid/src/mod_sid.c index 80de6c1bb..2a2caedad 100644 --- a/module/sid/src/mod_sid.c +++ b/module/sid/src/mod_sid.c @@ -12,10 +12,12 @@ #include #include #include +#include #include static bool initialized; static struct mod_sid_info info; +static struct mod_system_info sys_info; int mod_sid_get_system_info(const struct mod_sid_info **system_info) { @@ -28,6 +30,24 @@ int mod_sid_get_system_info(const struct mod_sid_info **system_info) return FWK_E_INIT; } +static struct mod_system_info *get_driver_data(void) +{ + if (!initialized) + return NULL; + + return &sys_info; +} + +/* + * API for the use of system info module to get the driver data. + */ +static struct mod_system_info_get_driver_data_api get_sys_info_driver_data = { + .get_driver_data = get_driver_data +}; + +/* + * Framework Handlers + */ static int sid_init( fwk_id_t module_id, unsigned int element_count, @@ -98,15 +118,37 @@ static int sid_subsystem_init( info.name = fwk_module_get_name( FWK_ID_ELEMENT(FWK_MODULE_IDX_SID, info.system_idx)); + /* Populate the system info structure */ + sys_info.product_id = info.system_part_number; + sys_info.config_id = info.config_number; + sys_info.chip_id = info.node_number; + sys_info.multi_chip_mode = info.multi_chip_mode; + sys_info.name = info.name; + initialized = true; } return FWK_SUCCESS; } +static int sid_process_bind_request(fwk_id_t requester_id, fwk_id_t targer_id, + fwk_id_t api_id, const void **api) +{ + switch (fwk_id_get_api_idx(api_id)) { + case MOD_SID_SYSTEM_INFO_DRIVER_DATA_API_IDX: + *api = &get_sys_info_driver_data; + break; + default: + return FWK_E_PARAM; + } + return FWK_SUCCESS; +} + const struct fwk_module module_sid = { .name = "SID", .type = FWK_MODULE_TYPE_DRIVER, .init = sid_init, .element_init = sid_subsystem_init, + .process_bind_request = sid_process_bind_request, + .api_count = MOD_SID_API_COUNT, }; diff --git a/product/rddaniel/scp_ramfw/firmware.mk b/product/rddaniel/scp_ramfw/firmware.mk index ec6660256..7815fc789 100644 --- a/product/rddaniel/scp_ramfw/firmware.mk +++ b/product/rddaniel/scp_ramfw/firmware.mk @@ -13,6 +13,7 @@ BS_FIRMWARE_NOTIFICATION_COUNT := 128 BS_FIRMWARE_MODULES := \ armv7m_mpu \ sid \ + system_info \ pcid \ pl011 \ log \ @@ -38,6 +39,7 @@ BS_FIRMWARE_MODULES := \ BS_FIRMWARE_SOURCES := \ config_system_power.c \ config_sid.c \ + config_system_info.c \ rtx_config.c \ config_armv7m_mpu.c \ config_pl011.c \ diff --git a/product/rddaniel/scp_romfw/firmware.mk b/product/rddaniel/scp_romfw/firmware.mk index f6b620249..584bd2b32 100644 --- a/product/rddaniel/scp_romfw/firmware.mk +++ b/product/rddaniel/scp_romfw/firmware.mk @@ -14,6 +14,7 @@ BS_FIRMWARE_MODULE_HEADERS_ONLY := \ BS_FIRMWARE_MODULES := \ sid \ + system_info \ pcid \ pl011 \ log \ @@ -22,6 +23,7 @@ BS_FIRMWARE_MODULES := \ BS_FIRMWARE_SOURCES := \ config_sid.c \ + config_system_info.c \ config_log.c \ config_pl011.c \ config_clock.c \ diff --git a/product/rddaniel/src/config_system_info.c b/product/rddaniel/src/config_system_info.c new file mode 100644 index 000000000..6fc998050 --- /dev/null +++ b/product/rddaniel/src/config_system_info.c @@ -0,0 +1,23 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include +#include +#include + +const struct fwk_module_config config_system_info = { + .get_element_table = NULL, + .data = &((struct mod_system_info_config) { + .system_info_driver_module_id = + FWK_ID_MODULE_INIT(FWK_MODULE_IDX_SID), + .system_info_driver_data_api_id = + FWK_ID_API_INIT(FWK_MODULE_IDX_SID, + MOD_SID_SYSTEM_INFO_DRIVER_DATA_API_IDX), + }), +}; diff --git a/product/rdn1e1/scp_ramfw/firmware.mk b/product/rdn1e1/scp_ramfw/firmware.mk index 0c38df16a..6e5b5c1c5 100644 --- a/product/rdn1e1/scp_ramfw/firmware.mk +++ b/product/rdn1e1/scp_ramfw/firmware.mk @@ -13,6 +13,7 @@ BS_FIRMWARE_MODULE_HEADERS_ONLY := BS_FIRMWARE_MODULES := \ armv7m_mpu \ sid \ + system_info \ pcid \ pl011 \ log \ @@ -49,6 +50,7 @@ BS_FIRMWARE_MODULES := \ BS_FIRMWARE_SOURCES := \ config_system_power.c \ config_sid.c \ + config_system_info.c \ rtx_config.c \ config_armv7m_mpu.c \ config_log.c \ diff --git a/product/rdn1e1/scp_romfw/firmware.mk b/product/rdn1e1/scp_romfw/firmware.mk index ff3e6defa..d22c1ca71 100644 --- a/product/rdn1e1/scp_romfw/firmware.mk +++ b/product/rdn1e1/scp_romfw/firmware.mk @@ -14,6 +14,7 @@ BS_FIRMWARE_MODULE_HEADERS_ONLY := \ BS_FIRMWARE_MODULES := \ sid \ + system_info \ pcid \ pl011 \ log \ @@ -23,6 +24,7 @@ BS_FIRMWARE_MODULES := \ BS_FIRMWARE_SOURCES := \ config_sid.c \ + config_system_info.c \ config_log.c \ config_rdn1e1_rom.c \ config_gtimer.c \ diff --git a/product/rdn1e1/src/config_system_info.c b/product/rdn1e1/src/config_system_info.c new file mode 100644 index 000000000..6fc998050 --- /dev/null +++ b/product/rdn1e1/src/config_system_info.c @@ -0,0 +1,23 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include +#include +#include + +const struct fwk_module_config config_system_info = { + .get_element_table = NULL, + .data = &((struct mod_system_info_config) { + .system_info_driver_module_id = + FWK_ID_MODULE_INIT(FWK_MODULE_IDX_SID), + .system_info_driver_data_api_id = + FWK_ID_API_INIT(FWK_MODULE_IDX_SID, + MOD_SID_SYSTEM_INFO_DRIVER_DATA_API_IDX), + }), +}; diff --git a/product/sgm776/scp_ramfw/firmware.mk b/product/sgm776/scp_ramfw/firmware.mk index 26aca7bf8..1106405c9 100644 --- a/product/sgm776/scp_ramfw/firmware.mk +++ b/product/sgm776/scp_ramfw/firmware.mk @@ -11,6 +11,7 @@ BS_FIRMWARE_HAS_NOTIFICATION := yes BS_FIRMWARE_MODULES := \ sid \ + system_info \ pcid \ pl011 \ log \ @@ -68,6 +69,7 @@ BS_FIRMWARE_SOURCES := \ config_psu.c \ config_mock_psu.c \ config_dvfs.c \ - config_sid.c + config_sid.c \ + config_system_info.c include $(BS_DIR)/firmware.mk diff --git a/product/sgm776/scp_romfw/firmware.mk b/product/sgm776/scp_romfw/firmware.mk index 8ab120c7d..a047668e6 100644 --- a/product/sgm776/scp_romfw/firmware.mk +++ b/product/sgm776/scp_romfw/firmware.mk @@ -15,6 +15,7 @@ BS_FIRMWARE_MODULE_HEADERS_ONLY := \ BS_FIRMWARE_MODULES := \ sid \ + system_info \ pcid \ ppu_v1 \ pl011 \ @@ -40,6 +41,7 @@ BS_FIRMWARE_SOURCES := \ config_pik_clock.c \ config_css_clock.c \ config_clock.c \ - config_sid.c + config_sid.c \ + config_system_info.c include $(BS_DIR)/firmware.mk diff --git a/product/sgm776/src/config_system_info.c b/product/sgm776/src/config_system_info.c new file mode 100644 index 000000000..6fc998050 --- /dev/null +++ b/product/sgm776/src/config_system_info.c @@ -0,0 +1,23 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include +#include +#include + +const struct fwk_module_config config_system_info = { + .get_element_table = NULL, + .data = &((struct mod_system_info_config) { + .system_info_driver_module_id = + FWK_ID_MODULE_INIT(FWK_MODULE_IDX_SID), + .system_info_driver_data_api_id = + FWK_ID_API_INIT(FWK_MODULE_IDX_SID, + MOD_SID_SYSTEM_INFO_DRIVER_DATA_API_IDX), + }), +}; -- GitLab From 30dcee9c2141488d52c451e42201fc3b9357c4f8 Mon Sep 17 00:00:00 2001 From: Vijayenthiran Subramaniam Date: Wed, 8 Jan 2020 13:26:26 +0530 Subject: [PATCH 4/8] module: add initial support for ssc registers This patch adds a initial module support for Serial Security Control interface registers which is available in ARM platforms such as Juno, N1SDP and SGI-575. SSC module provides an API using which the system_info module can bind to this module and obtain the system information data. Change-Id: I36c750b1ce7d9ab044bffe50715c64cfcb366731 Signed-off-by: Vijayenthiran Subramaniam --- module/ssc/include/mod_ssc.h | 33 +++++++++++++ module/ssc/src/Makefile | 11 +++++ module/ssc/src/mod_ssc.c | 94 ++++++++++++++++++++++++++++++++++++ module/ssc/src/ssc_reg.h | 54 +++++++++++++++++++++ 4 files changed, 192 insertions(+) create mode 100644 module/ssc/include/mod_ssc.h create mode 100644 module/ssc/src/Makefile create mode 100644 module/ssc/src/mod_ssc.c create mode 100644 module/ssc/src/ssc_reg.h diff --git a/module/ssc/include/mod_ssc.h b/module/ssc/include/mod_ssc.h new file mode 100644 index 000000000..365c1687c --- /dev/null +++ b/module/ssc/include/mod_ssc.h @@ -0,0 +1,33 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef MOD_SSC_H +#define MOD_SSC_H + +/*! + * \brief Module configuration. + */ +struct mod_ssc_config { + /*! Base address of the SSC registers. */ + uintptr_t ssc_base; + + /*! Debug authentication configuration set register */ + uint32_t ssc_debug_cfg_set; + + /*! Product name */ + const char *product_name; +}; + +/*! + * \brief Module API indicies. + */ +enum mod_ssc_api_idx { + MOD_SSC_SYSTEM_INFO_DRIVER_DATA_API_IDX, + MOD_SSC_API_COUNT +}; + +#endif /* MOD_SSC_H */ diff --git a/module/ssc/src/Makefile b/module/ssc/src/Makefile new file mode 100644 index 000000000..22bd1bbd4 --- /dev/null +++ b/module/ssc/src/Makefile @@ -0,0 +1,11 @@ +# +# Arm SCP/MCP Software +# Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +BS_LIB_NAME := Serial Security Control +BS_LIB_SOURCES = mod_ssc.c + +include $(BS_DIR)/lib.mk diff --git a/module/ssc/src/mod_ssc.c b/module/ssc/src/mod_ssc.c new file mode 100644 index 000000000..8e819c076 --- /dev/null +++ b/module/ssc/src/mod_ssc.c @@ -0,0 +1,94 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +static bool initialized; +static int chip_id, multi_chip_mode, part_number, revision_number; +static struct mod_system_info sys_info; + +static struct mod_system_info *get_driver_data(void) +{ + if (!initialized) + return NULL; + + return &sys_info; +} + +/* + * API for the use of system info module to get the driver data. + */ +static struct mod_system_info_get_driver_data_api get_sys_info_driver_data = { + .get_driver_data = get_driver_data +}; + +/* + * Framework Handlers + */ +static int ssc_init(fwk_id_t module_id, unsigned int count, + const void *data) +{ + const struct mod_ssc_config *config = data; + struct ssc_reg *ssc_reg; + + if ((config == NULL) || (config->ssc_base == 0)) + return FWK_E_DATA; + + ssc_reg = (struct ssc_reg *)config->ssc_base; + + chip_id = (ssc_reg->SSC_CHIPID_ST) & SSC_CHIPID_ST_CHIP_ID_MASK; + multi_chip_mode = ((ssc_reg->SSC_CHIPID_ST) & + SSC_CHIPID_ST_MULTI_CHIP_MODE_MASK) >> + SSC_CHIPID_ST_MULTI_CHIP_MODE_POS; + part_number = (ssc_reg->PID0 & SSC_PID0_PART_NUMBER_MASK) | + ((ssc_reg->PID1 & SSC_PID1_PART_NUMBER_MASK) << + SSC_PID1_PART_NUMBER_POS); + revision_number = (ssc_reg->PID2 & SSC_PID2_REVISION_NUMBER_MASK) >> + SSC_PID2_REVISION_NUMBER_POS; + + if (config->ssc_debug_cfg_set != 0) + ssc_reg->SSC_DBGCFG_SET = config->ssc_debug_cfg_set; + + /* Populate the system info structure */ + sys_info.product_id = part_number; + sys_info.config_id = revision_number; + sys_info.chip_id = chip_id; + sys_info.multi_chip_mode = multi_chip_mode; + sys_info.name = config->product_name; + + initialized = true; + + return FWK_SUCCESS; +} + +static int ssc_process_bind_request(fwk_id_t requester_id, fwk_id_t targer_id, + fwk_id_t api_id, const void **api) +{ + switch (fwk_id_get_api_idx(api_id)) { + case MOD_SSC_SYSTEM_INFO_DRIVER_DATA_API_IDX: + *api = &get_sys_info_driver_data; + break; + default: + return FWK_E_PARAM; + } + return FWK_SUCCESS; +} + +const struct fwk_module module_ssc = { + .name = "Serial Security Control", + .type = FWK_MODULE_TYPE_DRIVER, + .init = ssc_init, + .process_bind_request = ssc_process_bind_request, + .api_count = MOD_SSC_API_COUNT, +}; diff --git a/module/ssc/src/ssc_reg.h b/module/ssc/src/ssc_reg.h new file mode 100644 index 000000000..6c36b8334 --- /dev/null +++ b/module/ssc/src/ssc_reg.h @@ -0,0 +1,54 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef SSC_REG_H +#define SSC_REG_H + +#include +#include + +/*! + * \brief System Security Control (SSC) register definitions + */ +struct ssc_reg { + uint8_t RESERVED1[0x10 - 0x0]; + FWK_R uint32_t SSC_DBGCFG_STAT; + FWK_W uint32_t SSC_DBGCFG_SET; + FWK_W uint32_t SSC_DBGCFG_CLR; + uint8_t RESERVED2[0x28 - 0x1C]; + FWK_RW uint32_t SSC_AUXDBGCFG; + uint8_t RESERVED3[0x30 - 0x2C]; + FWK_RW uint32_t SSC_GPRETN; + uint8_t RESERVED4[0x40 - 0x34]; + FWK_R uint32_t SSC_VERSION; + uint8_t RESERVED5[0x500 - 0x44]; + FWK_R uint32_t SSC_CHIPID_ST; + uint8_t RESERVED6[0xFD0 - 0x504]; + FWK_R uint32_t PID4; + uint8_t RESERVED7[0xFE0 - 0xFD4]; + FWK_R uint32_t PID0; + FWK_R uint32_t PID1; + FWK_R uint32_t PID2; + FWK_R uint32_t PID3; + FWK_R uint32_t COMPID0; + FWK_R uint32_t COMPID1; + FWK_R uint32_t COMPID2; + FWK_R uint32_t COMPID3; +}; + +#define SSC_PID0_PART_NUMBER_MASK UINT32_C(0xFF) +#define SSC_PID1_PART_NUMBER_MASK UINT32_C(0x0F) +#define SSC_PID1_PART_NUMBER_POS 8 + +#define SSC_PID2_REVISION_NUMBER_MASK UINT32_C(0xF0) +#define SSC_PID2_REVISION_NUMBER_POS 4 + +#define SSC_CHIPID_ST_CHIP_ID_MASK UINT32_C(0x3F) +#define SSC_CHIPID_ST_MULTI_CHIP_MODE_MASK UINT32_C(0x100) +#define SSC_CHIPID_ST_MULTI_CHIP_MODE_POS 8 + +#endif /* SSC_REG_H */ -- GitLab From 2eaa8561ee1b83ffa76891e84ea94d8a853dbcaa Mon Sep 17 00:00:00 2001 From: Vijayenthiran Subramaniam Date: Mon, 3 Feb 2020 15:15:19 +0530 Subject: [PATCH 5/8] product/sgi575: add config data for ssc and system info module Add configuration data of serial security control and system information module and enable them for SGI-575 platform. Change-Id: I40336cbdef2fa76b3cab6db1826a98749a85dba4 Signed-off-by: Vijayenthiran Subramaniam --- product/sgi575/scp_ramfw/config_ssc.c | 19 ++++++++++++++++ product/sgi575/scp_ramfw/config_system_info.c | 22 +++++++++++++++++++ product/sgi575/scp_ramfw/firmware.mk | 4 ++++ 3 files changed, 45 insertions(+) create mode 100644 product/sgi575/scp_ramfw/config_ssc.c create mode 100644 product/sgi575/scp_ramfw/config_system_info.c diff --git a/product/sgi575/scp_ramfw/config_ssc.c b/product/sgi575/scp_ramfw/config_ssc.c new file mode 100644 index 000000000..96cfc1d6d --- /dev/null +++ b/product/sgi575/scp_ramfw/config_ssc.c @@ -0,0 +1,19 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include +#include + +const struct fwk_module_config config_ssc = { + .get_element_table = NULL, + .data = &(struct mod_ssc_config) { + .ssc_base = SSC_BASE, + .product_name = "System Guidance for Infrastructure - 575" + }, +}; diff --git a/product/sgi575/scp_ramfw/config_system_info.c b/product/sgi575/scp_ramfw/config_system_info.c new file mode 100644 index 000000000..08884553a --- /dev/null +++ b/product/sgi575/scp_ramfw/config_system_info.c @@ -0,0 +1,22 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include +#include + +const struct fwk_module_config config_system_info = { + .get_element_table = NULL, + .data = &((struct mod_system_info_config) { + .system_info_driver_module_id = + FWK_ID_MODULE_INIT(FWK_MODULE_IDX_SSC), + .system_info_driver_data_api_id = + FWK_ID_API_INIT(FWK_MODULE_IDX_SSC, + MOD_SSC_SYSTEM_INFO_DRIVER_DATA_API_IDX), + }), +}; diff --git a/product/sgi575/scp_ramfw/firmware.mk b/product/sgi575/scp_ramfw/firmware.mk index 32aa27af2..716b18c48 100644 --- a/product/sgi575/scp_ramfw/firmware.mk +++ b/product/sgi575/scp_ramfw/firmware.mk @@ -45,6 +45,8 @@ BS_FIRMWARE_MODULES := \ scmi_perf \ scmi_power_domain \ scmi_system_power \ + ssc \ + system_info \ scmi_apcore BS_FIRMWARE_SOURCES := \ @@ -74,6 +76,8 @@ BS_FIRMWARE_SOURCES := \ config_scmi_perf.c \ config_scmi_system_power.c \ config_scmi_apcore.c \ + config_ssc.c \ + config_system_info.c \ config_apcontext.c include $(BS_DIR)/firmware.mk -- GitLab From ad7eb69c1971e8863c76fd444711af2276180b87 Mon Sep 17 00:00:00 2001 From: Vijayenthiran Subramaniam Date: Wed, 20 Nov 2019 14:33:46 +0530 Subject: [PATCH 6/8] product/n1sdp: add config data for ssc and system info module Add configuration data of serial security control and system information module and enable them for N1SDP. Change-Id: I7ea756a44f70ce443f9b1910f8fb18345ce0276b Signed-off-by: Vijayenthiran Subramaniam --- product/n1sdp/include/n1sdp_ssc.h | 44 ------------------- .../n1sdp_system/src/mod_n1sdp_system.c | 4 -- product/n1sdp/scp_ramfw/config_ssc.c | 19 ++++++++ product/n1sdp/scp_ramfw/config_system_info.c | 22 ++++++++++ product/n1sdp/scp_ramfw/firmware.mk | 4 ++ 5 files changed, 45 insertions(+), 48 deletions(-) delete mode 100644 product/n1sdp/include/n1sdp_ssc.h create mode 100644 product/n1sdp/scp_ramfw/config_ssc.c create mode 100644 product/n1sdp/scp_ramfw/config_system_info.c diff --git a/product/n1sdp/include/n1sdp_ssc.h b/product/n1sdp/include/n1sdp_ssc.h deleted file mode 100644 index 25aca0113..000000000 --- a/product/n1sdp/include/n1sdp_ssc.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Arm SCP/MCP Software - * Copyright (c) 2018-2020, Arm Limited and Contributors. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef N1SDP_SSC_H -#define N1SDP_SSC_H - -#include -#include -#include - -/*! - * \brief System Security Control (SSC) register definitions - */ -struct ssc_reg { - uint8_t RESERVED1[0x10 - 0x0]; - FWK_R uint32_t SSC_DBGCFG_STAT; - FWK_W uint32_t SSC_DBGCFG_SET; - FWK_W uint32_t SSC_DBGCFG_CLR; - uint8_t RESERVED2[0x28 - 0x1C]; - FWK_RW uint32_t SSC_AUXDBGCFG; - uint8_t RESERVED3[0x30 - 0x2C]; - FWK_RW uint32_t SSC_GPRETN; - uint8_t RESERVED4[0x40 - 0x34]; - FWK_R uint32_t SSC_VERSION; - uint8_t RESERVED5[0xFD0 - 0x44]; - FWK_R uint32_t PID4; - uint8_t RESERVED6[0xFE0 - 0xFD4]; - FWK_R uint32_t PID0; - FWK_R uint32_t PID1; - FWK_R uint32_t PID2; - FWK_R uint32_t PID3; - FWK_R uint32_t COMPID0; - FWK_R uint32_t COMPID1; - FWK_R uint32_t COMPID2; - FWK_R uint32_t COMPID3; -}; - -#define SSC ((struct ssc_reg *)SCP_SSC_BASE) - -#endif /* N1SDP_SSC_H */ diff --git a/product/n1sdp/module/n1sdp_system/src/mod_n1sdp_system.c b/product/n1sdp/module/n1sdp_system/src/mod_n1sdp_system.c index 0ead88c2c..ba403f21f 100644 --- a/product/n1sdp/module/n1sdp_system/src/mod_n1sdp_system.c +++ b/product/n1sdp/module/n1sdp_system/src/mod_n1sdp_system.c @@ -38,7 +38,6 @@ #include #include #include -#include #include /* @@ -647,9 +646,6 @@ static int n1sdp_system_start(fwk_id_t id) PIK_CLUSTER(0)->CLKFORCE_SET = 0x00000004; PIK_CLUSTER(1)->CLKFORCE_SET = 0x00000004; - /* Enable debugger access in SSC */ - SSC->SSC_DBGCFG_SET = 0x000000FF; - /* Setup CoreSight counter */ CS_CNTCONTROL->CS_CNTCR |= (1 << 0); CS_CNTCONTROL->CS_CNTCVLW = 0x00000000; diff --git a/product/n1sdp/scp_ramfw/config_ssc.c b/product/n1sdp/scp_ramfw/config_ssc.c new file mode 100644 index 000000000..191b0cad0 --- /dev/null +++ b/product/n1sdp/scp_ramfw/config_ssc.c @@ -0,0 +1,19 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include + +const struct fwk_module_config config_ssc = { + .get_element_table = NULL, + .data = &(struct mod_ssc_config) { + .ssc_base = SCP_SSC_BASE, + .ssc_debug_cfg_set = 0xFF, + .product_name = "N1 System Development Platform" + }, +}; diff --git a/product/n1sdp/scp_ramfw/config_system_info.c b/product/n1sdp/scp_ramfw/config_system_info.c new file mode 100644 index 000000000..08884553a --- /dev/null +++ b/product/n1sdp/scp_ramfw/config_system_info.c @@ -0,0 +1,22 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include +#include + +const struct fwk_module_config config_system_info = { + .get_element_table = NULL, + .data = &((struct mod_system_info_config) { + .system_info_driver_module_id = + FWK_ID_MODULE_INIT(FWK_MODULE_IDX_SSC), + .system_info_driver_data_api_id = + FWK_ID_API_INIT(FWK_MODULE_IDX_SSC, + MOD_SSC_SYSTEM_INFO_DRIVER_DATA_API_IDX), + }), +}; diff --git a/product/n1sdp/scp_ramfw/firmware.mk b/product/n1sdp/scp_ramfw/firmware.mk index d5a0c459f..cce2d4e4d 100644 --- a/product/n1sdp/scp_ramfw/firmware.mk +++ b/product/n1sdp/scp_ramfw/firmware.mk @@ -49,6 +49,8 @@ BS_FIRMWARE_MODULES := \ n1sdp_c2c \ n1sdp_remote_pd \ n1sdp_pcie \ + ssc \ + system_info \ n1sdp_system BS_FIRMWARE_SOURCES := \ @@ -56,6 +58,8 @@ BS_FIRMWARE_SOURCES := \ rtx_config.c \ n1sdp_core.c \ config_armv7m_mpu.c \ + config_ssc.c \ + config_system_info.c \ config_log.c \ config_power_domain.c \ config_ppu_v0.c \ -- GitLab From cc0d341807fcdec52fc09cff67accb8a0f9e3f49 Mon Sep 17 00:00:00 2001 From: Vijayenthiran Subramaniam Date: Tue, 31 Dec 2019 17:41:30 +0530 Subject: [PATCH 7/8] cmn600: use system info module to retrieve chip information Commit 7acbd4d8fb4d ("cmn600: expose API to read chip information from platforms") introduced an api to obtain chip information in the cmn600 module. As the system info module provides a reusable and scalable interface to obtain system information, rework the cmn600 module to use the system_info module to obtain the chip id and multi-chip information and remove the chip info api in cmn600 and its implementation from the n1sdp system module. Change-Id: I2cfa45ba9bf4632f73bc021f4779f6bc2c96d93b Signed-off-by: Vijayenthiran Subramaniam --- module/cmn600/include/internal/cmn600_ctx.h | 4 +-- module/cmn600/include/mod_cmn600.h | 24 ---------------- module/cmn600/src/mod_cmn600.c | 28 +++++++++++-------- .../n1sdp_system/include/mod_n1sdp_system.h | 3 -- .../n1sdp_system/src/mod_n1sdp_system.c | 20 ------------- product/n1sdp/scp_ramfw/config_cmn600.c | 3 -- product/rdn1e1/scp_ramfw/config_cmn600.c | 2 -- product/sgi575/scp_ramfw/config_cmn600.c | 2 -- 8 files changed, 18 insertions(+), 68 deletions(-) diff --git a/module/cmn600/include/internal/cmn600_ctx.h b/module/cmn600/include/internal/cmn600_ctx.h index 2ae3ba822..4f43b9d98 100644 --- a/module/cmn600/include/internal/cmn600_ctx.h +++ b/module/cmn600/include/internal/cmn600_ctx.h @@ -94,8 +94,8 @@ struct cmn600_ctx { /* Timer module API */ struct mod_timer_api *timer_api; - /* Chip information API */ - struct mod_cmn600_chipinfo_api *chipinfo_api; + /* Chip information */ + const struct mod_system_info *system_info; bool initialized; diff --git a/module/cmn600/include/mod_cmn600.h b/module/cmn600/include/mod_cmn600.h index 42eefc185..8d8d0cb09 100644 --- a/module/cmn600/include/mod_cmn600.h +++ b/module/cmn600/include/mod_cmn600.h @@ -143,12 +143,6 @@ struct mod_cmn600_config { /*! Identifier of the clock that this device depends on */ fwk_id_t clock_id; - /*! Module ID for getting chip ID information */ - fwk_id_t chipinfo_mod_id; - - /*! API ID for getting chip ID information */ - fwk_id_t chipinfo_api_id; - /*! * \brief HN-F with CAL support flag * \details When set to true, enables HN-F with CAL support. This flag will @@ -308,24 +302,6 @@ struct mod_cmn600_ccix_config_api { int (*enter_dvm_domain)(uint8_t link_id); }; -/*! - * \brief API to read chip information from platform - */ -struct mod_cmn600_chipinfo_api { - /*! - * \brief API to be implemented by all platforms using CMN-600. - * Used to get multichip mode and chip ID information from platform. - * - * \param chip_id Pointer to storage where chip ID is stored. - * \param multichip_enabled Pointer to storage where multichip - * flag is stored. - * - * \retval FWK_SUCCESS if the operation succeed. - * \return one of the error code otherwise. - */ - int (*get_chipinfo)(uint8_t *chip_id, bool *multichip_enabled); -}; - /*! * @} */ diff --git a/module/cmn600/src/mod_cmn600.c b/module/cmn600/src/mod_cmn600.c index 27501a11a..622d6de53 100644 --- a/module/cmn600/src/mod_cmn600.c +++ b/module/cmn600/src/mod_cmn600.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -28,6 +29,9 @@ struct cmn600_ctx *ctx; +/* Chip information API */ +struct mod_system_info_get_info_api *system_info_api; + static void process_node_hnf(struct cmn600_hnf_reg *hnf) { unsigned int logical_id; @@ -759,14 +763,13 @@ static int cmn600_bind(fwk_id_t id, unsigned int round) if (status != FWK_SUCCESS) return FWK_E_PANIC; - /* Bind to the chip information API in platform if provided */ - if (!fwk_id_is_equal(ctx->config->chipinfo_mod_id, FWK_ID_NONE)) { - status = fwk_module_bind(ctx->config->chipinfo_mod_id, - ctx->config->chipinfo_api_id, - &ctx->chipinfo_api); - if (status != FWK_SUCCESS) - return FWK_E_PANIC; - } + /* Bind to system info module to obtain multi-chip info */ + status = fwk_module_bind(FWK_ID_MODULE(FWK_MODULE_IDX_SYSTEM_INFO), + FWK_ID_API(FWK_MODULE_IDX_SYSTEM_INFO, + MOD_SYSTEM_INFO_GET_API_IDX), + &system_info_api); + if (status != FWK_SUCCESS) + return FWK_E_PANIC; } return FWK_SUCCESS; @@ -799,11 +802,12 @@ int cmn600_start(fwk_id_t id) return FWK_SUCCESS; } - if (!fwk_id_is_equal(ctx->config->chipinfo_mod_id, FWK_ID_NONE)) { - status = ctx->chipinfo_api->get_chipinfo(&chip_id, &mc_mode); - if (status != FWK_SUCCESS) - return status; + status = system_info_api->get_system_info(&ctx->system_info); + if (status == FWK_SUCCESS) { + chip_id = ctx->system_info->chip_id; + mc_mode = ctx->system_info->multi_chip_mode; } + ctx->chip_id = chip_id; ctx->log_api->log(MOD_LOG_GROUP_DEBUG, diff --git a/product/n1sdp/module/n1sdp_system/include/mod_n1sdp_system.h b/product/n1sdp/module/n1sdp_system/include/mod_n1sdp_system.h index e9f9bb026..d22767026 100644 --- a/product/n1sdp/module/n1sdp_system/include/mod_n1sdp_system.h +++ b/product/n1sdp/module/n1sdp_system/include/mod_n1sdp_system.h @@ -69,9 +69,6 @@ enum mod_n1sdp_system_api_idx { /*! API index for AP memory access */ MOD_N1SDP_SYSTEM_API_IDX_AP_MEMORY_ACCESS, - /*! API index for getting chip information */ - MOD_N1SDP_SYSTEM_API_IDX_CHIPINFO, - /*! Number of exposed interfaces */ MOD_N1SDP_SYSTEM_API_COUNT, }; diff --git a/product/n1sdp/module/n1sdp_system/src/mod_n1sdp_system.c b/product/n1sdp/module/n1sdp_system/src/mod_n1sdp_system.c index ba403f21f..6c681daf4 100644 --- a/product/n1sdp/module/n1sdp_system/src/mod_n1sdp_system.c +++ b/product/n1sdp/module/n1sdp_system/src/mod_n1sdp_system.c @@ -238,23 +238,6 @@ static const struct mod_system_power_driver_api .system_shutdown = n1sdp_system_shutdown, }; -/* - * Chip information API - */ -static int n1sdp_get_chipinfo(uint8_t *chip_id, bool *mc_mode) -{ - fwk_assert((chip_id != NULL) && (mc_mode != NULL)); - - *chip_id = n1sdp_get_chipid(); - *mc_mode = n1sdp_is_multichip_enabled(); - - return FWK_SUCCESS; -} - -static const struct mod_cmn600_chipinfo_api n1sdp_chipinfo_api = { - .get_chipinfo = n1sdp_get_chipinfo, -}; - /* * AP memory 1MB windowed access driver API */ @@ -611,9 +594,6 @@ static int n1sdp_system_process_bind_request(fwk_id_t requester_id, case MOD_N1SDP_SYSTEM_API_IDX_AP_MEMORY_ACCESS: *api = &n1sdp_system_ap_memory_access_api; break; - case MOD_N1SDP_SYSTEM_API_IDX_CHIPINFO: - *api = &n1sdp_chipinfo_api; - break; default: return FWK_E_PARAM; } diff --git a/product/n1sdp/scp_ramfw/config_cmn600.c b/product/n1sdp/scp_ramfw/config_cmn600.c index faf0e9b63..ec13271cf 100644 --- a/product/n1sdp/scp_ramfw/config_cmn600.c +++ b/product/n1sdp/scp_ramfw/config_cmn600.c @@ -176,9 +176,6 @@ const struct fwk_module_config config_cmn600 = { .chip_addr_space = UINT64_C(4) * FWK_TIB, .clock_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_CLOCK, CLOCK_IDX_INTERCONNECT), - .chipinfo_api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_N1SDP_SYSTEM, - MOD_N1SDP_SYSTEM_API_IDX_CHIPINFO), - .chipinfo_mod_id = FWK_ID_MODULE_INIT(FWK_MODULE_IDX_N1SDP_SYSTEM), .hnf_cal_mode = false, }), }; diff --git a/product/rdn1e1/scp_ramfw/config_cmn600.c b/product/rdn1e1/scp_ramfw/config_cmn600.c index 051061a5c..99540b347 100644 --- a/product/rdn1e1/scp_ramfw/config_cmn600.c +++ b/product/rdn1e1/scp_ramfw/config_cmn600.c @@ -105,8 +105,6 @@ const struct fwk_module_config config_cmn600 = { .chip_addr_space = UINT64_C(4) * FWK_TIB, .clock_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_CLOCK, CLOCK_IDX_INTERCONNECT), - .chipinfo_api_id = FWK_ID_NONE_INIT, - .chipinfo_mod_id = FWK_ID_NONE_INIT, .hnf_cal_mode = false, }), }; diff --git a/product/sgi575/scp_ramfw/config_cmn600.c b/product/sgi575/scp_ramfw/config_cmn600.c index 71052ed01..3df9bf384 100644 --- a/product/sgi575/scp_ramfw/config_cmn600.c +++ b/product/sgi575/scp_ramfw/config_cmn600.c @@ -103,8 +103,6 @@ const struct fwk_module_config config_cmn600 = { .chip_addr_space = UINT64_C(4) * FWK_TIB, .clock_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_CLOCK, CLOCK_IDX_INTERCONNECT), - .chipinfo_api_id = FWK_ID_NONE_INIT, - .chipinfo_mod_id = FWK_ID_NONE_INIT, .hnf_cal_mode = false, }), }; -- GitLab From fa074ec24ecaecc1eb31f5233d79835204adccf0 Mon Sep 17 00:00:00 2001 From: Vijayenthiran Subramaniam Date: Fri, 3 Jan 2020 19:02:37 +0530 Subject: [PATCH 8/8] product/rdn1e1: add support for dual-chip configuration RD-N1-Edge based platforms can operate in dual-chip configuration wherein two rdn1edge SoCs are connected through a high speed coherent CCIX link. This patch adds support to configure the CCIX link in CMN-600 if multi-chip mode is detected. The AP core boot is done only for the primary chip (Chip 0) and the secondary chips will be put in idle state waiting for SCMI commands. Change-Id: I18ce2fad52af50b87ca956157204960704b07b6d Signed-off-by: Vijayenthiran Subramaniam --- .../rdn1e1_system/src/mod_rdn1e1_system.c | 79 +++++++++++++++++-- product/rdn1e1/scp_ramfw/config_cmn600.c | 15 +++- 2 files changed, 85 insertions(+), 9 deletions(-) diff --git a/product/rdn1e1/module/rdn1e1_system/src/mod_rdn1e1_system.c b/product/rdn1e1/module/rdn1e1_system/src/mod_rdn1e1_system.c index ba66c7d1f..32610e313 100644 --- a/product/rdn1e1/module/rdn1e1_system/src/mod_rdn1e1_system.c +++ b/product/rdn1e1/module/rdn1e1_system/src/mod_rdn1e1_system.c @@ -18,10 +18,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -55,6 +57,12 @@ struct rdn1e1_system_ctx { /* SDS API pointer */ const struct mod_sds_api *sds_api; + + /* CMN600 CCIX config API pointer */ + struct mod_cmn600_ccix_config_api *cmn600_api; + + /* System Information HAL API pointer */ + struct mod_system_info_get_info_api *system_info_api; }; struct rdn1e1_system_isr { @@ -230,6 +238,20 @@ static int rdn1e1_system_bind(fwk_id_t id, unsigned int round) if (status != FWK_SUCCESS) return status; + status = fwk_module_bind(FWK_ID_MODULE(FWK_MODULE_IDX_CMN600), + FWK_ID_API(FWK_MODULE_IDX_CMN600, + MOD_CMN600_API_IDX_CCIX_CONFIG), + &rdn1e1_system_ctx.cmn600_api); + if (status != FWK_SUCCESS) + return status; + + status = fwk_module_bind(FWK_ID_MODULE(FWK_MODULE_IDX_SYSTEM_INFO), + FWK_ID_API(FWK_MODULE_IDX_SYSTEM_INFO, + MOD_SYSTEM_INFO_GET_API_IDX), + &rdn1e1_system_ctx.system_info_api); + if (status != FWK_SUCCESS) + return status; + return fwk_module_bind(fwk_module_id_sds, FWK_ID_API(FWK_MODULE_IDX_SDS, 0), &rdn1e1_system_ctx.sds_api); @@ -299,36 +321,79 @@ int rdn1e1_system_process_notification(const struct fwk_event *event, struct mod_pd_restricted_api *mod_pd_restricted_api; static unsigned int scmi_notification_count = 0; static bool sds_notification_received = false; + struct mod_cmn600_ccix_remote_node_config remote_config; + const struct mod_system_info *system_info; + uint8_t chip_id = 0; + bool mc_mode = false; + + status = rdn1e1_system_ctx.system_info_api->get_system_info(&system_info); + if (status == FWK_SUCCESS) { + chip_id = system_info->chip_id; + mc_mode = system_info->multi_chip_mode; + } assert(fwk_id_is_type(event->target_id, FWK_ID_TYPE_MODULE)); if (fwk_id_is_equal(event->id, mod_clock_notification_id_state_changed)) { params = (struct clock_notification_params *)event->params; + if (params->new_state != MOD_CLOCK_STATE_RUNNING) + return FWK_SUCCESS; + + /* Perform the CCIX setup if multi-chip mode is detected */ + if (mc_mode == true) { + /* Populate CCIX config data statically */ + remote_config.remote_rnf_count = 2; + remote_config.remote_sa_count = 0; + remote_config.remote_ha_count = 1; + remote_config.ccix_link_id = 0; + remote_config.remote_ha_mmap_count = 1; + remote_config.smp_mode = true; + if (chip_id == 0) { + remote_config.remote_ha_mmap[0].ha_id = 0x1; + remote_config.remote_ha_mmap[0].base = (4ULL * FWK_TIB); + } else { + remote_config.remote_ha_mmap[0].ha_id = 0x0; + remote_config.remote_ha_mmap[0].base = 0x0; + } + remote_config.remote_ha_mmap[0].size = (4ULL * FWK_TIB); + + status = rdn1e1_system_ctx.cmn600_api->set_config(&remote_config); + if (status != FWK_SUCCESS) { + rdn1e1_system_ctx.log_api->log(MOD_LOG_GROUP_ERROR, + "CCIX Setup Failed for Chip: %d!\n", chip_id); + return status; + } + rdn1e1_system_ctx.cmn600_api->exchange_protocol_credit(0); + rdn1e1_system_ctx.cmn600_api->enter_system_coherency(0); + rdn1e1_system_ctx.cmn600_api->enter_dvm_domain(0); + } /* * Initialize primary core when the system is initialized for the first * time only */ - if (params->new_state == MOD_CLOCK_STATE_RUNNING) { + if (chip_id == 0) { rdn1e1_system_ctx.log_api->log(MOD_LOG_GROUP_DEBUG, "[RDN1E1 SYSTEM] Initializing the primary core...\n"); mod_pd_restricted_api = rdn1e1_system_ctx.mod_pd_restricted_api; - status = mod_pd_restricted_api->set_composite_state_async( + status = mod_pd_restricted_api->set_composite_state_async( FWK_ID_ELEMENT(FWK_MODULE_IDX_POWER_DOMAIN, 0), false, MOD_PD_COMPOSITE_STATE(MOD_PD_LEVEL_2, 0, MOD_PD_STATE_ON, MOD_PD_STATE_ON, MOD_PD_STATE_ON)); if (status != FWK_SUCCESS) return status; - - /* Unsubscribe to the notification */ - return fwk_notification_unsubscribe(event->id, event->source_id, - event->target_id); + } else { + rdn1e1_system_ctx.log_api->log(MOD_LOG_GROUP_DEBUG, + "[RDN1E1 SYSTEM] Detected as slave chip %d, " + "Waiting for SCMI command\n", chip_id); } - return FWK_SUCCESS; + /* Unsubscribe to the notification */ + return fwk_notification_unsubscribe(event->id, event->source_id, + event->target_id); } else if (fwk_id_is_equal(event->id, mod_scmi_notification_id_initialized)) { scmi_notification_count++; diff --git a/product/rdn1e1/scp_ramfw/config_cmn600.c b/product/rdn1e1/scp_ramfw/config_cmn600.c index 99540b347..5b548dad8 100644 --- a/product/rdn1e1/scp_ramfw/config_cmn600.c +++ b/product/rdn1e1/scp_ramfw/config_cmn600.c @@ -21,6 +21,7 @@ #define DMC1_ID 0x6c #define NODE_ID_HND 0x68 #define NODE_ID_SBSX 0x64 +#define NODE_ID_CCIX 0x0 static const unsigned int snf_table[] = { DMC0_ID, /* Maps to HN-F logical node 0 */ @@ -33,10 +34,10 @@ static const struct mod_cmn600_memory_region_map mmap[] = { { /* * System cache backed region - * Map: 0x0000_0000_0000 - 0xFFFF_FFFF_FFFF (256 TB) + * Map: 0x0000_0000_0000 - 0x07FF_FFFF_FFFF (8 TB) */ .base = UINT64_C(0x000000000000), - .size = UINT64_C(256) * FWK_TIB, + .size = UINT64_C(8) * FWK_TIB, .type = MOD_CMN600_MEMORY_REGION_TYPE_SYSCACHE, }, { @@ -89,6 +90,16 @@ static const struct mod_cmn600_memory_region_map mmap[] = { .type = MOD_CMN600_MEMORY_REGION_TYPE_IO, .node_id = NODE_ID_HND, }, + { + /* + * Remote chip address space + * Map: 0x400_0000_0000 - 0x7FF_FFFF_FFFF (4 TB to 8 TB) + */ + .base = UINT64_C(0x40000000000), + .size = UINT64_C(4) * FWK_TIB, + .type = MOD_CMN600_REGION_TYPE_CCIX, + .node_id = NODE_ID_CCIX, + }, }; const struct fwk_module_config config_cmn600 = { -- GitLab