예제 #1
0
/**
 * longrun_init - initializes the Transmeta Crusoe LongRun CPUFreq driver
 *
 * Initializes the LongRun support.
 */
static int __init longrun_init(void)
{
	int                     result;
	struct cpufreq_driver   *driver;
	struct cpuinfo_x86 *c = cpu_data;

	if (c->x86_vendor != X86_VENDOR_TRANSMETA || 
	    !cpu_has(c, X86_FEATURE_LONGRUN))
		return 0;

	/* initialization of main "cpufreq" code*/
	driver = kmalloc(sizeof(struct cpufreq_driver) + 
			 NR_CPUS * sizeof(struct cpufreq_policy), GFP_KERNEL);
	if (!driver)
		return -ENOMEM;

	driver->policy = (struct cpufreq_policy *) (driver + 1);

	if (longrun_determine_freqs(&longrun_low_freq, &longrun_high_freq)) {
		kfree(driver);
		return -EIO;
	}
	driver->policy[0].cpuinfo.min_freq = longrun_low_freq;
	driver->policy[0].cpuinfo.max_freq = longrun_high_freq;
	driver->policy[0].cpuinfo.transition_latency = CPUFREQ_ETERNAL;

	longrun_get_policy(&driver->policy[0]);

#ifdef CONFIG_CPU_FREQ_24_API
	driver->cpu_cur_freq[0] = longrun_high_freq; /* dummy value */
#endif

	driver->verify         = &longrun_verify_policy;
	driver->setpolicy      = &longrun_set_policy;

	longrun_driver = driver;

	result = cpufreq_register(driver);
	if (result) {
		longrun_driver = NULL;
		kfree(driver);
	}

	return result;
}
예제 #2
0
static int __init longrun_cpu_init(struct cpufreq_policy *policy)
{
	int result = 0;

	/* capability check */
	if (policy->cpu != 0)
		return -ENODEV;

	/* detect low and high frequency */
	result = longrun_determine_freqs(&longrun_low_freq, &longrun_high_freq);
	if (result)
		return result;

	/* cpuinfo and default policy values */
	policy->cpuinfo.min_freq = longrun_low_freq;
	policy->cpuinfo.max_freq = longrun_high_freq;
	policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
	longrun_get_policy(policy);

	return 0;
}