9
0
Fork 0
Commit Graph

709 Commits

Author SHA1 Message Date
Uwe Kleine-König faa369e9c5 nand-bb: fix writing to the end of a .bb device
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>
2017-03-02 08:41:53 +01:00
Sascha Hauer 2cd2bad2b7 Merge branch 'for-next/misc' 2017-02-13 09:26:04 +01:00
Sascha Hauer 857f69ba8c ARM: start: Fix image size calculation
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>
2017-02-08 12:03:20 +01:00
Peter Mamonov db791c7fb2 mtd: spi-nor: add support for s25fl208k
Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2017-01-30 07:27:11 +01:00
Sascha Hauer 08c62ae2fa Merge branch 'for-next/truncate' 2017-01-11 19:00:04 +01:00
Teresa Remmet fa9cc22e29 ubi: barebox: Remove character device flag from static volumes
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>
2017-01-11 08:06:48 +01:00
Teresa Remmet 55513dcec5 ubi: Add truncate callback
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>
2017-01-11 08:06:48 +01:00
Uwe Kleine-König d6fd3d914a mtd: m25p80: add support for Everspin MR25H40
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2017-01-10 08:27:33 +01:00
Ulrich Ölmann 520ac28b41 ubi: Only read necessary size when reading the VID header
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>
2017-01-10 08:27:33 +01:00
Sascha Hauer a478be1d5a mtd: peb: Fix format specifier
The correct format specifier for size_t is %zu. Use it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2017-01-10 08:27:33 +01:00
Sascha Hauer fda5f54de8 mtd: peb: fix usage of uninitialized variable
'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>
2017-01-10 08:27:33 +01:00
Sascha Hauer f772aa92c2 Merge branch 'for-next/misc' 2016-11-14 12:35:49 +01:00
Alexander Kurz 1c7cf80f75 mtd: spi-nor: add MX25U2033E
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>
2016-11-11 09:54:42 +01:00
Christian Hemp 7159d9d8e9 mtd: nand: nand_mxs: Fix readtotal calculation
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>
2016-11-11 09:54:42 +01:00
Sascha Hauer 0d68468c96 mtd: Make UBI detection more robust
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>
2016-11-11 09:54:42 +01:00
Daniel Schultz 6f58e5cac9 nand: imx6: Changed default NAND clock
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>
2016-11-11 09:54:13 +01:00
Sascha Hauer 75ee6ab076 mtd: ubi: enable thread earlier
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>
2016-10-19 14:49:10 +02:00
Yegor Yefremov 655b16187d ubi: fix spelling
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-10-12 08:51:54 +02:00
Sascha Hauer 57cebc46f7 mtd: ubi: Fix scrubbing during attach
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>
2016-10-11 08:44:12 +02:00
Sascha Hauer 385c95c60b Merge branch 'for-next/ubi' 2016-10-10 08:31:08 +02:00
Sascha Hauer b85e0cba7d Merge branch 'for-next/mtd' 2016-10-10 08:31:07 +02:00
Giorgio Dal Molin fc428987c8 mtd: ubi: add API call to rename volumes.
Signed-off-by: Giorgio Dal Molin <iw3gtf@arcor.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-09-27 08:15:32 +02:00
Sascha Hauer 29c844b965 mtd: ubi: remove now unused ioctls
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>
2016-09-27 08:15:32 +02:00
Steffen Trumtrar f89f1017a0 nand: denali: get rid of compile-time debug information
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>
2016-09-26 08:03:34 +02:00
Steffen Trumtrar a6c453168c nand: denali: use is_timeout in while loop
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>
2016-09-26 08:03:34 +02:00
Steffen Trumtrar acc6cc82a1 nand: denali: use correct interrupts in read_page
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>
2016-09-26 08:03:34 +02:00
Sascha Hauer 3209e4eaa8 mtd: imx-nand: Move v3 register definitions to include file
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>
2016-09-22 11:20:52 +02:00
Sascha Hauer 0f5b72a110 mtd: ubi: introduce barebox specific ioctl to get ubi_num
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>
2016-09-22 09:42:02 +02:00
Sascha Hauer 85dccb9298 mtd: ubi: Add API calls to create/remove volumes
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>
2016-09-22 09:39:55 +02:00
Sascha Hauer a2b88410ea mtd: nand-imx: Optimize timing for i.MX25
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>
2016-08-18 16:17:04 +02:00
Sascha Hauer 5a9a69155c mtd: nand-imx: split preset_v1_v2 into two functions
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>
2016-08-18 16:17:03 +02:00
Sascha Hauer cae9515d05 mtd: nand: add ONFI timing mode to nand_timings converter
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>
2016-08-18 16:16:27 +02:00
Sascha Hauer b927df0329 Merge branch 'for-next/misc' 2016-08-03 08:08:23 +02:00
Alexander Kurz 741642a862 mtd: spi-nor: add new variants
Read access tested on W25Q20BW and MX25U4035.

Signed-off-by: Alexander Kurz <akurz@blala.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-03 07:28:58 +02:00
Sascha Hauer 370e90bac9 nand: mrvl: use ERR_CAST() for returning error pointers
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>
2016-07-25 10:26:50 +02:00
Sascha Hauer 50543054eb Merge branch 'for-next/ubi' 2016-07-11 07:58:34 +02:00
Sascha Hauer bb73cb9427 Merge branch 'for-next/mtd' 2016-07-11 07:58:33 +02:00
Sascha Hauer f64075972b Merge branch 'for-next/misc' 2016-07-11 07:58:33 +02:00
Sascha Hauer e2da792a52 Merge branch 'for-next/imx' 2016-07-11 07:58:33 +02:00
Uwe Kleine-König 034c16f54e mtd: nand: imx-bbm: use raw reading when checking for factory BBM
This is necessary to prevent the imx_nand_bbm command to bail out
on ECC errors which leaves the device without BBT.

Also simplify buffer management: Use on-stack buffer instead of malloc.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-11 07:48:42 +02:00
Uwe Kleine-König c4fa1cb0f6 mtd: nand: simplify nand_block_checkbad
if (A) {
		if (!B)
			return C;
		return D;
	}

	return C;

can be simplified to:

	if (A && B)
		return D;

	return C;

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-05 09:02:40 +02:00
Teresa Remmet c087e0804f mtd: UBI: Add support for updating static volumes
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>
2016-06-28 07:31:37 +02:00
Sascha Hauer 94d8236556 mtd: ubi: actually do work in wear leveling code
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>
2016-06-28 07:30:04 +02:00
Teresa Remmet 8b765bebb6 mtd: ubi: Fix endless loop when moving PEB
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>
2016-06-28 07:30:00 +02:00
Sascha Hauer 1daa3bc8dc mtd: nand_mxs: Setup timing
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>
2016-06-24 11:44:26 +02:00
Sascha Hauer 6a175cb3ff mtd: nand: Set ONFI function hooks earlier
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>
2016-06-24 11:44:26 +02:00
Lucas Stach 8ef4478c37 mtd: fix mtdraw_erase stub signature
Commit 81737c1d43 (mtd: Fix erasing of devices >4GiB) changed the
prototype of the erase function, but fogot to fix up the stub function
used when no MTD write support is built in.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-24 08:23:33 +02:00
Sascha Hauer 13ef2b2490 mtd: nand: gpmi: Use subpage reads only on suitable NAND chips
On some NAND chips the driver uses a ECC size that is not dividable by
the number of chunks per page which means a single chunk cannot be read.
Disable the subpage feature for these NANDs. This is quite unfortunate
since the subpage feature really speeds up scanning NAND chips.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-22 08:45:45 +02:00
Sascha Hauer d059216c48 Merge branch 'for-next/ubi' 2016-06-14 09:13:41 +02:00
Teresa Remmet 31edb3f16d mtd: UBI: Remove ubi_free_fastmap
Freeing the fastmap is now done by ubi_fastmap_close() from kernel.
No need to keep the barebox own fastmap free function.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00