u-boot-brain/drivers
Ofer Heifetz b47f677931 mtd: nand: pxa3xx_nand: add support for partial chunks
This commit is needed to properly support the 8-bits ECC configuration
with 4KB pages.

When pages larger than 2 KB are used on platforms using the PXA3xx
NAND controller, the reading/programming operations need to be split
in chunks of 2 KBs or less because the controller FIFO is limited to
about 2 KB (i.e a bit more than 2 KB to accommodate OOB data). Due to
this requirement, the data layout on NAND is a bit strange, with ECC
interleaved with data, at the end of each chunk.

When a 4-bits ECC configuration is used with 4 KB pages, the physical
data layout on the NAND looks like this:

| 2048 data | 32 spare | 30 ECC | 2048 data | 32 spare | 30 ECC |

So the data chunks have an equal size, 2080 bytes for each chunk,
which the driver supports properly.

When a 8-bits ECC configuration is used with 4KB pages, the physical
data layout on the NAND looks like this:

| 1024 data | 30 ECC | 1024 data | 30 ECC | 1024 data | 30 ECC | 1024 data | 30 ECC | 64 spare | 30 ECC |

So, the spare area is stored in its own chunk, which has a different
size than the other chunks. Since OOB is not used by UBIFS, the initial
implementation of the driver has chosen to not support reading this
additional "spare" chunk of data.

Unfortunately, Marvell has chosen to store the BBT signature in the
OOB area. Therefore, if the driver doesn't read this spare area, Linux
has no way of finding the BBT. It thinks there is no BBT, and rewrites
one, which U-Boot does not recognize, causing compatibility problems
between the bootloader and the kernel in terms of NAND usage.

To fix this, this commit implements the support for reading a partial
last chunk. This support is currently only useful for the case of 8
bits ECC with 4 KB pages, but it will be useful in the future to
enable other configurations such as 12 bits and 16 bits ECC with 4 KB
pages, or 8 bits ECC with 8 KB pages, etc. All those configurations
have a "last" chunk that doesn't have the same size as the other
chunks.

In order to implement reading of the last chunk, this commit:

 - Adds a number of new fields to the pxa3xx_nand_info to describe how
   many full chunks and how many chunks we have, the size of full
   chunks and partial chunks, both in terms of data area and spare
   area.

 - Fills in the step_chunk_size and step_spare_size variables to
   describe how much data and spare should be read/written for the
   current read/program step.

 - Reworks the state machine to accommodate doing the additional read
   or program step when a last partial chunk is used.

This commit is taken from Linux:
'commit c2cdace755b'
("mtd: nand: pxa3xx_nand: add support for partial chunks")

Signed-off-by: Chris Packham <judge.packham@gmail.com>
Signed-off-by: Ofer Heifetz <oferh@marvell.com>
Reviewed-by: Igal Liberman <igall@marvell.com>
Cc: Stefan Roese <sr@denx.de>
Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Stefan Roese <sr@denx.de>
2018-09-19 09:00:39 +02:00
..
adc adc: Add driver for STM32 ADC 2018-08-03 19:53:10 -04:00
ata scsi: ceva: add ls1012a soc support 2018-07-26 10:59:35 -07:00
axi axi: Add AXI sandbox driver and simple emulator 2018-08-11 08:09:39 +02:00
bios_emulator bios_emulator: remove assignment without effect 2018-07-23 14:33:21 -04:00
block block: Add SPL_BLOCK_CACHE and default n 2018-06-18 14:43:13 -04:00
bootcount Add BOOTCOUNT_BOOTLIMIT to set reboot limit 2018-08-17 13:03:59 -04:00
clk clk: armada-37xx-periph: Support changing clock parent and rate 2018-09-19 08:59:26 +02:00
core device: expose the functions used to remove and unbind children of a device 2018-08-21 16:21:37 +02:00
cpu bcm6838: add initial support 2018-08-08 13:38:17 +02:00
crypto SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
ddr socfpga: stratix10: fix sdram_calculate_size 2018-09-15 03:17:01 +02:00
demo SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
dfu dfu: Provide more verbose error message 2018-08-08 22:22:08 +02:00
dma SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
fastboot usb: fastboot: Convert USB f_fastboot to shared fastboot 2018-05-30 11:59:21 +02:00
firmware dm: firmware: Automatically bind child devices 2018-09-11 08:32:55 -04:00
fpga fpga: Kconfig: Replace spaces with tabs 2018-09-11 10:58:41 +02:00
gpio gpio: dwapb_gpio: Change to use dev_read_addr() 2018-09-15 03:17:01 +02:00
i2c Merge branch 'master' of git://git.denx.de/u-boot-i2c 2018-09-14 09:33:01 -04:00
input Convert CONFIG_TWL4030_LED et al to Kconfig 2018-08-17 13:04:00 -04:00
led dm: led: move default state support in led uclass 2018-08-10 10:27:32 -04:00
mailbox spl: Allow mailbox drivers to be used within SPL 2018-09-11 08:32:55 -04:00
memory SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
misc Convert CONFIG_TWL4030_LED et al to Kconfig 2018-08-17 13:04:00 -04:00
mmc MMC: davinici_mmc: Enable CD and WP with DM and OF_CONTROL 2018-09-11 21:49:02 -04:00
mtd mtd: nand: pxa3xx_nand: add support for partial chunks 2018-09-19 09:00:39 +02:00
net Convert CONFIG_MII et al to Kconfig 2018-08-17 13:03:54 -04:00
nvme SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
pch SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
pci Remove <inttypes.h> includes and PRI* usages in printf() entirely 2018-09-10 20:48:17 -04:00
pcmcia SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
phy phy: marvell: Support changing SERDES map in board file 2018-09-19 08:59:26 +02:00
pinctrl pinctrl: Fix build warning with ARM64 2018-09-10 20:48:20 -04:00
power regulator: pbias: Add additional compatible flags 2018-09-11 21:38:37 -04:00
pwm pwm: sunxi: add support for PWM found on Allwinner A64 2018-05-15 08:18:09 +02:00
qe SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
ram bmips: ram: add an option to force the size of the ram 2018-08-08 13:34:27 +02:00
remoteproc spl: Allow remoteproc drivers to be used within SPL 2018-09-11 08:32:55 -04:00
reset reset: Introduce TI System Control Interface (TI SCI) reset driver 2018-09-11 08:32:55 -04:00
rtc Patch queue for efi - 2018-07-25 2018-07-30 16:02:29 -04:00
scsi Remove <inttypes.h> includes and PRI* usages in printf() entirely 2018-09-10 20:48:17 -04:00
serial arm: K3: Add initial support for TI's K3 generation of SoCs 2018-09-11 08:32:55 -04:00
smem drivers: smem: sandbox 2018-07-19 16:31:38 -04:00
soc SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
sound SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
spi arm: sunxi: Allwinner A10 SPI driver 2018-08-03 11:14:08 +05:30
spmi SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
sysreset sysreset: Add TI System Control Interface (TI SCI) sysreset driver 2018-09-11 08:32:55 -04:00
thermal SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
timer dm: omap-timer: Update clock rate only if not populated 2018-09-10 20:48:19 -04:00
tpm tpm: sandbox: fix wrong assignment with a simplification 2018-08-13 14:04:04 -04:00
usb usb: ehci-generic: Add vbus-supply regulator support 2018-09-15 03:17:43 +02:00
video Convert CONFIG_VIDEO_OMAP3 to Kconfig 2018-08-17 13:04:00 -04:00
watchdog watchdog: mx25: use the imx_watchdog driver for mx25 2018-09-04 08:47:23 +02:00
Kconfig drivers: Add AXI uclass 2018-08-11 08:07:36 +02:00
Makefile spl: Allow remoteproc drivers to be used within SPL 2018-09-11 08:32:55 -04:00