mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 04:10:18 +09:00
rk30: cpufreq: support sys_state
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include <linux/delay.h>
|
||||
#include <linux/regulator/consumer.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/miscdevice.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/earlysuspend.h>
|
||||
#include <asm/unistd.h>
|
||||
@@ -127,6 +128,32 @@ static const struct cpufreq_frequency_table temp_limits_high[] = {
|
||||
|
||||
extern int rk30_tsadc_get_temp(unsigned int chn);
|
||||
|
||||
static char sys_state;
|
||||
static ssize_t sys_state_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
|
||||
{
|
||||
char state;
|
||||
|
||||
if (count < 1)
|
||||
return count;
|
||||
if (copy_from_user(&state, buffer, 1)) {
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
sys_state = state;
|
||||
return count;
|
||||
}
|
||||
|
||||
static const struct file_operations sys_state_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.write = sys_state_write,
|
||||
};
|
||||
|
||||
static struct miscdevice sys_state_dev = {
|
||||
.fops = &sys_state_fops,
|
||||
.name = "sys_state",
|
||||
.minor = MISC_DYNAMIC_MINOR,
|
||||
};
|
||||
|
||||
static void rk30_cpufreq_temp_limit_work_func(struct work_struct *work)
|
||||
{
|
||||
struct cpufreq_policy *policy;
|
||||
@@ -142,7 +169,7 @@ static void rk30_cpufreq_temp_limit_work_func(struct work_struct *work)
|
||||
FREQ_PRINTK_LOG("cpu_thermal(%d)\n", temp);
|
||||
|
||||
gpu_irqs[1] = kstat_irqs(IRQ_GPU_GP);
|
||||
if (clk_get_rate(gpu_clk) > GPU_MAX_RATE) {
|
||||
if (sys_state == '1' || clk_get_rate(gpu_clk) > GPU_MAX_RATE) {
|
||||
delay = HZ / 20;
|
||||
if ((gpu_irqs[1] - gpu_irqs[0]) < 3) {
|
||||
limits_table = temp_limits_high;
|
||||
@@ -279,6 +306,7 @@ static int rk30_cpu_init(struct cpufreq_policy *policy)
|
||||
|
||||
freq_wq = create_singlethread_workqueue("rk30_cpufreqd");
|
||||
#ifdef CONFIG_RK30_CPU_FREQ_LIMIT_BY_TEMP
|
||||
misc_register(&sys_state_dev);
|
||||
if (rk30_cpufreq_is_ondemand_policy(policy)) {
|
||||
queue_delayed_work(freq_wq, &rk30_cpufreq_temp_limit_work, 0*HZ);
|
||||
}
|
||||
@@ -321,6 +349,7 @@ static int rk30_cpu_exit(struct cpufreq_policy *policy)
|
||||
cpufreq_unregister_notifier(¬ifier_policy_block, CPUFREQ_POLICY_NOTIFIER);
|
||||
if (freq_wq)
|
||||
cancel_delayed_work(&rk30_cpufreq_temp_limit_work);
|
||||
misc_deregister(&sys_state_dev);
|
||||
#endif
|
||||
if (freq_wq) {
|
||||
flush_workqueue(freq_wq);
|
||||
|
||||
Reference in New Issue
Block a user