diff options
Diffstat (limited to 'src/import/chips/ocmb/common/procedures/hwp/pmic/lib/utils/pmic_bias_utils.H')
-rw-r--r-- | src/import/chips/ocmb/common/procedures/hwp/pmic/lib/utils/pmic_bias_utils.H | 120 |
1 files changed, 115 insertions, 5 deletions
diff --git a/src/import/chips/ocmb/common/procedures/hwp/pmic/lib/utils/pmic_bias_utils.H b/src/import/chips/ocmb/common/procedures/hwp/pmic/lib/utils/pmic_bias_utils.H index 58757e249..64fd9fdcf 100644 --- a/src/import/chips/ocmb/common/procedures/hwp/pmic/lib/utils/pmic_bias_utils.H +++ b/src/import/chips/ocmb/common/procedures/hwp/pmic/lib/utils/pmic_bias_utils.H @@ -30,13 +30,18 @@ // *HWP HWP Owner: Mark Pizzutillo <mark.pizzutillo@ibm.com> // *HWP HWP Backup: Louis Stermole <stermole@us.ibm.com> // *HWP Team: Memory -// *HWP Level: 1 +// *HWP Level: 2 // *HWP Consumed by: FSP:HB #ifndef __PMIC_BIAS_UTILS_H__ #define __PMIC_BIAS_UTILS_H__ #include <fapi2.H> +#include <lib/utils/pmic_consts.H> +#include <lib/utils/pmic_common_utils.H> +#include <pmic_regs.H> +#include <pmic_regs_fld.H> +#include <generic/memory/lib/utils/c_str.H> namespace mss { @@ -49,12 +54,16 @@ namespace pmic enum setting { // We order these by rail in groups of 4 so they match with the rail enums, - // so the rail can be derived from just a % 4 when we have more settings to change + // so the rail can be derived from just a % 4 when we have more settings to change (see current) SWA_VOLT = 0, SWB_VOLT = 1, SWC_VOLT = 2, SWD_VOLT = 3, - NO_SETTING = 4, + // SWA_CURRENT = 4, + // SWB_CURRENT = 5, + // .. + // .. + NO_SETTING = 8, }; /// @@ -67,7 +76,108 @@ enum unit PERCENT = 2, }; -}// pmic -}// mss +// Max bias % change that the procedure will allow without override flag +static constexpr float PERCENT_MAX_BIAS = 10.0; + +//-------- JEDEC SPECIFIC HELPER FUNCS ---------// + +/// +/// @brief Set the voltage of a rail (post-rounding) +/// +/// @param[in] i_pmic_target PMIC target +/// @param[in] i_rail rail to set +/// @param[in] i_target_voltage voltage to set to +/// @param[in] i_range_selection range (0 or 1) of the rail +/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS iff success +/// +fapi2::ReturnCode set_new_rail_voltage( + const fapi2::Target<fapi2::TargetType::TARGET_TYPE_PMIC>& i_pmic_target, + const mss::pmic::rail i_rail, + const uint32_t i_target_voltage, + const uint8_t i_range_selection); + +/// +/// @brief round a target rail voltage to the nearest step of 5mV to create the voltage bitmap +/// +/// @param[in] l_target_voltage_unrounded unrounded voltage +/// @return uint32_t rounded voltage +/// +uint32_t round_rail_target_voltage(const uint32_t l_target_voltage_unrounded); + +/// +/// @brief Checks if bias percentage is within the MAX_BIAS threshold +/// +/// @param[in] i_percent percentage to check +/// @param[in] i_force force change (would force evaluation to true) +/// @return true if in range, false if not +/// +bool bias_percent_within_threshold(const float i_percent, const bool i_force); + +/// +/// @brief Get the current rail voltage of a JEDEC PMIC +/// +/// @param[in] i_pmic_target PMIC target +/// @param[in] i_rail rail to read from +/// @param[out] o_current_rail_voltage voltage calculated for rail +/// @param[out] o_range_selection range selection of that voltage +/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS iff success, else error +/// @note not templated as the arguments may differ for other chips (if we ever use others) +/// +fapi2::ReturnCode get_current_rail_voltage(const fapi2::Target<fapi2::TargetType::TARGET_TYPE_PMIC>& + i_pmic_target, + const mss::pmic::rail i_rail, + uint32_t& o_current_rail_voltage, + uint8_t& o_range_selection); + +//-------------- HELPER FUNCTIONS --------------// + +/// +/// @brief Set the voltage percent on the specified rail of a PMIC device +/// +/// @param[in] i_pmic_target PMIC target +/// @param[in] i_rail rail to bias +/// @param[in] i_percent percentage change +/// @param[in] i_force override 10% change limit +/// @return fapi2::ReturnCode fapi2::FAPI2_RC_SUCCESS iff success +/// +fapi2::ReturnCode set_voltage_percent(const fapi2::Target<fapi2::TargetType::TARGET_TYPE_PMIC>& i_pmic_target, + const mss::pmic::rail i_rail, + const float i_percent, + const bool i_force); + +/// +/// @brief Set the voltage of a rail by a value +/// +/// @param[in] i_pmic_target PMIC to bias +/// @param[in] i_rail rail to bias +/// @param[in] i_value value to set to +/// @param[in] i_force override 10% change limit +/// @return fapi2::ReturnCode fapi2::FAPI2_RC_SUCCESS iff success +/// +fapi2::ReturnCode set_voltage_value(const fapi2::Target<fapi2::TargetType::TARGET_TYPE_PMIC>& i_pmic_target, + const mss::pmic::rail i_rail, + const float i_value, + const bool i_force); + +//------------------- BIAS FUNCTIONS -----------------// + +/// +/// @brief Bias a chip with the given settings +/// +/// @param[in] i_pmic_target - the pmic_target +/// @param[in] i_setting setting to change (swa_volt, swb_volt, etc.) +/// @param[in] i_amount amount to change by +/// @param[in] i_unit percentage or value +/// @param[in] i_force ignore 10% change limit +/// @return fapi2::ReturnCode FAPI2_RC_SUCCESS iff success +/// +fapi2::ReturnCode bias_chip(const fapi2::Target<fapi2::TargetType::TARGET_TYPE_PMIC>& i_pmic_target, + const mss::pmic::setting i_setting, + const float i_amount, + const mss::pmic::unit i_unit, + const bool i_force); + +} // pmic +} // mss #endif |