dtc: Dynamic symbols & fixup support (v2)

Enable the generation of symbol & fixup information for
usage with dynamic DT loading.

Passing the -@ option generates a __symbols__ node at the
root node of the resulting blob for any node labels used.

When using the /plugin/ tag all unresolved label references
be tracked in the __fixups__ node, while all local phandle
references will the tracked in the __local_fixups__ node.

This is sufficient to implement a dynamic DT object loader.

Changes since v1:

* Forward ported to 1.4 version
* Added manual entries for the -@ option

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
dtc: Update shipped files after DT objects

Update shipped files after DT object support.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
of: Do not free memory at of_node_release

The life-cycle of nodes and properties does not allow us to release
the memory taken by a device_node. Pointer to properties and nodes
might still be in use in drivers, so any memory free'ing is dangerous.

Simply move all the properties to the deadprops list, and the node
itself to of_alldeadnodes until the life-cycles issues are resolved.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
OF: Add [__]of_find_node_by_full_name

__of_find_node_by_full_name recursively searches for a matching node
with the given full name without taking any locks.

of_find_node_by_full_name takes locks and takes a reference on the
matching node.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
of: platform: Fix and export of_platform_device_destroy

of_platform_destroy did not work properly, since the tree
population test was iterating on all devices having a parent
a given platform device.

The check was intended to check whether any other *platform*
devices were still populated, but instead checked for every
kind of device. This is wrong, since platform devices typically
create a subsystem regular device and set themselves as parents.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
OF: Export a number of __of_* methods

As part of moving to transactional DT, a number of methods are
reworked and exported.

The methods exported are:

__of_get_next_child, __for_each_child_of_node, __of_add_property,
__of_remove_property, __of_update_property, __of_attach_node,
__of_detach_node, __of_device_is_compatible, __of_device_is_available,
__of_get_property.

__of_update_property has been reworked to be more efficient
(double walk of the property list eliminated)
of_get_property was reworked to use __of_get_property internally.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
OF: Utility helper functions for dynamic nodes

Introduce helper functions for working with the live DT tree,
all of them related to dynamically adding/removing nodes and
properties.

__of_copy_property() copies a property dynamically
__of_create_empty_node() creates an empty node

Bug fix about prop->len == 0 by Ionut Nicu <ioan.nicu.ext@nsn.com>

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
of: Introduce tree change __foo_post methods.

As part of transactional DT support there needs to be a clearer
definition of how each dynamic tree change method works.

Let's take for example the of_add_property method. There are
discrete steps taken in sequence.

1. The OF_RECONFIG_ADD_PROPERTY notifier will be fired.
2. The devtree lock will be taken.
3. Insertion of the property in the live tree.
4. The devtree lock will be released.
5. The property will be inserted in the sysfs tree.

For each of the of_attach_node, of_detach_node, of_add_property,
of_remove_property and of_update_property methods we export (and
introduce if not available), their counterparts of
__of_attach_node, __of_attach_node_post, __of_detach_node,
__of_detach_node_post, __of_add_property, __of_add_property_post,
__of_remove_property, __of_remove_property_post, __of_update_property
and __of_update_property post.

So each of the tree modification methods is following the same
pattern, i.e. for method foo we have:

Firing of the notifer, lock, __foo, unlock, __foo_post

This breakdown is required when we introduce transaction.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
of: Transactional DT support.

Introducing DT transactional support.

A DT transaction is a method which allows one to apply changes
in the live tree, in such a way that either the full set of changes
take effect, or the state of the tree can be rolled-back to the
state it was before it was attempted. An applied transaction
can be rolled-back at any time.

If any transaction results in the change of a state of a device
node, a notifier for that node will be fired which allows a bus
to create/destroy devices as directed.

Documentation is in
	Documentation/devicetree/transactions.txt

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
OF: Introduce Device Tree resolve support.

Introduce support for dynamic device tree resolution.
Using it, it is possible to prepare a device tree that's
been loaded on runtime to be modified and inserted at the kernel
live tree.

Export of of_resolve and bug fix of double free by
	Guenter Roeck <groeck@juniper.net>

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
OF: Introduce DT overlay support.

Introduce DT overlay support.

Makes it possible to dynamically overlay a part of the kernel's
tree with another tree that's been dynamically loaded.
Removal of nodes and properties is also possible.

The hard part of applying and reverting the overlay is done
using transactions.

Documentation about internal and APIs is provided in
	Documentation/devicetree/overlay-notes.txt

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
OF: selftest: Add overlay self-test support.

This patch adds overlay tests to the OF selftest.

It tests overlay device addition/removal and whether
the apply revert sequence is correct.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
OF: DT-Overlay configfs interface (v2)

Add a runtime interface to using configfs for generic device tree overlay
usage.

A device-tree configfs entry is created in /config/device-tree/overlays

* To create an overlay you mkdir the directory:

	# mkdir /config/device-tree/overlays/foo

* Either you echo the overlay firmware file to the path property file.

	# echo foo.dtbo >/config/device-tree/overlays/foo/path

* Or you cat the contents of the overlay to the dtbo file

	# cat foo.dtbo >/config/device-tree/overlays/foo/dtbo

The overlay file will be applied.

To remove it simply rmdir the directory.

	# rmdir /config/device-tree/overlays/foo

Changes since v1:
* Implemented dtbo interface (relies on binary configfs attributes)

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
OF: platform: Add OF notifier handler (v2)

Add OF notifier handler needed for creating/destroying platform devices
according to dynamic runtime changes in the DT live tree.

Changes since V1:
* Use of_platform_device_destroy since it handles OF_POPULATED correctly.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
of: i2c: Export single device registration method

Dynamically inserting i2c client device nodes requires the use
of a single device registration method. Rework and export it.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
OF: i2c: Add OF notifier handler

Add OF notifier handler needed for creating/destroying i2c devices
according to dynamic runtime changes in the DT live tree.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
of: spi: Export single device registration method and accessors

Dynamically inserting spi device nodes requires the use of a single
device registration method. Rework and export it.

Methods to lookup a device/master using a device node are added
as well, of_find_spi_master_by_node() & of_find_spi_device_by_node().

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
OF: spi: Add OF notifier handler

Add OF notifier handler needed for creating/destroying spi devices
according to dynamic runtime changes in the DT live tree.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
gitignore: Ignore DTB files

Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
add PM firmware

Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>