aboutsummaryrefslogtreecommitdiff
path: root/drivers/core
AgeCommit message (Collapse)AuthorFilesLines
2020-01-07dm: Add a debug message when devices are skipped pre-relocSean Anderson1-1/+3
This adds a message to lists_bind_fdt when it skips initializing a device pre-relocation. I've had a couple errors where a device didn't initialize properly because one of its dependencies was missing. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-01-07dm: devres: Add a new OFDATA phaseSimon Glass1-5/+13
Since the ofdata_to_platdata() method can allocate resources, add it as a new devres phase. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-01-07dm: devres: Use an enum for the allocation phaseSimon Glass1-6/+16
At present we only support two phases where devres can be used: bind and probe. This is handled with a boolean. We want to add a new phase (platdata), so change this to an enum. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-01-07dm: devres: Add testsSimon Glass1-0/+13
The devres functionality has very few users in U-Boot, but it still should have tests. Add a few basic tests of the main functions. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-01-07dm: devres: Convert to use loggingSimon Glass1-2/+4
At present when CONFIG_DEBUG_DEVRES is enabled, U-Boot prints log messages to the console with every devres allocation/free event. This causes most tests to fail since the console output is not as expected. In particular this prevents us from adding a device to sandbox which uses devres in its bind method. Move devres over to use U-Boot's logging feature instead, and add a new category for devres. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-01-07dm: core: Add a new flag to track platform dataSimon Glass2-1/+4
We want to avoid allocating platform data twice. This could happen if device_probe() is called after device_ofdata_to_platdata() for the same device. Add a flag to track whether device_ofdata_to_platdata() has been called on a device. Check the flag to make sure it doesn't happen twice, and clear the flag when the data is freed. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-01-07dm: core: Export a new function to read platdataSimon Glass1-2/+27
Add a new internal function, device_ofdata_to_platdata() to handle allocating private space associated with each device and reading the platform data from the device tree. Call this new function from device_probe(). Signed-off-by: Simon Glass <sjg@chromium.org>
2020-01-07dm: core: Allocate parent data separate from probing parentSimon Glass1-8/+11
At present the parent is probed before the child's ofdata_to_platdata() method is called. Adjust the logic slightly so that probing parents is not done until afterwards. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-01-07dm: core: Move ofdata_to_platdata() call earlierSimon Glass1-7/+7
This method is supposed to extract platform data from the device tree. It should be done before the device itself is probed. Move it earlier in the device_probe() function. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-01-07dm: core: Don't clear active flag twice when probe() failsSimon Glass1-3/+1
Remove this duplicated code, since the 'fail' label does this immediately. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-01-07dm: core: Use assert_noisy() in devresSimon Glass1-3/+3
Use this macros instead of the linux ones, as the output is smaller. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-12-15dm: pci: Move pci_get_devfn() into a common fileSimon Glass1-0/+20
Early in boot it is necessary to decode the PCI device/function values for particular peripherals in the device tree or of-platdata. This is needed in TPL where CONFIG_PCI is not defined. To handle this, move pci_get_devfn() into a file that is built even when CONFIG_PCI is not defined. Also add a function for use by of-platdata, to convert a reg property to a pci_dev_t. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2019-12-03regmap: Fix potential memory leaksFaiz Abbas1-4/+12
Free allocated memory in case of an error in regmap_init_mem() and regmap_init_mem_index(). Signed-off-by: Faiz Abbas <faiz_abbas@ti.com>
2019-12-02common: Move ARM cache operations out of common.hSimon Glass1-0/+1
These functions are CPU-related and do not use driver model. Move them to cpu_func.h Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2019-11-01Merge tag 'dm-pull-29oct19' of git://git.denx.de/u-boot-dmTom Rini3-6/+9
- Fix for patman with email addresses containing commas - Bootstage improvements for TPL, SPL - Various sandbox and dm improvements and fixes
2019-10-27fdt: Fix alignment issue when reading 64-bits properties from fdtJean-Jacques Hiblot1-1/+1
The FDT specification [0] gives a requirement of aligning properties on 32-bits. Make sure that the compiler is aware of this constraint when accessing 64-bits properties. [0]: https://github.com/devicetree-org/devicetree-specification/blob/master/source/flattened-format.rst Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2019-10-27dm: core: Update log method for uclass_find_device_by_seqKever Yang1-4/+7
Use log() insted of debug() for uclass_find_device_by_seq function, since this print is very much and we can filter it out with log() interface. Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Reviewed-by: Simon Glass <sjg@chromium.org> Move #define to top of file as per docs: Signed-off-by: Simon Glass <sjg@chromium.org>
2019-10-27dm: regmap: Fix mask in regmap_update_bits()Simon Glass1-1/+1
This function assumes that the 'val' parameter has no masked bits set. This is not defined by the function prototype though. Fix the function to mask the value and update the documentation. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
2019-10-22drivers: clk: Fix using assigned-clocks in the node of the clock it sets upJean-Jacques Hiblot1-1/+1
This fixes the case where assigned-clocks is used to define a clock defaults inside this same clock's node. This is used sometimes to setup a default parents and/or rate for a clock. example: muxed_clock: muxed_clock { clocks = <&clk_provider 0>, <&clk_provider 1>; #clock-cells = <0>; assigned-clocks = <&muxed_clock>; assigned-clock-parents = <&clk_provider 1>; }; It doesn't work in u-boot because the assigned-clocks are setup *before* the clock is probed. (clk_set_parent() will likely crash or fail if called before the device probe function) Making it work by handling "assigned-clocks" in 2 steps: first before the clk device is probed, and then after the clk device is probed. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
2019-10-15dm: Tidy up dump output when there are many devicesPatrick Delaunay1-2/+2
At present the 'Index' column of 'dm tree' assumes there is two digits, this patch increase it to 3 digits. It also aligns output of 'dm uclass', assuming the same 3 digits index. The boards with CONFIG_PINCTRL_FULL activated have one pinconfig by pin configuration, so they can have more than 100 devices pinconfig (for example with stm32mp157c-ev1 board we have 106 pinconfig node). Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2019-10-15dm: core: device: switch off power domain after device removalAnatolij Gustschin1-0/+5
The power domain associated with a device is enabled when probing, but currently the domain remains enabled when the device is removed. Some boards started to disable power domains for selected devices via custom board_quiesce_devices(), but it doesn't work in many cases, i. e. because devices still can be accessed later in .remove() callback on behalf of dm_remove_devices_flags(). Utilize the DM core to power off the device power domain, but add a device flag to be able to selectively let the power domain enabled after device removal. This might be required for devices that must remain enabled when booting OS, i. e. serial console for debug output, etc. Signed-off-by: Anatolij Gustschin <agust@denx.de> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2019-10-15dm: core: Allow for not controlling the power-domain by DM frameworkLokesh Vutla1-1/+2
In some remoteproc cases, enabling the power domain of the core will start running the core. In such cases image should be loaded before enabling the power domain. But the current DM framework enables the power-domain by default during probe. This is causing the remotecore to start and crash as there is no valid image loaded. In order to avoid this introduce a DM flag that doesn't allow for enabling/disabling the power-domain by DM framework. Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2019-10-15core: device: use dev_power_domain_onPeng Fan1-3/+3
When multiple power domains attached to a device, need power on them all, so use dev_power_domain_on to do that. Signed-off-by: Peng Fan <peng.fan@nxp.com>
2019-10-15dm: device: Request next sequence numberThomas Fitzsimmons2-1/+8
For CONFIG_OF_PRIOR_STAGE, in the absence of a device tree alias for a given device, use the next request number for that type of device. This allows aliases to be used when they're available, while still allowing unaliased devices to be probed. Signed-off-by: Thomas Fitzsimmons <fitzsim@fitzsim.org> Cc: Bin Meng <bmeng.cn@gmail.com> Cc: Simon Glass <sjg@chromium.org>
2019-10-11dm: core: Add a function to count the children of a deviceLokesh Vutla1-0/+11
Add a function to count the available children of a device. Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
2019-10-08dm: core: Drop fdtdec_get_pci_addr()Simon Glass1-8/+5
This function ise effectively replaced by ofnode_read_pci_addr() which works with flat tree. Delete it to avoid code duplication. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2019-10-08dm: pci: Add a function to read a PCI BARSimon Glass2-0/+44
At present PCI address transaction is not supported so drivers must manually read the correct BAR after reading the device tree info. The ns16550 has a suitable implementation, so move this code into the core DM support. Note that there is no live-tree equivalent at present. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com> [bmeng: correct the unclear comments in test.dts] Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
2019-10-08dm: core: Correct the return value for uclass_find_first_device()Simon Glass1-1/+1
This function returns -ENODEV when there is no device. This is inconsistent with other functions, such as uclass_find_next_device(), which returns 0. Update it and tidy up the incorrect '-1' values in the comments. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com>
2019-10-08dm: core: Call ofdata_to_platdata() with of-platdataSimon Glass1-1/+2
At present this function is never called when of-platdata is enabled since we never have a device tree. However, this function is responsible for copying over the of-platdata, so we must call it. Otherwise the probe() method would have to be used. Correct this and fix the sandbox serial driver to not read from the device tree and try to write to what is read-only platdata on some platforms. Fixes: 396e343b3d (dm: core: Allow binding a device from a live tree) Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2019-10-08dm: core: Drop a few early returnsSimon Glass1-4/+10
Two functions in this file return early for no good reason. Adjust the code to match the standard DM style of returning 0 at the end of the function on success. Oddly enough this save 12 bytes of code size on ARM. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2019-10-08dm: core: Use U-Boot logging instead of pr_debug()Simon Glass1-8/+12
The pr_debug() functions do not response to setting the log level and in fact have their own separate log level. Use U-Boot logging instead. Perhaps we should make these options redirect to log_debug(), etc.? Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2019-10-03dm: core: Correct bad cast in ofnode_get_addr_size_index()Simon Glass1-2/+5
At present this code passes an fdt_addr_t pointer as a u64 pointer which is not safe, since sizeof(fdt_addr_t) may be 4, e.g. with sandbox. Correct this to avoid a stack corruption problem. Fixes: e679d03b08 (core: ofnode: Add ofnode_get_addr_size_index) Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> [bmeng: correct one typo in the commit message] Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
2019-10-03dm: core: Correct low cell in ofnode_read_pci_addr()Simon Glass1-1/+1
This reads the low cell of the PCI address from the wrong cell. Fix it. Also fix the function that this code came from. Fixes: 9e51204527 (dm: core: Add operations on device tree references) Fixes: 4ea5243a3a (fdt: fix fdtdec_get_pci_addr() for CONFIG_PHYS_64BIT) Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2019-09-08Merge tag 'mmc-9-6-2019' of https://gitlab.denx.de/u-boot/custodians/u-boot-mmcTom Rini2-1/+11
Bug fixes to mmc_spi Add Aspeed SD driver Fix dw_mmc timeout calculation Fix timeout values passed to mmc_wait_dat0 sdhci dt caps/mask update [trini: Fix evb-ast2500_defconfig CONFIG_MMC line] Signed-off-by: Tom Rini <trini@konsulko.com>
2019-09-06dm: core: Add functions to read 64-bit dt propertiesT Karthik Reddy2-1/+11
This patch adds functions dev_read_u64_default & dev_read_u64 to read unsigned 64-bit values from devicetree. Signed-off-by: T Karthik Reddy <t.karthik.reddy@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2019-09-02dm: core: Decouple DM from DTMarek Vasut3-7/+7
Some of the DM functions depend on OF_CONTROL, which is incorrect. DM and DT are orthogonal. Add macro guards around such functions to avoid compiling them in when DM is enabled, while OF_CONTROL is not. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Simon Glass <sjg@chromium.org>
2019-08-26Kconfig: Varios: Fix more SPL, TPL dependenciesAdam Ford1-1/+1
Several options are presenting themselves on a various boards where the options are clearly not used. (ie, SPL/TPL options when SPL or TPL are not defined) This patch is not attempting to be a complete list of items, but more like low hanging fruit. In some instances, I wasn't sure of DM was required, so I simply made them SPL or TPL. This patch attempts to reduce some of the menuconfig noise by defining dependencies so they don't appear when not used. Signed-off-by: Adam Ford <aford173@gmail.com>
2019-08-19core: ofnode: do not assert if node not valid in ofnode_get_name()Kever Yang1-1/+5
In some case with LIVE DT, some node always not valid, or not have a valid name, eg. blk driver add by mmc. Return fail instead of Assert for this kind of ofnode, and this help with assert happen from time to time when of_live is enabled and DEBUG is enabled. Signed-off-by: Kever Yang <kever.yang@rock-chips.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2019-08-12dm: core: add support for getting register address and sizeSekhar Nori2-0/+37
Current dev_read_*() API lacks support to get address and size of a "reg" property by name or index. Add support for the same. Livetree support has been added but not tested on real hardware. The existing unit tests testing reading address from device-tree have been updated to test address as well as size. Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com> Signed-off-by: Sekhar Nori <nsekhar@ti.com>
2019-07-24dm: device: make power domain calls optionalAnatolij Gustschin1-1/+2
Reduce power domain calls when CONFIG_POWER_DOMAIN is disabled. With gcc v8.2, this change saves 104 bytes. Signed-off-by: Anatolij Gustschin <agust@denx.de> Reviewed-by: Peng Fan <peng.fan@nxp.com>
2019-07-24dm: core: Set correct "status" value for a nodeBin Meng1-1/+1
Per device tree spec, "status" property can have a value of "okay", or "disabled", but not "disable". Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2019-07-24dm: core: Call clk_set_defaults() during probe() only for a valid ofnodeBin Meng1-4/+10
Without a valid ofnode, it's meaningless to call clk_set_defaults() to process various properties. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2019-07-22dm: core: Introduce xxx_translate_dma_address()Fabien Dessenne3-0/+17
Add the following functions to translate DMA address to CPU address: - dev_translate_dma_address() - ofnode_translate_dma_address() - of_translate_dma_address() - fdt_translate_dma_address() These functions work the same way as xxx_translate_address(), with the difference that the translation relies on the "dma-ranges" property instead of the "ranges" property. Add related test. Test report: => ut dm fdt_translation Test: dm_test_fdt_translation: test-fdt.c Test: dm_test_fdt_translation: test-fdt.c (flat tree) Failures: 0 Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com>
2019-07-17regmap: Add API regmap_init_mem_index()Faiz Abbas1-0/+42
In device nodes with more than one entry in the reg property, it is sometimes useful to regmap only of the entries. Add an API regmap_init_mem_index() to facilitate this. Signed-off-by: Faiz Abbas <faiz_abbas@ti.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2019-07-12drivers: core: use strcmp when find device by namePeng Fan1-1/+1
`if (!strncmp(dev->name, name, strlen(name)))` might find out the wrong device, it might find out `dram_pll_ref_sel`, when name is `dram_pll`. So use strcmp to avoid such issue. Signed-off-by: Peng Fan <peng.fan@nxp.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2019-07-10fdt: Allow indicating a node is for U-Boot proper onlyPatrick Delaunay1-0/+2
This add missing parts for previous commit 06f94461a9f4 ("fdt: Allow indicating a node is for U-Boot proper only") 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: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2019-07-05dm: Add a No-op uclassJean-Jacques Hiblot1-0/+5
This uclass is intended for devices that do not need any features from the uclass, including binding children. This will typically be used by devices that are used to bind child devices but do not use dm_scan_fdt_dev() to do it. That is for example the case of several USB wrappers that have 2 child devices (1 for device and 1 for host) but bind only one at a any given time. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2019-05-21dm: core: Fix dm_extended_scan_fdt()Patrice Chotard1-1/+1
This function takes an argument, blob, but never uses it, instead uses gd->fdt_blob directly. Fixes: e81c98649b7a ("dm: core: add clocks node scan") Reported-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Patrice Chotard <patrice.chotard@st.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2019-05-21core: ofnode: Have ofnode_read_u32_default return a u32Trent Piepho1-1/+1
It was returning an int, which doesn't work if the u32 it is reading, or the default value, will overflow a signed int. While it could be made to work, when using a C standard/compiler where casting negative signed values to unsigned has a defined behavior, combined with careful casting, it seems obvious one is meant to use ofnode_read_s32_default() with signed values. Cc: Simon Glass <sjg@chromium.org> Signed-off-by: Trent Piepho <tpiepho@impinj.com>
2019-05-21core: ofnode: Add ofnode_get_addr_size_indexKeerthy1-3/+10
Add ofnode_get_addr_size_index function to fetch the address and size of the reg space based on index. Signed-off-by: Keerthy <j-keerthy@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org>