Commit Graph

116 Commits

Author SHA1 Message Date
Max Krummenacher
8d99753ad9 This is the 4.9.87 stable release
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAlqlSYcACgkQONu9yGCS
 aT4QOBAAlV3X1U64uPZAafv52q/4GVvjh3fymj2aThOImY6cCG2wuQfEHq4lqRKJ
 ua+AY1etuGqJbQlroy8j85bIRtE1pmtW+hAA+vaITcrPJhWzhHmssMCK2aM1Jtim
 +zDXuh4GjXZ+5Gv3p4bbf3otFOgegr2Ftn4dVEmDClkSqRmNEpAtPzSo5TZQCopN
 +QksrFTXMs9QEBxCnfXWHxz0c1EIpaJVtyteX6wVZKC2hjOoF5RBBvErUABW9Po0
 db9+6v488AVouaEqxoLmtcwwUFhetMh/5M4oapD8NeRuwkG+4jFNDZcXIRaCzzyu
 /8DzeyaP1luA/6q0dSI9JD5Whg7FnuZ4A888D+pLHjEQgSgnxhIX38lpsRcrEbl9
 8myFYPoxj6eryM31Z3jW566TI7vT0uqxrc5RzKaFW1xwxLU1Dur5N09VROYIsLvm
 YXUjELN+RwrQa5OkenKbTFy0OPjDHzuo1V/b98T6LujozkyboKAsCUyqE+HukUSe
 Vicg8h5APSPnMSbPLVW5xDDzShBaKhFps92ELsUEZzr5GGS5SX7TBHlbX0bRKs59
 1+hsVts6Twi30/PUJBGkYCAfJ/Jqe0L9l/kj4wnBKWyBLFP5YRerkww2pZ1b/diY
 kwmxH26tSI9g3Nh4oeUB3j5MKu23XhDucB0r2H3pLqfTqFcoT3M=
 =Y/Vz
 -----END PGP SIGNATURE-----

Merge tag 'v4.9.87' into fslc_4.9-1.0.x-imx

This is the 4.9.87 stable release

 Conflicts:
	drivers/dma/fsl-edma.c
2018-03-12 16:59:40 +01:00
Sascha Hauer
dd1e39f4b3 mtd: nand: gpmi: Fix failure when a erased page has a bitflip at BBM
[ Upstream commit fdf2e82105 ]

When erased subpages are read then the BCH decoder returns STATUS_ERASED
if they are all empty, or STATUS_UNCORRECTABLE if there are bitflips.
When there are bitflips, we have to set these bits again to show the
upper layers a completely erased page. When a bitflip happens in the
exact byte where the bad block marker is, then this byte is swapped
with another byte in block_mark_swapping(). The correction code then
detects a bitflip in another subpage and no longer corrects the bitflip
where it really happens.

Correct this behaviour by calling block_mark_swapping() after the
bitflips have been corrected.

In our case UBIFS failed with this bug because it expects erased
pages to be really empty:

UBIFS error (pid 187): ubifs_scan: corrupt empty space at LEB 36:118735
UBIFS error (pid 187): ubifs_scanned_corruption: corruption at LEB 36:118735
UBIFS error (pid 187): ubifs_scanned_corruption: first 8192 bytes from LEB 36:118735
UBIFS error (pid 187): ubifs_scan: LEB 36 scanning failed
UBIFS error (pid 187): do_commit: commit failed, error -117

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reviewed-by: Richard Weinberger <richard@nod.at>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-03-03 10:23:21 +01:00
Octavian Purdila
ac337e78f0 MLK-14388 mtd: gpmi: remove direct mtd->priv accesses
mtd->priv is no longer pointing to the struct nand_chip it is attached
to.  Replace those accesses by mtd_to_nand() calls.

Signed-off-by: Octavian Purdila <octavian.purdila@nxp.com>
2017-06-08 21:00:37 +08:00
Han Xu
789a095c11 MLK-12684-2: mtd: gpmi: add NAND support
support NAND on imx6ull

Signed-off-by: Han Xu <han.xu@nxp.com>
2017-02-23 15:21:35 +02:00
Han Xu
fbb40e6fc0 MLK-12622: mtd: gpmi: fix the issue in legacy bch support
missed the brackets for bch legacy support, which leads the large oob
nand bch setting to wrong path.

Signed-off-by: Han Xu <han.xu@nxp.com>
2017-02-23 15:21:26 +02:00
Han Xu
a8f5e66971 MLK-12601: mtd: gpmi: provide the option to use legacy bch geometry
Provide an option in DT to use legacy bch geometry, which compatible
with the 3.10 kernel bch setting. To enable the feature, adding
"fsl,legacy-bch-geometry" under gpmi-nand node.

NOTICE: The feature must be enabled/disabled in both u-boot and kernel.

Conflicts:
	drivers/mtd/nand/gpmi-nand/gpmi-nand.h

Signed-off-by: Han Xu <han.xu@nxp.com>
(cherry picked from commit 4d28b1693905526558892d40525763e6bc4469e4)
2017-02-23 15:21:25 +02:00
Han Xu
ea4b72347d MLK-12449: mtd: gpmi: fix integer overflow issue
fix the potential integer overflow issue found by coverify.

Signed-off-by: Han Xu <han.xu@nxp.com>
2017-02-23 15:21:07 +02:00
Han Xu
f6597e2def MLK-12395: mtd: gpmi: add debugfs flag to indicate NAND driver use new raw access mode
For backward compatibility, kobs-ng need to know if the driver use
legacy raw mode or new bch layout raw mode, add a new flag in debugfs to
indicate the raw access mode.

Signed-off-by: Han Xu <han.xu@nxp.com>
2017-02-23 15:20:55 +02:00
Han Xu
d32eed1857 MLK-12394-2: mtd: gpmi: update NAND new raw page access functions
support the bch layout with dedicate ecc for meta

Signed-off-by: Han Xu <han.xu@nxp.com>
2017-02-23 15:20:54 +02:00
Han Xu
db1191c78f MLK-12394-1: Revert "MLK-12309: mtd: gpmi: workaround for kernel 4.1 NAND boot"
This reverts commit 76babd7d075c9c22a27e6bc272bb57b6327cfbd3.

Signed-off-by: Han Xu <han.xu@nxp.com>
2017-02-23 15:20:54 +02:00
Han Xu
6bd8d3dbd2 MLK-12309: mtd: gpmi: workaround for kernel 4.1 NAND boot
new implementation of GPMI NAND raw access functions was added in kernel
4.1 which changes the way from writing data in mirror mode to writing
data with BCH layout mode.

New implementation can help third party tools to analysis the data since
all data were written in same layout, with or without ECC, but this
implementation doesn't work for NAND boot. Kobs-ng, the tool for NAND
boot will create the boot configuration data for each specific platform
and need to write the data to NAND in mirror mode. In this workaround,
we will keep using the previous raw NAND access function to fix the
issue.

Signed-off-by: Han Xu <han.xu@nxp.com>
2017-02-23 15:20:40 +02:00
Fugang Duan
c05d64b81e MLK-11949 mtd: gpmi: fix the typo in .bbm_in_data_chunk()
Fix the typo in when check bch geometry ecc chunk0 and chunkn size.

Signed-off-by: Fugang Duan <B38611@freescale.com>
2017-02-23 14:21:42 +02:00
Han Xu
082f8cce07 MLK-11751: mtd: gpmi: add empty sentinel entry at the end of of_device_id table
add an empty sentinel entry to avoid the struct of_device_id is not
terminated with a NULL entry issue.

Signed-off-by: Han Xu <b45815@freescale.com>
(cherry picked from commit 2b1ce5ec442dde8801b6b2d059d22f5dce7c9c76)
2017-02-23 14:21:42 +02:00
Han Xu
6c47f97a73 MLK-11747: mtd: gpmi: save bch geometry setting only in initial stage
fix the bch setting issue when system suspend/resume, the bch geometry
only need to be saved to debugfs in driver initial stage

Signed-off-by: Han Xu <b45815@freescale.com>
(cherry picked from commit 3b4f7178854e428fb5ef08d554b13abe4f27c533)
2017-02-23 14:21:42 +02:00
Han Xu
842c7c9d66 MLK-11719-4: mtd: gpmi: change the BCH layout setting for large oob NAND
The cod change updated the NAND driver BCH ECC layout algorithm to
support large oob size NAND chips(oob > 1024 bytes) and proposed a new
way to set ECC layout.

Current implementation requires each chunk size larger than oob size so
the bad block marker (BBM) can be guaranteed located in data chunk. The
ECC layout always using the unbalanced layout(Ecc for both meta and
Data0 chunk), but for the NAND chips with oob larger than 1k, the driver
cannot support because BCH doesn’t support GF 15 for 2K chunk.

The change keeps the data chunk no larger than 1k and adjust the ECC
strength or ECC layout to locate the BBM in data chunk. General idea for
large oob NAND chips is

1.Try all ECC strength from the minimum value required by NAND spec to
the maximum one that works, any ECC makes the BBM locate in data chunk
can be chosen.

2.If none of them works, using separate ECC for meta, which will add one
extra ecc with the same ECC strength as other data chunks. This extra
ECC can guarantee BBM located in data chunk, of course, we need to check
if oob can afford it.

Previous code has two methods for ECC layout setting, the
legacy_set_geometry and set_geometry_by_ecc_info, the difference
between these two methods is, legacy_set_geometry set the chunk size
larger chan oob size and then set the maximum ECC strength that oob can
afford. While the set_geometry_by_ecc_info set chunk size and ECC
strength according to NAND spec. It has been proved that the first
method cannot provide safe ECC strength for some modern NAND chips, so
in current code,

1. Driver read NAND parameters first and then chose the proper ECC
layout setting method.

2. If the oob is large or NAND required data chunk larger than oob size,
chose set_geometry_for_large_oob, otherwise use set_geometry_by_ecc_info

3. legacy_set_geometry only used for some NAND chips does not contains
necessary information. So this is only a backup plan, it is NOT
recommended to use these NAND chips.

Signed-off-by: Han Xu <b45815@freescale.com>
(cherry picked from commit 78e8beff734adb72185405ae2cb55e0097eb96cb)
2017-02-23 14:21:42 +02:00
Han Xu
f9b1f3f548 MLK-11555: mtd: nand: i.MX6UL supports bitflip detection
i.MX6UL also has the DEBUG1 register which can be used for bitflip
detection for erased page.

Signed-off-by: Han Xu <b45815@freescale.com>
(cherry picked from commit 8df8d10edc8909e19e60f0cc1dd65c1fe706ab67)
2017-02-23 14:21:42 +02:00
Han Xu
fcb4733bd5 MLK-11336: mtd: nand: enable LPSR for GPMI NAND
The LPSR turns off the power for IOMUX when suspending so restore the
IOMUX when resuming in GPMI NAND driver.

The function was not tested yet since NAND only supported on 19x19
LPDDR board.

Signed-off-by: Han Xu <b45815@freescale.com>
Signed-off-by: Fugang Duan <B38611@freescale.com>
(cherry picked from commit: b0375f42a27044667082e53449e534b265d7a029)
2017-02-23 14:21:42 +02:00
Han Xu
d0279cfd89 MLK-11133: mtd:gpmi: support runtime pm for gpmi nand
support runtime PM on gpmi nand to save the cost to enable/disable clock
in each NAND IO. The driver also claim high-freq bus when resumed.

Signed-off-by: Han Xu <b45815@freescale.com>
(cherry picked from commit: 5b72b3388d1399420f3b49a0ca937ca5792e2d7d)
2017-02-23 14:21:42 +02:00
Han Xu
c9c6620b36 MLK-11044: mtd:nand: enable per1_bch for NAND on all i.MX6 platform
The per1_bch was moved in patch below since it was never mentioned in
any GPMI/BCH/APBH documents, but actually it is necessary for BCH module
since BCH use AXI bus transfer data through fabric, need to enable this
clock for BCH at fabric side.

This patch enabled this clock for all i.MX6 platforms and has been
tested on i.MX6Q/i.MX6QP/i.MX6SX and i.MX6UL.

commit 9aa0fb0a606a583e2b6e19892ac2cab1b0e726c4
Author: Han Xu <b45815@freescale.com>
Date: Thu May 28 16:49:18 2015 -0500

mtd: nand: support NAND on i.MX6UL

support i.MX6UL GPMI NAND driver and removed the unecessary clock
per1_bch.

Signed-off-by: Han Xu <b45815@freescale.com>
(cherry picked from commit: 53c5964a104f71c061d95bd98599fbf050644ddb)
2017-02-23 14:21:42 +02:00
Han Xu
71cfaa37b4 MLK-10985: mtd: nand: support NAND on i.MX6UL
support i.MX6UL GPMI NAND driver and removed the unecessary clock
per1_bch.

Signed-off-by: Han Xu <b45815@freescale.com>
(cherry picked from commit: 9aa0fb0a606a583e2b6e19892ac2cab1b0e726c4)
2017-02-23 14:21:42 +02:00
Han Xu
d61ce73915 MLK-10664: mtd: nand: change the maxchips for i.MX7D
change the maximum chips for i.MX7D, this part was missed when adding
i.MX7D NAND support.

Signed-off-by: Han Xu <b45815@freescale.com>
(cherry picked from commit: 313d4d5e701dd6a28dc7d2bd84094b8fbdb7f9ca)
2017-02-23 14:21:42 +02:00
Han Xu
41af2a3e16 MLK-10471: mtd: nand: use maximum ecc strength controller can support
when the maximum ecc NAND oob can afford exceed the ecc strength
controller can provide, use the maximum ecc strength controller can
support instead of the minimum ecc NAND spec required.

kobs-ng will also use the same ecc strength to align with kernel to make
sure all NAND chips can boot.

Signed-off-by: Han Xu <b45815@freescale.com>
(cherry picked from commit: 958a2c5b07524f3502cfdefe66724a9a1f8ad608)
2017-02-23 14:21:42 +02:00
Han Xu
2cc04d1612 MLK-10657: mtd: NAND: correct bitflip for erased NAND page
i.MX6QP and i.MX7D BCH module integrated a new feature to detect the
bitflip number for erased NAND page. So for these two platform, set the
erase threshold to gf/2 and if bitflip detected, GPMI driver will
correct the data to all 0xFF.

Also updated the imx6qp dts file to ditinguish the GPMI module for i.MX6Q
with the one for i.MX6QP.

Signed-off-by: Han Xu <b45815@freescale.com>
(cherry picked from commit: 4302ab74a301626e7e0b9cb398a23b2e488cfa6b)
2017-02-23 14:21:42 +02:00
Han Xu
a1d0f0eb20 MLK-10521-2: mtd: gpmi: Add NAND support on i.MX7D
Support NAND on i.MX7D

Signed-off-by: Han Xu <b45815@freescale.com>
Signed-off-by: Fugang Duan <B38611@freescale.com>
(cherry picked and merged from commit: 39af0df85dcbcb2ebd677ec5d2a2a4e6a61ed826)
2017-02-23 14:21:42 +02:00
Han Xu
1848a057a2 mtd: nand: gpmi: get correct free oob space
change the way to calculate pagesize to get correct free oob space for
legacy_set_geometry function.

Signed-off-by: Han Xu <han.xu@nxp.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
2016-09-23 09:35:16 +02:00
Markus Pargmann
bd2e778c9e gpmi-nand: Handle ECC Errors in erased pages
ECC is only calculated for written pages. As erased pages are not
actively written the ECC is always invalid. For this purpose the
Hardware BCH unit is able to check for erased pages and does not raise
an ECC error in this case. This behaviour can be influenced using the
BCH_MODE register which sets the number of allowed bitflips in an erased
page. Unfortunately the unit is not capable of fixing the bitflips in
memory.

To avoid complete software checks for erased pages, we can simply check
buffers with uncorrectable ECC errors because we know that any erased
page with errors is uncorrectable by the BCH unit.

This patch adds the generic nand_check_erased_ecc_chunk() to gpmi-nand
to correct erased pages. To have the valid data in the buffer before
using them, this patch moves the read_page_swap_end() call before the
ECC status checking for-loop.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
[Squashed patches by Stefan and Boris to check ECC area]
Tested-by: Stefan Christ <s.christ@phytec.de>
Acked-by: Han xu <han.xu@nxp.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
2016-05-05 23:55:15 +02:00
Boris Brezillon
f05f6a10fb mtd: nand: gpmi: rely on generic DT parsing done in nand_scan_ident()
The core now takes care of parsing generic DT properties in
nand_scan_ident() when nand_set_flash_node() has been called.
Rely on this initialization instead of calling of_get_nand_xxx()
manually.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Han xu <han.xu@nxp.com>
2016-05-05 23:51:57 +02:00
Boris Brezillon
3f158e47df mtd: nand: gpmi: switch to mtd_ooblayout_ops
Implementing the mtd_ooblayout_ops interface is the new way of exposing
ECC/OOB layout to MTD users.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Han Xu <han.xu@nxp.com>
Tested-by: Han Xu <han.xu@nxp.com>
2016-05-05 23:51:43 +02:00
Boris Brezillon
191a82946a mtd: nand: gpmi: use mtd_ooblayout_xxx() helpers where appropriate
The mtd_ooblayout_xxx() helper functions have been added to avoid direct
accesses to the ecclayout field, and thus ease for future reworks.
Use these helpers in all places where the oobfree[] and eccpos[] arrays
where directly accessed.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
2016-04-19 22:05:50 +02:00
Han Xu
2cd395d13a mtd: gpmi: fix raw_buffer pointer double free issue
fix the raw_buffer pointer double free issue found by coverify.

CID 18344 (#2 of 2): Double free (USE_AFTER_FREE)
3. double_free: Calling gpmi_alloc_dma_buffer frees pointer
this->raw_buffer which has already been freed

Signed-off-by: Han Xu <han.xu@nxp.com>
Reviewed-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
2016-04-19 22:04:52 +02:00
Han Xu
b8b0e465dd mtd: nand: gpmi: may use minimum required ecc for 744 oobsize NAND
By default NAND driver will choose the highest ecc strength that oob
could contain, in this case, for some 8K+744 NAND flash, the ecc
strength will be up to 52bit, which beyonds the i.MX6QDL BCH capability
(40bit).

This patch allows the NAND driver try to use minimum required ecc
strength if it failed to use the highest ecc, even without explicitly
claiming "fsl,use-minimum-ecc" in dts.

Signed-off-by: Han Xu <b45815@freescale.com>
Acked-by: Huang Shijie <shijie.huang@arm.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2016-01-23 14:45:57 -08:00
Huang Shijie
026918e711 mtd: nand: gpmi: add gpmi dsm supend/resume support
i.MX6SX supports deep sleep mode(DSM) that may turn off GPMI/BCH power
during suspend, add gpmi nand suspend/resume function to release DMA
channel in suspend function and re-init GPMI/BCH controller during
resume function.

Although it is not necessary to restore GPMI/BCH registers value for
i.MX6QDL, the code doesn't distinguish different platforms to keep the
code simple.

Signed-off-by: Huang Shijie <b32955@freescale.com>
Signed-off-by: Han Xu <han.xu@freescale.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2016-01-23 14:45:57 -08:00
Boris BREZILLON
d699ed250c mtd: nand: make use of nand_set/get_controller_data() helpers
New helpers have been added to avoid directly accessing chip->field. Use
them where appropriate.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
[Brian: fixed a few rebase conflicts]
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2016-01-07 10:23:41 -08:00
Boris BREZILLON
37f5a54646 mtd: nand: remove useless mtd->priv = chip assignments
mtd_to_nand() now uses the container_of() approach to transform an
mtd_info pointer into a nand_chip one. Drop useless mtd->priv
assignments from NAND controller drivers.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-12-18 13:21:40 -08:00
Boris BREZILLON
2a690b25f6 mtd: nand: gpmi: use the mtd instance embedded in struct nand_chip
struct nand_chip now embeds an mtd device. Make use of this mtd instance.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-12-18 10:54:41 -08:00
Boris BREZILLON
4bd4ebcc54 mtd: nand: make use of mtd_to_nand() in NAND drivers
mtd_to_nand() was recently introduced to avoid direct accesses to the
mtd->priv field. Update all NAND drivers to use it.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-12-08 12:24:36 -08:00
Brian Norris
a61ae81a19 mtd: nand: drop unnecessary partition parser data
All of these drivers set up a parser data struct just to communicate DT
partition data. This field has been deprecated and is instead supported
by telling nand_scan_ident() about the 'flash_node'.

This patch:
 * sets chip->flash_node for those drivers that didn't already (but used
   OF partitioning)
 * drops the parser data
 * switches to the simpler mtd_device_register() where possible, now
   that we've eliminated one of the auxiliary parameters

Now that we've assigned chip->flash_node for these drivers, we can
probably rely on nand_dt_init() to do more of the DT parsing for us, but
for now, I don't want to fiddle with each of these drivers. The parsing
is done in duplicate for now on some drivers. I don't think this should
break things. (Famous last words.)

(Rolled in some changes by Boris Brezillon)

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
2015-11-11 13:58:45 -08:00
Boris BREZILLON
45aaeff947 mtd: nand: pass page number to ecc->write_xxx() methods
The ->read_xxx() methods are all passed the page number the NAND controller
is supposed to read, but ->write_xxx() do not have such a parameter.

This is a problem if we want to properly implement data
scrambling/randomization in order to mitigate MLC sensibility to repeated
pattern: to prevent bitflips in adjacent pages in the same block we need
to avoid repeating the same pattern at the same offset in those pages,
hence the randomizer/scrambler engine need to be passed the page value
in order to adapt its seed accordingly.

Moreover, adding the page parameter to the ->write_xxx() methods add some
consistency to the current API.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
CC: Josh Wu <josh.wu@atmel.com>
CC: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
CC: Maxime Ripard <maxime.ripard@free-electrons.com>
CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
CC: Huang Shijie <shijie.huang@arm.com>
CC: Stefan Agner <stefan@agner.ch>
CC: devel@driverdev.osuosl.org
CC: linux-arm-kernel@lists.infradead.org
CC: linux-kernel@vger.kernel.org
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-10-13 12:56:49 -07:00
Frans Klaver
4dc67b1d50 mtd: nand: gpmi-nand: show parent device in sysfs
Fix a bug where parent device symlinks aren't shown in sysfs.

While at it, make use of the default owner set by mtdcore.

Signed-off-by: Frans Klaver <fransklaver@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-10-13 12:56:31 -07:00
Fabio Estevam
899b834a46 mtd: nand: gpmi: Check for scan_bbt() error
In case of scan_bbt() failure, we should better propagate it.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Acked-by: Huang Shijie <shijie.huang@intel.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-03-30 18:27:47 -07:00
Nicholas Mc Guire
706d5b2899 mtd: nand: gpmi: fixup return type of wait_for_completion_timeout
return type of wait_for_completion_timeout is unsigned long not int. The
return variable is renamed to reflect its use and the type adjusted to
unsigned long.

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Huang Shijie <shijie.huang@intel.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2015-03-30 18:12:55 -07:00
Boris BREZILLON
c967360924 mtd: nand: gpmi: remove deprecated comment
Now that we have raw functions properly implemented we can remove this
FIXME.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Huang Shijie <shijie.huang@intel.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2014-12-22 12:58:24 -08:00
Fabio Estevam
41bed23b78 mtd: gpmi: Remove noisy error message
mx28evk board has a socket for NAND flash that comes with no NAND flash
populated, and then we get this message on every boot:

[    1.657603] gpmi-nand 8000c000.gpmi-nand: driver registration failed: -19

which is not very helpful, so get rid of this error message.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2014-12-22 12:58:24 -08:00
Boris BREZILLON
7ca94e07fe mtd: nand: gpmi: add raw oob access functions
Implement raw OOB access functions to retrieve OOB bytes when accessing the
NAND in raw mode.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Tested-by: Huang Shijie <shijie8@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2014-12-01 00:41:50 -08:00
Boris BREZILLON
da3bc42c1b mtd: nand: gpmi: add proper raw access support
Several MTD users (either in user or kernel space) expect a valid raw
access support to NAND chip devices.
This is particularly true for testing tools which are often touching the
data stored in a NAND chip in raw mode to artificially generate errors.

The GPMI drivers do not implemenent raw access functions, and thus rely on
default HW_ECC scheme implementation.
The default implementation consider the data and OOB area as properly
separated in their respective NAND section, which is not true for the GPMI
controller.
In this driver/controller some OOB data are stored at the beginning of the
NAND data area (these data are called metadata in the driver), then ECC
bytes are interleaved with data chunk (which is similar to the
HW_ECC_SYNDROME scheme), and eventually the remaining bytes are used as
OOB data.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Tested-by: Huang Shijie <shijie8@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2014-12-01 00:41:50 -08:00
Lothar Waßmann
2a500afe1e mtd: gpmi: make blockmark swapping optional
With a flash-based BBT there is no reason to move the Factory Bad
Block Marker from the data area buffer (to where it is mapped by the
GPMI NAND controller) to the OOB buffer. Thus, make this feature
configurable via DT. This is required for the Ka-Ro electronics
platforms.

In the original code 'this->swap_block_mark' was synonymous with
'!GPMI_IS_MX23()', so use the latter at the relevant places.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Acked-by: Huang Shijie <b32955@freescale.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2014-07-27 22:06:31 -07:00
Lothar Waßmann
d8c0372baa mtd: gpmi: remove line breaks from error messages and improve wording
Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2014-07-27 22:06:30 -07:00
Lothar Waßmann
6a7609662b mtd: gpmi: remove useless (void *) type casts and spaces between type casts and variables
Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2014-07-27 22:06:30 -07:00
Huang Shijie
91f5498ebf mtd: gpmi: add gpmi support for imx6sx
The gpmi's IP for imx6sx is nearly the same as the gpmi's IP for imx6q,
except the following two new features:

     (1) the new BCH contoller has 62-BIT correcting ECC strength
            (The BCH for imx6q only has 40-BIT ECC strength).

     (2) add the hardware Randomizer support.

This patch does the follow changes:

     (1) add a new macro GPMI_IS_MX6SX to represent the imx6sx's gpmi.

     (2) add a new macro GPMI_IS_MX6.
           We use this macro to initialize the same registers for both
         imx6sx and imx6q, and so on.

     (3) add a new gpmi_devdata instance, the gpmi_devdata_imx6sx, for
         imx6sx.

Signed-off-by: Huang Shijie <b32955@freescale.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2014-05-28 16:02:16 -07:00
Huang Shijie
6189cccbe8 mtd: gpmi: add gpmi_devdata{} to simplify the code
More and more chips use the GPMI controller, but these chips may use different
version of the IPs for GPMI and BCH. Different IPs have
 different features, such as the BCH's maximum ECC strength:

     imx23/imx28 -- the BCH's maximum ECC strength is 20
     imx6q       -- the BCH's maximum ECC strength is 40
     imx6sx      -- the BCH's maximum ECC strength is 62

This patch does the following things:

  [1] add a new data structure, gpmi_devdata{}, to store the information for
      each IP. Besides the IP version, we store the following information:
         <1> BCH's maximum ECC strength.
         <2> the maximum chain delay in ns used by the EDO mode.

      but we may add more information in future.

  [2] add the gpmi_devdata_imx{23|28|6q} to replace the gpmi_ids.

  [3] simplify the code by using the ECC strength from gpmi_devdata, such as
      gpmi_check_ecc() and legacy_set_geometry();

  [4] use the maximum chain delay to initialize the EDO mode,
      see gpmi_compute_edo_timing().

  [5] rewrite the macros, such GPMI_IS_MX{23|28|6Q}.

Signed-off-by: Huang Shijie <b32955@freescale.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2014-04-16 00:46:55 -07:00