Skip to contentSkip to conversation

MTDRAM update for SRAM.

PATCH Bjorn Eriksson 1 participant 1 message Sep 21, 2000 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

[First attempt bounced with: administrative prohibition (host is blacklisted)]
Couple of small changes:

I made mtdram.c support my battery backuped, memory mapped SRAM device. Added -O1 CFLAGS_pmc551.o
Changed dirname $0 into 'cd dirname $0 && pwd' since $0 doesn't resolve
to a fully qualified path (I tried it with several shells).

Index: mtd/kernel/Config.in
===================================================================
RCS file: /home/cvs/mtd/kernel/Config.in,v
retrieving revision 1.27

kernel/Config.in +1 -0
diff -u -r1.27 Config.in
@@ -38,6 +38,9 @@
    if [ "$CONFIG_MTD_MTDRAM" != "n" ]; then
       int 'Device size in kB' CONFIG_MTDRAM_TOTAL_SIZE 4096
       int 'Size of the erase sectors in kB' CONFIG_MTDRAM_ERASE_SIZE 128
+      if [ "$CONFIG_MTD_MTDRAM" = "y" ]; then #If not a module (I don't

want to test it as a module)
+ int 'SRAM: Absolute position (or 0 if N/A)' CONFIG_MTDRAM_ABS_POS
0
+ fi
fi

comment 'Linearly Mapped Flash Device Drivers'
Index: mtd/kernel/Makefile
===================================================================
RCS file: /home/cvs/mtd/kernel/Makefile,v
retrieving revision 1.24

kernel/Makefile +1 -0
diff -u -r1.24 Makefile
@@ -21,6 +21,7 @@
 	nora.o octagon-5066.o pnc2000.o rpxlite.o vmax301.o mtdchar.o \
 	mtdblock.o ftl.o nftl.o sbc_mediagx.o elan-104nc.o
 
+CFLAGS_pmc551.o := -O1 # or -O0 or -g, or my egcs-2.91.66 goes to sleep.
 CFLAGS_nftl.o := -DCONFIG_NFTL_RW
 CFLAGS_mtdram.o

:= -DCONFIG_MTDRAM_TOTAL_SIZE=4096 -DCONFIG_MTDRAM_ERASE_SIZE=128
CFLAGS_physmap.o
:= -DCONFIG_MTD_PHYSMAP_START=0x8000000 -DCONFIG_MTD_PHYSMAP_LEN=0x4000000
Index: mtd/kernel/mtdram.c
===================================================================
RCS file: /home/cvs/mtd/kernel/mtdram.c,v
retrieving revision 1.16

kernel/mtdram.c +11 -2
diff -u -r1.16 mtdram.c
@@ -15,8 +15,9 @@
 #include <linux/ioport.h>
 #include <linux/mtd/compatmac.h>
 #include <linux/mtd/mtd.h>
-
-
+#if CONFIG_MTDRAM_ABS_POS > 0
+  #include <asm/io.h>
+#endif
 
 #ifdef MODULE
 static unsigned long total_size = CONFIG_MTDRAM_TOTAL_SIZE;
@@ -101,7 +107,11 @@
   if (mtd_info) {
     del_mtd_device(mtd_info);
     if (mtd_info->priv)
+#if CONFIG_MTDRAM_ABS_POS > 0
+      iounmap(mtd_info->priv);
+#else
       vfree(mtd_info->priv);
+#endif
     kfree(mtd_info);
   }
 }
@@ -123,8 +133,19 @@
    mtd_info->flags = MTD_CAP_RAM;
    mtd_info->size = MTDRAM_TOTAL_SIZE;
    mtd_info->erasesize = MTDRAM_ERASE_SIZE;
+#if CONFIG_MTDRAM_ABS_POS > 0
+   mtd_info->priv = ioremap(CONFIG_MTDRAM_ABS_POS, MTDRAM_TOTAL_SIZE);
+   if ( !mtd_info->priv ) {
+      printk("Failed to ioremap memory region (pos:%d, size: %d)\n",

(int)CONFIG_MTDRAM_ABS_POS, (int)MTDRAM_TOTAL_SIZE);
+ return -EIO;
+ } else {
+ printk("Sucess: ioremap memory region (pos:%d, size: %d)\n",
(int)CONFIG_MTDRAM_ABS_POS, (int)MTDRAM_TOTAL_SIZE);
+ }
+
+#else

    mtd_info->priv = vmalloc(MTDRAM_TOTAL_SIZE);
    memset(mtd_info->priv, 0xff, MTDRAM_TOTAL_SIZE);

+#endif

 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
    mtd_info->module = THIS_MODULE;
@@ -142,7 +163,11 @@
    mtd_info->write = ram_write;

    if (add_mtd_device(mtd_info)) {
+#if CONFIG_MTDRAM_ABS_POS > 0
+     iounmap(mtd_info->priv);
+#else
      vfree(mtd_info->priv);
+#endif
      kfree(mtd_info);
      mtd_info = NULL;
      return -EIO;

Index: mtd/patches/patchin.sh
===================================================================
RCS file: /home/cvs/mtd/patches/patchin.sh,v
retrieving revision 1.1

patches/patchin.sh +2 -1
diff -u -r1.1 patchin.sh
@@ -5,7 +5,8 @@
 # This only adds symlinks to the new files - you'll also need to apply
 # the appropriate patch from this directory.
 
-THISDIR=`dirname $0`
+cd `dirname $0`
+THISDIR=`pwd`
 TOPDIR=`dirname $THISDIR`
 
 LINUXDIR=/usr/src/linux

--
//Björnen

To unsubscribe, send "unsubscribe mtd" to [email protected]