Skip to contentSkip to conversation

NAND Flash support for Intel IXP4xx platform

PATH Ruslan V. Sushko 5 participants 11 messages Apr 28, 2007 – May 2, 2007

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

The patch adds glue logic to support MTD for NAND flash devices on Intel IXP4xx platform

Signed-off-by [email protected]

--------

drivers/mtd/nand/Kconfig +7 -0
Index: linux-2.6/drivers/mtd/nand/Kconfig
===================================================================
@@ -143,6 +143,13 @@ config MTD_NAND_S3C2410_CLKSTOP
         when the is NAND chip selected or released, but will save
         approximately 5mA of power when there is nothing happening.
 
+config MTD_NAND_IXP4XX
+       tristate "Support for NAND Flash on Intel IXP4XX based systems"
+       depends on MTD_NAND && ARCH_IXP4XX
+       help
+         This enable the use of NAND flash on Intel IXP400 based platforms.
+         Currently this is only supported on KIXRP435 platform.
+

config MTD_NAND_DISKONCHIP
tristate "DiskOnChip 2000, Millennium and Millennium Plus (NAND
reimplementation) (EXPERIMENTAL)"

       depends on MTD_NAND && EXPERIMENTAL
drivers/mtd/nand/Makefile +0 -0
Index: linux-2.6/drivers/mtd/nand/Makefile
===================================================================
@@ -25,6 +25,7 @@ obj-$(CONFIG_MTD_NAND_CS553X)         += cs553x
obj-$(CONFIG_MTD_NAND_NDFC)            += ndfc.o
obj-$(CONFIG_MTD_NAND_AT91)            += at91_nand.o
obj-$(CONFIG_MTD_NAND_BASLER_EXCITE)   += excite_nandflash.o

+obj-$(CONFIG_MTD_NAND_IXP4XX) += ixp4xx_nand.o

nand-objs := nand_base.o nand_bbt.o
cafe_nand-objs := cafe.o cafe_ecc.o

drivers/mtd/nand/ixp4xx_nand.c new file +217 -0

217 lines not on this page · raw message

#3 lore raw
In reply to Ruslan V. Sushko

drivers/mtd/nand/ixp4xx_nand.c line 54

Quoted 9 lines · Ruslan V. Sushko

+static void ixp_write_buf(struct mtd_info *mtd, const u_char * buf, int len)

drivers/mtd/nand/ixp4xx_nand.c new file +7 -0
+{
+       int i;
+       struct nand_chip *this = mtd->priv;
+
+       for (i = 0; i < len; i++)
+               writeb(buf[i], this->IO_ADDR_W);
+}

How excatly is this functionally different from the generic write_buf function in nand_base.c ?

static void nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)

{
        int i;
        struct nand_chip *chip = mtd->priv;

        for (i = 0; i < len; i++)
                writeb(buf[i], chip->IO_ADDR_W);
}

drivers/mtd/nand/ixp4xx_nand.c line 59

Quoted 5 lines

+static void ixp4xx_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)

drivers/mtd/nand/ixp4xx_nand.c new file +3 -0
+{
+       struct nand_chip *this = mtd->priv;
+       struct ixp4xx_faddr_info_t *addr_info = this->priv;

Newline between variables and code !

Quoted 4 lines
drivers/mtd/nand/ixp4xx_nand.c new file +3 -0
+       if (ctrl & NAND_CTRL_CHANGE) {
+               addr_info->offset = (ctrl & NAND_CLE) ? IXP4XX_NAND_CLE : 0;
+               addr_info->offset |= (ctrl & NAND_ALE) ? IXP4XX_NAND_ALE 

: 0;

Your patch is word wrapped !

drivers/mtd/nand/ixp4xx_nand.c line 69

Quoted 7 lines
drivers/mtd/nand/ixp4xx_nand.c new file +7 -0
+               if (addr_info->chip_select)
+                       addr_info->chip_select(ctrl);
+       }
+
+       if (cmd != NAND_CMD_NONE)
+               writeb(cmd, this->IO_ADDR_W + addr_info->offset);
+}

Aside of that I agree with Lennert, that we really need to get around and make this real platform code.

tglx

#2 lore raw
In reply to David Woodhouse

David,
I'm really sorry. I don't know but thunderbird change all tabs to spaces. I'm already prepare new patch in accordance with Tomas Gleixner suggestion, which I've already tested as you suggest in E-Mail etiquette. Should I send the patch in this thread?

Sorry for inconvenient.
Ruslan

Quoted 11 lines · David Woodhouse
Quoted 3 lines · Ruslan V. Sushko

The patch adds glue logic to support MTD for NAND flash devices on Intel IXP4xx platform

http://david.woodhou.se/email.html#test-patches

Why did you send me something you hadn't tested for yourself?

#4 lore raw
In reply to Thomas Gleixner

Thomas,
please see my comments below

Quoted 16 lines · Thomas Gleixner

drivers/mtd/nand/ixp4xx_nand.c line 54

Quoted 10 lines · Ruslan V. Sushko

+static void ixp_write_buf(struct mtd_info *mtd, const u_char * buf, int len)

drivers/mtd/nand/ixp4xx_nand.c new file +7 -0
+{
+       int i;
+       struct nand_chip *this = mtd->priv;
+
+       for (i = 0; i < len; i++)
+               writeb(buf[i], this->IO_ADDR_W);
+}

How excatly is this functionally different from the generic write_buf function in nand_base.c ?

Quoted 10 lines

static void nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)

{
        int i;
        struct nand_chip *chip = mtd->priv;

        for (i = 0; i < len; i++)
                writeb(buf[i], chip->IO_ADDR_W);
}

This function should be removed. It was different for originally. ALE and CLE signal assertion was herre, but I decide this functionality is not necessary for data writing, so I've remove that, but forget to check remainder with generic code.

Quoted 9 lines

drivers/mtd/nand/ixp4xx_nand.c line 59

Quoted 6 lines

+static void ixp4xx_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)

drivers/mtd/nand/ixp4xx_nand.c new file +3 -0
+{
+       struct nand_chip *this = mtd->priv;
+       struct ixp4xx_faddr_info_t *addr_info = this->priv;

Newline between variables and code !

will fixed.

Quoted 9 lines
Quoted 6 lines
drivers/mtd/nand/ixp4xx_nand.c new file +3 -0
+       if (ctrl & NAND_CTRL_CHANGE) {
+               addr_info->offset = (ctrl & NAND_CLE) ? IXP4XX_NAND_CLE : 0;
+               addr_info->offset |= (ctrl & NAND_ALE) ? IXP4XX_NAND_ALE 

: 0;

Your patch is word wrapped !

will fixed

Quoted 13 lines

drivers/mtd/nand/ixp4xx_nand.c line 69

Quoted 9 lines
drivers/mtd/nand/ixp4xx_nand.c new file +7 -0
+               if (addr_info->chip_select)
+                       addr_info->chip_select(ctrl);
+       }
+
+       if (cmd != NAND_CMD_NONE)
+               writeb(cmd, this->IO_ADDR_W + addr_info->offset);
+}

Aside of that I agree with Lennert, that we really need to get around and make this real platform code.

Sorry don't understand
Do you propose to move all these (especially hw_ctrl function) functionality to platform/arch code?

Best regards,
Ruslan

Quoted 4 lines

tglx

#5 lore raw

Ruslan,

Quoted 7 lines · Ruslan V. Sushko
Quoted 3 lines

How excatly is this functionally different from the generic write_buf function in nand_base.c ?

This function should be removed. It was different for originally. ALE and CLE signal assertion was herre, but I decide this functionality is not necessary for data writing, so I've remove that, but forget to check remainder with generic code.

I did a review and pointed this out. No need for lengthy explanaitions. Just remove it.

Quoted 6 lines
Quoted 3 lines

Aside of that I agree with Lennert, that we really need to get around and make this real platform code.

Sorry don't understand
Do you propose to move all these (especially hw_ctrl function) functionality to platform/arch code?

That's what Lennert said. And I agree. Many of the drivers just differ in the hardware control function and the pyhsical address where the device is located.

We have already platform support for NAND:

See include/linux/mtd/nand.h:

struct platform_nand_chip / struct platform_nand_ctrl

As far as I can tell, there is everything covered what you need for a generic platform driver.

Again. Lennert is right and another post of your driver does not change anything unless you listen to his and my advise.

tglx

#6 lore raw

Thomas,

I have tried to fit driver's functionality into common platform structures. Unfortunately the device hasn't NAND controller and some signals (ALE/CLE(pins on data bus) and CS(gpio)) are driven in custom way. Current platform structures have not enough fields to carry platform dependent data for this driver without hack (I guess use fields not used in driver but designed for other things is not good idea). Additionally due to device haven't NAND controller future version of board may change the way which is used to drive CS signal, So I move this functionality completely to hardware dependent part of driver (sent to LAKML)

Thank you,
Ruslan

Quoted 43 lines · Thomas Gleixner

Ruslan,

Quoted 6 lines · Ruslan V. Sushko
Quoted 4 lines

How excatly is this functionally different from the generic write_buf function in nand_base.c ?

This function should be removed. It was different for originally. ALE and CLE signal assertion was herre, but I decide this functionality is not necessary for data writing, so I've remove that, but forget to check remainder with generic code.

I did a review and pointed this out. No need for lengthy explanaitions. Just remove it.

Quoted 7 lines
Quoted 4 lines

Aside of that I agree with Lennert, that we really need to get around and make this real platform code.

Sorry don't understand
Do you propose to move all these (especially hw_ctrl function) functionality to platform/arch code?

That's what Lennert said. And I agree. Many of the drivers just differ in the hardware control function and the pyhsical address where the device is located.

We have already platform support for NAND:

See include/linux/mtd/nand.h:

struct platform_nand_chip / struct platform_nand_ctrl

As far as I can tell, there is everything covered what you need for a generic platform driver.

Again. Lennert is right and another post of your driver does not change anything unless you listen to his and my advise.

tglx

#7 lore raw

Ruslan,

Can you please read, understand and comply with
http://www.infradead.org/~dwmw2/email.html

Quoted 10 lines · Ruslan V. Sushko

Thomas,

I have tried to fit driver's functionality into common platform structures. Unfortunately the device hasn't NAND controller and some signals (ALE/CLE(pins on data bus) and CS(gpio)) are driven in custom way. Current platform structures have not enough fields to carry platform dependent data for this driver without hack (I guess use fields not used in driver but designed for other things is not good idea). Additionally due to device haven't NAND controller future version of board may change the way which is used to drive CS signal,

I really do not understand what you are talking about. There is no need for extra fields and no need for hacks at all.

A generic platform driver, which can be used for any board with a similar simple interface structure as yours, is just a basic interface to the nand driver and provides common code like initialization, .....

The platform dependent code (in arch/whatever) has the hardware dependent functions, which are given via the platform mechanism to the generic platform driver:

struct platform_nand_ctrl {
        void            (*hwcontrol)(struct mtd_info *mtd, int cmd);
        int             (*dev_ready)(struct mtd_info *mtd);
        void            (*select_chip)(struct mtd_info *mtd, int chip);
        void            *priv;
};

It does not matter whether your board has a special NAND controller or not. A GPIO based interface fits into this as well, simply because it is the hardware interface, which controls the NAND flash.

Quoted 3 lines

So I move
this functionality completely to hardware dependent part of driver (sent to LAKML)

Sigh. You need a platform driver in drivers/mtd/nand first to move anything related to nand into your arch code.

tglx

#8 lore raw
Quoted 6 lines · Thomas Gleixner
Quoted 3 lines

So I move
this functionality completely to hardware dependent part of driver (sent to LAKML)

Sigh. You need a platform driver in drivers/mtd/nand first to move anything related to nand into your arch code.

Ruslan, may I suggest that you post both parts of the driver (ie platform-specific part and hardware-independent part) just as you see those to this list? It's gonna be a lot easier to discuss things then,

Thanks,
Vitaly

#9 lore raw
In reply to Ruslan V. Sushko

On Apr 30 2007, at 11:36, Ruslan V. Sushko was caught saying:

Quoted 12 lines

Thomas,

I have tried to fit driver's functionality into common platform structures. Unfortunately the device hasn't NAND controller and some signals (ALE/CLE(pins on data bus) and CS(gpio)) are driven in custom way. Current platform structures have not enough fields to carry platform dependent data for this driver without hack (I guess use fields not used in driver but designed for other things is not good idea). Additionally due to device haven't NAND controller future version of board may change the way which is used to drive CS signal, So I move this functionality completely to hardware dependent part of driver (sent to LAKML)

Can't that extra functionality be stuffed into a structure that you point to via the priv member of platform_nand_chip?

~Deepak

Signature · 4 lines
Deepak Saxena - [email protected] - http://www.plexity.net

In the end, they will not say, "those were dark times,"  they will ask
"why were their poets silent?" - Bertolt Brecht
#10 lore raw
Quoted 2 lines · Deepak Saxena

Can't that extra functionality be stuffed into a structure that you point to via the priv member of platform_nand_chip?

Please see my recent posts/patches -- everything fits well in the updated model, so either Ruslan finishes my work on generic NAND driver or he'll have to wait till I clean up things.

Vitaly