diff options
author | Simon Glass <sjg@chromium.org> | 2017-06-12 06:21:30 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2017-07-11 10:08:20 -0600 |
commit | f7d6fcf7aead384ea39bc7aba581e912c3759eaa (patch) | |
tree | aae54342a8ce91b9c5ad4ba9418e42d2d891586b /drivers/core | |
parent | a44810123f9ef069587beacdce7d6f488cf42973 (diff) | |
download | u-boot-f7d6fcf7aead384ea39bc7aba581e912c3759eaa.tar.gz u-boot-f7d6fcf7aead384ea39bc7aba581e912c3759eaa.tar.xz u-boot-f7d6fcf7aead384ea39bc7aba581e912c3759eaa.zip |
dm: core: Add dev_read_enabled() to check if a device is enabled
This function allows a device's status to be read. This indicates whether
the device should be enabled or disabled.
Note: In normal operation disabled devices will not be present in the
driver-model tree.
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-on: Beaver, Jetson-TK1
Diffstat (limited to 'drivers/core')
-rw-r--r-- | drivers/core/read.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/core/read.c b/drivers/core/read.c index 3131e5379c..1080767313 100644 --- a/drivers/core/read.c +++ b/drivers/core/read.c @@ -138,3 +138,14 @@ const uint8_t *dev_read_u8_array_ptr(struct udevice *dev, const char *propname, { return ofnode_read_u8_array_ptr(dev_ofnode(dev), propname, sz); } + +int dev_read_enabled(struct udevice *dev) +{ + ofnode node = dev_ofnode(dev); + + if (ofnode_is_np(node)) + return of_device_is_available(ofnode_to_np(node)); + else + return fdtdec_get_is_enabled(gd->fdt_blob, + ofnode_to_offset(node)); +} |