Permalink
Browse files

Added OC/UV hack and cpufreq sysfs devices (FakeShmoo_cpu_temp, FakeS…

…hmoo_freq_voltage_table, FakeShmoo_UV_mV_table)*
  • Loading branch information...
1 parent 1ec7be8 commit 02af5771b4fda52613006658eeffcd2bc0dc1a22 @Cpasjuste committed Apr 8, 2011
View
@@ -1,7 +1,7 @@
VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 32
-EXTRAVERSION = .36
+EXTRAVERSION = .36-fakeShmoo-cpasjuste.1
NAME = Man-Eating Seals of Antiquity
# *DOCUMENTATION*
@@ -41,6 +41,74 @@
#include "ap15/ap15rm_private.h"
#include "ap15/project_relocation_table.h"
+#define USE_FAKE_SHMOO
+#ifdef USE_FAKE_SHMOO
+#include <linux/kernel.h>
+
+/*
+ * TEGRA AP20 CPU OC/UV Hack by Cpasjuste @ https://github.com/Cpasjuste/android_kernel_lg_p990
+ * Inspired by mblaster @ https://github.com/mblaster/linux_2.6.32_folio100
+*/
+
+// DEFAULT LG P990 VALUES
+// TEGRA_OC: max cpu low temp: -64
+// TEGRA_OC: max cpu high temp: 60
+// TEGRA_OC: min mV -> 770
+// TEGRA_OC: max mV -> 1000
+// TEGRA_OC: mV[0]-> 750
+// TEGRA_OC: mV[1]-> 800
+// TEGRA_OC: mV[2]-> 850
+// TEGRA_OC: mV[3]-> 875
+// TEGRA_OC: mV[4]-> 950
+// TEGRA_OC: mV[5]-> 1000
+// TEGRA_OC: Hz[0]-> 389000
+// TEGRA_OC: Hz[1]-> 503000
+// TEGRA_OC: Hz[2]-> 655000
+// TEGRA_OC: Hz[3]-> 760000
+// TEGRA_OC: Hz[4]-> 950000
+// TEGRA_OC: Hz[5]-> 1015000
+// TEGRA_OC: Hz[6]-> 1100000
+// TEGRA_OC: Hz[7]-> 1216000
+// TEGRA_OC: HwDeviceId-> 101
+// TEGRA_OC: SubClockId-> 0
+// TEGRA_OC: MinKHz-> 32
+
+#define MAX_OVERCLOCK (1400000)
+
+NvRmCpuShmoo fake_CpuShmoo; // Stored faked CpuShmoo values
+NvRmCpuShmoo stock_CpuShmoo; // Stored stock CpuShmoo values, unused
+NvU32 FakeShmooVmaxIndex = 8; // Max voltage index in the voltage tab (size-1)
+
+NvU32 FakeShmooVoltages[] = {
+ 750,
+ 800,
+ 850,
+ 875,
+ 950,
+ 1000,
+ 1100,
+ 1250,
+ 1250
+};
+NvRmScaledClkLimits FakepScaledCpuLimits = {
+ 101, // FakepScaledCpuLimits.HwDeviceId
+ 0, // FakepScaledCpuLimits.SubClockId
+ 32, // FakepScaledCpuLimits.MinKHz
+ // Clock table
+ {
+ 300000,
+ 500000,
+ 650000,
+ 750000,
+ 900000,
+ 1000000,
+ 1200000,
+ 1300000,
+ 1400000
+ }
+};
+#endif // USE_FAKE_SHMOO
+
#define NvRmPrivGetStepMV(hRmDevice, step) \
(s_ChipFlavor.pSocShmoo->ShmooVoltages[(step)])
@@ -226,9 +294,13 @@ NvRmPrivClockLimitsInit(NvRmDeviceHandle hRmDevice)
// Set upper clock boundaries for devices on CPU bus (CPU, Mselect,
// CMC) with combined Absolute/Scaled limits
+#ifdef USE_FAKE_SHMOO
+ CpuMaxKHz = MAX_OVERCLOCK;
+#else
CpuMaxKHz = pSKUedLimits->CpuMaxKHz;
CpuMaxKHz = NV_MIN(
CpuMaxKHz, s_ClockRangeLimits[NvRmModuleID_Cpu].MaxKHz);
+#endif
s_ClockRangeLimits[NvRmModuleID_Cpu].MaxKHz = CpuMaxKHz;
if ((hRmDevice->ChipId.Id == 0x15) || (hRmDevice->ChipId.Id == 0x16))
{
@@ -893,17 +965,32 @@ static NvError NvRmBootArgChipShmooGet(
offset = BootArgSh.CpuShmooVoltagesListOffset;
size = BootArgSh.CpuShmooVoltagesListSize;
NV_ASSERT (offset + size <= TotalSize);
+#ifdef USE_FAKE_SHMOO
+ s_CpuShmoo.ShmooVoltages = &FakeShmooVoltages[0];
+ stock_CpuShmoo.ShmooVoltages = (const NvU32*)((NvUPtr)s_pShmooData + offset);
+ fake_CpuShmoo.ShmooVoltages = &FakeShmooVoltages[0];
+#else
s_CpuShmoo.ShmooVoltages =(const NvU32*)((NvUPtr)s_pShmooData + offset);
+#endif
size /= sizeof(*s_CpuShmoo.ShmooVoltages);
NV_ASSERT((size * sizeof(*s_CpuShmoo.ShmooVoltages) ==
BootArgSh.CpuShmooVoltagesListSize) && (size > 1));
+#ifdef USE_FAKE_SHMOO
+ s_CpuShmoo.ShmooVmaxIndex = FakeShmooVmaxIndex;
+#else
s_CpuShmoo.ShmooVmaxIndex = size - 1;
-
+#endif
offset = BootArgSh.CpuScaledLimitsOffset;
size = BootArgSh.CpuScaledLimitsSize;
NV_ASSERT (offset + size <= TotalSize);
+#ifdef USE_FAKE_SHMOO
+ s_CpuShmoo.pScaledCpuLimits = &FakepScaledCpuLimits;
+ stock_CpuShmoo.pScaledCpuLimits = (const NvRmScaledClkLimits*)((NvUPtr)s_pShmooData + offset);
+ fake_CpuShmoo.pScaledCpuLimits = &FakepScaledCpuLimits;
+#else
s_CpuShmoo.pScaledCpuLimits =
(const NvRmScaledClkLimits*)((NvUPtr)s_pShmooData + offset);
+#endif
NV_ASSERT(size == sizeof(*s_CpuShmoo.pScaledCpuLimits));
}
else
@@ -52,6 +52,23 @@
#include "ap20/ap20rm_power_dfs.h"
#include "ap20/ap20rm_clocks.h"
+#define USE_FAKE_SHMOO
+#ifdef USE_FAKE_SHMOO
+#include <linux/kernel.h>
+
+/*
+ * TEGRA AP20 CPU OC/UV Hack by Cpasjuste @ https://github.com/Cpasjuste/tegra_lg_p990_kernel_oc_uv
+ * Inspired by mblaster @ https://github.com/mblaster/linux_2.6.32_folio100
+*/
+
+extern NvRmCpuShmoo fake_CpuShmoo; // Stored faked CpuShmoo
+extern int *FakeShmoo_UV_mV_Ptr; // Stored voltage table from cpufreq sysfs
+extern NvU32 FakeShmooVmaxIndex; // Max voltage index in the voltage tab (size-1)
+
+NvRmDfs *fakeShmoo_Dfs; // Used to get temp from cpufreq
+
+#endif // USE_FAKE_SHMOO
+
/*****************************************************************************/
// Initial DFS configuration
@@ -810,6 +827,10 @@ static void DfsParametersInit(NvRmDfs* pDfs)
pDfs->LowCornerKHz.Domains[i] = pDfs->DfsParameters[i].MinKHz;
pDfs->HighCornerKHz.Domains[i] = pDfs->DfsParameters[i].MaxKHz;
}
+#ifdef USE_FAKE_SHMOO
+ // Set maximum scaling frequency to 1000mhz at boot
+ pDfs->HighCornerKHz.Domains[NvRmDfsClockId_Cpu] = 1000000;
+#endif
pDfs->CpuCornersShadow.MinKHz =
pDfs->LowCornerKHz.Domains[NvRmDfsClockId_Cpu];
pDfs->CpuCornersShadow.MaxKHz =
@@ -1844,6 +1865,10 @@ NvError NvRmPrivDfsInit(NvRmDeviceHandle hRmDeviceHandle)
NvRmDfsFrequencies DfsKHz;
NvRmDfs* pDfs = &s_Dfs;
+#ifdef USE_FAKE_SHMOO
+ fakeShmoo_Dfs = &s_Dfs;
+#endif
+
NV_ASSERT(hRmDeviceHandle);
DfsHintsPrintInit();
@@ -2226,6 +2251,21 @@ DvsChangeCpuVoltage(
NvRmDvs* pDvs,
NvRmMilliVolts TargetMv)
{
+#ifdef USE_FAKE_SHMOO
+ // Voltage hack
+ int i = 0;
+ if( FakeShmoo_UV_mV_Ptr != NULL )
+ {
+ for(i=0; i <FakeShmooVmaxIndex+1; i++)
+ {
+ if(fake_CpuShmoo.ShmooVoltages[i] == TargetMv)
+ {
+ TargetMv -= FakeShmoo_UV_mV_Ptr[i];
+ break;
+ }
+ }
+ }
+#endif // USE_FAKE_SHMOO
NV_ASSERT(TargetMv >= pDvs->MinCpuMv);
NV_ASSERT(TargetMv <= pDvs->NominalCpuMv);
View
@@ -32,6 +32,24 @@
#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_CORE, \
"cpufreq-core", msg)
+#define USE_FAKE_SHMOO
+#ifdef USE_FAKE_SHMOO
+#include <arch/arm/mach-tegra/nvrm/core/common/nvrm_clocks_limits_private.h>
+#include <arch/arm/mach-tegra/nvrm/core/common/nvrm_power_dfs.h>
+#include <nvrm_diag.h>
+
+/*
+ * TEGRA AP20 CPU OC/UV Hack by Cpasjuste @ https://github.com/Cpasjuste/tegra_lg_p990_kernel_oc_uv
+ * Inspired by mblaster @ https://github.com/mblaster/linux_2.6.32_folio100
+*/
+
+extern int FakeShmooVmaxIndex; // Max voltage index in the voltage tab (size-1)
+int *FakeShmoo_UV_mV_Ptr; // Stored voltage table from cpufreq sysfs
+extern NvRmCpuShmoo fake_CpuShmoo; // Stored faked CpuShmoo values
+extern NvRmCpuShmoo stock_CpuShmoo; // Stored stock CpuShmoo values, unused
+extern NvRmDfs *fakeShmoo_Dfs;
+#endif // USE_FAKE_SHMOO
+
/**
* The "cpufreq driver" - the arch- or hardware-dependent low
* level driver of CPUFreq support, and its spinlock. This lock
@@ -647,6 +665,56 @@ static ssize_t show_scaling_setspeed(struct cpufreq_policy *policy, char *buf)
return policy->governor->show_setspeed(policy, buf);
}
+#ifdef USE_FAKE_SHMOO
+static ssize_t show_FakeShmoo_cpu_temp(struct cpufreq_policy *policy, char *buf)
+{
+ int pTemp = 0;
+
+ NvRmDtt* pDtt = &fakeShmoo_Dfs->ThermalThrottler;
+ NvOdmTmonTemperatureGet(pDtt->hOdmTcore, &pTemp);
+
+ return sprintf(buf, "%i\n", pTemp);
+}
+
+static ssize_t show_FakeShmoo_freq_voltage_table(struct cpufreq_policy *policy, char *buf)
+{
+ int i;
+ char *table = buf;
+
+ for( i=FakeShmooVmaxIndex; i>-1; i-- )
+ {
+ table += sprintf(table, "%d %d %d\n", fake_CpuShmoo.pScaledCpuLimits->MaxKHzList[i], fake_CpuShmoo.ShmooVoltages[i], fake_CpuShmoo.ShmooVoltages[i] - FakeShmoo_UV_mV_Ptr[i] );
+ }
+ return table - buf;
+}
+
+
+static ssize_t show_FakeShmoo_UV_mV_table(struct cpufreq_policy *policy, char *buf)
+{
+ int i;
+ char *table = buf;
+
+ for( i=FakeShmooVmaxIndex; i>-1; i-- )
+ {
+ table += sprintf(table, "%d ", FakeShmoo_UV_mV_Ptr[i] );
+ }
+ table += sprintf(table, "\n" );
+ return table - buf;
+}
+
+static ssize_t store_FakeShmoo_UV_mV_table(struct cpufreq_policy *policy, const char *buf, size_t count)
+{
+ int ret = sscanf( buf, "%i %i %i %i %i %i %i %i %i", &FakeShmoo_UV_mV_Ptr[8], &FakeShmoo_UV_mV_Ptr[7], &FakeShmoo_UV_mV_Ptr[6],
+ &FakeShmoo_UV_mV_Ptr[5], &FakeShmoo_UV_mV_Ptr[4],
+ &FakeShmoo_UV_mV_Ptr[3], &FakeShmoo_UV_mV_Ptr[2],
+ &FakeShmoo_UV_mV_Ptr[1], &FakeShmoo_UV_mV_Ptr[0] );
+ if (ret != 1)
+ return -EINVAL;
+
+ return count;
+}
+#endif // USE_FAKE_SHMOO
+
#define define_one_ro(_name) \
static struct freq_attr _name = \
__ATTR(_name, 0444, show_##_name, NULL)
@@ -672,6 +740,11 @@ define_one_rw(scaling_min_freq);
define_one_rw(scaling_max_freq);
define_one_rw(scaling_governor);
define_one_rw(scaling_setspeed);
+#ifdef USE_FAKE_SHMOO
+define_one_ro(FakeShmoo_cpu_temp);
+define_one_ro(FakeShmoo_freq_voltage_table);
+define_one_rw(FakeShmoo_UV_mV_table);
+#endif // USE_FAKE_SHMOO
static struct attribute *default_attrs[] = {
&cpuinfo_min_freq.attr,
@@ -685,6 +758,11 @@ static struct attribute *default_attrs[] = {
&scaling_driver.attr,
&scaling_available_governors.attr,
&scaling_setspeed.attr,
+#ifdef USE_FAKE_SHMOO
+ &FakeShmoo_cpu_temp.attr,
+ &FakeShmoo_freq_voltage_table.attr,
+ &FakeShmoo_UV_mV_table.attr,
+#endif // USE_FAKE_SHMOO
NULL
};
@@ -1970,6 +2048,11 @@ static int __init cpufreq_core_init(void)
{
int cpu;
+#ifdef USE_FAKE_SHMOO
+ // Allocate some memory for the voltage tab
+ FakeShmoo_UV_mV_Ptr = kzalloc(sizeof(int)*(FakeShmooVmaxIndex+1), GFP_KERNEL);
+#endif // USE_FAKE_SHMOO
+
for_each_possible_cpu(cpu) {
per_cpu(policy_cpu, cpu) = -1;
init_rwsem(&per_cpu(cpu_policy_rwsem, cpu));

0 comments on commit 02af577

Please sign in to comment.