All of lore.kernel.org
 help / color / mirror / Atom feed
* I have a NOR and NAND flash chips
@ 2003-08-07  8:22 Marcos Lois Bermúdez
  2003-08-07 10:52 ` David Woodhouse
  0 siblings, 1 reply; 3+ messages in thread
From: Marcos Lois Bermúdez @ 2003-08-07  8:22 UTC (permalink / raw)
  To: linux-mtd

Hello i will start to add support for the new revision of the Dragonix 
board. Now in the board we have a NOR flash (i already have this flash chip 
working), and a NAND chip also a SmartMedia slot.

My question is:

Can i setup mtd to work with both types of memories NOR and NAND, there are 
any example to do this?
How i can implement the SmartMedia slot, to allow hot plug of the 
smartmedia cards?

Any hel are apreciated.

Regards.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: I have a NOR and NAND flash chips
  2003-08-07  8:22 I have a NOR and NAND flash chips Marcos Lois Bermúdez
@ 2003-08-07 10:52 ` David Woodhouse
  2003-08-07 11:18   ` Ian Campbell
  0 siblings, 1 reply; 3+ messages in thread
From: David Woodhouse @ 2003-08-07 10:52 UTC (permalink / raw)
  To: Marcos Lois Bermúdez; +Cc: linux-mtd

On Thu, 2003-08-07 at 09:22, Marcos Lois Bermúdez wrote:
> Can i setup mtd to work with both types of memories NOR and NAND, there are 
> any example to do this?

Yes. You don't have to do anything special -- just have drivers for any
and all flash devices found in the system. You just have to be aware
that they'll get assigned numbers in the order they get registered,
that's all.

> How i can implement the SmartMedia slot, to allow hot plug of the 
> smartmedia cards?


That one's slightly harder. I suppose you just need to redirect all the
read/write/erase functions to something which returns -EIO when it's
hot-unplugged while it's in use.

-- 
dwmw2

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: I have a NOR and NAND flash chips
  2003-08-07 10:52 ` David Woodhouse
@ 2003-08-07 11:18   ` Ian Campbell
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Campbell @ 2003-08-07 11:18 UTC (permalink / raw)
  To: Linux MTD Mailing List

[-- Attachment #1: Type: text/plain, Size: 1237 bytes --]

> You just have to be aware
> that they'll get assigned numbers in the order they get registered,
> that's all.

A long while ago I submitted a patch which added a function
add_mtd_device_full which allowed you to request a specific minor
number. We use it to ensure SRAM is always minor 15, no matter how many
partitions are in the main flash array, which can make things easier on
the support guys, for documentation purposes etc.

I've attached it again since it may be of interest, since your map
driver could then register the flash at a specific device. I can see how
a add_mtd_partition_full which allowed you to specify a starting minor
number would be useful too, but I haven't needed it myself.

Ian.

-- 
Ian Campbell, Senior Design Engineer

Arcom, Clifton Road, 			Direct: +44 (0)1223 403 465
Cambridge CB1 7EA, United Kingdom	Phone:  +44 (0)1223 411 200


________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com
________________________________________________________________________

[-- Attachment #2: mtd-add_full.patch --]
[-- Type: text/plain, Size: 3442 bytes --]

%patch
Index: q/drivers/mtd/mtdcore.c
===================================================================
--- q.orig/drivers/mtd/mtdcore.c	Tue Aug  5 16:46:21 2003
+++ q/drivers/mtd/mtdcore.c	Tue Aug  5 16:46:38 2003
@@ -36,30 +36,39 @@
 static LIST_HEAD(mtd_notifiers);
 
 /**
- *	add_mtd_device - register an MTD device
+ *	add_mtd_device_full - register an MTD device at a particular minor number
  *	@mtd: pointer to new MTD device info structure
+ *	@minor: requested minor number. -1 to for the first free.
  *
- *	Add a device to the list of MTD devices present in the system, and
- *	notify each currently active MTD 'user' of its arrival. Returns
- *	zero on success or 1 on failure, which currently will only happen
- *	if the number of present devices exceeds MAX_MTD_DEVICES (i.e. 16)
+ *	Add a device to the list of MTD devices present in the system,
+ *	and notifies each currently active MTD 'user' of its
+ *	arrival. Returns zero on success or 1 on failure, which
+ *	currently only occurs if the requested minor number has
+ *	already been allocated or if minor exceeds MAX_MTD_DEVICES
+ *	(i.e. 16)
  */
-
-int add_mtd_device(struct mtd_info *mtd)
+int add_mtd_device_full(struct mtd_info *mtd, int minor)
 {
-	int i;
-
 	down(&mtd_table_mutex);
 
-	for (i=0; i < MAX_MTD_DEVICES; i++)
-		if (!mtd_table[i]) {
+	if ( minor == -1 ) {
+		for (minor = 0; minor < MAX_MTD_DEVICES; minor++)
+			if (!mtd_table[minor])
+				break;
+	}
+
+	if ( minor >= MAX_MTD_DEVICES || minor < 0 || mtd_table[minor] ) {
+		up(&mtd_table_mutex);
+		return 1;
+	}
+
 			struct list_head *this;
 
-			mtd_table[i] = mtd;
-			mtd->index = i;
+	mtd_table[minor] = mtd;
+	mtd->index = minor;
 			mtd->usecount = 0;
 
-			DEBUG(0, "mtd: Giving out device %d to %s\n",i, mtd->name);
+	DEBUG(0, "mtd: Giving out device %d to %s\n",minor, mtd->name);
 			/* No need to get a refcount on the module containing
 			   the notifier, since we hold the mtd_table_mutex */
 			list_for_each(this, &mtd_notifiers) {
@@ -76,8 +85,18 @@
 			return 0;
 		}
 	
-	up(&mtd_table_mutex);
-	return 1;
+/**
+ *	add_mtd_device - register an MTD device
+ *	@mtd: pointer to new MTD device info structure
+ *
+ *	Add a device to the list of MTD devices present in the system, and
+ *	notify each currently active MTD 'user' of its arrival. Returns
+ *	zero on success or 1 on failure, which currently will only happen
+ *	if the number of present devices exceeds MAX_MTD_DEVICES (i.e. 16)
+ */
+int add_mtd_device(struct mtd_info *mtd)
+{
+	return add_mtd_device_full(mtd, -1);
 }
 
 /**
@@ -288,6 +307,7 @@
 
 
 EXPORT_SYMBOL(add_mtd_device);
+EXPORT_SYMBOL(add_mtd_device_full);
 EXPORT_SYMBOL(del_mtd_device);
 EXPORT_SYMBOL(get_mtd_device);
 EXPORT_SYMBOL(put_mtd_device);
Index: q/include/linux/mtd/mtd.h
===================================================================
--- q.orig/include/linux/mtd/mtd.h	Tue Aug  5 16:46:22 2003
+++ q/include/linux/mtd/mtd.h	Tue Aug  5 16:46:38 2003
@@ -238,6 +238,7 @@
 	/* Kernel-side ioctl definitions */
 
 extern int add_mtd_device(struct mtd_info *mtd);
+extern int add_mtd_device_full(struct mtd_info *mtd, int minor);
 extern int del_mtd_device (struct mtd_info *mtd);
 
 extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num);

%diffstat
 drivers/mtd/mtdcore.c   |   52 +++++++++++++++++++++++++++++++++---------------
 include/linux/mtd/mtd.h |    1 
 2 files changed, 37 insertions(+), 16 deletions(-)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-08-07 11:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-07  8:22 I have a NOR and NAND flash chips Marcos Lois Bermúdez
2003-08-07 10:52 ` David Woodhouse
2003-08-07 11:18   ` Ian Campbell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.