summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* dm: core: Run tests with both livetree and flat treeSimon Glass2017-06-013-2/+40
| | | | | | | | | | | 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>
* dm: test: Add support for running tests with livetreeSimon Glass2017-06-011-7/+16
| | | | | | | | 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>
* dm: test: Show the test filename when runningSimon Glass2017-06-012-1/+4
| | | | | | | 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>
* dm: test: Move test running code into a separate functionSimon Glass2017-06-011-24/+32
| | | | | | | 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>
* sandbox: Add a way to reset sandbox state for testsSimon Glass2017-06-013-4/+19
| | | | | | | | | | | 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>
* dm: core: Update uclass_find_device_by_phandle() for livetreeSimon Glass2017-06-011-3/+2
| | | | | | Adjust this function to work with livetree. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: simple-bus: Add support for livetreeSimon Glass2017-06-011-2/+1
| | | | | | Modify simple-bus to support livetree. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: regmap: Add support for livetreeSimon Glass2017-06-011-15/+22
| | | | | | Modify regmap to support livetree. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: core: Add a way to find a device by ofnodeSimon Glass2017-06-013-0/+72
| | | | | | | 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>
* dm: core: Scan the live tree when setting up driver modelSimon Glass2017-06-013-7/+58
| | | | | | | 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>
* dm: core: Update device_bind_driver_to_node() to use ofnodeSimon Glass2017-06-0114-49/+39
| | | | | | | 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>
* dm: core: Update lists_bind_fdt() to use ofnodeSimon Glass2017-06-015-13/+14
| | | | | | | 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>
* dm: core: Allow binding a device from a live treeSimon Glass2017-06-013-15/+15
| | | | | | | 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>
* dm: core: Implement live tree 'read' functionsSimon Glass2017-06-013-92/+291
| | | | | | | 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>
* dm: core: Add device-based 'read' functions to access DTSimon Glass2017-06-012-0/+387
| | | | | | | | | | | | | | 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>
* dm: core: Add a place to put extra device-tree reading functionsSimon Glass2017-06-016-23/+87
| | | | | | | | 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>
* dm: core: Add address operations on device tree referencesSimon Glass2017-06-012-1/+49
| | | | | | Add functions to add addresses in the device tree using ofnode references. Signed-off-by: Simon Glass <sjg@chromium.org>
* fdt: Update fdt_get_base_address() to use constSimon Glass2017-06-012-2/+2
| | | | | | | 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>
* dm: core: Add livetree address functionsSimon Glass2017-06-014-3/+426
| | | | | | | | | 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>
* dm: core: Add operations on device tree referencesSimon Glass2017-06-013-3/+1017
| | | | | | | | | | | | | | | | | | | | | | | 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>
* dm: core: Rename of_device_is_compatible()Simon Glass2017-06-019-13/+13
| | | | | | | 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>
* dm: Build a live tree after relocationSimon Glass2017-06-011-0/+12
| | | | | | | 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>
* dm: Add a function to create a 'live' device treeSimon Glass2017-06-013-0/+358
| | | | | | | 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>
* dm: core: Add livetree access functionsSimon Glass2017-06-013-0/+1083
| | | | | | | | | 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>
* dm: core: Add livetree definitionsSimon Glass2017-06-013-0/+120
| | | | | | | 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>
* Update WARN_ON() to return a valueSimon Glass2017-06-011-2/+6
| | | | | | | | | 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>
* dm: core: Set return value first in lists_bind_fdt()Simon Glass2017-06-011-2/+2
| | | | | | Adjust the order to make it clear that *devp is set to NULL by default. Signed-off-by: Simon Glass <sjg@chromium.org>
* tegra: Convert MMC to use driver model for operationsSimon Glass2017-06-0129-86/+42
| | | | | | | 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>
* dm: mmc: Rewrite mmc_blk_probe()Simon Glass2017-06-011-6/+11
| | | | | | | | | | | | | | 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>
* dm: mmc: Check that drivers have operationsSimon Glass2017-06-011-0/+4
| | | | | | | | 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>
* dm: blk: Improve block device claimingSimon Glass2017-06-013-6/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* dm: blk: Add a function to find the next block device numberSimon Glass2017-06-011-6/+16
| | | | | | | 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>
* dm: blk: Allow finding block devices without probingSimon Glass2017-06-013-3/+48
| | | | | | | 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>
* dm: mmc: Don't re-init when accessing environmentSimon Glass2017-06-011-1/+2
| | | | | | | 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>
* dm: mmc: Don't call board_mmc_power_init() with driver modelSimon Glass2017-06-011-4/+11
| | | | | | | | 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>
* dm: core: Adjust device_bind_common() to take an ofnodeSimon Glass2017-06-011-8/+10
| | | | | | | 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>
* dm: core: Add ofnode to represent device tree nodesSimon Glass2017-06-015-6/+109
| | | | | | | | | | 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>
* dm: core: Replace of_offset with accessor (part 2)Simon Glass2017-06-0124-35/+37
| | | | | | | | | 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>
* dm: core: Dont export dm_scan_fdt_node()Simon Glass2017-06-012-18/+15
| | | | | | | | 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>
* dm: Fix up inclusion of common.hSimon Glass2017-06-0123-2/+24
| | | | | | | | | | | | | | 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>
* atmel: Fix up use of dm_scan_fdt_node()Simon Glass2017-06-011-2/+1
| | | | | | | 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>
* dm: Rename dev_addr..() functionsSimon Glass2017-06-01194-279/+281
| | | | | | | | | | | | | | | | | | | 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>
* dm: core: Move dev_get_addr() etc. into a separate fileSimon Glass2017-06-016-218/+255
| | | | | | | | 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>
* dm: Use dm.h header when driver mode is usedSimon Glass2017-06-0177-74/+77
| | | | | | | | 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>
* Merge branch 'master' of git://git.denx.de/u-boot-mipsTom Rini2017-05-3149-20/+1550
|\ | | | | | | | | Please pull another update for Broadcom MIPS. This contains new SoC's, new boards and new drivers and some bugfixes.
| * mips: bmips: fix BCM3380 periph clock frequencyÁlvaro Fernández Rojas2017-05-311-1/+1
| | | | | | | | | | | | | | | | 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>
| * mips: bmips: extend baud rates supportÁlvaro Fernández Rojas2017-05-311-0/+4
| | | | | | | | | | | | Now that the uart driver has been fixed we support more baud rates. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
| * dm: serial: bcm6345: fix baud rate clock calculationÁlvaro Fernández Rojas2017-05-311-4/+4
| | | | | | | | | | | | | | 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>
| * dm: serial: bcm6345: fix uart stop bitsÁlvaro Fernández Rojas2017-05-311-0/+2
| | | | | | | | | | | | | | 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>
| * mips: bmips: add board descriptionsÁlvaro Fernández Rojas2017-05-311-0/+24
| | | | | | | | | | Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>