Skip to contentSkip to conversation

Different nand interface

DISCUSSION Alice Hennessy 4 participants 13 messages Oct 23, 2003 – Nov 18, 2003

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

Hi,

I need some advice on how to support a board that has a hardware state machine
that creates a parallel bus style interface to the NAND chip. It is totally
different from the standard 8 IO signal controls. It can do write_byte
and read_byte
put requires the offset into the flash as a parameter. nand.c is
fairly modular, allowing
several functions to be coded in the hardware file but there is no current method of
passing an offset into, say, read_byte and write_byte unless the nand_chip priv field
can be used (via mtd->priv). Do you think the standard nand.c can be
used in this
case or should I create a specific one for this board?

Any advice would be appreciated.

Alice

#1 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 5 lines

I need some advice on how to support a board that has a hardware state machine
that creates a parallel bus style interface to the NAND chip. It is totally
different from the standard 8 IO signal controls.

I'm not certain if this is what you're looking for, but the iPAQ h1910 has NAND connected to the address pins. (Is this what you mean?) Take a look at the NAND code in handhelds.org CVS (module linux/kernel26, I think, although if h1910 flash is not an option there, try module linux/kernel) - it's just standard MTD NAND, except with some changes not to do moronic caching of IO_ADDR_R and IO_ADDR_W. (You can also look at the 1910 flash driver to see how I change IO_ADDR_R/W based on ALE and CLE.)

/j

- --

Joshua Wise | www.joshuawise.com
GPG Key     | 0xEA80E0B3
Quote       | <lilo> I akilled *@* by mistake

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/mII5Pn9tWOqA4LMRAvDuAKCLJ0Oq1P9lJpvWdZFSEkR+scf0BACgkXI4 1A7evWeG40v8DYM8dsUI9nU=
=/6q9
-----END PGP SIGNATURE-----

#2 lore raw
Quoted 7 lines · Joshua Wise

I'm not certain if this is what you're looking for, but the iPAQ h1910 has NAND connected to the address pins. (Is this what you mean?) Take a look at the NAND code in handhelds.org CVS (module linux/kernel26, I think, although if h1910 flash is not an option there, try module linux/kernel) - it's just standard MTD NAND, except with some changes not to do moronic caching of IO_ADDR_R and IO_ADDR_W. (You can also look at the 1910 flash driver to see how I change IO_ADDR_R/W based on ALE and CLE.)

Urgh. I suspect I already fixed the interface between nand.c and the board drivers so you don't need to do that... if not I'll fix it some more.

Signature · 1 line
dwmw2
#3 lore raw
In reply to Alice Hennessy
Quoted 12 lines · Alice Hennessy

Hi,

I need some advice on how to support a board that has a hardware state machine that creates a parallel bus style interface to the NAND chip.
It is totally different from the standard 8 IO signal controls. It
can do write_byte and read_byte put requires the offset into the flash
as a parameter. nand.c is fairly modular, allowing several
functions to be coded in the hardware file but there is no current method of passing an offset into, say, read_byte and write_byte unless the nand_chip priv field
can be used (via mtd->priv). Do you think the standard nand.c can be
used in this case or should I create a specific one for this board?

S'difficult to say without knowing more details of the hardware in question. What does it _do_ with the address lines in question? Are you at least looking at the current code which has read_buf() functions?

Even the DiskOnChip isn't this bizarre :)

Signature · 1 line
dwmw2
#12 lore raw
In reply to Alice Hennessy
Quoted 18 lines · Alice Hennessy

Hi,

I need some advice on how to support a board that has a hardware state machine
that creates a parallel bus style interface to the NAND chip. It is totally
different from the standard 8 IO signal controls. It can do write_byte
and read_byte
put requires the offset into the flash as a parameter. nand.c is
fairly modular, allowing
several functions to be coded in the hardware file but there is no current method of
passing an offset into, say, read_byte and write_byte unless the nand_chip priv field
can be used (via mtd->priv). Do you think the standard nand.c can be
used in this
case or should I create a specific one for this board?

Quoted 1 line

Any advice would be appreciated.

I would expect the existing nand.c can be used though you might have to do some clever stuff to hide your flash behind it.

This is definitely the prefered way to get going in the beginning because it will help comparmentalise things that inevitably go wrong when bringing up new hardware.

Once your system is up and running you might find that you want to replace nand.c for efficiency reasons or whatever, but quite likely this won't be required (and at least you'll have a way better understanding of where you need to go).

G'luck

-- CHarles

#4 lore raw
In reply to David Woodhouse
Quoted 14 lines · David Woodhouse
Quoted 12 lines · Alice Hennessy

Hi,

I need some advice on how to support a board that has a hardware state machine that creates a parallel bus style interface to the NAND chip.
It is totally different from the standard 8 IO signal controls. It
can do write_byte and read_byte put requires the offset into the flash
as a parameter. nand.c is fairly modular, allowing several
functions to be coded in the hardware file but there is no current method of passing an offset into, say, read_byte and write_byte unless the nand_chip priv field
can be used (via mtd->priv). Do you think the standard nand.c can be
used in this case or should I create a specific one for this board?

Quoted 8 lines

S'difficult to say without knowing more details of the hardware in question. What does it _do_ with the address lines in question? Are you at least looking at the current code which has read_buf() functions?

Even the DiskOnChip isn't this bizarre :)

--
dwmw2

Yes, I am looking at the current code which is more modular so it gives me hope.
There are 2 nand chips on the board. If you want to read from the 0x100th byte
on chip 1 you need to do readb(chip1_base + 0x100); if you want to write the 0x10000th byte on chip 2 you need to do writeb(chip2_base + 0x10000,bytedata).
The chips are 16M X 8 bit and are mapped in a contiguous 32 M byte memory space
with 0-16M for chip1 and 16-32M for chip2.

Alice

#5 lore raw

On Mon, 2003-10-27 at 10:25 -0800, Alice Hennessy wrote (modulo newlines):

Quoted 8 lines

Yes, I am looking at the current code which is more modular so it gives me hope.
There are 2 nand chips on the board. If you want to read from the 0x100th byte on chip 1 you need to do readb(chip1_base + 0x100); if you want to write the 0x10000th byte on chip 2 you need to do writeb(chip2_base + 0x10000,bytedata).
The chips are 16M X 8 bit and are mapped in a contiguous 32 M byte memory space with 0-16M for chip1 and 16-32M for chip2.

That's weird. How are the out-of-band areas accessed? How do you send commands like READ_ID and ERASE?

Signature · 1 line
dwmw2
#6 lore raw
Quoted 10 lines · David Woodhouse

On Mon, 2003-10-27 at 10:25 -0800, Alice Hennessy wrote (modulo newlines):

Quoted 8 lines

Yes, I am looking at the current code which is more modular so it gives me hope.
There are 2 nand chips on the board. If you want to read from the 0x100th byte on chip 1 you need to do readb(chip1_base + 0x100); if you want to write the 0x10000th byte on chip 2 you need to do writeb(chip2_base + 0x10000,bytedata).
The chips are 16M X 8 bit and are mapped in a contiguous 32 M byte memory space with 0-16M for chip1 and 16-32M for chip2.

Quoted 5 lines

That's weird. How are the out-of-band areas accessed? How do you send commands like READ_ID and ERASE?

--
dwmw2

The hardware logic uses register access for special commands. Readid,
status does
2 writes to a register, one for address (to distinquish which flash), one for command and one more
to read. Erase takes 2 writes to a register, address then command. The
out-of-band access
uses a register to give a command and then the out-of-band data is read using

readb with offset.

Alice

#7 lore raw

What is wrong with your mail user agent? It's customary to wrap lines at seventy-something characters; not to wrap them at 90 then again at 70, giving alternate 70-char and 20-char lines... :)

Quoted 12 lines · Alice Hennessy

The hardware logic uses register access for special commands. Readid,
status does
2 writes to a register, one for address (to distinquish which flash), one for
command and one more
to read. Erase takes 2 writes to a register, address then command. The
out-of-band access
uses a register to give a command and then the out-of-band data is read using

Quoted 1 line

readb with offset.

That's just bizarre. I don't think I want to ask _why_ they did this.

You may be able to massage this into the generic NAND code; you can override nand_command() completely. I suspect you won't be using much of the generic code if you do that though. You might end up just writing a standalone driver.

Signature · 1 line
dwmw2
#8 lore raw
Quoted 21 lines · David Woodhouse

What is wrong with your mail user agent? It's customary to wrap lines at seventy-something characters; not to wrap them at 90 then again at 70, giving alternate 70-char and 20-char lines... :)

Quoted 12 lines · Alice Hennessy

The hardware logic uses register access for special commands. Readid,
status does
2 writes to a register, one for address (to distinquish which flash), one for
command and one more
to read. Erase takes 2 writes to a register, address then command. The
out-of-band access
uses a register to give a command and then the out-of-band data is read using

Quoted 1 line

readb with offset.

That's just bizarre. I don't think I want to ask _why_ they did this.

Quoted 7 lines

You may be able to massage this into the generic NAND code; you can override nand_command() completely. I suspect you won't be using much of the generic code if you do that though. You might end up just writing a standalone driver.

--
dwmw2

I'll try to fix the email thing :-)

Thanks for the quick response. I'll weigh the massage effort with any future maintenance effort saved.

Alice

#9 lore raw
Quoted 2 lines · Alice Hennessy

Thanks for the quick response. I'll weigh the massage effort with any future maintenance effort saved.

Bear in mind I'm happy enough to make changes to the generic NAND interface if they're going to be useful in general.

Signature · 1 line
dwmw2
#10 lore raw
Quoted 7 lines · David Woodhouse
Quoted 2 lines · Alice Hennessy

Thanks for the quick response. I'll weigh the massage effort with any future maintenance effort saved.

Bear in mind I'm happy enough to make changes to the generic NAND interface if they're going to be useful in general.

Quoted 6 lines

--
dwmw2

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

I've attached the current driver for review, possibly as a standalone driver. As you can
see from the patch, the current placement of the driver is in the
drivers/mtd/nand
directory and it replaces the generic nand.c if configured to the customized board.
This was to make use of nand_ecc.c and nand_ids.c. Also, the supporting
files
stw_flash.h and stw_flash.c are currently under the board's directories but can be massaged to
go anywhere necessary. This board's nand flash, as I've stated in
previous emails,
has a completely different hardware interface than the standard nand flash and this makes
using the generic nand.c difficult. Any opinions on how this fits in
would be appreciated.

Alice

drivers/mtd/nand/Makefile +9 -2
diff -Nu head.orig/drivers/mtd/nand/Makefile head/drivers/mtd/nand/Makefile
@@ -3,17 +3,24 @@
 #
 # $Id: Makefile.common,v 1.1 2003/05/21 15:00:04 dwmw2 Exp $
 
+ifdef CONFIG_MTD_NAND_STW
+nand-base	:= stw_nand.o
+else
+nand-base	:= nand.o
+endif
+
 ifeq ($(PATCHLEVEL),4)
 O_TARGET			:= nandlink.o
-export-objs			:= nand.o nand_ecc.o nand_ids.o
+export-objs			:= $(nand-base) nand_ecc.o nand_ids.o
 endif
 
-obj-$(CONFIG_MTD_NAND)		+= nand.o nand_ecc.o
+obj-$(CONFIG_MTD_NAND)		+= $(nand-base) nand_ecc.o
 obj-$(CONFIG_MTD_NAND_SPIA)	+= spia.o
 obj-$(CONFIG_MTD_NAND_AUTCPU12)	+= autcpu12.o
 obj-$(CONFIG_MTD_NAND_EDB7312)  += edb7312.o
 obj-$(CONFIG_MTD_NAND_TX4925NDFMC)  += tx4925ndfmc.o
 obj-$(CONFIG_MTD_NAND_TX4938NDFMC)  += tx4938ndfmc.o
+obj-$(CONFIG_MTD_NAND_STW)	+= stw_nand_init.o
 obj-$(CONFIG_MTD_NAND_IDS)	+= nand_ids.o
 
 -include $(TOPDIR)/Rules.make
drivers/mtd/nand/stw_nand.c +1662 -0

1,662 lines not on this page · raw message

drivers/mtd/nand/stw_nand_init.c +333 -0

333 lines not on this page · raw message

include/asm-mips/ati/stw_flash.h +220 -0

220 lines not on this page · raw message

arch/mips/ati/xilleon/stw_flash.c +3423 -0

759 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

#11 lore raw
Quoted 33 lines · Alice Hennessy
Quoted 7 lines · David Woodhouse
Quoted 2 lines · Alice Hennessy

Thanks for the quick response. I'll weigh the massage effort with any future maintenance effort saved.

Bear in mind I'm happy enough to make changes to the generic NAND interface if they're going to be useful in general.

Quoted 6 lines

--
dwmw2

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

I've attached the current driver for review, possibly as a standalone driver. As you can
see from the patch, the current placement of the driver is in the
drivers/mtd/nand
directory and it replaces the generic nand.c if configured to the customized board.
This was to make use of nand_ecc.c and nand_ids.c. Also, the supporting
files
stw_flash.h and stw_flash.c are currently under the board's directories but can be massaged to
go anywhere necessary. This board's nand flash, as I've stated in
previous emails,
has a completely different hardware interface than the standard nand flash and this makes
using the generic nand.c difficult. Any opinions on how this fits in
would be appreciated.

Quoted 3 lines

Alice

------------------------------------------------------------------------

Hi,

Are there any objections or opinions on adding this driver ?

Alice