summaryrefslogtreecommitdiff
path: root/drivers/core
diff options
context:
space:
mode:
authorMugunthan V N <mugunthanvnm@ti.com>2016-04-28 10:06:02 (GMT)
committerJoe Hershberger <joe.hershberger@ni.com>2016-05-24 16:42:02 (GMT)
commit73443b9e4c451b17d1e08164ea933ee6a849b2b3 (patch)
tree0fc80ed0bc6b1ef1d928aa61f55650a0658e9d82 /drivers/core
parent24ae3961f811ee79e6c98474e21e07f8ce222dfc (diff)
downloadu-boot-73443b9e4c451b17d1e08164ea933ee6a849b2b3.tar.xz
drivers: core: device: add support to check dt compatible for a device/machine
Provide an api to check whether the given device or machine is compatible with the given compat string which helps in making decisions in drivers based on device or machine compatible. Idea taken from Linux. Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com> Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'drivers/core')
-rw-r--r--drivers/core/device.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 5c2dc70..45d5e3e 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -721,3 +721,17 @@ int device_set_name(struct udevice *dev, const char *name)
return 0;
}
+
+bool of_device_is_compatible(struct udevice *dev, const char *compat)
+{
+ const void *fdt = gd->fdt_blob;
+
+ return !fdt_node_check_compatible(fdt, dev->of_offset, compat);
+}
+
+bool of_machine_is_compatible(const char *compat)
+{
+ const void *fdt = gd->fdt_blob;
+
+ return !fdt_node_check_compatible(fdt, 0, compat);
+}