diff options
author | Pedro Custodio <Pedro.Krewinkelcustodio@arm.com> | 2018-08-14 16:29:43 +0100 |
---|---|---|
committer | ronald-cron-arm <39518861+ronald-cron-arm@users.noreply.github.com> | 2019-01-08 17:14:25 +0000 |
commit | 0781160f25533736e59f441833044e0ee88d732b (patch) | |
tree | 291afd2ee2ec19aec39f91263ac15674fe9abb6b | |
parent | c5c4eec25b45dcd3212186abad78e1b642b21a2d (diff) |
module: SID support
Co-authored-by: Chris Kay <chris.kay@arm.com>
Change-Id: I9c4e4db2885fd9f214d69fbc259156a39235df7e
Signed-off-by: Elieva Pignat <Elieva.Pignat@arm.com>
Signed-off-by: Chris Kay <chris.kay@arm.com>
-rw-r--r-- | module/sid/include/mod_sid.h | 123 | ||||
-rw-r--r-- | module/sid/src/Makefile | 11 | ||||
-rw-r--r-- | module/sid/src/mod_sid.c | 116 | ||||
-rw-r--r-- | module/sid/src/sid_reg.h | 41 |
4 files changed, 291 insertions, 0 deletions
diff --git a/module/sid/include/mod_sid.h b/module/sid/include/mod_sid.h new file mode 100644 index 00000000..54e0446d --- /dev/null +++ b/module/sid/include/mod_sid.h @@ -0,0 +1,123 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2017-2019, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef MOD_SID_H +#define MOD_SID_H + +#include <stdint.h> +#include <fwk_id.h> +#include <fwk_module_idx.h> +#include <mod_pcid.h> + +/*! + * \addtogroup GroupModules Modules + * @{ + */ + +/*! + * \defgroup GroupModuleSID System Identification (SID) + * + * \brief Module used to interface with the SID register set. + * + * \details This module uses the SID register set to get information about the + * subsystem that the firmware is running on. @{ + */ + +/*! + * \brief Module API indicies. + */ +enum mod_sid_api_idx { + MOD_SID_API_IDX_INFO, /*!< Index of the info api. */ + MOD_SID_API_COUNT, /*!< Number of apis. */ +}; + +/*! + * \brief Info API id. + */ +static const fwk_id_t mod_sid_api_id_info = + FWK_ID_API_INIT(FWK_MODULE_IDX_SID, MOD_SID_API_IDX_INFO); + +/*! + * \brief System information + */ +struct mod_sid_info { + /*! Major revision number of the subsystem */ + unsigned int system_major_revision; + + /*! Minor revision number of the subsystem */ + unsigned int system_minor_revision; + + /*! Designer ID of the subsystem */ + unsigned int system_designer_id; + + /*! Part number of the subsystem */ + unsigned int system_part_number; + + /*! Major revision number of the SoC */ + unsigned int soc_major_revision; + + /*! Minor revision number of the SoC */ + unsigned int soc_minor_revision; + + /*! Designer ID of the SoC */ + unsigned int soc_designer_id; + + /*! Part number of the SoC */ + unsigned int soc_part_number; + + /*! ID for the node when there are multiple sockets */ + unsigned int node_id; + + /*! Configuration number of the subsystem */ + unsigned int config_number; + + /*! Name of the subsystem */ + const char *name; + + /*! Element index of the subsystem */ + unsigned int system_idx; +}; + +/*! + * \brief Module configuration. + */ +struct mod_sid_config { + /*! Base address of the SID registers. */ + uintptr_t sid_base; + + /*! Expected values of the PID and CID registers */ + struct mod_pcid_registers pcid_expected; +}; + +/*! + * \brief Subsystem configuration. + */ +struct mod_sid_subsystem_config { + unsigned int part_number; /*!< Part number of the subsystem */ +}; + +/*! + * \brief Module interface. + */ +struct mod_sid_api_info { + /*! + * \brief Get a pointer to the structure holding the system information. + * + * \return Pointer to system information structure. + */ + const struct mod_sid_info * (*get_system_info)(void); +}; + +/*! + * @} + */ + +/*! + * @} + */ + +#endif /* MOD_SID_H */ diff --git a/module/sid/src/Makefile b/module/sid/src/Makefile new file mode 100644 index 00000000..4549c344 --- /dev/null +++ b/module/sid/src/Makefile @@ -0,0 +1,11 @@ +# +# Arm SCP/MCP Software +# Copyright (c) 2017-2019, Arm Limited and Contributors. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +BS_LIB_NAME := SID +BS_LIB_SOURCES := mod_sid.c + +include $(BS_DIR)/lib.mk diff --git a/module/sid/src/mod_sid.c b/module/sid/src/mod_sid.c new file mode 100644 index 00000000..9dfae234 --- /dev/null +++ b/module/sid/src/mod_sid.c @@ -0,0 +1,116 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2017-2019, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include <fwk_assert.h> +#include <fwk_id.h> +#include <fwk_module.h> +#include <fwk_module_idx.h> +#include <fwk_mm.h> +#include <mod_pcid.h> +#include <mod_sid.h> +#include <sid_reg.h> + +static struct mod_sid_info info; + +static const struct mod_sid_info* get_system_info(void) +{ + return &info; +} + +static const struct mod_sid_api_info info_api = { + .get_system_info = get_system_info, +}; + +static int sid_init( + fwk_id_t module_id, + unsigned int element_count, + const void *data) +{ + const struct mod_sid_config *config = data; + struct sid_reg *sid_reg; + + if ((config == NULL) || (config->sid_base == 0) || (element_count == 0)) { + assert(false); + return FWK_E_DATA; + } + + sid_reg = (struct sid_reg *)config->sid_base; + + assert(mod_pcid_check_registers(&sid_reg->pcid, &config->pcid_expected)); + + info.system_major_revision = + (sid_reg->SYSTEM_ID & SID_SYS_SOC_ID_MAJOR_REVISION_MASK) + >> SID_SYS_SOC_ID_MAJOR_REVISION_POS; + + info.system_minor_revision = + (sid_reg->SYSTEM_ID & SID_SYS_SOC_ID_MINOR_REVISION_MASK) + >> SID_SYS_SOC_ID_MINOR_REVISION_POS; + + info.system_designer_id = + (sid_reg->SYSTEM_ID & SID_SYS_SOC_ID_DESIGNER_ID_MASK) + >> SID_SYS_SOC_ID_DESIGNER_ID_POS; + + info.system_part_number = + sid_reg->SYSTEM_ID & SID_SYS_SOC_ID_PART_NUMBER_MASK; + + info.soc_major_revision = + (sid_reg->SOC_ID & SID_SYS_SOC_ID_MAJOR_REVISION_MASK) + >> SID_SYS_SOC_ID_MAJOR_REVISION_POS; + + info.soc_minor_revision = + (sid_reg->SOC_ID & SID_SYS_SOC_ID_MINOR_REVISION_MASK) + >> SID_SYS_SOC_ID_MINOR_REVISION_POS; + + info.soc_designer_id = + (sid_reg->SOC_ID & SID_SYS_SOC_ID_DESIGNER_ID_MASK) + >> SID_SYS_SOC_ID_DESIGNER_ID_POS; + + info.soc_part_number = sid_reg->SOC_ID & SID_SYS_SOC_ID_PART_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; +} + +static int sid_subsystem_init( + fwk_id_t subsystem_id, + unsigned int unused, + const void *data) +{ + const struct mod_sid_subsystem_config *subsystem_config; + + assert(data != NULL); + + subsystem_config = data; + if (subsystem_config->part_number == info.system_part_number) { + info.system_idx = fwk_id_get_element_idx(subsystem_id); + info.name = fwk_module_get_name( + FWK_ID_ELEMENT(FWK_MODULE_IDX_SID, info.system_idx)); + } + + return FWK_SUCCESS; +} + +static int sid_proc_bind_req( + fwk_id_t requester_id, + fwk_id_t id, + fwk_id_t api_id, + const void **api) +{ + *api = &info_api; + return FWK_SUCCESS; +} + +const struct fwk_module module_sid = { + .name = "SID", + .type = FWK_MODULE_TYPE_DRIVER, + .api_count = MOD_SID_API_COUNT, + .init = sid_init, + .element_init = sid_subsystem_init, + .process_bind_request = sid_proc_bind_req, +}; diff --git a/module/sid/src/sid_reg.h b/module/sid/src/sid_reg.h new file mode 100644 index 00000000..f9cf0d65 --- /dev/null +++ b/module/sid/src/sid_reg.h @@ -0,0 +1,41 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2017-2019, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef SID_REG_H +#define SID_REG_H + +#include <stdint.h> +#include <fwk_macros.h> +#include <mod_pcid.h> + +struct sid_reg { + uint8_t RESERVED0[0x40 - 0]; + FWK_R uint32_t SYSTEM_ID; + uint8_t RESERVED1[0x50 - 0x44]; + FWK_R uint32_t SOC_ID; + uint8_t RESERVED2[0x60 - 0x54]; + FWK_R uint32_t NODE_ID; + uint8_t RESERVED3[0x70 - 0x64]; + FWK_R uint32_t SYSTEM_CFG; + uint8_t RESERVED4[0xFD0 - 0x74]; + const struct mod_pcid_registers pcid; +}; + +#define SID_SYS_SOC_ID_PART_NUMBER_MASK UINT32_C(0xFFF) + +#define SID_SYS_SOC_ID_DESIGNER_ID_MASK UINT32_C(0xFF000) +#define SID_SYS_SOC_ID_DESIGNER_ID_POS UINT32_C(12) + +#define SID_SYS_SOC_ID_MINOR_REVISION_MASK UINT32_C(0xF00000) +#define SID_SYS_SOC_ID_MINOR_REVISION_POS UINT32_C(20) + +#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) + +#endif /* SID_REG_H */ |