From: 黄涛 Date: Wed, 3 Jul 2013 02:11:09 +0000 (+0800) Subject: rk30: cpufreq: support sys_state X-Git-Tag: firefly_0821_release~6958 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c83124f13aa04969eed5f7fd444a7edc4586aad2;p=firefly-linux-kernel-4.4.55.git rk30: cpufreq: support sys_state --- diff --git a/arch/arm/mach-rk30/cpufreq.c b/arch/arm/mach-rk30/cpufreq.c index d16f8c901315..ad7b788e3de0 100755 --- a/arch/arm/mach-rk30/cpufreq.c +++ b/arch/arm/mach-rk30/cpufreq.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -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);