summaryrefslogtreecommitdiff
path: root/lib/fdtdec.c
AgeCommit message (Collapse)AuthorFilesLines
2019-11-14fdtdec: only create phandle if caller wants it in fdtdec_add_reserved_memory()Heiko Stuebner1-7/+9
The phandlep pointer returning the phandle to the caller is optional and if it is not set when calling fdtdec_add_reserved_memory() it is highly likely that the caller is not interested in a phandle to the created reserved-memory area and really just wants that area added. So just don't create a phandle in that case. Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2019-11-14fdtdec: protect against another NULL phandlep in fdtdec_add_reserved_memory()Heiko Stuebner1-1/+2
The change adding fdtdec_add_reserved_memory() already protected the added phandle against the phandlep being NULL - making the phandlep var optional. But in the early code checking for an already existing carveout this check was not done and thus the phandle assignment could run into trouble, so add a check there as well, which makes the function still return successfully if a matching region is found, even though no-one wants to work with the phandle. Fixes: c9222a08b3f7 ("fdtdec: Implement fdtdec_add_reserved_memory()") Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com> Reviewed-by: Simon Glass <sjg@chromium.org>
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-08dm: core: Drop fdtdec_get_pci_addr()Simon Glass1-54/+0
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-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-08-26fdtdec: make CONFIG_OF_PRIOR_STAGE available in SPLLukas Auer1-4/+2
The current preprocessor logic prevents CONFIG_OF_PRIOR_STAGE from being used in U-Boot SPL. Change the logic to also make it available in U-Boot SPL. Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
2019-08-11env: Move env_get_ulong() to env.hSimon Glass1-0/+1
Move env_get_ulong() over to the new header file. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
2019-08-11common: Move gzip functions into a new gzip headerSimon Glass1-0/+1
As part of the effort to remove things from common.h, create a new header for the gzip functions. Move the function declarations to it and add missing documentation. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
2019-06-05fdtdec: Add fdtdec_set_ethernet_mac_address()Thierry Reding1-0/+29
This function can be used to set the local MAC address for the default Ethernet interface in its device tree node. The default interface is identified by the "ethernet" alias. One case where this is useful is for devices that store their MAC address in a custom location. Once extracted, board code can store the MAC address in U-Boot's control DTB so that it will automatically be used by the Ethernet uclass. Signed-off-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Tom Warren <twarren@nvidia.com>
2019-05-22fdtdec: Remove fdt_{addr,size}_unpack()Thierry Reding1-2/+6
U-Boot already defines the {upper,lower}_32_bits() macros that have the same purpose. Use the existing macros instead of defining new APIs. Signed-off-by: Thierry Reding <treding@nvidia.com>
2019-04-24fdtdec: Use fdt_setprop_u32() for fdtdec_set_phandle()Thierry Reding1-7/+0
The fdt_setprop_u32() function does everything that we need, so we really only use the function as a convenience wrapper, in which case it can simply be a static inline function. Signed-off-by: Thierry Reding <treding@nvidia.com>
2019-04-14Merge branch 'master' of git://git.denx.de/u-boot-spiTom Rini1-1/+1
Conflicts: arch/arm/dts/armada-385-amc.dts arch/arm/dts/armada-xp-theadorable.dts arch/arm/dts/stm32mp157c-ev1-u-boot.dtsi Signed-off-by: Tom Rini <trini@konsulko.com>
2019-04-12x86: dts: switch spi-flash to jedec, spi-nor compatibleNeil Armstrong1-1/+1
The x86 code and DT uses "spi-flash" to detect a flash node, switch to "jedec,spi-nor" in the DTS files and in fdtdec by switching the GENERIC_SPI_FLASH value to to jedec,spi-nor. Signed-off-by: Neil Armstrong <narmstrong@baylibre.com> Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com> Reviewed-by: Jagan Teki <jagan@openedev.com>
2019-04-12fdtdec: Implement carveout support functionsThierry Reding1-0/+87
The fdtdec_get_carveout() and fdtdec_set_carveout() function can be used to read a carveout from a given node or add a carveout to a given node using the standard device tree bindings (involving reserved-memory nodes and the memory-region property). Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Thierry Reding <treding@nvidia.com>
2019-04-12fdtdec: Implement fdtdec_add_reserved_memory()Thierry Reding1-0/+131
This function can be used to add subnodes in the /reserved-memory node. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Thierry Reding <treding@nvidia.com>
2019-04-12fdtdec: Implement fdtdec_set_phandle()Thierry Reding1-0/+7
This function can be used to set a phandle for a given node. Signed-off-by: Thierry Reding <treding@nvidia.com>
2019-04-09lib: fdt: Allow LZO and GZIP DT compression in U-BootMarek Vasut1-1/+1
Add required Kconfig symbols, Makefile bits and macro fixes in a few places to support LZO and DT compression in U-Boot. This can save a lot of space with multi-DTB fitImages. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org> Cc: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
2019-04-09lib: fdt: Allow enabling both LZO and GZIP DT compressionMarek Vasut1-6/+13
Allow enabling both LZO and GZIP DT compression in SPL and fix a bug where if the GZIP decompression failed, the LZO decompression would not even be attempted. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org> Cc: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com>
2019-04-09lib: fdt: Split fdtdec_setup_memory_banksize()Marek Vasut1-6/+12
Split fdtdec_setup_memory_banksize() into fdtdec_setup_memory_banksize_fdt(), which allows the caller to pass custom blob into the function and the original fdtdec_setup_memory_banksize(), which uses the gd->fdt_blob. This is useful when configuring the DRAM properties from a FDT blob fragment passed in by the firmware. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org> Cc: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2019-04-09lib: fdt: Split fdtdec_setup_mem_size_base()Marek Vasut1-3/+8
Split fdtdec_setup_mem_size_base() into fdtdec_setup_mem_size_base_fdt(), which allows the caller to pass custom blob into the function and the original fdtdec_setup_mem_size_base(), which uses the gd->fdt_blob. This is useful when configuring the DRAM properties from a FDT blob fragment passed in by the firmware. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org> Cc: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2019-02-11Merge branch 'master' of git://git.denx.de/u-boot-i2cTom Rini1-0/+33
- DM I2C improvements
2019-02-09fdt: tegra: Drop COMPAT_AMS_AS3722Simon Glass1-1/+0
This is no-longer used. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Lukasz Majewski <lukma@denx.de>
2019-02-09fdt: samsung: Drop unused fdt_compat_id valuesSimon Glass1-6/+0
This enum still exists but we can shrink it a little based on recent driver-model conversions with samsung. Update it to remove unused items. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Lukasz Majewski <lukma@denx.de>
2019-02-08fdt: Introduce fdtdec_get_alias_highest_id()Michal Simek1-0/+33
Find out the highest alias ID used for certain subsystem. This call will be used for alocating IDs for i2c buses which are not described in DT. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Heiko Schocher <hs@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2019-01-15lib: fdtdec: fdtdec_get_addr_size_fixed remove checksKeerthy1-10/+0
With 8 bytes addressing even on 32 bit machines these checks are no longer valid. Remove them. Signed-off-by: Keerthy <j-keerthy@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-12-12spl: fix build failure with !CONFIG_SPL_PCI_SUPPORTSekhar Nori1-1/+1
Building U-Boot with CONFIG_PCI and CONFIG_DM_PCI enabled, but CONFIG_SPL_PCI_SUPPORT disabled, results in following linker error: lib/built-in.o: In function `fdtdec_get_pci_bar32': lib/fdtdec.c:305: undefined reference to `dm_pci_read_bar32' fdtdec.c:305:(.text.fdtdec_get_pci_bar32+0x24): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `dm_pci_read_bar32' This is because reference to dm_pci_read_bar32() remains in lib/fdtdec.c while SPL build does not descend into drivers/pci directory in drivers/Makefile if CONFIG_SPL_PCI_SUPPORT is not enabled. Fix this by applying appropriate #define guards in lib/fdtdec.c. It looks like ns16550.c has the same problem, so fixed that too. To simplify this, CONFIG_SPL_PCI_SUPPORT is renamed to CONFIG_SPL_PCI (enables use of CONFIG_IS_ENABLED() macro). Suggested-by: Vignesh R <vigneshr@ti.com> Signed-off-by: Sekhar Nori <nsekhar@ti.com> Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2018-12-10lib: fdtdec: Add function re-setup the fdt more effecientlyJean-Jacques Hiblot1-1/+42
In some cases it may be useful to be able to change the fdt we have been using and use another one instead. For example, the TI platforms uses an EEPROM to store board information and, based on the type of board, different dtbs are used by the SPL. When DM_I2C is used, a first dtb must be used before the I2C is initialized and only then the final dtb can be selected. To speed up the process and reduce memory usage, introduce a new function fdtdec_setup_best_match() that re-use the DTBs loaded in memory by fdtdec_setup() to select the best match. Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Reviewed-by: Heiko Schocher <hs@denx.de>
2018-12-02fdt: sandbox: correct use of ${fdtcontroladdr}Heinrich Schuchardt1-2/+4
The sandbox uses a virtual address space that is neither the physical nor the virtual address space of the operating system. All address used on the command line live in this address space. So also the environment variable ${fdtcontroladdr} has to be in this address space. Commands like bootefi and booti receive the fdt address as parameter. Without the patch ${fdtcontroladdr} cannot be used as parameter value on the sandbox. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
2018-11-21fdt: Fix uncompress_blob() for U-Boot properMarek Vasut1-1/+2
When U-Boot proper is compiled with CONFIG_MULTI_DTB_FIT and tries to call uncompress_blob(), it fails with -ENOTSUPP. This is because the full implementation of this function which includes compression is available only in SPL. In U-Boot proper or if the compression is not enabled, the blob is not compressed and thus can be passed to locate_dtb_in_fit() in fdtdec_setup() without any changes. Pass the blob without any changes if compression is not enabled instead of failing. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Michal Simek <michal.simek@xilinx.com> Cc: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-10-15Revert "fdt: fdtdec_setup_memory_banksize() use livetree"Michal Simek1-21/+23
This reverts commit c35a7d375ec8f0a8ee343ae4868be3242172632e. This commit is breaking SPL on zc706. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Patrice Chotard <patrice.chotard@st.com> [on STM32F746-disco]
2018-10-09fdt: Remove fdtdec_decode_region() functionSimon Glass1-83/+0
This function is not used in U-Boot now. Remove it along with its 'memory' version. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-29fdt: fdtdec_setup_memory_banksize() use livetreeJens Wiklander1-23/+21
Converts fdtdec_setup_memory_banksize() to use ofnode functions instead. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
2018-09-11Remove <inttypes.h> includes and PRI* usages in printf() entirelyMasahiro Yamada1-5/+3
In int-ll64.h, we always use the following typedefs: typedef unsigned int u32; typedef unsigned long uintptr_t; typedef unsigned long long u64; This does not need to match to the compiler's <inttypes.h>. Do not include it. The use of PRI* makes the code super-ugly. You can simply use "l" for printing uintptr_t, "ll" for u64, and no modifier for u32. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2018-09-10fdt: fix get_next_memory_node()Marek Vasut1-3/+1
The get_next_memory_node() always sets mem to -1 , which is incorrect, because then every iteration of memory bank parsing will start from the first memory bank instead of the previous one. On systems with 1 memory bank defined in DT and CONFIG_NR_DRAM_BANKS=4 , like ie. r8a77965-salvator-x , this will result in U-Boot incorrectly reporting four identical memory banks with the same memory configuration. Fix this by setting mem to startoffset value, which restores the behavior before the fixed patch was applied. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Jens Wiklander <jens.wiklander@linaro.org> Cc: Simon Glass <sjg@chromium.org> Cc: Tom Rini <trini@konsulko.com> Fixes: 452bc121027d ("fdt: fix fdtdec_setup_memory_banksize()") Tested-by: Michal Simek <michal.simek@xilinx.com> [on ZynqMP}
2018-07-26fdt: fix fdtdec_setup_memory_banksize()Jens Wiklander1-5/+15
Prior to this patch is fdtdec_setup_memory_banksize() incorrectly ignoring the "status" field. This patch fixes that by testing the status with fdtdec_get_is_enabled() before using a memory node. Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2018-07-19lib: fdtdec: Rename routine fdtdec_setup_memory_size()Siva Durga Prasad Paladugu1-1/+1
This patch renames the routine fdtdec_setup_memory_size() to fdtdec_setup_mem_size_base() as it now fills the mem base as well along with size. Signed-off-by: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2018-07-19lib: fdtdec: Update ram_base to store ram start adddressSiva Durga Prasad Paladugu1-0/+1
This patch updates the ram_base to store the start address of the first bank DRAM and the use this ram_base to calculate ram_top properly. This patch fixes the erroneous calculation of ram_top incase of non zero ram start address. Signed-off-by: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2018-07-10board: arm: Add support for Broadcom BCM7445Thomas Fitzsimmons1-0/+4
Add support for loading U-Boot on the Broadcom 7445 SoC. This port assumes Broadcom's BOLT bootloader is acting as the second stage bootloader, and U-Boot is acting as the third stage bootloader, loaded as an ELF program by BOLT. Signed-off-by: Thomas Fitzsimmons <fitzsim@fitzsim.org> Cc: Stefan Roese <sr@denx.de> Cc: Tom Rini <trini@konsulko.com> Cc: Florian Fainelli <f.fainelli@gmail.com>
2018-07-09fdt: Add device tree memory bindingsMichael Pratt1-0/+109
Support a default memory bank, specified in reg, as well as board-specific memory banks in subtree board-id nodes. This allows memory information to be provided in the device tree, rather than hard-coded in, which will make it simpler to handle similar devices with different memory banks, as the board-id values or masks can be used to match devices. Signed-off-by: Michael Pratt <mpratt@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2018-05-18fdt: Add another Altera Arria10 clock init compatibleMarek Vasut1-0/+1
The DT bindings for the Arria10 clock init have changed, add another compatible to make them work with U-Boot until a proper clock driver gets written. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Tom Rini <trini@konsulko.com> Cc: Chin Liang See <chin.liang.see@intel.com> Cc: Dinh Nguyen <dinguyen@kernel.org>
2018-05-08lib: fdtdec: drop the old compatible about max77686Jaehoon Chung1-1/+0
Drop the old compatible about max77686. Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com> Acked-by: Lukasz Majewski <lukma@denx.de>
2018-05-07SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini1-1/+1
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
2018-03-05libfdt: move headers to <linux/libfdt.h> and <linux/libfdt_env.h>Masahiro Yamada1-1/+1
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-01-21lib: fdtdec: Fix some style violationsMario Six1-14/+15
Fix some style violations in fdtdec.c, and reduce the scope of some variables. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Mario Six <mario.six@gdsys.cc>
2018-01-21lib: fdtdec: Fix whitespace style violationsMario Six1-26/+30
Fix some whitespace-related style violations in fdtdec.c. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Mario Six <mario.six@gdsys.cc>
2018-01-16fdtdec: allow board to provide fdt for CONFIG_OF_SEPARATERob Clark1-12/+23
Similar to CONFIG_OF_BOARD, but in this case the fdt is still built by u-boot build. This allows the board to patch the fdt, etc. In the specific case of dragonboard 410c, we pass the u-boot generated fdt to the previous stage of bootloader (by embedding it in the u-boot.img that is loaded by lk/aboot), which patches the fdt and passes it back to u-boot. Signed-off-by: Rob Clark <robdclark@gmail.com> [trini: Update board_fdt_blob_setup #if check] Signed-off-by: Tom Rini <trini@konsulko.com>
2017-11-30Merge branch 'rmobile-mx' of git://git.denx.de/u-boot-shTom Rini1-6/+18
2017-11-30spl: make CONFIG_OF_EMBED pass dts through fdtgrepGoldschmidt Simon1-0/+4
Building spl with CONFIG_OF_EMBED enabled results in an error message on my board: "SPL image too big". This is because the fdtgrep build step is only executed for CONFIG_OF_SEPARATE. Fix this by moving the fdtgrep build step ('cmd_fdtgreo') from scripts/Makefile.spl to dts/Makefile so that the reduced dtb is available for all kinds of spl builds. The resulting variable name for the embedded device tree blob changes, too, which is why common.h and fdtdec.c have tiny changes. Signed-off-by: Simon Goldschmidt <sgoldschmidt@de.pepperl-fuchs.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2017-11-30fdtdec: Support parsing multiple /memory nodesMarek Vasut1-6/+18
It is legal to have multiple /memory nodes in a device tree . Currently, fdtdec_setup_memory_size() only supports parsing the first node . This patch extends the function such that if a particular /memory node does no longer have further "reg" entries and CONFIG_NR_DRAM_BANKS still allows for more DRAM banks, the code moves on to the next memory node and checks it's "reg"s. This makes it possible to handle both systems with single memory node with multiple entries and systems with multiple memory nodes with single entry. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Tom Rini <trini@konsulko.com> Cc: Simon Glass <sjg@chromium.org>
2017-11-26fdt: Add compatible strings for Arria 10Tien Fong Chee1-0/+2
Add compatible strings for Intel Arria 10 SoCFPGA device. Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com>