platform/kernel/linux-rpi3.git
6 years agoMerge tag 'nand/for-4.17' of git://git.infradead.org/linux-mtd into mtd/next
Boris Brezillon [Wed, 4 Apr 2018 20:11:36 +0000 (22:11 +0200)]
Merge tag 'nand/for-4.17' of git://git.infradead.org/linux-mtd into mtd/next

Core changes:
* Prepare arrival of the SPI NAND subsystem by implementing a generic
  (interface-agnostic) layer to ease manipulation of NAND devices
* Move onenand code base to the drivers/mtd/nand/ dir
* Rework timing mode selection
* Provide a generic way for NAND chip drivers to flag a specific
  GET/SET FEATURE operation as supported/unsupported
* Stop embedding ONFI/JEDEC param page in nand_chip

Driver changes:
* Rework/cleanup of the mxc driver
* Various cleanups in the vf610 driver
* Migrate the fsmc and vf610 to ->exec_op()
* Get rid of the pxa driver (replaced by marvell_nand)
* Support ->setup_data_interface() in the GPMI driver
* Fix probe error path in several drivers
* Remove support for unused hw_syndrome mode in sunxi_nand
* Various minor improvements

6 years agoMerge tag 'spi-nor/for-4.17' of git://git.infradead.org/linux-mtd into mtd/next
Boris Brezillon [Wed, 4 Apr 2018 20:11:24 +0000 (22:11 +0200)]
Merge tag 'spi-nor/for-4.17' of git://git.infradead.org/linux-mtd into mtd/next

* Make fsl-quaspi assign different names to MTD devices connected
  to the same QSPI controller
* Remove an unneeded driver.bus assigned in the fsl-qspi driver

6 years agodt-bindings: fsl-quadspi: Add the example of two SPI NOR
Fabio Estevam [Fri, 26 Jan 2018 21:23:25 +0000 (19:23 -0200)]
dt-bindings: fsl-quadspi: Add the example of two SPI NOR

Improve the bindings example by adding an example of how to represent
two SPI NOR devices.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Acked-by: Han Xu <han.xu@nxp.com>
Signed-off-by: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: fsl-quadspi: Distinguish the mtd device names
Fabio Estevam [Fri, 26 Jan 2018 21:23:24 +0000 (19:23 -0200)]
mtd: fsl-quadspi: Distinguish the mtd device names

Currently on a imx6sx-sdb board, which has two SPI NOR chips connected
to QSPI2 the following output from /proc/mtd is seen:

dev:    size   erasesize  name
mtd0: 01000000 00010000 "21e4000.qspi"
mtd1: 01000000 00010000 "21e4000.qspi"

Attempts to partition them on the kernel command line result in both
chips with identical (and identically named) partitions, which is
an inconvenient behavior.

Assign a different mtd->name for each mtd device to avoid this problem.

After this change the output from /proc/mtd becomes:

dev:    size   erasesize  name
mtd0: 01000000 00010000 "21e4000.qspi-0"
mtd1: 01000000 00010000 "21e4000.qspi-1"

In order to keep mtdparts compatibility keep the mtd->name
unchanged when a single SPI NOR is present.

Reported-by: David Wolfe <david.wolfe@nxp.com>
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Han Xu <han.xu@nxp.com>
Signed-off-by: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: Fix some function description mismatches in core.c
Xiaolei Li [Thu, 29 Mar 2018 01:34:59 +0000 (09:34 +0800)]
mtd: nand: Fix some function description mismatches in core.c

In core.c, some function descriptions do not match function
definitions. Just fix these mismatches.

Signed-off-by: Xiaolei Li <xiaolei.li@mediatek.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: fsl-quadspi: Remove unneeded driver.bus assignment
Boris Brezillon [Wed, 14 Feb 2018 12:46:25 +0000 (13:46 +0100)]
mtd: fsl-quadspi: Remove unneeded driver.bus assignment

platform_driver_register() takes care of assigning driver->bus
to &platform_bus_type, no need to explicitly assign it in the driver.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Acked-by: Han Xu <han.xu@nxp.com>
Signed-off-by: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>
6 years agomtd: rawnand: marvell: Rename ->ecc_clk into ->core_clk
Boris Brezillon [Mon, 26 Mar 2018 09:53:01 +0000 (11:53 +0200)]
mtd: rawnand: marvell: Rename ->ecc_clk into ->core_clk

The core clock field was badly named ->ecc_clk which might lead to some
confusion. Rename it ->core_clk.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
6 years agomtd: rawnand: s3c2410: enhance the probe function error path
Miquel Raynal [Wed, 21 Mar 2018 13:01:57 +0000 (14:01 +0100)]
mtd: rawnand: s3c2410: enhance the probe function error path

Prepare the migration of the lpc32xx_slc driver to use nand_scan() by
cleaning the error path in the probe function.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: tango: fix probe function error path
Miquel Raynal [Wed, 21 Mar 2018 13:01:53 +0000 (14:01 +0100)]
mtd: rawnand: tango: fix probe function error path

An error after nand_scan_tail() should trigger a nand_cleanup().
The helper mtd_device_parse_register() returns an error code that should
be checked and nand_cleanup() called accordingly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: sh_flctl: fix the probe function error path
Miquel Raynal [Wed, 21 Mar 2018 13:01:52 +0000 (14:01 +0100)]
mtd: rawnand: sh_flctl: fix the probe function error path

An error after nand_scan_tail() should trigger a nand_cleanup().
The helper mtd_device_parse_register() returns an error code that should
be checked and nand_cleanup() called accordingly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: omap2: fix the probe function error path
Miquel Raynal [Wed, 21 Mar 2018 13:01:51 +0000 (14:01 +0100)]
mtd: rawnand: omap2: fix the probe function error path

An error after nand_scan_tail() should trigger a nand_cleanup().
The helper mtd_device_parse_register() returns an error code that should
be checked and nand_cleanup() called accordingly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: mxc: fix probe function error path
Miquel Raynal [Wed, 21 Mar 2018 13:01:50 +0000 (14:01 +0100)]
mtd: rawnand: mxc: fix probe function error path

An error after nand_scan_tail() should trigger a nand_cleanup().
The helper mtd_device_parse_register() returns an error code that should
be checked and nand_cleanup() called accordingly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: denali: fix probe function error path
Miquel Raynal [Wed, 21 Mar 2018 13:01:45 +0000 (14:01 +0100)]
mtd: rawnand: denali: fix probe function error path

An error after nand_scan_tail() should trigger a nand_cleanup().
The helper mtd_device_register() returns an error code that should
be checked and nand_cleanup() called accordingly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: davinci: fix probe function error path
Miquel Raynal [Wed, 21 Mar 2018 13:01:44 +0000 (14:01 +0100)]
mtd: rawnand: davinci: fix probe function error path

An error after nand_scan_tail() should trigger a nand_cleanup().
The helper mtd_device_register() returns an error code that should
be checked and nand_cleanup() called accordingly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: cafe: fix probe function error path
Miquel Raynal [Wed, 21 Mar 2018 13:01:43 +0000 (14:01 +0100)]
mtd: rawnand: cafe: fix probe function error path

An error after nand_scan_tail() should trigger a nand_cleanup().
The helper mtd_device_parse_register() returns an error code that should
be checked and nand_cleanup() called accordingly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: brcmnand: fix probe function error path
Miquel Raynal [Wed, 21 Mar 2018 13:01:42 +0000 (14:01 +0100)]
mtd: rawnand: brcmnand: fix probe function error path

An error after nand_scan_tail() should trigger a nand_cleanup().
The helper mtd_device_register() returns an error code that should
be checked and nand_cleanup() called accordingly.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: sunxi: Stop supporting ECC_HW_SYNDROME mode
Boris Brezillon [Wed, 21 Mar 2018 08:36:18 +0000 (09:36 +0100)]
mtd: rawnand: sunxi: Stop supporting ECC_HW_SYNDROME mode

This mode is not used by any existing setup and should not be used
because it overwrites the BBMs. Let's just remove it before someone
starts using it.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Tested-by: Miquel Raynal <miquel.raynal@bootlin.com>
6 years agomtd: rawnand: marvell: Fix clock resource by adding a register clock
Gregory CLEMENT [Tue, 13 Mar 2018 10:30:16 +0000 (11:30 +0100)]
mtd: rawnand: marvell: Fix clock resource by adding a register clock

On Armada 7K/8K we need to explicitly enable the register clock. This
clock is optional because not all the SoCs using this IP need it but at
least for Armada 7K/8K it is actually mandatory.

The binding documentation is updated accordingly.

Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: ftl: Use DIV_ROUND_UP()
Arushi Singhal [Sun, 25 Mar 2018 15:37:43 +0000 (21:07 +0530)]
mtd: ftl: Use DIV_ROUND_UP()

The kernel.h macro DIV_ROUND_UP performs the computation
(((n) + (d) - 1) / (d)) but is perhaps more readable.

Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: Fix some function description mismatches in mtdcore.c
Xiaolei Li [Thu, 29 Mar 2018 01:34:58 +0000 (09:34 +0800)]
mtd: Fix some function description mismatches in mtdcore.c

In mtdcore.c, some function descriptions do not match function
definitions. Just fix these mismatches.

Signed-off-by: Xiaolei Li <xiaolei.li@mediatek.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: physmap_of: update struct map_info's swap as per map requirement
Prabhakar Kushwaha [Wed, 28 Mar 2018 05:45:52 +0000 (11:15 +0530)]
mtd: physmap_of: update struct map_info's swap as per map requirement

It is not necessary for all device's maps to be CFI_HOST_ENDIAN.
Maps device can be Big endian or little endian.

Currently it is being taken care using CONFIG_MTD_CFI_LE_BYTE_SWAP or
CONFIG_MTD_CFI_BE_BYTE_SWAP i.e. compile time.

Now update struct map_info's swap field based on device characteristics
defined in device tree.

Signed-off-by: Jagdish Gediya <jagdish.gediya@nxp.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agodt-bindings: mtd-physmap: Add endianness supports
Prabhakar Kushwaha [Wed, 28 Mar 2018 05:44:43 +0000 (11:14 +0530)]
dt-bindings: mtd-physmap: Add endianness supports

Provide a way to specify the endianness to use when accessing a
memory-mapped flash.

Signed-off-by: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: update documentation of mtd_device_parse_register()
Rafał Miłecki [Tue, 27 Mar 2018 13:36:47 +0000 (15:36 +0200)]
mtd: update documentation of mtd_device_parse_register()

In the commit 2c77c57d22adb ("mtd: move code adding master MTD out of
mtd_add_device_partitions()") behavior of mtd_device_parse_register()
has very slightly changed. It's a pretty non-significant order change
to match updated function behavior.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Reviewed-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agoMAINTAINERS: update maintainers for MTD and SPI NOR subsystems
Cyrille Pitchen [Thu, 15 Mar 2018 19:04:38 +0000 (20:04 +0100)]
MAINTAINERS: update maintainers for MTD and SPI NOR subsystems

remove myself as MTD and SPI NOR maintainer.

Signed-off-by: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: jedec_probe: add Eon EN29LV400A IDs
Linus Walleij [Sat, 3 Mar 2018 22:31:45 +0000 (23:31 +0100)]
mtd: jedec_probe: add Eon EN29LV400A IDs

This adds the JEDEC IDs for Eon EN29LV400A variants
EN29LV400AB and EN29LV400AT. This chip is found in the
D-Link DNS-313.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: ofpart: add of_match_table with "fixed-partitions"
Rafał Miłecki [Wed, 14 Mar 2018 12:10:44 +0000 (13:10 +0100)]
mtd: ofpart: add of_match_table with "fixed-partitions"

This allows using this parser with any flash driver that takes care of
setting of_node (using mtd_set_of_node helper) correctly. Up to now
support for "fixed-partitions" DT compatibility string was working only
with flash drivers that were specifying "ofpart" (manually or by letting
mtd use the default set of parsers).

This matches existing bindings documentation.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Reviewed-by: Brian Norris <computersforpeace@gmail.com>
Tested-by: Brian Norris <computersforpeace@gmail.com>
Reviewed-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rename "ofpart" parser to "fixed-partitions" as it fits it better
Rafał Miłecki [Wed, 14 Mar 2018 12:10:43 +0000 (13:10 +0100)]
mtd: rename "ofpart" parser to "fixed-partitions" as it fits it better

Type "ofpart" means that OF should be used to get partitioning info and
this driver supports "fixed-partitions" binding only. Renaming it should
lead to less confusion especially when parsers for new compatibility
strings start to appear.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Reviewed-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: partitions: add of_match_table parser matching for the "ofpart" type
Rafał Miłecki [Wed, 14 Mar 2018 12:10:42 +0000 (13:10 +0100)]
mtd: partitions: add of_match_table parser matching for the "ofpart" type

In order to properly support compatibility strings as described in the
bindings/mtd/partition.txt "ofpart" type should be treated as an
indication for looking into OF. MTD should check "compatible" property
and search for a matching parser rather than blindly trying the one
supporting "fixed-partitions".

It also means that existing "fixed-partitions" parser should get renamed
to use a more meaningful name.

This commit achievies that aim by introducing a new mtd_part_of_parse().
It works by looking for a matching parser for every string in the
"compatibility" property (starting with the most specific one).

Please note that driver-specified parsers still take a precedence. It's
assumed that driver providing a parser type has a good reason for that
(e.g. having platform data with device-specific info). Also doing
otherwise could break existing setups. The same applies to using default
parsers (including "cmdlinepart") as some overwrite DT data with cmdline
argument.

Partition parsers can now provide an of_match_table to enable
flash<-->parser matching via device tree as documented in the
mtd/partition.txt.

This support is currently limited to built-in parsers as it uses
request_module() and friends. This should be sufficient for most cases
though as compiling parsers as modules isn't a common choice.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Tested-by: Peter Rosin <peda@axentia.se>
Reviewed-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: maps: remove bfin-async-flash driver
Arnd Bergmann [Wed, 14 Mar 2018 16:30:22 +0000 (17:30 +0100)]
mtd: maps: remove bfin-async-flash driver

The blackfin architecture is getting removed, so this driver
has become obsolete.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: tests: check erase block count in page test
Stefan Agner [Sat, 3 Mar 2018 22:26:22 +0000 (23:26 +0100)]
mtd: tests: check erase block count in page test

When there is only a single erase block, the cross erase test
does not report sensible errors. Warn in case there is only
a single erase block instead of executing the test.

Signed-off-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nftl: use %*ph to print small buffer
Antonio Cardace [Tue, 13 Feb 2018 17:52:45 +0000 (17:52 +0000)]
mtd: nftl: use %*ph to print small buffer

Use %*ph format to print small buffer as hex string.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Antonio Cardace <anto.cardace@gmail.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: Stop updating erase_info->state and calling mtd_erase_callback()
Boris Brezillon [Mon, 12 Feb 2018 21:03:11 +0000 (22:03 +0100)]
mtd: Stop updating erase_info->state and calling mtd_erase_callback()

MTD users are no longer checking erase_info->state to determine if the
erase operation failed or succeeded. Moreover, mtd_erase_callback() is
now a NOP.

We can safely get rid of all mtd_erase_callback() calls and all
erase_info->state assignments. While at it, get rid of the
erase_info->state field, all MTD_ERASE_XXX definitions and the
mtd_erase_callback() function.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Reviewed-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Bert Kenward <bkenward@solarflare.com>
---
Changes in v2:
- Address a few coding style issues (reported by Miquel)
- Remove comments that are no longer valid (reported by Miquel)

6 years agomtd: rawnand: gpmi: use core timings instead of an empirical derivation
Miquel Raynal [Fri, 2 Mar 2018 14:38:40 +0000 (15:38 +0100)]
mtd: rawnand: gpmi: use core timings instead of an empirical derivation

GPMI driver timings derivation looks very empirical and does not use
the known timings that the core wants to use with the NAND chip, by
using local defined constants that have no special meaning from the
outside world.

Simplify the way all of this is computed and use the NAND core's SDR
timings.

Integrity of the reads/writes has been checked with nandbiterrs, speed
improvements with flash_speed on a Freescale i.MX6 DualLite/Solo SABRE
Automotive Board. Measures are below, variations of less than 150kiB/s
between tests are common and then not significant. Speeds using mode 5
are the same, while speeds using mode 0 are quite improved (+40/50%
from non-optimal computation).

Forcing timings mode 0:

=======================

Before this patch:
------------------
eraseblock write speed is 2298 KiB/s
eraseblock read speed is 3636 KiB/s
page write speed is 2136 KiB/s
page read speed is 3316 KiB/s
2 page write speed is 2199 KiB/s
2 page read speed is 3468 KiB/s

After this patch:
-----------------
eraseblock write speed is 3232 KiB/s
eraseblock read speed is 5663 KiB/s
page write speed is 2915 KiB/s
page read speed is 4904 KiB/s
2 page write speed is 3084 KiB/s
2 page read speed is 5267 KiB/s

Forcing timings mode 5:
=======================

Before this patch:
------------------
eraseblock write speed is 4338 KiB/s
eraseblock read speed is 14883 KiB/s
page write speed is 3786 KiB/s
page read speed is 12800 KiB/s
2 page write speed is 4076 KiB/s
2 page read speed is 14065 KiB/s

After this patch:
-----------------
eraseblock write speed is 4309 KiB/s
eraseblock read speed is 14712 KiB/s
page write speed is 3764 KiB/s
page read speed is 12673 KiB/s
2 page write speed is 4076 KiB/s
2 page read speed is 14065 KiB/s

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: gpmi: support ->setup_data_interface()
Miquel Raynal [Fri, 2 Mar 2018 14:38:39 +0000 (15:38 +0100)]
mtd: rawnand: gpmi: support ->setup_data_interface()

Until now the GPMI driver had its own timings logic while the core
already handles that and request the NAND controller drivers to support
the ->setup_data_interface() hook. Implement that hook by reusing the
already existing function. No real glue is necessary between core timing
delays and GPMI registers because the driver already translates the
ONFI timing modes into register values.

Make use of the core's tREA, tRLOH and tRHOH values that allow computing
more precise timings for mode [0-3] and get significantly better values
(+20% with an i.MX6 Sabre Auto board). Otherwise use the existing logic.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Tested-by: Han Xu <han.xu@nxp.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: get rid of the ONFI parameter page in nand_chip
Miquel Raynal [Mon, 19 Mar 2018 13:47:31 +0000 (14:47 +0100)]
mtd: rawnand: get rid of the ONFI parameter page in nand_chip

The NAND chip parameter page is statically allocated within the
nand_chip structure, which reserves a lot of space. Even not ONFI nor
JEDEC chips have it embedded. Also, only a few parameters are actually
read from the parameter page after the detection.

Now that there is a small nand_parameters structure that hold all needed
ONFI parameters, remove the ONFI page from the nand_chip structure by
just allocating it during the identification phase and removing it right
after.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: get rid of the JEDEC parameter page in nand_chip
Miquel Raynal [Mon, 19 Mar 2018 13:47:30 +0000 (14:47 +0100)]
mtd: rawnand: get rid of the JEDEC parameter page in nand_chip

The NAND chip parameter page is statically allocated within the
nand_chip structure, which reserves a lot of space. Even not ONFI nor
JEDEC chips have it embedded. Also, only a few parameters are actually
read from the parameter page after the detection.

Now that there is a small nand_parameters structure that can held
generic parameters, remove the JEDEC page from the nand_chip structure
by just allocating it during the identification phase and removing it
right after.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: macronix: nack the support of changing timings for one chip
Miquel Raynal [Mon, 19 Mar 2018 13:47:29 +0000 (14:47 +0100)]
mtd: rawnand: macronix: nack the support of changing timings for one chip

The MX30LF2G18AC chip declares in its parameter page supporting
SET/GET_FEATURES but when it comes to timings, experience shows that it
is not the case.

Unflag this feature for this particular chip in the nand_parameters
structure to avoid unnecessary errors and downturns.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: allow vendors to declare (un)supported features
Miquel Raynal [Mon, 19 Mar 2018 13:47:28 +0000 (14:47 +0100)]
mtd: rawnand: allow vendors to declare (un)supported features

If SET/GET_FEATURES is available (from the parameter page), use a
bitmap to declare what feature is actually supported.

Initialize the bitmap in the core to support timing changes (only
feature used by the core), also add support for Micron specific features
used in Micron initialization code (in the init routine).

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: prepare the removal of the ONFI parameter page
Miquel Raynal [Mon, 19 Mar 2018 13:47:27 +0000 (14:47 +0100)]
mtd: rawnand: prepare the removal of the ONFI parameter page

The NAND chip parameter page is statically allocated within the
nand_chip structure, which reserves a lot of space. Even not ONFI nor
JEDEC chips have it embedded. Also, only a few parameters are actually
read from the parameter page after the detection.

ONFI-related parameters that will be used outside from the
identification function are stored in a separate onfi_parameters
structure embedded in nand_parameters, this small structure that
already hold generic parameters.

For now, the onfi_parameters structure is allocated statically. However,
after some deep rework in the NAND framework, it will be possible to do
dynamic allocations from the NAND identification phase, and this
strcuture will then be dynamically allocated when needed.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: prepare the removal of ONFI/JEDEC parameter pages
Miquel Raynal [Mon, 19 Mar 2018 13:47:26 +0000 (14:47 +0100)]
mtd: rawnand: prepare the removal of ONFI/JEDEC parameter pages

The NAND chip parameter page is statically allocated within the
nand_chip structure, which reserves a lot of space. Even not ONFI nor
JEDEC chips have it embedded. Also, only a few parameters are actually
read from the parameter page after the detection.

To prepare to the removal of such huge structure, a small NAND parameter
structure is allocated statically and contains only very few members
that are generic to all chips and actually used elsewhere in the code.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: avoid setting again the timings to mode 0 after a reset
Miquel Raynal [Mon, 19 Mar 2018 13:47:25 +0000 (14:47 +0100)]
mtd: rawnand: avoid setting again the timings to mode 0 after a reset

After a nand_reset_data_interface(), both the NAND chip and the NAND
controller use timing mode 0. The previously defined data interface for
this chip has been saved and is supposed to be restored after that.
However, if the saved data interface also refers to timing mode 0, there
is no need to re-apply them again.

Also, as nand_setup_data_interface() uses ->set/get_features(), it could
lead to issues when doing the reset at probe time as the parameter page
is not available yet to know if these functions are supported or not.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: check ONFI timings have been acked by the chip
Miquel Raynal [Mon, 19 Mar 2018 13:47:24 +0000 (14:47 +0100)]
mtd: rawnand: check ONFI timings have been acked by the chip

Choosing ONFI timings when ->set/get_features() calls are supported
by the NAND chip is a matter of reading the chip's ONFI parameter page
and telling the chip the chosen mode (between all of the supported ones)
with ->set_feature().

Add a check on whether the chip "acked" the timing mode or not.

This can be a problem for NAND chips that do not follow entirely the
ONFI specification. These chips actually support other modes than
"mode 0", but either:
1/ do not update the timing mode register once a timing mode has been
   selected.
or
2/ do not support the TIMING_MODE featured and thus do not require users
   to change the timing mode at all.

These issues will be addressed in another patch that will add the
feature to overwrite NAND chips features within the parameter page, from
the NAND chip driver.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Tested-by: Han Xu <han.xu@nxp.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: move calls to ->select_chip() in nand_setup_data_interface()
Miquel Raynal [Mon, 19 Mar 2018 13:47:23 +0000 (14:47 +0100)]
mtd: rawnand: move calls to ->select_chip() in nand_setup_data_interface()

After a ->set_features(TIMINGS), the chip is supposed to be working at a
new speed. In order for all the transactions to be perperly handled, the
NAND controller should also be configured to this same speed. Calling
->setup_data_interface() is not enough and the chip should be
de-asserted/re-asserted through calls to ->select_chip().

Prepare the next change in nand_setup_data_interface() where timings
will be checked after being applied. Because assertions of the CS pin
will be needed from within this function, move the calls to
->select_chip() inside nand_setup_data_interface() for later
consistency.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: mxc: remove useless checks in GET/SET_FEATURES functions
Miquel Raynal [Mon, 19 Mar 2018 13:47:22 +0000 (14:47 +0100)]
mtd: rawnand: mxc: remove useless checks in GET/SET_FEATURES functions

All the calls to the chip's hooks ->get/set_features() go through
the core's wrappers nand_get/set_features() that already do the
necessary checks about feature support. Remove these
checks from the mxc's functions.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: handle differently chip/controller errors about timings
Miquel Raynal [Mon, 19 Mar 2018 13:47:21 +0000 (14:47 +0100)]
mtd: rawnand: handle differently chip/controller errors about timings

Usually, the source of the error when setting/getting features does not
matter (if the controller does not support sending the command or if
the chip does not support the operation).

When it comes to timings, if the controller fails it is an error while
if the chip does not support the operation, it can be silently supposed
that it already works with the maximum supported timings.

Introduce some logic in nand_setup_data_interface() to handle that
difference.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: use wrappers to call onfi GET/SET_FEATURES
Miquel Raynal [Mon, 19 Mar 2018 13:47:20 +0000 (14:47 +0100)]
mtd: rawnand: use wrappers to call onfi GET/SET_FEATURES

Prepare the fact that some features managed by GET/SET_FEATURES could be
overloaded by vendor code. To handle this logic, use new wrappers
instead of directly call the ->get/set_features() hooks.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: rename SET/GET FEATURES related functions
Miquel Raynal [Mon, 19 Mar 2018 13:47:19 +0000 (14:47 +0100)]
mtd: rawnand: rename SET/GET FEATURES related functions

SET/GET FEATURES are flagged ONFI-compliant because of their name. This
is not accurate as non-ONFI NAND chips support it and use it.

Rename the hooks and helpers to remove the "onfi" prefix.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: rename default ->onfi_get/set_features() implementations
Miquel Raynal [Mon, 19 Mar 2018 13:47:18 +0000 (14:47 +0100)]
mtd: rawnand: rename default ->onfi_get/set_features() implementations

Prepare future work on the ->onfi_get/set_features() hooks by renaming
the core's implementation as 'default' ones.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: makes the Kconfig entry clear when it comes to raw NANDs
Miquel Raynal [Mon, 19 Mar 2018 09:21:58 +0000 (10:21 +0100)]
mtd: rawnand: makes the Kconfig entry clear when it comes to raw NANDs

Files have been moved in the NAND subsystem to reflect the different
flavors of NAND devices.

Raw/Parallel NAND devices have been moved to a "raw" subdirectory to
make the difference with OneNAND and SPI NAND for instance. So adjust
the Kconfig entry to clarify things.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: remove bf5xx_nand driver
Arnd Bergmann [Wed, 14 Mar 2018 16:30:23 +0000 (17:30 +0100)]
mtd: rawnand: remove bf5xx_nand driver

The blackfin architecture is getting removed, so this driver has
become obsolete.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: vf610_nfc: support ONFI SET/GET_FEATURES commands
Stefan Agner [Fri, 9 Mar 2018 14:50:38 +0000 (15:50 +0100)]
mtd: rawnand: vf610_nfc: support ONFI SET/GET_FEATURES commands

With the move to ->exec_op() the driver should now support ONFI
SET/GET_FEATURES commands.

Signed-off-by: Stefan Agner <stefan@agner.ch>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: vf610_nfc: remove old hooks
Stefan Agner [Fri, 9 Mar 2018 14:50:37 +0000 (15:50 +0100)]
mtd: rawnand: vf610_nfc: remove old hooks

Now that the driver is using ->exec_op(), remove the old
hooks.

Signed-off-by: Stefan Agner <stefan@agner.ch>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: vf610_nfc: make use of ->exec_op()
Stefan Agner [Fri, 9 Mar 2018 14:50:36 +0000 (15:50 +0100)]
mtd: rawnand: vf610_nfc: make use of ->exec_op()

This reworks the driver to make use of ->exec_op() callback. The
command sequencer of the VF610 NFC aligns well with the new ops
interface.

The operations are translated to a NFC command code while filling
the necessary registers. Instead of using the special status and
read ID command codes (which require to read status/ID from
special registers instead of the regular data area) the driver
now now uses the main data buffer for all commands. This
simplifies the driver as no special casing is needed.

For control data (status byte, id bytes and parameter page) the
driver needs to reverse byte order for little endian CPUs since
the controller seems to store the bytes in big endian order in
the data buffer.

The current state seems to pass MTD tests on a Colibri VF61.

Signed-off-by: Stefan Agner <stefan@agner.ch>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: Unconditionally update ->fail_addr and ->addr in part_erase()
Boris Brezillon [Mon, 12 Feb 2018 21:03:10 +0000 (22:03 +0100)]
mtd: Unconditionally update ->fail_addr and ->addr in part_erase()

->fail_addr and ->addr can be updated no matter the result of
parent->_erase(), we just need to remove the code doing the same thing
in mtd_erase_callback() to avoid adjusting those fields twice.

Note that this can be done because all MTD users have been converted to
not pass an erase_info->callback() and are thus only taking the
->addr_fail and ->addr fields into account after part_erase() has
returned.

While we're at it, get rid of the erase_info->mtd field which was only
needed to let mtd_erase_callback() get the partition device back.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Reviewed-by: Richard Weinberger <richard@nod.at>
6 years agomtd: Stop assuming mtd_erase() is asynchronous
Boris Brezillon [Mon, 12 Feb 2018 21:03:09 +0000 (22:03 +0100)]
mtd: Stop assuming mtd_erase() is asynchronous

None of the mtd->_erase() implementations work in an asynchronous manner,
so let's simplify MTD users that call mtd_erase(). All they need to do
is check the value returned by mtd_erase() and assume that != 0 means
failure.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Reviewed-by: Richard Weinberger <richard@nod.at>
6 years agomtd: Get rid of unused fields in struct erase_info
Boris Brezillon [Mon, 12 Feb 2018 21:03:08 +0000 (22:03 +0100)]
mtd: Get rid of unused fields in struct erase_info

Some fields are not used by MTD drivers, users or core code. Moreover,
those fields are not documented, so get rid of them to avoid any
confusion.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Reviewed-by: Richard Weinberger <richard@nod.at>
6 years agomtd: Initialize ->fail_addr early in mtd_erase()
Boris Brezillon [Mon, 12 Feb 2018 21:03:07 +0000 (22:03 +0100)]
mtd: Initialize ->fail_addr early in mtd_erase()

mtd_erase() can return an error before ->fail_addr is initialized to
MTD_FAIL_ADDR_UNKNOWN. Move this initialization at the very beginning
of the function.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Reviewed-by: Richard Weinberger <richard@nod.at>
6 years agomtd: st_spi_fsm: use %*ph to print small buffer
Antonio Cardace [Mon, 12 Feb 2018 18:41:30 +0000 (18:41 +0000)]
mtd: st_spi_fsm: use %*ph to print small buffer

Use %*ph format to print small buffer as hex string.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Antonio Cardace <anto.cardace@gmail.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: block2mtd: remove redundant initialization of 'bdev'
Colin Ian King [Sat, 20 Jan 2018 22:09:34 +0000 (22:09 +0000)]
mtd: block2mtd: remove redundant initialization of 'bdev'

Pointer bdev is being initialized however this value is never
read as bdev is assigned an updated value from the returned
call to blkdev_get_by_path.  Remove the redundant assignment.

Cleans up clang warning:
drivers/mtd/devices/block2mtd.c:228:23: warning: Value stored to
'bdev' during its initialization is never read

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: remove STANDALONE compile mode of nand_ecc
Masahiro Yamada [Fri, 9 Mar 2018 13:03:52 +0000 (22:03 +0900)]
mtd: rawnand: remove STANDALONE compile mode of nand_ecc

This file can not be built independently any more.  We would have to
bring in more to resolve mtd_to_nand(mtd)->ecc.size, for example.

It is difficult to notice a breakage since nobody compiles this mode.
It is not worth fixing or maintaining in my opinion.  Remove.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: rawnand: Replace printk() with appropriate pr_*() macro
Shreeya Patel [Thu, 22 Feb 2018 16:31:22 +0000 (22:01 +0530)]
mtd: rawnand: Replace printk() with appropriate pr_*() macro

Using pr_<loglevel>() is more concise than printk(KERN_<LOGLEVEL>).
Replace printks having a log level with the appropriate pr_*() macros.
Define pr_fmt() and remove other additional macros from the replaced
printks.

Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: Move onenand code base to drivers/mtd/nand/onenand
Boris Brezillon [Sun, 18 Feb 2018 16:05:16 +0000 (17:05 +0100)]
mtd: Move onenand code base to drivers/mtd/nand/onenand

Move onenand code base to the drivers/mtd/nand directory in the hope
that someday someone will patch it to use the generic NAND helpers.
If it never happens, at least we'll have all NAND related support in a
single directory and not spread over the drivers/mtd/ directory.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: onenand: Get rid of comments giving the file path inside the file itself
Boris Brezillon [Sun, 18 Feb 2018 16:05:15 +0000 (17:05 +0100)]
mtd: onenand: Get rid of comments giving the file path inside the file itself

Some files add a comment giving the path of the file inside the Linux
tree, which is pretty useless since the reader had to find the file to
open it.

Getting rid of these comments will also allow us to easily move these
files around when needed.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agoMerge tag 'nand/pxa3xx-removal' of git://git.infradead.org/linux-mtd into nand/next
Boris Brezillon [Fri, 2 Mar 2018 21:57:43 +0000 (22:57 +0100)]
Merge tag 'nand/pxa3xx-removal' of git://git.infradead.org/linux-mtd into nand/next

Remove the pxa3xx_nand driver (replaced by marvell_nand).

6 years agoMAINTAINERS: remove entry for deleted pxa3xx_nand driver
Miquel Raynal [Mon, 19 Feb 2018 22:35:57 +0000 (23:35 +0100)]
MAINTAINERS: remove entry for deleted pxa3xx_nand driver

The driver pxa3xx_nand.c has been replaced everywhere by its rework
called marvell_nand.c so this entry can now be removed.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agoarm: dts: pxa: use reworked NAND controller driver
Miquel Raynal [Mon, 19 Feb 2018 22:35:56 +0000 (23:35 +0100)]
arm: dts: pxa: use reworked NAND controller driver

Use the new bindings of the reworked Marvell NAND controller driver.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agodt-bindings: mtd: remove pxa3xx NAND controller documentation
Miquel Raynal [Mon, 19 Feb 2018 22:35:55 +0000 (23:35 +0100)]
dt-bindings: mtd: remove pxa3xx NAND controller documentation

The deprecated pxa3xx_nand.c driver does not exist anymore, it has been
replaced by marvell_nand.c which has its own up-to-date documentation.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Tested-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: remove useless fields from pxa3xx NAND platform data
Miquel Raynal [Mon, 19 Feb 2018 22:35:54 +0000 (23:35 +0100)]
mtd: nand: remove useless fields from pxa3xx NAND platform data

The "enable arbiter" bit is available only for pxa3xx based platforms
but it was experimentally shown that even if this bit is reserved,
some Marvell platforms (64-bit) actually need it to be set. The driver
always set this bit regardless of this property, which is harmless.
Then this property is not needed.

The "num_cs" field is always 1 and for a good reason, the old driver
(pxa3xx_nand.c) could only handle one. The new driver that replaces it
(marvell_nand.c) can handle more, but better use device tree for such
description. As there is only one available chip select, there is no
need for an array of partitions neither an array of partition numbers.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: remove deprecated pxa3xx_nand driver
Miquel Raynal [Mon, 19 Feb 2018 22:35:53 +0000 (23:35 +0100)]
mtd: nand: remove deprecated pxa3xx_nand driver

All board files and defconfig files have been moved to use the new
marvell_nand driver instead of pxa3xx_nand, so we can safely remove this
file now. People should use the new driver which is supposed to behave
exactly like the old one.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: use Marvell reworked NAND controller driver with all platforms
Miquel Raynal [Mon, 19 Feb 2018 22:35:52 +0000 (23:35 +0100)]
mtd: nand: use Marvell reworked NAND controller driver with all platforms

Compile marvell_nand.c instead of pxa3xx_nand.c with all PXA based SoCs.
Convert all board files and defconfigs so that the new driver is used
everywhere instead of the old one.

Board files using CONFIG_MTD_NAND_PXA3xx now use CONFIG_MTD_NAND_MARVELL
instead.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Tested-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agoUpdate Boris Brezillon email address
Boris Brezillon [Fri, 16 Feb 2018 10:44:49 +0000 (11:44 +0100)]
Update Boris Brezillon email address

Free Electrons is now Bootlin.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agoMAINTAINERS: Update email address for Miquel Raynal
Miquel Raynal [Mon, 19 Feb 2018 22:57:59 +0000 (23:57 +0100)]
MAINTAINERS: Update email address for Miquel Raynal

Free Electrons is now Bootlin.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: fsmc: use ->exec_op()
Miquel Raynal [Fri, 16 Feb 2018 14:22:48 +0000 (15:22 +0100)]
mtd: nand: fsmc: use ->exec_op()

Remove the deprecated ->cmd_ctrl() implementation to use ->exec_op() in
the fsmc_nand driver.

Implement the ->select_chip() hook to avoid having to support the hack
from the core that send a NAND_CMD_NONE with NAND_NCE to signal a
deassertion of nCE.

Also get rid of the last references to ->IO_ADDR_[R|W] that are not used
anymore.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: fsmc: get rid of IO_ADDR_[R|W]
Miquel Raynal [Fri, 16 Feb 2018 14:22:47 +0000 (15:22 +0100)]
mtd: nand: fsmc: get rid of IO_ADDR_[R|W]

Remove the use of IO_ADDR_[R|W] in the fsmc_nand driver. Instead, use a
pointer to the control registers to avoid doing several arithmetic
operations (including a multiplication) each time a control register is
read or written.

All references to IO_ADDR_[R|W] are not entirely removed from the driver
as, at this time, these values are needed by the NAND core in the
default ->read/write_byte/word() hooks. These references will be
entirely removed when switching to ->exec_op(), that does not make use
of these hooks anymore.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: Add core infrastructure to deal with NAND devices
Boris Brezillon [Mon, 5 Feb 2018 22:02:05 +0000 (23:02 +0100)]
mtd: nand: Add core infrastructure to deal with NAND devices

Add an intermediate layer to abstract NAND device interface so that
some logic can be shared between SPI NANDs, parallel/raw NANDs,
OneNANDs, ...

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: move raw NAND related code to the raw/ subdir
Boris Brezillon [Mon, 5 Feb 2018 22:02:04 +0000 (23:02 +0100)]
mtd: nand: move raw NAND related code to the raw/ subdir

As part of the process of sharing more code between different NAND
based devices, we need to move all raw NAND related code to the raw/
subdirectory.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: Add missing copyright information
Boris Brezillon [Mon, 5 Feb 2018 22:02:03 +0000 (23:02 +0100)]
mtd: nand: Add missing copyright information

Some drivers have been derived from others which have then been removed
from the source tree. When this is the case, add mention the copyright
of the source file(s) they've been derived from.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: State when references to other drivers are no longer valid
Boris Brezillon [Mon, 5 Feb 2018 22:02:02 +0000 (23:02 +0100)]
mtd: nand: State when references to other drivers are no longer valid

A lot of NAND drivers have been derived from other old NAND drivers
which have since then been removed from the Linux tree. When this is
the case, specify when the file the header is referring to has been
removed so that people can find the original implementation more
easily.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: ams-delta: Fix path to toto.c source file
Boris Brezillon [Mon, 5 Feb 2018 22:02:01 +0000 (23:02 +0100)]
mtd: nand: ams-delta: Fix path to toto.c source file

Last known location of toto.c was drivers/mtd/nand/toto.c. Fix the
path so that one can use git log to find when the driver was deleted
and possibly checkout the source code.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: Stop using full path when referring to files placed in the same dir
Boris Brezillon [Mon, 5 Feb 2018 22:02:00 +0000 (23:02 +0100)]
mtd: nand: Stop using full path when referring to files placed in the same dir

Some NAND drivers are derived from other NAND drivers and state it in
their license header. Using full path to point to other driver files
sitting in the same directory is not such a good idea, since the NAND
drivers might be moved to a different directory at some point, and we
don't to patch all license/copyright headers everytime this happen.

The only exception where we keep full path is when the referred source
files no longer exist in the tree.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: Get rid of comments giving the file path inside the file itself
Boris Brezillon [Mon, 5 Feb 2018 22:01:59 +0000 (23:01 +0100)]
mtd: nand: Get rid of comments giving the file path inside the file itself

Some files add a comment giving the path of the file inside the Linux
tree, which is pretty useless since the reader had to find the file to
open it.

Getting rid of these comments will also allow us to easily move these
files around when needed.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: toshiba: Retrieve ECC requirements from extended ID
KOBAYASHI Yoshitake [Wed, 14 Feb 2018 15:35:06 +0000 (00:35 +0900)]
mtd: nand: toshiba: Retrieve ECC requirements from extended ID

This patch enables support to read the ECC strength and size from the
NAND flash using Toshiba Memory SLC NAND extended-ID. This patch is
based on the information of the 6th ID byte of the Toshiba Memory SLC
NAND.

Signed-off-by: KOBAYASHI Yoshitake <yoshitake.kobayashi@toshiba.co.jp>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: vf610: check mtd_device_register() return code
Alexey Khoroshilov [Fri, 9 Feb 2018 22:28:36 +0000 (01:28 +0300)]
mtd: nand: vf610: check mtd_device_register() return code

vf610_nfc_probe() misses error handling of mtd_device_register().

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Reviewed-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: vf610: improve readability of error label
Alexey Khoroshilov [Fri, 9 Feb 2018 22:28:35 +0000 (01:28 +0300)]
mtd: nand: vf610: improve readability of error label

Use clearer error labels as Boris Brezillon suggested.

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Reviewed-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: vf610: remove the unnecessary of_node_put()
Alexey Khoroshilov [Fri, 9 Feb 2018 22:28:34 +0000 (01:28 +0300)]
mtd: nand: vf610: remove the unnecessary of_node_put()

Calling of_node_put() in vf610_nfc_probe() is wrong because nothing in
this code retains a reference to the DT node.

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Reviewed-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: vf610_nfc: remove unused function
Stefan Agner [Thu, 8 Feb 2018 23:59:19 +0000 (00:59 +0100)]
mtd: nand: vf610_nfc: remove unused function

The function count_written_bits has been replaced by the generic
nand_check_erased_ecc_chunk() function with commit 48c25cf44118
("mtd: nand: vf610_nfc: use nand_check_erased_ecc_chunk() helper").
Remove the unused function.

Signed-off-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: add ->setup_data_interface() support for Marvell NFCv1
Miquel Raynal [Tue, 16 Jan 2018 23:19:34 +0000 (00:19 +0100)]
mtd: nand: add ->setup_data_interface() support for Marvell NFCv1

First generation of Marvell NAND flash controllers (eg. embedded in PXA
boards) did not make use of the NAND core hook ->setup_data_interface()
to setup controller timings. Add support for it.

Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: mxc: remove now unused code
Sascha Hauer [Wed, 17 Jan 2018 11:32:13 +0000 (12:32 +0100)]
mtd: nand: mxc: remove now unused code

Since we now have our own read_page/write_page functions
mxc_nand_command() will no longer be called with NAND_CMD_READ0,
NAND_CMD_READOOB, NAND_CMD_SEQIN and NAND_CMD_PAGEPROG. Remove
the code handling these commands.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: mxc: Drop now unnecessary functions
Sascha Hauer [Wed, 17 Jan 2018 11:32:12 +0000 (12:32 +0100)]
mtd: nand: mxc: Drop now unnecessary functions

Since we have our own read_page/write_page functions correct_data and
calculate are no longer needed. Remove them.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: mxc: Add own write_page
Sascha Hauer [Wed, 17 Jan 2018 11:32:11 +0000 (12:32 +0100)]
mtd: nand: mxc: Add own write_page

Now that we have our own read_page function add a write_page function
for consistency aswell. This can be a lot easier than the generic
function since we do not have to iterate over subpages but can write
the whole page at once. Also add write_page_raw and write_oob for
proper raw and oob write support.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: mxc: Fix failed/corrected values for v1 controllers
Sascha Hauer [Wed, 17 Jan 2018 11:32:10 +0000 (12:32 +0100)]
mtd: nand: mxc: Fix failed/corrected values for v1 controllers

The v1 controller code has several flaws:
- We do not forward the number of corrected bitflips to the upper layers
- For 2k page NAND chips only the status results from the fourth subpage
  read are evaluated, so ECC failures in the other subpages remain
  uncovered
- When there are uncorrectable errors we have to increase the statistics
  counter, but still have to return successfully. Currently we return
  an error

This patch fixes this by introducing a v1 specific read_page function.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: mxc: Fix failed/corrected values for v2/v3 controllers
Sascha Hauer [Wed, 17 Jan 2018 11:32:09 +0000 (12:32 +0100)]
mtd: nand: mxc: Fix failed/corrected values for v2/v3 controllers

Currently nand_read_page_hwecc() from nand_base calls
mxc_nand_correct_data_v2_v3() for each subpage, but in this function we
return the corrected/failed results for the whole page instead
of a single subpage. On a 2k page size Nand this leads to results which
are 4 times too high.
The whole ecc.calculate/ecc.correct mechanism used by
nand_read_page_hwecc() is not suitable for devices which correct the
data in hardware, so fix this by using a driver specific read_page
function which does the right thing. Also add read_page_raw and read_oob
For proper raw and oob read support.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: mxc: Add buffer argument to copy_spare
Sascha Hauer [Wed, 17 Jan 2018 11:32:08 +0000 (12:32 +0100)]
mtd: nand: mxc: Add buffer argument to copy_spare

With following patches we will have to copy the spare data to/from
other buffers, so add the buffer as argument to copy_spare().

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: mxc: Add function to control hardware ECC
Sascha Hauer [Wed, 17 Jan 2018 11:32:07 +0000 (12:32 +0100)]
mtd: nand: mxc: Add function to control hardware ECC

For proper raw read/write support need to be able to control the
hardware ECC engine. Add a function to enable/disable it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: nand: mxc: reorder functions to avoid forward declarations
Sascha Hauer [Wed, 17 Jan 2018 11:32:06 +0000 (12:32 +0100)]
mtd: nand: mxc: reorder functions to avoid forward declarations

We'll call copy_spare() and mxc_do_addr_cycle() from another place
during the next patches, so move functions up to avoid forward
declarations.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: get rid of the mtd_add_device_partitions()
Rafał Miłecki [Tue, 16 Jan 2018 15:45:42 +0000 (16:45 +0100)]
mtd: get rid of the mtd_add_device_partitions()

This simplifies code a bit by:
1) Avoiding an extra (tiny) function
2) Checking for amount of parsed (found) partitions just once
3) Avoiding clearing/filling struct mtd_partitions manually

With this commit proper functions are called directly from the
mtd_device_parse_register(). It doesn't need to use minor tricks like
memsetting struct to 0 to trigger an expected
mtd_add_device_partitions() behavior.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: move code adding master MTD out of mtd_add_device_partitions()
Rafał Miłecki [Tue, 16 Jan 2018 15:45:41 +0000 (16:45 +0100)]
mtd: move code adding master MTD out of mtd_add_device_partitions()

This change is a small cleanup of mtd_device_parse_register(). When
using MTD_PARTITIONED_MASTER it makes sure a master MTD is registered
before dealing with partitions. The advantage of this is not mixing
code handling master MTD with code handling partitions.

This commit doesn't change any behavior except from a slightly different
failure code path. The new code may need to call del_mtd_device when
something goes wrong.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agomtd: Make sure the device supports erase operations in mtd_erase()
Boris Brezillon [Mon, 22 Jan 2018 09:38:01 +0000 (10:38 +0100)]
mtd: Make sure the device supports erase operations in mtd_erase()

Some devices do not implement ->_erase() or have an invalid ->erasesize
value. In this case, mtd_erase() should return -ENOTSUPP.

Note that the test is not done on the MTD_NO_ERASE flag because this
flag means 'erasing a block before writing to it is unnecessary',
not 'the erase operation is not supported'. Actually, some drivers are
setting the MTD_NO_ERASE flag but still implementing the ->_erase()
hook and setting a valid ->erasesize value.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Reviewed-by: Miquel Raynal <miquel.raynal@free-electrons.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
6 years agoLinux 4.16-rc1
Linus Torvalds [Sun, 11 Feb 2018 23:04:29 +0000 (15:04 -0800)]
Linux 4.16-rc1

6 years agounify {de,}mangle_poll(), get rid of kernel-side POLL...
Al Viro [Thu, 1 Feb 2018 20:13:18 +0000 (15:13 -0500)]
unify {de,}mangle_poll(), get rid of kernel-side POLL...

except, again, POLLFREE and POLL_BUSY_LOOP.

With this, we finally get to the promised end result:

 - POLL{IN,OUT,...} are plain integers and *not* in __poll_t, so any
   stray instances of ->poll() still using those will be caught by
   sparse.

 - eventpoll.c and select.c warning-free wrt __poll_t

 - no more kernel-side definitions of POLL... - userland ones are
   visible through the entire kernel (and used pretty much only for
   mangle/demangle)

 - same behavior as after the first series (i.e. sparc et.al. epoll(2)
   working correctly).

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>