/****************************************************************************** // @file mode.c // @brief OCC Modes */ /****************************************************************************** * * @page ChangeLogs Change Logs * @section state.c STATE.C * @verbatim * * Flag Def/Fea Userid Date Description * ------- ---------- -------- ---------- ---------------------------------- * @th011 thallet 07/12/2012 Created * @th015 thallet 08/03/2012 Amec freq range set on mode change * @th022 thallet 10/03/2012 State/mode set by master occ * @th040 887069 thallet 06/11/2013 Support Nom & FFO Freq Setting for Mnfg * @gs008 894661 gjsilva 08/08/2013 Initial support for DPS-FP mode * @gs010 899888 gjsilva 09/24/2013 Process data format 0x13 from TMGT * @gs011 900661 gjsilva 09/30/2013 Make data format 0x13 required to go active * @at019 908390 alvinwan 12/05/2013 Disable DPS algorithms from running in Sapphire * @wb001 919163 wilbryan 03/06/2014 Updating error call outs, descriptions, and severities * * @endverbatim * *///*************************************************************************/ //************************************************************************* // Includes //************************************************************************* #include #include #include "ssx_io.h" #include "trac.h" #include "rtls.h" #include "state.h" #include "occ_service_codes.h" #include "amec_freq.h" #include "amec_part.h" #include "amec_data.h" //************************************************************************* // Externs //************************************************************************* //************************************************************************* // Macros //************************************************************************* //************************************************************************* // Defines/Enums //************************************************************************* //************************************************************************* // Structures //************************************************************************* //************************************************************************* // Forward Declarations //************************************************************************* errlHndl_t SMGR_mode_transition_to_nominal(); errlHndl_t SMGR_mode_transition_to_powersave(); errlHndl_t SMGR_mode_transition_to_dynpowersave(); errlHndl_t SMGR_mode_transition_to_dynpowersave_fp(); errlHndl_t SMGR_mode_transition_to_turbo(); errlHndl_t SMGR_mode_transition_to_superturbo(); errlHndl_t SMGR_mode_transition_to_ffo(); //************************************************************************* // Globals //************************************************************************* // Mode that OCC is currently in OCC_MODE G_occ_internal_mode = OCC_MODE_NOCHANGE; // @th040 // Mode that OCC is requesting that TMGT put OCC into OCC_MODE G_occ_internal_req_mode = OCC_MODE_NOCHANGE; // Mode that TMGT is requesting OCC go to OCC_MODE G_occ_external_req_mode = OCC_MODE_NOCHANGE; // Mode that TMGT is requesting OCC go to in KVM OCC_MODE G_occ_external_req_mode_kvm = OCC_MODE_NOCHANGE; // @at019a // Indicates if OCC must actually change the voltage / frequency during // a mode change. SMGR_SMS_CMD_TYPE G_occ_internal_sms = SMGR_SMS_VF_INFO_ONLY; // Indicates if we are currently in a mode transition bool G_mode_transition_occuring = FALSE; // Mode that OCC Master is in OCC_MODE G_occ_master_mode = OCC_MODE_NOCHANGE; // Semaphore to allow mode change to be called from multiple threads SsxSemaphore G_smgrModeChangeSem; // Table that indicates which functions should be run for a given mode // transition. const smgr_state_trans_t G_smgr_mode_trans[] = { /* ----- SPECIFIC CASE MODE TRANSITIONS ----- */ /* These are specific mode transitions for when it matters what * mode we were in before the transition. These must come before * the agnostic mode transitions below, and will be run instead of * those catch-all transition functions. */ /* Current Mode New Mode Transition Function */ {OCC_MODE_STURBO, OCC_MODE_NOMINAL, NULL}, /* ----- DEFAULT MODE TRANSITIONS ----- */ /* These are default mode transitions for when it doesn't matter what * mode we were in before the transition. */ /* Current Mode New Mode Transition Function */ {OCC_MODE_ALL, OCC_MODE_NOMINAL, &SMGR_mode_transition_to_nominal}, {OCC_MODE_ALL, OCC_MODE_PWRSAVE, &SMGR_mode_transition_to_powersave}, {OCC_MODE_ALL, OCC_MODE_DYN_POWER_SAVE, &SMGR_mode_transition_to_dynpowersave}, {OCC_MODE_ALL, OCC_MODE_DYN_POWER_SAVE_FP, &SMGR_mode_transition_to_dynpowersave_fp}, {OCC_MODE_ALL, OCC_MODE_TURBO, &SMGR_mode_transition_to_turbo}, {OCC_MODE_ALL, OCC_MODE_STURBO, &SMGR_mode_transition_to_superturbo}, {OCC_MODE_ALL, OCC_MODE_FFO, &SMGR_mode_transition_to_ffo}, }; const uint8_t G_smgr_mode_trans_count = sizeof(G_smgr_mode_trans)/sizeof(smgr_state_trans_t); //************************************************************************* // Functions //************************************************************************* // Function Specification // // Name: SMGR_is_mode_transitioning // // Description: // // Flow: FN= // // End Function Specification inline bool SMGR_is_mode_transitioning(void) { return G_mode_transition_occuring; } // Function Specification // // Name: SMGR_get_mode // // Description: // // Flow: FN= // // End Function Specification inline OCC_MODE SMGR_get_mode(void) { return G_occ_internal_mode; } // Function Specification // // Name: SMGR_set_mode // // Description: // // Flow: FN= // // End Function Specification errlHndl_t SMGR_set_mode(const OCC_MODE i_mode, const uint8_t i_sms_type) { errlHndl_t l_errlHndl = NULL; int jj=0; OCC_MODE l_mode = i_mode; do { // Get lock for critical section if(ssx_semaphore_pend(&G_smgrModeChangeSem,SSX_WAIT_FOREVER)) { /* @ * @errortype * @moduleid MAIN_MODE_TRANSITION_MID * @reasoncode SSX_GENERIC_FAILURE * @userdata1 none * @userdata4 ERC_RUNNING_SEM_PENDING_FAILURE * @devdesc SSX semaphore related failure */ l_errlHndl = createErrl(MAIN_MODE_TRANSITION_MID, //modId SSX_GENERIC_FAILURE, //reasoncode ERC_RUNNING_SEM_PENDING_FAILURE, //Extended reason code ERRL_SEV_UNRECOVERABLE, //Severity NULL, //Trace Buf DEFAULT_TRACE_SIZE, //Trace Size 0, //userdata1 0); //userdata2 // @wb001 -- Callout firmware addCalloutToErrl(l_errlHndl, ERRL_CALLOUT_TYPE_COMPONENT_ID, ERRL_COMPONENT_ID_FIRMWARE, ERRL_CALLOUT_PRIORITY_HIGH); break; } // @th022 //Check to see if we need to make a change if(l_mode == OCC_MODE_NOCHANGE) { break; } // @at019 - start // SAPPHIRE only accepts DPS-FE mode. In case OCC gets other modes, it should accept the request // and keep reporting back that it is in that mode. However, internally we should not // initiate any mode transition, i.e., OCC should remain internally in DPS-FE mode. if(G_sysConfigData.system_type.kvm) { G_occ_external_req_mode_kvm = l_mode; if (l_mode != OCC_MODE_DYN_POWER_SAVE) { TRAC_ERR("SAPPHIRE only accepts DPS-FE mode(6) but requested mode is : %d", l_mode); l_mode = OCC_MODE_DYN_POWER_SAVE; } } // @at019 - start switch (l_mode) { case OCC_MODE_NOMINAL: // FALL THROUGH case OCC_MODE_PWRSAVE: // FALL THROUGH case OCC_MODE_DYN_POWER_SAVE: // FALL THROUGH case OCC_MODE_DYN_POWER_SAVE_FP: // FALL THROUGH case OCC_MODE_TURBO: // FALL THROUGH case OCC_MODE_STURBO: // FALL THROUGH case OCC_MODE_FFO: // FALL THROUGH // Notify AMEC of mode change // Change Mode via Transition Function do { // Loop through mode transition table, and find the state // transition function that matches the transition we need to do. for(jj=0; jj