From b5743c02648e43b172bf913c5e006676fca6d1fa Mon Sep 17 00:00:00 2001 From: Peter Donka Date: Wed, 18 Jul 2012 13:09:03 +0200 Subject: [PATCH] Add OTF code --- arch/arm/mach-tegra/Kconfig.lge | 15 - .../nvrm/core/ap20/ap20rm_clock_config.c | 10 +- .../nvrm/core/ap20/ap20rm_power_dfs.h | 19 +- .../nvrm/core/common/nvrm_clocks_limits.c | 8 +- .../odm_kit/star/query/nvodm_query.c | 20 +- .../odm_kit/star/query/nvodm_query_pinmux.c | 1 + drivers/misc/Makefile | 1 + drivers/misc/otf/Makefile | 5 + drivers/misc/otf/otf.h | 20 ++ drivers/misc/otf/otf_avp.c | 78 +++++ drivers/misc/otf/otf_cpu1.c | 314 ++++++++++++++++++ drivers/misc/otf/otf_example.c | 117 +++++++ drivers/misc/otf/otf_gpu.c | 78 +++++ drivers/misc/otf/otf_nitro.c | 162 +++++++++ drivers/misc/otf/otf_vde.c | 78 +++++ drivers/video/tegra/nvmap.c | 6 +- init/Makefile | 2 +- init/otfinit.c | 82 +++++ 18 files changed, 974 insertions(+), 42 deletions(-) create mode 100644 drivers/misc/otf/Makefile create mode 100644 drivers/misc/otf/otf.h create mode 100644 drivers/misc/otf/otf_avp.c create mode 100644 drivers/misc/otf/otf_cpu1.c create mode 100644 drivers/misc/otf/otf_example.c create mode 100644 drivers/misc/otf/otf_gpu.c create mode 100644 drivers/misc/otf/otf_nitro.c create mode 100644 drivers/misc/otf/otf_vde.c create mode 100644 init/otfinit.c diff --git a/arch/arm/mach-tegra/Kconfig.lge b/arch/arm/mach-tegra/Kconfig.lge index c38f90fac8d..a96fa680014 100644 --- a/arch/arm/mach-tegra/Kconfig.lge +++ b/arch/arm/mach-tegra/Kconfig.lge @@ -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 diff --git a/arch/arm/mach-tegra/nvrm/core/ap20/ap20rm_clock_config.c b/arch/arm/mach-tegra/nvrm/core/ap20/ap20rm_clock_config.c index 85eb7cf6425..e3de8c3d9ee 100644 --- a/arch/arm/mach-tegra/nvrm/core/ap20/ap20rm_clock_config.c +++ b/arch/arm/mach-tegra/nvrm/core/ap20/ap20rm_clock_config.c @@ -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) @@ -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); diff --git a/arch/arm/mach-tegra/nvrm/core/ap20/ap20rm_power_dfs.h b/arch/arm/mach-tegra/nvrm/core/ap20/ap20rm_power_dfs.h index 7e438f91574..1b685285cb7 100644 --- a/arch/arm/mach-tegra/nvrm/core/ap20/ap20rm_power_dfs.h +++ b/arch/arm/mach-tegra/nvrm/core/ap20/ap20rm_power_dfs.h @@ -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. @@ -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) diff --git a/arch/arm/mach-tegra/nvrm/core/common/nvrm_clocks_limits.c b/arch/arm/mach-tegra/nvrm/core/common/nvrm_clocks_limits.c index d9f446ff825..4617b0b7559 100644 --- a/arch/arm/mach-tegra/nvrm/core/common/nvrm_clocks_limits.c +++ b/arch/arm/mach-tegra/nvrm/core/common/nvrm_clocks_limits.c @@ -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", diff --git a/arch/arm/mach-tegra/odm_kit/star/query/nvodm_query.c b/arch/arm/mach-tegra/odm_kit/star/query/nvodm_query.c index 08a91802776..4cd42196c1e 100644 --- a/arch/arm/mach-tegra/odm_kit/star/query/nvodm_query.c +++ b/arch/arm/mach-tegra/odm_kit/star/query/nvodm_query.c @@ -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 +#include +#include +#include + +#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 diff --git a/drivers/misc/otf/otf_avp.c b/drivers/misc/otf/otf_avp.c new file mode 100644 index 00000000000..a5d021561d9 --- /dev/null +++ b/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 +#include +#include + +/* 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); diff --git a/drivers/misc/otf/otf_cpu1.c b/drivers/misc/otf/otf_cpu1.c new file mode 100644 index 00000000000..951b8a149ab --- /dev/null +++ b/drivers/misc/otf/otf_cpu1.c @@ -0,0 +1,314 @@ +/* drivers/misc/otf/otf_cpu1.c + * + * Original source by Benee (c) 2012 + * + * Modified for the OTF by vadonka (c) 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 +#include +#include + +/** Define the LG variables + * You need to undef or comment out the original LG definitions + * in 'arch/arm/mach-tegra/nvrm/core/ap20/ap20rm_power_dfs.h' + */ + +/** Static containers */ +/* + * Defines CPU frequency threshold for slave CPU1 power management: + * - CPU1 is turned Off when cpu clock is below ONMINKHZ for + * ONDELAY time in a row + * - CPU1 is turned On when cpu clock is above OFFMAXKHZ for + * OFFDELAY time in a row + */ +static unsigned int MIN_ONMINKHZ = 216000; /* Minimum ON_MIN_KHZ value */ +static unsigned int MAX_ONMINKHZ = 1100000; /* Maximum ON_MIN_KHZ value */ +static unsigned int DEF_ONMINKHZ = 816000; /* Default ON_MIN_KHZ value */ + +static unsigned int MIN_ONDELAY = 200; /* Minimum ON_PENDING_MS value */ +static unsigned int MAX_ONDELAY = 3000; /* Maximum ON_PENDING_MS value */ +static unsigned int DEF_ONDELAY = 2000; /* Default ON_PENDING_MS value */ + +static unsigned int MIN_OFFMAXKHZ = 216000; /* Minimum OFF_MAX_KHZ value */ +static unsigned int MAX_OFFMAXKHZ = 1100000; /* Maximum OFF_MAX_KHZ value */ +static unsigned int DEF_OFFMAXKHZ = 860000; /* Default OFF_MAX_KHZ value */ + +static unsigned int MIN_OFFDELAY = 200; /* Mininum OFF_PENDING_MS value */ +static unsigned int MAX_OFFDELAY = 3000; /* Maximum OFF_PENDING_MS value */ +static unsigned int DEF_OFFDELAY = 500; /* Default OFF_PENDING_MS value */ + +/** Static containers end */ + +/* Boot time values */ +unsigned int onminkhz = 816000; /* ON_MIN_KHZ boot time value */ +unsigned int ondelay = 2000; /* ON_PENDING_MS boot time value */ + +unsigned int offmaxkhz = 860000; /* OFF_MAX_KHZ boot time value */ +unsigned int offdelay = 1000; /* OFF_PENDING_MS boot time value */ + +unsigned int NVRM_CPU1_ON_MIN_KHZ = 816000; /* ON_MIN_KHZ */ +unsigned int NVRM_CPU1_ON_PENDING_MS = 2000; /* ON_PENDING_MS */ +unsigned int NVRM_CPU1_OFF_MAX_KHZ = 860000; /* OFF_MAX_KHZ */ +unsigned int NVRM_CPU1_OFF_PENDING_MS = 500; /* OFF_PENDING_MS */ +/* Boot time values end */ + +/** SYSFS */ +extern unsigned int nitro; +/* ON_MIN_KHZ */ +static ssize_t onminkhz_read(struct device * dev, struct device_attribute * attr, char * buf) +{ + return sprintf(buf, "%d\n", onminkhz); +} + +static ssize_t onminkhz_write(struct device * dev, struct device_attribute * attr, const char * buf, size_t size) +{ + int dataonminkhz; + + if (nitro != 1) + { + if (sscanf(buf, "%d\n", &dataonminkhz) == 1) + { + if (dataonminkhz != onminkhz) + { + onminkhz = min(max(dataonminkhz, MIN_ONMINKHZ), MAX_ONMINKHZ); + /* LG variable get the new value */ + NVRM_CPU1_ON_MIN_KHZ = onminkhz; + pr_info("CPU1_ON_MIN_KHZ threshold changed to %d\n", onminkhz); + } + } + else + { + pr_info("CPU1_ON_MIN_KHZ invalid input\n"); + } + return size; + } +} + +static ssize_t onminkhz_min(struct device * dev, struct device_attribute * attr, char * buf) +{ + return sprintf(buf, "%u\n", MIN_ONMINKHZ); +} + +static ssize_t onminkhz_max(struct device * dev, struct device_attribute * attr, char * buf) +{ + return sprintf(buf, "%u\n", MAX_ONMINKHZ); +} + +static ssize_t onminkhz_def(struct device * dev, struct device_attribute * attr, char * buf) +{ + return sprintf(buf, "%u\n", DEF_ONMINKHZ); +} + +/* OFF_MAX_KHZ */ +static ssize_t offmaxkhz_read(struct device * dev, struct device_attribute * attr, char * buf) +{ + return sprintf(buf, "%d\n", offmaxkhz); +} + +static ssize_t offmaxkhz_write(struct device * dev, struct device_attribute * attr, const char * buf, size_t size) +{ + int dataoffmaxkhz; + + if (nitro == 0) + { + if (sscanf(buf, "%d\n", &dataoffmaxkhz) == 1) + { + if (dataoffmaxkhz != offmaxkhz) + { + offmaxkhz = min(max(dataoffmaxkhz, MIN_OFFMAXKHZ), MAX_OFFMAXKHZ); + /* LG variable get the new value */ + NVRM_CPU1_OFF_MAX_KHZ = offmaxkhz; + pr_info("CPU1_OFF_MAX_KHZ threshold changed to %d\n", offmaxkhz); + } + } + else + { + pr_info("CPU1_OFF_MAX_KHZ invalid input\n"); + } + return size; + } +} + +static ssize_t offmaxkhz_min(struct device * dev, struct device_attribute * attr, char * buf) +{ + return sprintf(buf, "%u\n", MIN_OFFMAXKHZ); +} + +static ssize_t offmaxkhz_max(struct device * dev, struct device_attribute * attr, char * buf) +{ + return sprintf(buf, "%u\n", MAX_OFFMAXKHZ); +} + +static ssize_t offmaxkhz_def(struct device * dev, struct device_attribute * attr, char * buf) +{ + return sprintf(buf, "%u\n", DEF_OFFMAXKHZ); +} + +/* ON_PENDING_MS */ +static ssize_t ondelay_read(struct device * dev, struct device_attribute * attr, char * buf) +{ + return sprintf(buf, "%d\n", ondelay); +} + +static ssize_t ondelay_write(struct device * dev, struct device_attribute * attr, const char * buf, size_t size) +{ + int dataondelay; + + if (nitro == 0) + { + if (sscanf(buf, "%d\n", &dataondelay) == 1) + { + if (dataondelay != ondelay) + { + ondelay = min(max(dataondelay, MIN_ONDELAY), MAX_ONDELAY); + /* LG variable get the new value */ + NVRM_CPU1_ON_PENDING_MS = ondelay; + pr_info("CPU1_ON_PENDING_MS threshold changed to %d\n", ondelay); + } + } + else + { + pr_info("CPU1_ON_PENDING_MS invalid input\n"); + } + return size; + } +} + +static ssize_t ondelay_min(struct device * dev, struct device_attribute * attr, char * buf) +{ + return sprintf(buf, "%u\n", MIN_ONDELAY); +} + +static ssize_t ondelay_max(struct device * dev, struct device_attribute * attr, char * buf) +{ + return sprintf(buf, "%u\n", MAX_ONDELAY); +} + +static ssize_t ondelay_def(struct device * dev, struct device_attribute * attr, char * buf) +{ + return sprintf(buf, "%u\n", DEF_ONDELAY); +} + +/* OFF_PENDING_MS */ +static ssize_t offdelay_read(struct device * dev, struct device_attribute * attr, char * buf) +{ + return sprintf(buf, "%d\n", offdelay); +} + +static ssize_t offdelay_write(struct device * dev, struct device_attribute * attr, const char * buf, size_t size) +{ + int dataoffdelay; + + if (nitro == 0) + { + if (sscanf(buf, "%d\n", &dataoffdelay) == 1) + { + if (dataoffdelay != offdelay) + { + offdelay = min(max(dataoffdelay, MIN_OFFDELAY), MAX_OFFDELAY); + /* LG variable get the new value */ + NVRM_CPU1_OFF_PENDING_MS = offdelay; + pr_info("CPU1_OFF_PENDING_MS threshold changed to %d\n", offdelay); + } + } + else + { + pr_info("CPU1_OFF_PENDING_MS invalid input\n"); + } + return size; + } +} + +static ssize_t offdelay_min(struct device * dev, struct device_attribute * attr, char * buf) +{ + return sprintf(buf, "%u\n", MIN_OFFDELAY); +} + +static ssize_t offdelay_max(struct device * dev, struct device_attribute * attr, char * buf) +{ + return sprintf(buf, "%u\n", MAX_OFFDELAY); +} + +static ssize_t offdelay_def(struct device * dev, struct device_attribute * attr, char * buf) +{ + return sprintf(buf, "%u\n", DEF_OFFDELAY); +} + +/** SYSFS attributes */ +/* ON_MIN_KHZ */ +static DEVICE_ATTR(onminkhz, S_IRUGO | S_IWUGO, onminkhz_read, onminkhz_write); +static DEVICE_ATTR(onminkhzmin, S_IRUGO , onminkhz_min, NULL); +static DEVICE_ATTR(onminkhzmax, S_IRUGO , onminkhz_max, NULL); +static DEVICE_ATTR(onminkhzdef, S_IRUGO , onminkhz_def, NULL); + +/* ON_PENDING_MS */ +static DEVICE_ATTR(ondelay, S_IRUGO | S_IWUGO, ondelay_read, ondelay_write); +static DEVICE_ATTR(ondelaymin, S_IRUGO , ondelay_min, NULL); +static DEVICE_ATTR(ondelaymax, S_IRUGO , ondelay_max, NULL); +static DEVICE_ATTR(ondelaydef, S_IRUGO , ondelay_def, NULL); + +/* OFF_MAX_KHZ */ +static DEVICE_ATTR(offmaxkhz, S_IRUGO | S_IWUGO, offmaxkhz_read, offmaxkhz_write); +static DEVICE_ATTR(offmaxkhzmin, S_IRUGO , offmaxkhz_min, NULL); +static DEVICE_ATTR(offmaxkhzmax, S_IRUGO , offmaxkhz_max, NULL); +static DEVICE_ATTR(offmaxkhzdef, S_IRUGO , offmaxkhz_def, NULL); + +/* OFF_PENDING_MS */ +static DEVICE_ATTR(offdelay, S_IRUGO | S_IWUGO, offdelay_read, offdelay_write); +static DEVICE_ATTR(offdelaymin, S_IRUGO , offdelay_min, NULL); +static DEVICE_ATTR(offdelaymax, S_IRUGO , offdelay_max, NULL); +static DEVICE_ATTR(offdelaydef, S_IRUGO , offdelay_def, NULL); + +static struct attribute *cpu1control_attributes[] = { + &dev_attr_onminkhz.attr, + &dev_attr_onminkhzmin.attr, + &dev_attr_onminkhzmax.attr, + &dev_attr_onminkhzdef.attr, + &dev_attr_ondelay.attr, + &dev_attr_ondelaymin.attr, + &dev_attr_ondelaymax.attr, + &dev_attr_ondelaydef.attr, + &dev_attr_offmaxkhz.attr, + &dev_attr_offmaxkhzmin.attr, + &dev_attr_offmaxkhzmax.attr, + &dev_attr_offmaxkhzdef.attr, + &dev_attr_offdelay.attr, + &dev_attr_offdelaymin.attr, + &dev_attr_offdelaymax.attr, + &dev_attr_offdelaydef.attr, + NULL +}; + +static struct attribute_group cpu1control_group = { + .attrs = cpu1control_attributes, +}; + +static struct miscdevice cpu1control_device = { + .minor = MISC_DYNAMIC_MINOR, + .name = "cpu1control", +}; + +static int __init cpu1control_init(void) { + int ret; + pr_info("%s misc_register(%s)\n", __FUNCTION__, cpu1control_device.name); + ret = misc_register(&cpu1control_device); + + if (ret) { + pr_err("%s misc_register(%s) fail\n", __FUNCTION__, cpu1control_device.name); + return 1; + } + + if (sysfs_create_group(&cpu1control_device.this_device->kobj, &cpu1control_group) < 0) { + pr_err("%s sysfs_create_group fail\n", __FUNCTION__); + pr_err("Failed to create sysfs group for device (%s)!\n", cpu1control_device.name); + } + return 0; +} + +device_initcall(cpu1control_init); diff --git a/drivers/misc/otf/otf_example.c b/drivers/misc/otf/otf_example.c new file mode 100644 index 00000000000..dbb4f392165 --- /dev/null +++ b/drivers/misc/otf/otf_example.c @@ -0,0 +1,117 @@ +/* drivers/misc/otf/otf_example.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. + * + +/* Some example */ +#if 0 +void example_block(void) +{ +...code... +} +EXPORT_SYMBOL(example_block); +--- +extern void example_block(void); +example_block(); +#endif + +#include +#include +#include + +int MIN_EXAMPLEVALUE = 1000; +int MAX_EXAMPLEVALUE = 2000; +int DEF_EXAMPLEVALUE = 1500; + +static int example_value = 1500; +int examplecontrol_value(void) { + return example_value; +} +EXPORT_SYMBOL(examplecontrol_value); +/* + * Calling with this: + ******************** + * extern int examplecontrol_value(void); + * + * Using: + ******** + * examplecontrol_value() + * + */ + +static ssize_t examplecontrol_value_read(struct device * dev, struct device_attribute * attr, char * buf) { + return sprintf(buf, "%d\n", example_value); +} + +static ssize_t examplecontrol_value_write(struct device * dev, struct device_attribute * attr, const char * buf, size_t size) { + int data; + + if (sscanf(buf, "%d\n", &data) == 1) { + if (data != example_value) { + example_value = min(max(data, MIN_EXAMPLEVALUE), MAX_EXAMPLEVALUE); + pr_info("EXAMPLECONTROL threshold changed to %d\n", example_value); + } + } else { + pr_info("EXAMPLECONTROL invalid input\n"); + } + return size; +} + +static ssize_t examplecontrol_min(struct device * dev, struct device_attribute * attr, char * buf) { + return sprintf(buf, "%u\n", MIN_EXAMPLEVALUE); +} + +static ssize_t examplecontrol_max(struct device * dev, struct device_attribute * attr, char * buf) { + return sprintf(buf, "%u\n", MAX_EXAMPLEVALUE); +} + +static ssize_t examplecontrol_def(struct device * dev, struct device_attribute * attr, char * buf) { + return sprintf(buf, "%u\n", DEF_EXAMPLEVALUE); +} + +static DEVICE_ATTR(examplevalue, S_IRUGO | S_IWUGO, examplecontrol_value_read, examplecontrol_value_write); +static DEVICE_ATTR(min, S_IRUGO , examplecontrol_min, NULL); +static DEVICE_ATTR(max, S_IRUGO , examplecontrol_max, NULL); +static DEVICE_ATTR(def, S_IRUGO , examplecontrol_def, NULL); + +static struct attribute *examplecontrol_attributes[] = { + &dev_attr_examplevalue.attr, + &dev_attr_min.attr, + &dev_attr_max.attr, + &dev_attr_def.attr, + NULL +}; + +static struct attribute_group examplecontrol_group = { + .attrs = examplecontrol_attributes, +}; + +static struct miscdevice examplecontrol_device = { + .minor = MISC_DYNAMIC_MINOR, + .name = "examplecontrol", +}; + +static int __init examplecontrol_init(void) { + int ret; + pr_info("%s misc_register(%s)\n", __FUNCTION__, examplecontrol_device.name); + ret = misc_register(&examplecontrol_device); + + if (ret) { + pr_err("%s misc_register(%s) fail\n", __FUNCTION__, examplecontrol_device.name); + return 1; + } + + if (sysfs_create_group(&examplecontrol_device.this_device->kobj, &examplecontrol_group) < 0) { + pr_err("%s sysfs_create_group fail\n", __FUNCTION__); + pr_err("Failed to create sysfs group for device (%s)!\n", examplecontrol_device.name); + } + return 0; +} + +device_initcall(examplecontrol_init); diff --git a/drivers/misc/otf/otf_gpu.c b/drivers/misc/otf/otf_gpu.c new file mode 100644 index 00000000000..12558fe93d9 --- /dev/null +++ b/drivers/misc/otf/otf_gpu.c @@ -0,0 +1,78 @@ +/* drivers/misc/otf/otf_gpu.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 +#include +#include + +/* Static containers + * gpufreq values are set in the init/otfinit.c + */ +extern unsigned int MIN_GPUFREQ; +extern unsigned int MAX_GPUFREQ; + +/* Boot time value taken from the kernel cmdline */ +extern unsigned int gpufreq; + +static ssize_t gpuinfo_boot(struct device * dev, struct device_attribute * attr, char * buf) +{ + return sprintf(buf, "%u\n", gpufreq); +} + +static ssize_t gpuinfo_min(struct device * dev, struct device_attribute * attr, char * buf) +{ + return sprintf(buf, "%u\n", MIN_GPUFREQ); +} + +static ssize_t gpuinfo_max(struct device * dev, struct device_attribute * attr, char * buf) +{ + return sprintf(buf, "%u\n", MAX_GPUFREQ); +} + +static DEVICE_ATTR(gpufreq, S_IRUGO , gpuinfo_boot, NULL); +static DEVICE_ATTR(gpufreqmin, S_IRUGO , gpuinfo_min, NULL); +static DEVICE_ATTR(gpufreqmax, S_IRUGO , gpuinfo_max, NULL); + +static struct attribute *gpuinfo_attributes[] = { + &dev_attr_gpufreq.attr, + &dev_attr_gpufreqmin.attr, + &dev_attr_gpufreqmax.attr, + NULL +}; + +static struct attribute_group gpuinfo_group = { + .attrs = gpuinfo_attributes, +}; + +static struct miscdevice gpuinfo_device = { + .minor = MISC_DYNAMIC_MINOR, + .name = "gpuinfo", +}; + +static int __init gpuinfo_init(void) { + int ret; + pr_info("%s misc_register(%s)\n", __FUNCTION__, gpuinfo_device.name); + ret = misc_register(&gpuinfo_device); + + if (ret) { + pr_err("%s misc_register(%s) fail\n", __FUNCTION__, gpuinfo_device.name); + return 1; + } + + if (sysfs_create_group(&gpuinfo_device.this_device->kobj, &gpuinfo_group) < 0) { + pr_err("%s sysfs_create_group fail\n", __FUNCTION__); + pr_err("Failed to create sysfs group for device (%s)!\n", gpuinfo_device.name); + } + return 0; +} + +device_initcall(gpuinfo_init); diff --git a/drivers/misc/otf/otf_nitro.c b/drivers/misc/otf/otf_nitro.c new file mode 100644 index 00000000000..092ad94e71c --- /dev/null +++ b/drivers/misc/otf/otf_nitro.c @@ -0,0 +1,162 @@ +/* drivers/misc/otf/otf_nitro.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 +#include +#include +#include "otf.h" + +/* Static containers */ +static unsigned int MIN_NITRO = 0; +static unsigned int MAX_NITRO = 1; +static unsigned int DEF_NITRO = 0; +static unsigned int onminkhznitro = 655000; +static unsigned int ondelaynitro = 2000; +static unsigned int offmaxkhznitro = 610000; +static unsigned int offdelaynitro = 200; + +/* Boot time value */ +unsigned int nitro = 0; +/* Boot time value end */ + +extern unsigned int onminkhz; +extern unsigned int ondelay; +extern unsigned int offmaxkhz; +extern unsigned int offdelay; + +static unsigned int oldonminkhz; +static unsigned int oldondelay; +static unsigned int oldoffmaxkhz; +static unsigned int oldoffdelay; + +static ssize_t nitro_read(struct device * dev, struct device_attribute * attr, char * buf) +{ + return sprintf(buf, "%d\n", nitro); +} + +static ssize_t nitro_write(struct device * dev, struct device_attribute * attr, const char * buf, size_t size) +{ + int datanitro; + + if (sscanf(buf, "%d\n", &datanitro) == 1) + { + if (datanitro != nitro) + { + nitro = min(max(datanitro, MIN_NITRO), MAX_NITRO); + if (nitro == 1) + { + pr_info("NITRO enabled\n", nitro); + + oldonminkhz = onminkhz; + onminkhz = onminkhznitro; + NVRM_CPU1_ON_MIN_KHZ = onminkhz; + pr_info("NITRO Enabled! CPU1_ON_MIN_KHZ threshold changed to %d\n", onminkhz); + + oldondelay = ondelay; + ondelay = ondelaynitro; + NVRM_CPU1_ON_PENDING_MS = ondelay; + pr_info("NITRO Enabled! CPU1_ON_PENDING_MS threshold changed to %d\n", ondelay); + + oldoffmaxkhz = offmaxkhz; + offmaxkhz = offmaxkhznitro; + NVRM_CPU1_OFF_MAX_KHZ = offmaxkhz; + pr_info("NITRO Enabled! CPU1_OFF_MAX_KHZ threshold changed to %d\n", offmaxkhz); + + oldoffdelay = offdelay; + offdelay = offdelaynitro; + NVRM_CPU1_OFF_PENDING_MS = offdelay; + pr_info("NITRO Enabled! CPU1_OFF_PENDING_MS threshold changed to %d\n", offdelay); + } + else + { + pr_info("NITRO disabled\n", nitro); + + onminkhz = oldonminkhz; + NVRM_CPU1_ON_MIN_KHZ = onminkhz; + pr_info("CPU1_ON_MIN_KHZ threshold restored to %d\n", onminkhz); + + ondelay = oldondelay; + NVRM_CPU1_ON_PENDING_MS = ondelay; + pr_info("CPU1_ON_PENDING_MS threshold restored to %d\n", ondelay); + + offmaxkhz = oldoffmaxkhz; + NVRM_CPU1_OFF_MAX_KHZ = offmaxkhz; + pr_info("CPU1_OFF_MAX_KHZ threshold restored to %d\n", offmaxkhz); + + offdelay = oldoffdelay; + NVRM_CPU1_OFF_PENDING_MS = offdelay; + pr_info("CPU1_OFF_PENDING_MS threshold restored to %d\n", offdelay); + } + } + } + else + { + pr_info("NITRO invalid input\n"); + } + return size; +} + +static ssize_t nitrocontrol_min(struct device * dev, struct device_attribute * attr, char * buf) +{ + return sprintf(buf, "%u\n", MIN_NITRO); +} + +static ssize_t nitrocontrol_max(struct device * dev, struct device_attribute * attr, char * buf) +{ + return sprintf(buf, "%u\n", MAX_NITRO); +} + +static ssize_t nitrocontrol_def(struct device * dev, struct device_attribute * attr, char * buf) +{ + return sprintf(buf, "%u\n", DEF_NITRO); +} + +static DEVICE_ATTR(nitro, S_IRUGO | S_IWUGO, nitro_read, nitro_write); +static DEVICE_ATTR(nitromin, S_IRUGO , nitrocontrol_min, NULL); +static DEVICE_ATTR(nitromax, S_IRUGO , nitrocontrol_max, NULL); +static DEVICE_ATTR(nitrodef, S_IRUGO , nitrocontrol_def, NULL); + +static struct attribute *nitrocontrol_attributes[] = { + &dev_attr_nitro.attr, + &dev_attr_nitromin.attr, + &dev_attr_nitromax.attr, + &dev_attr_nitrodef.attr, + NULL +}; + +static struct attribute_group nitrocontrol_group = { + .attrs = nitrocontrol_attributes, +}; + +static struct miscdevice nitrocontrol_device = { + .minor = MISC_DYNAMIC_MINOR, + .name = "nitrocontrol", +}; + +static int __init nitrocontrol_init(void) { + int ret; + pr_info("%s misc_register(%s)\n", __FUNCTION__, nitrocontrol_device.name); + ret = misc_register(&nitrocontrol_device); + + if (ret) { + pr_err("%s misc_register(%s) fail\n", __FUNCTION__, nitrocontrol_device.name); + return 1; + } + + if (sysfs_create_group(&nitrocontrol_device.this_device->kobj, &nitrocontrol_group) < 0) { + pr_err("%s sysfs_create_group fail\n", __FUNCTION__); + pr_err("Failed to create sysfs group for device (%s)!\n", nitrocontrol_device.name); + } + return 0; +} + +device_initcall(nitrocontrol_init); diff --git a/drivers/misc/otf/otf_vde.c b/drivers/misc/otf/otf_vde.c new file mode 100644 index 00000000000..5b5535fee88 --- /dev/null +++ b/drivers/misc/otf/otf_vde.c @@ -0,0 +1,78 @@ +/* drivers/misc/otf/otf_vde.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 +#include +#include + +/* Static containers + * vdefreq values are set in the init/otfinit.c + */ +extern unsigned int MIN_VDEFREQ; +extern unsigned int MAX_VDEFREQ; + +/* Boot time value taken from the kernel cmdline */ +extern unsigned int vdefreq; + +static ssize_t vdeinfo_boot(struct device * dev, struct device_attribute * attr, char * buf) +{ + return sprintf(buf, "%u\n", vdefreq); +} + +static ssize_t vdeinfo_min(struct device * dev, struct device_attribute * attr, char * buf) +{ + return sprintf(buf, "%u\n", MIN_VDEFREQ); +} + +static ssize_t vdeinfo_max(struct device * dev, struct device_attribute * attr, char * buf) +{ + return sprintf(buf, "%u\n", MAX_VDEFREQ); +} + +static DEVICE_ATTR(vdefreq, S_IRUGO , vdeinfo_boot, NULL); +static DEVICE_ATTR(vdefreqmin, S_IRUGO , vdeinfo_min, NULL); +static DEVICE_ATTR(vdefreqmax, S_IRUGO , vdeinfo_max, NULL); + +static struct attribute *vdeinfo_attributes[] = { + &dev_attr_vdefreq.attr, + &dev_attr_vdefreqmin.attr, + &dev_attr_vdefreqmax.attr, + NULL +}; + +static struct attribute_group vdeinfo_group = { + .attrs = vdeinfo_attributes, +}; + +static struct miscdevice vdeinfo_device = { + .minor = MISC_DYNAMIC_MINOR, + .name = "vdeinfo", +}; + +static int __init vdeinfo_init(void) { + int ret; + pr_info("%s misc_register(%s)\n", __FUNCTION__, vdeinfo_device.name); + ret = misc_register(&vdeinfo_device); + + if (ret) { + pr_err("%s misc_register(%s) fail\n", __FUNCTION__, vdeinfo_device.name); + return 1; + } + + if (sysfs_create_group(&vdeinfo_device.this_device->kobj, &vdeinfo_group) < 0) { + pr_err("%s sysfs_create_group fail\n", __FUNCTION__); + pr_err("Failed to create sysfs group for device (%s)!\n", vdeinfo_device.name); + } + return 0; +} + +device_initcall(vdeinfo_init); diff --git a/drivers/video/tegra/nvmap.c b/drivers/video/tegra/nvmap.c index bdccd0bf176..d041c5361e2 100644 --- a/drivers/video/tegra/nvmap.c +++ b/drivers/video/tegra/nvmap.c @@ -3522,7 +3522,6 @@ static int __init nvmap_core_init(void) pgd_t *pgd; pmd_t *pmd; pte_t *pte; - unsigned int i, sz = 0; nvmap_context.compact_kbytes_count = 0; nvmap_context.compact_attempts_count = 0; @@ -3569,10 +3568,6 @@ static int __init nvmap_core_init(void) snprintf(tmp, sizeof(tmp), "generic-%u", i); nvmap_add_carveout_heap(nvmap_carveout_cmd_base[i], nvmap_carveout_cmd_size[i], tmp, 0x1); - sz += nvmap_carveout_cmd_size[i]; - } - pr_info("%s: total carveout size=%d\n", __func__, sz); - nvmap_carveout_size = sz; return 0; } @@ -3591,6 +3586,7 @@ static int __init nvmap_heap_arg(char *options) if (nvmap_carveout_cmds < ARRAY_SIZE(nvmap_carveout_cmd_size)) { nvmap_carveout_cmd_base[nvmap_carveout_cmds] = start; nvmap_carveout_cmd_size[nvmap_carveout_cmds] = size; + nvmap_carveout_size += size; nvmap_carveout_cmds++; } return 0; diff --git a/init/Makefile b/init/Makefile index 4a243df426f..6c129934fc4 100644 --- a/init/Makefile +++ b/init/Makefile @@ -2,7 +2,7 @@ # Makefile for the linux kernel. # -obj-y := main.o version.o mounts.o +obj-y := main.o version.o mounts.o otfinit.o ifneq ($(CONFIG_BLK_DEV_INITRD),y) obj-y += noinitramfs.o else diff --git a/init/otfinit.c b/init/otfinit.c new file mode 100644 index 00000000000..2854b101037 --- /dev/null +++ b/init/otfinit.c @@ -0,0 +1,82 @@ +/* + * linux/init/otfinit.c + * (c) vadonka 2012 + */ + +#include +#include +#include +#include +#include + +/* AVP Freq */ +unsigned int avpfreq; +unsigned int MIN_AVPFREQ = 200000; +unsigned int MAX_AVPFREQ = 280000; + +EXPORT_SYMBOL(avpfreq); +EXPORT_SYMBOL(MIN_AVPFREQ); +EXPORT_SYMBOL(MAX_AVPFREQ); + +static int __init set_avpfreq(char *str) +{ + if ( simple_strtoul(str,NULL,0) < MIN_AVPFREQ || simple_strtoul(str,NULL,0) > MAX_AVPFREQ ) + { + avpfreq = 240000; // Default value + } + else + { + avpfreq = simple_strtoul(str,NULL,0); + } + return 1; +} +__setup("avpfreq=", set_avpfreq); +/* AVP Freq End */ + +/* GPU Freq */ +unsigned int gpufreq; +unsigned int MIN_GPUFREQ = 300000; +unsigned int MAX_GPUFREQ = 366000; + +EXPORT_SYMBOL(gpufreq); +EXPORT_SYMBOL(MIN_GPUFREQ); +EXPORT_SYMBOL(MAX_GPUFREQ); + +static int __init set_gpufreq(char *str) +{ + if ( simple_strtoul(str,NULL,0) < MIN_GPUFREQ || simple_strtoul(str,NULL,0) > MAX_GPUFREQ ) + { + gpufreq = 333000; // Default value + } + else + { + gpufreq = simple_strtoul(str,NULL,0); + } + return 1; +} +__setup("gpufreq=", set_gpufreq); +/* GPU Freq End */ + +/* VDE Freq */ +unsigned int vdefreq; +unsigned int MIN_VDEFREQ = 600000; +unsigned int MAX_VDEFREQ = 700000; + +EXPORT_SYMBOL(vdefreq); +EXPORT_SYMBOL(MIN_VDEFREQ); +EXPORT_SYMBOL(MAX_VDEFREQ); + +static int __init set_vdefreq(char *str) +{ + if ( simple_strtoul(str,NULL,0) < MIN_VDEFREQ || simple_strtoul(str,NULL,0) > MAX_VDEFREQ ) + { + vdefreq = 650000; // Default value + } + else + { + vdefreq = simple_strtoul(str,NULL,0); + } + return 1; +} +__setup("vdefreq=", set_vdefreq); +/* VDE Freq End */