mtd: nand: register nand flashes with nand specific function

This allows us to have some NAND specific stuff during registration,
like for example adding NAND specific device parameters.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
mtd: Add parameter to allow erasing bad blocks

While erasing bad blocks is a potentially dangerous operation
it is sometimes needed during development or when some foreign
code has touched the flash.

This patch adds a device parameter 'erasebad' to allow erasing
bad blocks. Since this is not wanted during production this is
behind a Kconfig option.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
mtd nand: introduce bbm.h

This file is present in current kernels. In order to get closer
to current mtd support introduce it for barebox aswell.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
nand command: use loff_t for block offset

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
nand command: use enumeration for command instead of bitmask

A command can only be one of NAND_*, so use an enumeration instead
of a bitmask.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
nand command: check for <dev> directly after option parsing

Allo subcommands need at least one nonopt arg, so check for
it right after parsing the options and drop the check in the
MARKBAD command.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
mtd: nand: replace NAND_USE_FLASH_BBT with NAND_BBT_USE_FLASH

To sync with the kernel.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
mtd nand i.MX: remove unused code

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
ARM: make cpu architecture detection available as static inline function

When we have multi cpu support compiled in we need the cpu architecture
early so that we can pick the correct cacheflush function. Make it available
as static inline function and add a comment above it that this function
normally should not be used.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
ARM: add early mmu cache flush function and use it in setup_c

Since recently with MMU_EARLY support it may happen that setup_c
runs with data caches enabled, so we have to make sure the caches
are flushed before we jump to the new binary.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
of: unflatten: allocate root node explicitly

By doing so of_new_node does not depend on the global root_node
anymore.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
of: export of_find_child

of_find_child is a useful function. Export it and rename it to
of_find_child_by_name.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
of: removed unused variables

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
of: Let of_find_node_by_path iterate over tree

of_find_node_by_path iterates over the allnodes list. Depending on
where the node we look for is, this can be significantly slower than
using the tree structure to look for a node, so iterate over the tree
instead.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
of: remove allnodes list

The allnodes list makes it hard to handle multiple devicetrees. Having
a list to iterate over all nodes of a tree is still good to have though.
This patch uses the list_head of the root node as the head of the list.
This way the root node is no longer part of the list, but when iterating
over a tree the root node is not interesting anyway.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
ARM bootm: Use of_get_fixed_tree

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
of: Add of_set_property and of_create_node

Add functions to create a new device node and to create/set
a new property based on the nodepath.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
of_node command: use of_create_node

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
of: Add missing prototype for of_device_is_compatible

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
of: let of_unflatten_dtb return the unflattened tree

In order to be able to handle multiple devicetrees, do not assume
the tree to be unflattened is the barebox internal one. Instead,
just return a pointer to it and assign the barebox internal root_node
external to the unflatten function.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>