oweals/u-boot.git
7 years agodm: regulator: Update fixed regulator to support livetree.
Simon Glass [Fri, 19 May 2017 02:09:35 +0000 (20:09 -0600)]
dm: regulator: Update fixed regulator to support livetree.

Update this driver to support a live device tree.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: regulator: Convert regulator uclass to support livetree
Simon Glass [Fri, 19 May 2017 02:09:34 +0000 (20:09 -0600)]
dm: regulator: Convert regulator uclass to support livetree

Update the regulator uclass to support a live device tree.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agosandbox: pmic: Convert pmic emulator to support livetree
Simon Glass [Fri, 19 May 2017 02:09:33 +0000 (20:09 -0600)]
sandbox: pmic: Convert pmic emulator to support livetree

Update this driver to support a live device tree.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: pmic: Convert uclass to livetree
Simon Glass [Fri, 19 May 2017 02:09:32 +0000 (20:09 -0600)]
dm: pmic: Convert uclass to livetree

Update the pmic uclass and all pmics to support a live device tree.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agosamsung: Move pmic header out of config file
Simon Glass [Fri, 19 May 2017 02:09:31 +0000 (20:09 -0600)]
samsung: Move pmic header out of config file

We should not be including a PMIC header file in the board config. Move it
to a C file.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: i2c: Convert uclass to livetree
Simon Glass [Fri, 19 May 2017 02:09:30 +0000 (20:09 -0600)]
dm: i2c: Convert uclass to livetree

Update the i2c uclass to support a live device tree.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agostring: Add strcspn()
Simon Glass [Fri, 19 May 2017 02:09:29 +0000 (20:09 -0600)]
string: Add strcspn()

Add an implementation of strcspn() which returns the number of initial
characters that do not match any in a rejection list.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agostring: Add strchrnul()
Simon Glass [Fri, 19 May 2017 02:09:28 +0000 (20:09 -0600)]
string: Add strchrnul()

This functions works like strchr() but returns the end of the string if
the character is not found. Add an implementation of this.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: Add more livetree helpers and definitions
Simon Glass [Fri, 19 May 2017 02:09:27 +0000 (20:09 -0600)]
dm: Add more livetree helpers and definitions

Add some definitions and helpers for livetree in the main of.h header
file. These include:

- reading multi-cell integers
- default number of address/size cells
- functions for comparing names

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agofdt: Rename a few functions in fdt_support
Simon Glass [Fri, 19 May 2017 02:09:26 +0000 (20:09 -0600)]
fdt: Rename a few functions in fdt_support

These two functions have an of_ prefix which conflicts with naming used
in of_addr. Rename them:

   fdt_read_number
   fdt_support_bus_default_count_cells

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agotest: Update 'make test' to run more tests
Simon Glass [Fri, 19 May 2017 02:09:25 +0000 (20:09 -0600)]
test: Update 'make test' to run more tests

The standard sandbox board cannot run the of-platdata test since it needs
SPL. Also, we should test the flat tree version of sandbox.

Add these tests to the default test script.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agosandbox: Add a new sandbox_flattree board
Simon Glass [Fri, 19 May 2017 02:09:24 +0000 (20:09 -0600)]
sandbox: Add a new sandbox_flattree board

Add a sandbox board to test the non-livetree build (i.e. with
CONFIG_OF_FLAT disabled). This increases our build and test coverage.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agocros_ec: Convert to support live tree
Simon Glass [Fri, 19 May 2017 02:09:23 +0000 (20:09 -0600)]
cros_ec: Convert to support live tree

Convert this driver to support the live device tree and remove the old
fdtdec support.

The keyboard is not yet converted.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agocros_ec: Fix debug() statement in ec_command_inptr()
Simon Glass [Fri, 19 May 2017 02:09:22 +0000 (20:09 -0600)]
cros_ec: Fix debug() statement in ec_command_inptr()

This prints out the wrong pointers. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: gpio: Add live tree support
Simon Glass [Wed, 31 May 2017 03:47:09 +0000 (21:47 -0600)]
dm: gpio: Add live tree support

Add support for requesting GPIOs with a live device tree.

This involves adjusting the function signature for the legacy function
gpio_request_by_name_nodev(), so fix up all callers.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes to stm32f746-disco.c:
Signed-off-by: Tom Rini <trini@konsulko.com>
7 years agodm: gpio: sandbox: Use dev_read...() functions to access DT
Simon Glass [Fri, 19 May 2017 02:09:20 +0000 (20:09 -0600)]
dm: gpio: sandbox: Use dev_read...() functions to access DT

Use the new dev_read...() functions to access the device tree, so that a
live tree can be used.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: gpio: Drop blank line in gpio_xlate_offs_flags() comment
Simon Glass [Fri, 19 May 2017 02:09:19 +0000 (20:09 -0600)]
dm: gpio: Drop blank line in gpio_xlate_offs_flags() comment

This is not needed. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: gpio: Refactor to prepare for live tree support
Simon Glass [Fri, 19 May 2017 02:09:18 +0000 (20:09 -0600)]
dm: gpio: Refactor to prepare for live tree support

Move the main part of the GPIO request function into a separate function
so that it can be used by the live tree function when added. Update the
xlate method to use a node reference.

Update all GPIO drivers to handle the modified xlate() method.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: core: Run tests with both livetree and flat tree
Simon Glass [Fri, 19 May 2017 02:09:17 +0000 (20:09 -0600)]
dm: core: Run tests with both livetree and flat tree

Some tests require either livetree or flat tree. Add flags to allow the
tests to specify this. Adjust the test runner to run with livetree (if
supported) and then flat tree.

Some video tests are quite slow and running on flat tree adds little extra
test value, so run these on livetree only.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: test: Add support for running tests with livetree
Simon Glass [Fri, 19 May 2017 02:09:16 +0000 (20:09 -0600)]
dm: test: Add support for running tests with livetree

It is useful to run the driver model tests with both livetree and flat
tree in case something is different between the two. Add this feature to
the test runner.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: test: Show the test filename when running
Simon Glass [Fri, 19 May 2017 02:09:15 +0000 (20:09 -0600)]
dm: test: Show the test filename when running

Show the filename of the test being run. Skip the path and show just the
base name.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: test: Move test running code into a separate function
Simon Glass [Fri, 19 May 2017 02:09:14 +0000 (20:09 -0600)]
dm: test: Move test running code into a separate function

We want to run the same test on flat and live trees. In preparation for
this, create a new function which handles running a test.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agosandbox: Add a way to reset sandbox state for tests
Simon Glass [Fri, 19 May 2017 02:09:13 +0000 (20:09 -0600)]
sandbox: Add a way to reset sandbox state for tests

Running a new test should reset the sandbox state to avoid tests
interferring with each other. Move the existing state-reset code into a
function so it can be used from tests.

Also update the code to reset the SPI devices and adjust the test code to
call it.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: core: Update uclass_find_device_by_phandle() for livetree
Simon Glass [Fri, 19 May 2017 02:09:12 +0000 (20:09 -0600)]
dm: core: Update uclass_find_device_by_phandle() for livetree

Adjust this function to work with livetree.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: simple-bus: Add support for livetree
Simon Glass [Fri, 19 May 2017 02:09:11 +0000 (20:09 -0600)]
dm: simple-bus: Add support for livetree

Modify simple-bus to support livetree.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: regmap: Add support for livetree
Simon Glass [Fri, 19 May 2017 02:09:10 +0000 (20:09 -0600)]
dm: regmap: Add support for livetree

Modify regmap to support livetree.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: core: Add a way to find a device by ofnode
Simon Glass [Fri, 19 May 2017 02:09:09 +0000 (20:09 -0600)]
dm: core: Add a way to find a device by ofnode

Add a function which looks up a device by its node (either in live tree
or flat tree).

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: core: Scan the live tree when setting up driver model
Simon Glass [Fri, 19 May 2017 02:09:08 +0000 (20:09 -0600)]
dm: core: Scan the live tree when setting up driver model

When starting up driver model with a live tree we need to scan the tree
for devices. Add code to handle this.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: core: Update device_bind_driver_to_node() to use ofnode
Simon Glass [Fri, 19 May 2017 02:09:07 +0000 (20:09 -0600)]
dm: core: Update device_bind_driver_to_node() to use ofnode

Adjust this function to us an ofnode instead of an offset, so it can be
used with livetree. This involves updating all callers.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: core: Update lists_bind_fdt() to use ofnode
Simon Glass [Fri, 19 May 2017 02:09:06 +0000 (20:09 -0600)]
dm: core: Update lists_bind_fdt() to use ofnode

Adjust this function to use an ofnode instead of an offset, so it can be
used with livetree. This involves updating all callers.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: core: Allow binding a device from a live tree
Simon Glass [Fri, 19 May 2017 02:09:05 +0000 (20:09 -0600)]
dm: core: Allow binding a device from a live tree

When a live tree is being used we need to record the node that was used to
create the device. Update device_bind_with_driver_data() to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: core: Implement live tree 'read' functions
Simon Glass [Fri, 19 May 2017 02:09:04 +0000 (20:09 -0600)]
dm: core: Implement live tree 'read' functions

When the live tree is supported some functions need to change a little.
Add an implementation which is used when not inlining these functions.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: core: Add device-based 'read' functions to access DT
Simon Glass [Fri, 19 May 2017 02:09:03 +0000 (20:09 -0600)]
dm: core: Add device-based 'read' functions to access DT

It is common to read a device-tree property from the node associated with
a device. Add convenience functions to do this so that drivers do not need
to deal with accessing the ofnode from the device.

These functions all start with 'dev_read_' to provide consistent naming
for all functions which read information from a device's device tree node.

These are inlined when using the flat DT to save code size. The live tree
implementation is added in a later commit.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: core: Add a place to put extra device-tree reading functions
Simon Glass [Fri, 19 May 2017 02:09:02 +0000 (20:09 -0600)]
dm: core: Add a place to put extra device-tree reading functions

Some functions deal with structured data rather than simple data types.
It makes sense to have these in their own file. For now this just has a
function to read a flashmap entry. Move the data types also.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: core: Add address operations on device tree references
Simon Glass [Fri, 19 May 2017 02:09:01 +0000 (20:09 -0600)]
dm: core: Add address operations on device tree references

Add functions to add addresses in the device tree using ofnode references.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agofdt: Update fdt_get_base_address() to use const
Simon Glass [Fri, 19 May 2017 02:09:00 +0000 (20:09 -0600)]
fdt: Update fdt_get_base_address() to use const

This function does not change the device tree so adjust it to use const
for this parameter.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: core: Add livetree address functions
Simon Glass [Fri, 19 May 2017 02:08:59 +0000 (20:08 -0600)]
dm: core: Add livetree address functions

Add functions to access addresses in the device tree. These are brought
in from Linux 4.10.

Also fix up the header guard for fdtaddr.h to avoid confusion.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: core: Add operations on device tree references
Simon Glass [Fri, 19 May 2017 02:08:58 +0000 (20:08 -0600)]
dm: core: Add operations on device tree references

Since U-Boot supports both a live tree and a flat tree, we need an easy
way to access the tree without worrying about which is currently active.
To support this, U-Boot has the concept of an ofnode, which can refer
either to a live tree node or a flat tree node.

For the live tree, the reference contains a pointer to the node (struct
device_node *) or NULL if the node is invalid. For the flat tree, the
reference contains the node offset or -1 if the node is invalid.

Add a basic set of operations using ofnodes. These are implemented by
using either libfdt functions (in the case of a flat DT reference) or
the live-tree of_...() functions.

Note that it is not possible to have both live and flat references active
at the same time. As soon as the live tree is available, everything in
U-Boot should switch to using that. This avoids confusion and allows us to
assume that the type of a reference is simply based on whether we have a
live tree yet, or not.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: core: Rename of_device_is_compatible()
Simon Glass [Fri, 19 May 2017 02:08:57 +0000 (20:08 -0600)]
dm: core: Rename of_device_is_compatible()

The of_ prefix conflicts with the livetree version of this function.
Rename it to avoid problems when we add livetree support.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: Build a live tree after relocation
Simon Glass [Fri, 19 May 2017 02:08:56 +0000 (20:08 -0600)]
dm: Build a live tree after relocation

If enabled, build a live device tree after relocation. This can then be
used by driver model.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: Add a function to create a 'live' device tree
Simon Glass [Fri, 19 May 2017 02:08:55 +0000 (20:08 -0600)]
dm: Add a function to create a 'live' device tree

This function converts the flat device tree into a hierarchical one with
C structures and pointers. This is easier to access.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: core: Add livetree access functions
Simon Glass [Fri, 19 May 2017 02:08:54 +0000 (20:08 -0600)]
dm: core: Add livetree access functions

Add a basic assortment of functions to access the live device tree. These
come from Linux v4.9 and are modified for U-Boot to the minimum extent
possible. While these functions are now very stable in Linux, it will be
possible to merge in fixes if needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: core: Add livetree definitions
Simon Glass [Fri, 19 May 2017 02:08:53 +0000 (20:08 -0600)]
dm: core: Add livetree definitions

Add a Kconfig option to enable a live device tree, built at run time from
the flat tree. Also add structure definitions and a root node.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agoUpdate WARN_ON() to return a value
Simon Glass [Fri, 19 May 2017 02:08:52 +0000 (20:08 -0600)]
Update WARN_ON() to return a value

In linux v4.9 this returns a value. This saves checking the warning
condition twice in some code.

Update the U-Boot version to do this also.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: core: Set return value first in lists_bind_fdt()
Simon Glass [Fri, 19 May 2017 02:08:51 +0000 (20:08 -0600)]
dm: core: Set return value first in lists_bind_fdt()

Adjust the order to make it clear that *devp is set to NULL by default.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agotegra: Convert MMC to use driver model for operations
Simon Glass [Mon, 24 Apr 2017 02:02:11 +0000 (20:02 -0600)]
tegra: Convert MMC to use driver model for operations

Enable CONFIG_DM_MMC_OPS and CONFIG_BLK for all Tegra devices. This moves
Tegra to use driver model fully for MMC.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: mmc: Rewrite mmc_blk_probe()
Simon Glass [Mon, 24 Apr 2017 02:02:10 +0000 (20:02 -0600)]
dm: mmc: Rewrite mmc_blk_probe()

This function is called when the MMC block device is being probed. There
is a recursive call in this function since find_mmc_device() itself can
cause the MMC device to be probed.

Admittedly the MMC device should already be probed, since we would not be
probing its child otherwise, but the current code is unnecessarily
convoluted.

Rewrite this to access the MMC structure directly.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: mmc: Check that drivers have operations
Simon Glass [Mon, 24 Apr 2017 02:02:09 +0000 (20:02 -0600)]
dm: mmc: Check that drivers have operations

When binding a new MMC device, make sure that it has the required
operations. Since for now we still support *not* having the operations
(with CONFIG_DM_MMC_OPS not enabled) it makes sense to add this check.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: blk: Improve block device claiming
Simon Glass [Mon, 24 Apr 2017 02:02:07 +0000 (20:02 -0600)]
dm: blk: Improve block device claiming

The intention with block devices is that the device number (devnum field
in its descriptor) matches the alias of its parent device. For example,
with:

aliases {
mmc0 = "/sdhci@700b0600";
mmc1 = "/sdhci@700b0400";
}

we expect that the block devices for mmc0 and mmc1 would have device
numbers of 0 and 1 respectively.

Unfortunately this does not currently always happen. If there is another
MMC device earlier in the driver model data structures its block device
will be created first. It will therefore get device number 0 and mmc0
will therefore miss out. In this case the MMC device will have sequence
number 0 but its block device will not.

To avoid this, allow a device to request a device number and bump any
existing device number that is using it. This all happens during the
binding phase so it is safe to change these numbers around. This allows
device numbers to match the aliases in all circumstances.

Add a test to verify the behaviour.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: blk: Add a function to find the next block device number
Simon Glass [Mon, 24 Apr 2017 02:02:06 +0000 (20:02 -0600)]
dm: blk: Add a function to find the next block device number

At present this code is inline. Move it into a function to allow it to
be used elsewhere.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: blk: Allow finding block devices without probing
Simon Glass [Mon, 24 Apr 2017 02:02:05 +0000 (20:02 -0600)]
dm: blk: Allow finding block devices without probing

Sometimes it is useful to be able to find a block device without also
probing it. Add a function for this as well as the associated test.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: mmc: Don't re-init when accessing environment
Simon Glass [Mon, 24 Apr 2017 02:02:04 +0000 (20:02 -0600)]
dm: mmc: Don't re-init when accessing environment

With driver model MMC is probed automatically when needed. We should not
re-init MMC each time.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: mmc: Don't call board_mmc_power_init() with driver model
Simon Glass [Sun, 23 Apr 2017 01:10:56 +0000 (19:10 -0600)]
dm: mmc: Don't call board_mmc_power_init() with driver model

We should not call out to board code from drivers. With driver model,
mmc_power_init() already has code to use a named regulator, but the
legacy code path remains. Update the code to make this clear.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: core: Adjust device_bind_common() to take an ofnode
Simon Glass [Wed, 17 May 2017 23:18:11 +0000 (17:18 -0600)]
dm: core: Adjust device_bind_common() to take an ofnode

This core function will need to work with a live tree also. Update it to
accept an ofnode instead of an offset.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: core: Add ofnode to represent device tree nodes
Simon Glass [Wed, 17 May 2017 23:18:10 +0000 (17:18 -0600)]
dm: core: Add ofnode to represent device tree nodes

With live tree we need a struct device_node * to reference a node. With
the existing flat tree, we need an int offset. We need to unify these into
a single value which can represent both.

Add an ofnode union for this and adjust existing code to move to this.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: core: Replace of_offset with accessor (part 2)
Simon Glass [Wed, 17 May 2017 23:18:09 +0000 (17:18 -0600)]
dm: core: Replace of_offset with accessor (part 2)

At present devices use a simple integer offset to record the device tree
node associated with the device. In preparation for supporting a live
device tree, which uses a node pointer instead, refactor existing code to
access this field through an inline function.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: core: Dont export dm_scan_fdt_node()
Simon Glass [Wed, 17 May 2017 23:18:08 +0000 (17:18 -0600)]
dm: core: Dont export dm_scan_fdt_node()

This function is only used in one place. It is better to just declare it
internally since there is a simpler replacement for use outside the
driver-model core code.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: Fix up inclusion of common.h
Simon Glass [Wed, 17 May 2017 23:18:07 +0000 (17:18 -0600)]
dm: Fix up inclusion of common.h

It is good practice to include common.h as the first header. This ensures
that required features like the DECLARE_GLOBAL_DATA_PTR macro,
configuration options and common types are available.

Fix up some files which currently don't do this. This is necessary because
driver model will soon start using global data and configuration in the
dm/read.h header file, included via dm.h. The gd->fdt_blob value will be
used to access the device tree and CONFIG options will be used to
determine whether to support inline functions in the header file.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agoatmel: Fix up use of dm_scan_fdt_node()
Simon Glass [Wed, 17 May 2017 23:18:06 +0000 (17:18 -0600)]
atmel: Fix up use of dm_scan_fdt_node()

This function should not be used outside the core driver-model code.
Update it to use dm_scan_fdt_dev() instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: Rename dev_addr..() functions
Simon Glass [Wed, 17 May 2017 23:18:05 +0000 (17:18 -0600)]
dm: Rename dev_addr..() functions

These support the flat device tree. We want to use the dev_read_..()
prefix for functions that support both flat tree and live tree. So rename
the existing functions to avoid confusion.

In the end we will have:

   1. dev_read_addr...()    - works on devices, supports flat/live tree
   2. devfdt_get_addr...()  - current functions, flat tree only
   3. of_get_address() etc. - new functions, live tree only

All drivers will be written to use 1. That function will in turn call
either 2 or 3 depending on whether the flat or live tree is in use.

Note this involves changing some dead code - the imx_lpi2c.c file.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: core: Move dev_get_addr() etc. into a separate file
Simon Glass [Wed, 17 May 2017 23:18:04 +0000 (17:18 -0600)]
dm: core: Move dev_get_addr() etc. into a separate file

Move this group of address-related functions into a new file. These use
the flat device tree. Future work will provide new versions of these which
can support the live tree.

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agodm: Use dm.h header when driver mode is used
Simon Glass [Wed, 17 May 2017 23:18:03 +0000 (17:18 -0600)]
dm: Use dm.h header when driver mode is used

This header includes things that are needed to make driver build. Adjust
existing users to include that always, even if other dm/ includes are
present

Signed-off-by: Simon Glass <sjg@chromium.org>
7 years agoMerge branch 'master' of git://git.denx.de/u-boot-mips
Tom Rini [Thu, 1 Jun 2017 02:28:06 +0000 (22:28 -0400)]
Merge branch 'master' of git://git.denx.de/u-boot-mips

Please pull another update for Broadcom MIPS.
This contains new SoC's, new boards and new drivers and some bugfixes.

7 years agoMerge git://www.denx.de/git/u-boot-marvell
Tom Rini [Thu, 1 Jun 2017 02:27:54 +0000 (22:27 -0400)]
Merge git://www.denx.de/git/u-boot-marvell

Mostly including the Armada 37xx pinctrl / gpio driver.

7 years agoKconfig: Finish migration of hashing commands
Daniel Thompson [Fri, 19 May 2017 16:26:58 +0000 (17:26 +0100)]
Kconfig: Finish migration of hashing commands

Currently these (board agnostic) commands cannot be selected using
menuconfig and friends. Fix this the obvious way.  As part of this,
don't muddle the meaning of CONFIG_HASH_VERIFY to mean both 'hash -v'
and "we have a hashing command" as this makes the Kconfig logic odd.

Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
[trini: Re-apply, add imply for a few cases, run moveconfig.py, also
        migrate CRC32_VERIFY]
Signed-off-by: Tom Rini <trini@konsulko.com>
7 years agomips: bmips: fix BCM3380 periph clock frequency
Álvaro Fernández Rojas [Tue, 23 May 2017 19:24:49 +0000 (21:24 +0200)]
mips: bmips: fix BCM3380 periph clock frequency

Instead of having a peripheral clock of 50 MHz like the BCM63xx family, it
has a 48 MHz clock.
This fixes uart baud rate calculation for BCM3380.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
7 years agomips: bmips: extend baud rates support
Álvaro Fernández Rojas [Mon, 22 May 2017 18:02:06 +0000 (20:02 +0200)]
mips: bmips: extend baud rates support

Now that the uart driver has been fixed we support more baud rates.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
7 years agodm: serial: bcm6345: fix baud rate clock calculation
Álvaro Fernández Rojas [Mon, 22 May 2017 18:01:46 +0000 (20:01 +0200)]
dm: serial: bcm6345: fix baud rate clock calculation

It's currently bugged and doesn't work for even cases.
Right shift bits instead of dividing and fix even cases.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
7 years agodm: serial: bcm6345: fix uart stop bits
Álvaro Fernández Rojas [Thu, 18 May 2017 21:09:45 +0000 (23:09 +0200)]
dm: serial: bcm6345: fix uart stop bits

I missed this when I added support for BMIPS UART driver and it's needed to
achieve a real 115200 8N1 setup.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
7 years agomips: bmips: add board descriptions
Álvaro Fernández Rojas [Tue, 16 May 2017 16:47:49 +0000 (18:47 +0200)]
mips: bmips: add board descriptions

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agoMIPS: add BMIPS Sagem F@ST1704 board
Álvaro Fernández Rojas [Tue, 16 May 2017 16:46:59 +0000 (18:46 +0200)]
MIPS: add BMIPS Sagem F@ST1704 board

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agoMIPS: add support for Broadcom MIPS BCM6338 SoC family
Álvaro Fernández Rojas [Tue, 16 May 2017 16:46:58 +0000 (18:46 +0200)]
MIPS: add support for Broadcom MIPS BCM6338 SoC family

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agodm: cpu: bmips: add BCM6338 support
Álvaro Fernández Rojas [Tue, 16 May 2017 16:46:57 +0000 (18:46 +0200)]
dm: cpu: bmips: add BCM6338 support

BCM6338 has a fixed CPU frequency of 240 MHz.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agoMIPS: add BMIPS Netgear CG3100D board
Álvaro Fernández Rojas [Tue, 16 May 2017 16:42:43 +0000 (18:42 +0200)]
MIPS: add BMIPS Netgear CG3100D board

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agoMIPS: add support for Broadcom MIPS BCM3380 SoC family
Álvaro Fernández Rojas [Tue, 16 May 2017 16:42:42 +0000 (18:42 +0200)]
MIPS: add support for Broadcom MIPS BCM3380 SoC family

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agodm: cpu: bmips: add BCM3380 support
Álvaro Fernández Rojas [Tue, 16 May 2017 16:42:41 +0000 (18:42 +0200)]
dm: cpu: bmips: add BCM3380 support

As far as I know BCM3380 has a fixed CPU frequency since I couldn't find its
PLL registers in any documentation.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agoMIPS: add BMIPS Comtrend CT-5361 board
Álvaro Fernández Rojas [Tue, 16 May 2017 16:39:04 +0000 (18:39 +0200)]
MIPS: add BMIPS Comtrend CT-5361 board

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agoMIPS: add support for Broadcom MIPS BCM6348 SoC family
Álvaro Fernández Rojas [Tue, 16 May 2017 16:39:03 +0000 (18:39 +0200)]
MIPS: add support for Broadcom MIPS BCM6348 SoC family

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agodm: ram: bmips: add BCM6338/BCM6348 support
Álvaro Fernández Rojas [Tue, 16 May 2017 16:39:02 +0000 (18:39 +0200)]
dm: ram: bmips: add BCM6338/BCM6348 support

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agodm: ram: bmips: split bcm6358_get_ram_size
Álvaro Fernández Rojas [Tue, 16 May 2017 16:39:01 +0000 (18:39 +0200)]
dm: ram: bmips: split bcm6358_get_ram_size

This is done in order to reuse ram size calculation for BCM6338/BCM6348

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agodm: cpu: bmips: add BCM6348 support
Álvaro Fernández Rojas [Tue, 16 May 2017 16:39:00 +0000 (18:39 +0200)]
dm: cpu: bmips: add BCM6348 support

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agodm: cpu: bmips: rename cpu_desc specific functions
Álvaro Fernández Rojas [Tue, 16 May 2017 16:38:59 +0000 (18:38 +0200)]
dm: cpu: bmips: rename cpu_desc specific functions

Use a generic name for cpu_desc functions instead of using a specific SoC one.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agomips: bmips: add wdt-reboot driver support for BCM63268
Álvaro Fernández Rojas [Tue, 16 May 2017 16:29:16 +0000 (18:29 +0200)]
mips: bmips: add wdt-reboot driver support for BCM63268

This driver allows rebooting the SoC by calling wdt_expire_now op.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agomips: bmips: add wdt-reboot driver support for BCM6328
Álvaro Fernández Rojas [Tue, 16 May 2017 16:29:15 +0000 (18:29 +0200)]
mips: bmips: add wdt-reboot driver support for BCM6328

This driver allows rebooting the SoC by calling wdt_expire_now op.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agomips: bmips: add wdt-reboot driver support for BCM6358
Álvaro Fernández Rojas [Tue, 16 May 2017 16:29:14 +0000 (18:29 +0200)]
mips: bmips: add wdt-reboot driver support for BCM6358

This driver allows rebooting the SoC by calling wdt_expire_now op.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agodm: sysreset: add watchdog-reboot driver
Álvaro Fernández Rojas [Tue, 16 May 2017 16:29:13 +0000 (18:29 +0200)]
dm: sysreset: add watchdog-reboot driver

Add a new sysreset driver that uses the recently added watchdog support.
It performs a full SoC reset by calling wdt_expire_now op.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agomips: bmips: add bcm6345-wdt driver support for BCM63268
Álvaro Fernández Rojas [Tue, 16 May 2017 16:29:12 +0000 (18:29 +0200)]
mips: bmips: add bcm6345-wdt driver support for BCM63268

This driver controls the watchdog present on this SoC.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agomips: bmips: add bcm6345-wdt driver support for BCM6328
Álvaro Fernández Rojas [Tue, 16 May 2017 16:29:11 +0000 (18:29 +0200)]
mips: bmips: add bcm6345-wdt driver support for BCM6328

This driver controls the watchdog present on this SoC.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agomips: bmips: add bcm6345-wdt driver support for BCM6358
Álvaro Fernández Rojas [Tue, 16 May 2017 16:29:10 +0000 (18:29 +0200)]
mips: bmips: add bcm6345-wdt driver support for BCM6358

This driver controls the watchdog present on this SoC.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agodm: watchdog: add BCM6345 watchdog driver
Álvaro Fernández Rojas [Tue, 16 May 2017 16:29:09 +0000 (18:29 +0200)]
dm: watchdog: add BCM6345 watchdog driver

This driver is a simplified version of linux/drivers/watchdog/bcm63xx_wdt.c

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
7 years agoarm: mvebu: kwbimage: inline function to fix use-after-free
Patrick Wildt [Wed, 10 May 2017 20:18:54 +0000 (22:18 +0200)]
arm: mvebu: kwbimage: inline function to fix use-after-free

image_version_file()'s only use is to return the version number of the
specified image, and it's only called by kwbimage_generate().  This
version function mallocs "image_cfg" and reads the contents of the image
into that buffer.  Before return to its caller it frees the buffer.

After extracting the version, kwb_image_generate() tries to calculate
the header size by calling image_headersz_v1().  This function now
accesses "image_cfg", which has already been freed.

Since image_version_file() is only used by a single function, inline it
into kwbimage_generate() and only free the buffer after it is no longer
needed.  This also improves code readability since the code is mostly
equal to kwbimage_set_header().

Signed-off-by: Patrick Wildt <patrick@blueri.se>
Signed-off-by: Stefan Roese <sr@denx.de>
7 years agoarm: mvebu: clearfog: generic distro bootcmd
Patrick Wildt [Wed, 10 May 2017 13:12:34 +0000 (15:12 +0200)]
arm: mvebu: clearfog: generic distro bootcmd

Switch Clearfog to the generic distro defaults.  This has been taken
from a Debian mailing list thread:

https://lists.debian.org/debian-boot/2016/10/msg00026.html

Signed-off-by: Patrick Wildt <patrick@blueri.se>
Signed-off-by: Stefan Roese <sr@denx.de>
7 years agoarm: mvebu: clearfog: reset uSOM onboard 1512 phy
Patrick Wildt [Tue, 9 May 2017 11:54:44 +0000 (13:54 +0200)]
arm: mvebu: clearfog: reset uSOM onboard 1512 phy

Use GPIO19 which is wired to the uSOM phy reset signal in order to reset
the uSOM's 1512 Gigabit Ethernet phy.

This GPIO is valid on ClearFog rev 2.1 and newer.

Taken from SolidRun's specialised u-boot, see
https://github.com/SolidRun/u-boot-armada38x/commit/f906e3df172e07ac82cdd87b278d7896949262ea

Signed-off-by: Patrick Wildt <patrick@blueri.se>
Signed-off-by: Stefan Roese <sr@denx.de>
7 years agoarm64: mvebu: Replace board specific with generic memory bank decoding
Stefan Roese [Mon, 8 May 2017 06:31:30 +0000 (08:31 +0200)]
arm64: mvebu: Replace board specific with generic memory bank decoding

The dram_init and dram_init_banksize functions were using a board
specific implementation for decoding the memory banks from the fdt.
This change makes the dram_init* functions use a generic implementation
of decoding and populating memory bank and size data.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Nathan Rossi <nathan@nathanrossi.com>
Cc: Nadav Haklai <nadavh@marvell.com>
Cc: Kostya Porotchkin <kostap@marvell.com>
Signed-off-by: Stefan Roese <sr@denx.de>
7 years agoarm64: mvebu: armada-7040-db: Enable 10GB port 0 / SFI (KR)
Stefan Roese [Thu, 6 Apr 2017 13:39:07 +0000 (15:39 +0200)]
arm64: mvebu: armada-7040-db: Enable 10GB port 0 / SFI (KR)

This patch enables the mvpp2 port 0 usage on the Armada 7k DB by setting
the correct PHY type (KR / SFI) for the COMPHY driver and enabling the
ethernet0 device node in the dts.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Stefan Chulski <stefanc@marvell.com>
Cc: Kostya Porotchkin <kostap@marvell.com>
Cc: Nadav Haklai <nadavh@marvell.com>
7 years agoarm64: mvebu_db-88f3720_defconfig: Enable PINCTRL and GPIO support
Stefan Roese [Wed, 17 May 2017 15:05:38 +0000 (17:05 +0200)]
arm64: mvebu_db-88f3720_defconfig: Enable PINCTRL and GPIO support

This patch enable the PINCTRL and GPIO support, including the GPIO
command on the Armada 3720 DB.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Konstantin Porotchkin <kostap@marvell.com>
Cc: Nadav Haklai <nadavh@marvell.com>
7 years agopinctrl: mvebu: Enable support for the Armada 37xx pinctrl driver
Stefan Roese [Tue, 9 May 2017 11:35:44 +0000 (13:35 +0200)]
pinctrl: mvebu: Enable support for the Armada 37xx pinctrl driver

To enable support for the Armada 37xx pinctrl driver, we need to
change the Kconfig symbol for the Armada 7k/8k pinctrl driver and its
dependencies to distinguish between both platforms and drivers.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Konstantin Porotchkin <kostap@marvell.com>
Cc: Nadav Haklai <nadavh@marvell.com>
7 years agopinctrl: armada-37xx: Add gpio support
Gregory CLEMENT [Wed, 17 May 2017 15:05:25 +0000 (17:05 +0200)]
pinctrl: armada-37xx: Add gpio support

GPIO management is pretty simple and is part of the same IP than the pin
controller for the Armada 37xx SoCs.  This patch adds the GPIO support to
the pinctrl-armada-37xx.c file, it also allows sharing common functions
between the gpio and the pinctrl drivers.

Ported to U-Boot based on the Linux version by Stefan Roese.

Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Gregory CLEMENT <gregory.clement@free-electrons.com>
Cc: Konstantin Porotchkin <kostap@marvell.com>
Cc: Nadav Haklai <nadavh@marvell.com>
7 years agopinctrl: armada-37xx: Add pin controller support for Armada 37xx
Gregory CLEMENT [Tue, 9 May 2017 11:36:21 +0000 (13:36 +0200)]
pinctrl: armada-37xx: Add pin controller support for Armada 37xx

The Armada 37xx SoC come with 2 pin controllers: one on the south
bridge (managing 28 pins) and one on the north bridge (managing 36 pins).

At the hardware level the controller configure the pins by group and not
pin by pin. This constraint is reflected in the design of the driver:
only the group related functions are implemented.

Ported to U-Boot based on the Linux version by Stefan Roese.

Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Gregory CLEMENT <gregory.clement@free-electrons.com>
Cc: Konstantin Porotchkin <kostap@marvell.com>
Cc: Nadav Haklai <nadavh@marvell.com>
7 years agoarm64: mvebu: armada37xx: add pinctrl definition
Gregory CLEMENT [Tue, 9 May 2017 11:35:22 +0000 (13:35 +0200)]
arm64: mvebu: armada37xx: add pinctrl definition

Start to populate the device tree of the Armada 37xx with the pincontrol
configuration used on the board providing a dts.

Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Gregory CLEMENT <gregory.clement@free-electrons.com>
Cc: Konstantin Porotchkin <kostap@marvell.com>
Cc: Nadav Haklai <nadavh@marvell.com>