summaryrefslogtreecommitdiffstats
path: root/drivers/mtd
Commit message (Collapse)AuthorAgeFilesLines
* mtd: nand: Make write support optionalSascha Hauer2020-12-112-4/+51
| | | | | | | | | NAND write support used to be optional and the correspoding CONFIG_MTD_WRITE option still exists. Bail out early from the write functions when CONFIG_MTD_WRITE is disabled like we used to before the last NAND layer update. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nand: omap: Fix BCH16 readSascha Hauer2020-12-111-4/+11
| | | | | | | | | | When reading in BCH16 mode the ECC for the first 512 byte fails. I am pretty sure this must have worked once and I can't see why it doesn't now. Change reading in BCH16 mode to the same way as the kernel driver does: Instead of using wrap mode 4 to skip ECC when reading the first OOB bytes, just use wrap mode 1 and skip reading the first OOB bytes. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: Allow non page aligned length writesSascha Hauer2020-12-111-1/+1
| | | | | | | | | When copying images to nand with plain cp it can happen that the length of the image is not page aligned. Allow misaligned image lengths as we used to before the last NAND layer update. Fixes: b6bcd96de5 ("mtd: nand: Update to Linux-5.9") Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand-imx: fix passing pointer of wrong type on NAND_CMD_READOOBAhmad Fatoum2020-11-131-1/+1
| | | | | | | | | | | | copy_spare used to take a mtd_info, but since 5f605dc6168c ("mtd: nand: Pass struct nand_chip around") it now takes a nand_chip. 3588d40c5385 ("mtd: nand-imx: repair reading the oob area") was drafted in parallel and still passes a mtd_info. Their merge did not adjust this, triggering a compiler warning and undefined behavior. Fix this. Fixes: 7b1d8b4b3561 ("Merge branch 'for-next/mtd-nand'") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: Fix dependeny on CONFIG_NAND_BBTSascha Hauer2020-11-112-2/+1
| | | | | | | CONFIG_NAND_BBT no longer exists, so remove the remaining occurences. Fixes: b6bcd96de5 ("mtd: nand: Update to Linux-5.9") Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/mtd-nand'Sascha Hauer2020-11-1048-5271/+11736
|\
| * nand command: Print OOB informationSascha Hauer2020-11-101-0/+81
| | | | | | | | | | | | | | | | NAND mtd devices carry information how the OOB area is used. So far there is no way to visualize it, so print it along with other NAND informations. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand: atmel: Fix pmecc ecc settingsSascha Hauer2020-11-101-42/+16
| | | | | | | | | | | | | | | | | | | | | | pmecc has hardcoded steps of 1 and ecc size of the nand chips page size. This is wrong, the ECC engine does 512 or 1024 bytes per step. Adjust ecc size and step size accordingly. Also, fix ecc strength which was hardcoded to 1. With this the correct number of bitflips is reported, which should be the number of bitflips per ecc step, not the one for the whole page. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand: atmel: drop dead codeSascha Hauer2020-11-101-22/+0
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand: atmel: Return number of bitflipsSascha Hauer2020-11-101-5/+5
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand: denali: Update to Linux-5.9Sascha Hauer2020-11-103-1572/+1338
| | | | | | | | | | | | | | The denali NAND driver is in an hopeless outdated state, it can't even check the ECC data. Throw in the denali driver from Linux-5.9. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand: Update to Linux-5.9Sascha Hauer2020-11-1036-2906/+9711
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: nand: orion: Use nand_to_mtd()Sascha Hauer2020-11-091-1/+1
| | | | | | | | | | | | | | We have a function for getting from the struct nand_chip * to the struct mtd_info *, so use it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand: gpmi: Use nand_to_mtd()Sascha Hauer2020-11-091-1/+1
| | | | | | | | | | | | | | We have a function for getting from the struct nand_chip * to the struct mtd_info *, so use it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand: marvell: Use nand_to_mtd()Sascha Hauer2020-11-091-8/+18
| | | | | | | | | | | | | | We have a function for getting from the struct nand_chip * to the struct mtd_info *, so use it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand: denali: Drop multichip supportSascha Hauer2020-11-091-16/+8
| | | | | | | | | | | | | | | | Current multichip support doesn't fir well into the coming update to the NAND layer. Remove it for now, it will be added back when the denali NAND driver is updated to current Linux. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand: omap_gpmc: Add missing bch16 stringSascha Hauer2020-11-091-0/+1
| | | | | | | | | | | | | | We support bch16_hw in the OMAP NAND driver, but we cannot show it in the eccmode parameter. Add the missing string. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand: omap_gpmc: Fix wrong length checkSascha Hauer2020-11-091-1/+1
| | | | | | | | | | | | | | We may only write more characters when there's actually something left to write. Fix the wrong check. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand: omap_gpmc: Drop unused variableSascha Hauer2020-11-091-4/+0
| | | | | | | | | | | | nand->controller is set but never used. Remove it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: Add ecc_step_sizeSascha Hauer2020-11-091-0/+1
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand: move function hooks to struct nand_legacySascha Hauer2020-11-0911-325/+326
| | | | | | | | | | | | | | Linux had moved the traditional nand function hooks to an extra struct nand_legacy. Do the same in barebox for compatibility. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: rename master to parentSascha Hauer2020-11-095-27/+27
| | | | | | | | | | | | | | In Linux mtd->parent is what in barebox is mtd->master. Rename this to get closer to the Linux mtd layer. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: rename class_dev to devSascha Hauer2020-11-0922-70/+70
| | | | | | | | | | | | | | | | 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>
| * mtd: Use classdev->parentSascha Hauer2020-11-0917-25/+23
| | | | | | | | | | | | | | | | | | | | Instead of mtd->parent we can use mtd->classdev.parent which points to the same device. With this we can remove the 'parent' member of struct mtd_info. This member exists in the Linux kernel as well, but is of type struct mtd_info, so this is done as preparation to re-add mtd->parent with the same type as in Linux. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: Add underscore prefix to mtd hooksSascha Hauer2020-11-0610-101/+101
| | | | | | | | | | | | | | In the Kernel the mtd function hooks begin with an underscore. Do the same in barebox to be better comparable to the Kernel. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand: Pass struct nand_chip aroundSascha Hauer2020-11-0613-844/+786
| | | | | | | | | | | | | | | | | | Traditionally Linux passed a struct mtd_info * around as context between the different functions. This has been changed to a struct nand_chip *. Do the same for barebox as well as another step towards updating the NAND layer to current Linux. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand: drop unused errstat hookSascha Hauer2020-11-061-15/+0
| | | | | | | | | | | | chip->errstat is never set by any driver, so remove it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand: drop unused erase_cmd hookSascha Hauer2020-11-061-2/+1
| | | | | | | | | | | | chip->erase_cmd is never used, so remove this hook. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: nand: remove unused header fileSascha Hauer2020-11-061-32/+0
| | | | | | | | | | | | nand.h is unused, remove it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: Drop asynchronous erase supportSascha Hauer2020-11-068-41/+9
| | | | | | | | | | | | | | asynchronous erase support is unused and also dropped from the Kernel, so remove it from barebox. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mtd: nand-imx: repair reading the oob areaUwe Kleine-König2020-10-231-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After sending the READOOB command the core (in nand_read_oob_std()) uses the read_buf callback to fetch the result. So in the imx driver it is necessary to emit the NFC_OUTPUT command to make the controller actually read the requested data into the internal buffer and then copy the data to the location where read_buf expects it. This fixes reading from /dev/nand0.oob and also (somewhat) reading bad block markers in the absence of a bad block table. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Tested-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/magicvar-unique-id' into masterSascha Hauer2020-10-141-12/+8
|\ \
| * | 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: nand-mxs: fix out-of-bounds write on 64-bit SoCsAhmad Fatoum2020-10-091-3/+1
|/ | | | | | | | | | | Probing the nand_mxs device driver on 64 bit systems invokes undefined behavior, because of an errant cast. Fix this. No change of behavior for 32-bit SoCs intended. On error, type == 0 == GPMI_MXS as it used to. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: spi-nor: cadence: fix csqpi corruption in cqspi_set_protocolIan Abbott2020-09-181-1/+5
| | | | | | | | | | | | cqspi_set_protocol() sets `inst_width`, `addr_width` and `data_width` for the previous chip-select in `cqspi->current_cs`, but that is initially set to -1, leading to corruption of other `cqspi->` members. Change it to set `inst_width`, `addr_width` and `data_width` for the chip-select associated with the `nor` parameter. Fixes: 5085d2ef3fbf ("mtd: spi-nor: cadence: add cqspi_set_protocol") Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: make use of PTR_ERR_OR_ZEROUwe Kleine-König2020-06-261-9/+3
| | | | | | | | | | | PTR_ERR_OR_ZERO is designed to replace boiler plate like: if (IS_ERR(x)) return PTR_ERR(x); return 0; Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: base: fix use of uninitialized struct memberAhmad Fatoum2020-06-031-0/+1
| | | | | | | | | | | ooblen is read in nand_do_read_ops, despite never having been assigned a value. Because ooblen is used to indicate how many bytes of oobbuf are usable and oobbuf is NULL, use 0 as initial value. Found on ARCH=sandbox using clang-analyzer. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: orion: depend on ARMAhmad Fatoum2020-06-031-1/+1
| | | | | | | | We have inline assembly in the driver, so we can't compile-test it unmodified on non-ARM. Indicate so in the Kconfig. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2020-05-146-13/+9
|\
| * mtd: mtdraw: Fix cdev size calculation for large NANDsStefan Riedmueller2020-05-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Raw size for large NAND devices (> 4 GB) can exceed 32 bits, so we need 64 bit types as factors. Both factors are of 32 bit types, as such is the return value. At least one factor needs to be 64 bit type when calculating the size. Signed-off-by: Stefan Riedmueller <s.riedmueller@phytec.de> Signed-off-by: Christian Hemp <c.hemp@phytec.de> Signed-off-by: Yunus Bas <y.bas@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ubi: Refuse to attach partitioned mtd devicesSascha Hauer2020-04-301-0/+8
| | | | | | | | | | | | | | When a mtd device has partitions it is wrong to attach the whole device as this would corrupt the partitions. Refuse to attach it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * treewide: remove references to CREDITSUwe Kleine-König2020-04-274-12/+0
| | | | | | | | | | | | | | | | The CREDITS file was removed from barebox in 2015 by commit 6570288f2d97 ("Remove the CREDITS file"). Remove references to it from several files. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | drivers: mark first batch of compilable drivers for COMPILE_TESTAhmad Fatoum2020-05-081-4/+4
| | | | | | | | | | | | | | | | | | All of these drivers have a runtime dependency on SoC peripherals, but can nevertheless be compile-tested. Add COMPILE_TEST as an alternate dependency. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | drivers: explicitly select dependency STMP_DEVICE for i.MX23/28 driversAhmad Fatoum2020-05-081-0/+1
|/ | | | | | | | | | | | | Some of the i.MXs drivers can be build tested even if building for other platforms. Support adding a future COMPILE_TEST dependency to some of these drivers by explicitly having their Kconfig symbol select STMP_DEVICE if the driver calls stmp_reset_block. This has not been necessary for the normal build, because the ARCH symbols for the IMX23 and IMX28 already selected STMP_DEVICE. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/spi'Sascha Hauer2020-04-161-0/+3
|\
| * mtd: spi-nor: Add support for cy15x104qSascha Hauer2020-04-141-0/+3
| | | | | | | | | | | | | | The Cypress cy15b104q and cy15v104q are 4Mbit serial SPI F-RAM devices. Add support for them to the spi-nor driver. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | treewide: use cpu_relax() where appropriateAhmad Fatoum2020-04-151-5/+3
|/ | | | | | | | Instead of doing /* cpu_relax(); */ barrier(); on upstream uses of cpu_relax(), just use the new cpu_relax() #define directly. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand-imx: make sure the just created BBT is usedSascha Hauer2020-02-051-0/+4
| | | | | | | | | When we create a new BBT we write it to the flash, but the currently running barebox doesn't use it yet, only after a reboot the BBT is actually used. Call nand_default_bbt() to make sure the current barebox also used the newly created BBT. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand-imx: Create BBT automatically when necessarySascha Hauer2020-02-054-227/+102
| | | | | | | | | | | | | | | Due to the differences of the logical page format and the raw page format on NAND the generic nand support can't read the bad block marker on the NAND. For this reason we have the imx_nand_bbm command which knows about these specialities and creates a BBT. The problem with this command is that one has to call it and experience shows this is often forgotten. Linux will then create a BBT based on wrong informations and the real bad blocks may be lost. With this patch we automatically create a BBT when none is found and make the command unnecssary. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand-imx: do not use blocks reserved for BBTSascha Hauer2020-02-052-9/+6
| | | | | | | | | | | | | | | | | | | | | | | | Due to the differences of the logical page format and the raw page format on NAND the generic nand support can't read the bad block marker on the NAND. For this reason we cleared the NAND_BBT_CREATE flag and have the imx_nand_bbm command to create a BBT if none is found in the flash. We have also cleared the NAND_BBT_WRITE flag which causes problems. Normally a BBT occupies two blocks in NAND, but to have some space for the BBT when one of these becomes bad we normally reserve 4 blocks for the BBT. In case we want to write the BBT to flash we have to reserve them from being written to by general NAND operations. In case we don't ever write to the BBT, as indicated by a cleared NAND_BBT_WRITE flag, the reserved blocks can be used by the general NAND operations. This way it happens that barebox uses the reserved blocks for data storage, but Linux (which has NAND_BBT_WRITE set) can't read any data from it. This results in corrupted UBI images. It's not necessary to clear the NAND_BBT_WRITE flag, all we really have to do is to prevent the BBT layer from creating a new BBT. For this it's enough to clear the NAND_BBT_CREATE flag. Fixes: 545453ddae ("mtd: nand: Add command to generate a flash BBT") Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>