예제 #1
0
/****************************************************************************
NAME	
	PioSetPowerPin

DESCRIPTION
    controls the internal regulators to latch / remove the power on state
    
RETURNS
	void
*/
void PioSetPowerPin ( bool enable ) 
{
    /* power on or off the smps */
#ifdef BC5_MULTIMEDIA
    PsuConfigure(PSU_SMPS0, PSU_ENABLE, enable);
#else
    /* when shutting down ensure all psus are off for BC7 chips */
    if(!enable)
        PsuConfigure(PSU_ALL, PSU_ENABLE, enable);
#endif
    PIO_DEBUG(("PIO : PowerOnSMPS %X\n", enable)) ;      
}
예제 #2
0
/****************************************************************************
NAME    
    powerManagerChargerSetup
    
DESCRIPTION
    Update the charger settings based on USB limits and provided temperature
    reading. Updates current, trim, boost charge settings and enables or 
    disables the charger. On BC7 this can also be used to select whether the
    chip draws power from VBAT or VBYP.
    
RETURNS
    bool
*/
bool powerManagerChargerSetup(voltage_reading* vthm)
{
    /* Get temperature limits */
    sink_charge_current* usb_limits = usbGetChargeCurrent();
    sink_charge_setting setting;

    PM_DEBUG(("PM: Set Current\n"));

    if(vthm)
    {
        PM_DEBUG(("PM: Temp 0x%02X %dmV\n", vthm->level, vthm->voltage));
        setting = theSink.conf1->power.chg_settings[vthm->level];
    }
    else
    {
        PM_DEBUG(("PM: No Temp Reading\n"));
        setting = default_charge_setting;
    }
    
    if(usb_limits)
    {
        /* Apply minimum settings from combined limits */
        setting.current.charge = usb_limits->charge & setting.current.charge;
        if(usb_limits->boost < setting.current.boost)
            setting.current.boost = usb_limits->boost;
        setting.current.vsel = usb_limits->vsel | setting.current.vsel;
        setting.current.disable_leds = usb_limits->disable_leds | setting.current.disable_leds;
        if(usb_limits->current < setting.current.current)
            setting.current.current = usb_limits->current;
    }
    
    if(!powerManagerIsChargerConnected())
    {
        /* Must apply these settings when charger removed */
        setting.current.boost  = power_boost_disabled;
        setting.current.charge = FALSE;
#ifdef HAVE_VBAT_SEL
        setting.current.vsel   = vsel_bat;
    }
    else if(setting.current.power_off)
    {
        /* If outside operating temp cannot run from battery */
        setting.current.vsel = vsel_chg;
#endif
    }

    switch(setting.termination.type)
    {
        case vterm_voltage:
            /* BC7 allows us to set absolute termination voltage */
            PM_DEBUG(("PM: Termination Voltage %d\n", setting.termination.voltage * POWER_VSCALE));
            if(!PowerChargerSetVterm(setting.termination.voltage))
            {
                PM_DEBUG(("PM: Failed, disabling charger\n"));
                setting.current.charge = FALSE;
            }
        break;
        case vterm_trim:
            /* BC5 needs to modify trim setting */
            PM_DEBUG(("PM: Trim Termination Voltage -%d\n", setting.termination.trim));
            /* Disable charger if unable to trim */
            if(!PowerChargerReduceTrim(setting.termination.trim))
            {
                PM_DEBUG(("PM: Failed, disabling charger\n"));
                setting.current.charge = FALSE;
            }
        break;
        default:
            /* Use default termination voltage */
            PM_DEBUG(("PM: Termination Voltage Unchanged\n"));
        break;
    }

    /* Disable LEDs if required */
    PM_DEBUG(("PM: %s LEDs\n", setting.current.disable_leds ? "Disable" : "Enable"));
#ifndef NO_LED    
    LedManagerForceDisable(setting.current.disable_leds);
#endif    
    /* With VBAT_SEL we can wait for temp reading before enabling charger. 
       Without we enable charger by default and may need to turn it off. */
    if(vthm)
    {
        PM_DEBUG(("PM: Current %d, Boost 0x%X\n", setting.current.current, setting.current.boost));
        PM_DEBUG(("PM: Charger %s\n", (setting.current.charge ? "Enabled" : "Disabled")));
        
        /* Set charge current */
        PowerChargerSetCurrent(setting.current.current);
        PowerChargerSetBoost(setting.current.boost);

#ifdef HAVE_VBAT_SEL
    }
    /* Flip the switch to draw current from VBAT or VBYP */
    PM_DEBUG(("PM: SEL %s\n", ((setting.current.vsel == vsel_bat) ? "VBAT" : "VBYP") ));
    PsuConfigure(PSU_VBAT_SWITCH, PSU_SMPS_INPUT_SEL_VBAT, ((setting.current.vsel == vsel_bat) ? TRUE : FALSE));

    if(vthm)
    {
#endif
        /* Enable/disable charger */
        PowerChargerEnable(setting.current.charge);

        /* Power off */
        if(setting.current.power_off)
        {
            PM_DEBUG(("PM: Power Off\n"));
            powerManagerPowerOff();
        }
    }
    return((vthm) && (setting.current.charge));
}