summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/timer.c
diff options
context:
space:
mode:
authorAnshul Jain <anshulj@nvidia.com>2012-07-23 14:59:32 -0700
committerSimone Willett <swillett@nvidia.com>2012-07-30 20:46:28 -0700
commit4582bcef392ae029336673f5685a18fc67ac041a (patch)
tree3f0da45b86faadf3f3f2efde51871ed5b0efd235 /arch/arm/mach-tegra/timer.c
parent4012b752d64fd88efc3797e42ad8fedb29045e06 (diff)
ARM: tegra: dvfs: Adjust VDD_CPU to offset aging
Add silicon aging for VDD_CPU, this recovers some of millivolts based on the age of the chip. BUG 1006420 Change-Id: Idddb5861ab039e7ece262dec3697a69c3534ccf2 Signed-off-by: Anshul Jain <anshulj@nvidia.com> Reviewed-on: http://git-master/r/116911 Reviewed-by: Aleksandr Frid <afrid@nvidia.com> Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com> GVS: Gerrit_Virtual_Submit
Diffstat (limited to 'arch/arm/mach-tegra/timer.c')
-rw-r--r--arch/arm/mach-tegra/timer.c91
1 files changed, 91 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/timer.c b/arch/arm/mach-tegra/timer.c
index 83d0e17b50c1..5771bfc9bdde 100644
--- a/arch/arm/mach-tegra/timer.c
+++ b/arch/arm/mach-tegra/timer.c
@@ -31,6 +31,7 @@
#include <linux/clk.h>
#include <linux/io.h>
#include <linux/syscore_ops.h>
+#include <linux/rtc.h>
#include <asm/mach/time.h>
#include <asm/localtimer.h>
@@ -238,6 +239,96 @@ void tegra_twd_resume(struct tegra_twd_context *context)
}
#endif
+#ifdef CONFIG_RTC_CLASS
+/**
+ * has_readtime - check rtc device has readtime ability
+ * @dev: current device
+ * @name_ptr: name to be returned
+ *
+ * This helper function checks to see if the rtc device can be
+ * used for reading time
+ */
+static int has_readtime(struct device *dev, void *name_ptr)
+{
+ struct rtc_device *candidate = to_rtc_device(dev);
+
+ if (!candidate->ops->read_time)
+ return 0;
+
+ return 1;
+}
+
+/**
+ * tegra_get_linear_age - helper function to return linear age
+ * from Jan 2012.
+ *
+ * @return
+ * 1 - Jan 2012,
+ * 2 - Feb 2012,
+ * .....
+ * 13 - Jan 2013
+ */
+int tegra_get_linear_age(void)
+{
+ struct rtc_time tm;
+ int year, month, linear_age;
+ struct rtc_device *rtc_dev = NULL;
+ const char *name = NULL;
+ int ret;
+ struct device *dev = NULL;
+
+ linear_age = -1;
+ year = month = 0;
+ dev = class_find_device(rtc_class, NULL, &name, has_readtime);
+
+ if (!dev) {
+ pr_err("DVFS: No device with readtime capability\n");
+ goto done;
+ }
+
+ name = dev_name(dev);
+
+ pr_info("DVFS: Got RTC device name:%s\n", name);
+
+ if (name)
+ rtc_dev = rtc_class_open((char *)name);
+
+ if (!rtc_dev) {
+ pr_err("DVFS: No RTC device\n");
+ goto error_dev;
+ }
+
+ ret = rtc_read_time(rtc_dev, &tm);
+
+ if (ret < 0) {
+ pr_err("DVFS: Can't read RTC time\n");
+ goto error_rtc;
+ }
+
+ year = tm.tm_year;
+ /*Normalize it to 2012*/
+ year -= 112;
+ month = tm.tm_mon + 1;
+
+ if (year >= 0)
+ linear_age = year * 12 + month;
+
+error_rtc:
+ rtc_class_close(rtc_dev);
+error_dev:
+ put_device(dev);
+done:
+ return linear_age;
+
+}
+
+#else
+int tegra_get_linear_age()
+{
+ return -1;
+}
+#endif
+
static void __init tegra_init_timer(void)
{
struct clk *clk;