Skip to contentSkip to conversation

mtd: nand: new base driver for memory mapped nand devices

PATCH New Mike Frysinger 3 participants 24 messages Apr 12, 2009 – May 29, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: nand: new base driver for memory mapped nand devices

The BF537-STAMP Blackfin board had a driver for working with NAND devices that are simply memory mapped. Since there is nothing Blackfin specific about this, generalize the driver a bit so that everyone can leverage it.

---
 board/bf537-stamp/Makefile        |    1 -
 board/bf537-stamp/nand.c          |  100 -------------------------------------
 drivers/mtd/nand/Makefile         |    1 +
 drivers/mtd/nand/nand_plat.c      |   66 ++++++++++++++++++++++++
 include/configs/bf537-stamp.h     |   43 +++++-----------
 include/configs/bfin_adi_common.h |    3 +
 6 files changed, 84 insertions(+), 130 deletions(-)
 delete mode 100644 board/bf537-stamp/nand.c
 create mode 100644 drivers/mtd/nand/nand_plat.c
board/bf537-stamp/Makefile +0 -1
index 1dbf406..6da04e3 100644
@@ -32,7 +32,6 @@ LIB	= $(obj)lib$(BOARD).a
 COBJS-y	:= $(BOARD).o cmd_bf537led.o
 COBJS-$(CONFIG_BFIN_IDE)   += ide-cf.o
 COBJS-$(CONFIG_CMD_EEPROM) += spi_flash.o
-COBJS-$(CONFIG_CMD_NAND)   += nand.o
 COBJS-$(CONFIG_POST)       += post.o post-memory.o
 
 SRCS	:= $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
board/bf537-stamp/nand.c deleted +0 -100

100 lines not on this page · raw message

drivers/mtd/nand/Makefile +1 -0
index 5974d77..46ad901 100644
@@ -41,6 +41,7 @@ COBJS-$(CONFIG_NAND_FSL_UPM) += fsl_upm.o
 COBJS-$(CONFIG_NAND_NOMADIK) += nomadik.o
 COBJS-$(CONFIG_NAND_S3C64XX) += s3c64xx.o
 COBJS-$(CONFIG_NAND_OMAP_GPMC) += omap_gpmc.o
+COBJS-$(CONFIG_NAND_PLAT) += nand_plat.o
 endif
 
 COBJS	:= $(COBJS-y)
drivers/mtd/nand/nand_plat.c new file +66 -0

66 lines not on this page · raw message

include/configs/bf537-stamp.h +14 -29

50 lines not on this page · raw message

include/configs/bfin_adi_common.h +3 -0
index 030e63c..fa96dcf 100644
@@ -38,6 +38,9 @@
 #  define CONFIG_CMD_USB_STORAGE
 #  define CONFIG_DOS_PARTITION
 # endif
+# ifdef CONFIG_NAND_PLAT
+#  define CONFIG_CMD_NAND
+# endif
 # ifdef CONFIG_POST
 #  define CONFIG_CMD_DIAG
 # endif
Signature · 1 line
1.6.2.2
#1 lore raw

PATCH 1/1 mtd: nand: new base driver for memory mapped nand devices

Quoted 1 line · Mike Frysinger

+#ifdef NAND_PLAT_WRITE_CMD

Why would a user select this driver without providing the necessary definitions -- and if they do, why do you want anything other than a compilation error to result?

+ /* Drain the writebuffer */
+ sync();

This doesn't look generic to me.

include/configs/bf537-stamp.h line 145

Quoted 3 lines
include/configs/bf537-stamp.h +3 -0
+#define BFIN_NAND_CLE(chip) ((unsigned long)chip->IO_ADDR_W | (1 << 2))
+#define BFIN_NAND_ALE(chip) ((unsigned long)chip->IO_ADDR_W | (1 << 1))
+#define BFIN_NAND_READY     PF3

You have a global variable called "PF3"?

include/configs/bf537-stamp.h line 153

Quoted 7 lines
include/configs/bf537-stamp.h +7 -0
+#define NAND_PLAT_WRITE_CMD(cmd, chip) bfin_write8(BFIN_NAND_CLE(chip), cmd)
+#define NAND_PLAT_WRITE_ADR(cmd, chip) bfin_write8(BFIN_NAND_ALE(chip), cmd)
+#define NAND_PLAT_DEV_READY(chip)      ((*pPORTFIO & BFIN_NAND_READY) ? 1 : 0)
+#define NAND_PLAT_INIT() \
+	*pPORTF_FER &= ~BFIN_NAND_READY; \
+	*pPORTFIO_DIR &= ~BFIN_NAND_READY; \
+	*pPORTFIO_INEN |= BFIN_NAND_READY;

I'm not too fond of such things being done through header files -- it means that only one type of so-called "memory mapped" NAND device can be supported in a given u-boot image. If it doesn't add too much image size overhead, I'd prefer having platform code register a struct of callbacks (or just live with the duplication of 10-15 almost-but-not-quite-generic lines, and focus on factoring out instances where they're truly identical).

If we do do it in the header file, though, at least use static inline functions rather than macros -- besides being less visually obnoxious, they provide type checking of arguments and avoid problems with name collisions. And if you must use macros, always use this:

#define NAND_PLAT_INIT() do { \
	multi; \
	line; \
	macro; \
} while (0) \

rather than this:

#define NAND_PLAT_INIT() \
	multi; \
	line; \
	macro;

The latter will break if you put it in the body of a single-line if statement.

-Scott

#2 lore raw

PATCH 1/1 mtd: nand: new base driver for memory mapped nand devices

Quoted 6 lines · On Monday 13 April 2009 11:59:30 Scott Wood wrote:
Quoted 1 line · Mike Frysinger

+#ifdef NAND_PLAT_WRITE_CMD

Why would a user select this driver without providing the necessary definitions -- and if they do, why do you want anything other than a compilation error to result?

*shrug* ... i'm not completely familiar with the nand layers and what people have done to know exactly what is optional. easy enough to turn it into:
#ifndef NAND_PLAT_WRITE_CMD

# error "You must define NAND_PLAT_WRITE_CMD"
#endif
Quoted 4 lines
drivers/mtd/nand/nand_plat.c new file +2 -0
+	/* Drain the writebuffer */
+	sync();

This doesn't look generic to me.

yes it does. every arch should define "sync()" in asm/io.h. if it doesnt, your arch is broken.

Quoted 5 lines

include/configs/bf537-stamp.h line 145

Quoted 3 lines
include/configs/bf537-stamp.h +3 -0
+#define BFIN_NAND_CLE(chip) ((unsigned long)chip->IO_ADDR_W | (1 << 2))
+#define BFIN_NAND_ALE(chip) ((unsigned long)chip->IO_ADDR_W | (1 << 1))
+#define BFIN_NAND_READY     PF3

You have a global variable called "PF3"?

a global define actually, but yes

Quoted 8 lines

include/configs/bf537-stamp.h line 153

Quoted 7 lines

+#define NAND_PLAT_WRITE_CMD(cmd, chip) bfin_write8(BFIN_NAND_CLE(chip), cmd) +#define NAND_PLAT_WRITE_ADR(cmd, chip) bfin_write8(BFIN_NAND_ALE(chip), cmd) +#define NAND_PLAT_DEV_READY(chip)

    ((*pPORTFIO & BFIN_NAND_READY) ? 1 : 0) +#define NAND_PLAT_INIT() \
include/configs/bf537-stamp.h +3 -0
+	*pPORTF_FER &= ~BFIN_NAND_READY; \
+	*pPORTFIO_DIR &= ~BFIN_NAND_READY; \
+	*pPORTFIO_INEN |= BFIN_NAND_READY;
Quoted 7 lines

I'm not too fond of such things being done through header files -- it means that only one type of so-called "memory mapped" NAND device can be supported in a given u-boot image. If it doesn't add too much image size overhead, I'd prefer having platform code register a struct of callbacks (or just live with the duplication of 10-15 almost-but-not-quite-generic lines, and focus on factoring out instances where they're truly identical).

doing it in the header follows u-boot convention, and it's much easier than creating a dedicated file. doesnt matter to me.

Quoted 4 lines

If we do do it in the header file, though, at least use static inline functions rather than macros -- besides being less visually obnoxious, they provide type checking of arguments and avoid problems with name collisions.

actually, it kind of does the opposite. it increases name space pollution. if someone does a #define with the same variable name or similar as is used in the function, then you can easily get a build failure. see all the random times this has caused a problem with linux/glibc/uClibc and just function prototypes let alone function definitions. plus, not so critically, using static inlines would slow down the compiler as it would need to compile & optimize & consider it in every single file rather than letting the CPP cull it early on.

Quoted 2 lines

The latter will break if you put it in the body of a single-line if statement.

i'm fully aware of this, but didnt care since i knew how it was used
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090413/227bf00c/attachment.pgp

#3 lore raw

PATCH 1/1 mtd: nand: new base driver for memory mapped nand devices

Quoted 9 lines · Mike Frysinger
Quoted 5 lines · On Monday 13 April 2009 11:59:30 Scott Wood wrote:
Quoted 1 line · Mike Frysinger

+#ifdef NAND_PLAT_WRITE_CMD

Why would a user select this driver without providing the necessary definitions -- and if they do, why do you want anything other than a compilation error to result?

*shrug* ... i'm not completely familiar with the nand layers and what people have done to know exactly what is optional.

You're defining the interface -- there are no existing users.

Quoted 4 lines

easy enough to turn it into:
#ifndef NAND_PLAT_WRITE_CMD

# error "You must define NAND_PLAT_WRITE_CMD"
#endif

Or just let the compiler give an undefined symbol error.

Quoted 7 lines
Quoted 4 lines
drivers/mtd/nand/nand_plat.c new file +2 -0
+	/* Drain the writebuffer */
+	sync();

This doesn't look generic to me.

yes it does. every arch should define "sync()" in asm/io.h. if it doesnt, your arch is broken.

I realize that there is a "sync" defined in every architecture (otherwise, my comment would have been "this breaks on XXX arch").

However, the need to do a sync in this specific situation is specific to how NAND_PLAT_WRITE_* are implemented (in many cases, they will have already included a sync or something similar -- they're often included in the basic I/O accessors). And the specific comment about a "writebuffer" seems even more out of place in generic code.

Quoted 10 lines
Quoted 7 lines

I'm not too fond of such things being done through header files -- it means that only one type of so-called "memory mapped" NAND device can be supported in a given u-boot image. If it doesn't add too much image size overhead, I'd prefer having platform code register a struct of callbacks (or just live with the duplication of 10-15 almost-but-not-quite-generic lines, and focus on factoring out instances where they're truly identical).

doing it in the header follows u-boot convention, and it's much easier than creating a dedicated file. doesnt matter to me.

That convention has been the subject of some (quite justified, IMHO) complaints recently.

Quoted 8 lines
Quoted 4 lines

If we do do it in the header file, though, at least use static inline functions rather than macros -- besides being less visually obnoxious, they provide type checking of arguments and avoid problems with name collisions.

actually, it kind of does the opposite. it increases name space pollution. if someone does a #define with the same variable name or similar as is used in the function, then you can easily get a build failure.

The root cause of that is the namespace-polluting #define, not the function. It would just as easily cause problems with code in .c files (including when your macros get expanded) as with inline functions in headers.

Quoted 2 lines

see all the random times this has caused a problem with linux/glibc/uClibc and just function prototypes let alone function definitions.

This is an internal header file, not a public library header that is standards-constrained to accept #define interference from the application.

Quoted 4 lines

plus, not so critically, using
static inlines would slow down the compiler as it would need to compile & optimize & consider it in every single file rather than letting the CPP cull it early on.

On the other hand, that means that errors get caught immediately rather than when usage changes.

Quoted 4 lines
Quoted 2 lines

The latter will break if you put it in the body of a single-line if statement.

i'm fully aware of this, but didnt care since i knew how it was used

And maybe it gets used differently in the future? Or someone copies the bad example to somewhere else where it matters?

-Scott

#4 lore raw

PATCH 1/1 mtd: nand: new base driver for memory mapped nand devices

Quoted 5 lines · On Monday 13 April 2009 17:42:00 Scott Wood wrote:
Quoted 4 lines · Mike Frysinger
Quoted 3 lines · On Monday 13 April 2009 11:59:30 Scott Wood wrote:
Quoted 1 line · Mike Frysinger

+#ifdef NAND_PLAT_WRITE_CMD

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Why would a user select this driver without providing the necessary definitions -- and if they do, why do you want anything other than a compilation error to result?

*shrug* ... i'm not completely familiar with the nand layers and what people have done to know exactly what is optional.

You're defining the interface -- there are no existing users.

just because *my* device needs it doesnt mean every device needs it. i was trying to be nice from the get go.

Quoted 6 lines
Quoted 4 lines

easy enough to turn it into:
#ifndef NAND_PLAT_WRITE_CMD

# error "You must define NAND_PLAT_WRITE_CMD"
#endif

Or just let the compiler give an undefined symbol error.

true, but i think that route leads to people grepping files and scratching their heads. an #error would save them some time.

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
drivers/mtd/nand/nand_plat.c new file +2 -0
+	/* Drain the writebuffer */
+	sync();

This doesn't look generic to me.

yes it does. every arch should define "sync()" in asm/io.h. if it doesnt, your arch is broken.

Quoted 8 lines

I realize that there is a "sync" defined in every architecture (otherwise, my comment would have been "this breaks on XXX arch").

However, the need to do a sync in this specific situation is specific to how NAND_PLAT_WRITE_* are implemented (in many cases, they will have already included a sync or something similar -- they're often included in the basic I/O accessors). And the specific comment about a "writebuffer" seems even more out of place in generic code.

if they're included in the I/O accessors, then the arch most likely defines sync() to nothing, so it doesnt matter. "write buffer" may not be entirely arch independent, but it conveys the exact same thing as "make sure write makes it to external device". this is how sync() is used -- just grep the drivers tree and see the smsc driver for example.

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines

If we do do it in the header file, though, at least use static inline functions rather than macros -- besides being less visually obnoxious, they provide type checking of arguments and avoid problems with name collisions.

actually, it kind of does the opposite. it increases name space pollution. if someone does a #define with the same variable name or similar as is used in the function, then you can easily get a build failure.

Quoted 4 lines

The root cause of that is the namespace-polluting #define, not the function. It would just as easily cause problems with code in .c files (including when your macros get expanded) as with inline functions in headers.

or accidental shadowing of global state, but i guess you dont care much about that usage either

Quoted 6 lines
Quoted 3 lines

see all the random times this has caused a problem with linux/glibc/uClibc and just function prototypes let alone function definitions.

This is an internal header file, not a public library header that is standards-constrained to accept #define interference from the application.

really ? you call internal kernel headers "standards constrained" ? my point is that it's seen in both scenarios.

Quoted 7 lines
Quoted 4 lines

plus, not so critically, using
static inlines would slow down the compiler as it would need to compile & optimize & consider it in every single file rather than letting the CPP cull it early on.

On the other hand, that means that errors get caught immediately rather than when usage changes.

indeed

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

The latter will break if you put it in the body of a single-line if statement.

i'm fully aware of this, but didnt care since i knew how it was used

And maybe it gets used differently in the future? Or someone copies the bad example to somewhere else where it matters?

people should check their work before they hand in their paper ;)
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090413/7d02c21b/attachment.pgp

#5 lore raw

PATCH 1/1 mtd: nand: new base driver for memory mapped nand devices

Quoted 5 lines · Mike Frysinger
Quoted 1 line · On Monday 13 April 2009 17:42:00 Scott Wood wrote:

You're defining the interface -- there are no existing users.

just because *my* device needs it doesnt mean every device needs it. i was trying to be nice from the get go.

Every device that is a reasonable candidate for using such a shared driver does need it. If a device is different enough that a "write a command byte/word" operation doesn't map well (such as Freescale's eLBC), then we shouldn't try to force it into a so-called generic framework.

In other words, this is just to templatize a common NAND driver pattern, not to replace the main NAND driver interface.

Quoted 8 lines
Quoted 5 lines
Quoted 4 lines

easy enough to turn it into:
#ifndef NAND_PLAT_WRITE_CMD

# error "You must define NAND_PLAT_WRITE_CMD"
#endif

Or just let the compiler give an undefined symbol error.

true, but i think that route leads to people grepping files and scratching their heads. an #error would save them some time.

If we did that every place some arch- or platform-defined symbol were used, the source code would be (even more of) a mess.

Instead, how about putting a comment at the top of the file stating what it requires from the platform, and describing the semantics of each item? That would save more head-scratching than simply turning "not defined" into "you must define".

Quoted 8 lines
Quoted 5 lines

However, the need to do a sync in this specific situation is specific to how NAND_PLAT_WRITE_* are implemented (in many cases, they will have already included a sync or something similar -- they're often included in the basic I/O accessors). And the specific comment about a "writebuffer" seems even more out of place in generic code.

if they're included in the I/O accessors, then the arch most likely defines sync() to nothing, so it doesnt matter.

Um, no. See powerpc for example.

Explicit barriers are for when you use raw I/O accessors in optimized paths, or when you need to synchronize accesses to main memory (such as in a DMA buffer).

Quoted 4 lines

"write buffer" may not be entirely
arch independent, but it conveys the exact same thing as "make sure write makes it to external device". this is how sync() is used -- just grep the drivers tree and see the smsc driver for example.

I did grep, and the only non-arch-specific use I found was in cfi_flash. I'm not sure what you mean by the "smsc driver".

Quoted 7 lines
Quoted 4 lines

The root cause of that is the namespace-polluting #define, not the function. It would just as easily cause problems with code in .c files (including when your macros get expanded) as with inline functions in headers.

or accidental shadowing of global state, but i guess you dont care much about that usage either

I care very much about avoiding accidents. Preprocessor macros cause accidents. :-)

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

see all the random times this has caused a problem with linux/glibc/uClibc and just function prototypes let alone function definitions.

This is an internal header file, not a public library header that is standards-constrained to accept #define interference from the application.

really ? you call internal kernel headers "standards constrained" ?

Linux contains headers used by glibc; those parts are indeed standards constrained. And while the user-visible headers that aren't directly included in a glibc header aren't specifically constrained by the C standard, they're intended to be used in more or less arbitrary C environments in ways similar to the C library, so quality-of-implementation dictates that similar care be taken.

As for the internal headers, any such problem could be remedied by fixing the offending #define. Further, inline functions seem to be preferred over macros in Linux, so I'm not sure that they're the best example to pick to justify using macros.

Indeed, I'm not sure what relevance this has at all -- the solution to the "variable has the same name as a user define" problem in public headers is to use a reserved namespace, not to use a macro. Macros make the problem worse by making it possible to alias local variables in the expanding context (which may have been used as macro parameters), as well as #defines.

Which reminds me:

include/configs/bf537-stamp.h line 144

Quoted 2 lines
include/configs/bf537-stamp.h +2 -0
+#define BFIN_NAND_CLE(chip) ((unsigned long)chip->IO_ADDR_W | (1 << 2))
+#define BFIN_NAND_ALE(chip) ((unsigned long)chip->IO_ADDR_W | (1 << 1))

Put parentheses around chip, in case the caller provided a complex expression.

-Scott

#6 lore raw

PATCH 1/1 mtd: nand: new base driver for memory mapped nand devices

Quoted 7 lines · On Monday 13 April 2009 19:02:05 Scott Wood wrote:
Quoted 5 lines · Mike Frysinger
Quoted 1 line · On Monday 13 April 2009 17:42:00 Scott Wood wrote:

You're defining the interface -- there are no existing users.

just because *my* device needs it doesnt mean every device needs it. i was trying to be nice from the get go.

Quoted 8 lines

Every device that is a reasonable candidate for using such a shared driver does need it. If a device is different enough that a "write a command byte/word" operation doesn't map well (such as Freescale's eLBC), then we shouldn't try to force it into a so-called generic framework.

In other words, this is just to templatize a common NAND driver pattern, not to replace the main NAND driver interface.

as i said, i'm not familiar with other use cases, so i cant pick out exactly what is common/required and what isnt. you can just state which is which and i'll do it.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

easy enough to turn it into:
#ifndef NAND_PLAT_WRITE_CMD

# error "You must define NAND_PLAT_WRITE_CMD"
#endif
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Or just let the compiler give an undefined symbol error.

true, but i think that route leads to people grepping files and scratching their heads. an #error would save them some time.

If we did that every place some arch- or platform-defined symbol were used, the source code would be (even more of) a mess.

there's a difference between "used" and "required". the #error makes sense in the face of no documentation.

Quoted 4 lines

Instead, how about putting a comment at the top of the file stating what it requires from the platform, and describing the semantics of each item? That would save more head-scratching than simply turning "not defined" into "you must define".

that works for me

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

However, the need to do a sync in this specific situation is specific to how NAND_PLAT_WRITE_* are implemented (in many cases, they will have already included a sync or something similar -- they're often included in the basic I/O accessors). And the specific comment about a "writebuffer" seems even more out of place in generic code.

Quoted 8 lines
Quoted 2 lines

if they're included in the I/O accessors, then the arch most likely defines sync() to nothing, so it doesnt matter.

Um, no. See powerpc for example.

Explicit barriers are for when you use raw I/O accessors in optimized paths, or when you need to synchronize accesses to main memory (such as in a DMA buffer).

OK

Quoted 7 lines
Quoted 4 lines

"write buffer" may not be entirely
arch independent, but it conveys the exact same thing as "make sure write makes it to external device". this is how sync() is used -- just grep the drivers tree and see the smsc driver for example.

I did grep, and the only non-arch-specific use I found was in cfi_flash. I'm not sure what you mean by the "smsc driver".

it used to be in there, but it isnt anymore. guess it changed since i last read it (but that was back in like 1.1.6 days).

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

see all the random times this has caused a problem with linux/glibc/uClibc and just function prototypes let alone function definitions.

This is an internal header file, not a public library header that is standards-constrained to accept #define interference from the application.

Quoted 8 lines
Quoted 1 line

really ? you call internal kernel headers "standards constrained" ?

Linux contains headers used by glibc; those parts are indeed standards constrained. And while the user-visible headers that aren't directly included in a glibc header aren't specifically constrained by the C standard, they're intended to be used in more or less arbitrary C environments in ways similar to the C library, so quality-of-implementation dictates that similar care be taken.

which is why so many of the exported headers use macros rather than static inlines. they only get expanded and make a mess when they actually get used.

Quoted 4 lines

As for the internal headers, any such problem could be remedied by fixing the offending #define. Further, inline functions seem to be preferred over macros in Linux, so I'm not sure that they're the best example to pick to justify using macros.

except using defines avoiding the need to "fix" files constantly

Quoted 6 lines

Indeed, I'm not sure what relevance this has at all -- the solution to the "variable has the same name as a user define" problem in public headers is to use a reserved namespace, not to use a macro. Macros make the problem worse by making it possible to alias local variables in the expanding context (which may have been used as macro parameters), as well as #defines.

static inline usage works in the kernel because the headers are separated logically -- there is no config.h which gets included by every file and contains static inline functions or complex macros.

my point is that "static inline" vs "define" isnt as cut as try as you may like. if we had a dedicated header file that only was included when needed (or included with the nand headers), then i'd have no problem with static inline. but considering the board config header is included *everywhere*, including assembly files and when building the utilities on the host, C code should be avoided in it whenever possible.

Quoted 6 lines

Which reminds me:

include/configs/bf537-stamp.h line 144

Quoted 2 lines
include/configs/bf537-stamp.h +2 -0
+#define BFIN_NAND_CLE(chip) ((unsigned long)chip->IO_ADDR_W | (1 << 2))
+#define BFIN_NAND_ALE(chip) ((unsigned long)chip->IO_ADDR_W | (1 << 1))

Put parentheses around chip, in case the caller provided a complex expression.

thanks
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090413/cc58369b/attachment.pgp

#7 lore raw

PATCH v2 1/1 mtd: nand: new base driver for memory mapped nand devices

In reply to Mike Frysinger

The BF537-STAMP Blackfin board had a driver for working with NAND devices that are simply memory mapped. Since there is nothing Blackfin specific about this, generalize the driver a bit so that everyone can leverage it.

---
v2
- update based on feedback from Scott Wood

 board/bf537-stamp/Makefile        |    1 -
 board/bf537-stamp/nand.c          |  100 -------------------------------------
 drivers/mtd/nand/Makefile         |    1 +
 drivers/mtd/nand/nand_plat.c      |   53 +++++++++++++++++++
 include/configs/bf537-stamp.h     |   44 +++++++----------
 include/configs/bfin_adi_common.h |    3 +
 6 files changed, 75 insertions(+), 127 deletions(-)
 delete mode 100644 board/bf537-stamp/nand.c
 create mode 100644 drivers/mtd/nand/nand_plat.c
board/bf537-stamp/Makefile +0 -1
index 1dbf406..6da04e3 100644
@@ -32,7 +32,6 @@ LIB	= $(obj)lib$(BOARD).a
 COBJS-y	:= $(BOARD).o cmd_bf537led.o
 COBJS-$(CONFIG_BFIN_IDE)   += ide-cf.o
 COBJS-$(CONFIG_CMD_EEPROM) += spi_flash.o
-COBJS-$(CONFIG_CMD_NAND)   += nand.o
 COBJS-$(CONFIG_POST)       += post.o post-memory.o
 
 SRCS	:= $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
board/bf537-stamp/nand.c deleted +0 -100

100 lines not on this page · raw message

drivers/mtd/nand/Makefile +1 -0
index 471cd6b..3f87b4d 100644
@@ -44,6 +44,7 @@ COBJS-$(CONFIG_NAND_NOMADIK) += nomadik.o
 COBJS-$(CONFIG_NAND_S3C2410) += s3c2410_nand.c
 COBJS-$(CONFIG_NAND_S3C64XX) += s3c64xx.o
 COBJS-$(CONFIG_NAND_OMAP_GPMC) += omap_gpmc.o
+COBJS-$(CONFIG_NAND_PLAT) += nand_plat.o
 endif
 
 COBJS	:= $(COBJS-y)
drivers/mtd/nand/nand_plat.c new file +53 -0

53 lines not on this page · raw message

include/configs/bf537-stamp.h +18 -26

54 lines not on this page · raw message

include/configs/bfin_adi_common.h +3 -0
index bfe5376..ac0298d 100644
@@ -38,6 +38,9 @@
 #  define CONFIG_CMD_USB_STORAGE
 #  define CONFIG_DOS_PARTITION
 # endif
+# ifdef CONFIG_NAND_PLAT
+#  define CONFIG_CMD_NAND
+# endif
 # ifdef CONFIG_POST
 #  define CONFIG_CMD_DIAG
 # endif
Signature · 1 line
1.6.2.5
#8 lore raw

PATCH v2 1/1 mtd: nand: new base driver for memory mapped nand devices

Quoted 2 lines · Mike Frysinger

+ * NAND_PLAT_WRITE_CMD(cmd, chip)
+ * NAND_PLAT_WRITE_ADR(cmd, chip)

It seems counterintuitive to have "cmd" before "this" -- it's backwards from both cmd_ctrl and the blackfin command that you turn it into (yes, it's like writeb() -- but I always found that to be weird too).

Quoted 1 line

+/* #define CONFIG_NAND_PLAT */

Why is this commented out?

Quoted 1 line

+#define NAND_PLAT_DEV_READY(chip) ((*pPORTFIO & BFIN_NAND_READY) ? 1 : 0)

Why not just (*pPORTFIO & BFIN_NAND_READY)?

-Scott

#9 lore raw

PATCH v2 1/1 mtd: nand: new base driver for memory mapped nand devices

Quoted 7 lines · On Wednesday 06 May 2009 13:35:29 Scott Wood wrote:
Quoted 2 lines · Mike Frysinger

+ * NAND_PLAT_WRITE_CMD(cmd, chip)
+ * NAND_PLAT_WRITE_ADR(cmd, chip)

It seems counterintuitive to have "cmd" before "this" -- it's backwards from both cmd_ctrl and the blackfin command that you turn it into (yes, it's like writeb() -- but I always found that to be weird too).

np

Quoted 3 lines
Quoted 1 line

+/* #define CONFIG_NAND_PLAT */

Why is this commented out?

because it's a driver for an optional add-on card that people usually dont have, let alone plugged in

Quoted 4 lines
Quoted 2 lines

+#define NAND_PLAT_DEV_READY(chip) ((*pPORTFIO & BFIN_NAND_READY) ?
1 : 0)

Why not just (*pPORTFIO & BFIN_NAND_READY)?

i thought the nand/mtd layers expect 1/0 only ? if the higher layers dont care, then there's no reason.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090506/5352b9e1/attachment.pgp

#10 lore raw

PATCH v2 1/1 mtd: nand: new base driver for memory mapped nand devices

Quoted 5 lines · Mike Frysinger
Quoted 2 lines
Quoted 1 line

+/* #define CONFIG_NAND_PLAT */

Why is this commented out?

because it's a driver for an optional add-on card that people usually dont have, let alone plugged in

OK, was hoping there would be at least one config that selects it so it gets compilation exposure.

Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

+#define NAND_PLAT_DEV_READY(chip) ((*pPORTFIO & BFIN_NAND_READY) ?
1 : 0)

Why not just (*pPORTFIO & BFIN_NAND_READY)?

i thought the nand/mtd layers expect 1/0 only ? if the higher layers dont care, then there's no reason.

A quick grep doesn't show any non-boolean uses.

-Scott

#11 lore raw

PATCH v2 1/1 mtd: nand: new base driver for memory mapped nand devices

Quoted 10 lines · On Wednesday 06 May 2009 14:19:07 Scott Wood wrote:
Quoted 6 lines · Mike Frysinger
Quoted 3 lines
Quoted 1 line

+/* #define CONFIG_NAND_PLAT */

Why is this commented out?

because it's a driver for an optional add-on card that people usually dont have, let alone plugged in

OK, was hoping there would be at least one config that selects it so it gets compilation exposure.

i have another board that does rely on it that i'll be merging in the next cycle

Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

+#define NAND_PLAT_DEV_READY(chip) ((*pPORTFIO & BFIN_NAND_READY)
? 1 : 0)

Why not just (*pPORTFIO & BFIN_NAND_READY)?

i thought the nand/mtd layers expect 1/0 only ? if the higher layers dont care, then there's no reason.

A quick grep doesn't show any non-boolean uses.

sounds good, i'll make the change then
-mike

#12 lore raw

PATCH v3 1/1 mtd: nand: new base driver for memory mapped nand devices

In reply to Scott Wood

The BF537-STAMP Blackfin board had a driver for working with NAND devices that are simply memory mapped. Since there is nothing Blackfin specific about this, generalize the driver a bit so that everyone can leverage it.

---
v3
- re-order args to NAND_PLAT_WRITE_*
- dont bother normalizing NAND_PLAT_DEV_READY

 board/bf537-stamp/Makefile        |    1 -
 board/bf537-stamp/nand.c          |  100 -------------------------------------
 drivers/mtd/nand/Makefile         |    1 +
 drivers/mtd/nand/nand_plat.c      |   53 +++++++++++++++++++
 include/configs/bf537-stamp.h     |   44 +++++++----------
 include/configs/bfin_adi_common.h |    3 +
 6 files changed, 75 insertions(+), 127 deletions(-)
 delete mode 100644 board/bf537-stamp/nand.c
 create mode 100644 drivers/mtd/nand/nand_plat.c
board/bf537-stamp/Makefile +0 -1
index 1dbf406..6da04e3 100644
@@ -32,7 +32,6 @@ LIB	= $(obj)lib$(BOARD).a
 COBJS-y	:= $(BOARD).o cmd_bf537led.o
 COBJS-$(CONFIG_BFIN_IDE)   += ide-cf.o
 COBJS-$(CONFIG_CMD_EEPROM) += spi_flash.o
-COBJS-$(CONFIG_CMD_NAND)   += nand.o
 COBJS-$(CONFIG_POST)       += post.o post-memory.o
 
 SRCS	:= $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
board/bf537-stamp/nand.c deleted +0 -100

100 lines not on this page · raw message

drivers/mtd/nand/Makefile +1 -0
index 471cd6b..3f87b4d 100644
@@ -44,6 +44,7 @@ COBJS-$(CONFIG_NAND_NOMADIK) += nomadik.o
 COBJS-$(CONFIG_NAND_S3C2410) += s3c2410_nand.c
 COBJS-$(CONFIG_NAND_S3C64XX) += s3c64xx.o
 COBJS-$(CONFIG_NAND_OMAP_GPMC) += omap_gpmc.o
+COBJS-$(CONFIG_NAND_PLAT) += nand_plat.o
 endif
 
 COBJS	:= $(COBJS-y)
drivers/mtd/nand/nand_plat.c new file +53 -0

53 lines not on this page · raw message

include/configs/bf537-stamp.h +18 -26

54 lines not on this page · raw message

include/configs/bfin_adi_common.h +3 -0
index bfe5376..ac0298d 100644
@@ -38,6 +38,9 @@
 #  define CONFIG_CMD_USB_STORAGE
 #  define CONFIG_DOS_PARTITION
 # endif
+# ifdef CONFIG_NAND_PLAT
+#  define CONFIG_CMD_NAND
+# endif
 # ifdef CONFIG_POST
 #  define CONFIG_CMD_DIAG
 # endif
Signature · 1 line
1.6.2.5
#13 lore raw

PATCH v3 1/1 mtd: nand: new base driver for memory mapped nand devices

Quoted 6 lines · Mike Frysinger

The BF537-STAMP Blackfin board had a driver for working with NAND devices that are simply memory mapped. Since there is nothing Blackfin specific about this, generalize the driver a bit so that everyone can leverage it.

Applied to u-boot-nand-flash/next.

-Scott

#14 lore raw

PATCH v3 1/1 mtd: nand: new base driver for memory mapped nand devices

Quoted 9 lines · On Wednesday 06 May 2009 15:49:12 Scott Wood wrote:
Quoted 6 lines · Mike Frysinger

The BF537-STAMP Blackfin board had a driver for working with NAND devices that are simply memory mapped. Since there is nothing Blackfin specific about this, generalize the driver a bit so that everyone can leverage it.

Applied to u-boot-nand-flash/next.

thanks !
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090506/0abc71ae/attachment.pgp

#15 lore raw

PATCH v3 1/1 mtd: nand: new base driver for memory mapped nand devices

In reply to Mike Frysinger

Dear Mike Frysinger,

Quoted 10 lines · In message <[email protected]> you wrote:

The BF537-STAMP Blackfin board had a driver for working with NAND devices that are simply memory mapped. Since there is nothing Blackfin specific about this, generalize the driver a bit so that everyone can leverage it.

---
v3
- re-order args to NAND_PLAT_WRITE_*
- dont bother normalizing NAND_PLAT_DEV_READY

Please see my comments for v2; they still apply.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The philosophy exam was a piece of cake  -  which  was  a  bit  of  a
surprise, actually, because I was expecting some questions on a sheet
of paper.
#16 lore raw

PATCH v2 1/1 mtd: nand: new base driver for memory mapped nand devices

In reply to Mike Frysinger

Dear Mike Frysinger,

Quoted 5 lines · In message <[email protected]> you wrote:

The BF537-STAMP Blackfin board had a driver for working with NAND devices that are simply memory mapped. Since there is nothing Blackfin specific about this, generalize the driver a bit so that everyone can leverage it.

...

drivers/mtd/nand/nand_plat.c line 2

Quoted 8 lines
drivers/mtd/nand/nand_plat.c new file +2 -0
new file mode 100644
index 0000000..9a0e4c0
@@ -0,0 +1,53 @@
+/*
+ * Genericish driver for memory mapped NAND devices

Genericish ?

...

drivers/mtd/nand/nand_plat.c line 11

Quoted 9 lines
drivers/mtd/nand/nand_plat.c new file +9 -0
+#define NAND_PLAT_WRITE_CMD(cmd, chip) BFIN_NAND_WRITE(BFIN_NAND_CLE(chip), cmd)
+#define NAND_PLAT_WRITE_ADR(cmd, chip) BFIN_NAND_WRITE(BFIN_NAND_ALE(chip), cmd)
+#define NAND_PLAT_DEV_READY(chip)      ((*pPORTFIO & BFIN_NAND_READY) ? 1 : 0)
+#define NAND_PLAT_INIT() \
+	do { \
+		*pPORTF_FER &= ~BFIN_NAND_READY; \
+		*pPORTFIO_DIR &= ~BFIN_NAND_READY; \
+		*pPORTFIO_INEN |= BFIN_NAND_READY; \
+	} while (0)

Please use I/O accessors instead of pointers.

Best regards,

Wolfgang Denk

Signature · 7 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
All repairs tend to destroy the structure, to  increase  the  entropy
and  disorder  of the system. Less and less effort is spent on fixing
original design flaws; more and more is spent on fixing flaws  intro-
duced by earlier fixes.       - Fred Brooks, "The Mythical Man Month"
#17 lore raw

PATCH v2 1/1 mtd: nand: new base driver for memory mapped nand devices

Quoted 8 lines · On Wednesday 06 May 2009 16:51:18 Wolfgang Denk wrote:

drivers/mtd/nand/nand_plat.c line 2

Quoted 5 lines · In Mike Frysinger
drivers/mtd/nand/nand_plat.c new file +2 -0
@@ -0,0 +1,53 @@
+/*
+ * Genericish driver for memory mapped NAND devices

Genericish ?

i tried to make it generic. i dont know if i accomplished that :).

Quoted 4 lines
Quoted 4 lines
drivers/mtd/nand/nand_plat.c new file +1 -0
+#define NAND_PLAT_WRITE_CMD(cmd, chip)

BFIN_NAND_WRITE(BFIN_NAND_CLE(chip), cmd) +#define NAND_PLAT_WRITE_ADR(cmd, chip) BFIN_NAND_WRITE(BFIN_NAND_ALE(chip), cmd)
+#define NAND_PLAT_DEV_READY(chip) ((*pPORTFIO & BFIN_NAND_READY) ?

Quoted 8 lines

drivers/mtd/nand/nand_plat.c

Quoted 6 lines

1 : 0) +#define NAND_PLAT_INIT() \

drivers/mtd/nand/nand_plat.c new file +5 -0
+	do { \
+		*pPORTF_FER &= ~BFIN_NAND_READY; \
+		*pPORTFIO_DIR &= ~BFIN_NAND_READY; \
+		*pPORTFIO_INEN |= BFIN_NAND_READY; \
+	} while (0)

Please use I/O accessors instead of pointers.

OK
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090506/af9bcacd/attachment.pgp

#18 lore raw

PATCH v4 1/1 mtd: nand: new base driver for memory mapped nand devices

In reply to Wolfgang Denk

The BF537-STAMP Blackfin board had a driver for working with NAND devices that are simply memory mapped. Since there is nothing Blackfin specific about this, generalize the driver a bit so that everyone can leverage it.

---
v4
- use I/O accessors

 board/bf537-stamp/Makefile        |    1 -
 board/bf537-stamp/nand.c          |  100 -------------------------------------
 drivers/mtd/nand/Makefile         |    1 +
 drivers/mtd/nand/nand_plat.c      |   53 +++++++++++++++++++
 include/configs/bf537-stamp.h     |   44 +++++++----------
 include/configs/bfin_adi_common.h |    3 +
 6 files changed, 75 insertions(+), 127 deletions(-)
 delete mode 100644 board/bf537-stamp/nand.c
 create mode 100644 drivers/mtd/nand/nand_plat.c
board/bf537-stamp/Makefile +0 -1
index 1dbf406..6da04e3 100644
@@ -32,7 +32,6 @@ LIB	= $(obj)lib$(BOARD).a
 COBJS-y	:= $(BOARD).o cmd_bf537led.o
 COBJS-$(CONFIG_BFIN_IDE)   += ide-cf.o
 COBJS-$(CONFIG_CMD_EEPROM) += spi_flash.o
-COBJS-$(CONFIG_CMD_NAND)   += nand.o
 COBJS-$(CONFIG_POST)       += post.o post-memory.o
 
 SRCS	:= $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
board/bf537-stamp/nand.c deleted +0 -100

100 lines not on this page · raw message

drivers/mtd/nand/Makefile +1 -0
index 471cd6b..3f87b4d 100644
@@ -44,6 +44,7 @@ COBJS-$(CONFIG_NAND_NOMADIK) += nomadik.o
 COBJS-$(CONFIG_NAND_S3C2410) += s3c2410_nand.c
 COBJS-$(CONFIG_NAND_S3C64XX) += s3c64xx.o
 COBJS-$(CONFIG_NAND_OMAP_GPMC) += omap_gpmc.o
+COBJS-$(CONFIG_NAND_PLAT) += nand_plat.o
 endif
 
 COBJS	:= $(COBJS-y)
drivers/mtd/nand/nand_plat.c new file +53 -0

53 lines not on this page · raw message

include/configs/bf537-stamp.h +18 -26

54 lines not on this page · raw message

include/configs/bfin_adi_common.h +3 -0
index bfe5376..ac0298d 100644
@@ -38,6 +38,9 @@
 #  define CONFIG_CMD_USB_STORAGE
 #  define CONFIG_DOS_PARTITION
 # endif
+# ifdef CONFIG_NAND_PLAT
+#  define CONFIG_CMD_NAND
+# endif
 # ifdef CONFIG_POST
 #  define CONFIG_CMD_DIAG
 # endif
Signature · 1 line
1.6.2.5
#19 lore raw

PATCH v4 1/1 mtd: nand: new base driver for memory mapped nand devices

Quoted 9 lines · Mike Frysinger

The BF537-STAMP Blackfin board had a driver for working with NAND devices that are simply memory mapped. Since there is nothing Blackfin specific about this, generalize the driver a bit so that everyone can leverage it.

---
v4
- use I/O accessors

[snip]

Quoted 1 line

+#define NAND_PLAT_DEV_READY(chip) (*pPORTFIO & BFIN_NAND_READY)

This is still using direct pointer access.

-Scott

#20 lore raw

PATCH v5 1/1 mtd: nand: new base driver for memory mapped nand devices

The BF537-STAMP Blackfin board had a driver for working with NAND devices that are simply memory mapped. Since there is nothing Blackfin specific about this, generalize the driver a bit so that everyone can leverage it.

---
v5
- fix one more I/O usage

 board/bf537-stamp/Makefile        |    1 -
 board/bf537-stamp/nand.c          |  100 -------------------------------------
 drivers/mtd/nand/Makefile         |    1 +
 drivers/mtd/nand/nand_plat.c      |   53 +++++++++++++++++++
 include/configs/bf537-stamp.h     |   44 +++++++----------
 include/configs/bfin_adi_common.h |    3 +
 6 files changed, 75 insertions(+), 127 deletions(-)
 delete mode 100644 board/bf537-stamp/nand.c
 create mode 100644 drivers/mtd/nand/nand_plat.c
board/bf537-stamp/Makefile +0 -1
index 1dbf406..6da04e3 100644
@@ -32,7 +32,6 @@ LIB	= $(obj)lib$(BOARD).a
 COBJS-y	:= $(BOARD).o cmd_bf537led.o
 COBJS-$(CONFIG_BFIN_IDE)   += ide-cf.o
 COBJS-$(CONFIG_CMD_EEPROM) += spi_flash.o
-COBJS-$(CONFIG_CMD_NAND)   += nand.o
 COBJS-$(CONFIG_POST)       += post.o post-memory.o
 
 SRCS	:= $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
board/bf537-stamp/nand.c deleted +0 -100

100 lines not on this page · raw message

drivers/mtd/nand/Makefile +1 -0
index 471cd6b..3f87b4d 100644
@@ -44,6 +44,7 @@ COBJS-$(CONFIG_NAND_NOMADIK) += nomadik.o
 COBJS-$(CONFIG_NAND_S3C2410) += s3c2410_nand.c
 COBJS-$(CONFIG_NAND_S3C64XX) += s3c64xx.o
 COBJS-$(CONFIG_NAND_OMAP_GPMC) += omap_gpmc.o
+COBJS-$(CONFIG_NAND_PLAT) += nand_plat.o
 endif
 
 COBJS	:= $(COBJS-y)
drivers/mtd/nand/nand_plat.c new file +53 -0

53 lines not on this page · raw message

include/configs/bf537-stamp.h +18 -26

54 lines not on this page · raw message

include/configs/bfin_adi_common.h +3 -0
index bfe5376..ac0298d 100644
@@ -38,6 +38,9 @@
 #  define CONFIG_CMD_USB_STORAGE
 #  define CONFIG_DOS_PARTITION
 # endif
+# ifdef CONFIG_NAND_PLAT
+#  define CONFIG_CMD_NAND
+# endif
 # ifdef CONFIG_POST
 #  define CONFIG_CMD_DIAG
 # endif
Signature · 1 line
1.6.3
#21 lore raw

PATCH v5 1/1 mtd: nand: new base driver for memory mapped nand devices

Quoted 6 lines · Mike Frysinger

The BF537-STAMP Blackfin board had a driver for working with NAND devices that are simply memory mapped. Since there is nothing Blackfin specific about this, generalize the driver a bit so that everyone can leverage it.

Applied to u-boot-nand-flash/next

-Scott

#22 lore raw

PATCH v6 1/1 mtd: nand: new base driver for memory mapped nand devices

In reply to Mike Frysinger

The BF537-STAMP Blackfin board had a driver for working with NAND devices that are simply memory mapped. Since there is nothing Blackfin specific about this, generalize the driver a bit so that everyone can leverage it.

---
v6
- add "plat_" prefixes to avoid cpp error due to stubbed functions having the same name as the members of the nand_chip struct

 board/bf537-stamp/Makefile        |    1 -
 board/bf537-stamp/nand.c          |  100 -------------------------------------
 drivers/mtd/nand/Makefile         |    1 +
 drivers/mtd/nand/nand_plat.c      |   53 +++++++++++++++++++
 include/configs/bf537-stamp.h     |   44 +++++++----------
 include/configs/bfin_adi_common.h |    3 +
 6 files changed, 75 insertions(+), 127 deletions(-)
 delete mode 100644 board/bf537-stamp/nand.c
 create mode 100644 drivers/mtd/nand/nand_plat.c
board/bf537-stamp/Makefile +0 -1
index 1dbf406..6da04e3 100644
@@ -32,7 +32,6 @@ LIB	= $(obj)lib$(BOARD).a
 COBJS-y	:= $(BOARD).o cmd_bf537led.o
 COBJS-$(CONFIG_BFIN_IDE)   += ide-cf.o
 COBJS-$(CONFIG_CMD_EEPROM) += spi_flash.o
-COBJS-$(CONFIG_CMD_NAND)   += nand.o
 COBJS-$(CONFIG_POST)       += post.o post-memory.o
 
 SRCS	:= $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
board/bf537-stamp/nand.c deleted +0 -100

100 lines not on this page · raw message

drivers/mtd/nand/Makefile +1 -0
index 471cd6b..3f87b4d 100644
@@ -44,6 +44,7 @@ COBJS-$(CONFIG_NAND_NOMADIK) += nomadik.o
 COBJS-$(CONFIG_NAND_S3C2410) += s3c2410_nand.c
 COBJS-$(CONFIG_NAND_S3C64XX) += s3c64xx.o
 COBJS-$(CONFIG_NAND_OMAP_GPMC) += omap_gpmc.o
+COBJS-$(CONFIG_NAND_PLAT) += nand_plat.o
 endif
 
 COBJS	:= $(COBJS-y)
drivers/mtd/nand/nand_plat.c new file +53 -0

53 lines not on this page · raw message

include/configs/bf537-stamp.h +18 -26

54 lines not on this page · raw message

include/configs/bfin_adi_common.h +3 -0
index bfe5376..ac0298d 100644
@@ -38,6 +38,9 @@
 #  define CONFIG_CMD_USB_STORAGE
 #  define CONFIG_DOS_PARTITION
 # endif
+# ifdef CONFIG_NAND_PLAT
+#  define CONFIG_CMD_NAND
+# endif
 # ifdef CONFIG_POST
 #  define CONFIG_CMD_DIAG
 # endif
Signature · 1 line
1.6.3.1
#23 lore raw

PATCH v6 1/1 mtd: nand: new base driver for memory mapped nand devices

Quoted 10 lines · Mike Frysinger

The BF537-STAMP Blackfin board had a driver for working with NAND devices that are simply memory mapped. Since there is nothing Blackfin specific about this, generalize the driver a bit so that everyone can leverage it.

---
v6
- add "plat_" prefixes to avoid cpp error due to stubbed functions having the same name as the members of the nand_chip struct

Applied to u-boot-nand-flash/next.

-Scott