summaryrefslogtreecommitdiffstats
path: root/drivers/mtd
Commit message (Collapse)AuthorAgeFilesLines
* mtd: nand_omap_gpmc: fix BCH error correctionMatt Reimer2017-04-191-1/+2
| | | | | | | | | | | | | | | | | | | BCH error detection and correction was only looking at the first of four syndrome polynomials, which meant it was failing to detect and correct bitflips in the last 3/4 of the data. In effect, only the first 512 bytes of a 2048 byte page were being protected by ECC. The syndrome polynomials (BCH error codes) are stored in the NAND's OOB, each of which protects 512 bytes of data. The driver used eccsteps = 1 which effectively made it only use the first polynomial, and therefore was only protecting the first 512 bytes of the page. The fix is to pull over a bit of code from the kernel's omap_correct_data() that sets eccsteps = 4 when the page size is 2048 bytes and hardware ECC is being used. Signed-off-by: Matt Reimer <mreimer@sdgsystems.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/ofpart'Sascha Hauer2017-04-072-62/+5
|\
| * fs: devfs-core: replace DEVFS_IS_PARTITION flag with pointer to the master cdevSascha Hauer2017-03-311-0/+2
| | | | | | | | | | | | | | | | Instead of having a flag indicating a cdev is a partition on some master cdev, just add a master pointer to the cdev, so that we can also find out who the master is. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * of: partition: Move of_mtd_fixup to drivers/of/Sascha Hauer2017-03-301-62/+3
| | | | | | | | | | | | | | | | Move the fixup code where the parser code is already. Since the code will not only be used for mtd in the future drivers/of/ is a better place than drivers/mtd/. 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: fix reading data from page that needs cleanupSascha Hauer2017-03-231-4/+3
| | | | | | | | mtd_read´() returns -EUCLEAN to indicate that a page needs cleanup. This value shouldn't be returned from the mtd read file operation since this should return the number of bytes read. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nand-bb: fix writing to the end of a .bb deviceUwe Kleine-König2017-03-021-1/+1
| | | | | | | | As nand_bb_write_buf calls mtd_write(bb->mtd, cur_ofs, now, ...) the limit that now should be checked against is bb->mtd->size - cur_ofs. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2017-02-131-0/+1
|\
| * mtd: spi-nor: add support for s25fl208kPeter Mamonov2017-01-301-0/+1
| | | | | | | | | | Signed-off-by: Peter Mamonov <pmamonov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ARM: start: Fix image size calculationSascha Hauer2017-02-081-1/+1
|/ | | | | | | | | | In barebox_non_pbl_start() we do not run at the address we are linked at, so we must read linker variables using ld_var(). Since ld_var() current is not available on arm64 we create two zero sized arrays, one at the begin of the image and one at the end. The difference between both is the image size we are looking for. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/truncate'Sascha Hauer2017-01-111-3/+16
|\
| * ubi: barebox: Remove character device flag from static volumesTeresa Remmet2017-01-111-3/+0
| | | | | | | | | | | | | | | | | | | | Character device flag was set for ubi static volumes to vary the device file size. This is now done with the truncate option. So no need for the character device flag. This makes it also possible to dump a image from the static volume. Signed-off-by: Teresa Remmet <t.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ubi: Add truncate callbackTeresa Remmet2017-01-111-0/+16
| | | | | | | | | | | | | | | | The size of static ubi volumes changes depending on the content. Add truncate callback to handle resizes. Signed-off-by: Teresa Remmet <t.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mtd: m25p80: add support for Everspin MR25H40Uwe Kleine-König2017-01-102-1/+2
| | | | | | | | | | Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ubi: Only read necessary size when reading the VID headerUlrich Ölmann2017-01-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on kernel commit 8a8e8d2fdbab ("ubi: Only read necessary size when reading the VID header") by Sascha Hauer <s.hauer@pengutronix.de>: When reading the vid hdr from the device UBI always reads a whole page. Instead, read only the data we actually need and speed up attachment of UBI devices by potentially making use of reading subpages if the NAND driver supports it. Since the VID header may be at offset vid_hdr_shift in the page and we can only read from the beginning of a page we have to add that offset to the read size. Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> 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>
* Merge branch 'for-next/misc'Sascha Hauer2016-11-141-3/+3
|\
| * ubi: fix spellingYegor Yefremov2016-10-121-3/+3
| | | | | | | | | | Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mtd: spi-nor: add MX25U2033EAlexander Kurz2016-11-111-0/+1
| | | | | | | | | | | | | | This chip can be found in 4th generation Kindle devices Signed-off-by: Alexander Kurz <akurz@blala.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mtd: nand: nand_mxs: Fix readtotal calculationChristian Hemp2016-11-111-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The calculation of readtotal must be bit alligend. If not the bch core finds bit flips in every page, because readtotal is too small. This bug was mostly introduced since commit "51061a9 mtd: nand: nand_mxs: Add subpage read support". Tested with: nand: NAND device: Manufacturer ID: 0x01, Chip ID: 0xd3 (AMD/Spansion S34ML08G2), 1024MiB, page size: 2048, OOB size: 128 nand: NAND device: Manufacturer ID: 0x2c, Chip ID: 0xdc (Micron MT29F4G08ABADAWP), 512MiB, page size: 2048, OOB size: 64 nand: NAND device: Manufacturer ID: 0xec, Chip ID: 0xd3 (Samsung NAND 1GiB 3,3V 8-bit), 1024MiB, page size: 2048, OOB size: 64 Signed-off-by: Christian Hemp <c.hemp@phytec.de> Signed-off-by: Stefan Lengfeld <s.lengfeld@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mtd: Make UBI detection more robustSascha Hauer2016-11-111-11/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | When we want to detect if a mtd device contains an UBI image then testing the first block is not enough since it can always happen that UBI has just erased the block before the power failed during last boot. Since UBI only ever erases one block at a time and directly writes the ec header to it afterwards, it shouldn't be necessary to scan the whole device for UBI data. Scan the first 64 blocks. The first non-empty block then must contain UBI data, if instead we find foreign data we assume that no UBI is on that mtd device. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | nand: imx6: Changed default NAND clockDaniel Schultz2016-11-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Barebox recognized false bad erase blocks while booting from a Spansion NAND (1). This error occurred due a to high clock. The Kernel sets the default NAND clock to 22Mhz. So, to fix this error and to be more identical with the Kernel, the Barebox should be too. 1: nand: NAND device: Manufacturer ID: 0x01, Chip ID: 0xd3 (AMD/Spansion S34ML08G2), 1024MiB, page size: 2048, OOB size: 128 Signed-off-by: Daniel Schultz <d.schultz@phytec.de> Tested-by: Stefan Lengfeld <s.lengfeld@phytec.de> Signed-off-by: Christian Hemp <c.hemp@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mtd: ubi: enable thread earlierSascha Hauer2016-10-191-9/+5
|/ | | | | | | | | | | Since "57cebc4 mtd: ubi: Fix scrubbing during attach" we make sure that the wear level worker does not start too early. However, now there are cases when the worker starts too late. When a ubi image is freshly written a volume may be autoresized. This has to be done after the wear level worker is started because otherwise the initial fastmap update will not be able to find any anchor PEBs. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: ubi: Fix scrubbing during attachSascha Hauer2016-10-113-3/+28
| | | | | | | | | | | | | | | | | | | | | | | | | ensure_wear_leveling() is called at the end of ubi_wl_init() and may come to the decision to scrub some blocks. In the Kernel this is done in a separate thread, but in barebox we do this synchronously. The problem is that during ubi_wl_init() the EBA system is not yet initialized (ubi_eba_init() is not yet called), so the wear level worker hits a NULL pointer deref when the fastmap needs to be updated and ubi_write_fastmap() accesses vol->eba_tbl. Solve this by honoring the ubi->thread_enabled flag which is only set to true when UBI is sufficiently initialized. This means we now can have multiple works queued, so we can no longer simply do one work when queued, but instead have to continue to do work until all work is done. The best place to do so is a ubi_thread() function which behaves similar to the Kernel function with the same name, but is called synchronously in barebox. To make sure that the initially queued works are done, the call to (no-op) wake_up_process() at the end of ubi_attach_mtd_dev() is replaced with a call to ubi_thread(). While at it also honor the ubi->ro_mode flag to make sure we do not do any wear leveling work on readonly UBI devices. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/ubi'Sascha Hauer2016-10-102-13/+189
|\
| * mtd: ubi: add API call to rename volumes.Giorgio Dal Molin2016-09-272-0/+159
| | | | | | | | | | Signed-off-by: Giorgio Dal Molin <iw3gtf@arcor.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: ubi: remove now unused ioctlsSascha Hauer2016-09-271-14/+5
| | | | | | | | | | | | | | | | The only ioctl needed is the one to get the ubi_num from a file descriptor. The remaining ioctls are now implemented as regular function calls. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: ubi: introduce barebox specific ioctl to get ubi_numSascha Hauer2016-09-221-0/+3
| | | | | | | | | | | | | | | | Code wishing to manipulate ubi devices from outside the ubi layer needs the ubi_num as reference. Add an ioctl to get the ubi_num from a filedescriptor. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: ubi: Add API calls to create/remove volumesSascha Hauer2016-09-221-0/+23
| | | | | | | | | | | | | | | | | | | | Currently we use a ioctl API to create/remove ubi volumes. This means we always have to carry all function code for ubi volume manipulation when the ioctl is compiled in. This adds a function API to create/remove volumes so that the linker can throw the unused code away later. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/mtd'Sascha Hauer2016-10-101-30/+26
|\ \
| * | nand: denali: get rid of compile-time debug informationSteffen Trumtrar2016-09-261-12/+0
| | | | | | | | | | | | | | | | | | | | | | | | Remove dev_dbgs containing __FILE__ and __LINE__ and no other interesting debug informations. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | nand: denali: use is_timeout in while loopSteffen Trumtrar2016-09-261-16/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of using udelay and a countdown, use the is_timeout function. Also, move the code closer to the kernel version, i.e. check for the correct bank and clean the interrupt status. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | nand: denali: use correct interrupts in read_pageSteffen Trumtrar2016-09-261-2/+3
| |/ | | | | | | | | | | | | | | The interrupt mask is incorrect in case of HW error correction. The driver will time out waiting for the wrong interrupts. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / mtd: imx-nand: Move v3 register definitions to include fileSascha Hauer2016-09-221-49/+0
|/ | | | | | | Move v3 register definitions to include file so that they can be reused for the early nand boot code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand-imx: Optimize timing for i.MX25Sascha Hauer2016-08-181-0/+30
| | | | | | | | | | | So far we relied on the clock rate as configured by reset default or board code. Also we did not touch the symmetric mode bit. Use the ONFI provided timing parameters to configure the clock rate for the Nand controller. Also symmetric mode (EDO mode) when needed. This is done for v2 controllers (i.MX25/35) only, other controllers need other setup code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand-imx: split preset_v1_v2 into two functionsSascha Hauer2016-08-181-13/+29
| | | | | | | | | preset_v1_v2() still needs to distinguish between v1 and v2 and the shared code is not very big. Since we need another v2 only addtion in the next patch split the function into a v1 and a v2 specific function. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mtd: nand: add ONFI timing mode to nand_timings converterSascha Hauer2016-08-182-1/+252
| | | | | | | | | | | Ported from Linux commit 974647e: | Add a converter to retrieve NAND timings from an ONFI NAND timing mode. | At the moment, only SDR NAND timings are supported. | | Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com> | Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2016-08-031-0/+5
|\
| * mtd: spi-nor: add new variantsAlexander Kurz2016-08-031-0/+5
| | | | | | | | | | | | | | Read access tested on W25Q20BW and MX25U4035. Signed-off-by: Alexander Kurz <akurz@blala.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | nand: mrvl: use ERR_CAST() for returning error pointersSascha Hauer2016-07-251-3/+3
|/ | | | | | | | | | | ERR_CAST exists to return error pointers as error pointers without casting them explicitly to the correct pointer type. Also this Fixes: In function 'alloc_nand_resource': warning: return makes pointer from integer without a cast Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/ubi'Sascha Hauer2016-07-114-28/+58
|\
| * mtd: UBI: Add support for updating static volumesTeresa Remmet2016-06-282-14/+54
| | | | | | | | | | | | | | | | Added support to update UBI static volumes in barebox. This is mainly realized with adding the ioctl UBI_IOCVOLUP. Signed-off-by: Teresa Remmet <t.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: ubi: actually do work in wear leveling codeSascha Hauer2016-06-281-4/+3
| | | | | | | | | | | | | | | | | | | | | | The actual work in the wear leveling code is done in a separate thread. Since we do not have threading so far we did not do any of the queued work. Change this by calling the worker function synchronously. With this barebox now can write a fastmap on a freshly ubiformated device. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mtd: ubi: Fix endless loop when moving PEBTeresa Remmet2016-06-281-10/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When moving a PEB the leb_write_trylock() function is called. As the function never returns 0 UBI will end up in an endless loop. Noticed the issue when fastmap has been enabled and data is beeing copied several times to a UBI volume. When UBI tries to move the anchor PEB, the issue comes up. The leb_write_trylock() is now equal to the leb_write_lock(). But kept it for easier maintaince in future when syncing with kernel. Signed-off-by: Teresa Remmet <t.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/mtd'Sascha Hauer2016-07-112-10/+815
|\ \
| * | mtd: nand_mxs: Setup timingSascha Hauer2016-06-241-4/+808
| | | | | | | | | | | | | | | | | | | | | | | | So far we relied on the default timing values which are rather slow. This patch adds the timing setup functions from the kernel. Tested on i.MX6 with a AMD/Spansion S34ML08G2 and a Micron MT29F32G08ABAAAWP. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | mtd: nand: Set ONFI function hooks earlierSascha Hauer2016-06-241-6/+7
| |/ | | | | | | | | | | | | | | Make the ONFI function hooks available after nand_scan_ident() but before nand_scan_tail(). Based on the kernel commit: 4204ccc mtd: set ONFI nand's default hooks in nand_set_defaults() Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2016-07-111-4/+1
|\ \