9
0
Fork 0
Commit Graph

472 Commits

Author SHA1 Message Date
Jan Luebbe 8d95a37cae fixup! davinci_nand: add support for the NAND controller 2015-07-30 17:20:33 +02:00
Jan Luebbe f6e1175934 davinci_nand: add support for the NAND controller
This driver is based on the Linux driver (v4.0).

Signed-off-by: Jan Luebbe <jluebbe@debian.org>
2015-06-14 12:17:07 +02:00
Sascha Hauer 9ffd3d0376 mtd: ubi: create device with persistent names
UBI devices used to show up with a dynamically assigned number
which is bad for scripting. After a 'ubiattach' a script cannot
know the number of the ubi to continue with. Change this to use
the parent mtd name and extend it with ".ubi".

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-10 13:42:33 +02:00
Sascha Hauer db0d4ccd56 mtd: ubi: Let ubidetach take mtd as argument
The ubi number is a dynamically assigned number, so once multiple
ubis are attached, scripts cannot know the ubi number they want
to detach anymore. Convert the ubidetach command to take the mtd
device file instead which is the same argument that was previously
passed to ubiattach.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-10 13:42:33 +02:00
Sascha Hauer e4cabc3d89 blspec: automatically append bootargs
When bootloader spec is used to boot devices it is often desirable
to boot the same image from different media. Since the fs images
need to contain the root= parameters to tell Linux where to boot
from the images can't be identical on different media.

This patch changes this by introducing a 'appendroot' option for
bootloader spec. If set to true, barebox will construct a Linux
commandline option for the device the bootloader spec entry is found
on.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-06-10 13:42:33 +02:00
Sascha Hauer 4de5f732c0 Merge branch 'for-next/of-device-id' 2015-05-06 21:36:13 +02:00
Sascha Hauer 3975737a7d Merge branch 'for-next/misc' 2015-05-06 21:36:13 +02:00
Marc Kleine-Budde 6da925f87c mtd: of_mtd_fixup(): fix given DT not the default one
We have to start searching for the mtd node starting in the given root node not
the defaukt (= barebox internal) one. This means the internal DT is always
fixed up. This leads to booting not fixed up DT when using external DTs.

This patch fixes the problem.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-05-01 08:40:44 +02:00
Antony Pavlov 377d261708 of: use 'const void *' for struct of_device_id.data
Since 2011 barebox' of_device_id struct uses unsigned long type for data field:

    struct of_device_id {
            char *compatible;
            unsigned long data;
    };

Almost always struct of_device_id.data field are used as pointer
and need 'unsigned long' casting.

E.g. see 'git grep -A 4 of_device_id drivers/' output:

    drivers/ata/sata-imx.c:static __maybe_unused struct of_device_id imx_sata_dt_ids[] = {
    drivers/ata/sata-imx.c- {
    drivers/ata/sata-imx.c-         .compatible = "fsl,imx6q-ahci",
    drivers/ata/sata-imx.c-         .data = (unsigned long)&data_imx6,
    drivers/ata/sata-imx.c- }, {

Here is of_device_id struct in linux kernel v4.0:

    struct of_device_id {
            char name[32];
            char type[32];
            char compatible[128];
            const void *data;
    };

Changing of_device_id.data type to 'const void *data' will increase
barebox' linux kernel compatibility and decrease number of 'unsigned
long' casts.

Part of the patch was done using the 'coccinelle' tool with the
following semantic patch:

    @rule1@
    identifier dev;
    identifier type;
    identifier func;
    @@
    func(...) {
    <...
    - dev_get_drvdata(dev, (unsigned long *)&type)
    + dev_get_drvdata(dev, (const void **)&type)
    ...>
    }
    @rule2@
    identifier dev;
    identifier type;
    identifier func;
    identifier data;
    @@
    func(...) {
    <...
    - dev_get_drvdata(dev, (unsigned long *)&type->data)
    + dev_get_drvdata(dev, (const void **)&type->data)
    ...>
    }

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-04-30 08:12:57 +02:00
Sascha Hauer 10e6930323 mtd: partition: Fix OF partition fixup
To get the number of address cells and size cells we have to use
the newly created partition node, not the parent device node. The
parent device node returns the address/size cells of the controller
node, not the partition node.

On an am335x machine this fixes the device tree passed to Linux.
The situation there is:
	...
	gpmc@50000000 {
		...
		#address-cells = <0x2>;
		#size-cells = <0x1>;
		ranges = <0x0 0x0 0x8000000 0x10000000>;
		...
		nand@0,0 {
			reg = <0x0 0x0 0x0>;
			#address-cells = <0x1>;
			#size-cells = <0x1>;
			...
			partition@7 {
				label = "system";
				reg = <0x220000 0x7de0000>;
			};
		};
	};

and without this patch barebox passes three bytes for
partition@7's reg property instead of only two which naturally
confuses Linux and yields to the system partition to start at 0
with a size of 0x220000.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Tested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2015-04-28 09:09:46 +02:00
Marc Kleine-Budde 0238fb4c0d ubi: cdev: remove trailing newline from debug messages
This patch removes the trailing newline "\n" from the ubi/cdev.c debug
messages, as the macro ifself already adds a newine.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-04-23 08:12:28 +02:00
Antony Pavlov bd3e501134 mtd: m25p80: import ID for Winbond W25Q128FVSSI from linux
Winbond W25Q128FVSSI chip is used in Black Swift board,
(see http://www.black-swift.com for details).

Black Swift can run barebox for TP-LINK MR3020.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-04-14 20:49:19 +02:00
Teresa Gámez 394d4acb8d mtd: nand_omap_gpmc: Fix ecc check for bch8 romcode
The bch8 romcode was only checked and corrected for the
first 512 bytes of a 2048 byte page. Set interation counter
and eccsizes correct for the different bch types.

Tested OMAP_ECC_BCH8_CODE_HW and OMAP_ECC_BCH8_CODE_HW_ROMCODE.

Reported-by: Gabor Janak <g.janak@agilion.de>
Signed-off-by: Teresa Gámez <t.gamez@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-03-30 19:27:21 +02:00
Teresa Gámez 4ef5f8cf34 mtd: nand_omap_gpmc: Remove unused code
The ecc layout structs are not used anywhere.

Signed-off-by: Teresa Gámez <t.gamez@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-03-30 19:27:21 +02:00
Sascha Hauer 4680b375b9 Merge branch 'for-next/streaming-dma'
Conflicts:
	drivers/mci/dw_mmc.c
2015-03-09 08:32:21 +01:00
Sascha Hauer 0e055c254c Merge branch 'for-next/mtd-partitions' 2015-03-06 08:33:43 +01:00
Lucas Stach 381f034ed6 ARM: move DMA alloc functions to dma.h
This better separates the DMA from the MMU functionality.

Also move all drivers that only depends on asm/mmu.h for the alloc
functions over to the common header.

Signed-off-by: Lucas Stach <dev@lynxeye.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-03-06 07:52:02 +01:00
Lucas Stach e05f9586b3 ARM: change dma_alloc/free_coherent to match other architectures
As a lot drivers currently rely on the 1:1 virt->phys mapping on ARM
we define DMA_ADDRESS_BROKEN to mark them. In order to use them on
other architectures with a different mapping they need proper fixing.

Signed-off-by: Lucas Stach <dev@lynxeye.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-03-06 07:51:47 +01:00
Sascha Hauer ed440360e6 mtd: fixup device tree partitions
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-02-12 09:33:44 +01:00
Sascha Hauer 2bdbd1436d mtd: Add a partitions parameter to mtd devices
The partitions parameter allows to partition a mtd device
using a standard cmdline partition description string. This
way the partitions of a mtd device can be changed at once.
The output of the string can be used to be passed to the kernel
as cmdline partition string. The partitions can also still be
changed with addpart/delpart, the partitions parameter will
be updated accordingly.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-02-12 09:33:44 +01:00
Sascha Hauer 8f19864803 mtd: Use flags parameter in mtd_add_partition
mtd_add_partition is passed a flag parameter. This has been unused
so the DEVFS_PARTITION_FIXED and DEVFS_PARTITION_READONLY were ignored.
Fix this.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-02-12 09:33:44 +01:00
Sascha Hauer 8587c5f8a9 mtd: forbid conflicting mtd partitions
mtd partitions should not conflict with each other, so forbid this.
Also add the partitions to the partitions list sorted, so that they
can be easier translated into a cmdline partition string.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-02-12 09:33:44 +01:00
Sascha Hauer 7649473f40 mtd: nand: remove automatically created bb devices
the bb devices which are created in add_mtd_device() must be removed
in del_mtd_device(). Also remove deletion of the bb devices in the
mtdparts-add environment file.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-02-12 09:33:43 +01:00
Sascha Hauer 99bed34278 mtd: Add partitions to list
So that we can iterate over the existing partitions from the master
mtd device.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-02-12 09:33:43 +01:00
Sascha Hauer 891e08b822 mtd: partitions: Add error check
add_mtd_device can fail. Add an error check and bail out properly.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-02-12 09:33:43 +01:00
Sascha Hauer 31d8b2e83d mtd: partitions: Use xstrdup
The return value of strdup is not checked. Use xstrdup instead.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-02-12 09:33:43 +01:00
Sascha Hauer b798f55495 mtd: core: add error checks
register_device and devfs_create can fail. Add error checks for these.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-02-12 09:33:42 +01:00
Uwe Kleine-König dd6090ecba mtd: nand-imx: don't copy more bytes than read from hardware
The NFC command used for reading the result of a READID command to the NAND chip
reads 6 bytes (in x8 mode) or 6 words (in x16 mode with the upper bytes all
being 0). So there is no need to safe 16 bytes for later consumption.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-02-11 09:49:30 +01:00
Brian Norris 1a0ab5e97e mtd: nand: cleanup ONFI printed errors, warnings
This corresponds to commit c7f23a70635895b5125aeb5593aaf8cb44d3a088 in
the Linux kernel.

One notable difference is however that ONFI detection is allowed here
even in 16-bit mode. This is proved to work fine on an i.MX25 based
machine with a x16 NAND.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-02-11 09:49:30 +01:00
Uwe Kleine-König a6eacb9b33 mtd: nand-imx: fix byte reading in x16 mode
There are a few NAND commands that make the chip only respond on I/O
lines 0 to 7 even for x16 devices. READID (90h) is one such command
which was already handled fine in the driver (at least for NFC v1 and
v2). Other commands (like PARAM (ECh) to read out ONFI parameters)
however were not handled properly. Instead of adding another callback
make the read_byte callback handle the holes added by the NFC and depend
on the nand-base support to call read_byte when necessary instead of
read_buf.

This fixes reading the ONFI parameter page on an i.MX25 with an x16 NAND
and probably[1] also the result of READID on i.MX51/i.MX53 with x16
NAND.

[1] untested because no matching machine available

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-02-11 09:49:30 +01:00
Sascha Hauer c7dbb6c689 mtd: nand-bb: Also print raw position in debug messages
When debugging the nand-bb devices also the raw position on the
device is interesting, print it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-02-10 09:58:23 +01:00
Sascha Hauer ce073eb9e4 mtd: nand-bb: Fix test for bad block when reading
in nand_bb_read() 'offset' contains the virtual position on the device,
but we have to test for a bad block on the raw physical position, so
use bb->offset instead of offset

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-02-10 09:58:23 +01:00
Sascha Hauer eebfbe9116 mtd: nand-bb: fix erasing bb devices with bad blocks
mtd_erase does not skip bad blocks, we must skip them in nand_bb_erase
instead.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-02-10 09:58:18 +01:00
Sascha Hauer 3b71b23b46 mtd: nand-bb: Fix accesses beyond device
When a block is marked bad after the bb device has been created
the real size of the bb device is smaller than the calculated size
on creation. In this case we can't rely on the upper layers anymore
that they won't pass read/write sizes in that fit into the device.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-02-10 09:55:44 +01:00
Sascha Hauer 9d82489c07 mtd: Fix allowing to erase bad blocks on partitions
Partitions are mtd devices themselves, but the 'erasebad'
parameter is only set to the master mtd device. To allow to
erase bad blocks on partitions test the master device instead
of the partition devices.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-02-10 09:55:44 +01:00
Sascha Hauer 0d26729d85 mtd: nand: omap: Fix OMAP_ECC_BCH8_CODE_HW ecc mode
This is broken since:

| commit 00f119a293
| Author: Sascha Hauer <s.hauer@pengutronix.de>
| Date:   Fri Aug 1 14:09:48 2014 +0200
|
|     mtd: omap gpmc: fix ecc bytes/size
|
|     The ecc bytes / size are per subpage, not per page.
|
|     Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

The ecc code in omap_correct_data() expects to correct a whole page
at once, so we must tell the nand layer that we have 4 * 13 bytes of
ecc bytes and 4 * 512 bytes of ecc size. Otherwise the NAND layer will
iterate over 512 byte steps over a page and call the .correct callback
each time.

This only works for 2k pagesize and needs revisit once other page sizes
shall be supported. It would be better to tell the nand layer the real
ecc bytes (13) and ecc size (512) instead and drop the iteration in
omap_correct_bch(). However, this needs better testing so it isn't done
here now.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-02-10 09:55:43 +01:00
Sascha Hauer 1b95290433 Merge branch 'for-next/pxa' 2015-02-04 19:09:15 +01:00
Sascha Hauer ce961e3412 Merge branch 'for-next/misc' 2015-02-04 19:09:15 +01:00
Stefan Christ a114e9b00c ARM: i.MX6: use generic calculation in nand bbu handler
The parameters ECC Strength, BadBlockMarkerByte and BadBlockMarkerStartBit in
the FCB structure depends on the nand chip's pagesize and oobsize. Instead of
hardcoding these values into the imx6 bbu handler calculate these values on the
fly. Therefore we export the necessary functions from the nand_mxs driver to
use them in the bbu handler.

Signed-off-by: Stefan Christ <s.christ@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-01-29 07:58:00 +01:00
Uwe Kleine-König 866516511e trivial: s/flasg/flash/
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-01-27 08:59:18 +01:00
Robert Jarzmik 0ebe45422a mtd: nand: add mrvl-nand driver
The driver is taken from the Linux kernel, with the following changes :
 - all DMA removed
 - all asynchronous handling removed, including the interrupt handler,
   and the asynchronous state handling
 - pxa armada support removed

Most the kernel structure was kept, to ease up future fixes integration
from the kernel driver.

The driver is tested on a pxa3xx system development
board (aka. zylonite), and reading, writing, erasing, and bad block
management were tested.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-01-19 09:02:23 +01:00
Masahiro Yamada d8753571b2 sizes.h: move include/sizes.h to include/linux/sizes.h
This file originates in Linux.  Linux has it under include/linux/
directory since commit dccd2304cc90.
Let's move it to the same place as well in barebox.

This commit was generated by the following commands:

  find -name '*.[chS]' | xargs sed -i -e 's:<sizes.h>:<linux/sizes.h>:'
  git mv include/sizes.h include/linux/

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-01-08 14:00:26 +01:00
Sascha Hauer 7413dc4258 treewide: Fix typo collumn -> column
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-12-11 08:07:47 +01:00
Sascha Hauer 86916569a8 Merge branch 'for-next/imx' 2014-12-08 14:53:59 +01:00
Dmitry Lavnikevich 54961378f0 imx6: clk: Gate off ENFC clock before setting clock rate
This fixes NAND initialization issue which appears occasionally on
some i.MX6 SoCs (particulary was observed on phyCARD-i.MX6 with
i.MX6Solo).

Signed-off-by: Dmitry Lavnikevich <d.lavnikevich@sam-solutions.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-11-26 16:43:12 +01:00
Jan Weitzel c267e2dd73 mtd: ubi: get_bad_peb_limit from mtd master
Like mentioned in the coment we need the size of the entire flash chip.
Check if a master exists and take his size.

Otherwise the limit will be too small and kernel prints:
UBI warning: print_rsvd_warning: cannot reserve enough PEBs for \
bad PEB handling, reserved 19, need 20

Signed-off-by: Jan Weitzel <j.weitzel@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-11-20 14:53:42 +01:00
Uwe Kleine-König 42bc1ac850 mtd: nand_orion: remove unused goto label
This fixes the following warning:

	drivers/mtd/nand/nand_orion.c: In function ‘orion_nand_probe’:
	drivers/mtd/nand/nand_orion.c:145:1: warning: label ‘no_res’ defined but not used [-Wunused-label]

Fixes: 1a215f5 ("nand: Add Marvell Orion NAND driver")
Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-11-10 07:13:18 +01:00
Sascha Hauer 0d03667db7 Merge branch 'for-next/ubi' 2014-10-02 08:54:43 +02:00
Sascha Hauer fa93e4fb60 Merge branch 'for-next/resource-err-ptr' 2014-10-02 08:54:42 +02:00
Sascha Hauer 868de66f8d Merge branch 'for-next/mtd' 2014-10-02 08:54:42 +02:00