/****************************************************************************
NAME    
    batteryNormal
    
DESCRIPTION
    Called when the battery voltage is detected to be in a Normal state
*/
static void handleBatteryNormal(power_battery_level pLevel)
{
    uint16 level = (uint16)(pLevel - POWER_BATT_LEVEL0);

    PM_DEBUG(("PM: Battery Normal,level %d\n",level));

	#ifndef BHC612	
	MessageSend(&theHeadset.task, EventOkBattery, 0);
	
    /* If charger connected send a charger gas gauge message (these don't have any functional use but can be associated with LEDs/tones) */
	if (ChargerIsChargerConnected())
	    MessageSend(&theHeadset.task, (EventChargerGasGauge0+level), 0);
    #endif
	
    /* Send notification to AG if batt level has changed */
    MessageSend(&theHeadset.task, EventGasGauge0+level, 0);    
    
#ifdef ROM_LEDS
    /* when changing from low battery state to a normal state, refresh the led state pattern
       to replace the low battery pattern should it have been shown */
    if(theHeadset.battery_low_state == TRUE)
    {
        /* kick off a check to see if there is a low battery led state configured */
	 PM_DEBUG(("Battery Normal\n"));
        LEDManagerIndicateState( stateManagerGetState() );
    }
#endif
    
    /* reset any low battery warning that may be in place */
    theHeadset.battery_low_state   = FALSE;  
    theHeadset.low_battery_flag_ag = FALSE;

}
Example #2
0
/*
 * pm_pc3_exit: 
 * Calling function needs to grab idle_state mutex.
 *
 * Execute pc3 exit for a node.
 * mic_ctx: The driver context of the node.
 */
int pm_pc3_exit(mic_ctx_t *mic_ctx)
{
	int err;
	int wait_cnt;

	WARN_ON(!mutex_is_locked(&mic_data.dd_pm.pm_idle_mutex));
	mic_send_pm_intr(mic_ctx);
	for (wait_cnt = 0; wait_cnt < PC3_EXIT_WAIT_COUNT; wait_cnt++) {
		if (check_card_state(mic_ctx, PM_IDLE_STATE_PC0))
			break;
		msleep(1);
	}


	if(wait_cnt >= PC3_EXIT_WAIT_COUNT) {
		PM_DEBUG("Syncronization with card failed."
			" Node is lost\n");
		err = -EFAULT;
		goto exit;
	}

	set_host_state(mic_ctx, PM_IDLE_STATE_PC0);
	mic_ctx->micpm_ctx.idle_state = PM_IDLE_STATE_PC0;
	PM_DEBUG("Node %d exited PC3\n", mic_get_scifnode_id(mic_ctx));

	return 0;
exit:
	return err;
}
/****************************************************************************
NAME    
    handleBatteryLow
    
DESCRIPTION
  	Called when the battery voltage is detected to be in Battery Low state
*/
static void handleBatteryLow( void )
{
    bool last_state = theHeadset.battery_low_state; 
    
    PM_DEBUG(("PM: Battery Low\n"));
   
    /*we only want low battery reminders if the headset is ON and not charging */
    if(stateManagerGetState() != headsetLimbo)
    {
        MessageSend(&theHeadset.task, EventLowBattery, 0); 
		#if 0
		theHeadset.battery_low_state = TRUE;    
		#endif
		PM_DEBUG(("battery_low_state = true\n"));
    }
    
    if(ChargerIsChargerConnected() || stateManagerGetState() == headsetLimbo)
    {
      /*  printf("the battery is charging or the headset is in limbo state\n");*/
        theHeadset.battery_low_state = FALSE;
	  	PM_DEBUG(("battery_low_state = false\n"));
    }

    if(!last_state || !theHeadset.battery_low_state)
    {
#ifdef ROM_LEDS          /* update state indication to indicate low batt state change */
	 	PM_DEBUG(("Low battery state\n"));
        LEDManagerIndicateState( stateManagerGetState() );
#endif     
     }

}
Example #4
0
int pc6_entry_start(mic_ctx_t *mic_ctx) {

	int err = 0;

	if (mic_ctx->micpm_ctx.idle_state == PM_IDLE_STATE_PC0) {
		PM_DEBUG("Node not in PC3\n");
		err = -EFAULT;
		goto exit;
	}

	mutex_lock(&mic_data.dd_pm.pm_idle_mutex);

	if (mic_ctx->micpm_ctx.idle_state != PM_IDLE_STATE_PC3) {
		PM_DEBUG("PC6 transition failed. Node not in DPC3\n");
		mutex_unlock(&mic_data.dd_pm.pm_idle_mutex);
		err = -EINVAL;
		goto exit;
	}

	if ((err = pm_pc3_to_pc6_entry(mic_ctx))) {
		PM_DEBUG("PC6 transition from PC3 failed for node %d\n",
				mic_get_scifnode_id(mic_ctx));
		mutex_unlock(&mic_data.dd_pm.pm_idle_mutex);
		goto exit;
	}
	mutex_unlock(&mic_data.dd_pm.pm_idle_mutex);
exit:
	return err;

}
Example #5
0
static int str8131_pm_enter(suspend_state_t state)
{
	PM_DEBUG("%s: state=%d\n",__FUNCTION__,state);
	switch (state)
	{
	case PM_SUSPEND_STANDBY:
	case PM_SUSPEND_MEM:

#ifdef DEBUG
		/*
		* Configure system Xtal clock to be output to CLKOUT pin
		*/
		HAL_PWRMGT_CONFIGURE_CLOCK_OUT_PIN(0, 0);
#endif

		/*
		* 1. Disable DRAM Controller's clock
		* 2. Power-down sytem 25MHz XTAL pad
		* 3. Force CPU into sleep mode, and wait until wake-up interrupt happens!!
		*    When in sleep mode, CPU internal clock and system PLLs and/or 25MHZ XTAL 
		*    pad will be power-down!!
		*/

//int 16, 18, 28-30
//#define WAKEUP_INT 0x70050000
//int 16, 18, 29-30
//#define WAKEUP_INT 0x60050000
//int 18, 29-30
#define WAKEUP_INT 0x60040000
//int 29-30
//#define WAKEUP_INT 0x60000000
//#define WAKEUP_INT 0xffffffff
		PM_DEBUG("%s: int that can wake cpu up, WAKEUP_INT=%.8x\n",__FUNCTION__,WAKEUP_INT);
//		HAL_INTC_SELECT_INTERRUPT_SOURCE_FOR_SLEEP_WAKEUP(30);
		INTC_POWER_MANAGEMENT_INTERRUPT_REG=WAKEUP_INT;
		HAL_PWRMGT_DISABLE_DRAMC_CLOCK();
#ifndef CONFIG_STAR_NIC_PHY_INTERNAL_PHY
		HAL_PWRMGT_POWER_DOWN_SYSTEM_XTAL_PAD();
#endif

		PM_DEBUG("%s: bye...\n",__FUNCTION__);
		str8131_nic_suspend(state);
		local_irq_enable();
		Hal_Cpu_Enter_Sleep_Mode();
		local_irq_disable();
		str8131_nic_resume();
		PM_DEBUG("%s: awake from sleep\n",__FUNCTION__);

		break;

	case PM_SUSPEND_DISK:
		return -ENOTSUPP;

	default:
		return -EINVAL;
	}

	return 0;
}
Example #6
0
/****************************************************************************
NAME    
    powerManagerGetLBIPM
    
DESCRIPTION
    Returns the Power level to use for Low Battery Intelligent Power 
    Management (LBIPM).
    Note will always return high level if this feature is disabled.
    
RETURNS
    void
*/
power_battery_level powerManagerGetLBIPM( void )                             
{
    PM_DEBUG(("PM: Battery Management %s\n", theSink.lbipmEnable ? "Enabled" : "Disabled"));
    PM_DEBUG(("PM: Using %s Level ", powerManagerIsChargerConnected() ? "Chg" : "Batt"));
    PM_DEBUG(("%d\n", powerManagerIsChargerConnected() ? POWER_BATT_LEVEL3 : theSink.battery_state));

    /* Get current battery level */
    if(theSink.lbipmEnable && !powerManagerIsChargerConnected())
        return theSink.battery_state;
    
    /* LBIPM disabled or charger is connected so use full power level */
    return POWER_BATT_LEVEL3;
}
Example #7
0
/****************************************************************************
NAME
    powerManagerIsVthmCritical
    
DESCRIPTION
    This function is called by applications to check whether the battery 
    temperature has reached critical level where the device must be powered
    off
    
RETURNS
    bool
*/
bool powerManagerIsVthmCritical(void)
{
    voltage_reading vthm;

    if(PowerBatteryGetTemperature(&vthm))
    {
        /* Check the power_off setting for this temperature */
        sink_charge_setting setting = theSink.conf1->power.chg_settings[vthm.level];
        PM_DEBUG(("PM: VTHM %s\n", setting.current.power_off ? "Critical" : "Okay"));
        return setting.current.power_off;
    }
    /* No temperature reading, wait until one available */
    PM_DEBUG(("PM: VTHM Okay\n"));
    return FALSE;
}
Example #8
0
/*
 * setup_pm_dependency:
 *
 * Function sets up the dependency matrix by populating
 * the matrix with node depency information.
 *
 * Returns 0 on success. Appropriate error on failure.
 */
int setup_pm_dependency(void){
	int err = 0;
	uint16_t i;
	uint16_t j;
	mic_ctx_t *mic_ctx;

	for (i = 0; i < mic_data.dd_numdevs; i++) {
		mic_ctx = get_per_dev_ctx(i);
		if (!mic_ctx) {
			PM_DEBUG("Failed to retrieve driver context\n");
			return -EFAULT;
		}
		if (mic_ctx->micpm_ctx.idle_state ==
			PM_IDLE_STATE_PC3_READY) {
			for (j = 0; j < mic_data.dd_numdevs; j++) {
				if (micscif_get_nodedep(mic_get_scifnode_id(mic_ctx),j+1) ==
						DEP_STATE_DEPENDENT) {
					micscif_set_nodedep(mic_get_scifnode_id(mic_ctx),j+1,
							DEP_STATE_DISCONNECT_READY);
				}
			}
		}
	}
	return err;
}
Example #9
0
/****************************************************************************
NAME    
    powerManagerConfig
    
DESCRIPTION
    Configure power management
    
RETURNS
    void
*/
void powerManagerConfig(const power_config* config, const power_pmu_temp_mon_config* pmu_mon_config)
{
    uint16 level = 0;
    
    PM_DEBUG(("PM: Power Library Init\n"));
    PowerInit(&theSink.task, config, pmu_mon_config);
    theSink.battery_state = POWER_BATT_LEVEL3;   
    
    if ((theSink.conf1 != NULL) && (config != NULL))
    {
        /* store the charger termination voltage as the max battery voltage */
        theSink.rundata->battery_limits.max_battery_v = 0;
        PsFullRetrieve(PSKEY_CHARGER_CALC_VTERM, &theSink.rundata->battery_limits.max_battery_v, sizeof(uint16));    
        /* store the critical voltage as the min battery voltage */
        theSink.rundata->battery_limits.min_battery_v = 0;
    
        for (level = 0; level < POWER_MAX_VBAT_LIMITS; level++)
        {
            if ((theSink.conf1->power.bat_events[level].event) == EventSysBatteryCritical)
            {
                theSink.rundata->battery_limits.min_battery_v = config->vbat.limits[level].limit * POWER_VSCALE;
                break;
            }
        }
    }
}
Example #10
0
/****************************************************************************
NAME    
    powerManagerHandleVbatLow
    
DESCRIPTION
    Called when the battery voltage is detected to be in Battery Low state
*/
static void powerManagerHandleVbatLow( void )
{
    sinkState lSinkState = stateManagerGetState ();
    bool batt_was_low = powerManagerIsVbatLow();

    PM_DEBUG(("PM: Battery Low\n"));
    if(powerManagerIsChargerConnected() || lSinkState == deviceLimbo)
    {
        theSink.battery_state = POWER_BATT_LEVEL0;
    }
    else
    {
        theSink.battery_state = POWER_BATT_LOW;  
    }

    if(!batt_was_low || !powerManagerIsVbatLow())
    {
        /* update state indication to indicate low batt state change */
#ifndef NO_LED         
        LEDManagerIndicateState( lSinkState );
#endif        
    }
    
    AudioSetPower(powerManagerGetLBIPM());
}
Example #11
0
static uint32_t main_system_reset_handler(uint32_t a0, uint32_t a1)
{
	(void)&a0;
	(void)&a1;
	PM_DEBUG("cpu %zu: a0 0%x", get_core_pos(), a0);
	return 0;
}
// The poll function checks the value of the light sensor.  The signal is
// debounced over a period of 16 * polling period -- about 16 seconds -- and
// has a threshold as well.
bool PowerManagement :: Poll
(
    unsigned long                                   time
)
{
#ifndef PM_DISABLE
    if ((time - m_time) > LIGHT_SENSOR_POLLING_MS)
    {
        m_time = time;

        // Shift the bitfield down one, and append the last value read.
        int lightSensor = analogRead(BOOTH_PIN_LIGHT_SENSOR);
        m_debounce = 
            (m_debounce << 1) 
            |   (   (lightSensor > LIGHT_SENSOR_THRESHOLD)
                    ?   0x1 
                    :   0
                );
        m_ready = true;
    }
    if 
    (   (m_debounce == DEBOUNCE_ALL_ZEROS) 
    ||  (m_debounce == DEBOUNCE_ALL_ONES)
    ) 
    {
        m_lowPowerStatus = 
            (m_debounce == DEBOUNCE_ALL_ONES) 
            ?   PM_LOW_POWER_MODE_ON
            :   PM_LOW_POWER_MODE_OFF;
        if (m_lowPowerStatusOld != m_lowPowerStatus)
        {
            m_lowPowerStatusOld = m_lowPowerStatus;
#ifdef PM_DEBUG_ENABLE
            PM_DEBUG2("PM:   Low power status --> ");
            if (m_lowPowerStatus == PM_LOW_POWER_MODE_ON)
            {
                PM_DEBUG("ON");
            } else {
                PM_DEBUG("OFF");
            }
#endif
            return true;
        }
    }
#endif
    return false;
}
Example #13
0
/****************************************************************************
NAME    
    powerManagerChargerConnected
    
DESCRIPTION
    This function is called when the charger is plugged into the device
    
RETURNS
    void
*/
void powerManagerChargerConnected( void )
{
    PM_DEBUG(("PM: Charger has been connected\n"));
    /* Monitor charger state */
    PowerChargerMonitor();
    /* notify the audio plugin of the new power state */
    AudioSetPower(POWER_BATT_LEVEL3);
}
Example #14
0
static uint32_t main_cpu_resume_handler(uint32_t a0, uint32_t a1)
{
	(void)&a0;
	(void)&a1;
	/* Could restore generic timer here */
	PM_DEBUG("cpu %zu: a0 0%x", get_core_pos(), a0);
	return 0;
}
Example #15
0
uint32_t main_cpu_on_handler(uint32_t a0, uint32_t a1)
{
	size_t pos = get_core_pos();

	(void)&a0;
	(void)&a1;
	PM_DEBUG("cpu %zu: a0 0%x", pos, a0);
	main_init_helper(false, pos, NSEC_ENTRY_INVALID);
	return 0;
}
Example #16
0
/****************************************************************************
NAME    
    powerManagerHandleVbat
    
DESCRIPTION
    Called when the battery voltage is detected to be in a Normal state
*/
static void powerManagerHandleVbat(voltage_reading vbat, battery_level_source source)
{
    /* Get the event associated with this battery level */
    sink_battery_setting setting = theSink.conf1->power.bat_events[vbat.level];
    sinkEvents_t event = setting.event;

    PM_DEBUG(("PM: Battery Voltage 0x%02X (%dmV)\n", vbat.level, vbat.voltage));

    displayUpdateBatteryLevel(powerManagerIsChargerConnected());
    
    /* Send indication if not charging, not in limbo state and indication enabled for this source */
    if(!powerManagerIsChargerConnected() && (stateManagerGetState() != deviceLimbo) && (setting.sources & source))
    {
        PM_DEBUG(("PM: Sending Event 0x%X\n", event));
        MessageSend(&theSink.task, event, NULL);
    }
    
    switch(event)
    {
        case EventSysBatteryCritical:
            /* Always indicate critical battery */
            powerManagerHandleVbatCritical();
            usbSetVbatDead(TRUE);
            break;

        case EventSysBatteryLow:
            powerManagerHandleVbatLow();
            usbSetVbatDead(FALSE);
            break;

        case EventSysGasGauge0 :
        case EventSysGasGauge1 :
        case EventSysGasGauge2 :
        case EventSysGasGauge3 :
            powerManagerHandleVbatNormal(event - EventSysGasGauge0);
            usbSetVbatDead(FALSE);
            break;

        default:
            break;
    }
}
Example #17
0
/****************************************************************************
NAME    
    powerManagerHandleVbatCritical
    
DESCRIPTION
    Called when the battery voltage is detected to be in critical state
*/
static void powerManagerHandleVbatCritical( void )
{
    PM_DEBUG(("PM: Battery Critical\n"));
    /* Reset low batt warning */
    theSink.battery_state = POWER_BATT_CRITICAL;
    /* Power Off */
    if(!powerManagerIsChargerConnected())
    {
        powerManagerPowerOff();
    }
}
Example #18
0
/****************************************************************************
NAME    
    powerManagerChargerDisconnected
    
DESCRIPTION
    This function is called when the charger is unplugged from the device
    
RETURNS
    void
*/
void powerManagerChargerDisconnected( void )
{
    PM_DEBUG(("PM: Charger has been disconnected\n"));  
    /* Immediately update charger */
    PowerChargerMonitor();
    powerManagerUpdateChargeCurrent();
    /* Cancel current LED indication */
    MessageSend(&theSink.task, EventSysCancelLedIndication, 0);
    /* Restore default bootmode */
    usbSetBootMode(BOOTMODE_DEFAULT);
}
/****************************************************************************
NAME    
    powerManagerConfig
    
DESCRIPTION
  	Configure power management
    
RETURNS
    void
*/
bool powerManagerConfig(const power_type* config)
{
	bool success = TRUE;
		
	PM_DEBUG(("PM Config\n"));
	
	if(config)
	{
        	theHeadset.low_battery_flag_ag = FALSE;
		/* Initialise the battery and its charging sub-system */
        	PowerInit(&theHeadset.task, config);
		PM_DEBUG(("Power init\n"));
	}
	else
	{
		success = FALSE;
	}
	
	return success;
}
/****************************************************************************
NAME    
    powerManagerChargerDisconnected
    
DESCRIPTION
  	This function is called when the charger is unplugged from the headset
    
RETURNS
    void
*/
void powerManagerChargerDisconnected( void )
{
    PM_DEBUG(("PM: Charger has been disconnected\n"));
    setChargeEnablePio(FALSE);
	PowerCharger(FALSE);

#ifndef New_MMI
    /* Cancel current LED indication */
	MessageSend(&theHeadset.task, EventCancelLedIndication, 0);
#endif

}
void PowerManagement :: PowerUp()
{
    PM_DEBUG("PM:   Powering Up");
    m_powerStatus = PM_POWER_ON;
#ifdef PM_DISABLE
    m_ready = true;
#else
    digitalWrite(BOOTH_PIN_LOW_POWER_EN, PM_LOW_POWER_SIGNAL_DISABLE);
    m_time = millis() + PM_POWER_UP_DELAY_MS;
    m_ready = false;
#endif
}
void PowerManagement :: PowerDown()
{
    PM_DEBUG("PM:   Powering Down");
    m_powerStatus = PM_POWER_OFF;
#ifdef PM_DISABLE
    m_ready = true;
#else
    digitalWrite(BOOTH_PIN_LOW_POWER_EN, PM_LOW_POWER_SIGNAL_ENABLE);
    m_time = millis();
    m_ready = false;
#endif
}
Example #23
0
void powerManagerCheckPanic(void)
{
    vm_reset_source rst_src = VmGetResetSource();
    vm_power_enabler en_src = VmGetPowerSource();

    theSink.panic_reconnect = FALSE;
    /* Is panic check enabled */
    if(theSink.features.ReconnectOnPanic)
        if(rst_src == RESET_SOURCE_FIRMWARE || rst_src == UNEXPECTED_RESET || en_src == POWER_ENABLER_RESET_PROTECTION)
            theSink.panic_reconnect = TRUE;

    PM_DEBUG(("PM: Power %d, Reset %d, Old State %d %sReconnect\n", en_src, rst_src, theSink.rundata->old_state, theSink.panic_reconnect ? "":"Don't "));
}
Example #24
0
/*
 * revert_idle_entry_trasaction:
 *
 * @node_disc_bitmask: Bitmask of nodes which were involved in the
 *  transaction
 *
 *  Function Reverts idle state changes made to nodes when an idle
 *  state trasaction fails.
 */
int revert_idle_entry_trasaction(uint8_t *node_disc_bitmask) {
	int err = 0;
	mic_ctx_t *node_ctx;
	uint32_t node_id = 0;

	for(node_id = 0; node_id <= ms_info.mi_maxid;  node_id++) {
		if (node_id == SCIF_HOST_NODE)
			continue;

		if (!get_nodemask_bit(node_disc_bitmask, node_id))
			continue;

		node_ctx = get_per_dev_ctx(node_id - 1);
		if (!node_ctx) {
			PM_DEBUG("Failed to retrieve node context.");
			err = -EINVAL;
			goto exit;
		}

		if (node_ctx->micpm_ctx.idle_state == PM_IDLE_STATE_PC3) {
			err = pm_pc3_exit(node_ctx);
			if (err) {
				PM_DEBUG("Wakeup of Node %d failed. Node is lost"
					" and is to be disconnected",node_id);
				node_ctx->micpm_ctx.idle_state = PM_IDLE_STATE_LOST;
				/* Since node is lost, ref_cnt increment(decement) through the
				* pm_get(put)_reference interface is prevented by idle_state.
				* We still need to ensure the ref_cnt iself is reset
				* back to 0 so that pm_get(put)_reference will work after the
				* lost node interface recovers the node. */
				atomic_set(&node_ctx->micpm_ctx.pm_ref_cnt, 0);
			}
		}
	}
exit:
	return err;
}
Example #25
0
/* @print_nodemaskbuf
 *
 * @param -  buf - the nodemask buffer
 *
 * prints the nodes in the nodemask.
 *
 * @returns - none
 */
void print_nodemaskbuf(uint8_t* buf) {

	uint8_t *temp_buf_ptr;
	uint32_t i,j;

	temp_buf_ptr = buf;
	PM_DEBUG("Nodes in nodemask: ");
	for(i = 0; i <= ms_info.mi_maxid; i++) {
		temp_buf_ptr = buf + i;
		for (j = 0; j < 8; j++) {
			if (get_nodemask_bit(temp_buf_ptr, j))
				pr_debug("%d ", j + (i * 8));
		}
	}
}
/****************************************************************************
NAME    
    powerManagerChargerConnected
    
DESCRIPTION
  	This function is called when the charger is plugged into the headset
    
RETURNS
    void
*/
void powerManagerChargerConnected( void )
{
    PM_DEBUG(("PM: Charger has been connected\n"));
    setChargeEnablePio(TRUE);

	#ifdef InitCharger
	if(theHeadset.BHC612_PowerInitComplete)
		PowerCharger(TRUE);
	#else
	PowerCharger(TRUE);
    #endif
		
    /* notify the audio plugin of thenew power state */
    AudioSetPower(POWER_BATT_LEVEL3);
    
}
Example #27
0
/*
 * pm_pc3_entry:
 *
 * Execute pc3 entry for a node.
 * mic_ctx: The driver context of the node.
 */
int pm_pc3_entry(mic_ctx_t *mic_ctx)
{
	int err = 0;
	if (mic_ctx == NULL) {
		err = -EINVAL;
		goto exit;
	}

	if (((!check_host_state(mic_ctx, PM_IDLE_STATE_PC0))) ||
		(mic_ctx->micpm_ctx.idle_state != PM_IDLE_STATE_PC0)) {
		PM_DEBUG("Wrong host state. register state = %d"
			" idle state = %d\n", get_host_state(mic_ctx),
			mic_ctx->micpm_ctx.idle_state);
		goto send_wakeup;
	}

	/* cancel pc6 entry work that may be scheduled. We need to
 	* do this either here or after a pervious pc3 exit */
	cancel_delayed_work_sync(&mic_ctx->micpm_ctx.pc6_entry_work);

	if ((mic_ctx->micpm_ctx.con_state != PM_CONNECTED) ||
		(!mic_ctx->micpm_ctx.pc3_enabled))
		goto send_wakeup;

	mic_ctx->micpm_ctx.idle_state = PM_IDLE_STATE_PC3_READY;
	err = do_idlestate_entry(mic_ctx);
	if (err)
		goto exit;
	if ((mic_ctx->micpm_ctx.pc6_enabled) &&
		(KNC_C_STEP <= mic_ctx->bi_stepping) &&
		(KNC_B1_STEP != mic_ctx->bi_stepping)) {
			queue_delayed_work(mic_ctx->micpm_ctx.pc6_entry_wq, 
			&mic_ctx->micpm_ctx.pc6_entry_work, 
			mic_ctx->micpm_ctx.pc6_timeout*HZ);
	}

	goto exit;

send_wakeup:
	mutex_lock(&mic_data.dd_pm.pm_idle_mutex);
	pm_pc3_exit(mic_ctx);
	mutex_unlock(&mic_data.dd_pm.pm_idle_mutex);
exit:
	return err;
}
Example #28
0
int hw_active(mic_ctx_t *mic_ctx) {
	uint8_t is_ring_active;
	sbox_pcu_ctrl_t ctrl_regval;
	uint32_t idle_wait_cnt;

	for(idle_wait_cnt = 0; idle_wait_cnt <= MAX_HW_IDLE_WAIT_COUNT;
			idle_wait_cnt++) {
		ctrl_regval.value = pm_reg_read(mic_ctx,SBOX_PCU_CONTROL);
		is_ring_active = ctrl_regval.bits.mclk_enabled;
		if (likely(is_ring_active))
			return is_ring_active;
		msleep(10);
	}

	PM_DEBUG("Timing out waiting for HW to become active\n");
	return is_ring_active;

}
Example #29
0
static int str8131_pm_prepare(suspend_state_t state)
{
	int error = 0;
	PM_DEBUG("%s: state=%d\n",__FUNCTION__,state);
	switch (state)
	{
	case PM_SUSPEND_STANDBY:
	case PM_SUSPEND_MEM:
		break;

	case PM_SUSPEND_DISK:
		return -ENOTSUPP;

	default:
		return -EINVAL;
	}

	return error;
}
Example #30
0
/****************************************************************************
NAME    
    batteryNormal
    
DESCRIPTION
    Called when the battery voltage is detected to be in a Normal state
*/
static void powerManagerHandleVbatNormal(uint8 level)
{
#ifndef NO_LED     
    bool low_batt = powerManagerIsVbatLow();
#endif    
    PM_DEBUG(("PM: Battery Normal %d\n", level));
    MessageSend(&theSink.task, EventSysBatteryOk, 0);
    
    /* If charger connected send a charger gas gauge message (these don't have any functional use but can be associated with LEDs/tones) */
    if (powerManagerIsChargerConnected())
        MessageSend(&theSink.task, (EventSysChargerGasGauge0+level), 0);
    
    /* reset any low battery warning that may be in place */
    theSink.battery_state = POWER_BATT_LEVEL0 + level;
    csr2csrHandleAgBatteryRequestRes(level);
#ifndef NO_LED 
    /* when changing from low battery state to a normal state, refresh the led state pattern
       to replace the low battery pattern should it have been shown */
    if(low_batt) LEDManagerIndicateState(stateManagerGetState());
#endif    
    AudioSetPower(powerManagerGetLBIPM());
}