From 48abe5e8afb54e389f45233e66e100a501d038e8 Mon Sep 17 00:00:00 2001 From: Mark Pizzutillo Date: Mon, 26 Aug 2019 18:02:37 -0400 Subject: Add support for new pmic sequencing SPD fields Change-Id: I8847090585161375fbb2c0ef853cffed80a67cc3 Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/82961 Tested-by: FSP CI Jenkins Reviewed-by: Louis Stermole Reviewed-by: STEPHEN GLANCY Tested-by: Jenkins Server Tested-by: Hostboot CI Tested-by: HWSV CI Reviewed-by: Jennifer A Stofer Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/83375 Tested-by: Jenkins OP Build CI Tested-by: Jenkins OP HW Reviewed-by: Christian R Geddes --- .../memory/lib/spd/common/dimm_module_decoder.H | 22 +++++++++ .../memory/lib/spd/ddimm/ddr4/ddimm_decoder_ddr4.H | 52 +++++++++++----------- src/import/generic/memory/lib/spd/spd_facade.H | 26 +++++++++++ .../generic/memory/lib/spd/spd_fields_ddr4.H | 24 +++++----- .../generic/memory/lib/spd/spd_traits_ddr4.H | 16 +++---- src/import/generic/memory/lib/utils/find.H | 20 +++++++++ src/import/generic/memory/lib/utils/index.H | 17 +++++++ 7 files changed, 131 insertions(+), 46 deletions(-) (limited to 'src/import/generic') diff --git a/src/import/generic/memory/lib/spd/common/dimm_module_decoder.H b/src/import/generic/memory/lib/spd/common/dimm_module_decoder.H index c8ab503ec..b1c47aa3f 100644 --- a/src/import/generic/memory/lib/spd/common/dimm_module_decoder.H +++ b/src/import/generic/memory/lib/spd/common/dimm_module_decoder.H @@ -1491,6 +1491,28 @@ class dimm_module_decoder return fapi2::FAPI2_RC_SUCCESS; } + /// + /// @brief Decodes PMIC0 Sequence Order + /// @param[out] o_output encoding from SPD + /// @return FAPI2_RC_SUCCESS if okay + /// + virtual fapi2::ReturnCode sequence_pmic0(uint8_t& o_output) const + { + o_output = 0; + return fapi2::FAPI2_RC_SUCCESS; + } + + /// + /// @brief Decodes PMIC1 Sequence Order + /// @param[out] o_output encoding from SPD + /// @return FAPI2_RC_SUCCESS if okay + /// + virtual fapi2::ReturnCode sequence_pmic1(uint8_t& o_output) const + { + o_output = 0; + return fapi2::FAPI2_RC_SUCCESS; + } + /// /// @brief Decodes DRAM Manufacturer ID code /// @param[out] o_value dram manufacturing id code diff --git a/src/import/generic/memory/lib/spd/ddimm/ddr4/ddimm_decoder_ddr4.H b/src/import/generic/memory/lib/spd/ddimm/ddr4/ddimm_decoder_ddr4.H index 7c1b4f5c9..b72fde057 100644 --- a/src/import/generic/memory/lib/spd/ddimm/ddr4/ddimm_decoder_ddr4.H +++ b/src/import/generic/memory/lib/spd/ddimm/ddr4/ddimm_decoder_ddr4.H @@ -641,19 +641,6 @@ class decoder< DDR4, DDIMM_MODULE, R > : public dimm_module_decoder return fapi2::current_err; } - /// - /// @brief Decodes VDD_Core PMIC0 -> VDD_CORE_PMIC0 - /// @param[out] o_output encoding from SPD - /// @return FAPI2_RC_SUCCESS if okay - /// - virtual fapi2::ReturnCode vdd_core_pmic0(uint8_t& o_output) const override - { - FAPI_TRY( (mss::spd::reader(iv_target, iv_data, o_output)) ); - - fapi_try_exit: - return fapi2::current_err; - } - /// /// @brief Decodes PMIC0 Manfacture ID code 2nd byte /// @param[out] o_output encoding from SPD - multiple fields used @@ -695,19 +682,6 @@ class decoder< DDR4, DDIMM_MODULE, R > : public dimm_module_decoder return fapi2::current_err; } - /// - /// @brief Decodes VDD_Core PMIC1 -> VDD_CORE_PMIC1 - /// @param[out] o_output encoding from SPD - /// @return FAPI2_RC_SUCCESS if okay - /// - virtual fapi2::ReturnCode vdd_core_pmic1(uint8_t& o_output) const override - { - FAPI_TRY( (mss::spd::reader(iv_target, iv_data, o_output)) ); - - fapi_try_exit: - return fapi2::current_err; - } - /// /// @brief Decodes PMIC1 Manfacture ID code 2nd byte /// @param[out] o_output encoding from SPD - multiple fields used @@ -1399,6 +1373,32 @@ class decoder< DDR4, DDIMM_MODULE, R > : public dimm_module_decoder return fapi2::current_err; } + /// + /// @brief Decodes PMIC1 Sequence -> PMIC0_SEQUENCE + /// @param[out] o_output encoding from SPD + /// @return FAPI2_RC_SUCCESS if okay + /// + virtual fapi2::ReturnCode sequence_pmic0(uint8_t& o_output) const override + { + FAPI_TRY((mss::spd::reader(iv_target, iv_data, o_output))); + + fapi_try_exit: + return fapi2::current_err; + } + + /// + /// @brief Decodes PMIC1 Sequence -> PMIC1_SEQUENCE + /// @param[out] o_output encoding from SPD + /// @return FAPI2_RC_SUCCESS if okay + /// + virtual fapi2::ReturnCode sequence_pmic1(uint8_t& o_output) const override + { + FAPI_TRY((mss::spd::reader(iv_target, iv_data, o_output))); + + fapi_try_exit: + return fapi2::current_err; + } + /// /// @brief Decodes DRAM manufacturing ID Code /// @param[out] o_output encoding from SPD diff --git a/src/import/generic/memory/lib/spd/spd_facade.H b/src/import/generic/memory/lib/spd/spd_facade.H index 009059c09..d28138dba 100644 --- a/src/import/generic/memory/lib/spd/spd_facade.H +++ b/src/import/generic/memory/lib/spd/spd_facade.H @@ -2417,6 +2417,19 @@ class facade final return fapi2::current_err; } + /// + /// @brief Decodes PMIC0 Sequence -> PMIC0_SEQUENCE + /// @param[out] o_output encoding from SPD + /// @return FAPI2_RC_SUCCESS if okay + /// + fapi2::ReturnCode sequence_pmic0(uint8_t& o_output) const + { + FAPI_TRY( iv_dimm_module_decoder->sequence_pmic0(o_output) ); + + fapi_try_exit: + return fapi2::current_err; + } + /// /// @brief Decodes PMIC1 SWA Voltage Setting -> PMIC1_SWA_VOLT_SET /// @param[out] o_output encoding from SPD @@ -2741,6 +2754,19 @@ class facade final fapi_try_exit: return fapi2::current_err; } + + /// + /// @brief Decodes PMIC0 Sequence -> PMIC0_SEQUENCE + /// @param[out] o_output encoding from SPD + /// @return FAPI2_RC_SUCCESS if okay + /// + fapi2::ReturnCode sequence_pmic1(uint8_t& o_output) const + { + FAPI_TRY( iv_dimm_module_decoder->sequence_pmic1(o_output) ); + + fapi_try_exit: + return fapi2::current_err; + } }; /// diff --git a/src/import/generic/memory/lib/spd/spd_fields_ddr4.H b/src/import/generic/memory/lib/spd/spd_fields_ddr4.H index 194eba510..b60e69222 100644 --- a/src/import/generic/memory/lib/spd/spd_fields_ddr4.H +++ b/src/import/generic/memory/lib/spd/spd_fields_ddr4.H @@ -959,10 +959,10 @@ class fields VIN_BULK_ENDURANT_START = 6, VIN_BULK_ENDURANT_LEN = 2, - // Byte 226: VDD_Core PMIC0 - VDD_CORE_PMIC0_BYTE = 226, - VDD_CORE_PMIC0_START = 0, - VDD_CORE_PMIC0_LEN = 8, + // Byte 226: PMIC0 Sequence + PMIC0_SEQUENCE_BYTE = 226, + PMIC0_SEQUENCE_START = 0, + PMIC0_SEQUENCE_LEN = 8, // Byte 227: PMIC0 Manfacture ID code 1st byte PMIC0_MFG_CODE1_BYTE = 227, @@ -979,10 +979,10 @@ class fields PMIC0_REV_START = 0, PMIC0_REV_LEN = 8, - // Byte 230: VDD_Core PMIC1 - VDD_CORE_PMIC1_BYTE = 230, - VDD_CORE_PMIC1_START = 0, - VDD_CORE_PMIC1_LEN = 8, + // Byte 230: PMIC1 Sequence + PMIC1_SEQUENCE_BYTE = 230, + PMIC1_SEQUENCE_START = 0, + PMIC1_SEQUENCE_LEN = 8, // Byte 231: PMIC1 Manfacture ID code 1st byte PMIC1_MFG_CODE1_BYTE = 231, @@ -1288,8 +1288,8 @@ class fields static constexpr field_t VIN_BULK_OPERABLE{VIN_BULK_BYTE, VIN_BULK_OPERABLE_START, VIN_BULK_OPERABLE_LEN}; static constexpr field_t VIN_BULK_ENDURANT{VIN_BULK_BYTE, VIN_BULK_ENDURANT_START, VIN_BULK_ENDURANT_LEN}; - // Byte 226: VDD_Core PMIC0 - static constexpr field_t VDD_CORE_PMIC0{VDD_CORE_PMIC0_BYTE, VDD_CORE_PMIC0_START, VDD_CORE_PMIC0_LEN}; + // Byte 226: PMIC0 Sequence + static constexpr field_t PMIC0_SEQUENCE{PMIC0_SEQUENCE_BYTE, PMIC0_SEQUENCE_START, PMIC0_SEQUENCE_LEN}; // Byte 227: PMIC0 Manfacture ID code 1st byte static constexpr field_t PMIC0_CONT_CODE{PMIC0_MFG_CODE1_BYTE, PMIC0_CONT_CODE_START, PMIC0_CONT_CODE_LEN}; @@ -1300,8 +1300,8 @@ class fields // Byte 229: PMIC0 Revision Number static constexpr field_t PMIC0_REV{PMIC0_REV_BYTE, PMIC0_REV_START, PMIC0_REV_LEN}; - // Byte 230: VDD_Core PMIC1 - static constexpr field_t VDD_CORE_PMIC1{VDD_CORE_PMIC1_BYTE, VDD_CORE_PMIC1_START, VDD_CORE_PMIC1_LEN}; + // Byte 230: PMIC1 Sequence + static constexpr field_t PMIC1_SEQUENCE{PMIC1_SEQUENCE_BYTE, PMIC1_SEQUENCE_START, PMIC1_SEQUENCE_LEN}; // Byte 231: PMIC1 Manfacture ID code 1st byte static constexpr field_t PMIC1_CONT_CODE{PMIC1_MFG_CODE1_BYTE, PMIC1_CONT_CODE_START, PMIC1_CONT_CODE_LEN}; diff --git a/src/import/generic/memory/lib/spd/spd_traits_ddr4.H b/src/import/generic/memory/lib/spd/spd_traits_ddr4.H index eb0fde595..a26ab64e3 100644 --- a/src/import/generic/memory/lib/spd/spd_traits_ddr4.H +++ b/src/import/generic/memory/lib/spd/spd_traits_ddr4.H @@ -4450,16 +4450,16 @@ class readerTraits < fields< DDR4, DDIMM_MODULE>::VIN_BULK_ENDURANT, R > /// @class readerTraits /// @brief trait structure to hold static SPD information /// @tparam R the revision of the SPD field -/// @note VDD_CORE_PMIC0 field specialization +/// @note PMIC0_SEQUENCE field specialization /// @note valid for all revs /// template< rev R > -class readerTraits < fields< DDR4, DDIMM_MODULE>::VDD_CORE_PMIC0, R > +class readerTraits < fields< DDR4, DDIMM_MODULE>::PMIC0_SEQUENCE, R > { public: - static constexpr size_t COMPARISON_VAL = 0xff; - static constexpr const char* FIELD_STR = "VDD_Core PMIC0"; + static constexpr size_t COMPARISON_VAL = 0x4; + static constexpr const char* FIELD_STR = "PMIC0 Sequence"; template using COMPARISON_OP = std::less_equal; @@ -4526,16 +4526,16 @@ class readerTraits < fields< DDR4, DDIMM_MODULE>::PMIC0_REV, R > /// @class readerTraits /// @brief trait structure to hold static SPD information /// @tparam R the revision of the SPD field -/// @note VDD_CORE_PMIC1 field specialization +/// @note PMIC1_SEQUENCE field specialization /// @note valid for all revs /// template< rev R > -class readerTraits < fields< DDR4, DDIMM_MODULE>::VDD_CORE_PMIC1, R > +class readerTraits < fields< DDR4, DDIMM_MODULE>::PMIC1_SEQUENCE, R > { public: - static constexpr size_t COMPARISON_VAL = 0xff; - static constexpr const char* FIELD_STR = "VDD_Core PMIC1"; + static constexpr size_t COMPARISON_VAL = 0x04; + static constexpr const char* FIELD_STR = "PMIC1 Sequence"; template using COMPARISON_OP = std::less_equal; diff --git a/src/import/generic/memory/lib/utils/find.H b/src/import/generic/memory/lib/utils/find.H index f96252913..dd5a6dbfd 100644 --- a/src/import/generic/memory/lib/utils/find.H +++ b/src/import/generic/memory/lib/utils/find.H @@ -39,10 +39,12 @@ #include #include #include +#include #include namespace mss { + /// /// @brief Helper to find a set of elements based on a fapi2 target /// @tparam M the target type to be returned @@ -257,6 +259,24 @@ find_targets( const fapi2::Target& i_target, return l_ports; } +/// +/// @brief Helper to find a set of elements based on a fapi2 target, then sort them +/// @tparam M the target type to be returned +/// @tparam T the fapi2 target type of the argument +/// @param[in] i_target the fapi2 target T +/// @param[in] i_state [optional] fapi2 target state (defaults to TARGET_STATE_FUNCTIONAL) +/// @return a vector of M targets sorted by mss::index. +/// @note this uses mss::index so the targets will be sorted via ATTR_REL_POS of their immediate parent +/// +template< fapi2::TargetType M, fapi2::TargetType T > +static inline std::vector< fapi2::Target > find_targets_sorted_by_index( const fapi2::Target& i_target, + fapi2::TargetState i_state = fapi2::TARGET_STATE_FUNCTIONAL ) +{ + std::vector> l_targets = find_targets(i_target, i_state); + sort_targets_by_index(l_targets); + return l_targets; +} + /// /// @brief find a key value from a vector of STL pairs /// @tparam T input type diff --git a/src/import/generic/memory/lib/utils/index.H b/src/import/generic/memory/lib/utils/index.H index fde43f711..1657a9e18 100644 --- a/src/import/generic/memory/lib/utils/index.H +++ b/src/import/generic/memory/lib/utils/index.H @@ -73,6 +73,23 @@ fapi_try_exit: return 0; } +/// +/// @brief Sort the provided target vector in order of index (low to high) +/// +/// @tparam T TargetType +/// @param[in,out] io_targets vector of targets to sort +/// +template +inline void sort_targets_by_index(std::vector>& io_targets) +{ + std::sort(io_targets.begin(), io_targets.end(), [] ( + const fapi2::Target& l_first_target, + const fapi2::Target& l_second_target) -> bool + { + return mss::index(l_first_target) < mss::index(l_first_target); + }); +} + /// /// @brief Return an attribute array index from a rank number /// @param[in] i_rank uint64_t a rank number DIMM0 {0, 1, 2, 3} DIMM1 {0, 1, 2, 3} -- cgit v1.2.1