summaryrefslogtreecommitdiff
path: root/cleopatre
diff options
context:
space:
mode:
authorOlivier Dufour2012-11-14 17:42:16 +0100
committerOlivier Dufour2012-12-21 15:15:44 +0100
commita87e735cbe7994e052c220f57d792b6c37a8c98d (patch)
treedebdbfeda61d2ff605848fc5d64f74a16d6ad8fe /cleopatre
parentf27bb17628e6de40771e8a7102f7a5a135047f40 (diff)
cleo/linux: create a proc entry to manage standby mode, refs #2633
Diffstat (limited to 'cleopatre')
-rw-r--r--cleopatre/linux-2.6.25.10-spc300/arch/arm/mach-spc300/spc300-pm.c59
-rw-r--r--cleopatre/linux-2.6.25.10-spc300/include/asm-arm/arch-spc300/spc300-pm.h26
2 files changed, 85 insertions, 0 deletions
diff --git a/cleopatre/linux-2.6.25.10-spc300/arch/arm/mach-spc300/spc300-pm.c b/cleopatre/linux-2.6.25.10-spc300/arch/arm/mach-spc300/spc300-pm.c
index 7a4794b18f..751990c356 100644
--- a/cleopatre/linux-2.6.25.10-spc300/arch/arm/mach-spc300/spc300-pm.c
+++ b/cleopatre/linux-2.6.25.10-spc300/arch/arm/mach-spc300/spc300-pm.c
@@ -20,10 +20,12 @@
*/
#include <linux/suspend.h>
#include <linux/interrupt.h>
+#include <linux/proc_fs.h>
#ifdef CONFIG_CHIP_FEATURE_SRAM
#include <asm/arch/ips/sram.h>
#endif
#include <asm/arch/wdt.h>
+#include <asm/arch/spc300-pm.h>
#include "spc300.h"
@@ -34,6 +36,18 @@ sram_data_t sram_data;
static void (* pm_process) (void);
#endif
+static bool spc300_pm_suspend_cmd;
+
+void spc300_pm_request_suspend (void)
+{
+ spc300_pm_suspend_cmd = true;
+}
+
+void spc300_pm_clear_suspend (void)
+{
+ spc300_pm_suspend_cmd = false;
+}
+
static int spc300_pm_enter(suspend_state_t state)
{
BUG_ON(state != PM_SUSPEND_MEM);
@@ -49,6 +63,8 @@ static int spc300_pm_enter(suspend_state_t state)
#ifdef CONFIG_CHIP_FEATURE_SRAM
pm_process();
#endif
+ /* Clear suspend request command */
+ spc300_pm_suspend_cmd = false;
spc300_wdt_unset_irq_mode();
local_irq_enable();
spc300_irq_resume();
@@ -60,10 +76,43 @@ static struct platform_suspend_ops spc300_pm_ops ={
.enter = spc300_pm_enter,
};
+/**
+ * Read the PM data structure by /proc.
+ *
+ * \param file file structure.
+ * \param buffer string pointer given by user.
+ * \param start string pointer begin.
+ * \param offset offset value.
+ * \param count count parameter.
+ * \param eof end of file.
+ * \param data PM data structure.
+ * \return new pointer position.
+ */
+static int spc300_readproc_pm(char *buf, char **start, off_t offset,
+ int count, int *eof, void *data)
+{
+ bool suspend_cmd = *(bool *)data;
+ char *p;
+
+ p = buf;
+
+ p += sprintf(p, "%d\n", suspend_cmd);
+
+ *eof = 1;
+
+ return p-buf+1;
+}
+
static int __init spc300_pm_init(void)
{
+ struct proc_dir_entry *pm_proc_dir;
+ struct proc_dir_entry *entry;
+
printk("SPC300: Power Management\n");
+ /* Initialize PM standby command. */
+ spc300_pm_suspend_cmd = false;
+
#ifdef CONFIG_CHIP_FEATURE_SRAM
/* Link SRAM part of the suspend process. */
pm_process = (void *) SRAM_BASE_VA_PTR;
@@ -74,6 +123,16 @@ static int __init spc300_pm_init(void)
/* Allow WDT IRQ to wake us up in low power mode. */
enable_irq_wake(INT_WDT);
+ /* Create proc entry */
+ pm_proc_dir = proc_mkdir("pm", &proc_root);
+
+ /* This entry is read only, so there is no write function and permissions
+ * are set to 0444. */
+ entry = create_proc_entry("suspend_cmd", 0, pm_proc_dir);
+ entry->read_proc = spc300_readproc_pm;
+ entry->mode = S_IRUGO;
+ entry->data = (void *)(&spc300_pm_suspend_cmd);
+
return 0;
}
arch_initcall(spc300_pm_init);
diff --git a/cleopatre/linux-2.6.25.10-spc300/include/asm-arm/arch-spc300/spc300-pm.h b/cleopatre/linux-2.6.25.10-spc300/include/asm-arm/arch-spc300/spc300-pm.h
new file mode 100644
index 0000000000..a1f3448ef1
--- /dev/null
+++ b/cleopatre/linux-2.6.25.10-spc300/include/asm-arm/arch-spc300/spc300-pm.h
@@ -0,0 +1,26 @@
+/*
+ * include/asm/arch/spc300-pm.h
+ *
+ * Copyright (C) 2012 MStar Semiconductor.
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+#ifndef __ASM_ARCH_SPC300_PM_H
+#define __ASM_ARCH_SPC300_PM_H
+
+void spc300_pm_request_suspend (void);
+void spc300_pm_clear_suspend (void);
+
+#endif /* __ASM_ARCH_SPC300_PM_H */