summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/peb.c
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'for-next/mtd-nand'Sascha Hauer2020-11-101-22/+21
|\
| * mtd: nand: Update to Linux-5.9Sascha Hauer2020-11-101-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This updates the barebox NAND layer and parts of the mtd layer to Linux-5.9. This patch is huge, but the barebox NAND layer is so far away from the Linux NAND layer that a step by step update would have taken ages. Unlike Linux barebox has functions to mark a block as good. This feature has been preserved. Also barebox used to make NAND write support optional, this feature is lost during the update for the sake of better compatibility to the Linux NAND layer. This patch has been tested: - GPMI aka nand_mxs on i.MX6 - nand_imx on i.MX25 - nand_omap_gpmc on AM335x - atmel_nand on Atmel sama5d3 - nand_denali on SoCFPGA Currently untested: - nand_orion - nand_mrvl_nfc - nand_s3c24xx The nand_denali driver is tested with the update of that driver to Linux-5.9 following in the next patch. I could only test the drivers with the NAND chips found on my boards, so there's still enough room for regressions, especially given that the NAND drivers themselves are mostly not updated. With the NAND layer being up-to-date with Linux it should hopefully be easy to update drivers to their Linux counterpart as well if necessary. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: rename class_dev to devSascha Hauer2020-11-091-21/+21
| | | | | | | | | | | | | | | | The mtds own device is named 'dev' in the Kernel whereas it's named 'class_dev' in barebox. Rename it to 'dev' for better compatilibility to the Kernel. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | magicvar: Replace BAREBOX_MAGICVAR_NAMED with BAREBOX_MAGICVARSascha Hauer2020-10-021-12/+8
|/ | | | | | | | BAREBOX_MAGICVAR now generates a unique identifier automatically, so we can convert users of BAREBOX_MAGICVAR_NAMED to the simpler BAREBOX_MAGICVAR macro. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: peb: Add function to write fileSascha Hauer2019-08-281-0/+84
| | | | | | | | | This adds a function to the mtd peb API to write a file spanning multiple blocks to a mtd device. Bad blocks are automatically skipped and before anything is done we check if the image will fit into the remaining space (honouring bad blocks). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: peb: Do not mark as bad in mtd_peb_torture()Sascha Hauer2019-07-161-6/+3
| | | | | | | | | | | Both the Kernel and mtd-utils have peb torture functions and both do not mark the block as bad automatically. Instead, the caller must mark the block as bad when -EIO is returned from the torture function. Do the same in barebox. This is necessary as the UBI code otherwise may mark a block as bad twice: Once indirectly in mtd_peb_torture() and then directly afterwards. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: peb: Add function to skip bad blocksSascha Hauer2019-01-281-0/+27
| | | | | | | | This adds a function that given a pointer to a PEB number increases the number until the corresponding PEB is good. It also checks for the PEB number being inside the mtd device. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Revert "globalvar: make globalvar functions more consistent"Sascha Hauer2017-06-131-3/+3
| | | | This reverts commit 1b4a05c9263ae26083526acfabdea1ef96531a1d.
* globalvar: make globalvar functions more consistentSascha Hauer2017-04-111-3/+3
| | | | | | | | | Similar to the device parameter functions also make the globalvar functions more consistent. This also adds support for readonly globalvars and changes several existing globalvars which should really be readonly to readonly. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: when creating bitflips the offset has to be page alignedSascha Hauer2017-03-301-0/+2
| | | | | | | | mtd_peb_create_bitflips() assumes the offset is page aligned. Enforce this and in the nand_bitlfip command print a warning if it's not aligned. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: create bitflips in the correct pageSascha Hauer2017-03-301-1/+1
| | | | | | | | In mtd_peb_create_bitflips() buf always points to the first page in a block. If we want to create bitflips in other pages we have to add the offset into the block. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: peb: Fix format specifierSascha Hauer2017-01-101-1/+1
| | | | | | The correct format specifier for size_t is %zu. Use it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: peb: fix usage of uninitialized variableSascha Hauer2017-01-101-3/+2
| | | | | | | 'read' is used in an error message but never assigned a value to. Remove the variable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: Create nand_bitflip commandSascha Hauer2016-04-061-0/+121
| | | | | | | | | | | | | | | | | | | This adds a command to flip bits in a Nand flash. This is useful for testing purposes to check if flipped bits are corrected and if the driver returns the correct number of bitflips. The command writes a configurable number of bitflips to a single Nand page. If the -r option is not given the results are reproducible, so calling the same command twice will revert the bitflips. The command uses the raw read/write Nand operations which are probably less tested than the regular read/write operations, so the command may produce surprising results. As of writing the command has been tested with the GPMI Nand driver and the imx-nand driver with fixes posted. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: Introduce mtd-peb APISascha Hauer2016-04-061-0/+537
Code which properly wants to handle Nand flash has to work in a block based way since blocks are the entities that are erased or may become bad. The regular mtd API works based on offsets in the device which introduces unhandy 64bit arithmetics and the requirement to align buffers to blocks. This introduces the mtd peb API (PEB for physical Erase Block) which allows the users to work in a block oriented way. The API is heavily inspired by the UBI IO layer and in fact can replace parts thereof later. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>