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; }
static int bcm2835_cpufreq_driver_target_index(struct cpufreq_policy *policy, unsigned int state) { unsigned int target_freq = bcm2835_freq_table[state].frequency; unsigned int cur = bcm2835_cpufreq_set_clock(policy->cur, target_freq); if (!cur) { print_err("Error occurred setting a new frequency (%d)\n", target_freq); return -EINVAL; } print_debug("%s: %i: freq %d->%d\n", policy->governor->name, state, policy->cur, cur); return 0; }