nand: lpc32xx: add SLC NAND driver
PATCH 1/3 nand: lpc32xx: add SLC NAND driver
From: Sylvain Lemieux <[email protected]>
Incorporate NAND SLC drivers from legacy LPCLinux NXP BSP. The files taken from the legacy patch are:
- lpc32xx SLC NAND driver
- lpc3250 header file SLC NAND registers definition.
Updated the driver to integrate with the latest u-boot:
1) Fixed checkpatch script output in legacy code.
A single warning remaining.
2) Use LPC32xx definition from "cpu.h" and "clk.h".
3) Incorporate NAND specific register definition from "lpc3250.h" header file from legacy BSP patch from LPCLinux.
4) Use u-boot API for register access to remove the use of volatile in register definition taken from "lpc3250.h" header file.
5) Add support to configure BBT options.
6) Add support to configure ECC strength.
7) Add slc nand clock control register bits (clk.h).
8) Add functions to initialize the SLC NAND clock.
The following warning from the legacy code is still present:
lpc32xx_nand.c:195: WARNING: Use of volatile is usually wrong: see Documentation/volatile-considered-harmful.txt
The legacy BSP patch (u-boot-2009.03_lpc32x0-v1.07.patch.tar.bz2) was downloaded from the LPCLinux Web site.
--- arch/arm/cpu/arm926ejs/lpc32xx/devices.c | 6 + arch/arm/include/asm/arch-lpc32xx/clk.h | 2 + arch/arm/include/asm/arch-lpc32xx/sys_proto.h | 1 + drivers/mtd/nand/Makefile | 1 + drivers/mtd/nand/lpc32xx_nand_slc.c | 501 ++++++++++++++++++++++++++ 5 files changed, 511 insertions(+) create mode 100644 drivers/mtd/nand/lpc32xx_nand_slc.c
arch/arm/cpu/arm926ejs/lpc32xx/devices.c +6 -0
@@ -59,6 +59,12 @@ void lpc32xx_mlc_nand_init(void)writel (CLK_NAND_MLC |CLK_NAND_MLC_INT , &clk->flashclk_ctrl); } +void lpc32xx_slc_nand_init (void ) +{ +/* Enable SLC NAND interface */ +writel (CLK_NAND_SLC |CLK_NAND_SLC_SELECT , &clk->flashclk_ctrl); +} +void lpc32xx_i2c_init (unsigned int devnum) {/* Enable I2C interface */
arch/arm/include/asm/arch-lpc32xx/clk.h +2 -0
@@ -153,7 +153,9 @@ struct clk_pm_regs {#define CLK_DMA_ENABLE (1 << 0)/* NAND Clock Control Register bits */ +#define CLK_NAND_SLC (1 << 0)#define CLK_NAND_MLC (1 << 1) +#define CLK_NAND_SLC_SELECT (1 << 2)#define CLK_NAND_MLC_INT (1 << 5)/* SSP Clock Control Register bits */
arch/arm/include/asm/arch-lpc32xx/sys_proto.h +1 -0
@@ -12,6 +12,7 @@void lpc32xx_uart_init (unsigned int uart_id);void lpc32xx_mac_init (void );void lpc32xx_mlc_nand_init (void ); +void lpc32xx_slc_nand_init (void );void lpc32xx_i2c_init (unsigned int devnum);void lpc32xx_ssp_init (void );#if defined(CONFIG_SPL_BUILD )
drivers/mtd/nand/Makefile +1 -0
@@ -53,6 +53,7 @@ obj-$(CONFIG_NAND_KB9202) += kb9202_nand.o obj-$(CONFIG_NAND_KIRKWOOD) += kirkwood_nand.o obj-$(CONFIG_NAND_KMETER1) += kmeter1_nand.o obj-$(CONFIG_NAND_LPC32XX_MLC) += lpc32xx_nand_mlc.o +obj-$(CONFIG_NAND_LPC32XX_SLC) += lpc32xx_nand_slc.o obj-$(CONFIG_NAND_MPC5121_NFC) += mpc5121_nfc.o obj-$(CONFIG_NAND_VF610_NFC) += vf610_nfc.o obj-$(CONFIG_NAND_MXC) += mxc_nand.o
drivers/mtd/nand/lpc32xx_nand_slc.c new file +501 -0
501 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 1/3 nand: lpc32xx: add SLC NAND driver
Hello Sylvain,
Quoted 6 lines · slemieux.tyco at gmail.com
1) Fixed checkpatch script output in legacy code.
A single warning remaining.The following warning from the legacy code is still present:
lpc32xx_nand.c:195: WARNING: Use of volatile is usually wrong: seeDocumentation/volatile-considered-harmful.txt
drivers/mtd/nand/lpc32xx_nand_slc.c line 198
Quoted 8 lines
drivers/mtd/nand/lpc32xx_nand_slc.c new file +8
-0+static u_char lpc32xx_read_byte (struct mtd_info *mtd) +{ +struct nand_chip *this = mtd->priv; +unsigned long *preg = (unsigned long *)this->IO_ADDR_R; +volatile unsigned long tmp32; + tmp32 = *preg; +return (u_char )tmp32; +}
The volatile above has no reason to exist; the warning is justified here as we have accessors that guarantee that the access will not be optimized away or reordered, juste like the 'volatile' above tries to do (and yes, these accessors *use* 'volatile'. All the more a reason not to use it again here).
Besides, the code is quite verbose and not precise enough. Yes, 'unsigned long' is 32-bit-ish, but in U-Boot, when something is 32-bit, that is explicit.
All in all, the whole function could be expressed as:
static u_char lpc32xx_read_byte(struct mtd_info *mtd)
{
struct nand_chip *this = mtd->priv;
return (u_char)readl(this->IO_ADDR_R);
}BTW, isn't IO_ADDR_R pointing to the data register, and isn't the data register 16-bits? And if so, then why the 32-bits read?
Also, I did not find where the IO_ADDR_R field is assigned. Did I miss it?
This is just one case, but I suspect in many places, the code is unnecessarily complex. I understand it was ported, not written from scratch, but I think porting code should not prevent us from making it smaller, more efficient and more maintainable.
Amicalement,
Signature · 1 line
Albert.
LEMIEUX
PATCH 1/3 nand: lpc32xx: add SLC NAND driver
Hi Albert,
Thanks for the feedback.
Quoted 42 lines
From: U-Boot [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Albert ARIBAUD
Sent: 17-Jul-15 5:20 PMHello Sylvain,
Quoted 6 lines · slemieux.tyco at gmail.com
1) Fixed checkpatch script output in legacy code.
A single warning remaining.The following warning from the legacy code is still present:
lpc32xx_nand.c:195: WARNING: Use of volatile is usually wrong: seeDocumentation/volatile-considered-harmful.txtdrivers/mtd/nand/lpc32xx_nand_slc.c line 198
Quoted 8 lines
drivers/mtd/nand/lpc32xx_nand_slc.c new file +8
-0+static u_char lpc32xx_read_byte (struct mtd_info *mtd) +{ +struct nand_chip *this = mtd->priv; +unsigned long *preg = (unsigned long *)this->IO_ADDR_R; +volatile unsigned long tmp32; + tmp32 = *preg; +return (u_char )tmp32; +}The volatile above has no reason to exist; the warning is justified here as we have accessors that guarantee that the access will not be optimized away or reordered, juste like the 'volatile' above tries to do (and yes, these accessors *use* 'volatile'. All the more a reason not to use it again here).
Besides, the code is quite verbose and not precise enough. Yes, 'unsigned long' is 32-bit-ish, but in U-Boot, when something is 32-bit, that is explicit.
All in all, the whole function could be expressed as:
static u_char lpc32xx_read_byte(struct mtd_info *mtd) { struct nand_chip *this = mtd->priv; return (u_char)readl(this->IO_ADDR_R); }
Quoted 3 lines
BTW, isn't
IO_ADDR_Rpointing to the data register, and isn't the data register 16-bits? And if so, then why the 32-bits read?
The register is 16 bits; this implementation is the porting of the initial code. I will wait for feedback and see how we want to approach this
(add DMA and HW ECC to the NAND SLC driver sent by Vladimir or update the driver as part of the porting effort).
Quoted 2 lines
Also, I did not find where the
IO_ADDR_Rfield is assigned. Did I miss it?
"CONFIG_SYS_NAND_SELF_INIT" is not define; the legacy BSP driver is using the default initialization done within "nand_init_chip()" function inside "drivers/mtd/nand/nand.c".
Quoted 10 lines
This is just one case, but I suspect in many places, the code is unnecessarily complex. I understand it was ported, not written from scratch, but I think porting code should not prevent us from making it smaller, more efficient and more maintainable.
Amicalement,
--
Albert.
Sylvain
________________________________
This e-mail contains privileged and confidential information intended for the use of the addressees named above. If you are not the intended recipient of this e-mail, you are hereby notified that you must not disseminate, copy or take any action in respect of any information contained in it. If you have received this e-mail in error, please notify the sender immediately by e-mail and immediately destroy this e-mail and its attachments.
PATCH 1/3 nand: lpc32xx: add SLC NAND driver
Quoted 52 lines · SYLVAIN
Hi Albert,
Thanks for the feedback.
Quoted 44 lines
From: U-Boot [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Albert ARIBAUD
Sent: 17-Jul-15 5:20 PMHello Sylvain,
Quoted 7 lines · slemieux.tyco at gmail.com
1) Fixed checkpatch script output in legacy code.
A single warning remaining.The following warning from the legacy code is still present:
lpc32xx_nand.c:195: WARNING: Use of volatile is usually wrong: seeDocumentation/volatile-considered-harmful.txtdrivers/mtd/nand/lpc32xx_nand_slc.c line 198
Quoted 8 lines
drivers/mtd/nand/lpc32xx_nand_slc.c new file +8
-0+static u_char lpc32xx_read_byte (struct mtd_info *mtd) +{ +struct nand_chip *this = mtd->priv; +unsigned long *preg = (unsigned long *)this->IO_ADDR_R; +volatile unsigned long tmp32; + tmp32 = *preg; +return (u_char )tmp32; +}The volatile above has no reason to exist; the warning is justified here as we have accessors that guarantee that the access will not be optimized away or reordered, juste like the 'volatile' above tries to do (and yes, these accessors *use* 'volatile'. All the more a reason not to use it again here).
Besides, the code is quite verbose and not precise enough. Yes, 'unsigned long' is 32-bit-ish, but in U-Boot, when something is 32-bit, that is explicit.
All in all, the whole function could be expressed as:
static u_char lpc32xx_read_byte(struct mtd_info *mtd) { struct nand_chip *this = mtd->priv; return (u_char)readl(this->IO_ADDR_R); }Quoted 3 lines
BTW, isn't
IO_ADDR_Rpointing to the data register, and isn't the data register 16-bits? And if so, then why the 32-bits read?
Quoted 5 lines
The register is 16 bits; this implementation is the porting of the initial code.
I will wait for feedback and see how we want to approach this (add DMA and HW ECC to the NAND SLC driver sent by Vladimir or update the driver as part of the porting effort).
If the register is 16-bit, then you should use readw(), not readl().
Why are there two different versions of this driver being submitted in parallel?
-Scott
Vladimir Zapolskiy
maintainerPATCH 1/3 nand: lpc32xx: add SLC NAND driver
In reply to LEMIEUXHi Sylvain, Albert,
Quoted 43 lines · SYLVAIN
Hi Albert,
Thanks for the feedback.
Quoted 39 lines
From: U-Boot [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Albert ARIBAUD
Sent: 17-Jul-15 5:20 PMHello Sylvain,
Quoted 6 lines · slemieux.tyco at gmail.com
1) Fixed checkpatch script output in legacy code.
A single warning remaining.The following warning from the legacy code is still present:
lpc32xx_nand.c:195: WARNING: Use of volatile is usually wrong: seeDocumentation/volatile-considered-harmful.txtdrivers/mtd/nand/lpc32xx_nand_slc.c line 198
Quoted 8 lines
drivers/mtd/nand/lpc32xx_nand_slc.c new file +8
-0+static u_char lpc32xx_read_byte (struct mtd_info *mtd) +{ +struct nand_chip *this = mtd->priv; +unsigned long *preg = (unsigned long *)this->IO_ADDR_R; +volatile unsigned long tmp32; + tmp32 = *preg; +return (u_char )tmp32; +}The volatile above has no reason to exist; the warning is justified here as we have accessors that guarantee that the access will not be optimized away or reordered, juste like the 'volatile' above tries to do (and yes, these accessors *use* 'volatile'. All the more a reason not to use it again here).
Besides, the code is quite verbose and not precise enough. Yes, 'unsigned long' is 32-bit-ish, but in U-Boot, when something is 32-bit, that is explicit.
All in all, the whole function could be expressed as:
static u_char lpc32xx_read_byte(struct mtd_info *mtd) { struct nand_chip *this = mtd->priv;
Quoted 8 lines
Quoted 6 lines
return (u_char)readl(this->IO_ADDR_R); }BTW, isn't
IO_ADDR_Rpointing to the data register, and isn't the data register 16-bits? And if so, then why the 32-bits read?The register is 16 bits; this implementation is the porting of the initial code.
hmm, you remember it was discussed yesterday that the data register is 32-bit...
----8<----
5.2 Data FIFO
There is only one Data FIFO. The Data FIFO is configured either in Read or in Write mode.
1. When the Data FIFO is configured in Read mode, the sequencer reads data from the NAND flash, and stores the data in the Data FIFO. The FIFO is then emptied by 32-bit reads on the AHB bus from either the ARM or the DMA.
2. When the Data FIFO is configured in Write mode, the ARM or the DMA writes data to the FIFO with 32-bit AHB bus writes. The sequencer then takes data out of the FIFO 8 bits@a time, and writes data to the NAND flash.
----8<----
Quoted 3 lines
I will wait for feedback and see how we want to approach this (add DMA and HW ECC to the NAND SLC driver sent by Vladimir or update the driver as part of the porting effort).
now when I see the code I still haven't changed my opinion, I would propose to add HW ECC processing on top of my trivial change.
Some general reasons:
* I agree with Albert that the code is a bit overcomplicated and can be improved, basic functions like read_byte(), cmd_ctrl() etc are better in my version IMHO --- for example just compare Kevin's monstrous lpc32xx_nand_hwcontrol() and my lpc32xx_nand_cmd_ctrl() --- so if my version is reviewed and accepted, then there is no need to fix all the same issues in this legacy forward-ported code,
* this change strictly depends on DMA driver (the driver simply does not work, if DMA is disabled), this means that DMA driver must be 1/3 and SLC NAND should go as 2/3, this implies that DMA driver is reviewed and accepted by maintainers firstly,
* I don't see any users of this new code, this addresses Albert's notice about adding dead code ---
http://lists.denx.de/pipermail/u-boot/2015-July/219124.html
* What about functional support in SPL? Is it correct, that if I want to have this code in SPL, then I have to pull in DMA driver as a mandatory dependency to tiny SPL?
Quoted 19 lines
Quoted 2 lines
Also, I did not find where the
IO_ADDR_Rfield is assigned. Did I miss it?"
CONFIG_SYS_NAND_SELF_INIT" is not define; the legacy BSP driver is using the default initialization done within "nand_init_chip()" function inside "drivers/mtd/nand/nand.c".Quoted 10 lines
This is just one case, but I suspect in many places, the code is unnecessarily complex. I understand it was ported, not written from scratch, but I think porting code should not prevent us from making it smaller, more efficient and more maintainable.
Amicalement,
--
Albert.Sylvain
LEMIEUX
PATCH 1/3 nand: lpc32xx: add SLC NAND driver
Hi Vladimir,
Quoted 95 lines
From: Vladimir Zapolskiy [mailto:vz at mleia.com]
Sent: 17-Jul-15 7:10 PMHi Sylvain, Albert,
Quoted 43 lines · SYLVAIN
Hi Albert,
Thanks for the feedback.
Quoted 39 lines
From: U-Boot [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Albert ARIBAUD
Sent: 17-Jul-15 5:20 PMHello Sylvain,
Quoted 6 lines · slemieux.tyco at gmail.com
1) Fixed checkpatch script output in legacy code.
A single warning remaining.The following warning from the legacy code is still present:
lpc32xx_nand.c:195: WARNING: Use of volatile is usually wrong: seeDocumentation/volatile-considered-harmful.txtdrivers/mtd/nand/lpc32xx_nand_slc.c line 198
Quoted 8 lines
drivers/mtd/nand/lpc32xx_nand_slc.c new file +8
-0+static u_char lpc32xx_read_byte (struct mtd_info *mtd) +{ +struct nand_chip *this = mtd->priv; +unsigned long *preg = (unsigned long *)this->IO_ADDR_R; +volatile unsigned long tmp32; + tmp32 = *preg; +return (u_char )tmp32; +}The volatile above has no reason to exist; the warning is justified here as we have accessors that guarantee that the access will not be optimized away or reordered, juste like the 'volatile' above tries to do (and yes, these accessors *use* 'volatile'. All the more a reason not to use it again here).
Besides, the code is quite verbose and not precise enough. Yes, 'unsigned long' is 32-bit-ish, but in U-Boot, when something is 32-bit, that is explicit.
All in all, the whole function could be expressed as:
static u_char lpc32xx_read_byte(struct mtd_info *mtd) { struct nand_chip *this = mtd->priv;Quoted 8 lines
Quoted 6 lines
return (u_char)readl(this->IO_ADDR_R); }BTW, isn't
IO_ADDR_Rpointing to the data register, and isn't the data register 16-bits? And if so, then why the 32-bits read?The register is 16 bits; this implementation is the porting of the initial code.
hmm, you remember it was discussed yesterday that the data register is 32-bit...
----8<----
5.2 Data FIFOThere is only one Data FIFO. The Data FIFO is configured either in Read or in Write mode.
1. When the Data FIFO is configured in Read mode, the sequencer reads data from the NAND flash, and stores the data in the Data FIFO. The FIFO is then emptied by 32-bit reads on the AHB bus from either the ARM or the DMA.
2. When the Data FIFO is configured in Write mode, the ARM or the DMA writes data to the FIFO with 32-bit AHB bus writes. The sequencer then takes data out of the FIFO 8 bits at a time, and writes data to the NAND flash.
----8<----
Quoted 3 lines
I will wait for feedback and see how we want to approach this (add DMA and HW ECC to the NAND SLC driver sent by Vladimir or update the driver as part of the porting effort).
now when I see the code I still haven't changed my opinion, I would propose to add HW ECC processing on top of my trivial change.
Some general reasons:
* I agree with Albert that the code is a bit overcomplicated and can be improved, basic functions like
read_byte(),cmd_ctrl()etc are better in my version IMHO --- for example just compare Kevin's monstrouslpc32xx_nand_hwcontrol()and mylpc32xx_nand_cmd_ctrl()--- so if my version is reviewed and accepted, then there is no need to fix all the same issues in this legacy forward-ported code,
Quoted 5 lines
* this change strictly depends on DMA driver (the driver simply does not work, if DMA is disabled), this means that DMA driver must be 1/3 and SLC NAND should go as 2/3, this implies that DMA driver is reviewed and accepted by maintainers firstly,
DMA can be the first patch of the series.
No problem, I can try to add the support for hardware ECC and DMA inside your driver. However, I will not be able to this until the following week.
Quoted 4 lines
* I don't see any users of this new code, this addresses Albert's notice about adding dead code ---
http://lists.denx.de/pipermail/u-boot/2015-July/219124.html
We did the porting of the legacy NXP BSP driver internally, as we are using it on a custom LPC32xx board running u-boot.
As LPC32xx driver became available in u-boot (thanks to Albert and Vladimir), we start using them (I2C, Ethernet, GPIO). After migrating to those drivers, we did the porting of the remaining legacy drivers to the latest u-boot version.
The intent of those patches was to bring the remaining legacy drivers, not wet available in u-boot.
Quoted 4 lines
* What about functional support in SPL? Is it correct, that if I want to have this code in SPL, then I have to pull in DMA driver as a mandatory dependency to tiny SPL?
We are not using the SPL;
may be the SLC NAND driver can use the DMA only for non-SPL build.
Quoted 12 lines
Quoted 12 lines
Quoted 2 lines
Also, I did not find where the
IO_ADDR_Rfield is assigned. Did I miss it?"
CONFIG_SYS_NAND_SELF_INIT" is not define; the legacy BSP driver is using the default initialization done within "nand_init_chip()" function inside "drivers/mtd/nand/nand.c".Quoted 6 lines
This is just one case, but I suspect in many places, the code is unnecessarily complex. I understand it was ported, not written from scratch, but I think porting code should not prevent us from making it smaller, more efficient and more maintainable.
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Amicalement,
--
Albert.Sylvain
________________________________
This e-mail contains privileged and confidential information intended for the use of the addressees named above. If you are not the intended recipient of this e-mail, you are hereby notified that you must not disseminate, copy or take any action in respect of any information contained in it. If you have received this e-mail in error, please notify the sender immediately by e-mail and immediately destroy this e-mail and its attachments.
PATCH 1/3 nand: lpc32xx: add SLC NAND driver
In reply to Vladimir ZapolskiyHello Vladimir,
Quoted 69 lines · Vladimir Zapolskiy
Hi Sylvain, Albert,
Quoted 43 lines · SYLVAIN
Hi Albert,
Thanks for the feedback.
Quoted 39 lines
From: U-Boot [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Albert ARIBAUD
Sent: 17-Jul-15 5:20 PMHello Sylvain,
Quoted 6 lines · slemieux.tyco at gmail.com
1) Fixed checkpatch script output in legacy code.
A single warning remaining.The following warning from the legacy code is still present:
lpc32xx_nand.c:195: WARNING: Use of volatile is usually wrong: seeDocumentation/volatile-considered-harmful.txtdrivers/mtd/nand/lpc32xx_nand_slc.c line 198
Quoted 8 lines
drivers/mtd/nand/lpc32xx_nand_slc.c new file +8
-0+static u_char lpc32xx_read_byte (struct mtd_info *mtd) +{ +struct nand_chip *this = mtd->priv; +unsigned long *preg = (unsigned long *)this->IO_ADDR_R; +volatile unsigned long tmp32; + tmp32 = *preg; +return (u_char )tmp32; +}The volatile above has no reason to exist; the warning is justified here as we have accessors that guarantee that the access will not be optimized away or reordered, juste like the 'volatile' above tries to do (and yes, these accessors *use* 'volatile'. All the more a reason not to use it again here).
Besides, the code is quite verbose and not precise enough. Yes, 'unsigned long' is 32-bit-ish, but in U-Boot, when something is 32-bit, that is explicit.
All in all, the whole function could be expressed as:
static u_char lpc32xx_read_byte(struct mtd_info *mtd) { struct nand_chip *this = mtd->priv;Quoted 8 lines
Quoted 6 lines
return (u_char)readl(this->IO_ADDR_R); }BTW, isn't
IO_ADDR_Rpointing to the data register, and isn't the data register 16-bits? And if so, then why the 32-bits read?The register is 16 bits; this implementation is the porting of the initial code.
hmm, you remember it was discussed yesterday that the data register is 32-bit...
----8<----
5.2 Data FIFOThere is only one Data FIFO. The Data FIFO is configured either in Read or in Write mode.
1. When the Data FIFO is configured in Read mode, the sequencer reads data from the NAND flash, and stores the data in the Data FIFO. The FIFO is then emptied by 32-bit reads on the AHB bus from either the ARM or the DMA.
Quoted 6 lines
2. When the Data FIFO is configured in Write mode, the ARM or the DMA writes data to the FIFO with 32-bit AHB bus writes. The sequencer then takes data out of the FIFO 8 bits at a time, and writes data to the NAND flash.
----8<----
This is about the width of the data FIFO bus transfers, not about the width of the DATA register.
The width of the data register is defined in UM10326 rev. 1 chapter 9, section 6.1, page 192/193.
While, for other registers only bits 0..7 are specified, for SLC_DATA, described as "a 16-bit wide register", bits 0..15 are specified, with bits 8..15 being described as "Reserved, user software should not write ones to reserved bits. The value read from a reserved bit is not defined".
This makes me interpret the 'word' in the statement "SLC_DATA must be accessed as a word register, although only 8 bits of data are used during a write or provided during a read" as being a 16-, not 32-bit quantity.
Quoted 7 lines
Quoted 3 lines
I will wait for feedback and see how we want to approach this (add DMA and HW ECC to the NAND SLC driver sent by Vladimir or update the driver as part of the porting effort).
now when I see the code I still haven't changed my opinion, I would propose to add HW ECC processing on top of my trivial change.
Quoted 8 lines
Some general reasons:
* I agree with Albert that the code is a bit overcomplicated and can be improved, basic functions like
read_byte(),cmd_ctrl()etc are better in my version IMHO --- for example just compare Kevin's monstrouslpc32xx_nand_hwcontrol()and mylpc32xx_nand_cmd_ctrl()--- so if my version is reviewed and accepted, then there is no need to fix all the same issues in this legacy forward-ported code,
Ok, so there is a slight misunderstanding: when I said which version should be submitted was to be discussed between you and Sylvain, I meant that you come out with a single proposal.
Quoted 4 lines
* this change strictly depends on DMA driver (the driver simply does not work, if DMA is disabled), this means that DMA driver must be 1/3 and SLC NAND should go as 2/3, this implies that DMA driver is reviewed and accepted by maintainers firstly,
That's what patch series are for. Just submit the series and it should be accepted as a whole and in order, or rejected as a whole (unless some patch in it is really independent, in which case it can be applied independently (and any subsequent version of the series will have one less patch).
Quoted 3 lines
* I don't see any users of this new code, this addresses Albert's notice about adding dead code ---
http://lists.denx.de/pipermail/u-boot/2015-July/219124.html
Actually, my notice about dead code is not that there should already be a use for new code, it is that there must appear a use for new code in the same patch series where the new code is introduced. I don't want to see independent patches for the code and use, because the first one might get applied and the second one dropped and then we have dead code.
Quoted 3 lines
* What about functional support in SPL? Is it correct, that if I want to have this code in SPL, then I have to pull in DMA driver as a mandatory dependency to tiny SPL?
You have to ensure DMA, but whether you pull the whole BSP driver or hard-code the necessary parts into a single self-contained SLC NAND + DMA file is a design decision. That said, I would personally go for pulling the driver *and* adding preprocessing out any part of it not necessary for SPL -- not so much for size (the compiler and linker should optimize useless parts away on their own anyway) than for clarity and maintenance (readers of the driver code would know which part is needed for SPL and which is not).
Amicalement,
Signature · 1 line
Albert.
LEMIEUX
PATCH 1/3 nand: lpc32xx: add SLC NAND driver
Hi Vladimir and Albert,
See comment, questions and test results below;
Quoted 23 lines
From: Albert ARIBAUD [mailto:albert.u.boot at aribaud.net]
Sent: 18-Jul-15 1:50 AMHello Vladimir,
Quoted 16 lines · Vladimir Zapolskiy
Hi Sylvain, Albert,
Quoted 13 lines · SYLVAIN
Hi Albert,
Thanks for the feedback.
Quoted 9 lines
From: U-Boot [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Albert ARIBAUD
Sent: 17-Jul-15 5:20 PMHello Sylvain,
Quoted 1 line · slemieux.tyco at gmail.com
....
Quoted 5 lines
Quoted 4 lines
* What about functional support in SPL? Is it correct, that if I want to have this code in SPL, then I have to pull in DMA driver as a mandatory dependency to tiny SPL?
Quoted 9 lines
You have to ensure DMA, but whether you pull the whole BSP driver or hard-code the necessary parts into a single self-contained SLC NAND + DMA file is a design decision. That said, I would personally go for pulling the driver *and* adding preprocessing out any part of it not necessary for SPL -- not so much for size (the compiler and linker should optimize useless parts away on their own anyway) than for clarity and maintenance (readers of the driver code would know which part is needed for SPL and which is not).
I am in the process of putting a patch together to add the hardware ECC support on top of the SLC NAND driver patch
(https://patchwork.ozlabs.org/patch/497308/).
A have a few questions:
1) The LPC32xx SLC NAND driver is using a custom NAND ECC Layout for small page; You can refer to the Kernel driver:
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/mtd/nand/lpc32xx_slc.c?id=refs/tags/v4.1.3
Are you planning to update your driver with the change or should I submit a separate patch for it before adding the support for DMA and hardware ECC?
2) As suggested by Albert, I will add a conditional compile option to ensure the original version of the driver (no DMA) can be used for SPL.
I was planning to do it using the configuration option use to select the LPC32xx DMA driver (CONFIG_DMA_LPC32XX). Are you OK with this approach?
3) Should I separate the NAND SLC /DMA & the USB into 2 separate patch?
Test result (full command log below):
Clock configuration:
CPU clock: 266MHz / AHB bus clock: 133MHz / Peripheral clock: 13MHz
1) NAND SLC driver: https://patchwork.ozlabs.org/patch/497308/
NAND read: 51904512 bytes
read.raw: 1.444 MiB per second / read: 0.625 MiB per second
2) NAND SLC driver: https://patchwork.ozlabs.org/patch/497308/
& Legacy BSP porting (hardware ECC & DMA)
NAND read: 51904512 bytes
read.raw: 2.272 MiB per second / read: 2.139 MiB per second
------------------
Full log:
NAND SLC driver: https://patchwork.ozlabs.org/patch/497308/
==> gettime; nand read.raw 0x80000000 0xd00000 0x6000; gettime Timer val: 259607
Seconds : 259
Remainder : 607sys_hz = 1000
NAND read: 51904512 bytes read: OK
Timer val: 293885
Seconds : 293
Remainder : 885sys_hz = 1000
--> 1.444 MiB per second
==> gettime; nand read.e 0x80000000 0xd00000 0x3180000; gettime Timer val: 11304
Seconds : 11
Remainder : 304sys_hz = 1000
NAND read: device 0 offset 0xd00000, size 0x3180000
51904512 bytes read: OK
Timer val: 90495
Seconds : 90
Remainder : 495sys_hz = 1000
--> 0.625 MiB per second
NAND SLC driver: https://patchwork.ozlabs.org/patch/497308/
& Legacy BSP porting (hardware ECC & DMA)
==> gettime; nand read.raw 0x80000000 0xd00000 0x6000; gettime Timer val: 49705
Seconds : 49
Remainder : 705sys_hz = 1000
NAND read: 51904512 bytes read: OK
Timer val: 71483
Seconds : 71
Remainder : 483sys_hz = 1000
--> 2.272 MiB per second
Timer val: 280282
Seconds : 280
Remainder : 282sys_hz = 1000
NAND read: device 0 offset 0xd00000, size 0x3180000
51904512 bytes read: OK
Timer val: 303423
Seconds : 303
Remainder : 423sys_hz = 1000
--> 2.139 MiB per second
Sylvain
Quoted 3 lines
Amicalement,
--
Albert.
________________________________
This e-mail contains privileged and confidential information intended for the use of the addressees named above. If you are not the intended recipient of this e-mail, you are hereby notified that you must not disseminate, copy or take any action in respect of any information contained in it. If you have received this e-mail in error, please notify the sender immediately by e-mail and immediately destroy this e-mail and its attachments.
Vladimir Zapolskiy
maintainerPATCH 1/3 nand: lpc32xx: add SLC NAND driver
Hi Sylvain,
Quoted 49 lines · SYLVAIN
Hi Vladimir and Albert,
See comment, questions and test results below;
Quoted 23 lines
From: Albert ARIBAUD [mailto:albert.u.boot at aribaud.net]
Sent: 18-Jul-15 1:50 AMHello Vladimir,
Quoted 16 lines · Vladimir Zapolskiy
Hi Sylvain, Albert,
Quoted 13 lines · SYLVAIN
Hi Albert,
Thanks for the feedback.
Quoted 9 lines
From: U-Boot [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Albert ARIBAUD
Sent: 17-Jul-15 5:20 PMHello Sylvain,
Quoted 1 line · slemieux.tyco at gmail.com
....
Quoted 5 lines
Quoted 4 lines
* What about functional support in SPL? Is it correct, that if I want to have this code in SPL, then I have to pull in DMA driver as a mandatory dependency to tiny SPL?
Quoted 9 lines
You have to ensure DMA, but whether you pull the whole BSP driver or hard-code the necessary parts into a single self-contained SLC NAND + DMA file is a design decision. That said, I would personally go for pulling the driver *and* adding preprocessing out any part of it not necessary for SPL -- not so much for size (the compiler and linker should optimize useless parts away on their own anyway) than for clarity and maintenance (readers of the driver code would know which part is needed for SPL and which is not).
I am in the process of putting a patch together to add the hardware ECC support on top of the SLC NAND driver patch
(https://patchwork.ozlabs.org/patch/497308/).
Quoted 7 lines
A have a few questions:
1) The LPC32xx SLC NAND driver is using a custom NAND ECC Layout for small page; You can refer to the Kernel driver:
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/mtd/nand/lpc32xx_slc.c?id=refs/tags/v4.1.3Are you planning to update your driver with the change or should I submit a separate patch for it before adding the support for DMA and hardware ECC?
if you don't object to rebase your changes on top of mine (see my closing comment), I'm fine, if custom NAND ECC Layout for small page chip is added in a separate patch. For your information on my side I won't be able to test it though.
Quoted 2 lines
2) As suggested by Albert, I will add a conditional compile option to ensure the original version of the driver (no DMA) can be used for SPL.
Great, thank you.
Quoted 2 lines
I was planning to do it using the configuration option use to select the LPC32xx DMA driver (
CONFIG_DMA_LPC32XX). Are you OK with this approach?
I'm not sure, if DMA is really needed in SPL binary, but if you want to add this option, I don't object. To separate code for SPL and normal image please use CONFIG_SPL_BUILD macro.
Quoted 1 line
3) Should I separate the NAND SLC /DMA & the USB into 2 separate patch?
I would say DMA driver as a prerequisite should go first, then in arbitrary order NAND SLC updates specific to available/compiled DMA and USB changes.
Quoted 68 lines
Test result (full command log below):
Clock configuration:
CPU clock: 266MHz / AHB bus clock: 133MHz / Peripheral clock: 13MHz1) NAND SLC driver: https://patchwork.ozlabs.org/patch/497308/
NAND read: 51904512 bytes
read.raw: 1.444 MiB per second / read: 0.625 MiB per second2) NAND SLC driver: https://patchwork.ozlabs.org/patch/497308/
& Legacy BSP porting (hardware ECC & DMA)
NAND read: 51904512 bytes
read.raw: 2.272 MiB per second / read: 2.139 MiB per second------------------
Full log:NAND SLC driver: https://patchwork.ozlabs.org/patch/497308/
==> gettime; nand read.raw
0x800000000xd000000x6000; gettime Timer val: 259607
Seconds : 259
Remainder : 607sys_hz= 1000NAND read: 51904512 bytes read: OK
Timer val: 293885
Seconds : 293
Remainder : 885sys_hz= 1000
--> 1.444 MiB per second==> gettime; nand read.e
0x800000000xd000000x3180000; gettime Timer val: 11304
Seconds : 11
Remainder : 304sys_hz= 1000NAND read: device 0 offset
0xd00000, size0x3180000
51904512 bytes read: OK
Timer val: 90495
Seconds : 90
Remainder : 495sys_hz= 1000
--> 0.625 MiB per secondNAND SLC driver: https://patchwork.ozlabs.org/patch/497308/
& Legacy BSP porting (hardware ECC & DMA)==> gettime; nand read.raw
0x800000000xd000000x6000; gettime Timer val: 49705
Seconds : 49
Remainder : 705sys_hz= 1000NAND read: 51904512 bytes read: OK
Timer val: 71483
Seconds : 71
Remainder : 483sys_hz= 1000
--> 2.272 MiB per secondTimer val: 280282
Seconds : 280
Remainder : 282sys_hz= 1000
Quoted 8 lines
NAND read: device 0 offset
0xd00000, size0x3180000
51904512 bytes read: OK
Timer val: 303423
Seconds : 303
Remainder : 423sys_hz= 1000
--> 2.139 MiB per second
Thank you for tests. So, as expected if DMA and hardware ECC is enabled, then the performance is 1.5 (raw read) or 3.5 times (read & ecc) better.
I do recognize and appreciate this work, advocating my change I can repeat my last arguments:
* it has a ready valid user in U-boot, my change is not a dead code,
* it is more functional -- read from NAND in SPL is supported,
* it is extremely simple (180 LoC vs. 500 LoC + ~200 LoC of DMA driver),
* it has been reviewed by Scott, all review comments are fixed and published in v4, and it is ready for inclusion to the next release IMHO.
If there is no more review comments to my version of the driver, I would kindly ask you to rebase legacy SLC NAND driver on top of my version of the driver, it is a doable and simple task in my opinion, performance optimization with the associated code complexity may be added later on.
--
With best wishes,
Vladimir
LEMIEUX
PATCH 1/3 nand: lpc32xx: add SLC NAND driver
Hi Vladimir,
See comment below.
Quoted 60 lines
From: Vladimir Zapolskiy [mailto:vz at mleia.com]
Sent: 27-Jul-15 8:22 PMHi Sylvain,
Quoted 54 lines · SYLVAIN
Hi Vladimir and Albert,
See comment, questions and test results below;
Quoted 23 lines
From: Albert ARIBAUD [mailto:albert.u.boot at aribaud.net]
Sent: 18-Jul-15 1:50 AMHello Vladimir,
Quoted 16 lines · Vladimir Zapolskiy
Hi Sylvain, Albert,
Quoted 13 lines · SYLVAIN
Hi Albert,
Thanks for the feedback.
Quoted 9 lines
From: U-Boot [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Albert ARIBAUD
Sent: 17-Jul-15 5:20 PMHello Sylvain,
Quoted 1 line · slemieux.tyco at gmail.com
....
Quoted 5 lines
Quoted 4 lines
* What about functional support in SPL? Is it correct, that if I want to have this code in SPL, then I have to pull in DMA driver as a mandatory dependency to tiny SPL?
Quoted 9 lines
You have to ensure DMA, but whether you pull the whole BSP driver or hard-code the necessary parts into a single self-contained SLC NAND + DMA file is a design decision. That said, I would personally go for pulling the driver *and* adding preprocessing out any part of it not necessary for SPL -- not so much for size (the compiler and linker should optimize useless parts away on their own anyway) than for clarity and maintenance (readers of the driver code would know which part is needed for SPL and which is not).
I am in the process of putting a patch together to add the hardware ECC support on top of the SLC NAND driver patch
(https://patchwork.ozlabs.org/patch/497308/).A have a few questions:
1) The LPC32xx SLC NAND driver is using a custom NAND ECC Layout for small page; You can refer to the Kernel driver:
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/drivers/mtd/nand/lpc32xx_slc.c?id=refs/tags/v4.1.3
Quoted 7 lines
Quoted 2 lines
Are you planning to update your driver with the change or should I submit a separate patch for it before adding the support for DMA and hardware ECC?
if you don't object to rebase your changes on top of mine (see my closing comment), I'm fine, if custom NAND ECC Layout for small page chip is added in a separate patch. For your information on my side I won't be able to test it though.
Already done, I will update the change based on the comment bellow and submit a second version of the patch;
The test result, listed below, are with the NXP legacy BSP code on top of your patch.
I will add a patch from the small page change; the change are taken from the legacy NXP BSP and the mapping is matching the kernel driver.
Who will provide feedback on the DMA patch?
Quoted 107 lines
Quoted 3 lines
2) As suggested by Albert, I will add a conditional compile option to ensure the original version of the driver (no DMA) can be used for SPL.
Great, thank you.
Quoted 2 lines
I was planning to do it using the configuration option use to select the LPC32xx DMA driver (
CONFIG_DMA_LPC32XX). Are you OK with this approach?I'm not sure, if DMA is really needed in SPL binary, but if you want to add this option, I don't object. To separate code for SPL and normal image please use
CONFIG_SPL_BUILDmacro.Quoted 1 line
3) Should I separate the NAND SLC /DMA & the USB into 2 separate patch?
I would say DMA driver as a prerequisite should go first, then in arbitrary order NAND SLC updates specific to available/compiled DMA and USB changes.
Quoted 68 lines
Test result (full command log below):
Clock configuration:
CPU clock: 266MHz / AHB bus clock: 133MHz / Peripheral clock: 13MHz1) NAND SLC driver: https://patchwork.ozlabs.org/patch/497308/
NAND read: 51904512 bytes
read.raw: 1.444 MiB per second / read: 0.625 MiB per second2) NAND SLC driver: https://patchwork.ozlabs.org/patch/497308/
& Legacy BSP porting (hardware ECC & DMA)
NAND read: 51904512 bytes
read.raw: 2.272 MiB per second / read: 2.139 MiB per second------------------
Full log:NAND SLC driver: https://patchwork.ozlabs.org/patch/497308/
==> gettime; nand read.raw
0x800000000xd000000x6000; gettime Timer val: 259607
Seconds : 259
Remainder : 607sys_hz= 1000NAND read: 51904512 bytes read: OK
Timer val: 293885
Seconds : 293
Remainder : 885sys_hz= 1000
--> 1.444 MiB per second==> gettime; nand read.e
0x800000000xd000000x3180000; gettime Timer val: 11304
Seconds : 11
Remainder : 304sys_hz= 1000NAND read: device 0 offset
0xd00000, size0x3180000
51904512 bytes read: OK
Timer val: 90495
Seconds : 90
Remainder : 495sys_hz= 1000
--> 0.625 MiB per secondNAND SLC driver: https://patchwork.ozlabs.org/patch/497308/
& Legacy BSP porting (hardware ECC & DMA)==> gettime; nand read.raw
0x800000000xd000000x6000; gettime Timer val: 49705
Seconds : 49
Remainder : 705sys_hz= 1000NAND read: 51904512 bytes read: OK
Timer val: 71483
Seconds : 71
Remainder : 483sys_hz= 1000
--> 2.272 MiB per secondTimer val: 280282
Seconds : 280
Remainder : 282sys_hz= 1000Quoted 8 lines
NAND read: device 0 offset
0xd00000, size0x3180000
51904512 bytes read: OK
Timer val: 303423
Seconds : 303
Remainder : 423sys_hz= 1000
--> 2.139 MiB per secondThank you for tests. So, as expected if DMA and hardware ECC is enabled, then the performance is 1.5 (raw read) or 3.5 times (read & ecc) better.
I do recognize and appreciate this work, advocating my change I can repeat my last arguments:
* it has a ready valid user in U-boot, my change is not a dead code,
* it is more functional -- read from NAND in SPL is supported,
* it is extremely simple (180 LoC vs. 500 LoC + ~200 LoC of DMA driver),
* it has been reviewed by Scott, all review comments are fixed and published in v4, and it is ready for inclusion to the next release IMHO.
Quoted 8 lines
If there is no more review comments to my version of the driver, I would kindly ask you to rebase legacy SLC NAND driver on top of my version of the driver, it is a doable and simple task in my opinion, performance optimization with the associated code complexity may be added later on.
--
With best wishes,
Vladimir
________________________________
This e-mail contains privileged and confidential information intended for the use of the addressees named above. If you are not the intended recipient of this e-mail, you are hereby notified that you must not disseminate, copy or take any action in respect of any information contained in it. If you have received this e-mail in error, please notify the sender immediately by e-mail and immediately destroy this e-mail and its attachments.