Permalink
Browse files

Merge branch 'OC-testing'

* OC-testing:
  testing oc code from atrix
  testing :)

Conflicts:
	maek-kernel.sh
  • Loading branch information...
2 parents 0eff569 + 13ef379 commit a791da5650f39fa2b416e0d45791131a6c69d8db @Shabbypenguin committed Sep 9, 2011
@@ -41,13 +41,49 @@
#include "ap15/ap15rm_private.h"
#include "ap15/project_relocation_table.h"
+#include <linux/module.h>
#define NvRmPrivGetStepMV(hRmDevice, step) \
(s_ChipFlavor.pSocShmoo->ShmooVoltages[(step)])
-// Extended clock limits IDs
-typedef enum
-{
+#define USE_FAKE_SHMOO
+
+#ifdef USE_FAKE_SHMOO
+#include <linux/kernel.h>
+
+NvRmCpuShmoo fake_CpuShmoo; // Pointer to fake CpuShmoo values
+NvU32 FakeShmooVmaxIndex = 6; // Max voltage index in the voltage tab (size-1)
+#define MAX_OVERCLOCK (1100000)
+NvU32 FakeShmooVoltages[] = {
+ 770,
+ 800,
+ 875,
+ 950,
+ 1000,
+ 1100,
+};
+
+NvRmScaledClkLimits FakepScaledCpuLimits = {
+ 101, // FakepScaledCpuLimits.HwDeviceId
+ 0, // FakepScaledCpuLimits.SubClockId
+ 32, // FakepScaledCpuLimits.MinKHz
+ // Clock table
+ {
+ 300000,
+ 500000,
+ 750000,
+ 900000,
+ 1000000,
+ 1100000,
+ }
+};
+
+#endif // USE_FAKE_SHMOO
+
+
+ // Extended clock limits IDs
+ typedef enum
+ {
// Last Module ID
NvRmClkLimitsExtID_LastModuleID = NvRmPrivModuleID_Num,
@@ -226,9 +262,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))
{
@@ -380,12 +420,21 @@ NvRmPrivModuleVscaleGetMV(
// Use CPU specific voltage ladder if SoC has dedicated CPU rail
if (s_ChipFlavor.pCpuShmoo && (Module == NvRmModuleID_Cpu))
{
+#ifdef USE_FAKE_SHMOO
+ for (i = 0; i < fake_CpuShmoo.ShmooVmaxIndex; i++)
+ {
+ if (FreqKHz <= pScale[i])
+ break;
+ }
+ return fake_CpuShmoo.ShmooVoltages[i];
+#else
for (i = 0; i < s_ChipFlavor.pCpuShmoo->ShmooVmaxIndex; i++)
{
if (FreqKHz <= pScale[i])
break;
}
return s_ChipFlavor.pCpuShmoo->ShmooVoltages[i];
+#endif
}
// Use common ladder for all other modules or CPU on core rail
for (i = 0; i < s_ChipFlavor.pSocShmoo->ShmooVmaxIndex; i++)
@@ -408,6 +457,12 @@ NvRmPrivModuleVscaleGetMaxKHzList(
// Use CPU specific voltage ladder if SoC has dedicated CPU rail
if (s_ChipFlavor.pCpuShmoo && (Module == NvRmModuleID_Cpu))
*pListSize = s_ChipFlavor.pCpuShmoo->ShmooVmaxIndex + 1;
+#ifdef USE_FAKE_SHMOO
+if
+ (*pListSize = fake_CpuShmoo.ShmooVmaxIndex + 1);
+#else
+ *pListSize = s_ChipFlavor.pCpuShmoo->ShmooVmaxIndex + 1;
+#endif
else
*pListSize = s_ChipFlavor.pSocShmoo->ShmooVmaxIndex + 1;
@@ -758,6 +813,8 @@ static NvError NvRmBootArgChipShmooGet(
NvRmMemHandle hMem = NULL;
NvError err = NvSuccess;
ExecPlatform env;
+ int i = 0;
+ int j = 0;
// Retrieve shmoo data
err = NvOsBootArgGet(NvBootArgKey_ChipShmoo, &BootArgSh, sizeof(BootArgSh));
@@ -890,6 +947,14 @@ static NvError NvRmBootArgChipShmooGet(
// Shmoo data for dedicated CPU domain
pChipFlavor->pCpuShmoo = &s_CpuShmoo;
+#ifdef USE_FAKE_SHMOO
+ s_CpuShmoo.ShmooVoltages = &FakeShmooVoltages[0];
+ s_CpuShmoo.ShmooVmaxIndex = FakeShmooVmaxIndex;
+ s_CpuShmoo.pScaledCpuLimits = &FakepScaledCpuLimits;
+ fake_CpuShmoo.ShmooVoltages = &FakeShmooVoltages[0];
+ fake_CpuShmoo.ShmooVmaxIndex = FakeShmooVmaxIndex;
+ fake_CpuShmoo.pScaledCpuLimits = &FakepScaledCpuLimits;
+#else
offset = BootArgSh.CpuShmooVoltagesListOffset;
size = BootArgSh.CpuShmooVoltagesListSize;
NV_ASSERT (offset + size <= TotalSize);
@@ -899,16 +964,37 @@ static NvError NvRmBootArgChipShmooGet(
BootArgSh.CpuShmooVoltagesListSize) && (size > 1));
s_CpuShmoo.ShmooVmaxIndex = size - 1;
+ for (i = 0; i < size; i++) {
+ printk(KERN_ERR "ShmooVoltage[%d] %u\n", i, s_CpuShmoo.ShmooVoltages[i]);
+ }
+
offset = BootArgSh.CpuScaledLimitsOffset;
size = BootArgSh.CpuScaledLimitsSize;
NV_ASSERT (offset + size <= TotalSize);
s_CpuShmoo.pScaledCpuLimits =
(const NvRmScaledClkLimits*)((NvUPtr)s_pShmooData + offset);
NV_ASSERT(size == sizeof(*s_CpuShmoo.pScaledCpuLimits));
- }
- else
- {
- pChipFlavor->pCpuShmoo = NULL;
+/*
+typedef struct NvRmScaledClkLimitsRec
+{
+ NvU32 HwDeviceId;
+ NvU32 SubClockId;
+ NvRmFreqKHz MinKHz;
+ NvRmFreqKHz MaxKHzList[NVRM_VOLTAGE_STEPS];
+} NvRmScaledClkLimits;
+*/
+ for (i = 0; i < size; i++) {
+ printk(KERN_ERR "ScaledCpuLimits[%d] did: %u scid: %u\n minkhz: %u\n", i, s_CpuShmoo.pScaledCpuLimits[i].HwDeviceId, s_CpuShmoo.pScaledCpuLimits[i].SubClockId, s_CpuShmoo.pScaledCpuLimits[i].MinKHz);
+ for (j = 0; j < NVRM_VOLTAGE_STEPS; j++) {
+ printk(KERN_ERR " MaxKHzList[%d]: %u\n", j, s_CpuShmoo.pScaledCpuLimits[i].MaxKHzList[j]);
+ }
+ }
+#endif
+
+ }
+ else
+ {
+ pChipFlavor->pCpuShmoo = NULL;
}
return err;
@@ -51,6 +51,14 @@
#include "ap15/ap15rm_clocks.h"
#include "ap20/ap20rm_power_dfs.h"
#include "ap20/ap20rm_clocks.h"
+#define USE_FAKE_SHMOO
+#ifdef USE_FAKE_SHMOO
+#include <linux/kernel.h>
+extern NvRmCpuShmoo fake_CpuShmoo; // Pointer to fake CpuShmoo
+extern int *FakeShmoo_UV_mV_Ptr; // Stored voltage table from cpufreq sysfs
+NvRmDfs *fakeShmoo_Dfs; // Used to get temp from cpufreq
+#endif // USE_FAKE_SHMOO
+
/*****************************************************************************/
@@ -815,6 +823,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 1015MHz at boot
+ pDfs->HighCornerKHz.Domains[NvRmDfsClockId_Cpu] = 1000000;
+#endif
pDfs->CpuCornersShadow.MinKHz =
pDfs->LowCornerKHz.Domains[NvRmDfsClockId_Cpu];
pDfs->CpuCornersShadow.MaxKHz =
@@ -2001,6 +2013,10 @@ void NvRmPrivDfsResync(void)
NvRmDfsFrequencies DfsKHz;
NvRmDfs* pDfs = &s_Dfs;
+#ifdef USE_FAKE_SHMOO
+ fakeShmoo_Dfs = &s_Dfs; // Crappy way to get temp ?!
+#endif
+
DfsClockFreqGet(pDfs->hRm, &DfsKHz);
NvOsIntrMutexLock(pDfs->hIntrMutex);
@@ -2168,13 +2184,31 @@ DvsChangeCpuVoltage(
NvRmDvs* pDvs,
NvRmMilliVolts TargetMv)
{
+#ifdef USE_FAKE_SHMOO
+ // Voltage hack
+ int i = 0;
+ if( FakeShmoo_UV_mV_Ptr != NULL )
+ {
+ for(i=0; i <fake_CpuShmoo.ShmooVmaxIndex+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);
if (pDvs->CurrentCpuMv != TargetMv)
{
NvRmPmuSetVoltage(hRm, pDvs->CpuRailAddress, TargetMv, NULL);
pDvs->CurrentCpuMv = TargetMv;
+#ifdef USE_FAKE_SHMOO
+ //printk( "*** fakeShmoo **** -> CurrentCpuMv : %i\n", TargetMv );
+#endif
}
}
View
@@ -32,6 +32,16 @@
#define dprintk(msg...) cpufreq_debug_printk(CPUFREQ_DEBUG_CORE, \
"cpufreq-core", msg)
+#define USE_FAKE_SHMOO
+#ifdef USE_FAKE_SHMOO
+#include "../nvrm/core/common/nvrm_clocks_limits_private.h"
+#include "../nvrm/core/common/nvrm_power_dfs.h"
+#include <nvrm_diag.h>
+int *FakeShmoo_UV_mV_Ptr; // Stored voltage table from cpufreq sysfs
+extern NvRmCpuShmoo fake_CpuShmoo; // Stored faked CpuShmoo values
+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 +657,58 @@ 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_cpu_temp(struct cpufreq_policy *policy, char *buf)
+{
+ int pTemp = 0;
+
+ if( fakeShmoo_Dfs != NULL )
+ {
+ NvRmDtt* pDtt = &fakeShmoo_Dfs->ThermalThrottler;
+ NvOdmTmonTemperatureGet(pDtt->hOdmTcore, &pTemp);
+ }
+ return sprintf(buf, "%i\n", pTemp);
+}
+
+static ssize_t show_frequency_voltage_table(struct cpufreq_policy *policy, char *buf)
+{
+ int i;
+ char *table = buf;
+
+ for( i=fake_CpuShmoo.ShmooVmaxIndex; 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_UV_mV_table(struct cpufreq_policy *policy, char *buf)
+{
+ int i;
+ char *table = buf;
+
+ for( i=fake_CpuShmoo.ShmooVmaxIndex; i>-1; i-- )
+ {
+ table += sprintf(table, "%d ", FakeShmoo_UV_mV_Ptr[i] );
+ }
+ table += sprintf(table, "\n" );
+ return table - buf;
+}
+
+static ssize_t store_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", &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 +734,12 @@ 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(cpu_temp);
+define_one_ro(frequency_voltage_table);
+define_one_rw(UV_mV_table);
+#endif // USE_FAKE_SHMOO
+
static struct attribute *default_attrs[] = {
&cpuinfo_min_freq.attr,
@@ -685,6 +753,11 @@ static struct attribute *default_attrs[] = {
&scaling_driver.attr,
&scaling_available_governors.attr,
&scaling_setspeed.attr,
+#ifdef USE_FAKE_SHMOO
+ &cpu_temp.attr,
+ &frequency_voltage_table.attr,
+ &UV_mV_table.attr,
+#endif // USE_FAKE_SHMOO
NULL
};
@@ -1993,6 +2066,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)*(fake_CpuShmoo.ShmooVmaxIndex+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));
View
@@ -1,12 +0,0 @@
-#!/bin/bash
-rm config
-cp -a ~/config.gz .
-gunzip config.gz
-cp -a config .config
-export ARCH=arm
-export CROSS_COMPILE=arm-linux-gnueabi-
-make clean
-make oldconfig
-KBUILD_BUILD_VERSION="Photon-Penguins_v0.0.3-oc"
-export KBUILD_BUILD_VERSION
-make zImage

0 comments on commit a791da5

Please sign in to comment.