Files
android_kernel_samsung_msm8…/drivers/devfreq/governor_msm_cpufreq.c
Saravana Kannan 4bbc993b17 devfreq: Add MSM CPUfreq governor
The MSM CPUfreq devfreq governor determines the CPU to DDR bandwidth vote
based on the current CPU frequency of all the active CPUs.

This functionality used to be a part of the MSM CPUfreq driver that
directly voted for the CPU to DDR bandwidth using MSM bus scaling APIs.
This refactor decouples CPU to DDR BW scaling from CPU frequency and allows
switch between various CPU BW governors.

The bandwidth values in the msm-cpufreq table have to be updated since the
new CPU BW driver does the MBps to Bps conversion correctly. The MSM
CPUfreq driver used to do * 1000 * 1000 to convert from MBps to Bps instead
of doing * 1024 * 1024.

Change-Id: I184f09d628a1b27d52506d2f760d65831f1a1110
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2014-01-03 11:20:35 -08:00

86 lines
1.9 KiB
C

/*
* Copyright (c) 2013, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* 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.
*/
#include <linux/devfreq.h>
#include <mach/cpufreq.h>
#include "governor.h"
DEFINE_MUTEX(df_lock);
static struct devfreq *df;
static int devfreq_msm_cpufreq_get_freq(struct devfreq *df,
unsigned long *freq,
u32 *flag)
{
*freq = msm_cpufreq_get_bw();
return 0;
}
int devfreq_msm_cpufreq_update_bw(void)
{
int ret = 0;
mutex_lock(&df_lock);
if (df) {
mutex_lock(&df->lock);
ret = update_devfreq(df);
mutex_unlock(&df->lock);
}
mutex_unlock(&df_lock);
return ret;
}
static int devfreq_msm_cpufreq_ev_handler(struct devfreq *devfreq,
unsigned int event, void *data)
{
int ret;
switch (event) {
case DEVFREQ_GOV_START:
mutex_lock(&df_lock);
df = devfreq;
mutex_unlock(&df_lock);
ret = devfreq_msm_cpufreq_update_bw();
if (ret) {
pr_err("Unable to update BW! Gov start failed!\n");
return ret;
}
devfreq_monitor_stop(df);
pr_debug("Enabled MSM CPUfreq governor\n");
break;
case DEVFREQ_GOV_STOP:
mutex_lock(&df_lock);
df = NULL;
mutex_unlock(&df_lock);
pr_debug("Disabled MSM CPUfreq governor\n");
break;
}
return 0;
}
static struct devfreq_governor devfreq_msm_cpufreq = {
.name = "msm_cpufreq",
.get_target_freq = devfreq_msm_cpufreq_get_freq,
.event_handler = devfreq_msm_cpufreq_ev_handler,
};
int register_devfreq_msm_cpufreq(void)
{
return devfreq_add_governor(&devfreq_msm_cpufreq);
}