From 1522d76c9df97e9bb9e994afff455e013b6f56fa Mon Sep 17 00:00:00 2001 From: Andres Lugo-Reyes Date: Tue, 26 Sep 2017 13:10:19 -0500 Subject: Prevent Over-Current scenario caused by vdd ratio calculations Change-Id: I3faf6590d9ad430cf2926caeb669082fda77dce2 RTC:180234 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/46758 Reviewed-by: Martha Broyles Reviewed-by: Christopher J. Cain Tested-by: FSP CI Jenkins Reviewed-by: William A. Bryan --- src/occ_405/errl/errl.h | 1 + src/occ_405/wof/wof.c | 69 +++++++++++++++++++++++++++++++++++++++---------- src/occ_405/wof/wof.h | 10 ++++--- 3 files changed, 63 insertions(+), 17 deletions(-) diff --git a/src/occ_405/errl/errl.h b/src/occ_405/errl/errl.h index 882c348..3f8c460 100755 --- a/src/occ_405/errl/errl.h +++ b/src/occ_405/errl/errl.h @@ -296,6 +296,7 @@ typedef enum { ERRH_GPE0_NOT_IDLE = 0x16, ERRH_GPE1_NOT_IDLE = 0x17, ERRH_24X7_DISABLED = 0x18, + ERRH_CEFF_RATIO_VDD_EXCURSION = 0x19, } ERR_HISTORY_INDEX; #define INCREMENT_ERR_HISTORY(errorIndex) { \ if ((errorIndex < ERR_HISTORY_SIZE) && (G_error_history[errorIndex] < 255)) { \ diff --git a/src/occ_405/wof/wof.c b/src/occ_405/wof/wof.c index f2b5c3e..09ad7b0 100644 --- a/src/occ_405/wof/wof.c +++ b/src/occ_405/wof/wof.c @@ -325,15 +325,15 @@ void call_wof_main( void ) } /** - * wof_main + * wof_main * - * Description: Main Wof algorithm + * Description: Main Wof algorithm * - * Param: None + * Param: None * - * Return: None + * Return: None */ -void wof_main(void) +void wof_main( void ) { // Read out the sensor data needed for calculations @@ -390,17 +390,17 @@ void wof_main(void) } /** - * calculate_step_from_start + * calculate_step_from_start * - * Description: Calculates the step number for the current VDN/VDD + * Description: Calculates the step number for the current VDN/VDD * - * Param[in]: i_ceff_vdx_ratio - The current Ceff_vdd or Ceff_vdn_ratio - * to calculate the step for. - * Param[in]: i_step_size - The size of each step. - * Param[in]: i_min_ceff - The minimum step number for this VDN/VDD - * Param[in]: i_max_step - The maximum step number for this VDN/VDD + * Param[in]: i_ceff_vdx_ratio - The current Ceff_vdd or Ceff_vdn_ratio + * to calculate the step for. + * Param[in]: i_step_size - The size of each step. + * Param[in]: i_min_ceff - The minimum step number for this VDN/VDD + * Param[in]: i_max_step - The maximum step number for this VDN/VDD * - * Return: The calculated step for current Ceff_vdd/Ceff_vdn + * Return: The calculated step for current Ceff_vdd/Ceff_vdn */ uint16_t calculate_step_from_start(uint16_t i_ceff_vdx_ratio, uint16_t i_step_size, @@ -1119,7 +1119,9 @@ void calculate_ceff_ratio_vdd( void ) else { // Save ceff_ratio_vdd. Multiply by 10000 to convert to correct granularity. - g_wof->ceff_ratio_vdd = (g_wof->ceff_vdd*10000) / g_wof->ceff_tdp_vdd; + // Prevent Over current by clipping to max of 100% + g_wof->ceff_ratio_vdd = + prevent_over_current((g_wof->ceff_vdd*10000) / g_wof->ceff_tdp_vdd); } } @@ -2062,3 +2064,42 @@ void print_oppb( void ) CMDH_TRAC_INFO("vdn_sysparm.distloss = %d", G_oppb.vdn_sysparm.distloss_uohm); CMDH_TRAC_INFO("End OCCPstateParmBlock"); } + +/** + * prevent_over_current + * + * Description: Determines whether ceff_ratio_vdd will cause an over-current + * and clips it to a ratio of 1.0 if necessary. + * + * Param: Calculated ceff_ratio before clipping at 1.0 + * + * Return: Clipped ceff_ratio + */ +uint32_t prevent_over_current( uint32_t i_ceff_ratio ) +{ + static uint8_t L_oc_prevention_timer = 0; + uint32_t l_clipped_ratio = i_ceff_ratio; + + if( i_ceff_ratio > MAX_CEFF_RATIO ) // 10000 = 1.0 ratio + { + INCREMENT_ERR_HISTORY( ERRH_CEFF_RATIO_VDD_EXCURSION ); + l_clipped_ratio = MAX_CEFF_RATIO; + + // If over current timer not started, start it. + if( L_oc_prevention_timer == 0 ) + { + L_oc_prevention_timer = 10; // 10 WOF iterations + } + else + { + L_oc_prevention_timer--; + } + } + else if( L_oc_prevention_timer != 0 ) // Timer is running + { + l_clipped_ratio = MAX_CEFF_RATIO; + L_oc_prevention_timer--; + } + + return l_clipped_ratio; +} diff --git a/src/occ_405/wof/wof.h b/src/occ_405/wof/wof.h index c0bcd77..162c9d7 100644 --- a/src/occ_405/wof/wof.h +++ b/src/occ_405/wof/wof.h @@ -37,7 +37,9 @@ #define PGPE_WOF_OFF 0 #define PGPE_WOF_ON 1 #define NUM_CORES_PER_QUAD 4 -#define WOF_TABLES_OFFSET 0xC0000// Relative to PPMR_ADDRESS_HOMER +#define WOF_TABLES_OFFSET 0xC0000 // Relative to PPMR_ADDRESS_HOMER +#define MAX_CEFF_RATIO 10000 // 1.0 ratio = 10000 + // (scaled to avoid floating point) //****************************************************************************** // Bit Vector Masks //****************************************************************************** @@ -437,7 +439,9 @@ uint32_t scale_and_interpolate( uint16_t * i_leak_arr, uint16_t i_base_temp, uint16_t i_voltage ); -void print_data(void); +void print_data( void ); -void print_oppb(void); +void print_oppb( void ); + +uint32_t prevent_over_current( uint32_t i_ceff_ratio ); #endif -- cgit v1.2.1