diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/dm/of_access.h | 10 | ||||
-rw-r--r-- | include/dm/read.h | 16 | ||||
-rw-r--r-- | include/fdtdec.h | 13 |
3 files changed, 39 insertions, 0 deletions
diff --git a/include/dm/of_access.h b/include/dm/of_access.h index 5ed1a0cdb42..13fedb7cf5e 100644 --- a/include/dm/of_access.h +++ b/include/dm/of_access.h @@ -425,6 +425,16 @@ int of_alias_scan(void); int of_alias_get_id(const struct device_node *np, const char *stem); /** + * of_alias_get_highest_id - Get highest alias id for the given stem + * @stem: Alias stem to be examined + * + * The function travels the lookup table to get the highest alias id for the + * given alias stem. + * @return alias ID, if found, else -1 + */ +int of_alias_get_highest_id(const char *stem); + +/** * of_get_stdout() - Get node to use for stdout * * @return node referred to by stdout-path alias, or NULL if none diff --git a/include/dm/read.h b/include/dm/read.h index 389e30e7fb4..60b727cbd82 100644 --- a/include/dm/read.h +++ b/include/dm/read.h @@ -510,6 +510,17 @@ int dev_read_resource_byname(struct udevice *dev, const char *name, * @return the translated address; OF_BAD_ADDR on error */ u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_addr); + +/** + * dev_read_alias_highest_id - Get highest alias id for the given stem + * @stem: Alias stem to be examined + * + * The function travels the lookup table to get the highest alias id for the + * given alias stem. + * @return alias ID, if found, else -1 + */ +int dev_read_alias_highest_id(const char *stem); + #else /* CONFIG_DM_DEV_READ_INLINE is enabled */ static inline int dev_read_u32(struct udevice *dev, @@ -740,6 +751,11 @@ static inline u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_a return ofnode_translate_address(dev_ofnode(dev), in_addr); } +static inline int dev_read_alias_highest_id(const char *stem) +{ + return fdtdec_get_alias_highest_id(gd->fdt_blob, stem); +} + #endif /* CONFIG_DM_DEV_READ_INLINE */ /** diff --git a/include/fdtdec.h b/include/fdtdec.h index 2a8ad960260..b7e35cd87c5 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -619,6 +619,19 @@ int fdtdec_get_alias_seq(const void *blob, const char *base, int node, int *seqp); /** + * Get the highest alias number for susbystem. + * + * It parses all aliases and find out highest recorded alias for subsystem. + * Aliases are of the form <base><num> where <num> is the sequence number. + * + * @param blob Device tree blob (if NULL, then error is returned) + * @param base Base name for alias susbystem (before the number) + * + * @return 0 highest alias ID, -1 if not found + */ +int fdtdec_get_alias_highest_id(const void *blob, const char *base); + +/** * Get a property from the /chosen node * * @param blob Device tree blob (if NULL, then NULL is returned) |