Skip to content

Commit

Permalink
Add OTF code
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Donka committed Jul 18, 2012
1 parent 9b15d4a commit b5743c0
Show file tree
Hide file tree
Showing 18 changed files with 974 additions and 42 deletions.
15 changes: 0 additions & 15 deletions arch/arm/mach-tegra/Kconfig.lge
Expand Up @@ -13,21 +13,6 @@ config FAKE_SHMOO
depends on MACH_STAR
default y

config BOOST_PERIPHERALS
bool "Tegra2 Overclocking Peripheral Enable"
depends on MACH_STAR
default y

config MAX_AVP_OC_FREQ
int "AVP Overclock Frequency"
default 240000
depends on FAKE_SHMOO && BOOST_PERIPHERALS

config MAX_3D_OC_FREQ
int "3D Overclock Frequency"
default 340000
depends on FAKE_SHMOO && BOOST_PERIPHERALS

config STAR_PMIC
bool "star pmic test"
depends on MACH_STAR
Expand Down
10 changes: 7 additions & 3 deletions arch/arm/mach-tegra/nvrm/core/ap20/ap20rm_clock_config.c
Expand Up @@ -42,6 +42,8 @@
#include "ap15/ap15rm_private.h"
#include "nvodm_query.h"

extern unsigned int vdefreq;

// Enable CPU/EMC ratio policy
#define NVRM_LIMIT_CPU_EMC_RATIO (1)

Expand Down Expand Up @@ -1212,12 +1214,14 @@ Ap20SystemClockSourceFind(
*/
if (DomainKHz > (NvRmPrivGetClockSourceFreq(NvRmClockSource_PllP0) >> 1))
{
C1KHz = M1KHz = DomainKHz;
C1KHz = M1KHz = DomainKHz;
c = NvRmPrivFindFreqMinAbove(NvRmClockDivider_Fractional_2,
NvRmPrivGetClockSourceFreq(NvRmClockSource_PllC0),
vdefreq,
//NvRmPrivGetClockSourceFreq(NvRmClockSource_PllC0),
MaxKHz, &C1KHz);
m = NvRmPrivFindFreqMinAbove(NvRmClockDivider_Fractional_2,
NvRmPrivGetClockSourceFreq(NvRmClockSource_PllM0),
vdefreq,
//NvRmPrivGetClockSourceFreq(NvRmClockSource_PllM0),
MaxKHz, &M1KHz);

SourceKHz = NV_MAX(NV_MAX(C1KHz, M1KHz), P2KHz);
Expand Down
19 changes: 12 additions & 7 deletions arch/arm/mach-tegra/nvrm/core/ap20/ap20rm_power_dfs.h
Expand Up @@ -242,11 +242,16 @@ extern "C"
* If thresholds are set to 0, the values are derived at run time from the
* characterization data
*/
#define NVRM_CPU1_ON_MIN_KHZ (0)
#define NVRM_CPU1_OFF_MAX_KHZ (0)
extern unsigned int NVRM_CPU1_ON_MIN_KHZ;
extern unsigned int NVRM_CPU1_OFF_MAX_KHZ;
extern unsigned int NVRM_CPU1_ON_PENDING_MS;
extern unsigned int NVRM_CPU1_OFF_PENDING_MS;

#define NVRM_CPU1_ON_PENDING_MS (1500)
#define NVRM_CPU1_OFF_PENDING_MS (1000)
//#define NVRM_CPU1_ON_MIN_KHZ (0)
//#define NVRM_CPU1_OFF_MAX_KHZ (0)

//#define NVRM_CPU1_ON_PENDING_MS (1500)
//#define NVRM_CPU1_OFF_PENDING_MS (1000)

/**
* Defines AP20 Thermal policy parameters.
Expand All @@ -267,9 +272,9 @@ extern "C"
* ODM should also set a critical threshold to trigger h/w shutdown
* mechanism.
*/
#define NVRM_DTT_DEGREES_HIGH (90L)
#define NVRM_DTT_DEGREES_LOW (60L)
#define NVRM_DTT_DEGREES_HYSTERESIS (5L)
#define NVRM_DTT_DEGREES_HIGH (95L)
#define NVRM_DTT_DEGREES_LOW (65L)
#define NVRM_DTT_DEGREES_HYSTERESIS (8L)

#define NVRM_DTT_VOLTAGE_THROTTLE_MV (NvRmVoltsMaximum)
#define NVRM_DTT_CPU_DELTA_KHZ (100000UL)
Expand Down
8 changes: 4 additions & 4 deletions arch/arm/mach-tegra/nvrm/core/common/nvrm_clocks_limits.c
Expand Up @@ -222,12 +222,12 @@ NvRmPrivClockLimitsInit(NvRmDeviceHandle hRmDevice)
// CPU clock duh!
pSKUedLimits->CpuMaxKHz = MAX_CPU_OC_FREQ;

#ifdef CONFIG_BOOST_PERIPHERALS
// AVP clock
pSKUedLimits->AvpMaxKHz = CONFIG_MAX_AVP_OC_FREQ;
extern unsigned int avpfreq;
pSKUedLimits->AvpMaxKHz = avpfreq;
// 3D clock
pSKUedLimits->TDMaxKHz = CONFIG_MAX_3D_OC_FREQ;
#endif // CONFIG_BOOST_PERIPHERALS
extern unsigned int gpufreq;
pSKUedLimits->TDMaxKHz = gpufreq;
#endif // CONFIG_FAKE_SHMOO

NvOsDebugPrintf("NVRM corner (%d, %d)\n",
Expand Down
20 changes: 13 additions & 7 deletions arch/arm/mach-tegra/odm_kit/star/query/nvodm_query.c
Expand Up @@ -974,16 +974,16 @@ NvOdmQueryDapPortGetProperty(
{ NvOdmDapPort_None, NvOdmDapPort_None, { 0, 0, 0, 0 } },
// I2S1 (DAC1) <-> DAP1 <-> HIFICODEC
{ NvOdmDapPort_I2s1, NvOdmDapPort_HifiCodecType,
{ 2, 24, 48000, NvOdmQueryI2sDataCommFormat_I2S } }, // Dap1
{ 2, 16, 44100, NvOdmQueryI2sDataCommFormat_I2S } }, // Dap1
// I2S2 (DAC2) <-> DAP2 <-> VOICECODEC
{NvOdmDapPort_I2s2, NvOdmDapPort_VoiceCodecType,
{2, 16, 22000, NvOdmQueryI2sDataCommFormat_Dsp } }, // Dap2
{2, 16, 8000, NvOdmQueryI2sDataCommFormat_Dsp } }, // Dap2
// I2S2 (DAC2) <-> DAP3 <-> BASEBAND
{NvOdmDapPort_I2s2, NvOdmDapPort_BaseBand,
{2, 16, 22000, NvOdmQueryI2sDataCommFormat_I2S } }, // Dap3
{2, 16, 8000, NvOdmQueryI2sDataCommFormat_I2S } }, // Dap3
// I2S2 (DAC2) <-> DAP4 <-> BLUETOOTH
{NvOdmDapPort_I2s2, NvOdmDapPort_BlueTooth,
{2, 16, 16000, NvOdmQueryI2sDataCommFormat_I2S } }, // Dap4
{2, 16, 8000, NvOdmQueryI2sDataCommFormat_I2S } }, // Dap4
};

if (DapPortId && DapPortId<NV_ARRAY_SIZE(s_Property))
Expand Down Expand Up @@ -1460,13 +1460,19 @@ NvU32 NvOdmQueryMemSize(NvOdmMemoryType MemType)
}
}

#define ONE_MB 0x00100000
NvU32 NvOdmQueryCarveoutSize(void)
{
return (128*ONE_MB);
//20100802 increase carveout memory
#if 0
return 0x08000000; // 128 MB <- 64MB
#else
extern unsigned int nvmap_carveout_size;
/* carveout size is controled by the nvmem boot param. nvmem=128M is default for LG Star */
return nvmap_carveout_size;
#endif
}

NvU32 NvOdmQuerySecureRegionSize(void)
{
return (8*ONE_MB);// 8 MB
return 0x00800000;// 8 MB
}
Expand Up @@ -229,6 +229,7 @@ NvOdmQueryPinMux(
NvU32 Personality = 0;
NvU32 Ril = 0;
NvOdmServicesKeyListHandle hKeyList;
hKeyList = NvOdmServicesKeyListOpen();
if (hKeyList)
{
CustomerOption =
Expand Down
1 change: 1 addition & 0 deletions drivers/misc/Makefile
Expand Up @@ -31,3 +31,4 @@ obj-$(CONFIG_WL127X_RFKILL) += wl127x-rfkill.o
obj-$(CONFIG_APANIC) += apanic.o
obj-$(CONFIG_TSPDRV) += tspdrv/
obj-$(CONFIG_BLX) += blx.o
obj-y += otf/
5 changes: 5 additions & 0 deletions drivers/misc/otf/Makefile
@@ -0,0 +1,5 @@
#
# Makefile for OTF.
#

obj-y += otf_vde.o otf_cpu1.o otf_gpu.o otf_avp.o otf_nitro.o
20 changes: 20 additions & 0 deletions drivers/misc/otf/otf.h
@@ -0,0 +1,20 @@
#ifndef _OTF_H
#define _OTF_H
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <asm/uaccess.h>

#undef CFS_BOOST
#undef CONFIG_CFS_BOOST
#define CFS_BOOST_NICE -15

extern unsigned int NVRM_CPU1_ON_MIN_KHZ;
extern unsigned int NVRM_CPU1_OFF_MAX_KHZ;
extern unsigned int NVRM_CPU1_ON_PENDING_MS;
extern unsigned int NVRM_CPU1_OFF_PENDING_MS;
extern unsigned int avpfreq;
extern unsigned int gpufreq;
extern unsigned int vdefreq;

#endif
78 changes: 78 additions & 0 deletions drivers/misc/otf/otf_avp.c
@@ -0,0 +1,78 @@
/* drivers/misc/otf/otf_avp.c
*
* Original source by Benee (c) 2012
*
* Modified for the OTF by vadonka 2012
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
*/

#include <linux/init.h>
#include <linux/device.h>
#include <linux/miscdevice.h>

/* Static containers
* avpfreq values are set in the init/otfinit.c
*/
extern unsigned int MIN_AVPFREQ;
extern unsigned int MAX_AVPFREQ;

/* Boot time value taken from the kernel cmdline */
extern unsigned int avpfreq;

static ssize_t avpinfo_boot(struct device * dev, struct device_attribute * attr, char * buf)
{
return sprintf(buf, "%u\n", avpfreq);
}

static ssize_t avpinfo_min(struct device * dev, struct device_attribute * attr, char * buf)
{
return sprintf(buf, "%u\n", MIN_AVPFREQ);
}

static ssize_t avpinfo_max(struct device * dev, struct device_attribute * attr, char * buf)
{
return sprintf(buf, "%u\n", MAX_AVPFREQ);
}

static DEVICE_ATTR(avpfreq, S_IRUGO , avpinfo_boot, NULL);
static DEVICE_ATTR(avpfreqmin, S_IRUGO , avpinfo_min, NULL);
static DEVICE_ATTR(avpfreqmax, S_IRUGO , avpinfo_max, NULL);

static struct attribute *avpinfo_attributes[] = {
&dev_attr_avpfreq.attr,
&dev_attr_avpfreqmin.attr,
&dev_attr_avpfreqmax.attr,
NULL
};

static struct attribute_group avpinfo_group = {
.attrs = avpinfo_attributes,
};

static struct miscdevice avpinfo_device = {
.minor = MISC_DYNAMIC_MINOR,
.name = "avpinfo",
};

static int __init avpinfo_init(void) {
int ret;
pr_info("%s misc_register(%s)\n", __FUNCTION__, avpinfo_device.name);
ret = misc_register(&avpinfo_device);

if (ret) {
pr_err("%s misc_register(%s) fail\n", __FUNCTION__, avpinfo_device.name);
return 1;
}

if (sysfs_create_group(&avpinfo_device.this_device->kobj, &avpinfo_group) < 0) {
pr_err("%s sysfs_create_group fail\n", __FUNCTION__);
pr_err("Failed to create sysfs group for device (%s)!\n", avpinfo_device.name);
}
return 0;
}

device_initcall(avpinfo_init);

0 comments on commit b5743c0

Please sign in to comment.