]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
driver: misc: Force cpu reset on cpus periodically
authorSai Gurrappadi <sgurrappadi@nvidia.com>
Tue, 14 Jan 2014 00:24:17 +0000 (16:24 -0800)
committerThomas Cherry <tcherry@nvidia.com>
Mon, 3 Feb 2014 19:42:42 +0000 (11:42 -0800)
Change-Id: I8d30f0a785a17cdf424c559b971729365a63ab8c
Reviewed-on: http://git-master/r/355374
Reviewed-on: http://git-master/r/355277
Signed-off-by: Sai Gurrappadi <sgurrappadi@nvidia.com>
Reviewed-on: http://git-master/r/361687
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Thomas Cherry <tcherry@nvidia.com>
Tested-by: Thomas Cherry <tcherry@nvidia.com>
drivers/misc/Makefile
drivers/misc/force_idle_t132.c [new file with mode: 0644]

index 51ab9b05dd6498dfff645873d684aa60869db934..997a7b6f3779223e33bc1a039ccc866f21db6a97 100644 (file)
@@ -81,3 +81,4 @@ obj-y                         += issp/
 obj-$(CONFIG_TEGRA_PROFILER)    += tegra-profiler/
 obj-$(CONFIG_MTK_GPS)          += gps/
 obj-y          += tegra-fuse/
+obj-$(CONFIG_DENVER_CPU)       += force_idle_t132.o
diff --git a/drivers/misc/force_idle_t132.c b/drivers/misc/force_idle_t132.c
new file mode 100644 (file)
index 0000000..98a2b83
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * drivers/misc/force_idle_t132.c
+ *
+ * Copyright (C) 2014 NVIDIA Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/debugfs.h>
+#include <linux/kernel.h>
+#include <linux/fs.h>
+#include <linux/uaccess.h>
+#include <linux/ktime.h>
+#include <linux/interrupt.h>
+#include <linux/suspend.h>
+#include <linux/tick.h>
+#include <linux/workqueue.h>
+#include <linux/irq.h>
+#include <linux/timer.h>
+#include <linux/jiffies.h>
+#include <linux/interrupt.h>
+#include <linux/tick.h>
+#include <linux/gpio.h>
+#include <mach/pinmux-defines.h>
+#include <mach/pinmux-t12.h>
+
+#include "../../arch/arm/mach-tegra/gpio-names.h"
+#include "../../kernel/irq/internals.h"
+
+#define LEN            200
+#define DEBUG_HOOKS    1
+#define DBG_PRINT(fmt, arg...) pr_err(fmt, ## arg)
+#define POWER_BACKDOOR_I2C_CC4_VOLTAGE_DOWN            0x14
+#define POWER_BACKDOOR_I2C_CC4_VOLTAGE_UP              0x15
+
+static struct dentry *dfs_dir;
+static char ker_buf[LEN];
+static u64 pmstate = 5;
+
+/* Forces idle every time_interval seconds */
+static u64 time_interval_sec = 2;
+static struct delayed_work cpus_idle_work;
+
+static void tegra132_do_idle(ulong pmstate)
+{
+       asm volatile(
+       "       msr actlr_el1, %0\n"
+       "       wfi\n"
+       :
+       : "r" (pmstate));
+}
+
+static void force_idle_work_func(struct work_struct *work)
+{
+       tegra132_do_idle(pmstate);
+}
+
+/* Force idle on all online cpus */
+static void force_idle_cpus_work(struct work_struct *work)
+{
+       schedule_on_each_cpu(force_idle_work_func);
+       schedule_delayed_work(&cpus_idle_work,
+                             msecs_to_jiffies(time_interval_sec * 1000));
+}
+
+static int __init init_debug(void)
+{
+       struct dentry *dfs_file;
+       int filevalue;
+
+       dfs_dir = debugfs_create_dir("force_idle", NULL);
+       dfs_file = debugfs_create_u64("time_interval_sec", 0644, dfs_dir,
+                                               &time_interval_sec);
+       if (!dfs_file) {
+               DBG_PRINT("error creating time_interval_sec file");
+               return -ENODEV;
+       }
+       dfs_file = debugfs_create_u64("pmstate", 0644, dfs_dir,
+                                               &pmstate);
+       if (!dfs_file) {
+               DBG_PRINT("error creating pmstate file");
+               return -ENODEV;
+       }
+       INIT_DEFERRABLE_WORK(&cpus_idle_work, force_idle_cpus_work);
+       schedule_delayed_work(&cpus_idle_work,
+                               msecs_to_jiffies(time_interval_sec * 1000));
+       return 0;
+}
+module_init(init_debug);
+
+static void __exit exit_debug(void)
+{
+       debugfs_remove_recursive(dfs_dir);
+       cancel_delayed_work_sync(&cpus_idle_work);
+}
+module_exit(exit_debug);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Force idle");