dm: core: Add functions to obtain node's address/size cells

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
This commit is contained in:
Simon Glass 2017-06-12 06:21:31 -06:00
parent f7d6fcf7ae
commit 878d68c0c3
8 changed files with 128 additions and 6 deletions

View file

@ -230,6 +230,26 @@ int dev_read_addr_cells(struct udevice *dev);
*/
int dev_read_size_cells(struct udevice *dev);
/**
* dev_read_addr_cells() - Get the address cells property in a node
*
* This function matches fdt_address_cells().
*
* @dev: devioe to check
* @return number of address cells this node uses
*/
int dev_read_simple_addr_cells(struct udevice *dev);
/**
* dev_read_size_cells() - Get the size cells property in a node
*
* This function matches fdt_size_cells().
*
* @dev: devioe to check
* @return number of size cells this node uses
*/
int dev_read_simple_size_cells(struct udevice *dev);
/**
* dev_read_phandle() - Get the phandle from a device
*
@ -398,10 +418,22 @@ static inline int dev_read_phandle_with_args(struct udevice *dev,
static inline int dev_read_addr_cells(struct udevice *dev)
{
/* NOTE: this call should walk up the parent stack */
return fdt_address_cells(gd->fdt_blob, dev_of_offset(dev));
}
static inline int dev_read_size_cells(struct udevice *dev)
{
/* NOTE: this call should walk up the parent stack */
return fdt_size_cells(gd->fdt_blob, dev_of_offset(dev));
}
static inline int dev_read_simple_addr_cells(struct udevice *dev)
{
return fdt_address_cells(gd->fdt_blob, dev_of_offset(dev));
}
static inline int dev_read_simple_size_cells(struct udevice *dev)
{
return fdt_size_cells(gd->fdt_blob, dev_of_offset(dev));
}