aboutsummaryrefslogtreecommitdiff
path: root/include/fdt_support.h
diff options
context:
space:
mode:
authorMarek BehĂșn2021-11-26 14:57:10 +0100
committerStefan Roese2021-12-19 09:50:47 +0100
commit9ab0c2f837241b819b23cbb5d48fa43acc2938d5 (patch)
tree7274860398816aa71ee957aa8c8b443f7e3c0aa5 /include/fdt_support.h
parentc92ccba7710b3f5fbeebced9cad57f24c940b834 (diff)
fdt_support: Add some useful functions
Add functions fdt_node_offset_by_pathf(), fdt_create_phandle_by_pathf(), fdt_set_status_by_pathf() to get node offset, get/create node phandle and set status for node given by path/alias formatted with sprintf. Add functions fdt_create_phandle_by_compatible(), fdt_set_status_by_compatible() to get/create node phandle and set status for first node given by compatible. Signed-off-by: Marek BehĂșn <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'include/fdt_support.h')
-rw-r--r--include/fdt_support.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/include/fdt_support.h b/include/fdt_support.h
index 850c860bd42..d40586725bc 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -285,8 +285,13 @@ int fdt_get_dma_range(const void *blob, int node_offset, phys_addr_t *cpu,
int fdt_node_offset_by_compat_reg(void *blob, const char *compat,
phys_addr_t compat_off);
+int fdt_node_offset_by_pathf(void *blob, const char *fmt, ...)
+ __attribute__ ((format (printf, 2, 3)));
int fdt_set_phandle(void *fdt, int nodeoffset, uint32_t phandle);
unsigned int fdt_create_phandle(void *fdt, int nodeoffset);
+unsigned int fdt_create_phandle_by_compatible(void *fdt, const char *compat);
+unsigned int fdt_create_phandle_by_pathf(void *fdt, const char *fmt, ...)
+ __attribute__ ((format (printf, 2, 3)));
int fdt_add_edid(void *blob, const char *compat, unsigned char *buf);
int fdt_verify_alias_address(void *fdt, int anode, const char *alias,
@@ -329,6 +334,31 @@ static inline int fdt_status_fail_by_alias(void *fdt, const char *alias)
return fdt_set_status_by_alias(fdt, alias, FDT_STATUS_FAIL);
}
+int fdt_set_status_by_compatible(void *fdt, const char *compat,
+ enum fdt_status status);
+static inline int fdt_status_okay_by_compatible(void *fdt, const char *compat)
+{
+ return fdt_set_status_by_compatible(fdt, compat, FDT_STATUS_OKAY);
+}
+static inline int fdt_status_disabled_by_compatible(void *fdt,
+ const char *compat)
+{
+ return fdt_set_status_by_compatible(fdt, compat, FDT_STATUS_DISABLED);
+}
+static inline int fdt_status_fail_by_compatible(void *fdt, const char *compat)
+{
+ return fdt_set_status_by_compatible(fdt, compat, FDT_STATUS_FAIL);
+}
+
+int fdt_set_status_by_pathf(void *fdt, enum fdt_status status, const char *fmt,
+ ...) __attribute__ ((format (printf, 3, 4)));
+#define fdt_status_okay_by_pathf(fdt, fmt, ...) \
+ fdt_set_status_by_pathf((fdt), FDT_STATUS_OKAY, (fmt), ##__VA_ARGS__)
+#define fdt_status_disabled_by_pathf(fdt, fmt, ...) \
+ fdt_set_status_by_pathf((fdt), FDT_STATUS_DISABLED, (fmt), ##__VA_ARGS__)
+#define fdt_status_fail_by_pathf(fdt, fmt, ...) \
+ fdt_set_status_by_pathf((fdt), FDT_STATUS_FAIL, (fmt), ##__VA_ARGS__)
+
/* Helper to read a big number; size is in cells (not bytes) */
static inline u64 fdt_read_number(const fdt32_t *cell, int size)
{