return OF_ROOT_NODE_SIZE_CELLS_DEFAULT;
}
+int of_simple_addr_cells(const struct device_node *np)
+{
+ const __be32 *ip;
+
+ ip = of_get_property(np, "#address-cells", NULL);
+ if (ip)
+ return be32_to_cpup(ip);
+
+ /* Return a default of 2 to match fdt_address_cells()*/
+ return 2;
+}
+
+int of_simple_size_cells(const struct device_node *np)
+{
+ const __be32 *ip;
+
+ ip = of_get_property(np, "#size-cells", NULL);
+ if (ip)
+ return be32_to_cpup(ip);
+
+ /* Return a default of 2 to match fdt_size_cells()*/
+ return 2;
+}
+
struct property *of_find_property(const struct device_node *np,
const char *name, int *lenp)
{
{
if (ofnode_is_np(node))
return of_n_addr_cells(ofnode_to_np(node));
- else
+ else /* NOTE: this call should walk up the parent stack */
return fdt_address_cells(gd->fdt_blob, ofnode_to_offset(node));
}
{
if (ofnode_is_np(node))
return of_n_size_cells(ofnode_to_np(node));
+ else /* NOTE: this call should walk up the parent stack */
+ return fdt_size_cells(gd->fdt_blob, ofnode_to_offset(node));
+}
+
+int ofnode_read_simple_addr_cells(ofnode node)
+{
+ if (ofnode_is_np(node))
+ return of_simple_addr_cells(ofnode_to_np(node));
+ else
+ return fdt_address_cells(gd->fdt_blob, ofnode_to_offset(node));
+}
+
+int ofnode_read_simple_size_cells(ofnode node)
+{
+ if (ofnode_is_np(node))
+ return of_simple_size_cells(ofnode_to_np(node));
else
return fdt_size_cells(gd->fdt_blob, ofnode_to_offset(node));
}
return ofnode_read_size_cells(dev_ofnode(dev));
}
+int dev_read_simple_addr_cells(struct udevice *dev)
+{
+ return ofnode_read_simple_addr_cells(dev_ofnode(dev));
+}
+
+int dev_read_simple_size_cells(struct udevice *dev)
+{
+ return ofnode_read_simple_size_cells(dev_ofnode(dev));
+}
+
int dev_read_phandle(struct udevice *dev)
{
ofnode node = dev_ofnode(dev);
ofnode node = dev_ofnode(dev);
struct resource r;
- addr_len = dev_read_addr_cells(dev->parent);
- size_len = dev_read_size_cells(dev->parent);
+ addr_len = dev_read_simple_addr_cells(dev->parent);
+ size_len = dev_read_simple_size_cells(dev->parent);
both_len = addr_len + size_len;
len = dev_read_size(dev, "reg");
prop = ofnode_read_prop(node, "ranges", &len);
if (!prop)
return -EINVAL;
- pci_addr_cells = ofnode_read_addr_cells(node);
- addr_cells = ofnode_read_addr_cells(parent_node);
- size_cells = ofnode_read_size_cells(node);
+ pci_addr_cells = ofnode_read_simple_addr_cells(node);
+ addr_cells = ofnode_read_simple_addr_cells(parent_node);
+ size_cells = ofnode_read_simple_size_cells(node);
/* PCI addresses are always 3-cells */
len /= sizeof(u32);
*/
int of_n_size_cells(const struct device_node *np);
+/**
+ * of_simple_addr_cells() - Get the address cells property in a node
+ *
+ * This function matches fdt_address_cells().
+ *
+ * @np: Node pointer to check
+ * @return value of #address-cells property in this node, or 2 if none
+ */
+int of_simple_addr_cells(const struct device_node *np);
+
+/**
+ * of_simple_size_cells() - Get the size cells property in a node
+ *
+ * This function matches fdt_size_cells().
+ *
+ * @np: Node pointer to check
+ * @return value of #size-cells property in this node, or 2 if none
+ */
+int of_simple_size_cells(const struct device_node *np);
+
/**
* of_find_property() - find a property in a node
*
*/
int ofnode_read_size_cells(ofnode node);
+/**
+ * ofnode_read_simple_addr_cells() - Get the address cells property in a node
+ *
+ * This function matches fdt_address_cells().
+ *
+ * @np: Node pointer to check
+ * @return value of #address-cells property in this node, or 2 if none
+ */
+int ofnode_read_simple_addr_cells(ofnode node);
+
+/**
+ * ofnode_read_simple_size_cells() - Get the size cells property in a node
+ *
+ * This function matches fdt_size_cells().
+ *
+ * @np: Node pointer to check
+ * @return value of #size-cells property in this node, or 2 if none
+ */
+int ofnode_read_simple_size_cells(ofnode node);
+
/**
* ofnode_pre_reloc() - check if a node should be bound before relocation
*
*/
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
*
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));
}