summaryrefslogtreecommitdiff
path: root/cleopatre/linux-2.6.25.10-spc300/arch
diff options
context:
space:
mode:
authorCyril Jourdan2013-01-23 11:06:13 +0100
committerCyril Jourdan2013-01-31 15:49:55 +0100
commit82ef513b2c67eae0ea2386cd223a736adea58324 (patch)
treeb7228810924ddc50e83c0f18b0fc117844ddcedf /cleopatre/linux-2.6.25.10-spc300/arch
parentdd9f0f3ca9d3799580c85daab350f2248ffa0fd9 (diff)
cleo/linux/spc300: add a proc to handle autoswitch info, refs #3692
Diffstat (limited to 'cleopatre/linux-2.6.25.10-spc300/arch')
-rw-r--r--cleopatre/linux-2.6.25.10-spc300/arch/arm/mach-spc300/Makefile3
-rw-r--r--cleopatre/linux-2.6.25.10-spc300/arch/arm/mach-spc300/mse500-autoswitch.c140
2 files changed, 143 insertions, 0 deletions
diff --git a/cleopatre/linux-2.6.25.10-spc300/arch/arm/mach-spc300/Makefile b/cleopatre/linux-2.6.25.10-spc300/arch/arm/mach-spc300/Makefile
index 79c0a68a29..bade1a293a 100644
--- a/cleopatre/linux-2.6.25.10-spc300/arch/arm/mach-spc300/Makefile
+++ b/cleopatre/linux-2.6.25.10-spc300/arch/arm/mach-spc300/Makefile
@@ -25,3 +25,6 @@ obj-$(CONFIG_MACH_MCR500) += board-mse500.o
obj-$(CONFIG_MACH_MPR520) += board-mse500.o
obj-$(CONFIG_CHIP_FEATURE_SRAM) += sram.o
+
+# Auto Switch
+obj-$(CONFIG_CHIP_MSE500) += mse500-autoswitch.o
diff --git a/cleopatre/linux-2.6.25.10-spc300/arch/arm/mach-spc300/mse500-autoswitch.c b/cleopatre/linux-2.6.25.10-spc300/arch/arm/mach-spc300/mse500-autoswitch.c
new file mode 100644
index 0000000000..223c09f995
--- /dev/null
+++ b/cleopatre/linux-2.6.25.10-spc300/arch/arm/mach-spc300/mse500-autoswitch.c
@@ -0,0 +1,140 @@
+/*
+ * arch/arm/mach-spc300/mse500-autoswitch.c
+ *
+ * (C) Copyright 2013 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, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+#include <linux/string.h>
+#include <linux/proc_fs.h>
+#include <asm/arch/sram-mapping.h>
+#include <asm/arch/mse500-autoswitch.h>
+
+#include "spc300.h"
+
+/* Pointer on autoswitch data in SRAM. */
+static volatile sram_autoswitch_data_t *sram_autoswitch_data;
+
+/**
+ * Read autoswitch enable 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 NULL.
+ * \return new pointer position.
+ */
+static int mse500_autoswitch_en_readproc (char *buf, char **start, off_t offset,
+ int count, int *eof, void *data)
+{
+ char *p;
+
+ p = buf;
+
+ p += sprintf (p, "%d\n", spc300_autoswitch_en);
+
+ *eof = 1;
+
+ return (p - buf + 1);
+}
+
+/**
+ * Read autoswitch next image slot 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 NULL.
+ * \return new pointer position.
+ */
+static int mse500_autoswitch_readproc (char *buf, char **start, off_t offset,
+ int count, int *eof, void *data)
+{
+ char *p;
+
+ p = buf;
+
+ if (!strncmp ((const char *) sram_autoswitch_data->magic,
+ MSE500_AUTOSWITCH_MAGIC, MSE500_AUTOSWITCH_MAGIC_SIZE))
+ p += sprintf (p, "%d\n", sram_autoswitch_data->slot);
+ else
+ p += sprintf (p, "%d\n", MSE500_AUTOSWITCH_SLOT_INVALID);
+
+ *eof = 1;
+
+ return (p - buf + 1);
+}
+
+/**
+ * Write autoswitch next image slot by /proc.
+ *
+ * \param file file structure.
+ * \param buffer string pointer given by user.
+ * \param count count parameter.
+ * \param data NULL.
+ * \return counter value.
+ */
+static int mse500_autoswitch_writeproc (struct file *file, const char *buffer,
+ unsigned long count, void *data)
+{
+ int slot;
+
+ if (sscanf (buffer,"%d", &slot) == 1)
+ {
+ memcpy ((void *) sram_autoswitch_data->magic,
+ MSE500_AUTOSWITCH_MAGIC, MSE500_AUTOSWITCH_MAGIC_SIZE);
+ sram_autoswitch_data->slot = slot;
+ }
+
+ return count;
+}
+
+static int __init mse500_autoswitch_init (void)
+{
+ struct proc_dir_entry *entry;
+
+ printk ("Autoswitch init\n");
+
+ sram_autoswitch_data = (volatile sram_autoswitch_data_t *)
+ SRAM_DATA_PTR (autoswitch);
+
+ memset ((void *) sram_autoswitch_data->magic, 0,
+ MSE500_AUTOSWITCH_MAGIC_SIZE);
+ sram_autoswitch_data->slot = MSE500_AUTOSWITCH_SLOT_INVALID;
+
+ /* Create proc entries */
+ entry = create_proc_entry ("autoswitch_en", S_IRUGO,
+ spc300_spidimg_proc_dir);
+ entry->read_proc = mse500_autoswitch_en_readproc;
+ entry->data = NULL;
+
+ entry = create_proc_entry ("next_img_slot", S_IRUGO | S_IWUGO,
+ spc300_spidimg_proc_dir);
+ entry->read_proc = mse500_autoswitch_readproc;
+ entry->write_proc = mse500_autoswitch_writeproc;
+ entry->data = NULL;
+
+ /* TODO : create an entry to print version field of the images ? */
+
+ return 0;
+}
+arch_initcall(mse500_autoswitch_init);