]> Pileus Git - ~andy/linux/log
~andy/linux
10 years agomtd: bcm47xxsflash: writing support
Rafał Miłecki [Wed, 22 May 2013 12:39:02 +0000 (14:39 +0200)]
mtd: bcm47xxsflash: writing support

Tested with BCM4706.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: bcm47xxsflash: implement erasing support
Rafał Miłecki [Tue, 21 May 2013 19:03:46 +0000 (21:03 +0200)]
mtd: bcm47xxsflash: implement erasing support

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: bcm47xxsflash: convert to module_platform_driver instead of init/exit
Libo Chen [Thu, 30 May 2013 02:22:16 +0000 (10:22 +0800)]
mtd: bcm47xxsflash: convert to module_platform_driver instead of init/exit

convert to module_platform_driver instead of init/exit

Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Libo chen <libo.chen@huawei.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: bcm47xxsflash: convert kzalloc to avoid invalid access
Libo Chen [Thu, 30 May 2013 02:22:12 +0000 (10:22 +0800)]
mtd: bcm47xxsflash: convert kzalloc to avoid invalid access

mtd is just member of bcm47xxsflash, so we should free bcm47xxsflash not
its member. So I use devm_kazlloc instead of kazlloc to avoid it.

* Changelog:
   convert to devm_kzalloc

Signed-off-by: Libo chen <libo.chen@huawei.com>
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
[Brian: fixed conflicts]
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: remove alauda driver
Jussi Kivilinna [Tue, 6 Aug 2013 12:03:29 +0000 (15:03 +0300)]
mtd: remove alauda driver

The driver has very low utility.  Devices in question are limited to
about 400kB/s and the only known user (me) discarded the hardware
several years back.

Signed-off-by: Joern Engel <joern@logfs.org>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: mxc_nand: mark 'const' properly
Jingoo Han [Wed, 7 Aug 2013 07:18:52 +0000 (16:18 +0900)]
mtd: nand: mxc_nand: mark 'const' properly

The values pointed by the pointer are used as read-only.
Also, mtd_device_parse_register() uses 'part_probes[]' as
the second argument which is defined as 'const char * const *types'.
Thus, the 'const' should be moved to be after the '*'.

drivers/mtd/nand/mxc_nand.c:269:25: warning: duplicate const

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: maps: cfi_flagadm: add missing __iomem annotation
Jingoo Han [Wed, 7 Aug 2013 07:17:29 +0000 (16:17 +0900)]
mtd: maps: cfi_flagadm: add missing __iomem annotation

Added missing __iomem annotation and staticized local symbols
in order to fix the following sparse warnings:

drivers/mtd/maps/cfi_flagadm.c:58:17: warning: symbol 'flagadm_map' was not declared. Should it be static?
drivers/mtd/maps/cfi_flagadm.c:64:22: warning: symbol 'flagadm_parts' was not declared. Should it be static?
drivers/mtd/maps/cfi_flagadm.c:115:18: warning: cast removes address space of expression
drivers/mtd/maps/cfi_flagadm.c:115:18: warning: incorrect type in argument 1 (different address spaces)
drivers/mtd/maps/cfi_flagadm.c:115:18:    expected void volatile [noderef] <asn:2>*addr
drivers/mtd/maps/cfi_flagadm.c:115:18:    got void *<noident>
drivers/mtd/maps/cfi_flagadm.c:126:26: warning: cast removes address space of expression
drivers/mtd/maps/cfi_flagadm.c:126:26: warning: incorrect type in argument 1 (different address spaces)
drivers/mtd/maps/cfi_flagadm.c:126:26:    expected void volatile [noderef] <asn:2>*addr
drivers/mtd/maps/cfi_flagadm.c:126:26:    got void *<noident>
drivers/mtd/maps/cfi_flagadm.c:127:36: warning: Using plain integer as NULL pointer

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: spear_smi: add missing __iomem annotation
Jingoo Han [Wed, 7 Aug 2013 07:16:36 +0000 (16:16 +0900)]
mtd: spear_smi: add missing __iomem annotation

Added missing __iomem annotation in order to fix the following
sparse warnings:

drivers/mtd/devices/spear_smi.c:566:13: warning: incorrect type in assignment (different address spaces)
drivers/mtd/devices/spear_smi.c:566:13:    expected void *src
drivers/mtd/devices/spear_smi.c:566:13:    got void [noderef] <asn:2>*
drivers/mtd/devices/spear_smi.c:586:9: warning: incorrect type in argument 2 (different address spaces)
drivers/mtd/devices/spear_smi.c:586:9:    expected void const volatile [noderef] <asn:2>*<noident>
drivers/mtd/devices/spear_smi.c:586:9:    got unsigned char [usertype] *<noident>
drivers/mtd/devices/spear_smi.c:659:14: warning: incorrect type in assignment (different address spaces)
drivers/mtd/devices/spear_smi.c:659:14:    expected void *dest
drivers/mtd/devices/spear_smi.c:659:14:    got void [noderef] <asn:2>*
drivers/mtd/devices/spear_smi.c:620:9: warning: incorrect type in argument 1 (different address spaces)
drivers/mtd/devices/spear_smi.c:620:9:    expected void volatile [noderef] <asn:2>*<noident>
drivers/mtd/devices/spear_smi.c:620:9:    got void *dest
drivers/mtd/devices/spear_smi.c:620:9: warning: incorrect type in argument 1 (different address spaces)
drivers/mtd/devices/spear_smi.c:620:9:    expected void volatile [noderef] <asn:2>*<noident>
drivers/mtd/devices/spear_smi.c:620:9:    got void *dest
drivers/mtd/devices/spear_smi.c:620:9: warning: incorrect type in argument 1 (different address spaces)
drivers/mtd/devices/spear_smi.c:620:9:    expected void volatile [noderef] <asn:2>*<noident>
drivers/mtd/devices/spear_smi.c:620:9:    got void *dest

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: r852: Staticize local symbols
Jingoo Han [Wed, 7 Aug 2013 07:14:38 +0000 (16:14 +0900)]
mtd: r852: Staticize local symbols

These local symbols are used only in this file.
Fix the following sparse warnings:

drivers/mtd/nand/r852.c:232:6: warning: symbol 'r852_write_buf' was not declared. Should it be static?
drivers/mtd/nand/r852.c:264:6: warning: symbol 'r852_read_buf' was not declared. Should it be static?
drivers/mtd/nand/r852.c:315:6: warning: symbol 'r852_cmdctl' was not declared. Should it be static?
drivers/mtd/nand/r852.c:360:5: warning: symbol 'r852_wait' was not declared. Should it be static?
drivers/mtd/nand/r852.c:389:5: warning: symbol 'r852_ready' was not declared. Should it be static?
drivers/mtd/nand/r852.c:400:6: warning: symbol 'r852_ecc_hwctl' was not declared. Should it be static?
drivers/mtd/nand/r852.c:432:5: warning: symbol 'r852_ecc_calculate' was not declared. Should it be static?
drivers/mtd/nand/r852.c:464:5: warning: symbol 'r852_ecc_correct' was not declared. Should it be static?
drivers/mtd/nand/r852.c:532:6: warning: symbol 'r852_engine_enable' was not declared. Should it be static?
drivers/mtd/nand/r852.c:550:6: warning: symbol 'r852_engine_disable' was not declared. Should it be static?
drivers/mtd/nand/r852.c:560:6: warning: symbol 'r852_card_update_present' was not declared. Should it be static?
drivers/mtd/nand/r852.c:575:6: warning: symbol 'r852_update_card_detect' was not declared. Should it be static?
drivers/mtd/nand/r852.c:589:9: warning: symbol 'r852_media_type_show' was not declared. Should it be static?
drivers/mtd/nand/r852.c:600:1: warning: symbol 'dev_attr_media_type' was not declared. Should it be static?
drivers/mtd/nand/r852.c:604:6: warning: symbol 'r852_update_media_status' was not declared. Should it be static?
drivers/mtd/nand/r852.c:633:5: warning: symbol 'r852_register_nand_device' was not declared. Should it be static?
drivers/mtd/nand/r852.c:671:6: warning: symbol 'r852_unregister_nand_device' was not declared. Should it be static?
drivers/mtd/nand/r852.c:685:6: warning: symbol 'r852_card_detect_work' was not declared. Should it be static?
drivers/mtd/nand/r852.c:824:6: warning: symbol 'r852_probe' was not declared. Should it be static?
drivers/mtd/nand/r852.c:964:6: warning: symbol 'r852_remove' was not declared. Should it be static?
drivers/mtd/nand/r852.c:995:6: warning: symbol 'r852_shutdown' was not declared. Should it be static?

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nandsim: Staticize local symbols
Jingoo Han [Wed, 7 Aug 2013 07:13:32 +0000 (16:13 +0900)]
mtd: nandsim: Staticize local symbols

These local symbols are used only in this file.
Fix the following sparse warnings:

drivers/mtd/nand/nandsim.c:1436:5: warning: symbol 'do_read_error' was not declared. Should it be static?
drivers/mtd/nand/nandsim.c:1448:6: warning: symbol 'do_bit_flips' was not declared. Should it be static?

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: impa7: add missing __iomem annotation
Jingoo Han [Wed, 7 Aug 2013 07:12:14 +0000 (16:12 +0900)]
mtd: impa7: add missing __iomem annotation

Added missing __iomem annotation and used NULL instead of 0
in order to fix the following sparse warnings:

drivers/mtd/maps/impa7.c:82:32: warning: Using plain integer as NULL pointer
drivers/mtd/maps/impa7.c:96:34: warning: cast removes address space of expression
drivers/mtd/maps/impa7.c:96:34: warning: incorrect type in argument 1 (different address spaces)
drivers/mtd/maps/impa7.c:96:34:    expected void volatile [noderef] <asn:2>*addr
drivers/mtd/maps/impa7.c:96:34:    got void *<noident>
drivers/mtd/maps/impa7.c:108:34: warning: cast removes address space of expression
drivers/mtd/maps/impa7.c:108:34: warning: incorrect type in argument 1 (different address spaces)
drivers/mtd/maps/impa7.c:108:34:    expected void volatile [noderef] <asn:2>*addr
drivers/mtd/maps/impa7.c:108:34:    got void *<noident>
drivers/mtd/maps/impa7.c:109:45: warning: Using plain integer as NULL pointer

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: sm_ftl: Staticize local symbols
Jingoo Han [Wed, 7 Aug 2013 07:10:21 +0000 (16:10 +0900)]
mtd: sm_ftl: Staticize local symbols

These local symbols are used only in this file.
Fix the following sparse warnings:

drivers/mtd/sm_ftl.c:25:25: warning: symbol 'cache_flush_workqueue' was not declared. Should it be static?
drivers/mtd/sm_ftl.c:44:9: warning: symbol 'sm_attr_show' was not declared. Should it be static?
drivers/mtd/sm_ftl.c:57:24: warning: symbol 'sm_create_sysfs_attributes' was not declared. Should it be static?
drivers/mtd/sm_ftl.c:110:6: warning: symbol 'sm_delete_sysfs_attributes' was not declared. Should it be static?
drivers/mtd/sm_ftl.c:574:5: warning: symbol 'sm_get_media_info' was not declared. Should it be static?
drivers/mtd/sm_ftl.c:881:17: warning: symbol 'sm_get_zone' was not declared. Should it be static?
drivers/mtd/sm_ftl.c:902:6: warning: symbol 'sm_cache_init' was not declared. Should it be static?
drivers/mtd/sm_ftl.c:912:6: warning: symbol 'sm_cache_put' was not declared. Should it be static?
drivers/mtd/sm_ftl.c:920:5: warning: symbol 'sm_cache_get' was not declared. Should it be static?
drivers/mtd/sm_ftl.c:931:5: warning: symbol 'sm_cache_flush' was not declared. Should it be static?

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: m25p80: add support for mr25h10
Markus Niebel [Tue, 20 Aug 2013 07:54:41 +0000 (09:54 +0200)]
mtd: m25p80: add support for mr25h10

This adds support for the Everspin mr25h10 MRAM chip to the m25p80
driver.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Marek Vasut <marex@denx.de>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: m25p80: make CONFIG_M25PXX_USE_FAST_READ safe to enable
Sascha Hauer [Tue, 20 Aug 2013 07:54:40 +0000 (09:54 +0200)]
mtd: m25p80: make CONFIG_M25PXX_USE_FAST_READ safe to enable

This patch adds a flag to struct flash_info indicating that
fast_read is not supported. This now gives the following logic
when determing whether to enable fastread:

If the flash chip does not support fast_read, then disable it.
Otherwise:
1) enable fast_read if device node contains m25p,fast-read
2) enable fast_read if forced in Kconfig

This makes enabling CONFIG_M25PXX_USE_FAST_READ a safe option
since we no longer enable the fast_read option unconditionally.

For now fast_read is disabled for the everspin mr25h256 and the
catalyst devices. Others may need the flag aswell.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Marek Vasut <marex@denx.de>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: m25p80: Pass flags through CAT25_INFO macro
Sascha Hauer [Tue, 20 Aug 2013 07:54:39 +0000 (09:54 +0200)]
mtd: m25p80: Pass flags through CAT25_INFO macro

The flags may have to be overwritten, so add them to the CAT25_INFO
macro.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Marek Vasut <marex@denx.de>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: m25p80: remove unnecessary ifdef
Sascha Hauer [Mon, 12 Aug 2013 10:22:26 +0000 (12:22 +0200)]
mtd: m25p80: remove unnecessary ifdef

of_property_read_bool properly compiles away, no need to ifdef this
for non DT builds.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Marek Vasut <marex@denx.de>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: MTD_NAND_DENALI should depend on HAS_DMA
Geert Uytterhoeven [Sun, 18 Aug 2013 11:03:59 +0000 (13:03 +0200)]
mtd: MTD_NAND_DENALI should depend on HAS_DMA

If NO_DMA=y:

drivers/built-in.o: In function `denali_remove':
drivers/mtd/nand/denali.c:1605: undefined reference to `dma_unmap_single'
drivers/built-in.o: In function `denali_read_page_raw':
drivers/mtd/nand/denali.c:1190: undefined reference to `dma_sync_single_for_cpu'
drivers/built-in.o: In function `denali_read_page':
drivers/mtd/nand/denali.c:1140: undefined reference to `dma_sync_single_for_cpu'
drivers/built-in.o: In function `write_page':
drivers/mtd/nand/denali.c:1051: undefined reference to `dma_sync_single_for_cpu'
drivers/built-in.o: In function `denali_init':
drivers/mtd/nand/denali.c:1433: undefined reference to `dma_set_mask'
drivers/mtd/nand/denali.c:1438: undefined reference to `dma_map_single'
drivers/mtd/nand/denali.c:1442: undefined reference to `dma_mapping_error'

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: fsmc_nand: simplify platform_get_resource_byname/devm_ioremap_resource
Julia Lawall [Mon, 19 Aug 2013 08:51:53 +0000 (10:51 +0200)]
mtd: fsmc_nand: simplify platform_get_resource_byname/devm_ioremap_resource

Remove unneeded error handling on the result of a call to
platform_get_resource_byname when the value is passed to devm_ioremap_resource.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,e,e1;
expression ret != 0;
identifier l;
@@

  res = platform_get_resource_byname(...);
- if (res == NULL) { ... \(goto l;\|return ret;\) }
  e = devm_ioremap_resource(e1, res);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: atmel_nand: pmecc: fix failure to correct bit error in 1024-bytes sector
Josh Wu [Mon, 19 Aug 2013 10:05:44 +0000 (18:05 +0800)]
mtd: atmel_nand: pmecc: fix failure to correct bit error in 1024-bytes sector

The PMECC use BCH algorithm to correct error. In BCH algorithm, the primitive
polynomial value is GF(2^13) for 512-bytes sector size. And it is GF(2^14) for
1024-bytes sector size.

This patch will choose correct degree of the remainders (13 or 14) for
different sector size.

Tested in AT91SAM9X5-EK with MLC nand flash.

More detail can be found in §5.4.1 of:
  AT91SAM ARM-based Embedded MPU Application Note
  <http://www.atmel.com/Images/doc11127.pdf>

Signed-off-by: Josh Wu <josh.wu@atmel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: m25p80: Micron SPI uses Macronix-style 4-byte addressing
Brian Norris [Sat, 17 Aug 2013 19:16:29 +0000 (12:16 -0700)]
mtd: m25p80: Micron SPI uses Macronix-style 4-byte addressing

For SPI NOR flash that are larger than 128Mbit (16MiB), we need 4 bytes
of address space to reach the entire flash; however, the original SPI
flash protocol used only 3 bytes for the address. So far, the practice
for handling this has been either to use new command opcodes that are
defined to use 4 bytes for their address, or to use special
mode-switching command to configure all traditionally-3-byte-address
commands to take 4 bytes instead.

Macronix and Spansion developed two incompatible methods for
entering/exiting "4-byte address mode." Micron flash uses the Macronix
method (OPCODE_{EN4B,EX4B}), not the Spansion method.

This patch solves addressing issues on Micron n25q256a and provides the
ability to support other future Micron SPI flash >16MiB.

Quoting a Micron representative:

  "Majority of our NOR that needs 4-byte addressing (256Mb or 32MB and
   higher) enter and exit 4byte through B7h and E9h commands. The
   N25Q256A7xxx and N25Q512A7xxx parts do not support 4-byte addressing
   mode via B7h or E9h command."

They further clarified that those that don't support the enter/exit
opcodes (B7h/E9h) are manufactured specifically to come up by default in
4-byte mode. We don't need to treat those parts any diffently, as they
will discard the EN4B opcode as a no-op.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Acked-by: Marek Vasut <marex@denx.de>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: fixup kerneldoc, rename parameter
Brian Norris [Fri, 9 Aug 2013 00:16:36 +0000 (17:16 -0700)]
mtd: nand: fixup kerneldoc, rename parameter

First, the function argument is 'offset' not 'column'.

Second, the 'data_buf' name is inconsistent with the rest of this file.
Just use 'buf'.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Cc: Gupta, Pekon <pekon@ti.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: update the ABI document about the ecc step size
Huang Shijie [Fri, 16 Aug 2013 02:10:09 +0000 (10:10 +0800)]
mtd: update the ABI document about the ecc step size

We add a new sys node for ecc step size. So update the ABI document about it.

Signed-off-by: Huang Shijie <b32955@freescale.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
[Brian: edited description, modified 'ecc_strength']
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: gpmi: remove the nand_scan()
Huang Shijie [Fri, 16 Aug 2013 02:10:08 +0000 (10:10 +0800)]
mtd: gpmi: remove the nand_scan()

In order to make the nand_scan() work, the current code uses the hack code
to init the @nand_chip->ecc.size and the @nand_chip->ecc.strength. and
re-init some the ECC info in the gpmi_pre_bbt_scan().
This code is really a little ugly.

The patch does following changes:
  (1) Use the nand_scan_ident()/nand_scan_tail() to replace the nand_scan().

  (2) Init all the necessary values in the gpmi_init_last()
      before we call the nand_scan_tail().

  (3) remove the code setting the ECC info, let the mtd layer to do the
      real job.

  (4) remove the gpmi_scan_bbt(). we do not need this function any more.

Signed-off-by: Huang Shijie <b32955@freescale.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: set ONFI nand's default hooks in nand_set_defaults()
Huang Shijie [Fri, 16 Aug 2013 02:10:07 +0000 (10:10 +0800)]
mtd: set ONFI nand's default hooks in nand_set_defaults()

We may do some ONFI get/set features operations before we call the
nand_scan_tail().

So move the default ONFI nand hooks into nand_set_defaults().

Signed-off-by: Huang Shijie <b32955@freescale.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: set the ecc step size for master/slave mtd_info
Huang Shijie [Fri, 16 Aug 2013 02:10:06 +0000 (10:10 +0800)]
mtd: set the ecc step size for master/slave mtd_info

Set the ecc step size for master/slave mtd_info{}.

Signed-off-by: Huang Shijie <b32955@freescale.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: add a new sys node to show the ecc step size
Huang Shijie [Fri, 16 Aug 2013 02:10:05 +0000 (10:10 +0800)]
mtd: add a new sys node to show the ecc step size

Add a new sys node to show the ecc step size.
The application then can uses this node to get the ecc step
size.

Signed-off-by: Huang Shijie <b32955@freescale.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: add a new ecc_step_size field to mtd_info{}
Huang Shijie [Fri, 16 Aug 2013 02:10:04 +0000 (10:10 +0800)]
mtd: add a new ecc_step_size field to mtd_info{}

In order to implement the NAND boot for some Freescale's chips, such as
imx23/imx28/imx50/imx6, we use a tool (called kobs-ng) to burn the uboot
and some metadata to nand chip. And the ROM code will use the metadata to
configrate the BCH, and to find the uboot.

The ECC information(ecc step size, ecc strength) which is used to configrure
the BCH is part of the metadata. The kobs-ng can get the ecc strength from
the sys node /sys/*/ecc_strength now. But it can not get the ecc step size.

This patch adds a new field to store the ecc step size in mtd_info{}, and
it makes preparation for the next patches.

Signed-off-by: Huang Shijie <b32955@freescale.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: silence some shift wrap warnings
Dan Carpenter [Fri, 9 Aug 2013 09:49:05 +0000 (12:49 +0300)]
mtd: nand: silence some shift wrap warnings

There are static checkers which complain when we declare variables as
64 bit bitfields but only use the lower 32 bits because of shift
wrapping.  In this case "len" is declared as u64 as opposed to unsigned
long or something which might be 32 bits.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: simplify use of devm_ioremap_resource
Julia Lawall [Wed, 14 Aug 2013 09:11:08 +0000 (11:11 +0200)]
mtd: simplify use of devm_ioremap_resource

Remove unneeded error handling on the result of a call to
platform_get_resource when the value is passed to devm_ioremap_resource.

Move the call to platform_get_resource adjacent to the call to
devm_ioremap_resource to make the connection between them more clear.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression pdev,res,n,e,e1;
expression ret != 0;
identifier l;
@@

- res = platform_get_resource(pdev, IORESOURCE_MEM, n);
  ... when != res
- if (res == NULL) { ... \(goto l;\|return ret;\) }
  ... when != res
+ res = platform_get_resource(pdev, IORESOURCE_MEM, n);
  e = devm_ioremap_resource(e1, res);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: create_freezable_workqueue() doesn't return an ERR_PTR
Dan Carpenter [Thu, 15 Aug 2013 07:56:29 +0000 (10:56 +0300)]
mtd: create_freezable_workqueue() doesn't return an ERR_PTR

The create_freezable_workqueue() returns a NULL on error, it doesn't
return an ERR_PTR.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: tests: incorporate error message for mtdtest_write()
Akinobu Mita [Thu, 15 Aug 2013 13:55:09 +0000 (22:55 +0900)]
mtd: tests: incorporate error message for mtdtest_write()

All callers of mtdtest_write() print the same error message on failure.
This incorporates the error message to mtdtest_write() and removes them
from the callers.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: tests: incorporate error message for mtdtest_read()
Akinobu Mita [Thu, 15 Aug 2013 13:55:08 +0000 (22:55 +0900)]
mtd: tests: incorporate error message for mtdtest_read()

All callers of mtdtest_read() print the same error message on failure.
This incorporates the error message to mtdtest_read() and removes them
from the callers.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: Allow to build pxa3xx_nand on Orion platforms
Ezequiel Garcia [Mon, 12 Aug 2013 17:14:59 +0000 (14:14 -0300)]
mtd: nand: Allow to build pxa3xx_nand on Orion platforms

The Armada 370 and Armada XP SoC families, selected by PLAT_ORION,
have a Nand Flash Controller (NFC) IP very similar to the one present
in PXA platforms. Therefore, we want to build this driver on PLAT_ORION.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Tested-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: pxa3xx: Allow devices with no dma resources
Ezequiel Garcia [Mon, 12 Aug 2013 17:14:58 +0000 (14:14 -0300)]
mtd: nand: pxa3xx: Allow devices with no dma resources

When use_dma=0 there's no point in requesting resources for dma,
since they won't be used anyway. Therefore we remove that requirement,
therefore allowing devices without dma to pass the driver probe.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Tested-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: pxa3xx: Add __maybe_unused keyword to enable_int()
Ezequiel Garcia [Mon, 12 Aug 2013 17:14:57 +0000 (14:14 -0300)]
mtd: nand: pxa3xx: Add __maybe_unused keyword to enable_int()

Now that we have added ARCH_HAS_DMA conditional the function
enable_int() may be unused. Declare it as __maybe_unused,
in order to remove the following warning, when the function is not used:

drivers/mtd/nand//pxa3xx_nand.c:343:24: warning: 'enable_int' defined
but not used [-Wunused-function]

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Tested-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: pxa3xx: Make dma code dependent on dma capable platforms
Ezequiel Garcia [Mon, 12 Aug 2013 17:14:56 +0000 (14:14 -0300)]
mtd: nand: pxa3xx: Make dma code dependent on dma capable platforms

This patch adds a macro ARCH_HAS_DMA to compile-out arch specific
dma code, namely pxa_request_dma() and pxa_free_dma(). These symbols
are available only in pxa, which makes impossible to build the driver in
other platforms than ARCH_PXA.

In order to handle non-dma capable platforms, we implement a fallbacks that
allocate buffers as if 'use_dma=false', putting the dma related code
under the ARCH_HAS_DMA conditional.

Please note that the correct way to handle this is to migrate the
dma code to use of the mmp_pdma dmaengine driver. However, currently
this is not possible because the two dmaengine drivers can't work together.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Tested-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: pxa3xx: Move cached registers to info structure
Ezequiel Garcia [Mon, 12 Aug 2013 17:14:55 +0000 (14:14 -0300)]
mtd: nand: pxa3xx: Move cached registers to info structure

This registers are not per-chip (aka host) but controller-wide,
so it's better to store them in the global 'info' structure.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Tested-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: pxa3xx: Remove unneeded internal cmdset
Ezequiel Garcia [Mon, 12 Aug 2013 17:14:54 +0000 (14:14 -0300)]
mtd: nand: pxa3xx: Remove unneeded internal cmdset

Use the defined macros for NAND command instead of using a constant
internal structure. This commit is only a cleanup, there's no
functionality modification.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Tested-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: pxa3xx: Remove hardcoded mtd name
Ezequiel Garcia [Mon, 12 Aug 2013 17:14:53 +0000 (14:14 -0300)]
mtd: nand: pxa3xx: Remove hardcoded mtd name

There's no advantage in using a hardcoded name for the mtd device.
Instead use the provided by the platform_device.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Tested-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: pxa3xx: Add a local loop variable
Ezequiel Garcia [Mon, 12 Aug 2013 17:14:52 +0000 (14:14 -0300)]
mtd: nand: pxa3xx: Add a local loop variable

This is just a cosmetic change, to make the code more readable.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Tested-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: pxa3xx: Use 'length override' in ONFI paramater page read
Ezequiel Garcia [Mon, 12 Aug 2013 17:14:51 +0000 (14:14 -0300)]
mtd: nand: pxa3xx: Use 'length override' in ONFI paramater page read

The ONFI command 'parameter page read' needs a non-standard length.
Therefore, we enable the 'length override' field in NDCB0 and set
a non-zero 'length count' in NDCB3.

Additionally, the 'spare enable' bit must be disabled for any command
that sets a non-zero 'length count' in NDCB3.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Tested-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: pxa3xx: Support command buffer #3
Ezequiel Garcia [Mon, 12 Aug 2013 17:14:50 +0000 (14:14 -0300)]
mtd: nand: pxa3xx: Support command buffer #3

Some newer controllers support a fourth command buffer. This additional
command buffer allows to set an arbitrary length count, using the
NDCB3.NDLENCNT field, to perform non-standard length operations
such as the ONFI parameter page read.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Tested-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: pxa3xx: Allow to set/clear the 'spare enable' field
Ezequiel Garcia [Mon, 12 Aug 2013 17:14:49 +0000 (14:14 -0300)]
mtd: nand: pxa3xx: Allow to set/clear the 'spare enable' field

Some commands (such as the ONFI parameter page read) need to
clear the 'spare enable' bit. This commit allows to set/clear
depending on the prepared command, instead of having it always
set.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Tested-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: pxa3xx: Handle ECC and DMA enable/disable properly
Ezequiel Garcia [Mon, 12 Aug 2013 17:14:48 +0000 (14:14 -0300)]
mtd: nand: pxa3xx: Handle ECC and DMA enable/disable properly

When ECC is not selected, the ECC enable bit must be cleared
in the NAND control register. Same applies to DMA.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Tested-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: pxa3xx: Introduce 'marvell,armada370-nand' compatible string
Ezequiel Garcia [Sat, 10 Aug 2013 19:34:52 +0000 (16:34 -0300)]
mtd: nand: pxa3xx: Introduce 'marvell,armada370-nand' compatible string

This driver supports NFCv1 (as found in PXA SoC) and NFCv2 (as found in
Armada 370/XP SoC). As both controller has a few differences, a way of
distinguishing between the two is needed.

This commit introduces a new compatible string 'marvell,armada370-nand'
and assigns a compatible data of type enum pxa3xx_nand_variant to allow
such distinction.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Tested-by: Daniel Mack <zonque@gmail.com>
Cc: devicetree@vger.kernel.org
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: gpmi: set the BCH's geometry with the ecc info
Huang Shijie [Fri, 17 May 2013 03:17:34 +0000 (11:17 +0800)]
mtd: gpmi: set the BCH's geometry with the ecc info

If the nand chip provides us the ECC info, we can use it firstly.
The set_geometry_by_ecc_info() will use the ECC info, and
calculate the parameters we need.

Rename the old code to legacy_set_geometry() which will takes effect
when there is no ECC info from the nand chip or we fails in the ECC info case.

Signed-off-by: Huang Shijie <b32955@freescale.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: add the ecc info for some full-id nand chips
Huang Shijie [Fri, 17 May 2013 03:17:33 +0000 (11:17 +0800)]
mtd: add the ecc info for some full-id nand chips

Add the ecc info for TC58NVG2S0F, TC58NVG3S0F, TC58NVG5D2 and TC58NVG6D2.

From these chips' datasheets, we know that:
   The TC58NVG2S0F and TC58NVG3S0F require 4bit ECC for per 512byte.
   The TC58NVG5D2 and TC58NVG6D2 require 40bits ECC for per 1024byte.

Signed-off-by: Huang Shijie <b32955@freescale.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: parse out the ECC info for the full-id nand chips
Huang Shijie [Fri, 17 May 2013 03:17:32 +0000 (11:17 +0800)]
mtd: parse out the ECC info for the full-id nand chips

Parse out the ECC information for the full-id nand chips.

Signed-off-by: Huang Shijie <b32955@freescale.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: add ECC info for nand_flash_dev{}
Huang Shijie [Fri, 17 May 2013 03:17:31 +0000 (11:17 +0800)]
mtd: add ECC info for nand_flash_dev{}

Add an instance of an anonymous struct to store the ECC info for full id
nand chips.
@ecc.strength_ds: ECC correctability from the datasheet.
@ecc.step_ds: ECC size required by the @ecc.strength_ds,

These two fields are all from the datasheet.

Also add the necessary macros to make the code simple and clean.

Signed-off-by: Huang Shijie <b32955@freescale.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: replace the hardcode with the onfi_feature()
Huang Shijie [Fri, 17 May 2013 03:17:30 +0000 (11:17 +0800)]
mtd: replace the hardcode with the onfi_feature()

The current code uses the hardcode to detect the 16-bit bus width.
Use the onfi_feature() to replace it.

Signed-off-by: Huang Shijie <b32955@freescale.com>
[Brian: small fixup]
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: get the ECC info from the Extended Parameter Page
Huang Shijie [Wed, 22 May 2013 02:28:27 +0000 (10:28 +0800)]
mtd: get the ECC info from the Extended Parameter Page

Since the ONFI 2.1, the onfi spec adds the Extended Parameter Page
to store the ECC info.

The onfi spec tells us that if the nand chip's recommended ECC codeword
size is not 512 bytes, then the @ecc_bits is 0xff. The host _SHOULD_ then
read the Extended ECC information that is part of the extended parameter
page to retrieve the ECC requirements for this device.

This patch implement the reading of the Extended Parameter Page, and parses
the sections for ECC type, and get the ECC info from the ECC section.

Tested this patch with Micron MT29F64G08CBABAWP.

Acked-by: Pekon Gupta <pekon@ti.com>
Signed-off-by: Huang Shijie <b32955@freescale.com>
Reviewed-and-tested-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: add a helper to get the supported features for ONFI nand
Huang Shijie [Fri, 17 May 2013 03:17:28 +0000 (11:17 +0800)]
mtd: add a helper to get the supported features for ONFI nand

add a helper to get the supported features for ONFI nand.
Also add the neccessary macros.

Signed-off-by: Huang Shijie <b32955@freescale.com>
Reviewed-and-tested-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: add data structures for Extended Parameter Page
Huang Shijie [Fri, 17 May 2013 03:17:27 +0000 (11:17 +0800)]
mtd: add data structures for Extended Parameter Page

Since the ONFI 2.1, the onfi spec adds the Extended Parameter Page
to store the ECC info.

The onfi spec tells us that if the nand chip's recommended ECC codeword
size is not 512 bytes, then the @ecc_bits is 0xff. The host _SHOULD_ then
read the Extended ECC information that is part of the extended parameter
page to retrieve the ECC requirements for this device.

This patch adds
    [1] the neccessary fields for nand_onfi_params{},
    [2] and adds the onfi_ext_ecc_info{} for Extended ECC information,
    [3] adds onfi_ext_section{} for extended sections,
    [4] and adds onfi_ext_param_page{} for the Extended Parameter Page.

Acked-by: Pekon Gupta <pekon@ti.com>
Signed-off-by: Huang Shijie <b32955@freescale.com>
Reviewed-and-tested-by: Brian Norris <computersforpeace@gmail.com>
[Brian: amended for checkpatch.pl]
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: get the ECC info from the parameter page for ONFI nand
Huang Shijie [Fri, 17 May 2013 03:17:26 +0000 (11:17 +0800)]
mtd: get the ECC info from the parameter page for ONFI nand

From the ONFI spec, we can just get the ECC info from the @ecc_bits field of
the parameter page.

Signed-off-by: Huang Shijie <b32955@freescale.com>
Reviewed-and-tested-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: add datasheet's ECC information to nand_chip{}
Huang Shijie [Fri, 17 May 2013 03:17:25 +0000 (11:17 +0800)]
mtd: add datasheet's ECC information to nand_chip{}

1.) Why add the ECC information to the nand_chip{} ?
   Each nand chip has its requirement for the ECC correctability, such as
   "4bit ECC for each 512Byte" or "40bit ECC for each 1024Byte".
   This ECC info is very important to the nand controller, such as gpmi.

   Take the Micron MT29F64G08CBABA for example, its geometry is
   8KiB page size, 744 bytes oob size and it requires 40bit ECC per 1KiB.
   If we do not provide the ECC info to the gpmi nand driver, it has to
   calculate the ECC correctability itself. The gpmi driver will gets the 56bit
   ECC for per 1KiB which is beyond its BCH's 40bit ecc capibility.
   The gpmi will quits in this case. But in actually, the gpmi can supports
   this nand chip if it can get the right ECC info.

2.) about the new fields.
   The @ecc_strength_ds stands for the ecc bits needed within the @ecc_step_ds.
   The two fields should be set from the nand chip's datasheets.

   For example:
"4bit ECC for each 512Byte" could be:
@ecc_strength_ds = 4, @ecc_step_ds = 512.
"40bit ECC for each 1024Byte" could be:
@ecc_strength_ds = 40, @ecc_step_ds = 1024.

3.) Why do not re-use the @strength and @size in the nand_ecc_ctrl{}?
   The @strength and @size in nand_ecc_ctrl{} is used by the nand controller
   driver, while the @ecc_strength_ds and @ecc_step_ds are get from the datasheet.

Signed-off-by: Huang Shijie <b32955@freescale.com>
Reviewed-and-tested-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: atmel_nand: move the sanity check to the beginning of pmecc_enable()
Josh Wu [Wed, 7 Aug 2013 09:58:11 +0000 (17:58 +0800)]
mtd: atmel_nand: move the sanity check to the beginning of pmecc_enable()

It is better to do the sanity check for the parameter before any hardware
operation.

Signed-off-by: Josh Wu <josh.wu@atmel.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: onenand: use dev_get_platdata()
Jingoo Han [Tue, 30 Jul 2013 08:18:53 +0000 (17:18 +0900)]
mtd: onenand: use dev_get_platdata()

Use the wrapper function for retrieving the platform data instead of
accessing dev->platform_data directly.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: use dev_get_platdata()
Jingoo Han [Tue, 30 Jul 2013 08:18:33 +0000 (17:18 +0900)]
mtd: nand: use dev_get_platdata()

Use the wrapper function for retrieving the platform data instead of
accessing dev->platform_data directly.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: maps: use dev_get_platdata()
Jingoo Han [Tue, 30 Jul 2013 08:18:06 +0000 (17:18 +0900)]
mtd: maps: use dev_get_platdata()

Use the wrapper function for retrieving the platform data instead of
accessing dev->platform_data directly.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: devices: use dev_get_platdata()
Jingoo Han [Tue, 30 Jul 2013 08:17:44 +0000 (17:17 +0900)]
mtd: devices: use dev_get_platdata()

Use the wrapper function for retrieving the platform data instead of
accessing dev->platform_data directly.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: denali: use NAND_CI_CELLTYPE_MSK instead of hardcoded constant
Akinobu Mita [Sat, 27 Jul 2013 14:09:53 +0000 (23:09 +0900)]
mtd: denali: use NAND_CI_CELLTYPE_MSK instead of hardcoded constant

Use NAND_CI_CELLTYPE_MSK to extract the cell type from nand_chip.cellinfo
instead of hardcoded constant.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Artem Bityutskiy <dedekind1@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: gpmi-nand: use more sensible error codes at various places
Lothar Waßmann [Wed, 7 Aug 2013 06:15:38 +0000 (08:15 +0200)]
mtd: nand: gpmi-nand: use more sensible error codes at various places

Acked-by: Huang Shijie <b32955@freescale.com>
Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: atmel_nand: fix the warning when CONFIG_OF is not defined
Josh Wu [Wed, 7 Aug 2013 03:36:09 +0000 (11:36 +0800)]
mtd: atmel_nand: fix the warning when CONFIG_OF is not defined

This patch fix following warning:

drivers/mtd/nand/atmel_nand.c:2007: warning: 'atmel_nand_nfc_match' defined but not used

This patch add '#if defined(CONFIG_OF)' block to guard around the definition
of atmel_nand_nfc_match, in order to avoid the warning when the kernel is
configured without DT support.

Signed-off-by: Josh Wu <josh.wu@atmel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: mtd_nandbiterrs: use mtd_test helpers
Akinobu Mita [Sat, 3 Aug 2013 09:52:16 +0000 (18:52 +0900)]
mtd: mtd_nandbiterrs: use mtd_test helpers

Use mtdtest_write() and mtdtest_erase_eraseblock() in mtd_test helpers.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Iwo Mergler <Iwo.Mergler@netcommwireless.com.au>
Cc: Brian Norris <computersforpeace@gmail.com>
Cc: Vikram Narayanan <vikram186@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: mtd_torturetest: use mtd_test helpers
Akinobu Mita [Sat, 3 Aug 2013 09:52:15 +0000 (18:52 +0900)]
mtd: mtd_torturetest: use mtd_test helpers

Use mtdtest_scan_for_bad_eraseblocks() and mtdtest_erase_good_eraseblocks()
in mtd_test helpers.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Brian Norris <computersforpeace@gmail.com>
Cc: Vikram Narayanan <vikram186@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: mtd_subpagetest: use mtd_test helpers
Akinobu Mita [Sat, 3 Aug 2013 09:52:14 +0000 (18:52 +0900)]
mtd: mtd_subpagetest: use mtd_test helpers

Use mtdtest_scan_for_bad_eraseblocks() and mtdtest_erase_good_eraseblocks()
in mtd_test helpers.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Brian Norris <computersforpeace@gmail.com>
Cc: Vikram Narayanan <vikram186@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: mtd_stresstest: use mtd_test helpers
Akinobu Mita [Sat, 3 Aug 2013 09:52:13 +0000 (18:52 +0900)]
mtd: mtd_stresstest: use mtd_test helpers

Use mtdtest_read(), mtdtest_write(), mtdtest_erase_eraseblock(), and
mtdtest_scan_for_bad_eraseblocks() in mtd_test helpers.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Brian Norris <computersforpeace@gmail.com>
Cc: Vikram Narayanan <vikram186@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: mtd_speedtest: use mtd_test helpers
Akinobu Mita [Sat, 3 Aug 2013 09:52:12 +0000 (18:52 +0900)]
mtd: mtd_speedtest: use mtd_test helpers

Use mtdtest_write(), mtdtest_read(), mtdtest_scan_for_bad_eraseblocks(),
mtdtest_erase_good_eraseblocks() in mtd_test helpers.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Brian Norris <computersforpeace@gmail.com>
Cc: Vikram Narayanan <vikram186@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: mtd_readtest: use mtd_test helpers
Akinobu Mita [Sat, 3 Aug 2013 09:52:11 +0000 (18:52 +0900)]
mtd: mtd_readtest: use mtd_test helpers

Use mtdtest_read() and mtdtest_scan_for_bad_eraseblocks() in mtd_test
helpers.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Brian Norris <computersforpeace@gmail.com>
Cc: Vikram Narayanan <vikram186@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: mtd_pagetest: use mtd_test helpers
Akinobu Mita [Sat, 3 Aug 2013 09:52:10 +0000 (18:52 +0900)]
mtd: mtd_pagetest: use mtd_test helpers

Use mtdtest_write(), mtdtest_read(), mtdtest_erase_eraseblock(),
mtdtest_scan_for_bad_eraseblocks(), and mtdtest_erase_good_eraseblocks()
in mtd_test helpers.

[dwmw2: merge later 'remove always true condition' fix]

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Brian Norris <computersforpeace@gmail.com>
Cc: Vikram Narayanan <vikram186@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: mtd_oobtest: use mtd_test helpers
Akinobu Mita [Sat, 3 Aug 2013 09:52:09 +0000 (18:52 +0900)]
mtd: mtd_oobtest: use mtd_test helpers

Use mtdtest_scan_for_bad_eraseblocks(), mtdtest_erase_good_eraseblocks(),
and mtdtest_erase_eraseblock() in mtd_test helpers.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Brian Norris <computersforpeace@gmail.com>
Cc: Vikram Narayanan <vikram186@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: tests: rename sources in order to link a helper object
Akinobu Mita [Sat, 3 Aug 2013 09:52:08 +0000 (18:52 +0900)]
mtd: tests: rename sources in order to link a helper object

Each mtd test module have a single source whose name is the same as
the module name.  In order to link a single object including helper
functions to every test module, this rename these sources to the
different names.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Brian Norris <computersforpeace@gmail.com>
Cc: Vikram Narayanan <vikram186@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: tests: introduce helper functions
Akinobu Mita [Sat, 3 Aug 2013 09:52:07 +0000 (18:52 +0900)]
mtd: tests: introduce helper functions

This introduces the helper functions which can be used by several
mtd/tests modules.

The following three functions are used all over the test modules.

- mtdtest_erase_eraseblock()
- mtdtest_scan_for_bad_eraseblocks()
- mtdtest_erase_good_eraseblocks()

The following are wrapper functions for mtd_read() and mtd_write()
which can simplify the return value check.

- mtdtest_read()
- mtdtest_write()

All helpers are put into a single .c file and it will be linked to
every test module later.  The code will actually be copied to every
test module, but it is fine for our small test infrastructure.

[dwmw2: merge later 'return -EIO when mtdtest_read() failed' fix]

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Brian Norris <computersforpeace@gmail.com>
Cc: Vikram Narayanan <vikram186@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: remove NAND_BBT_SCANEMPTY
Brian Norris [Wed, 31 Jul 2013 00:53:00 +0000 (17:53 -0700)]
mtd: nand: remove NAND_BBT_SCANEMPTY

NAND_BBT_SCANEMPTY is a strange, badly-supported option with omap as its
single remaining user.

NAND_BBT_SCANEMPTY was likely used by accident in omap2[1]. And anyway,
omap2 doesn't scan the chip for bad blocks (courtesy of
NAND_SKIP_BBTSCAN), and so its use of this option is irrelevant.

This patch drops the NAND_BBT_SCANEMPTY option.

[1] http://lists.infradead.org/pipermail/linux-mtd/2012-July/042902.html

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Cc: Ivan Djelic <ivan.djelic@parrot.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: hide in-memory BBT implementation details
Brian Norris [Wed, 31 Jul 2013 00:52:59 +0000 (17:52 -0700)]
mtd: nand: hide in-memory BBT implementation details

nand_base.c shouldn't have to know the implementation details of
nand_bbt's in-memory BBT. Specifically, nand_base shouldn't perform the
bit masking and shifting to isolate a BBT entry.

Instead, just move some of the BBT code into a new nand_markbad_bbt()
interface. This interface allows external users (i.e., nand_base) to
mark a single block as bad in the BBT. Then nand_bbt will take care of
modifying the in-memory BBT and updating the flash-based BBT (if
applicable).

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: refactor chip->block_markbad interface
Brian Norris [Wed, 31 Jul 2013 00:52:58 +0000 (17:52 -0700)]
mtd: nand: refactor chip->block_markbad interface

The chip->block_markbad pointer should really only be responsible for
writing a bad block marker for new bad blocks. It should not take care
of BBT-related functionality, nor should it handle bookkeeping of bad
block stats.

This patch refactors the 3 users of the block_markbad interface (plus
the default nand_base implementation) so that the common code is kept in
nand_block_markbad_lowlevel(). It removes some inconsistencies between
the various implementations and should allow for more centralized
improvements in the future.

Because gpmi-nand no longer needs the nand_update_bbt() function, let's
stop exporting it as well.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Acked-by: Huang Shijie <b32955@freescale.com> (for gpmi-nand parts)
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: eliminate cast
Brian Norris [Wed, 31 Jul 2013 00:52:57 +0000 (17:52 -0700)]
mtd: nand: eliminate cast

Just make 'res' an int.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: remove multiplied-by-2 block logic
Brian Norris [Wed, 31 Jul 2013 00:52:56 +0000 (17:52 -0700)]
mtd: nand: remove multiplied-by-2 block logic

The parent commit 771c568bcf915e708ae819ef9d07d862f7e2da86 ("mtd: nand: add
accessors, macros for in-memory BBT") makes the following comment obsolete:

/*
 * Note that numblocks is 2 * (real numblocks) here, see i+=2
 * below as it makes shifting and masking less painful
 */

I don't think it ever could have been "less painful" to have to shift an
extra bit (or 2, or 3) at various points in nand_bbt.c (and even
outside, since we leak our in-memory format). But now it is certainly
more painful, since we have nice macros and functions to retrieve the
relevant portions of the BBT.

This patch removes any points where the block number is
doubled/halved/otherwise-shifted, instead representing the block number
in its most natural form: as the actual block number.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: add accessors, macros for in-memory BBT
Brian Norris [Wed, 31 Jul 2013 00:52:55 +0000 (17:52 -0700)]
mtd: nand: add accessors, macros for in-memory BBT

There is an abundance of magic numbers and complicated shifting/masking
logic in the in-memory BBT code which makes the code unnecessary complex
and hard to read.

This patch adds macros to represent the 00b, 01b, 10b, and 11b
memory-BBT magic numbers, as well as two accessor functions for reading
and marking the memory-BBT bitfield for a given block.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: ofpart: add compatible check for child nodes
Josh Wu [Mon, 5 Aug 2013 11:14:38 +0000 (19:14 +0800)]
mtd: ofpart: add compatible check for child nodes

In case that the nand device will support some features like Nand Flash
Controller, we want to make the sub feature as a sub node of nand device.

Use such organization it is easy to enable/disable feature, also it is back
compatible and more readable.

If the sub-node has a compatible property then it is a driver not partition.

Signed-off-by: Josh Wu <josh.wu@atmel.com>
Acked-by: Brian Norris <computersforpeace@gmail.com>
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
[ added a missing newline -Brian ]
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: atmel_nand: enable Nand Flash Controller (NFC) write via sram
Josh Wu [Mon, 5 Aug 2013 11:14:37 +0000 (19:14 +0800)]
mtd: atmel_nand: enable Nand Flash Controller (NFC) write via sram

This patch enable writing nand flash via NFC SRAM. It will minimize the CPU
overhead. The SRAM write only support ECC_NONE and ECC_HW with PMECC.

To enable this NFC write by SRAM feature, you can add a string in dts under
NFC driver node.

This driver has been tested on SAMA5D3X-EK with JFFS2, YAFFS2, UBIFS and
mtd-utils.

Here is part of mtd_speedtest (writing test) result, compare with non-NFC
writing, it reduces %65 cpu load with loss %12 speed.

- commands use to test:
  # insmod /mnt/mtd_speedtest.ko dev=2 &
  # top -n 30 -d 1 | grep speedtest

- test result:
=================================================
mtd_speedtest: MTD device: 2
mtd_speedtest: MTD device size 41943040, eraseblock size 131072, page size 2048, count of eraseblocks 320, pages per eraseblock 64, OOB size 64
mtd_speedtest: testing eraseblock write speed
  509   495 root     D     1164   0%   7% insmod /mnt/mtd_speedtest.ko dev=2
  509   495 root     D     1164   0%   8% insmod /mnt/mtd_speedtest.ko dev=2
  509   495 root     R     1164   0%   5% insmod /mnt/mtd_speedtest.ko dev=2
mtd_speedtest: eraseblock write speed is 5194 KiB/s
mtd_speedtest: testing page write speed
  509   495 root     D     1164   0%  32% insmod /mnt/mtd_speedtest.ko dev=2
  509   495 root     D     1164   0%  27% insmod /mnt/mtd_speedtest.ko dev=2
  509   495 root     D     1164   0%  25% insmod /mnt/mtd_speedtest.ko dev=2
  509   495 root     D     1164   0%  30% insmod /mnt/mtd_speedtest.ko dev=2
mtd_speedtest: page write speed is 5024 KiB/s

Signed-off-by: Josh Wu <josh.wu@atmel.com>
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: atmel_nand: enable Nand Flash Controller (NFC) read data via sram
Josh Wu [Mon, 5 Aug 2013 11:14:36 +0000 (19:14 +0800)]
mtd: atmel_nand: enable Nand Flash Controller (NFC) read data via sram

NFC has embedded sram which can use to transfer data. This patch enable reading
nand flash via NFC SRAM. It will minimize the CPU overhead.

This driver has been tested on SAMA5D3X-EK with JFFS2, YAFFS2, UBIFS and
mtd-utils.

Here puts the part of mtd_speedtest (read test) result as following:
Compare with non-NFC mtd_speedtest result, reading will reduce %45 cpu load
with increase %80 speed.

- commands use to test:
  # insmod /mnt/mtd_speedtest.ko dev=2 &
  # top -n 30 -d 1 | grep speedtest

- test result:
=================================================
mtd_speedtest: MTD device: 2
mtd_speedtest: MTD device size 41943040, eraseblock size 131072, page size 2048, count of eraseblocks 320, pages per eraseblock 64, OOB size 64
mtd_speedtest: testing eraseblock read speed
  509   495 root     D     1164   0%  28% insmod /mnt/mtd_speedtest.ko dev=2
  509   495 root     D     1164   0%  25% insmod /mnt/mtd_speedtest.ko dev=2
  509   495 root     D     1164   0%  26% insmod /mnt/mtd_speedtest.ko dev=2
mtd_speedtest: eraseblock read speed is 9403 KiB/s
mtd_speedtest: testing page read speed
  509   495 root     R     1164   0%  31% insmod /mnt/mtd_speedtest.ko dev=2
  509   495 root     D     1164   0%  57% insmod /mnt/mtd_speedtest.ko dev=2
  509   495 root     D     1164   0%  53% insmod /mnt/mtd_speedtest.ko dev=2
  509   495 root     D     1164   0%  71% insmod /mnt/mtd_speedtest.ko dev=2
mtd_speedtest: page read speed is 9258 KiB/s

Signed-off-by: Josh Wu <josh.wu@atmel.com>
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: atmel_nand: add Nand Flash Controller (NFC) support
Josh Wu [Mon, 5 Aug 2013 11:14:35 +0000 (19:14 +0800)]
mtd: atmel_nand: add Nand Flash Controller (NFC) support

Nand Flash Controller (NFC) can handle automatic transfers, sending the
commands and address cycles to the NAND Flash.

To use NFC in this driver, user needs to add NFC child node in nand flash
driver. The NFC child node includes NFC's compatible string and regiters
of the address and size of NFC command registers, NFC registers (embedded
in HSMC) and NFC SRAM.
Also user need to set up the HSMC irq, which use to check whether nfc
command is finish or not.

This driver has been tested on SAMA5D3X-EK board with JFFS2, YAFFS,
UBIFS and mtd-utils.

I put the part of the mtd_speedtest result here for your information.
>From the mtd_speedtest, we can see the NFC will reduce the %50 of cpu load
when writing nand flash. No change when reading.
In the meantime, the speed will be slow about %8.

- commands use to test:
    #insmod /mnt/mtd_speedtest.ko dev=2 &
    #top -n 30 -d 1 | grep speedtest

- test result:

Before the patch:
=================================================
mtd_speedtest: MTD device: 2
mtd_speedtest: MTD device size 41943040, eraseblock size 131072, page size 2048, count of eraseblocks 320, pages per eraseblock 64, OOB size 64
  515   495 root     R     1164   0%  93% insmod /mnt/mtd_speedtest.ko dev=2
  515   495 root     R     1164   0%  98% insmod /mnt/mtd_speedtest.ko dev=2
  515   495 root     R     1164   0%  99% insmod /mnt/mtd_speedtest.ko dev=2
mtd_speedtest: eraseblock write speed is 5768 KiB/s
mtd_speedtest: testing eraseblock read speed
  515   495 root     R     1164   0%  92% insmod /mnt/mtd_speedtest.ko dev=2
  515   495 root     R     1164   0%  91% insmod /mnt/mtd_speedtest.ko dev=2
  515   495 root     R     1164   0%  94% insmod /mnt/mtd_speedtest.ko dev=2
mtd_speedtest: eraseblock read speed is 5932 KiB/s
mtd_speedtest: testing page write speed
  515   495 root     R     1164   0%  94% insmod /mnt/mtd_speedtest.ko dev=2
  515   495 root     R     1164   0%  98% insmod /mnt/mtd_speedtest.ko dev=2
  515   495 root     R     1164   0%  98% insmod /mnt/mtd_speedtest.ko dev=2
mtd_speedtest: page write speed is 5770 KiB/s
mtd_speedtest: testing page read speed
  515   495 root     R     1164   0%  91% insmod /mnt/mtd_speedtest.ko dev=2
  515   495 root     R     1164   0%  89% insmod /mnt/mtd_speedtest.ko dev=2
  515   495 root     R     1164   0%  91% insmod /mnt/mtd_speedtest.ko dev=2
mtd_speedtest: page read speed is 5910 KiB/s

After the patch:
=================================================
mtd_speedtest: MTD device: 2
mtd_speedtest: MTD device size 41943040, eraseblock size 131072, page size 2048, count of eraseblocks 320, pages per eraseblock 64, OOB size 64
mtd_speedtest: testing eraseblock write speed
  509   495 root     D     1164   0%  49% insmod /mnt/mtd_speedtest.ko dev=2
  509   495 root     D     1164   0%  50% insmod /mnt/mtd_speedtest.ko dev=2
  509   495 root     D     1164   0%  47% insmod /mnt/mtd_speedtest.ko dev=2
mtd_speedtest: eraseblock write speed is 5370 KiB/s
mtd_speedtest: testing eraseblock read speed
  509   495 root     R     1164   0%  92% insmod /mnt/mtd_speedtest.ko dev=2
  509   495 root     R     1164   0%  91% insmod /mnt/mtd_speedtest.ko dev=2
  509   495 root     R     1164   0%  95% insmod /mnt/mtd_speedtest.ko dev=2
mtd_speedtest: eraseblock read speed is 5715 KiB/s
mtd_speedtest: testing page write speed
  509   495 root     D     1164   0%  48% insmod /mnt/mtd_speedtest.ko dev=2
  509   495 root     D     1164   0%  47% insmod /mnt/mtd_speedtest.ko dev=2
  509   495 root     D     1164   0%  50% insmod /mnt/mtd_speedtest.ko dev=2
mtd_speedtest: page write speed is 5224 KiB/s
mtd_speedtest: testing page read speed
  509   495 root     R     1164   0%  89% insmod /mnt/mtd_speedtest.ko dev=2
  509   495 root     R     1164   0%  94% insmod /mnt/mtd_speedtest.ko dev=2
  509   495 root     R     1164   0%  93% insmod /mnt/mtd_speedtest.ko dev=2
mtd_speedtest: page read speed is 5641 KiB/s

Signed-off-by: Josh Wu <josh.wu@atmel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: atmel_nand: replace pmecc enable code with one function.
Josh Wu [Mon, 5 Aug 2013 11:14:34 +0000 (19:14 +0800)]
mtd: atmel_nand: replace pmecc enable code with one function.

Signed-off-by: Josh Wu <josh.wu@atmel.com>
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: atmel_nand: use devm_xxx gpio kzalloc, gpio and ioremap
Jean-Christophe PLAGNIOL-VILLARD [Mon, 5 Aug 2013 11:14:33 +0000 (19:14 +0800)]
mtd: atmel_nand: use devm_xxx gpio kzalloc, gpio and ioremap

this will allow to simply the error and remove path

Cc: linux-mtd@lists.infradead.org
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
[josh.wu@atmel.com: fix checkpatch warnings and rebase to latest mtd git tree]
[josh.wu@atmel.com: replace devm_request_and_ioremap with devm_ioremap_resource]
Signed-off-by: Josh Wu <josh.wu@atmel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nandsim: remove unused ns->geom.oobshift
Akinobu Mita [Sun, 28 Jul 2013 02:21:58 +0000 (11:21 +0900)]
mtd: nandsim: remove unused ns->geom.oobshift

ns->geom.oobshift holds bits number in OOB size, but OOB size is not
always power of two.  So it is useless and it actually isn't used in
this driver except for just printing the value at module loading.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nandsim: remove unused code
Akinobu Mita [Sun, 28 Jul 2013 02:21:57 +0000 (11:21 +0900)]
mtd: nandsim: remove unused code

Remove the leftover from commit 831d316b8b80b68dcdd2b3f5ede6d33c2bbf5835
("mtd: nandsim: remove autoincrement code").

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nandsim: use NS_RAW_OFFSET()
Akinobu Mita [Sun, 28 Jul 2013 02:21:56 +0000 (11:21 +0900)]
mtd: nandsim: use NS_RAW_OFFSET()

Use NS_RAW_OFFSET() to calculate the page offset in flash RAM image by
(row, column) address.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nandsim: simplify NS_RAW_OFFSET()
Akinobu Mita [Sun, 28 Jul 2013 02:21:55 +0000 (11:21 +0900)]
mtd: nandsim: simplify NS_RAW_OFFSET()

Simplify the definision of NS_RAW_OFFSET() by using (ns)->geom.pgszoob
which holds the sum of page size and OOB size.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nandsim: use kasprintf()
Akinobu Mita [Sun, 28 Jul 2013 02:21:54 +0000 (11:21 +0900)]
mtd: nandsim: use kasprintf()

Use kasprintf() which combines kmalloc and sprintf.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nandsim: convert pages_written[] to bitmap
Akinobu Mita [Sun, 28 Jul 2013 02:21:53 +0000 (11:21 +0900)]
mtd: nandsim: convert pages_written[] to bitmap

nandsim.pages_written[] is the array of unsigned char which is indexed
by the page number and used for identifying which pages have been written
when cache_file is used.  Each entry holds 0 (not written) or 1 (written),
so it can be converted to bitmap.  This reduces the allocation size of
pages_written[] by 1/8.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: detect OOB size for Toshiba 24nm raw SLC
Brian Norris [Tue, 25 Jun 2013 20:17:59 +0000 (13:17 -0700)]
mtd: nand: detect OOB size for Toshiba 24nm raw SLC

Toshiba NAND datasheets have not been very forthcoming on OOB size
information; they do not provide any bitfields in the ID string for
spare area. In their 24nm technology flash, however, Toshiba migrated
their NAND to have 32 bytes spare per 512 bytes of page area (up from
the traditional 16 bytes), as they now require 8-bit ECC or higher.

I have discussed this issue directly with Toshiba representatives, and
they acknowledge this problem. They recommend detecting these flash
based on their technology node as follows:

  For 24nm Toshiba SLC raw NAND (not BENAND -- Built-in Ecc NAND), there
  are 32 bytes of spare area for every 512 bytes of in-band data area.

We can implement this rule with the following snippet of a device ID
decode table, which applies to all their 43nm, 32nm, and 24nm SLC NAND
(this table is not fully in the NAND datasheets, but it was provided
directly by Toshiba representatives):

  - ID byte 5, bit[7]:
          1    -> BENAND
          0    -> raw SLC

  - ID byte 6, bits[2:0]:
          100b -> 43nm
          101b -> 32nm
          110b -> 24nm
          111b -> Reserved

I'm also working with Toshiba on including this bitfield description for
their 5th and 6th ID bytes in their public data sheets.

I will provide the 8-byte ID strings from the two 24nm Toshiba samples I
have; their first 6 bytes match the documentation I received from
Toshiba:

  24nm SLC 1Gbit TC58NVG0S3HTA00
  0x98 0xf1 0x80 0x15 0x72 0x16 0x08 0x00

  24nm SLC 2Gbit TC58NVG1S3HTA00
  0x98 0xda 0x90 0x15 0x76 0x16 0x08 0x00

I have also tested for regressions with:

  43nm SLC 4Gbit TC58NVG2S3ETA00
  0x98 0xdc 0x90 0x15 0x76 0x14 0x03 0x10

  32nm SLC 8Gbit TC58NVG3SOFA00
  0x98 0xd3 0x90 0x26 0x76 0x15 0x02 0x08

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: jedec_probe: fix LH28F640BF definition
Andrea Adami [Sat, 20 Jul 2013 23:07:33 +0000 (01:07 +0200)]
mtd: jedec_probe: fix LH28F640BF definition

Zaurus 5500 contains 2 LH28F640BFHE-PTTL90 (64M 4Mx16) and
the LH28F640BFHE-PTTL90.pdf datasheet available on the net shows
the exact erasesize and the OTP support.
At the moment only jedec_probe can discover the chip and
the NOR is mounted read only probably because of wrong vpp.

Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: atmel_nand: fix pmecc selction for ecc requirement typo
Josh Wu [Wed, 3 Jul 2013 09:56:19 +0000 (17:56 +0800)]
mtd: atmel_nand: fix pmecc selction for ecc requirement typo

Atmel PMECC support 2, 4, 8, 12, 24 bit error correction.
So if the ecc requirement in ONFI is <= 2, 4, 8, 12, 24.
We will use 2, 4, 8, 12, 24.

This patch fix the typo. Use '<=' replace '<'.

Reported-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Josh Wu <josh.wu@atmel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: fix NAND_BUSWIDTH_AUTO for x16 devices
Brian Norris [Thu, 18 Jul 2013 08:17:02 +0000 (01:17 -0700)]
mtd: nand: fix NAND_BUSWIDTH_AUTO for x16 devices

The code for NAND_BUSWIDTH_AUTO is broken. According to Alexander:

  "I have a problem with attach NAND UBI in 16 bit mode.
   NAND works fine if I specify NAND_BUSWIDTH_16 option, but not
   working with NAND_BUSWIDTH_AUTO option. In second case NAND
   chip is identifyed with ONFI."

See his report for the rest of the details:

  http://lists.infradead.org/pipermail/linux-mtd/2013-July/047515.html

Anyway, the problem is that nand_set_defaults() is called twice, we
intend it to reset the chip functions to their x16 buswidth verions
if the buswidth changed from x8 to x16; however, nand_set_defaults()
does exactly nothing if called a second time.

Fix this by hacking nand_set_defaults() to reset the buswidth-dependent
functions if they were set to the x8 version the first time. Note that
this does not do anything to reset from x16 to x8, but that's not the
supported use case for NAND_BUSWIDTH_AUTO anyway.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Reported-by: Alexander Shiyan <shc_work@mail.ru>
Tested-by: Alexander Shiyan <shc_work@mail.ru>
Cc: Matthieu Castet <matthieu.castet@parrot.com>
Cc: <stable@vger.kernel.org> # v3.8+
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: diskonchip: remove unused entries in Kconfig
Michael Opdenacker [Mon, 8 Jul 2013 04:39:20 +0000 (06:39 +0200)]
mtd: diskonchip: remove unused entries in Kconfig

This patch proposes to remove kernel configuration parameters
defined in drivers/mtd/devices/Kconfig, but used nowhere
in the makefiles and source code (except in comments).

Signed-off-by: Michael Opdenacker <michael.opdenacker@free-electrons.com>
Acked-by: Kees Cook <keescook@chromium.org>
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: refactor call to request_module
Kees Cook [Mon, 8 Jul 2013 13:05:12 +0000 (06:05 -0700)]
mtd: refactor call to request_module

This reduces the size of the stack frame when calling request_module().
Performing the sprintf before the call is not needed.

Signed-off-by: Kees Cook <keescook@chromium.org>
Acked-by: Rusty Russell <rusty@rustcorp.com.au>
Reviewed-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: atmel_nand: don't use devm_pinctrl_get_select_default() in probe
Wolfram Sang [Wed, 10 Jul 2013 15:57:40 +0000 (16:57 +0100)]
mtd: atmel_nand: don't use devm_pinctrl_get_select_default() in probe

Since commit ab78029 (drivers/pinctrl: grab default handles from device core),
we can rely on device core for setting the default pins. Compile tested only.

Acked-by: Linus Walleij <linus.walleij@linaro.org> (personally at LCE13)
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: gpmi-nand: don't use devm_pinctrl_get_select_default() in probe
Wolfram Sang [Wed, 10 Jul 2013 15:57:41 +0000 (16:57 +0100)]
mtd: gpmi-nand: don't use devm_pinctrl_get_select_default() in probe

Since commit ab78029 (drivers/pinctrl: grab default handles from device core),
we can rely on device core for setting the default pins. Compile tested only.

Acked-by: Linus Walleij <linus.walleij@linaro.org> (personally at LCE13)
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agomtd: nand: mxc_nand: Remove unneeded check for platform_get_resource()
Fabio Estevam [Sun, 21 Jul 2013 17:52:02 +0000 (14:52 -0300)]
mtd: nand: mxc_nand: Remove unneeded check for platform_get_resource()

devm_ioremap_resource() checks its arguments, so there is no need for
explicitly checking the return value from platform_get_resource().

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>