summaryrefslogtreecommitdiff
path: root/drivers/core/ofnode.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2018-08-09 11:10:41 -0400
committerTom Rini <trini@konsulko.com>2018-08-09 11:10:41 -0400
commitb243f41f12d63d35234b25949319837e318ff9e0 (patch)
treef1161e19e75eba5acf78341006609df07a4ac482 /drivers/core/ofnode.c
parent9d17682a57bcc290a2584d81a47537aa0b6b17c1 (diff)
parent41d7535cba42cd88f3b04f8fbd4409e5a479076f (diff)
Merge git://git.denx.de/u-boot-dm
Diffstat (limited to 'drivers/core/ofnode.c')
-rw-r--r--drivers/core/ofnode.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index 29375397e0..0cfb0fbabb 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -623,6 +623,42 @@ fail:
return ret;
}
+int ofnode_read_pci_vendev(ofnode node, u16 *vendor, u16 *device)
+{
+ const char *list, *end;
+ int len;
+
+ list = ofnode_get_property(node, "compatible", &len);
+ if (!list)
+ return -ENOENT;
+
+ end = list + len;
+ while (list < end) {
+ len = strlen(list);
+ if (len >= strlen("pciVVVV,DDDD")) {
+ char *s = strstr(list, "pci");
+
+ /*
+ * check if the string is something like pciVVVV,DDDD.RR
+ * or just pciVVVV,DDDD
+ */
+ if (s && s[7] == ',' &&
+ (s[12] == '.' || s[12] == 0)) {
+ s += 3;
+ *vendor = simple_strtol(s, NULL, 16);
+
+ s += 5;
+ *device = simple_strtol(s, NULL, 16);
+
+ return 0;
+ }
+ }
+ list += (len + 1);
+ }
+
+ return -ENOENT;
+}
+
int ofnode_read_addr_cells(ofnode node)
{
if (ofnode_is_np(node))