summaryrefslogtreecommitdiff
path: root/drivers/core
AgeCommit message (Collapse)Author
2019-02-18MLK-20945-2 dm: device: Check the power up result in probeYe Li
If a device has relevant power domain, we will check the power up result in probing the device. If the power up is failed, the device_probe will return failure immediately. The only exception is the new FLAG (DM_FLAG_IGNORE_POWER_ON) is set by driver to indicate ignore the power up result. Signed-off-by: Ye Li <ye.li@nxp.com>
2018-04-27MLK-16118-3 core: Add power domain operation to device probeYe Li
When power domain driver is enabled, power on the power domain for the device be probed. Reviewed-by: Peng Fan <peng.fan@nxp.com> Signed-off-by: Ye Li <ye.li@nxp.com> (cherry picked from commit bf3e8ecc36ed9f84b9ad1348be48088fbe4eef55)
2018-04-26core: ofnode: Fix translation for #size-cells == 0Mario Six
Commit 286ede6 ("drivers: core: Add translation in live tree case") made dev_get_addr always use proper bus translations for addresses read from the device tree. But this leads to problems with certain busses, e.g. I2C busses, which run into an error during translation, and hence stop working. It turns out that of_translate_address() and fdt_translate_address() stop the address translation with an error when they're asked to translate addresses for busses where #size-cells == 0 (comment from drivers/core/of_addr.c): * Note: We consider that crossing any level with #size-cells == 0 to mean * that translation is impossible (that is we are not dealing with a value * that can be mapped to a cpu physical address). This is not really specified * that way, but this is traditionally the way IBM at least do things To fix this case, we check in both the live-tree and non-live tree-case, whether the bus of the device whose address is about to be translated has size-cell size zero. If this is the case, we just read the address as a plain integer and return it, and only apply bus translations if the size-cell size if greater than zero. Signed-off-by: Mario Six <mario.six@gdsys.cc> Signed-off-by: Martin Fuzzey <mfuzzey@parkeon.com> Reported-by: Martin Fuzzey <mfuzzey@parkeon.com> Fixes: 286ede6 ("drivers: core: Add translation in live tree case") Reviewed-by: Simon Glass <sjg@chromium.org>
2018-03-05libfdt: move headers to <linux/libfdt.h> and <linux/libfdt_env.h>Masahiro Yamada
Thomas reported U-Boot failed to build host tools if libfdt-devel package is installed because tools include libfdt headers from /usr/include/ instead of using internal ones. This commit moves the header code: include/libfdt.h -> include/linux/libfdt.h include/libfdt_env.h -> include/linux/libfdt_env.h and replaces include directives: #include <libfdt.h> -> #include <linux/libfdt.h> #include <libfdt_env.h> -> #include <linux/libfdt_env.h> Reported-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-02-23core: add ofnode_get_by_phandle() apiKever Yang
We need to get ofnode from a phandle, add interface to support both live dt and fdt. Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> Tested-by: Klaus Goger <klaus.goger@theobroma-systems.com> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
2018-02-23core: ofnode: add ofnode_get_parent functionPhilipp Tomsich
The Rockchip video drivers need to walk the ofnode-parrents to find an enclosing device that has a UCLASS_DISPLAY driver bound. This adds a ofnode_get_parent()-function that returns the parent-node. Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> Tested-by: Klaus Goger <klaus.goger@theobroma-systems.com> Reviewed-by: Anatolij Gustschin <agust@denx.de>
2018-02-03dm: core: Add a function to look up a uclass by nameSimon Glass
Each uclass has a driver name which we can use to look up the uclass. This is useful for logging, where the uclass ID is used as the category. Add a function to handle this, as well as a test. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-01-28clk: implement clk_set_defaults()Philipp Tomsich
Linux uses the properties 'assigned-clocks', 'assigned-clock-parents' and 'assigned-clock-rates' to configure the clock subsystem for use with various peripheral nodes. This implements clk_set_defaults() and hooks it up with the general device probibin in drivers/core/device.c: when a new device is probed, clk_set_defaults() will be called for it and will process the properties mentioned above. Note that this functionality is designed to fail gracefully (i.e. if a clock-driver does not implement set_parent(), we simply accept this and ignore the error) as not to break existing board-support. Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> Tested-by: David Wu <david.wu@rock-chips.com> Series-changes: 2 - Fixed David's email address. Series-version: 2 Cover-letter: clk: support assigned-clock, assigned-clock-parents, assigned-clock-rates For various peripherals on Rockchip SoCs (e.g. for the Ethernet GMAC), the parent-clock needs to be set via the DTS. This adds the required plumbing and implements the GMAC case for the RK3399. END
2018-01-24Merge git://git.denx.de/u-boot-mmcTom Rini
2018-01-22dm: add dev_read_u32()Masahiro Yamada
dev_read_u32_default() always returns something even when the property is missing. So, it is impossible to do nothing in the case. One solution is to use ofnode_read_u32() instead, but adding dev_read_u32() will be helpful. BTW, Linux has an equvalent function, device_property_read_u32(); it is clearer that it reads a property. I cannot understand the behavior of dev_read_u32() from its name. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-01-21core: Make device_is_compatible live-tree compatibleMario Six
Judging from its name and parameters, device_is_compatible looks like it is compatible with a live device tree, but it actually isn't. Make it compatible with a live device tree. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Mario Six <mario.six@gdsys.cc>
2018-01-21core: Add {ofnode, dev}_translate_address functionsMario Six
Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Mario Six <mario.six@gdsys.cc>
2018-01-21core: read: Fix style violationsMario Six
There are some whitespace-related style violations in read.c; fix those. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Mario Six <mario.six@gdsys.cc>
2018-01-21core: ofnode: Fix style violationsMario Six
There are some style violations in ofnode.c; fix those. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Mario Six <mario.six@gdsys.cc>
2018-01-21drivers: core: Add translation in live tree caseMario Six
The function dev_read_addr calls ofnode_get_addr_index in the live tree case, which does not apply bus translations to the address read from the device tree. This results in illegal addresses on boards that rely on bus translations being applied. Fix this situation by applying bus translations in the live tree case as well. Signed-off-by: Mario Six <mario.six@gdsys.cc> Tested-by: Stephen Warren <swarren@nvidia.com>
2018-01-15Merge git://git.denx.de/u-boot-netTom Rini
2018-01-15dm: core: add missing dev_count_phandle_with_args()Patrice Chotard
Add missing dev_count_phandle_with_args() to avoid compilation issue. Signed-off-by: Patrice Chotard <patrice.chotard@st.com> Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
2018-01-15dm: core: parse chosen nodeRob Clark
This is the node that would contain, for example, the framebuffer setup by an earlier stage. Signed-off-by: Rob Clark <robdclark@gmail.com>
2017-11-16dm: core: Correct address cast in dev_read_addr_ptr()Simon Glass
This currently causes a warning in sandbox and will not do the right thing: drivers/core/read.c: In function ‘dev_read_addr_ptr’: drivers/core/read.c:64:44: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] return (addr == FDT_ADDR_T_NONE) ? NULL : (void *)addr; Use map_sysmem() which is the correct way to convert an address to a pointer. Fixes: c131c8bca8 (dm: core: add dev_read_addr_ptr()) Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com> Acked-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
2017-10-23simple-bus: remove DECLARE_GLOBAL_DATA_PTRMasahiro Yamada
No global pointer is used in this file. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2017-10-08dm: ofnode: query correct property in livetree ofnode_get_addr_sizeKlaus Goger
The livetree codepath of ofnode_get_addr_size always used the "reg" property for of_get_property. Use the property parameter of the function call instead and check the return value if the property exists. Otherwise return FDT_ADDR_T_NONE. This was discoverd while using SPI NOR with livetree. spi_flash_decode_fdt checks for memory-map and will not fail with livetree even if the property does not exist. Signed-off-by: Klaus Goger <klaus.goger@theobroma-systems.com> Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2017-10-08dm: core: Round up size when allocating so that it is cache line alignedFaiz Abbas
The size variable may not be always be a mulitple of ARCH_DMA_MINALIGN and using it to flush cache leads to cache misaligned warnings. Therefore, round up the size to a multiple of ARCH_DMA_MINLAIGN when allocating private data. Signed-off-by: Faiz Abbas <faiz_abbas@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2017-10-04dm: replace dm_dbg() with pr_debug()Masahiro Yamada
As we discussed before in ML, dm_dbg() causes undefined reference error if #define DEBUG is added to users, but not drivers/core/util.c We do not need this macro because we can use pr_debug() instead, and it is pretty easy to enable it for the DM core by using ccflags-y. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2017-09-22dm: core: Add functions to get strings and the string count from a stringlistJean-Jacques Hiblot
dev_read_string_count() is used to get the number of strings in a stringlist. dev_read_string_index() is used to get a string in the stringlist based on its position in the list. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
2017-09-18dm: core: add dev_read_addr_ptr()Philipp Tomsich
The dev_read_addr_ptr() mimics the behaviour of the devfdt_get_addr_ptr(), retrieving the first address of the node's reg-property and returning it as a pointer (or NULL on failure). Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> Acked-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2017-09-15dtoc: Add support for 32 or 64-bit addressesSimon Glass
When using 32-bit addresses dtoc works correctly. For 64-bit addresses it does not since it ignores the #address-cells and #size-cells properties. Update the tool to use fdt64_t as the element type for reg properties when either the address or size is larger than one cell. Use the correct value so that C code can obtain the information from the device tree easily. Alos create a new type, fdt_val_t, which is defined to either fdt32_t or fdt64_t depending on the word size of the machine. This type corresponds to fdt_addr_t and fdt_size_t. Unfortunately we cannot just use those types since they are defined to phys_addr_t and phys_size_t which use 'unsigned long' in the 32-bit case, rather than 'unsigned int'. Add tests for the four combinations of address and size values (32/32, 64/64, 32/64, 64/32). Also update existing uses for rk3399 and rk3368 which now need to use the new fdt_val_t type. Signed-off-by: Simon Glass <sjg@chromium.org> Suggested-by: Heiko Stuebner <heiko@sntech.de> Reported-by: Kever Yang <kever.yang@rock-chips.com> Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> Tested-by: Kever Yang <kever.yang@rock-chips.com>
2017-09-11dm: core: add clocks node scanPatrice Chotard
Currently, all fixed-clock declared in "clocks" node in device tree can be binded by clk_fixed_rate.c driver only if each of them have the "simple-bus" compatible string. This constraint has been invoked here [1]. This patch offers a solution to avoid adding "simple-bus" compatible string to nodes that are not busses. [1] https://patchwork.ozlabs.org/patch/558837/ Signed-off-by: Patrice Chotard <patrice.chotard@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2017-09-11dm: core: Add ofnode_for_each_subnode()Simon Glass
Add a convenience macro to iterate over subnodes of a node. Make use of this where appropriate in the code. Signed-off-by: Simon Glass <sjg@chromium.org>
2017-09-11dm: core: Show driver name with 'dm tree'Simon Glass
It is often useful to see which driver was actually selected for each device. Add a new 'Driver' column to provide this information. Sample output: Class Probed Driver Name ---------------------------------------- root [ + ] root_drive root_driver keyboard [ + ] i8042_kbd |-- keyboard serial [ + ] ns16550_se |-- serial rtc [ ] rtc_mc1468 |-- rtc timer [ + ] tsc_timer |-- tsc-timer syscon [ + ] ich6_pinct |-- pch_pinctrl pci [ + ] pci_x86 |-- pci northbridge [ + ] bd82x6x_no | |-- northbridge@0,0 video [ + ] bd82x6x_vi | |-- gma@2,0 vidconsole0 [ + ] vidconsole | | `-- gma@2,0.vidconsole0 ... Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com>
2017-09-11dm: core: Drop use of strlcpy()Simon Glass
We can use printf() to limit the string width. Adjust the code to do this instead of using strlcpy() which is a bit clumbsy. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com>
2017-08-29ofnode: add {ofnode, dev}_read_resource_byname()Masahiro Yamada
Linux supports platform_get_resource_byname() to look up a resource by name. We want a similar helper. It is useful when a device node has named register regions. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2017-08-17dm: core: Avoid calling dm_scan_fdt_dev() with of-platdataSimon Glass
We cannot call dm_scan_fdt_dev() with of-platdata since there is no device tree. Fix this with an #if check. Fixes: 3be9a37 (dm: syscon: scan sub-nodes of the syscon node) Signed-off-by: Simon Glass <sjg@chromium.org>
2017-08-13spl: dm: Kconfig: split REGMAP/SYSCON support for TPL from SPLPhilipp Tomsich
This change introduces TPL variants of the REGMAP and SYSCON config options (i.e. TPL_REGMAP and TPL_SYSCON in analogy to SPL_REGMAP and SPL_SYSCON) in preparation of a finer-grained feature selection for building feature-rich TPL variants. Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2017-08-13spl: dm: Kconfig: use more specific prereqs for SPL_REGMAP and SPL_SYSCONPhilipp Tomsich
SPL_REGMAP and SPL_SYSCON were marked as depending on DM, when a stricter dependency of SPL_DM was possible. This commit makes the prereq more specific. Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2017-07-29Merge git://git.denx.de/u-boot-usbTom Rini
2017-07-28dm: core: add ofnode_count_phandle_with_args()Patrice Chotard
This function is usefull to get phandle number contained in a property list. For example, this allows to allocate the right amount of memory to keep clock's reference contained into the "clocks" property. To implement it, either of_count_phandle_with_args() or fdtdec_parse_phandle_with_args() are used respectively for live tree and flat tree. By passing index = -1, these 2 functions returns the number of phandle contained into the property list. Add also the dev_count_phandle_with_args() based on ofnode_count_phandle_with_args() Signed-off-by: Patrice Chotard <patrice.chotard@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2017-07-28dm: core: Fix up ofnode_get_addr_index() for 64-bit valuesSimon Glass
At present this function only supports 32-bit (single-cell) values. Update it to support two-cell values also. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> Tested-on: Beaver, Jetson-TK1 Tested-by: Stephen Warren <swarren@nvidia.com>
2017-07-28dm: core: Add ofnode_read_resource()Simon Glass
We sometimes need to read a resource from an arbitrary node. In any case for consistency we should not put the live-tree switching code in a dev_read_...() function. Update this to suit. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> Tested-on: Beaver, Jetson-TK1 Tested-by: Stephen Warren <swarren@nvidia.com>
2017-07-28dm: ofnode: change return type of dev_read_prop() to opaque pointerMasahiro Yamada
DT property values can be strings as well as integers. This is why of_get_property/fdt_getprop returns an opaque pointer. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Acked-by: Simon Glass <sjg@chromium.org>
2017-07-27spl: make SPL and normal u-boot stage use independent SYS_MALLOC_F_LENAndy Yan
Some platforms have very limited SRAM to run SPL code, so there may not be the same amount space for a malloc pool before relocation in the SPL stage as the normal U-Boot stage. Make SPL and (the full) U-Boot stage use independent SYS_MALLOC_F_LEN, so the size of pre-relocation malloc pool can be configured memory space independently. Signed-off-by: Andy Yan <andy.yan@rock-chips.com> Reviewed-by: Tom Rini <trini@konsulko.com> Acked-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> [fixed up commit-message:] Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
2017-07-11dm: ofnode: use fdt32_t for DT property value to fix sparse warningMasahiro Yamada
DTB is encoded in big endian. When we retrieve property values, we need to use fdt32_to_cpu (aka be32_to_cpu) for endian conversion. This is a bit error-prone, but sparse is useful to detect endian mismatch. We need to use (fdt32_t *) instead of (u32 *) for a pointer of a property value. Otherwise sparse warns "cast to restricted __be32". Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2017-07-11dm: include <dm/util.h> from driver/core/dump.cMasahiro Yamada
Include <dm/util.h> to fix sparse warnings: symbol 'dm_dump_all' was not declared. Should it be static? symbol 'dm_dump_uclass' was not declared. Should it be static? Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Acked-by: Simon Glass <sjg@chromium.org>
2017-07-11dm: ofnode: simplify ofnode_read_bool()Masahiro Yamada
Reuse ofnode_get_property() to simplify the implementation. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Acked-by: Simon Glass <sjg@chromium.org>
2017-07-11dm: ofnode: rename ofnode_read_prop() to ofnode_get_property()Masahiro Yamada
This function returns the pointer to the value of a node property. The current name ofnode_read_prop() is confusing. Follow the naming of_get_property() from Linux. The return type (const u32 *) is wrong. DT property values can be strings as well as integers. This is why of_get_property/fdt_getprop returns an opaque pointer. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Acked-by: Simon Glass <sjg@chromium.org>
2017-07-11dm: ofnode: simplify ofnode_read_prop()Masahiro Yamada
The code inside the if-block is the same as of_get_property(). Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Acked-by: Simon Glass <sjg@chromium.org>
2017-07-11dm: ofnode: use ofnode_read_bool() to check property existenceMasahiro Yamada
This will clarify the code. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Acked-by: Simon Glass <sjg@chromium.org>
2017-07-11dm: include <dm/util.h> from drivers/core/util.cMasahiro Yamada
Fix sparse warnings "... was not declared. Should it be static?" Also, fix redefinition of dm_warn/dm_dbg. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2017-07-11dm: core: Add functions to obtain node's address/size cellsSimon Glass
The of_n_addr_cells() and of_n_size_cells() functions are useful for getting the size of addresses in a node, but in a few places U-Boot needs to obtain the actual property value for a node without walking up the stack. Add functions for this and just the existing code to use it. Add a comment to the existing ofnode functions which do not do the right thing with a flat tree. This fixes a problem reading PCI addresses. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> Tested-on: Beaver, Jetson-TK1
2017-07-11dm: core: Add dev_read_enabled() to check if a device is enabledSimon Glass
This function allows a device's status to be read. This indicates whether the device should be enabled or disabled. Note: In normal operation disabled devices will not be present in the driver-model tree. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> Tested-on: Beaver, Jetson-TK1
2017-07-11dm: core: Add dev_read_resource() to read device resourcesSimon Glass
Add a function which reads resources from a device, such as the device hardware address. This uses the "reg" property in the device. Unlike other functions there is little sense in inlining this when livetree is not being used because it has some logic in it and this would just bloat the code size. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> Tested-on: Beaver, Jetson-TK1