/*
 ==============================================================
  Initialisation function sets up the CPU policy for first use
 ==============================================================
*/
static int bcm2835_cpufreq_driver_init(struct cpufreq_policy *policy)
{
	/* measured value of how long it takes to change frequency */	
	policy->cpuinfo.transition_latency = 355000; /* ns */

	/* now find out what the maximum and minimum frequencies are */
	policy->min = policy->cpuinfo.min_freq = bcm2835_cpufreq_get_clock(VCMSG_GET_MIN_CLOCK);
	policy->max = policy->cpuinfo.max_freq = bcm2835_cpufreq_get_clock(VCMSG_GET_MAX_CLOCK);
	policy->cur = bcm2835_cpufreq_get_clock(VCMSG_GET_CLOCK_RATE);
	
	print_info("min=%d max=%d cur=%d\n", policy->min, policy->max, policy->cur);
	return 0;
}
static int bcm2835_cpufreq_driver_target(struct cpufreq_policy *policy, unsigned int target_freq, unsigned int relation)
{
	unsigned int target = target_freq;
	unsigned int cur = policy->cur;
	print_debug("%s: min=%d max=%d cur=%d target=%d\n",policy->governor->name,policy->min,policy->max,policy->cur,target_freq);
	
	/* if we are above min and using ondemand, then just use max */
	if (strcmp("ondemand", policy->governor->name)==0 && target > policy->min)
		target = policy->max;
	/* if the frequency is the same, just quit */
	if (target == policy->cur)
		return 0;

	/* otherwise were good to set the clock frequency */
	policy->cur = bcm2835_cpufreq_set_clock(policy->cur, target);
	
	if (!policy->cur)
	{
		print_err("Error occurred setting a new frequency (%d)!\n", target);
		policy->cur = bcm2835_cpufreq_get_clock(VCMSG_GET_CLOCK_RATE);
		return -EINVAL;
	}
	print_debug("Freq %d->%d (min=%d max=%d target=%d request=%d)\n", cur, policy->cur, policy->min, policy->max, target_freq, target);
	return 0;
}
Exemplo n.º 3
0
/*
 ==============================================================
  Initialisation function sets up the CPU policy for first use
 ==============================================================
*/
static int bcm2835_cpufreq_driver_init(struct cpufreq_policy *policy)
{
	/* measured value of how long it takes to change frequency */
	const unsigned int transition_latency = 355000; /* ns */

	if (!rpi_firmware_get(NULL)) {
		print_err("Firmware is not available\n");
		return -ENODEV;
	}

	/* now find out what the maximum and minimum frequencies are */
	bcm2835_freq_table[0].frequency = bcm2835_cpufreq_get_clock(RPI_FIRMWARE_GET_MIN_CLOCK_RATE);
	bcm2835_freq_table[1].frequency = bcm2835_cpufreq_get_clock(RPI_FIRMWARE_GET_MAX_CLOCK_RATE);

	print_info("min=%d max=%d\n", bcm2835_freq_table[0].frequency, bcm2835_freq_table[1].frequency);
	return cpufreq_generic_init(policy, bcm2835_freq_table, transition_latency);
}
static unsigned int bcm2835_cpufreq_driver_get(unsigned int cpu)
{
	unsigned int actual_rate = bcm2835_cpufreq_get_clock(VCMSG_GET_CLOCK_RATE);
	print_debug("cpu=%d\n", actual_rate);
	return actual_rate;
}
Exemplo n.º 5
0
static unsigned int bcm2835_cpufreq_driver_get(unsigned int cpu)
{
	unsigned int actual_rate = bcm2835_cpufreq_get_clock(RPI_FIRMWARE_GET_CLOCK_RATE);
	print_debug("cpu%d: freq=%d\n", cpu, actual_rate);
	return actual_rate <= bcm2835_freq_table[0].frequency ? bcm2835_freq_table[0].frequency : bcm2835_freq_table[1].frequency;
}