Example #1
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 #2
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;
}