* [PATCH] [REPOST] mtd: extend plat_nand for (read|write)_buf @ 2009-05-11 18:28 Alexander Clouter 2009-05-15 13:51 ` Artem Bityutskiy 0 siblings, 1 reply; 5+ messages in thread From: Alexander Clouter @ 2009-05-11 18:28 UTC (permalink / raw) To: linux-mtd; +Cc: hsweeten This patch adds (write|read)_buf callbacks to plat_nand. The NAND on the TS-7800 provisioned by the FPGA allows readw() and readl() to be used which gives a 2.5x speed up. To be able to use this from the plat_nand driver a hook for read_buf (and also write_buf whilst we are in there) need to be made available. This patch adds the hook. This is a repost[1] of a feature asked for before[2], plus other helpful patches to plat_nand[3] would be welcomed if at all possible too. [1] http://lists.infradead.org/pipermail/linux-mtd/2009-March/024747.html [2] http://lists.infradead.org/pipermail/linux-mtd/2007-October/019659.html [3] http://lists.infradead.org/pipermail/linux-mtd/2009-March/024780.html Signed-off-by: Alexander Clouter <alex@digriz.org.uk> --- diff --git a/drivers/mtd/nand/plat_nand.c b/drivers/mtd/nand/plat_nand.c index 86e1d08..4cdec46 100644 --- a/drivers/mtd/nand/plat_nand.c +++ b/drivers/mtd/nand/plat_nand.c @@ -61,6 +61,8 @@ static int __devinit plat_nand_probe(struct platform_device *pdev) data->chip.cmd_ctrl = pdata->ctrl.cmd_ctrl; data->chip.dev_ready = pdata->ctrl.dev_ready; data->chip.select_chip = pdata->ctrl.select_chip; + data->chip.write_buf = pdata->ctrl.write_buf; + data->chip.read_buf = pdata->ctrl.read_buf; data->chip.chip_delay = pdata->chip.chip_delay; data->chip.options |= pdata->chip.options; diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 7efb9be..0e35375 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -584,6 +584,8 @@ struct platform_nand_chip { * @select_chip: platform specific chip select function * @cmd_ctrl: platform specific function for controlling * ALE/CLE/nCE. Also used to write command and address + * @write_buf: platform specific function for write buffer + * @read_buf: platform specific function for read buffer * @priv: private data to transport driver specific settings * * All fields are optional and depend on the hardware driver requirements @@ -594,6 +596,10 @@ struct platform_nand_ctrl { void (*select_chip)(struct mtd_info *mtd, int chip); void (*cmd_ctrl)(struct mtd_info *mtd, int dat, unsigned int ctrl); + void (*write_buf)(struct mtd_info *mtd, + const uint8_t *buf, int len); + void (*read_buf)(struct mtd_info *mtd, + uint8_t *buf, int len); void *priv; }; ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] [REPOST] mtd: extend plat_nand for (read|write)_buf 2009-05-11 18:28 [PATCH] [REPOST] mtd: extend plat_nand for (read|write)_buf Alexander Clouter @ 2009-05-15 13:51 ` Artem Bityutskiy 2009-05-15 15:05 ` Alexander Clouter 0 siblings, 1 reply; 5+ messages in thread From: Artem Bityutskiy @ 2009-05-15 13:51 UTC (permalink / raw) To: Alexander Clouter; +Cc: hsweeten, linux-mtd On Mon, 2009-05-11 at 19:28 +0100, Alexander Clouter wrote: > This patch adds (write|read)_buf callbacks to plat_nand. > > The NAND on the TS-7800 provisioned by the FPGA allows readw() and > readl() to be used which gives a 2.5x speed up. To be able to use this > from the plat_nand driver a hook for read_buf (and also write_buf whilst > we are in there) need to be made available. This patch adds the hook. > > This is a repost[1] of a feature asked for before[2], plus other helpful > patches to plat_nand[3] would be welcomed if at all possible too. > > [1] http://lists.infradead.org/pipermail/linux-mtd/2009-March/024747.html > [2] http://lists.infradead.org/pipermail/linux-mtd/2007-October/019659.html > [3] http://lists.infradead.org/pipermail/linux-mtd/2009-March/024780.html > > Signed-off-by: Alexander Clouter <alex@digriz.org.uk> I think this should be submitted with the user at the same time. Adding hooks without having a user is not very good. E.g., you may find out later that this does not help, or cancel your project, or end up with different call-backs, etc. You may keep this patch privately, work on your NAND driver, and when you have it ready, you submit it with this at the same time. -- Best regards, Artem Bityutskiy (Битюцкий Артём) ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] [REPOST] mtd: extend plat_nand for (read|write)_buf 2009-05-15 13:51 ` Artem Bityutskiy @ 2009-05-15 15:05 ` Alexander Clouter 2009-05-15 15:27 ` Alexander Clouter 2009-05-15 15:31 ` Artem Bityutskiy 0 siblings, 2 replies; 5+ messages in thread From: Alexander Clouter @ 2009-05-15 15:05 UTC (permalink / raw) To: Artem Bityutskiy; +Cc: linux-mtd Hi, * Artem Bityutskiy <dedekind@infradead.org> [2009-05-15 16:51:00+0300]: > > On Mon, 2009-05-11 at 19:28 +0100, Alexander Clouter wrote: > > This patch adds (write|read)_buf callbacks to plat_nand. > > > > The NAND on the TS-7800 provisioned by the FPGA allows readw() and > > readl() to be used which gives a 2.5x speed up. To be able to use this > > from the plat_nand driver a hook for read_buf (and also write_buf whilst > > we are in there) need to be made available. This patch adds the hook. > > > > This is a repost[1] of a feature asked for before[2], plus other helpful > > patches to plat_nand[3] would be welcomed if at all possible too. > > > > [1] http://lists.infradead.org/pipermail/linux-mtd/2009-March/024747.html > > [2] http://lists.infradead.org/pipermail/linux-mtd/2007-October/019659.html > > [3] http://lists.infradead.org/pipermail/linux-mtd/2009-March/024780.html > > > > Signed-off-by: Alexander Clouter <alex@digriz.org.uk> > > I think this should be submitted with the user at the same > time. Adding hooks without having a user is not very good. > E.g., you may find out later that this does not help, or > cancel your project, or end up with different call-backs, > etc. > In the case of read/write_buf...there is no other way, I'm all ears if you know how I can do (read|write)(w|l) with plat_nand *now*? I just pulled off this type of manoeuvre for a HW RNG driver: http://lkml.indiana.edu/hypermail/linux/kernel/0902.2/02727.html http://git.marvell.com/?p=orion.git;a=commit;h=8be7b57dea0467324ad4545334c5e35c18f0814b I doubt the ARM people would be happy if I push ARM patches through the MTD sub-system :) > You may keep this patch privately, work on your NAND driver, > and when you have it ready, you submit it with this at the > same time. > Erm, it's been ready for a *long* time, about a year[1], and is being used. Recently the bits of my plat_nand impementation[2] is on it's way to going mainline (Orion -> ARM -> Linus): http://git.marvell.com/?p=orion.git;a=commit;h=75bb6b9aab3255f440ef4e72a31978d1681105d6 Cheers [1] http://tech.groups.yahoo.com/group/ts-7000/message/11616 [2] http://lists.infradead.org/pipermail/linux-mtd/2009-February/024555.html -- Alexander Clouter .sigmonster says: Your fly might be open (but don't check it just now). ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] [REPOST] mtd: extend plat_nand for (read|write)_buf 2009-05-15 15:05 ` Alexander Clouter @ 2009-05-15 15:27 ` Alexander Clouter 2009-05-15 15:31 ` Artem Bityutskiy 1 sibling, 0 replies; 5+ messages in thread From: Alexander Clouter @ 2009-05-15 15:27 UTC (permalink / raw) To: Artem Bityutskiy; +Cc: linux-mtd Hi, * Alexander Clouter <alex@digriz.org.uk> [2009-05-15 16:05:49+0100]: > > * Artem Bityutskiy <dedekind@infradead.org> [2009-05-15 16:51:00+0300]: > > > > On Mon, 2009-05-11 at 19:28 +0100, Alexander Clouter wrote: > > > This patch adds (write|read)_buf callbacks to plat_nand. > > > > > > The NAND on the TS-7800 provisioned by the FPGA allows readw() and > > > readl() to be used which gives a 2.5x speed up. To be able to use this > > > from the plat_nand driver a hook for read_buf (and also write_buf whilst > > > we are in there) need to be made available. This patch adds the hook. > > > > > > This is a repost[1] of a feature asked for before[2], plus other helpful > > > patches to plat_nand[3] would be welcomed if at all possible too. > > > > > > [1] http://lists.infradead.org/pipermail/linux-mtd/2009-March/024747.html > > > [2] http://lists.infradead.org/pipermail/linux-mtd/2007-October/019659.html > > > [3] http://lists.infradead.org/pipermail/linux-mtd/2009-March/024780.html > > > > > > Signed-off-by: Alexander Clouter <alex@digriz.org.uk> > > > > I think this should be submitted with the user at the same > > time. Adding hooks without having a user is not very good. > > E.g., you may find out later that this does not help, or > > cancel your project, or end up with different call-backs, > > etc. > > > In the case of read/write_buf...there is no other way, I'm all ears if > you know how I can do (read|write)(w|l) with plat_nand *now*? > For those interested, what I'm currently doing is attached inline below, this of course goes on top of the existing plat_nand driver hooks going mainline now: http://git.marvell.com/?p=orion.git;a=commitdiff;h=75bb6b9aab3255f440ef4e72a31978d1681105d6;hp=673492a800b14a9aac5d9d1af120334b9578a23c I probably will be re-writing the platform specific functions to be more like: http://git.marvell.com/?p=orion.git;a=commitdiff;h=b7eafc31c123a0a068c475c1a8690de06de4e36a;hp=9154da39b1da931b60ff380d3172d797ccaed71e I doubt (read|write)w is worth it for the extra function complexity. Feedback welcome on this of course though; I was thinking maybe to leave it in as DMA support is just around the corner but on my particular board there are no alignment requirements for using the DMA engines. Cheers Cheers -- Alexander Clouter .sigmonster says: Yow! I want to mail a bronzed artichoke to Nicaragua! diff --git a/arch/arm/mach-orion5x/ts78xx-setup.c b/arch/arm/mach-orion5x/ts78xx-setup.c index 5041d1b..263a2db 100644 --- a/arch/arm/mach-orion5x/ts78xx-setup.c +++ b/arch/arm/mach-orion5x/ts78xx-setup.c @@ -191,6 +191,75 @@ static int ts78xx_ts_nand_dev_ready(struct mtd_info *mtd) return readb(TS_NAND_CTRL) & 0x20; } +/* + * FPGA will handle 8/16/32bit reads and writes + */ +static void ts78xx_ts_nand_read_buf(struct mtd_info *mtd, + uint8_t *buf, int len) +{ + struct nand_chip *this = mtd->priv; + + if (len % 2) { + *buf++ = readb(this->IO_ADDR_R); + len--; + } + if (len % 4 == 2) { + uint16_t *t = (uint16_t *) buf; + *t = readw(this->IO_ADDR_R); + buf += 2; + len -= 2; + } + + while (len > 3) { + uint32_t *t = (uint32_t *) buf; + *t = readl(this->IO_ADDR_R); + buf += 4; + len -= 4; + } + + if (len % 4 == 2) { + uint16_t *t = (uint16_t *) buf; + *t = readw(this->IO_ADDR_R); + buf += 2; + len -= 2; + } + if (len) + *buf = readb(this->IO_ADDR_R); +} + +static void ts78xx_ts_nand_write_buf(struct mtd_info *mtd, + const uint8_t *buf, int len) +{ + struct nand_chip *this = mtd->priv; + + if (len % 2) { + writeb(*buf++, this->IO_ADDR_W); + len--; + } + if (len % 4 == 2) { + uint16_t *t = (uint16_t *) buf; + writew(*t, this->IO_ADDR_W); + buf += 2; + len -= 2; + } + + while (len > 3) { + uint32_t *t = (uint32_t *) buf; + writel(*t, this->IO_ADDR_W); + buf += 4; + len -= 4; + } + + if (len % 4 == 2) { + uint16_t *t = (uint16_t *) buf; + writew(*t, this->IO_ADDR_W); + buf += 2; + len -= 2; + } + if (len) + writeb(*buf, this->IO_ADDR_W); +} + const char *ts_nand_part_probes[] = { "cmdlinepart", NULL }; static struct mtd_partition ts78xx_ts_nand_parts[] = { @@ -230,8 +299,10 @@ static struct platform_nand_data ts78xx_ts_nand_data = { * e6cf5df1838c28bb060ac45b5585e48e71bbc740 so now there is * no performance advantage to be had so we no longer bother */ - .cmd_ctrl = ts78xx_ts_nand_cmd_ctrl, .dev_ready = ts78xx_ts_nand_dev_ready, + .cmd_ctrl = ts78xx_ts_nand_cmd_ctrl, + .read_buf = ts78xx_ts_nand_read_buf, + .write_buf = ts78xx_ts_nand_write_buf, }, }; diff --git a/drivers/mtd/nand/plat_nand.c b/drivers/mtd/nand/plat_nand.c index 86e1d08..4cdec46 100644 --- a/drivers/mtd/nand/plat_nand.c +++ b/drivers/mtd/nand/plat_nand.c @@ -61,6 +61,8 @@ static int __devinit plat_nand_probe(struct platform_device *pdev) data->chip.cmd_ctrl = pdata->ctrl.cmd_ctrl; data->chip.dev_ready = pdata->ctrl.dev_ready; data->chip.select_chip = pdata->ctrl.select_chip; + data->chip.write_buf = pdata->ctrl.write_buf; + data->chip.read_buf = pdata->ctrl.read_buf; data->chip.chip_delay = pdata->chip.chip_delay; data->chip.options |= pdata->chip.options; diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 7efb9be..0e35375 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -584,6 +584,8 @@ struct platform_nand_chip { * @select_chip: platform specific chip select function * @cmd_ctrl: platform specific function for controlling * ALE/CLE/nCE. Also used to write command and address + * @write_buf: platform specific function for write buffer + * @read_buf: platform specific function for read buffer * @priv: private data to transport driver specific settings * * All fields are optional and depend on the hardware driver requirements @@ -594,6 +596,10 @@ struct platform_nand_ctrl { void (*select_chip)(struct mtd_info *mtd, int chip); void (*cmd_ctrl)(struct mtd_info *mtd, int dat, unsigned int ctrl); + void (*write_buf)(struct mtd_info *mtd, + const uint8_t *buf, int len); + void (*read_buf)(struct mtd_info *mtd, + uint8_t *buf, int len); void *priv; }; ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] [REPOST] mtd: extend plat_nand for (read|write)_buf 2009-05-15 15:05 ` Alexander Clouter 2009-05-15 15:27 ` Alexander Clouter @ 2009-05-15 15:31 ` Artem Bityutskiy 1 sibling, 0 replies; 5+ messages in thread From: Artem Bityutskiy @ 2009-05-15 15:31 UTC (permalink / raw) To: Alexander Clouter; +Cc: linux-mtd On Fri, 2009-05-15 at 16:05 +0100, Alexander Clouter wrote: > > You may keep this patch privately, work on your NAND driver, > > and when you have it ready, you submit it with this at the > > same time. > > > Erm, it's been ready for a *long* time, about a year[1], and is being > used. Recently the bits of my plat_nand impementation[2] is on it's way > to going mainline (Orion -> ARM -> Linus): Ok, I thought you do not use this so far. I've pushed your patch to l2-mtd-2.6.git. This does not guarantee anything, just means I'll ping David to look at it and send upstream. -- Best regards, Artem Bityutskiy (Битюцкий Артём) ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-05-15 15:32 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-05-11 18:28 [PATCH] [REPOST] mtd: extend plat_nand for (read|write)_buf Alexander Clouter 2009-05-15 13:51 ` Artem Bityutskiy 2009-05-15 15:05 ` Alexander Clouter 2009-05-15 15:27 ` Alexander Clouter 2009-05-15 15:31 ` Artem Bityutskiy
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox