From: T Karthik Reddy Date: Mon, 2 Sep 2019 14:34:30 +0000 (+0200) Subject: dm: core: Add functions to read 64-bit dt properties X-Git-Tag: v2019.10-rc4~17^2~1 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3f3d77158b8452a16dca4a6966217b344f77f9b7;p=oweals%2Fu-boot.git dm: core: Add functions to read 64-bit dt properties This patch adds functions dev_read_u64_default & dev_read_u64 to read unsigned 64-bit values from devicetree. Signed-off-by: T Karthik Reddy Signed-off-by: Michal Simek Reviewed-by: Bin Meng --- diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index e74a662d1d..7eca00cd66 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -79,7 +79,7 @@ int ofnode_read_u64(ofnode node, const char *propname, u64 *outp) return 0; } -int ofnode_read_u64_default(ofnode node, const char *propname, u64 def) +u64 ofnode_read_u64_default(ofnode node, const char *propname, u64 def) { assert(ofnode_valid(node)); ofnode_read_u64(node, propname, &def); diff --git a/drivers/core/read.c b/drivers/core/read.c index 8b5502de11..fb3dcd9a79 100644 --- a/drivers/core/read.c +++ b/drivers/core/read.c @@ -44,6 +44,16 @@ int dev_read_u32u(struct udevice *dev, const char *propname, uint *outp) return 0; } +int dev_read_u64(struct udevice *dev, const char *propname, u64 *outp) +{ + return ofnode_read_u64(dev_ofnode(dev), propname, outp); +} + +u64 dev_read_u64_default(struct udevice *dev, const char *propname, u64 def) +{ + return ofnode_read_u64_default(dev_ofnode(dev), propname, def); +} + const char *dev_read_string(struct udevice *dev, const char *propname) { return ofnode_read_string(dev_ofnode(dev), propname); diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 4f89db44c1..5c4cbf0998 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -254,7 +254,7 @@ int ofnode_read_u64(ofnode node, const char *propname, u64 *outp); * @def: default value to return if the property has no value * @return property value, or @def if not found */ -int ofnode_read_u64_default(ofnode node, const char *propname, u64 def); +u64 ofnode_read_u64_default(ofnode node, const char *propname, u64 def); /** * ofnode_read_string() - Read a string from a property diff --git a/include/dm/read.h b/include/dm/read.h index 0c62d62f11..803daf7620 100644 --- a/include/dm/read.h +++ b/include/dm/read.h @@ -44,6 +44,7 @@ static inline bool dev_of_valid(struct udevice *dev) } #ifndef CONFIG_DM_DEV_READ_INLINE + /** * dev_read_u32() - read a 32-bit integer from a device's DT property * @@ -96,6 +97,26 @@ int dev_read_s32_default(struct udevice *dev, const char *propname, int def); */ int dev_read_u32u(struct udevice *dev, const char *propname, uint *outp); +/** + * dev_read_u64() - read a 64-bit integer from a device's DT property + * + * @dev: device to read DT property from + * @propname: name of the property to read from + * @outp: place to put value (if found) + * @return 0 if OK, -ve on error + */ +int dev_read_u64(struct udevice *dev, const char *propname, u64 *outp); + +/** + * dev_read_u64_default() - read a 64-bit integer from a device's DT property + * + * @dev: device to read DT property from + * @propname: name of the property to read from + * @def: default value to return if the property has no value + * @return property value, or @def if not found + */ +u64 dev_read_u64_default(struct udevice *dev, const char *propname, u64 def); + /** * dev_read_string() - Read a string from a device's DT property * @@ -601,6 +622,18 @@ static inline int dev_read_u32u(struct udevice *dev, return 0; } +static inline int dev_read_u64(struct udevice *dev, + const char *propname, u64 *outp) +{ + return ofnode_read_u64(dev_ofnode(dev), propname, outp); +} + +static inline u64 dev_read_u64_default(struct udevice *dev, + const char *propname, u64 def) +{ + return ofnode_read_u64_default(dev_ofnode(dev), propname, def); +} + static inline const char *dev_read_string(struct udevice *dev, const char *propname) {