Commit graph

518 commits

Author SHA1 Message Date
Lucas Stach
a5afa2d86c mtd: nand_denali: don't include arch header
It causes build failures on other arches than socfpga and the driver
doesn't use anything provided by this header.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-10-14 15:33:07 +02:00
Sascha Hauer
181bb315d0 Merge branch 'for-next/mtd' 2015-10-07 08:23:45 +02:00
Enrico Jorns
16a6d8a674 mtd denali: pass col argument to READID operation
A read id operation followed by 0x00 reads the device ID while
a read id operation followed by 0x20 reads the possible ONFI identifier.

As the READID function did not propagate the second id parameter but had
a hard-coded call for 0x90 0x00, reading the ONFI identifier was not
possible and thus chips werde not detected (tested with
MT29F8G08ABABAWP)

Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-09-23 10:35:37 +02:00
Enrico Jorns
aca725cc86 mtd nand_denali: Add denali nand driver
The driver is based on the denali driver from the linux kernel

Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-09-23 10:35:37 +02:00
Enrico Jorns
61720f7bd4 mtd nand: added 'bits_per_cell' property
This one is available in the kernel and used by the denali driver

Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-09-23 10:33:23 +02:00
Antony Pavlov
1734538494 mtd: spi-nor: add Spansion S25FL204K support
Spansion S25FL204K is a 4-Mbit 3.0V Serial Flash Memory
with Uniform 4 kB Sectors.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Acked-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-09-02 07:54:26 +02:00
Sascha Hauer
60fc3e99b5 Merge branch 'for-next/mtd' 2015-09-01 09:43:54 +02:00
Sascha Hauer
311f02fbe4 mtd: spi-nor: mostly drop lock/unlock code
The lock/unlock code is broken beyond repair.

First of all the algorithm doesn't work properly. SPI NOR flashes
can only protect a certain amount of blocks from the end of the device
which is incompatible to the protect(start,len) API we have. The
algorithm tries to be clever by doing protection only when it does
not protect unrelated blocks and unprotection only when it does not
unprotect unrelated blocks. This breaks for example when some code
protects the last blocks (which may contain the bootloader), then
protects the blocks before the last ones (which may contain the
environment). Then if we try to overwrite the bootloader this won't
work since it would unprotect the environment aswell, so the driver
will not unprotect anything resulting in a failed erase/write later.

Then the protection behaviour is different between different flashes.
Some have three protection bits, some have four. For some the smallest
protection are is 1/16 of the device, others have 1/256 or 1/64. Some
have a bit which selects the lower area instead of upper area for
protection. The position of this bit differs on different flashes.

This patch removes the lock code completely and always unprotects
the whole device. This way we can unprotect a device for writing to
it and never protect it again.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-08-28 11:11:46 +02:00
Sascha Hauer
3e1adbf832 mtd: m25p80: make it possible to use large blocks if desired
Some SPI NOR flashes support 4K erase blocks. 4K erase blocks do not
work with UBIFS which needs a minimum erase block size of 15360 bytes.
Also bigger sectors are faster to erase. This patch adds a device tree
option to use the bigger blocks instead of the default 4K blocks.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
2015-08-26 15:14:00 +02:00
Robert Jarzmik
73deb9f992 mtd: nand: mrvl-nand: create initial empty bbt
When creating an initial bad blocks table, create it empty. This is
necessary because when the bad block table blocks are not
initialized (all ff) while some partitions are, all the blocks which
have an OOB data not beginning with 0xff 0xff will be marked as bad
blocks in the initial bad blocks scan.

As a consequence, any existing blocks are impossible to erase
anymore. Fix this by fixing the BBT creation flag.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-08-19 16:24:39 +02:00
Fabio Estevam
81caed9cce spi-nor: Align spi_nor_ids[] with kernel 4.1
Sync the spi_nor_ids[] struct with the one from kernel 4.1.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-08-19 16:22:20 +02:00
Sascha Hauer
4ee01d2b46 Merge branch 'for-next/misc' 2015-08-06 12:33:15 +02:00
Antony Pavlov
4f37af47a8 mtd: nand_base: replace ifdef with IS_ENABLE
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-08-06 12:30:18 +02:00
Sascha Hauer
4955c2c1bc mtd: concat: initialize *retlen
In concat_write and concat_read *retlen is only added to, but it's never
initialized. If the caller hasn't initialized retlen doesn't contain
valid values. Fix this by initializing *retlen properly.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-08-05 14:47:59 +02:00
Sascha Hauer
db48d9d190 mtd: cfi-flash: Fix info
Since

636d384 mtd: cfi-flash: Add mtd concat support

The devinfo output is broken. dev->priv no longer contains a
struct flash_info * but instead a struct cfi_priv *.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-08-05 14:47:36 +02:00
Sascha Hauer
742bd91919 mtd: of: put master offset into partition name
Partition names should be partition@<offset> with <offset> being the
offset in the master mtd, and not a counting number.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-07-23 15:16:56 +02:00
Teresa Remmet
aa2bbd2d57 mtd: core: Check partitions for empty string
Make setting partitions a litte bit more robust.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-07-20 07:29:23 +02:00
Sascha Hauer
d297851b1a Merge branch 'for-next/blspec' 2015-07-06 12:43:29 +02:00
Sascha Hauer
7b4e61bbf9 Merge branch 'for-next/mtd'
Conflicts:
	drivers/mtd/core.c
2015-07-03 08:37:52 +02:00
Sascha Hauer
f2a2894c27 Merge branch 'for-next/misc' 2015-07-03 08:37:40 +02:00
Sascha Hauer
c5438404db Merge branch 'for-next/imx-bbu-nand-fcb'
Conflicts:
	common/Kconfig
2015-07-03 08:37:36 +02:00
Sascha Hauer
021dda6744 Merge branch 'for-next/cfi-flash' 2015-07-03 08:37:29 +02:00
Sascha Hauer
5f51ca71f6 mtd: m25p80: Fix Kconfig dependencies
The m25p80 driver now depends on MTD_SPI_NOR which is disabled in all
defconfigs, so this effectively disables the m25p80 driver in all
defconfigs. Fix this by selecting MTD_SPI_NOR which is library code
without further dependencies. Also let m25p80 depend on SPI because
it needs the SPI code and won't link without it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-29 07:13:23 +02:00
Sascha Hauer
3fc17ce4c8 mtd: m25p80: make flash_name const
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-29 07:07:30 +02:00
Sascha Hauer
5f11e80670 mtd: Make devname argument to add_mtd_device const
add_mtd_device duplicates the string where necessary, so make it
const.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-29 07:04:55 +02:00
Sascha Hauer
c54fb2ecbd ubi: Lower 'already attached' message to debug level
The caller will show a message, no need to do this in UBI. This
is for the case when mtd_detect calls ubi_attach_mtd_dev. mtd_detect
does not know whether this is already attached and it's not an error.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-26 09:21:37 +02:00
Sascha Hauer
542a81fff3 mtd: detect ubi devices automatically
Hook UBI attachment into the mtd class devices detect function. This
makes it possible to attach ubi devices with 'detect nand0.root'.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-26 09:21:37 +02:00
Sascha Hauer
adb3c6359d ubi: Use preditable device names
Instead of naming all ubi devices and cdev names ubi<num> append
'.ubi' to the original mtd name. This makes ubi device and cdev
names predictable. With this ubi0 becomes nand0.root.ubi. Also
do the same for volume names, so ubi0.root becomes nand0.root.ubi.root.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-26 09:21:36 +02:00
Sascha Hauer
636d384ed4 mtd: cfi-flash: Add mtd concat support
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-23 16:59:54 +02:00
Sascha Hauer
ce72d46f42 mtd: Add mtd concat support
The mtd concat layer supports concatenating several MTD devices
into a single one. This is nearly as-is from the corresponding
Kernel code.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-23 16:59:54 +02:00
Sascha Hauer
713285ca19 mtd: cfi-flash: remove dead code
CFG_FLASH_PROTECTION is never defined, remove the code. Also
remove code inside #if 0.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-22 10:38:31 +02:00
Sascha Hauer
9746f02cae mtd: cfi-flash: Coding style cleanup
- use consistent variable types (drop uchar, ushort and friends)
- remove whitespace between functions and opening brace
- Add some blank lines to rectify code
- drop 'rc' and 'retcode' and use 'ret' consistently
- Do not put variable assignment into if()
- drop unncessary braces

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-22 10:38:31 +02:00
Sascha Hauer
6be93f2fce mtd: cfi-flash: use unaligned accessor functions
Some members in struct cfi_qry are unaligned. Use get_unaligned_*
to access them. Fixes unaligned aborts on busses which don't support
unaligned accesses.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-22 09:27:59 +02:00
Sascha Hauer
9c48ac000b mtd: cfi-flash: turn some messages into vdbg
Some messages produce a lot of log spam. Turn them into
dev_vdbg to make some more important messages more visible.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-22 09:27:59 +02:00
Sascha Hauer
81d8fa83b4 mtd: cfi-flash: return 0 for success
Use zero as success return code and negative standard error codes
consistently in the driver.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-22 09:26:52 +02:00
Sascha Hauer
0203b33d14 mtd: cfi-flash: make flash_detect_width more readable
Use variables instead of long defines to get the loops into a single
line. Also use goto to move the deeply indented code more to the left.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-22 09:17:16 +02:00
Sascha Hauer
20a096120a mtd: cfi-flash: remove unnecessary ifdefs
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-22 09:17:16 +02:00
Sascha Hauer
25b42d1fe7 mtd: cfi-flash: replace ifdef with IS_ENABLED
TO get rid of some ifdefs. While at it add the vendor code of
the unsupported vendor to the error message.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-22 09:16:40 +02:00
Sascha Hauer
2ec3921248 mtd: cfi-flash: statically initialize instead of memset
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-22 08:59:59 +02:00
Sascha Hauer
bbc89b5754 mtd: cfi-flash: save indention level
Bail out early in flash_get_size() and save an indention level.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-22 08:58:56 +02:00
Sascha Hauer
1099bd178e mtd: cfi-flash: We can print longlongs
printf supports printing longlongs, so drop print_longlong.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-22 08:58:15 +02:00
Sascha Hauer
745594d51a fs: ubifs: Implement Linux rootarg
Add the parameter to boot from ubifs fileystems. This assumes that
there will be only one UBI device registered in the kernel, otherwise
there is no way to predict the ubi number.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-18 09:01:01 +02:00
Sascha Hauer
b7b0b348a5 mtd: m25p80: Whitespace cleanup
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-17 08:03:58 +02:00
Sascha Hauer
ff40732d0a mtd: partition: implement write_oob
To enable mtd_write_oob for partitions.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-12 08:28:04 +02:00
Sascha Hauer
3a32e7acd4 Merge branch 'for-next/spi-nor' 2015-06-09 09:26:44 +02:00
Steffen Trumtrar
04a2c84fda mtd: m25p80: use the SPI nor framework
Use the spi-nor framework for the m25p80 driver to de-duplicate the code base
and follow along with the linux kernel version, so bugfixes or features can be
easier integrated.

Based on the Linux v4.1-rc3 version of m25p80.c.

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-05-29 09:10:38 +02:00
Steffen Trumtrar
51de1b3c40 mtd: spi-nor: add cadence quadspi driver
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-05-29 09:08:49 +02:00
Steffen Trumtrar
160a10252e mtd: spi-nor: add SPI-NOR framework
Import the SPI-NOR framework from linux kernel v3.19.

Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-05-29 09:08:49 +02:00
Masahiro Yamada
5731d3ebcc Abolish cpu_read* and cpu_write* accessors
Commit 2e6a88f210 (add cpu native ordered io accessors) introduced
these macros and then commit be57f20cdd (Fix big endian MMIO
primitives) figured out they are equivalent to __raw_{read,write}*.

They turned out unnecessary after all.  Anyway, most source files
use __raw_read* and __raw_write*.

Let's replace a few remaining references and abolish them.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-05-20 08:05:44 +02:00
Sascha Hauer
1ec907c701 mtd: nand: Fix format specifier
'count' is of type size_t, so use %zx.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-05-15 07:01:43 +02:00