summaryrefslogtreecommitdiff
path: root/drivers/core/ofnode.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/core/ofnode.c')
-rw-r--r--drivers/core/ofnode.c87
1 files changed, 44 insertions, 43 deletions
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index 21a233f90f0..7e3b3719d18 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -6,7 +6,6 @@
#define LOG_CATEGORY LOGC_DT
-#include <common.h>
#include <dm.h>
#include <fdtdec.h>
#include <fdt_support.h>
@@ -17,6 +16,7 @@
#include <dm/of_access.h>
#include <dm/of_addr.h>
#include <dm/ofnode.h>
+#include <dm/util.h>
#include <linux/err.h>
#include <linux/ioport.h>
#include <asm/global_data.h>
@@ -315,7 +315,7 @@ int ofnode_read_u8(ofnode node, const char *propname, u8 *outp)
int len;
assert(ofnode_valid(node));
- debug("%s: %s: ", __func__, propname);
+ dm_warn("%s: %s: ", __func__, propname);
if (ofnode_is_np(node))
return of_read_u8(ofnode_to_np(node), propname, outp);
@@ -323,11 +323,11 @@ int ofnode_read_u8(ofnode node, const char *propname, u8 *outp)
cell = fdt_getprop(gd->fdt_blob, ofnode_to_offset(node), propname,
&len);
if (!cell || len < sizeof(*cell)) {
- debug("(not found)\n");
+ dm_warn("(not found)\n");
return -EINVAL;
}
*outp = *cell;
- debug("%#x (%d)\n", *outp, *outp);
+ dm_warn("%#x (%u)\n", *outp, *outp);
return 0;
}
@@ -346,7 +346,7 @@ int ofnode_read_u16(ofnode node, const char *propname, u16 *outp)
int len;
assert(ofnode_valid(node));
- debug("%s: %s: ", __func__, propname);
+ dm_warn("%s: %s: ", __func__, propname);
if (ofnode_is_np(node))
return of_read_u16(ofnode_to_np(node), propname, outp);
@@ -354,11 +354,11 @@ int ofnode_read_u16(ofnode node, const char *propname, u16 *outp)
cell = fdt_getprop(gd->fdt_blob, ofnode_to_offset(node), propname,
&len);
if (!cell || len < sizeof(*cell)) {
- debug("(not found)\n");
+ dm_warn("(not found)\n");
return -EINVAL;
}
*outp = be16_to_cpup(cell);
- debug("%#x (%d)\n", *outp, *outp);
+ dm_warn("%#x (%u)\n", *outp, *outp);
return 0;
}
@@ -391,7 +391,7 @@ int ofnode_read_u32_index(ofnode node, const char *propname, int index,
int len;
assert(ofnode_valid(node));
- debug("%s: %s: ", __func__, propname);
+ dm_warn("%s: %s: ", __func__, propname);
if (ofnode_is_np(node))
return of_read_u32_index(ofnode_to_np(node), propname, index,
@@ -400,17 +400,17 @@ int ofnode_read_u32_index(ofnode node, const char *propname, int index,
cell = fdt_getprop(ofnode_to_fdt(node), ofnode_to_offset(node),
propname, &len);
if (!cell) {
- debug("(not found)\n");
+ dm_warn("(not found)\n");
return -EINVAL;
}
if (len < (sizeof(int) * (index + 1))) {
- debug("(not large enough)\n");
+ dm_warn("(not large enough)\n");
return -EOVERFLOW;
}
*outp = fdt32_to_cpu(cell[index]);
- debug("%#x (%d)\n", *outp, *outp);
+ dm_warn("%#x (%u)\n", *outp, *outp);
return 0;
}
@@ -430,17 +430,17 @@ int ofnode_read_u64_index(ofnode node, const char *propname, int index,
cell = fdt_getprop(ofnode_to_fdt(node), ofnode_to_offset(node),
propname, &len);
if (!cell) {
- debug("(not found)\n");
+ dm_warn("(not found)\n");
return -EINVAL;
}
if (len < (sizeof(u64) * (index + 1))) {
- debug("(not large enough)\n");
+ dm_warn("(not large enough)\n");
return -EOVERFLOW;
}
*outp = fdt64_to_cpu(cell[index]);
- debug("%#llx (%lld)\n", *outp, *outp);
+ dm_warn("%#llx (%llu)\n", *outp, *outp);
return 0;
}
@@ -468,7 +468,7 @@ int ofnode_read_u64(ofnode node, const char *propname, u64 *outp)
int len;
assert(ofnode_valid(node));
- debug("%s: %s: ", __func__, propname);
+ dm_warn("%s: %s: ", __func__, propname);
if (ofnode_is_np(node))
return of_read_u64(ofnode_to_np(node), propname, outp);
@@ -476,12 +476,12 @@ int ofnode_read_u64(ofnode node, const char *propname, u64 *outp)
cell = fdt_getprop(ofnode_to_fdt(node), ofnode_to_offset(node),
propname, &len);
if (!cell || len < sizeof(*cell)) {
- debug("(not found)\n");
+ dm_warn("(not found)\n");
return -EINVAL;
}
*outp = fdt64_to_cpu(cell[0]);
- debug("%#llx (%lld)\n", (unsigned long long)*outp,
- (unsigned long long)*outp);
+ dm_warn("%#llx (%llu)\n", (unsigned long long)*outp,
+ (unsigned long long)*outp);
return 0;
}
@@ -499,11 +499,11 @@ bool ofnode_read_bool(ofnode node, const char *propname)
bool prop;
assert(ofnode_valid(node));
- debug("%s: %s: ", __func__, propname);
+ dm_warn("%s: %s: ", __func__, propname);
prop = ofnode_has_property(node, propname);
- debug("%s\n", prop ? "true" : "false");
+ dm_warn("%s\n", prop ? "true" : "false");
return prop ? true : false;
}
@@ -514,7 +514,7 @@ const void *ofnode_read_prop(ofnode node, const char *propname, int *sizep)
int len;
assert(ofnode_valid(node));
- debug("%s: %s: ", __func__, propname);
+ dm_warn("%s: %s: ", __func__, propname);
if (ofnode_is_np(node)) {
struct property *prop = of_find_property(
@@ -529,7 +529,7 @@ const void *ofnode_read_prop(ofnode node, const char *propname, int *sizep)
propname, &len);
}
if (!val) {
- debug("<not found>\n");
+ dm_warn("<not found>\n");
if (sizep)
*sizep = -FDT_ERR_NOTFOUND;
return NULL;
@@ -550,10 +550,10 @@ const char *ofnode_read_string(ofnode node, const char *propname)
return NULL;
if (strnlen(str, len) >= len) {
- debug("<invalid>\n");
+ dm_warn("<invalid>\n");
return NULL;
}
- debug("%s\n", str);
+ dm_warn("%s\n", str);
return str;
}
@@ -573,7 +573,7 @@ ofnode ofnode_find_subnode(ofnode node, const char *subnode_name)
ofnode subnode;
assert(ofnode_valid(node));
- debug("%s: %s: ", __func__, subnode_name);
+ dm_warn("%s: %s: ", __func__, subnode_name);
if (ofnode_is_np(node)) {
struct device_node *np = ofnode_to_np(node);
@@ -588,8 +588,8 @@ ofnode ofnode_find_subnode(ofnode node, const char *subnode_name)
ofnode_to_offset(node), subnode_name);
subnode = noffset_to_ofnode(node, ooffset);
}
- debug("%s\n", ofnode_valid(subnode) ?
- ofnode_get_name(subnode) : "<none>");
+ dm_warn("%s\n", ofnode_valid(subnode) ?
+ ofnode_get_name(subnode) : "<none>");
return subnode;
}
@@ -598,7 +598,7 @@ int ofnode_read_u32_array(ofnode node, const char *propname,
u32 *out_values, size_t sz)
{
assert(ofnode_valid(node));
- debug("%s: %s: ", __func__, propname);
+ dm_warn("%s: %s: ", __func__, propname);
if (ofnode_is_np(node)) {
return of_read_u32_array(ofnode_to_np(node), propname,
@@ -670,7 +670,7 @@ ofnode ofnode_get_parent(ofnode node)
const char *ofnode_get_name(ofnode node)
{
if (!ofnode_valid(node)) {
- debug("%s node not valid\n", __func__);
+ dm_warn("%s node not valid\n", __func__);
return NULL;
}
@@ -762,8 +762,9 @@ static fdt_addr_t __ofnode_get_addr_size_index(ofnode node, int index,
return of_read_number(prop_val, na);
}
} else {
- na = ofnode_read_simple_addr_cells(ofnode_get_parent(node));
- ns = ofnode_read_simple_size_cells(ofnode_get_parent(node));
+ ofnode parent = ofnode_get_parent(node);
+ na = ofnode_read_simple_addr_cells(parent);
+ ns = ofnode_read_simple_size_cells(parent);
return fdtdec_get_addr_size_fixed(ofnode_to_fdt(node),
ofnode_to_offset(node), "reg",
index, na, ns, size,
@@ -1031,7 +1032,7 @@ ofnode ofnode_get_aliases_node(const char *name)
if (!prop)
return ofnode_null();
- debug("%s: node_path: %s\n", __func__, prop);
+ dm_warn("%s: node_path: %s\n", __func__, prop);
return ofnode_path(prop);
}
@@ -1054,8 +1055,8 @@ static int decode_timing_property(ofnode node, const char *name,
length = ofnode_read_size(node, name);
if (length < 0) {
- debug("%s: could not find property %s\n",
- ofnode_get_name(node), name);
+ dm_warn("%s: could not find property %s\n",
+ ofnode_get_name(node), name);
return length;
}
@@ -1300,7 +1301,7 @@ int ofnode_read_pci_addr(ofnode node, enum fdt_pci_space type,
int len;
int ret = -ENOENT;
- debug("%s: %s: ", __func__, propname);
+ dm_warn("%s: %s: ", __func__, propname);
/*
* If we follow the pci bus bindings strictly, we should check
@@ -1317,8 +1318,8 @@ int ofnode_read_pci_addr(ofnode node, enum fdt_pci_space type,
int i;
for (i = 0; i < num; i++) {
- debug("pci address #%d: %08lx %08lx %08lx\n", i,
- (ulong)fdt32_to_cpu(cell[0]),
+ dm_warn("pci address #%d: %08lx %08lx %08lx\n", i,
+ (ulong)fdt32_to_cpu(cell[0]),
(ulong)fdt32_to_cpu(cell[1]),
(ulong)fdt32_to_cpu(cell[2]));
if ((fdt32_to_cpu(*cell) & type) == type) {
@@ -1347,7 +1348,7 @@ int ofnode_read_pci_addr(ofnode node, enum fdt_pci_space type,
ret = -EINVAL;
fail:
- debug("(not found)\n");
+ dm_warn("(not found)\n");
return ret;
}
@@ -1631,7 +1632,7 @@ int ofnode_write_string(ofnode node, const char *propname, const char *value)
{
assert(ofnode_valid(node));
- debug("%s: %s = %s", __func__, propname, value);
+ dm_warn("%s: %s = %s", __func__, propname, value);
return ofnode_write_prop(node, propname, value, strlen(value) + 1,
false);
@@ -1744,7 +1745,7 @@ int ofnode_read_bootscript_address(u64 *bootscr_address, u64 *bootscr_offset)
uboot = ofnode_path("/options/u-boot");
if (!ofnode_valid(uboot)) {
- debug("%s: Missing /u-boot node\n", __func__);
+ dm_warn("%s: Missing /u-boot node\n", __func__);
return -EINVAL;
}
@@ -1770,7 +1771,7 @@ int ofnode_read_bootscript_flash(u64 *bootscr_flash_offset,
uboot = ofnode_path("/options/u-boot");
if (!ofnode_valid(uboot)) {
- debug("%s: Missing /u-boot node\n", __func__);
+ dm_warn("%s: Missing /u-boot node\n", __func__);
return -EINVAL;
}
@@ -1785,7 +1786,7 @@ int ofnode_read_bootscript_flash(u64 *bootscr_flash_offset,
return -EINVAL;
if (!bootscr_flash_size) {
- debug("bootscr-flash-size is zero. Ignoring properties!\n");
+ dm_warn("bootscr-flash-size is zero. Ignoring properties!\n");
*bootscr_flash_offset = 0;
return -EINVAL;
}
@@ -1832,7 +1833,7 @@ phy_interface_t ofnode_read_phy_mode(ofnode node)
if (!strcmp(mode, phy_interface_strings[i]))
return i;
- debug("%s: Invalid PHY interface '%s'\n", __func__, mode);
+ dm_warn("%s: Invalid PHY interface '%s'\n", __func__, mode);
return PHY_INTERFACE_MODE_NA;
}