summaryrefslogtreecommitdiff
path: root/drivers/core
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2015-08-06 15:31:02 -0600
committerSimon Glass <sjg@chromium.org>2015-09-15 07:57:13 -0600
commit02464e386bb5f0a022c121f95ae75cf583759d95 (patch)
treedf285b436346479298805f01ffc4dbe33ace1b79 /drivers/core
parent850f788709cef8f7d53d571aec3bfb73b14c5531 (diff)
downloadu-boot-imx-02464e386bb5f0a022c121f95ae75cf583759d95.zip
u-boot-imx-02464e386bb5f0a022c121f95ae75cf583759d95.tar.gz
u-boot-imx-02464e386bb5f0a022c121f95ae75cf583759d95.tar.bz2
fdt: add new fdt address parsing functions
fdtdec_get_addr_size() hard-codes the number of cells used to represent an address or size in DT. This is incorrect in many cases depending on the DT binding for a particular node or property (e.g. it is incorrect for the "reg" property). In most cases, DT parsing code must use the properties #address-cells and #size-cells to parse addres properties. This change splits up the implementation of fdtdec_get_addr_size() so that the core logic can be used for both hard-coded and non-hard-coded cases. Various wrapper functions are implemented that support cases where hard-coded cell counts should or should not be used, and where the client does and doesn't know the parent node ID that contains the properties #address-cells and #size-cells. dev_get_addr() is updated to use the new functions. Core functionality in fdtdec_get_addr_size_fixed() is widely tested via fdtdec_get_addr_size(). I tested fdtdec_get_addr_size_auto_noparent() and dev_get_addr() by manually modifying the Tegra I2C driver to invoke them. Much of the core implementation of fdtdec_get_addr_size_fixed(), fdtdec_get_addr_size_auto_parent(), and fdtdec_get_addr_size_auto_noparent() comes from Thierry Reding's previous commit "fdt: Fix fdtdec_get_addr_size() for 64-bit". Based-on-work-by: Thierry Reding <treding@nvidia.com> Cc: Thierry Reding <treding@nvidia.com> Cc: Simon Glass <sjg@chromium.org> Cc: Michal Suchanek <hramrach@gmail.com> Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Simon Glass <sjg@chromium.org> Dropped #define DEBUG at the top of fdtdec.c: Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core')
-rw-r--r--drivers/core/device.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 0ccd443..0bc04d4 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -581,7 +581,10 @@ fdt_addr_t dev_get_addr(struct udevice *dev)
#if CONFIG_IS_ENABLED(OF_CONTROL)
fdt_addr_t addr;
- addr = fdtdec_get_addr(gd->fdt_blob, dev->of_offset, "reg");
+ addr = fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
+ dev->parent->of_offset,
+ dev->of_offset, "reg",
+ 0, NULL);
if (CONFIG_IS_ENABLED(SIMPLE_BUS) && addr != FDT_ADDR_T_NONE) {
if (device_get_uclass_id(dev->parent) == UCLASS_SIMPLE_BUS)
addr = simple_bus_translate(dev->parent, addr);