diff options
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-tegra/board-ventana-panel.c | 11 | ||||
-rw-r--r-- | arch/arm/mach-tegra/board-whistler-panel.c | 12 | ||||
-rw-r--r-- | arch/arm/mach-tegra/common.c | 122 | ||||
-rw-r--r-- | arch/arm/mach-tegra/include/mach/tegra_cpufreq.h | 33 |
4 files changed, 178 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/board-ventana-panel.c b/arch/arm/mach-tegra/board-ventana-panel.c index 66bea3b0a9c7..0194ebfa036c 100644 --- a/arch/arm/mach-tegra/board-ventana-panel.c +++ b/arch/arm/mach-tegra/board-ventana-panel.c @@ -32,6 +32,7 @@ #include <mach/iomap.h> #include <mach/dc.h> #include <mach/fb.h> +#include <mach/tegra_cpufreq.h> #include "devices.h" #include "gpio-names.h" @@ -336,12 +337,22 @@ static void ventana_panel_early_suspend(struct early_suspend *h) { if (num_registered_fb > 0) fb_blank(registered_fb[0], FB_BLANK_POWERDOWN); +#ifdef CONFIG_CPU_FREQ + cpufreq_save_default_governor(); + cpufreq_set_conservative_governor(); + cpufreq_set_conservative_governor_param( + SET_CONSERVATIVE_GOVERNOR_UP_THRESHOLD, + SET_CONSERVATIVE_GOVERNOR_DOWN_THRESHOLD); +#endif } static void ventana_panel_late_resume(struct early_suspend *h) { if (num_registered_fb > 0) fb_blank(registered_fb[0], FB_BLANK_UNBLANK); +#ifdef CONFIG_CPU_FREQ + cpufreq_restore_default_governor(); +#endif } #endif diff --git a/arch/arm/mach-tegra/board-whistler-panel.c b/arch/arm/mach-tegra/board-whistler-panel.c index 9cc797739149..fdf3960d4684 100644 --- a/arch/arm/mach-tegra/board-whistler-panel.c +++ b/arch/arm/mach-tegra/board-whistler-panel.c @@ -25,6 +25,7 @@ #include <asm/mach-types.h> #include <linux/platform_device.h> #include <linux/earlysuspend.h> +#include <linux/kernel.h> #include <linux/pwm_backlight.h> #include <linux/tegra_pwm_bl.h> #include <mach/nvhost.h> @@ -33,6 +34,7 @@ #include <mach/iomap.h> #include <mach/dc.h> #include <mach/fb.h> +#include <mach/tegra_cpufreq.h> #include "devices.h" #include "gpio-names.h" @@ -299,6 +301,13 @@ static void whistler_panel_early_suspend(struct early_suspend *h) unsigned i; for (i = 0; i < num_registered_fb; i++) fb_blank(registered_fb[i], FB_BLANK_POWERDOWN); +#ifdef CONFIG_CPU_FREQ + cpufreq_save_default_governor(); + cpufreq_set_conservative_governor(); + cpufreq_set_conservative_governor_param( + SET_CONSERVATIVE_GOVERNOR_UP_THRESHOLD, + SET_CONSERVATIVE_GOVERNOR_DOWN_THRESHOLD); +#endif } static void whistler_panel_late_resume(struct early_suspend *h) @@ -306,6 +315,9 @@ static void whistler_panel_late_resume(struct early_suspend *h) unsigned i; for (i = 0; i < num_registered_fb; i++) fb_blank(registered_fb[i], FB_BLANK_UNBLANK); +#ifdef CONFIG_CPU_FREQ + cpufreq_restore_default_governor(); +#endif } #endif diff --git a/arch/arm/mach-tegra/common.c b/arch/arm/mach-tegra/common.c index e36af7691fc3..51aa082a45dd 100644 --- a/arch/arm/mach-tegra/common.c +++ b/arch/arm/mach-tegra/common.c @@ -36,6 +36,7 @@ #include <mach/dma.h> #include <mach/powergate.h> #include <mach/system.h> +#include <mach/tegra_cpufreq.h> #include "apbio.h" #include "board.h" @@ -496,3 +497,124 @@ void __init tegra_reserve(unsigned long carveout_size, unsigned long fb_size, tegra_carveout_start, tegra_carveout_start + tegra_carveout_size - 1); } + +#if defined CONFIG_HAS_EARLYSUSPEND && defined CONFIG_CPU_FREQ +static char cpufreq_gov_default[32]; +static char *cpufreq_gov_conservative = "conservative"; +static char *cpufreq_sysfs_place_holder="/sys/devices/system/cpu/cpu%i/cpufreq/scaling_governor"; +static char *cpufreq_gov_conservative_param="/sys/devices/system/cpu/cpufreq/conservative/%s"; + +static void cpufreq_set_governor(char *governor) +{ + struct file *scaling_gov = NULL; + char buf[128]; + int i; + loff_t offset = 0; + + if (governor == NULL) + return; + + for_each_cpu(i, cpu_present_mask) { + sprintf(buf, cpufreq_sysfs_place_holder, i); + scaling_gov = filp_open(buf, O_RDWR, 0); + if (scaling_gov != NULL) { + if (scaling_gov->f_op != NULL && + scaling_gov->f_op->write != NULL) + scaling_gov->f_op->write(scaling_gov, + governor, + strlen(governor), + &offset); + else + pr_err("f_op might be null\n"); + + filp_close(scaling_gov, NULL); + } else { + pr_err("%s. Can't open %s\n", __func__, buf); + } + } +} + +void cpufreq_save_default_governor(void) +{ + struct file *scaling_gov = NULL; + char buf[128]; + loff_t offset = 0; + + buf[127] = 0; + sprintf(buf, cpufreq_sysfs_place_holder,0); + scaling_gov = filp_open(buf, O_RDONLY, 0); + if (scaling_gov != NULL) { + if (scaling_gov->f_op != NULL && + scaling_gov->f_op->read != NULL) + scaling_gov->f_op->read(scaling_gov, + cpufreq_gov_default, + 32, + &offset); + else + pr_err("f_op might be null\n"); + + filp_close(scaling_gov, NULL); + } else { + pr_err("%s. Can't open %s\n", __func__, buf); + } +} + +void cpufreq_restore_default_governor(void) +{ + cpufreq_set_governor(cpufreq_gov_default); +} + +void cpufreq_set_conservative_governor_param(int up_th, int down_th) +{ + struct file *gov_param = NULL; + static char buf[128],parm[8]; + loff_t offset = 0; + + if (up_th <= down_th) { + printk(KERN_ERR "%s: up_th(%d) is lesser than down_th(%d)\n", + __func__, up_th, down_th); + return; + } + + sprintf(parm, "%d", up_th); + sprintf(buf, cpufreq_gov_conservative_param ,"up_threshold"); + gov_param = filp_open(buf, O_RDONLY, 0); + if (gov_param != NULL) { + if (gov_param->f_op != NULL && + gov_param->f_op->write != NULL) + gov_param->f_op->write(gov_param, + parm, + strlen(parm), + &offset); + else + pr_err("f_op might be null\n"); + + filp_close(gov_param, NULL); + } else { + pr_err("%s. Can't open %s\n", __func__, buf); + } + + sprintf(parm, "%d", down_th); + sprintf(buf, cpufreq_gov_conservative_param ,"down_threshold"); + gov_param = filp_open(buf, O_RDONLY, 0); + if (gov_param != NULL) { + if (gov_param->f_op != NULL && + gov_param->f_op->write != NULL) + gov_param->f_op->write(gov_param, + parm, + strlen(parm), + &offset); + else + pr_err("f_op might be null\n"); + + filp_close(gov_param, NULL); + } else { + pr_err("%s. Can't open %s\n", __func__, buf); + } +} + +void cpufreq_set_conservative_governor(void) +{ + cpufreq_set_governor(cpufreq_gov_conservative); +} +#endif diff --git a/arch/arm/mach-tegra/include/mach/tegra_cpufreq.h b/arch/arm/mach-tegra/include/mach/tegra_cpufreq.h new file mode 100644 index 000000000000..2812926c6ecd --- /dev/null +++ b/arch/arm/mach-tegra/include/mach/tegra_cpufreq.h @@ -0,0 +1,33 @@ +/* + * arch/arm/mach-tegra/include/mach/fb.h + * + * Copyright (C) 2010 Google, Inc. + * + * Author: + * Erik Gilling <konkers@google.com> + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef __MACH_TEGRA_CPUFREQ_H +#define __MACH_TEGRA_CPUFREQ_H + +#if defined CONFIG_HAS_EARLYSUSPEND && defined CONFIG_CPU_FREQ +#define SET_CONSERVATIVE_GOVERNOR_UP_THRESHOLD 95 +#define SET_CONSERVATIVE_GOVERNOR_DOWN_THRESHOLD 50 + +void cpufreq_save_default_governor(void); +void cpufreq_restore_default_governor(void); +void cpufreq_set_conservative_governor(void); +void cpufreq_set_conservative_governor_param(int up_th, int down_th); +#endif + +#endif |