summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--polux/linux-2.6.10/arch/arm/mach-mse500/core.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/polux/linux-2.6.10/arch/arm/mach-mse500/core.c b/polux/linux-2.6.10/arch/arm/mach-mse500/core.c
index 6c67a5691d..1637846ec9 100644
--- a/polux/linux-2.6.10/arch/arm/mach-mse500/core.c
+++ b/polux/linux-2.6.10/arch/arm/mach-mse500/core.c
@@ -25,6 +25,7 @@
#include <linux/interrupt.h>
#include <linux/mm.h>
#include <linux/module.h>
+#include <linux/proc_fs.h>
#include <asm/sizes.h>
#include <asm/hardware.h>
@@ -57,6 +58,9 @@ static int mse500_global_mode = 0;
//static unsigned int mse500_FPGA_clock = 66666666;
static unsigned int mse500_FPGA_clock = EXT_APB_CLK;
+/** Current image slot number. */
+static int mse500_cur_img_slot = -1;
+
void mse500_register_uart(int idx, int port);
extern void mse500_register_spi_devices(void);
@@ -329,6 +333,48 @@ void __init mse500_init_irq(void)
} /* mse500_init_irq */
/**
+ * Read the current 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 current image slot.
+ * \return new pointer position.
+ */
+static int mse500_readproc_img_slot (char *buf, char **start, off_t offset,
+ int count, int *eof, void *data)
+{
+ int img_slot = *(int *)data;
+ char *p;
+
+ p = buf;
+
+ p += sprintf(p, "%d\n", img_slot);
+
+ *eof = 1;
+
+ return p-buf+1;
+}
+
+static void mse500_spidimg_proc_init (void)
+{
+ struct proc_dir_entry *spidimg_proc_dir;
+ struct proc_dir_entry *entry;
+
+ spidimg_proc_dir = proc_mkdir("spidimg", &proc_root);
+
+ /* This entry is read only, so there is no write function and permissions
+ * are set to 0444. */
+ entry = create_proc_entry("current_img_slot", 0, spidimg_proc_dir);
+ entry->read_proc = mse500_readproc_img_slot;
+ entry->mode = S_IRUGO;
+ entry->data = (void *)(&mse500_cur_img_slot);
+}
+
+/**
* Function: mse500_init
* Parameters: void
* Purpose: Initialize MSE500
@@ -346,6 +392,7 @@ static void __init mse500_init(void)
mse500_init_gpio();
mse500_init_nvram (nvram_offset);
mse500_register_spi_devices();
+ mse500_spidimg_proc_init();
#if 0
#if defined(CONFIG_CPU_MXU_ENABLE) && defined(CONFIG_CPU_RO_SRAM)
// Turn SRAM_BASE Read Only