/**
 *	enter_state - Do common work of entering low-power state.
 *	@state:		pm_state structure for state we're entering.
 *
 *	Make sure we're the only ones trying to enter a sleep state. Fail
 *	if someone has beat us to it, since we don't want anything weird to
 *	happen when we wake up.
 *	Then, do the setup for suspend, enter the state, and cleaup (after
 *	we've woken up).
 */
int enter_state(suspend_state_t state)
{
	int error;

	if (!valid_state(state))
		return -ENODEV;

	if (!mutex_trylock(&pm_mutex))
		return -EBUSY;

	printk(KERN_INFO "PM: Syncing filesystems ... ");
	sys_sync();
	printk("done.\n");

	pr_debug("PM: Preparing system for %s sleep\n", pm_states[state]);
	error = suspend_prepare();
	if (error)
		goto Unlock;

	if (suspend_test(TEST_FREEZER))
		goto Finish;

	pr_debug("PM: Entering %s sleep\n", pm_states[state]);
	pm_restrict_gfp_mask();
	error = suspend_devices_and_enter(state);
	pm_restore_gfp_mask();

 Finish:
	pr_debug("PM: Finishing wakeup.\n");
	suspend_finish();
 Unlock:
	mutex_unlock(&pm_mutex);
#ifdef CONFIG_SUSPEND_WATCHDOG
	extern void disable_watchdog(void);
	disable_watchdog();
#endif   	
	return error;
}
Example #2
0
/**
 * enter_state - Do common work needed to enter system sleep state.
 * @state: System sleep state to enter.
 *
 * Make sure that no one else is trying to put the system into a sleep state.
 * Fail if that's not the case.  Otherwise, prepare for system suspend, make the
 * system enter the given sleep state and clean up after wakeup.
 */
static int enter_state(suspend_state_t state)
{
	int error;

	if (!valid_state(state))
		return -ENODEV;

	if (!mutex_trylock(&pm_mutex))
		return -EBUSY;

	suspend_sys_sync_queue();
	pr_debug("PM: Preparing system for %s sleep\n", pm_states[state]);
	error = suspend_prepare();
	if (error)
		goto Unlock;

	if (suspend_test(TEST_FREEZER))
		goto Finish;

	pr_debug("PM: Entering %s sleep\n", pm_states[state]);
	pm_restrict_gfp_mask();
	error = suspend_devices_and_enter(state);
	pm_restore_gfp_mask();

 Finish:
	pr_debug("PM: Finishing wakeup.\n");
#ifdef CONFIG_MACH_LGE
	start_monitor_blocking(suspend_monitor_id,
		jiffies + usecs_to_jiffies(3000000));
#endif
	suspend_finish();
#ifdef CONFIG_MACH_LGE
	end_monitor_blocking(suspend_monitor_id);
#endif
 Unlock:
	mutex_unlock(&pm_mutex);
	return error;
}
Example #3
0
/**
 * enter_state - Do common work needed to enter system sleep state.
 * @state: System sleep state to enter.
 *
 * Make sure that no one else is trying to put the system into a sleep state.
 * Fail if that's not the case.  Otherwise, prepare for system suspend, make the
 * system enter the given sleep state and clean up after wakeup.
 */
static int enter_state(suspend_state_t state)
{
	int error;

	if (!valid_state(state))
		return -ENODEV;

	if (!mutex_trylock(&pm_mutex))
		return -EBUSY;

#ifdef CONFIG_PERFLOCK_SUSPEND_LOCK
	shsys_enter_state_perf_lock();
#endif

	suspend_sys_sync_queue();
	pr_debug("PM: Preparing system for %s sleep\n", pm_states[state]);
	error = suspend_prepare();
	if (error)
		goto Unlock;

	if (suspend_test(TEST_FREEZER))
		goto Finish;

	pr_debug("PM: Entering %s sleep\n", pm_states[state]);
	pm_restrict_gfp_mask();
	error = suspend_devices_and_enter(state);
	pm_restore_gfp_mask();

 Finish:
	pr_debug("PM: Finishing wakeup.\n");
	suspend_finish();
 Unlock:
#ifdef CONFIG_PERFLOCK_SUSPEND_LOCK
	shsys_enter_state_perf_unlock();
#endif
	mutex_unlock(&pm_mutex);
	return error;
}
/**
 * enter_state - Do common work needed to enter system sleep state.
 * @state: System sleep state to enter.
 *
 * Make sure that no one else is trying to put the system into a sleep state.
 * Fail if that's not the case.  Otherwise, prepare for system suspend, make the
 * system enter the given sleep state and clean up after wakeup.
 */
static int enter_state(suspend_state_t state)
{
	int error;

	if (!valid_state(state))
		return -ENODEV;

	if (!mutex_trylock(&pm_mutex))
		return -EBUSY;
#ifdef CONFIG_HUAWEI_KERNEL
	printk(KERN_INFO "PM: Syncing filesystems put the sync in the queue... ");
	suspend_sys_sync_queue();
	printk("put it done.\n");
#else
	printk(KERN_INFO "PM: Syncing filesystems ... ");
	sys_sync();
	printk("done.\n");
#endif
	pr_debug("PM: Preparing system for %s sleep\n", pm_states[state]);
	error = suspend_prepare();
	if (error)
		goto Unlock;

	if (suspend_test(TEST_FREEZER))
		goto Finish;

	pr_debug("PM: Entering %s sleep\n", pm_states[state]);
	pm_restrict_gfp_mask();
	error = suspend_devices_and_enter(state);
	pm_restore_gfp_mask();

 Finish:
	pr_debug("PM: Finishing wakeup.\n");
	suspend_finish();
 Unlock:
	mutex_unlock(&pm_mutex);
	return error;
}
Example #5
0
/**
 * enter_state - Do common work needed to enter system sleep state.
 * @state: System sleep state to enter.
 *
 * Make sure that no one else is trying to put the system into a sleep state.
 * Fail if that's not the case.  Otherwise, prepare for system suspend, make the
 * system enter the given sleep state and clean up after wakeup.
 */
static int enter_state(suspend_state_t state)
{
	int error;

	if (!valid_state(state))
		return -ENODEV;

	if (!mutex_trylock(&pm_mutex))
		return -EBUSY;

	if (state == PM_SUSPEND_FREEZE)
		freeze_begin();

	printk(KERN_INFO "PM: Syncing filesystems ... ");
	sys_sync();
	printk("done.\n");

	pr_debug("PM: Preparing system for %s sleep\n", pm_states[state]);
	error = suspend_prepare(state);
	if (error)
		goto Unlock;

	if (suspend_test(TEST_FREEZER))
		goto Finish;

	pr_debug("PM: Entering %s sleep\n", pm_states[state]);
	pm_restrict_gfp_mask();
	error = suspend_devices_and_enter(state);
	pm_restore_gfp_mask();

 Finish:
	pr_debug("PM: Finishing wakeup.\n");
	suspend_finish();
 Unlock:
	mutex_unlock(&pm_mutex);
	return error;
}
Example #6
0
/**
 *	enter_state - Do common work of entering low-power state.
 *	@state:		pm_state structure for state we're entering.
 *
 *	Make sure we're the only ones trying to enter a sleep state. Fail
 *	if someone has beat us to it, since we don't want anything weird to
 *	happen when we wake up.
 *	Then, do the setup for suspend, enter the state, and cleaup (after
 *	we've woken up).
 */
int enter_state(suspend_state_t state)
{
	int error;

	if (!valid_state(state))
		return -ENODEV;

	if (!mutex_trylock(&pm_mutex))
		return -EBUSY;

	suspend_footprint = 3;
	suspend_sys_sync_queue();
	suspend_footprint = 4;
	pr_debug("PM: Preparing system for %s sleep\n", pm_states[state]);
	error = suspend_prepare();
	if (error)
		goto Unlock;
	suspend_footprint = 10;
	if (suspend_test(TEST_FREEZER))
		goto Finish;
	suspend_footprint = 11;
	pr_debug("PM: Entering %s sleep\n", pm_states[state]);
	pm_restrict_gfp_mask();
	suspend_footprint = 12;
	error = suspend_devices_and_enter(state);
	suspend_footprint = 13;
	pm_restore_gfp_mask();
	suspend_footprint = 14;

 Finish:
	pr_debug("PM: Finishing wakeup.\n");
	suspend_finish();
	suspend_footprint = 18;
 Unlock:
	mutex_unlock(&pm_mutex);
	return error;
}
Example #7
0
/**
 *	enter_state - Do common work of entering low-power state.
 *	@state:		pm_state structure for state we're entering.
 *
 *	Make sure we're the only ones trying to enter a sleep state. Fail
 *	if someone has beat us to it, since we don't want anything weird to
 *	happen when we wake up.
 *	Then, do the setup for suspend, enter the state, and cleaup (after
 *	we've woken up).
 */
int enter_state(suspend_state_t state)
{
	int error;

	if (!valid_state(state))
		return -ENODEV;

	if (!mutex_trylock(&pm_mutex))
		return -EBUSY;

//20110727 [email protected]	Patch applied from P990 froyo MR-03
	printk("[LOG] star_emergency_restart() called at enter_state() \n");
	star_emergency_restart("sys", 63);

	printk(KERN_INFO "PM: Syncing filesystems ... ");
	sys_sync();
	printk("done.\n");

	pr_debug("PM: Preparing system for %s sleep\n", pm_states[state]);
	error = suspend_prepare();
	if (error)
		goto Unlock;

	if (suspend_test(TEST_FREEZER))
		goto Finish;

	pr_debug("PM: Entering %s sleep\n", pm_states[state]);
	error = suspend_devices_and_enter(state);

 Finish:
	pr_debug("PM: Finishing wakeup.\n");
	suspend_finish();
 Unlock:
	mutex_unlock(&pm_mutex);
	return error;
}
int enter_state(suspend_state_t state)
{
	int error;
	int dock=0;
	int retries=3;
	
	if (!valid_state(state))
		return -ENODEV;

	if (!mutex_trylock(&pm_mutex))
		return -EBUSY;
	
	printk(KERN_INFO "PM: Syncing filesystems ... ");
	sys_sync();
	printk("done.\n");
#ifdef CONFIG_ASUSEC
	if (gpio_get_value(TEGRA_GPIO_PX5)==0){
		dock=1;
		hub_suspended=0;
////		nousb=1;
//		printk("mutex+\n");
//		mutex_lock(&usb_mutex);
		if (nousb==1) {
			printk("usb wait1\n");
			msleep(500);
		}
		asusec_close_keyboard();
////		asusec_suspend_hub_callback2();
/*		while (!hub_suspended) {
			asusec_suspend_hub_callback();
			if (retries-- == 0)
				break;
			if (!hub_suspended) {
				stop_dock();
				msleep(500);
				asusec_resume(0);
				msleep(500);
//				printk("try to restart asusec\n");
//				reload_asusec();
			}
		}
*/		
//		printk("mutex-\n");
//		mutex_unlock(&usb_mutex);

/*
		if (!hub_suspended) {
			stop_dock();
			printk("Dock problem\n");
			if (failed_dock < 3) {
				printk("aborted suspend\n");
				failed_dock++;
				asusec_resume(0);
				error=999;
//				nousb=0;
				goto Unlock;
			}
		} 
*/		
//		nousb=0;
		failed_dock=0;
		msleep(2000);	
//		cpu_down(1);
	}
#endif
	pr_debug("PM: Preparing system for %s sleep\n", pm_states[state]);
	error = suspend_prepare();
	if (error) {
		if (dock==1) {
			asusec_resume(0);
		}
		goto Unlock;
	}

	if (suspend_test(TEST_FREEZER))
		goto Finish;

	pr_debug("PM: Entering %s sleep\n", pm_states[state]);
	pm_restrict_gfp_mask();
	error = suspend_devices_and_enter(state);
	pm_restore_gfp_mask();

 Finish:
	pr_debug("PM: Finishing wakeup.\n");
	suspend_finish();
 Unlock:
//	asusec_resume(0);
	mutex_unlock(&pm_mutex);
	return error;
}
Example #9
0
/**
 *	enter_state - Do common work of entering low-power state.
 *	@state:		pm_state structure for state we're entering.
 *
 *	Make sure we're the only ones trying to enter a sleep state. Fail
 *	if someone has beat us to it, since we don't want anything weird to
 *	happen when we wake up.
 *	Then, do the setup for suspend, enter the state, and cleaup (after
 *	we've woken up).
 */
static int enter_state(suspend_state_t state)
{
	int error;
	extern unsigned long set1_gpio;
	extern unsigned long set2_gpio;

	if (!valid_state(state))
		return -ENODEV;

	if (!mutex_trylock(&pm_mutex))
		return -EBUSY;

#ifdef CONFIG_CPU_FREQ
#ifdef SLEEP_CPUFREQ_CONSERVATIVE
	// change cpufreq governor to performance
	// if conservative governor
#ifdef SLEEP_CPUFREQ_MANUAL_SET
	if(is_userspace_gov())
	{
		g_cpuspeed = s5pc110_getspeed(0);
		printk("userspace cpu speed %d \n",g_cpuspeed);
		userSpaceGovernor=true;
    	}
	else if(is_conservative_gov())
	{
		s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_5, 0);
		gbGovernorTransition=true;
	}
#else//SLEEP_CPUFREQ_MANUAL_SET
	if(is_conservative_gov()) {
		s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_5, 0);
		gbGovernorTransition = true;
		gpio_set_value(set2_gpio, 0);
  		gpio_set_value(set1_gpio, 1);
	}
#endif//SLEEP_CPUFREQ_MANUAL_SET	
#else//SLEEP_CPUFREQ_CONSERVATIVE
	cpufreq_direct_set_policy(0, "userspace");
	cpufreq_direct_store_scaling_setspeed(0, "800000", 0);
#endif//SLEEP_CPUFREQ_CONSERVATIVE
#endif//CONFIG_CPU_FREQ

	printk(KERN_INFO "PM: Syncing filesystems ... ");
	sys_sync();
	printk("done.\n");

	pr_debug("PM: Preparing system for %s sleep\n", pm_states[state]);
	error = suspend_prepare();
	if (error)
		goto Unlock;

	if (suspend_test(TEST_FREEZER))
		goto Finish;

	pr_debug("PM: Entering %s sleep\n", pm_states[state]);
	error = suspend_devices_and_enter(state);

 Finish:
	pr_debug("PM: Finishing wakeup.\n");
	suspend_finish();
 Unlock:
	mutex_unlock(&pm_mutex);
#ifdef CONFIG_CPU_FREQ
#ifdef SLEEP_CPUFREQ_CONSERVATIVE
#ifdef SLEEP_CPUFREQ_MANUAL_SET
	if(userSpaceGovernor)
	{
		s5pc110_pm_target(g_cpuspeed);
		printk("recover userspace cpu speed %d \n",g_cpuspeed);
		g_cpuspeed=0;
		userSpaceGovernor=false;
	}
	if(gbGovernorTransition)
	{
		s5pc110_unlock_dvfs_high_level(DVFS_LOCK_TOKEN_5);
		gbGovernorTransition=false;
	}	
#else//SLEEP_CPUFREQ_MANUAL_SET
	// change cpufreq to original one
	if(gbGovernorTransition) {
		s5pc110_unlock_dvfs_high_level(DVFS_LOCK_TOKEN_5);
		gbGovernorTransition = false;
	}
#endif//SLEEP_CPUFREQ_MANUAL_SET	
#else//SLEEP_CPUFREQ_CONSERVATIVE
	cpufreq_direct_set_policy(0, "conservative");
#endif//SLEEP_CPUFREQ_CONSERVATIVE
#endif//CONFIG_CPU_FREQ

	return error;
}
Example #10
0
int enter_state(suspend_state_t state)
{
	int error;
	struct cpufreq_policy policy;

	if (!valid_state(state))
		return -ENODEV;

	if (!mutex_trylock(&pm_mutex))
		return -EBUSY;


#ifdef CONFIG_CPU_FREQ
#if 1
	// change cpufreq governor to performance
	// if conservative governor
	if(is_userspace_gov())
	{
		g_cpuspeed = s5pc110_getspeed(0);
		printk("userspace cpu speed %d \n",g_cpuspeed);
		userSpaceGovernor=true;
    	} else if(is_conservative_gov()) {
		/*Fix the upper transition scaling*/
		g_dvfs_fix_lock_limit = true;
#if MAXIMUM_FREQ == 1200000
		s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_7, LEV_800MHZ);
#else
		s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_7, LEV_832MHZ);
#endif
		gbClockFix = true;

		error = cpufreq_get_policy(&policy, 0);
		if(error)
		{
			printk("Failed to get policy\n");
			goto Unlock;
		}

		cpufreq_driver_target(&policy, 800000, CPUFREQ_RELATION_L);
	}
	
#else
//	cpufreq_direct_set_policy(0, "userspace");
//	cpufreq_direct_store_scaling_setspeed(0, "800000", 0);
#endif
#endif

	printk(KERN_INFO "PM: Syncing filesystems ... ");
	sys_sync();
	printk("done.\n");

	pr_debug("PM: Preparing system for %s sleep\n", pm_states[state]);
	error = suspend_prepare();
	if (error)
		goto Unlock;

	if (suspend_test(TEST_FREEZER))
		goto Finish;

	pr_debug("PM: Entering %s sleep\n", pm_states[state]);
	error = suspend_devices_and_enter(state);

 Finish:
	pr_debug("PM: Finishing wakeup.\n");
	suspend_finish();
 Unlock:
	mutex_unlock(&pm_mutex);
#ifdef CONFIG_CPU_FREQ
#if 1
	if(userSpaceGovernor)
	{
		s5pc110_pm_target(g_cpuspeed);
		printk("recover userspace cpu speed %d \n",g_cpuspeed);
		g_cpuspeed=0;
		userSpaceGovernor=false;
	}
	// change cpufreq to original one
	if(gbClockFix) {
		g_dvfs_fix_lock_limit = false;
		s5pc110_unlock_dvfs_high_level(DVFS_LOCK_TOKEN_7);
		gbClockFix = false;
	}
#else
//	cpufreq_direct_set_policy(0, "conservative");
#endif
#endif
	return error;
}