* [PATCH] Add a map_sram driver to drivers/chips/
@ 2002-11-12 11:05 Ian Campbell
2002-11-12 16:02 ` Jörn Engel
0 siblings, 1 reply; 2+ messages in thread
From: Ian Campbell @ 2002-11-12 11:05 UTC (permalink / raw)
To: Linux MTD Mailing List; +Cc: David Woodhouse
[-- Attachment #1: Type: text/plain, Size: 1194 bytes --]
Howdy,
The attached patch adds "map_sram" as a second chip driver in
drivers/mtd/chips/map_ram.c. The two are basically identical apart from
the use of the MTD_VOLATILE flag.
I have another patch which makes an entirely separate map_sram.c, but
there was so much code duplication with map_ram.c I didn't see the
point. I guess if you are using modules then you will need 'alias
map_sram map_ram' in /etc/modules.conf or something to get autoloading
to work.
The patch also includes a previous patch to set the state to
MTD_ERASE_DONE in mapram_erase. This is needed to mount a JFFS2 f/s on
an SRAM or RAM device.
Cheers,
Ian.
--
Ian Campbell
Design Engineer
Arcom Control Systems Ltd,
Clifton Road,
Cambridge CB1 7EA
United Kingdom
Tel: +44 (0)1223 403465
E-Mail: icampbell@arcomcontrols.com
Web: http://www.arcomcontrols.com
________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit http://www.messagelabs.com
________________________________________________________________________
[-- Attachment #2: mtd.map_sram-2.patch --]
[-- Type: text/x-patch, Size: 3370 bytes --]
diff -urN kernel-2.4.18.orig/include/linux/mtd/mtd.h kernel-2.4.18/include/linux/mtd/mtd.h
--- kernel-2.4.18.orig/include/linux/mtd/mtd.h Tue Jun 12 18:30:27 2001
+++ kernel-2.4.18/include/linux/mtd/mtd.h Wed Nov 6 14:05:30 2002
@@ -39,5 +39,6 @@
#define MTD_NORFLASH 3
#define MTD_NANDFLASH 4
#define MTD_PEROM 5
+#define MTD_SRAM 6
#define MTD_OTHER 14
#define MTD_UNKNOWN 15
diff -urN kernel-2.4.18.orig/drivers/mtd/chips/Config.in kernel-2.4.18/drivers/mtd/chips/Config.in
--- kernel-2.4.18.orig/drivers/mtd/chips/Config.in Thu Oct 4 23:13:18 2001
+++ kernel-2.4.18/drivers/mtd/chips/Config.in Tue Nov 12 10:29:27 2002
@@ -44,7 +44,7 @@
dep_tristate ' Support for Intel/Sharp flash chips' CONFIG_MTD_CFI_INTELEXT $CONFIG_MTD_GEN_PROBE
dep_tristate ' Support for AMD/Fujitsu flash chips' CONFIG_MTD_CFI_AMDSTD $CONFIG_MTD_GEN_PROBE
-dep_tristate ' Support for RAM chips in bus mapping' CONFIG_MTD_RAM $CONFIG_MTD
+dep_tristate ' Support for RAM/SRAM chips in bus mapping' CONFIG_MTD_RAM $CONFIG_MTD
dep_tristate ' Support for ROM chips in bus mapping' CONFIG_MTD_ROM $CONFIG_MTD
dep_tristate ' Support for absent chips in bus mapping' CONFIG_MTD_ABSENT $CONFIG_MTD
diff -urN kernel-2.4.18.orig/drivers/mtd/chips/map_ram.c kernel-2.4.18/drivers/mtd/chips/map_ram.c
--- kernel-2.4.18.orig/drivers/mtd/chips/map_ram.c Thu Oct 4 23:14:59 2001
+++ kernel-2.4.18/drivers/mtd/chips/map_ram.c Tue Nov 12 10:52:11 2002
@@ -20,6 +20,7 @@
static int mapram_erase (struct mtd_info *, struct erase_info *);
static void mapram_nop (struct mtd_info *);
static struct mtd_info *map_ram_probe(struct map_info *map);
+static struct mtd_info *map_sram_probe(struct map_info *map);
static struct mtd_chip_driver mapram_chipdrv = {
@@ -27,6 +28,11 @@
name: "map_ram",
module: THIS_MODULE
};
+static struct mtd_chip_driver mapsram_chipdrv = {
+ probe: map_sram_probe,
+ name: "map_sram",
+ module: THIS_MODULE
+};
static struct mtd_info *map_ram_probe(struct map_info *map)
{
@@ -78,6 +84,34 @@
return mtd;
}
+static struct mtd_info *map_sram_probe(struct map_info *map)
+{
+ struct mtd_info *mtd;
+
+ mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
+ if (!mtd)
+ return NULL;
+
+ memset(mtd, 0, sizeof(*mtd));
+
+ map->fldrv = &mapram_chipdrv;
+ mtd->priv = map;
+ mtd->name = map->name;
+ mtd->type = MTD_SRAM;
+ mtd->size = map->size;
+ mtd->erase = mapram_erase;
+ mtd->read = mapram_read;
+ mtd->write = mapram_write;
+ mtd->sync = mapram_nop;
+ mtd->flags = MTD_CAP_RAM;
+
+ mtd->erasesize = PAGE_SIZE;
+ while(mtd->size & (mtd->erasesize - 1))
+ mtd->erasesize >>= 1;
+
+ MOD_INC_USE_COUNT;
+ return mtd;
+}
static int mapram_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
{
@@ -107,6 +141,8 @@
for (i=0; i<instr->len; i++)
map->write8(map, 0xFF, instr->addr + i);
+ instr->state = MTD_ERASE_DONE;
+
if (instr->callback)
instr->callback(instr);
@@ -121,12 +157,14 @@
int __init map_ram_init(void)
{
register_mtd_chip_driver(&mapram_chipdrv);
+ register_mtd_chip_driver(&mapsram_chipdrv);
return 0;
}
static void __exit map_ram_exit(void)
{
unregister_mtd_chip_driver(&mapram_chipdrv);
+ unregister_mtd_chip_driver(&mapsram_chipdrv);
}
module_init(map_ram_init);
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] Add a map_sram driver to drivers/chips/
2002-11-12 11:05 [PATCH] Add a map_sram driver to drivers/chips/ Ian Campbell
@ 2002-11-12 16:02 ` Jörn Engel
0 siblings, 0 replies; 2+ messages in thread
From: Jörn Engel @ 2002-11-12 16:02 UTC (permalink / raw)
To: Ian Campbell; +Cc: Linux MTD Mailing List
On Tue, 12 November 2002 11:05:25 +0000, Ian Campbell wrote:
>
> The attached patch adds "map_sram" as a second chip driver in
> drivers/mtd/chips/map_ram.c. The two are basically identical apart from
> the use of the MTD_VOLATILE flag.
Slightly OT.
Have you tried the slram driver? I have always used that one to access
plain old memory and was very happy. And now you make me wonder, if
there is another way that might even be better.
Jörn
--
A victorious army first wins and then seeks battle.
-- Sun Tzu
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-11-12 15:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-12 11:05 [PATCH] Add a map_sram driver to drivers/chips/ Ian Campbell
2002-11-12 16:02 ` Jörn Engel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox