aboutsummaryrefslogtreecommitdiff
path: root/drivers/core
AgeCommit message (Collapse)Author
2018-11-29core: ofnode: Fix ofnode_get_addr_index functionKeerthy
Currently the else part of ofnode_get_addr_index function does not fetch addresses based on the index but rather just returns the base address. Fix that. Signed-off-by: Keerthy <j-keerthy@ti.com>
2018-11-29dm: core: Add a few more specific child-finding functionsSimon Glass
Add two functions which can find a child device by uclass or by name. The first is useful with Multi-Function-Devices (MFDs) to find one of a particular type. The second is useful when only the name is known. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-11-29dm: core: Export uclass_find_device_by_phandle()Simon Glass
This function may be useful to code outside of the code driver-model implementation. Export it and add a test. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-11-20dm: core: Widen the dump tree to show more of the driver's name.Liviu Dudau
With drivers that have prefix names that are quite long (like 'versatile_') it is useful to have a wider column for the driver's name when dumping the device driver tree. Also update the tests to take into account the wider output format. Signed-off-by: Liviu Dudau <liviu.dudau@foss.arm.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-11-16dm: uclass: Add uclass_next_device_err() to return a valid devicePatrice Chotard
Similarly to uclass_first_device_err(), add uclass_next_device_err() which returns an error if there are no next devices in that uclass. Signed-off-by: Patrice Chotard <patrice.chotard@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-11-14uclass: Use uclass_foreach_dev() macro instead of open codingLiviu Dudau
Use the uclass_foreach_dev() macro instead of the open coded version. Signed-off-by: Liviu Dudau <liviu.dudau@foss.arm.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-11-14dm: core: Allow uclass to set up a device's child after it is probedBin Meng
Some buses need to set up their child devices after they are probed. Support a common child_post_probe() method for the uclass. With this change, the two APIs uclass_pre_probe_device() and uclass_post_probe_device() become symmetric. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-11-14regmap: Add endianness supportMario Six
Add support for switching the endianness of regmap accesses via the "little-endian", "big-endian", and "native-endian" boolean properties in the device tree. The default endianness is native endianness. Signed-off-by: Mario Six <mario.six@gdsys.cc> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
2018-11-14regmap: Support reading from specific rangeMario Six
It is useful to be able to treat the different ranges of a regmap separately to be able to use distinct offset for them, but this is currently not implemented in the regmap API. To preserve backwards compatibility, add regmap_read_range and regmap_write_range functions that take an additional parameter 'range_num' that identifies the range to operate on. Reviewed-by: Anatolij Gustschin <agust@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Mario Six <mario.six@gdsys.cc>
2018-11-14regmap: Add raw read/write functionsMario Six
The regmap functions currently assume that all register map accesses have a data width of 32 bits, but there are maps that have different widths. To rectify this, implement the regmap_raw_read and regmap_raw_write functions from the Linux kernel API that specify the width of a desired read or write operation on a regmap. Implement the regmap_read and regmap_write functions using these raw functions in a backwards-compatible manner. Reviewed-by: Anatolij Gustschin <agust@denx.de> Signed-off-by: Mario Six <mario.six@gdsys.cc> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-11-14regmap: Add error outputMario Six
Add some debug output in cases where the initialization of a regmap fails. Reviewed-by: Anatolij Gustschin <agust@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Mario Six <mario.six@gdsys.cc>
2018-11-14regmap: Introduce init_rangeMario Six
Both fdtdec_get_addr_size_fixed and of_address_to_resource can fail with an error, which is not currently checked during regmap initialization. Since the indentation depth is already quite deep, extract a new 'init_range' method to do the initialization. Reviewed-by: Anatolij Gustschin <agust@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Mario Six <mario.six@gdsys.cc>
2018-11-14core: ofnode: Fix mem leak in error pathMario Six
A newly created property is currently not freed if a name could not be allocated. This patch fixes the resulting memory leak in the error patch. Reported-by: Coverity (CID: 184085) Fixes: e369e58df79c ("core: Add functions to set properties in live-tree") Signed-off-by: Mario Six <mario.six@gdsys.cc>
2018-11-14regmap: Improve error handlingMario Six
ofnode_read_simple_addr_cells may fail and return a negative error code. Check for this when initializing regmaps. Also check if both_len is zero, since this is perfectly possible, and would lead to a division-by-zero further down the line. Reviewed-by: Anatolij Gustschin <agust@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Mario Six <mario.six@gdsys.cc>
2018-11-14regmap: Add documentationMario Six
Document the regmap_alloc() function. Reviewed-by: Anatolij Gustschin <agust@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Mario Six <mario.six@gdsys.cc>
2018-11-14dm: core: Mirror the chosen node parse logic in the livetree scanningBin Meng
Commit f2006808f099: ("dm: core: parse chosen node") added a logic to parse the chosen node during dm_scan_fdt_node(), but unfortunately it missed adding the same logic in dm_scan_fdt_live(). This mirrors the logic in the livetree version. The weird thing is that commit f2006808f099 did update the test case to test such logic, but even if I reset to that commit, the test case still fails, and I have no idea how it could pass. With this fix, the following 2 test cases now pass: Test: dm_test_bus_children: bus.c test/dm/bus.c:112, dm_test_bus_children(): num_devices == list_count_items(&uc->dev_head): Expected 7, got 6 Test: dm_test_fdt: test-fdt.c test/dm/test-fdt.c:184, dm_test_fdt(): num_devices == list_count_items(&uc->dev_head): Expected 7, got 6 Fixes: f2006808f099 ("dm: core: parse chosen node") Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-11-14dm: core: Respect drivers with the DM_FLAG_PRE_RELOC flag in lists_bind_fdt()Bin Meng
Currently the comments of several APIs (eg: dm_init_and_scan()) say: @pre_reloc_only: If true, bind only drivers with the DM_FLAG_PRE_RELOC flag. If false bind all drivers. The 'Pre-Relocation Support' chapter in doc/driver-model/README.txt documents the same that both device tree properties and driver flag are supported. However the implementation only checks these special device tree properties without checking the driver flag at all. This updates lists_bind_fdt() to consider both scenarios. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> Squashed in http://patchwork.ozlabs.org/patch/996473/ : Signed-off-by: Simon Glass <sjg@chromium.org>
2018-11-14dm: util: Add a livetree equivalent API of dm_fdt_pre_reloc()Bin Meng
This adds a new API dm_ofnode_pre_reloc(), a livetree equivalent API of dm_fdt_pre_reloc(). Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-10-09fdt: Allow indicating a node is for U-Boot proper onlySimon Glass
At present it is not possible to specify that a node should be used before relocation (in U-Boot proper) without it also ending up in SPL and TPL device trees. Add a new "u-boot,dm-pre-proper" boolean property for this. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-10-09dm: core: Update ofnode to read binman-style flash entrySimon Glass
At present ofnode_read_fmap_entry() reads a flash map entry in a format which is not supported by binman. To allow use to use binman-format descriptions, update this function. Also add a simple test. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-10-09dm: core: Add a function to find the first inactive childSimon Glass
Some devices have children and want to press an existing inactive child into service when needed. Add a function to help with this. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-10-09dm: core: Update some functions to use constSimon Glass
Quite a few functions do not actually modify the device that is passed in. Update the function signatures to reflect that. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-10-09dm: core: Alloc uclass-private data to be cache-alignedSimon Glass
There is no reason why this feature should not be supported for uclass- private data. Update the code accordingly. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-10-08ofnode: Add missing address translation into ofnode_get_addr_size()Marek Vasut
Of CONFIG_OF_TRANSLATE is enabled, this function still returns untranslated bogus results. Add the missing translation. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-10-08ofnode: Replace of_n_addr_cells with of_n_size_cellsMarek Vasut
The size should be decoded using of_n_size_cells(), make it so. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-10-07dm: fdt: scan for devices under /firmware tooJens Wiklander
Just as /chosen may contain devices /firmware may contain devices, scan for devices under /firmware too. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2018-09-29core: Add dev_{disable,enable}_by_pathMario Six
We cannot use device structures to disable devices, since getting them with the API functions would bind and activate the device, which would fail if the underlying device does not exist. Reviewed-by: Simon Glass <sjg@chromium.org>
2018-09-29core: Add functions to set properties in live-treeMario Six
Implement a set of functions to manipulate properties in a live device tree: * ofnode_write_prop() to set generic properties of a node * ofnode_write_string() to set string properties of a node * ofnode_set_enabled() to either enable or disable a node Signed-off-by: Mario Six <mario.six@gdsys.cc> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-09-18ofnode: add ofnode_by_prop_value()Jens Wiklander
Adds ofnode_by_prop_value() to search for nodes with a given property and value, an ofnode version of fdt_node_offset_by_prop_value(). Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-09-18dm: core: fix devfdt_remap_addr_index()Cédric Le Goater
commit 30a90f56c3a2 ("dm: core: add functions to get memory-mapped I/O addresses") introduced a devfdt_remap_addr_index() routine but it does not make use of the index parameter. Signed-off-by: Cédric Le Goater <clg@kaod.org> Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
2018-09-18dm: core: Scan "/firmware" node by defaultRajan Vaja
All Linux firmware drivers are put under "/firmware" node and it has support to populate "/firmware" node by default. u-boot and Linux can share same DTB. In this case, driver probe for devices under "/firmware" will not be invoked as "/firmware" does not have its own "compatible" property. This patch scans "/firmware" node by default like "/clocks". Signed-off-by: Rajan Vaja <rajan.vaja@xilinx.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-09-18dm: core: Move "/clock" node scan into functionRajan Vaja
Create separate function for scanning node by path and move "/clock" node scan code into that function. This will be usable if scanning of more node is required. Signed-off-by: Rajan Vaja <rajan.vaja@xilinx.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-08-21device: expose the functions used to remove and unbind children of a deviceJean-Jacques Hiblot
Also add a 'drv' parameter to filter the children to remove/unbind. Exporting those functions is a preparatory work for the addition of the bind/unbind commands. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
2018-08-21dm: convert device_get_global_by_of_offset() to device_get_global_by_ofnode()Jean-Jacques Hiblot
Also add device_find_global_by_ofnode() that also find a device based on the OF node, but doesn't probe the device. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
2018-08-21dm: print the index of the device when dumping the dm treeJean-Jacques Hiblot
Command "dm tree" dumps the devices with class, driver, name information. Add the index of the device in the class too, because the information is useful for the bind/unbind commands. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-08-21uclass: Add dev_get_uclass_index() to get the uclass/index of a deviceJean-Jacques Hiblot
This function is the reciprocal of uclass_find_device(). It will be used to print the index information in dm tree dump. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
2018-08-08dm: core: Add ofnode function to read PCI vendor and device idBin Meng
We don't have the live-tree version of fdtdec_get_pci_vendev(). This adds the API. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-08-06dm: core: device: enable power domain in probePeng Fan
Enable power domain associated with the device when probe. Signed-off-by: Peng Fan <peng.fan@nxp.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-07-09dm: core: Add logging of some common errorsSimon Glass
Add additional logging so that common errors when finding a device by ofnode are easier to debug. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-07-09dm: core: Add a function to decode a memory regionSimon Glass
Add a way to decode a memory region, including the memory type (sram or sdram) and its start address and size. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-07-09dm: core: Update of_read_fmap_entry() for livetreeSimon Glass
Update this function to take an ofnode so that it can work with livetree. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-07-09dm: core: Add a way to bind a device by ofnodeSimon Glass
Add a new device_bind_ofnode() function which can bind a device given its ofnode. This allows binding devices more easily with livetree nodes. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-07-09dm: core: Add a way to find an ofnode by compatible stringSimon Glass
Add an ofnode_by_compatible() to allow iterating through ofnodes with a given compatible string. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-07-09dm: core: Add ofnode function to read a 64-bit intSimon Glass
We have a 32-bit version of this function. Add a 64-bit version as well so we can easily read 64-bit ints from the device tree. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-06-01dm: core: add functions to get memory-mapped I/O addressesÁlvaro Fernández Rojas
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com> Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-05-08regmap: add regmap_update_bits() helperNeil Armstrong
Add the regmap_update_bits() to simply the read/modify/write of registers in a single command. The function is taken from Linux regmap implementation. Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-05-07syscon: add Linux-compatible syscon APIMasahiro Yamada
The syscon implementation in U-Boot is different from that in Linux. Thus, DT files imported from Linux do not work for U-Boot. In U-Boot driver model, each node is bound to a dedicated driver that is the most compatible to it. This design gets along with the concept of DT, and the syscon in Linux originally worked like that. However, Linux commit bdb0066df96e ("mfd: syscon: Decouple syscon interface from platform devices") changed the behavior because it is useful to let a device bind to another driver, but still work as a syscon provider. That change had happened before U-Boot initially supported the syscon driver by commit 6f98b7504f70 ("dm: Add support for generic system controllers (syscon)"). So, the U-Boot's syscon works differently from the beginning. I'd say this is mis-implementation given that DT is not oriented to a particular project, but Linux is the canon of DT in practice. The problem typically arises in the combination of "syscon" and "simple-mfd" compatibles. In Linux, they are orthogonal, i.e., the order between "syscon" and "simple-mfd" does not matter at all. Assume the following compatible. compatible = "foo,bar-syscon", "syscon", "simple-mfd"; In U-Boot, this device node is bound to the syscon driver (driver/core/syscon-uclass.c) since the "syscon" is found to be the most compatible. Then, syscon_get_regmap() succeeds. However, compatible = "foo,bar-syscon", "simple-mfd", "syscon"; does not work because this node is bound to the simple-bus driver (drivers/core/simple-bus.c) in favor of "simple-mfd" compatible. The compatible string "syscon" is just dismissed. Moreover, compatible = "foo,bar-syscon", "syscon"; works like the first case because the syscon driver populates the child devices. This is wrong because populating children is the job of "simple-mfd" (or "simple-bus"). This commit ports syscon_node_to_regmap() from Linux. This API does not require the given node to be bound to a driver in any way. Reported-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-05-07regmap: change regmap_init_mem() to take ofnode instead udeviceMasahiro Yamada
Currently, regmap_init_mem() takes a udevice. This requires the node has already been associated with a device. It prevents syscon/regmap from behaving like those in Linux. Change the first argumenet to take a device node. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Acked-by: Neil Armstrong <narmstrong@baylibre.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-05-07dm: ofnode: add ofnode_device_is_compatible() helperMasahiro Yamada
device_is_compatible() takes udevice, but there is no such a helper that takes ofnode. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-05-07regmap: clean up regmap allocationMasahiro Yamada
Putting zero length array at the end of struct is a common technique to embed arbitrary length of members. There is no good reason to let regmap_alloc_count() branch by "if (count <= 1)". As far as I understood the code, regmap->base is an alias of regmap->ranges[0].start, but it is not helpful but make the code just ugly. Rename regmap_alloc_count() to regmap_alloc() because the _count suffix seems pointless. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Simon Glass <sjg@chromium.org> [trini: fixup cpu_info-rcar.c] Signed-off-by: Tom Rini <trini@konsulko.com>