src/occ_405/wof/wof.c
/**
 *  calculate_ceff_ratio_vdd
 *
 *  Description: Function to calculate the effective capacitance ratio
 *               for the core
 */
calculate_ceff_ratio_vdd
Description: Function to calculate the effective capacitance ratio
for the core
calculate_ceff_ratio_vdd Description : Function to calculate the effective capacitance ratio for the core
void calculate_ceff_ratio_vdd( void )
{
    if( g_wof->v_ratio == 0 )
    {
        g_wof->ceff_ratio_vdd = 0;
    }
    else
    {
        g_wof->iac_tdp_vdd =
                multiply_ratio( G_oppb.lac_tdp_vdd_turbo_10ma,
                                g_wof->v_ratio );
        g_wof->c_ratio_vdd_volt = G_oppb.operating_points[TURBO].vdd_mv * 10;
        g_wof->c_ratio_vdd_freq =
            G_oppb.operating_points[TURBO].frequency_mhz * g_wof->f_ratio;
        g_wof->ceff_tdp_vdd =
                    calculate_effective_capacitance( g_wof->iac_tdp_vdd,
                                                     g_wof->c_ratio_vdd_volt,
                                                     g_wof->c_ratio_vdd_freq );
        g_wof->ceff_vdd =
                    calculate_effective_capacitance( g_wof->iac_vdd,
                                                     g_wof->voltvddsense_sensor,
                                                     g_wof->f_clip_freq );
        if( g_wof->ceff_tdp_vdd == 0 )
        {
            INTR_TRAC_ERR("WOF Disabled! Ceff VDD divide by 0");
            INTR_TRAC_ERR("iac_tdp_vdd = %d", G_oppb.lac_tdp_vdd_turbo_10ma );
            INTR_TRAC_ERR("v_ratio     = %d", g_wof->v_ratio );
            INTR_TRAC_ERR("f_ratio     = %d", g_wof->f_ratio );
            INTR_TRAC_ERR("vdd_mv      = %d", G_oppb.operating_points[TURBO].vdd_mv);
            INTR_TRAC_ERR("freq_mhz    = %d", G_oppb.operating_points[TURBO].frequency_mhz);
            INTR_TRAC_ERR("v_clip_mv   = %d", g_wof->v_clip);
            INTR_TRAC_ERR("f_clip_PS   = 0x%x", g_wof->f_clip_ps);
            print_oppb();
            g_wof->ceff_ratio_vdd = 0;
            set_clear_wof_disabled(SET,
                                   WOF_RC_DIVIDE_BY_ZERO_VDD,
                                   ERC_WOF_DIVIDE_BY_ZERO_VDD);
        }
        else
        {
            g_wof->ceff_ratio_vdd =
               prevent_over_current((g_wof->ceff_vdd*10000) / g_wof->ceff_tdp_vdd);
        }
    }
}
void calculate_ceff_ratio_vdd ( void ) { if ( g_wof -> v_ratio == 0 ) { g_wof -> ceff_ratio_vdd = 0 ; } else { g_wof -> iac_tdp_vdd = multiply_ratio ( G_oppb . lac_tdp_vdd_turbo_10ma , g_wof -> v_ratio ) ; g_wof -> c_ratio_vdd_volt = G_oppb . operating_points [ TURBO ] . vdd_mv * 10 ; g_wof -> c_ratio_vdd_freq = G_oppb . operating_points [ TURBO ] . frequency_mhz * g_wof -> f_ratio ; g_wof -> ceff_tdp_vdd = calculate_effective_capacitance ( g_wof -> iac_tdp_vdd , g_wof -> c_ratio_vdd_volt , g_wof -> c_ratio_vdd_freq ) ; g_wof -> ceff_vdd = calculate_effective_capacitance ( g_wof -> iac_vdd , g_wof -> voltvddsense_sensor , g_wof -> f_clip_freq ) ; if ( g_wof -> ceff_tdp_vdd == 0 ) { INTR_TRAC_ERR ( " " ) ; INTR_TRAC_ERR ( " " , G_oppb . lac_tdp_vdd_turbo_10ma ) ; INTR_TRAC_ERR ( " " , g_wof -> v_ratio ) ; INTR_TRAC_ERR ( " " , g_wof -> f_ratio ) ; INTR_TRAC_ERR ( " " , G_oppb . operating_points [ TURBO ] . vdd_mv ) ; INTR_TRAC_ERR ( " " , G_oppb . operating_points [ TURBO ] . frequency_mhz ) ; INTR_TRAC_ERR ( " " , g_wof -> v_clip ) ; INTR_TRAC_ERR ( " " , g_wof -> f_clip_ps ) ; print_oppb ( ) ; g_wof -> ceff_ratio_vdd = 0 ; set_clear_wof_disabled ( SET , WOF_RC_DIVIDE_BY_ZERO_VDD , ERC_WOF_DIVIDE_BY_ZERO_VDD ) ; } else { g_wof -> ceff_ratio_vdd = prevent_over_current ( ( g_wof -> ceff_vdd * 10000 ) / g_wof -> ceff_tdp_vdd ) ; } } }
calculate_ceff_ratio_vdd
  Description: Function to calculate the effective capacitance ratio
               for the core
calculate_ceff_ratio_vdd Description : Function to calculate the effective capacitance ratio for the core
// If we get v_ratio of 0 from pgpe, force ceff_ratio_vdd to 0; // Read iac_tdp_vdd from OCCPstateParmBlock struct // Get Vturbo and convert to 100uV (mV -> 100uV) = mV*10 // Multiply by Vratio // Get Fturbo and multiply by Fratio /* TODO Uncomment once we use f_ratio from PGPE
        g_wof->c_ratio_vdd_freq =
             multiply_ratio( G_oppb.operating_points[TURBO].frequency_mhz,
                             g_wof->f_ratio );
        */ // Calculate ceff_tdp_vdd // iac_tdp_vdd / ((Vturbo*Vratio)^1.3 * (Fturbo*Fratio)) // Calculate ceff_vdd // iac_vdd / (Vclip^1.3 * Fclip) // NOTE: WOF Phase 1 to use VOLTVDDSENSE. Phase 2 will use v_clip //(g_wof->v_clip*10),// mV->100uV // Prevent divide by zero // Print debug info to help isolate offending variable // Return 0 // Save ceff_ratio_vdd. Multiply by 10000 to convert to correct granularity. // Prevent Over current by clipping to max of 100%