nand: lpc32xx: add SLC NAND controller support
Vladimir Zapolskiy
maintainerPATCH 1/1 nand: lpc32xx: add SLC NAND controller support
The change adds support of LPC32xx SLC NAND controller.
LPC32xx SoC has two different mutually exclusive NAND controllers to communicate with single and multiple layer chips.
This simple driver allows to specify NAND chip timings and defines custom read_buf()/write_buf() operations, because access to 8-bit data register must be 32-bit aligned.
Support of hardware ECC calculation is not implemented (data correction is always done by software), since it requires a working DMA engine.
The driver can be included to an SPL image.
--- 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 | 183 ++++++++++++++++++++++++++ 5 files changed, 193 insertions(+) create mode 100644 drivers/mtd/nand/lpc32xx_nand_slc.c
arch/arm/cpu/arm926ejs/lpc32xx/devices.c +6 -0
@@ -54,6 +54,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
@@ -54,6 +54,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 +183 -0
183 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH 1/1 nand: lpc32xx: add SLC NAND controller support
Hello Vladimir,
Quoted 9 lines · Vladimir Zapolskiy
The change adds support of LPC32xx SLC NAND controller.
LPC32xx SoC has two different mutually exclusive NAND controllers to communicate with single and multiple layer chips.
This simple driver allows to specify NAND chip timings and defines custom read_buf()/write_buf() operations, because access to 8-bit data register must be 32-bit aligned.
Quoted 5 lines
Support of hardware ECC calculation is not implemented (data correction is always done by software), since it requires a working DMA engine.
The driver can be included to an SPL image.
This is needed for an upcoming new board support patch, right? If so, then I suggest you put together all patches for this new board in a single series. This will make it clear(er) you're not adding dead code here.
Quoted 2 lines
Signed-off-by Vladimir Zapolskiy <[email protected]>Cc Albert ARIBAUD <[email protected]>
Amicalement,
Signature · 1 line
Albert.
Vladimir Zapolskiy
maintainerPATCH 1/1 nand: lpc32xx: add SLC NAND controller support
Hello Albert,
Quoted 13 lines · Albert ARIBAUD
Hello Vladimir,
Quoted 9 lines · Vladimir Zapolskiy
The change adds support of LPC32xx SLC NAND controller.
LPC32xx SoC has two different mutually exclusive NAND controllers to communicate with single and multiple layer chips.
This simple driver allows to specify NAND chip timings and defines
custom read_buf()/write_buf() operations, because access to 8-bit
data register must be 32-bit aligned.
Quoted 7 lines
Quoted 5 lines
Support of hardware ECC calculation is not implemented (data correction is always done by software), since it requires a working DMA engine.
The driver can be included to an SPL image.
This is needed for an upcoming new board support patch, right?
you are correct, I plan to extend current support of devkit3250 board.
Quoted 4 lines
If so, then I suggest you put together all patches for this new board in a single series. This will make it clear(er) you're not adding dead code here.
I got the point, I will be able to complete board specific changes today tonight and send them for review.
Please let me ask you for one more advice, if I want to add peripherals support on the board (by the way thank you for your drivers) and SPL image building support, both changes touch defconfig and board config header files. Should I split these changes into separate ones or is one "board support extension" patch preferred?
--
With best wishes,
Vladimir
PATCH 1/1 nand: lpc32xx: add SLC NAND controller support
Hello Vladimir,
Quoted 26 lines · Vladimir Zapolskiy
Hello Albert,
Quoted 13 lines · Albert ARIBAUD
Hello Vladimir,
Quoted 9 lines · Vladimir Zapolskiy
The change adds support of LPC32xx SLC NAND controller.
LPC32xx SoC has two different mutually exclusive NAND controllers to communicate with single and multiple layer chips.
This simple driver allows to specify NAND chip timings and defines
custom read_buf()/write_buf() operations, because access to 8-bit
data register must be 32-bit aligned.Quoted 7 lines
Quoted 5 lines
Support of hardware ECC calculation is not implemented (data correction is always done by software), since it requires a working DMA engine.
The driver can be included to an SPL image.
This is needed for an upcoming new board support patch, right?
you are correct, I plan to extend current support of devkit3250 board.
Quoted 7 lines
Quoted 4 lines
If so, then I suggest you put together all patches for this new board in a single series. This will make it clear(er) you're not adding dead code here.
I got the point, I will be able to complete board specific changes today tonight and send them for review.
Thanks.
Quoted 5 lines
Please let me ask you for one more advice, if I want to add peripherals support on the board (by the way thank you for your drivers) and SPL image building support, both changes touch defconfig and board config header files. Should I split these changes into separate ones or is one "board support extension" patch preferred?
A commit should ideally be a single, self-contained, logical change.
So I would say each driver addition should be one commit, and the SPL support addition should be its own commit, even though each of these commits touches the defconfig and header config files.
This has at least two benefits:
- each commit is simpler to review (and to design and test, too). If a commit contains several logical changes, it is harder to sort out which change(s) a given patch chunk is about.
- in case a change was applied to U-Boot and later proves to cause an issue, then we can easily revert this change, and only this change, by reverting its commit. If the commit contains several change, then we cannot simply revert the commit, we need to manually "patch out" the problematic change while keeping the others.
Quoted 3 lines
--
With best wishes,
Vladimir
Amicalement,
Signature · 1 line
Albert.
LEMIEUX
PATCH 1/1 nand: lpc32xx: add SLC NAND controller support
Hi Vladimir and Albert,
During this merge window (once our issues with our exchange server are resolve), we were planning on submitting a few patches for the LPC32xx.
Some of the patches are the porting of the legacy NXP BSP (u-boot) drivers into the latest version; the drivers are the DMA, the SLC NAND and the USB.
This original NXP implementation of the SLC NAND was using the DMA. I am also planning on testing this patch to compare the flashing time, with and without the DMA.
I have two questions:
1) How do you suggest to approach this, as some patches may be similar or conflicting with what Vladimir is planning on submitting?
2) For submitting legacy NXP BSP driver porting patch, would you like to see a 3 patches series (original driver, checkpatch script fix and the update for latest u-boot) to have history of the change or a single patch with the final result?
Sylvain Lemieux
-----Original Message-----
From: U-Boot [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Albert ARIBAUD
Sent: 15-Jul-15 5:21 AM
To: Vladimir Zapolskiy
Cc: Scott Wood; Albert ARIBAUD; u-boot at lists.denx.de
Subject: Re: [U-Boot] [PATCH] nand: lpc32xx: add SLC NAND controller support
Hello Vladimir,
Quoted 27 lines · Vladimir Zapolskiy
Hello Albert,
Quoted 14 lines · Albert ARIBAUD
Hello Vladimir,
Quoted 9 lines · Vladimir Zapolskiy
The change adds support of LPC32xx SLC NAND controller.
LPC32xx SoC has two different mutually exclusive NAND controllers to communicate with single and multiple layer chips.
This simple driver allows to specify NAND chip timings and defines custom read_buf()/write_buf() operations, because access to 8-bit data register must be 32-bit aligned.
Quoted 7 lines
Quoted 5 lines
Support of hardware ECC calculation is not implemented (data correction is always done by software), since it requires a working DMA engine.
The driver can be included to an SPL image.
This is needed for an upcoming new board support patch, right?
you are correct, I plan to extend current support of devkit3250 board.
Quoted 7 lines
Quoted 4 lines
If so, then I suggest you put together all patches for this new board in a single series. This will make it clear(er) you're not adding dead code here.
I got the point, I will be able to complete board specific changes today tonight and send them for review.
Thanks.
Quoted 5 lines
Please let me ask you for one more advice, if I want to add peripherals support on the board (by the way thank you for your drivers) and SPL image building support, both changes touch defconfig and board config header files. Should I split these changes into separate ones or is one "board support extension" patch preferred?
A commit should ideally be a single, self-contained, logical change.
So I would say each driver addition should be one commit, and the SPL support addition should be its own commit, even though each of these commits touches the defconfig and header config files.
This has at least two benefits:
- each commit is simpler to review (and to design and test, too). If a commit contains several logical changes, it is harder to sort out which change(s) a given patch chunk is about.
- in case a change was applied to U-Boot and later proves to cause an issue, then we can easily revert this change, and only this change, by reverting its commit. If the commit contains several change, then we cannot simply revert the commit, we need to manually "patch out" the problematic change while keeping the others.
Quoted 3 lines
--
With best wishes,
Vladimir
Amicalement,
--
Albert.
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
________________________________
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/1 nand: lpc32xx: add SLC NAND controller support
Hello SYLVAIN,
Quoted 10 lines · SYLVAIN
Hi Vladimir and Albert,
During this merge window (once our issues with our exchange server are resolve), we were planning on submitting a few patches for the LPC32xx.
Some of the patches are the porting of the legacy NXP BSP (u-boot) drivers into the latest version; the drivers are the DMA, the SLC NAND and the USB.
Quoted 7 lines
This original NXP implementation of the SLC NAND was using the DMA. I am also planning on testing this patch to compare the flashing time, with and without the DMA.
I have two questions:
1) How do you suggest to approach this, as some patches may be similar or conflicting with what Vladimir is planning on submitting?
That question is for you and Vladimir to discuss.
Quoted 4 lines
2) For submitting legacy NXP BSP driver porting patch, would you like to see a 3 patches series (original driver, checkpatch script fix and the update for latest u-boot) to have history of the change or a single patch with the final result?
Single patch with the final result.
Amicalement,
Signature · 1 line
Albert.
Vladimir Zapolskiy
maintainerPATCH 1/1 nand: lpc32xx: add SLC NAND controller support
In reply to LEMIEUXHi Sylvain,
Quoted 3 lines · SYLVAIN
Hi Vladimir and Albert,
During this merge window (once our issues with our exchange server are resolve), we were planning on submitting a few patches for the LPC32xx.
great, feel free to add me to Cc.
Quoted 1 line
Some of the patches are the porting of the legacy NXP BSP (u-boot) drivers into the latest version; the drivers are the DMA, the SLC NAND and the USB.
If DMA and USB are added, I'll gratefully reuse this on my board :)
Quoted 1 line
This original NXP implementation of the SLC NAND was using the DMA. I am also planning on testing this patch to compare the flashing time, with and without the DMA.
Sounds good. Also since DMA is going to be supported it would be nice to add HW ECC calculation to the SLC NAND driver.
FYI here are performance test results of my PIO version:
=> gettime; nand read.raw 0x80000000 0x0 0x6000; gettime Timer val: 63952
Seconds : 63
Remainder : 952
sys_hz = 1000
NAND read: 51904512 bytes read: OK
Timer val: 113352
Seconds : 113
Remainder : 352
sys_hz = 1000
1.002 MiB per second, quite slow, but not drastically slow.
Quoted 2 lines
I have two questions:
1) How do you suggest to approach this, as some patches may be similar or conflicting with what Vladimir is planning on submitting?
I presume the only conflicting place is SLC NAND driver.
Here I see some benefits of my version:
* the driver is very tiny, practically it is read_buf()/write_buf() and timing configuration, all the rest I managed to offload to existing mtd/nand and spl/nand frameworks at the price of more added CONFIG_* defines in a board header file,
* not sure what OOB layout is coming from NXP BSP (I don't have this BSP to check, unfortunately), but I would prefer to see the same OOB layout in U-boot and in vanilla Linux --- this is done in my version,
* the driver can be included to SPL binary,
* the driver is well tested on my environment,
* the code has been published for review.
The only two missing things from the driver I see at the moment are based on working DMA driver:
* data transfer by means of DMA,
* HW ECC calculation (data correction is always done by software).
Also my driver has not been tested with small page NAND chips, not sure, if it is relevant for you.
If DMA works, I hope it should be easy to add some lpc32xx_chip.ecc.* callbacks to my version of the driver.
Quoted 2 lines
2) For submitting legacy NXP BSP driver porting patch, would you like to see a 3 patches series (original driver, checkpatch script fix and the update for latest u-boot) to have history of the change or a single patch with the final result?
If it were related to Linux kernel project, I know the clear answer, but please let me leave U-boot maintenance specifics to be explained by Albert.
--
With best wishes,
Vladimir
Quoted 87 lines
-----Original Message-----
From: U-Boot [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Albert ARIBAUD
Sent: 15-Jul-15 5:21 AM
To: Vladimir Zapolskiy
Cc: Scott Wood; Albert ARIBAUD; u-boot at lists.denx.de
Subject: Re: [U-Boot] [PATCH] nand: lpc32xx: add SLC NAND controller supportHello Vladimir,
Quoted 27 lines · Vladimir Zapolskiy
Hello Albert,
Quoted 14 lines · Albert ARIBAUD
Hello Vladimir,
Quoted 9 lines · Vladimir Zapolskiy
The change adds support of LPC32xx SLC NAND controller.
LPC32xx SoC has two different mutually exclusive NAND controllers to communicate with single and multiple layer chips.
This simple driver allows to specify NAND chip timings and defines custom read_buf()/write_buf() operations, because access to 8-bit data register must be 32-bit aligned.
Quoted 7 lines
Quoted 5 lines
Support of hardware ECC calculation is not implemented (data correction is always done by software), since it requires a working DMA engine.
The driver can be included to an SPL image.
This is needed for an upcoming new board support patch, right?
you are correct, I plan to extend current support of devkit3250 board.
Quoted 7 lines
Quoted 4 lines
If so, then I suggest you put together all patches for this new board in a single series. This will make it clear(er) you're not adding dead code here.
I got the point, I will be able to complete board specific changes today tonight and send them for review.
Thanks.
Quoted 5 lines
Please let me ask you for one more advice, if I want to add peripherals support on the board (by the way thank you for your drivers) and SPL image building support, both changes touch defconfig and board config header files. Should I split these changes into separate ones or is one "board support extension" patch preferred?
A commit should ideally be a single, self-contained, logical change.
So I would say each driver addition should be one commit, and the SPL support addition should be its own commit, even though each of these commits touches the defconfig and header config files.
This has at least two benefits:
- each commit is simpler to review (and to design and test, too). If a commit contains several logical changes, it is harder to sort out which change(s) a given patch chunk is about.
- in case a change was applied to U-Boot and later proves to cause an issue, then we can easily revert this change, and only this change, by reverting its commit. If the commit contains several change, then we cannot simply revert the commit, we need to manually "patch out" the problematic change while keeping the others.
Quoted 3 lines
--
With best wishes,
VladimirAmicalement,
--
Albert.
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot________________________________
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.
LEMIEUX
PATCH 1/1 nand: lpc32xx: add SLC NAND controller support
Hi Vladimir,
Thanks for taking time to read my feedback.
You can see my comments and my answer below.
Sylvain
Quoted 9 lines
-----Original Message-----
From: Vladimir Zapolskiy [mailto:vz at mleia.com]
Sent: 15-Jul-15 8:20 PM
To: LEMIEUX, SYLVAIN; Albert ARIBAUD
Cc: Scott Wood; u-boot at lists.denx.de
Subject: Re: [U-Boot] [PATCH] nand: lpc32xx: add SLC NAND controller supportHi Sylvain,
Quoted 7 lines
Quoted 3 lines · SYLVAIN
Hi Vladimir and Albert,
During this merge window (once our issues with our exchange server are
resolve), we were planning on submitting a few patches for the LPC32xx.
great, feel free to add me to Cc.
Will do;
Quoted 5 lines
Quoted 2 lines
Some of the patches are the porting of the legacy NXP BSP (u-boot) drivers
into the latest version; the drivers are the DMA, the SLC NAND and the USB.
If DMA and USB are added, I'll gratefully reuse this on my board :)
I will submit the LPC32xx patches using an alternate e-mail for now, until the problem with our e-mail infrastructure is resolve.
First, I need to do some rework (matching the naming convention of your NAND SLC patch and update our porting effort based on the feedback from Albert).
Quoted 7 lines
Quoted 2 lines
This original NXP implementation of the SLC NAND was using the DMA. I am
also planning on testing this patch to compare the flashing time, with and without the DMA.
Sounds good. Also since DMA is going to be supported it would be nice to add HW ECC calculation to the SLC NAND driver.
Hardware ECC was already supported in the legacy BSP; it will be part of the patches I will submit.
Quoted 9 lines
FYI here are performance test results of my PIO version:
=> gettime; nand read.raw
0x800000000x00x6000; gettime Timer val: 63952
Seconds : 63
Remainder : 952
sys_hz= 1000
Quoted 8 lines
NAND read: 51904512 bytes read: OK
Timer val: 113352
Seconds : 113
Remainder : 352
sys_hz= 10001.002 MiB per second, quite slow, but not drastically slow.
FYI, I did the same testing on my side using the legacy NXP BSP implementation; the test was done with the CPU clock at 208MHz and 266MHz.
For those test, we have no timing optimization for the SLC NAND.
Clock configuration:
CPU clock: 266MHz / AHB bus clock: 133MHz / Peripheral clock: 13MHz ==> gettime; nand read.raw 0x80000000 0xd00000 0x6000; gettime Timer val: 22949
Seconds : 22
Remainder : 949sys_hz = 1000
NAND read: 51904512 bytes read: OK
Timer val: 44803
Seconds : 44
Remainder : 803sys_hz = 1000
--> 2.265 MiB per second
==> gettime; nand read.e 0x80000000 0xd00000 0x3180000; gettime Timer val: 66054
Seconds : 66
Remainder : 54sys_hz = 1000
NAND read: device 0 offset 0xd00000, size 0x3180000
51904512 bytes read: OK
Timer val: 89214
Seconds : 89
Remainder : 214sys_hz = 1000
--> 2.137 MiB per second
Clock configuration:
CPU clock: 208MHz / AHB bus clock: 104MHz / Peripheral clock: 13MHz
==> gettime; nand read.raw 0x80000000 0xd00000 0x6000; gettime Timer val: 24605
Seconds : 24
Remainder : 605sys_hz = 1000
NAND read: 51904512 bytes read: OK
Timer val: 52458
Seconds : 52
Remainder : 458sys_hz = 1000
--> 1.777 MiB per second
==> gettime; nand read.e 0x80000000 0x00d00000 0x3180000; gettime Timer val: 134819
Seconds : 134
Remainder : 819sys_hz = 1000
NAND read: device 0 offset 0xd00000, size 0x3180000
51904512 bytes read: OK
Timer val: 164465
Seconds : 164
Remainder : 465sys_hz = 1000
--> 1.669 MiB per second
Quoted 6 lines
Quoted 3 lines
I have two questions:
1) How do you suggest to approach this, as some patches may be similar orconflicting with what Vladimir is planning on submitting?
I presume the only conflicting place is SLC NAND driver.
Yes, this will be the only conflicting patch.
Quoted 13 lines
Here I see some benefits of my version:
* the driver is very tiny, practically it is read_buf()/write_buf() and timing configuration, all the rest I managed to offload to existing mtd/nand and spl/nand frameworks at the price of more added CONFIG_* defines in a board header file,
* not sure what OOB layout is coming from NXP BSP (I don't have this BSP to check, unfortunately), but I would prefer to see the same OOB layout in U- boot and in vanilla Linux --- this is done in my version,
* the driver can be included to SPL binary,
* the driver is well tested on my environment,
* the code has been published for review.
This is the benefits (I am thinking we get) from the legacy NXP BSP porting:
* The driver went through multiple iteration (the latest version of the legacy patch was 1.07).
* The BSP, from LPC Linux, was most likely review and tested by multiple users; it was the initial u-boot reference for the LPC32xx development boards.
* The SLC NAND implementation is integrated with the DMA, and already support hardware ECC.
* The OOB layout from the legacy BSP is matching the LPC32xx NAND SLC Linux driver.
Quoted 8 lines
The only two missing things from the driver I see at the moment are based on working DMA driver:
* data transfer by means of DMA,
* HW ECC calculation (data correction is always done by software).Also my driver has not been tested with small page NAND chips, not sure, if it is relevant for you.
The legacy BSP driver was only tested with large page NAND on our side.
Quoted 10 lines
If DMA works, I hope it should be easy to add some lpc32xx_chip.ecc.* callbacks to my version of the driver.
Quoted 1 line
2) For submitting legacy NXP BSP driver porting patch, would you like to see
a 3 patches series (original driver, checkpatch script fix and the update for latest u-boot) to have history of the change or a single patch with the final result?
Quoted 1 line
Quoted 7 lines
If it were related to Linux kernel project, I know the clear answer, but please let me leave U-boot maintenance specifics to be explained by Albert.
--
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.