summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2020-04-16 13:45:03 -0400
committerTom Rini <trini@konsulko.com>2020-04-16 13:45:03 -0400
commitf51b4bcf61c9aa7994138a4a417488c1fbdb47cd (patch)
tree4f536d0892be1359f2cf02bfe366b56bef83bf28 /include
parentdba0a6ae1907bbff3ebda06e4874d006f10db1bb (diff)
parentb0dcc87106464c3fc019e3771378a092fd32ebdb (diff)
Merge tag 'dm-pull-10apr20-take2' of git://git.denx.de/u-boot-dm
Functions for reading indexed values from device tree Enhancements to 'dm' command Log test enhancements and syslog driver DM change to read parent ofdata before children Minor fixes
Diffstat (limited to 'include')
-rw-r--r--include/dm/device.h11
-rw-r--r--include/dm/of_access.h19
-rw-r--r--include/dm/ofnode.h25
-rw-r--r--include/dm/read.h40
-rw-r--r--include/dm/util.h27
-rw-r--r--include/log.h10
-rw-r--r--include/test/log.h16
-rw-r--r--include/test/suites.h1
-rw-r--r--include/test/ut.h16
9 files changed, 129 insertions, 36 deletions
diff --git a/include/dm/device.h b/include/dm/device.h
index 35e19d8700..975eec5d0e 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -80,18 +80,21 @@ struct driver_info;
*/
enum {
/* Normal remove, remove all devices */
- DM_REMOVE_NORMAL = 1 << 0,
+ DM_REMOVE_NORMAL = 1 << 0,
/* Remove devices with active DMA */
- DM_REMOVE_ACTIVE_DMA = DM_FLAG_ACTIVE_DMA,
+ DM_REMOVE_ACTIVE_DMA = DM_FLAG_ACTIVE_DMA,
/* Remove devices which need some final OS preparation steps */
- DM_REMOVE_OS_PREPARE = DM_FLAG_OS_PREPARE,
+ DM_REMOVE_OS_PREPARE = DM_FLAG_OS_PREPARE,
/* Add more use cases here */
/* Remove devices with any active flag */
- DM_REMOVE_ACTIVE_ALL = DM_REMOVE_ACTIVE_DMA | DM_REMOVE_OS_PREPARE,
+ DM_REMOVE_ACTIVE_ALL = DM_REMOVE_ACTIVE_DMA | DM_REMOVE_OS_PREPARE,
+
+ /* Don't power down any attached power domains */
+ DM_REMOVE_NO_PD = 1 << 1,
};
/**
diff --git a/include/dm/of_access.h b/include/dm/of_access.h
index 13fedb7cf5..92876b3ecb 100644
--- a/include/dm/of_access.h
+++ b/include/dm/of_access.h
@@ -235,6 +235,25 @@ struct device_node *of_find_node_by_phandle(phandle handle);
int of_read_u32(const struct device_node *np, const char *propname, u32 *outp);
/**
+ * of_read_u32_index() - Find and read a 32-bit value from a multi-value
+ * property
+ *
+ * Search for a property in a device node and read a 32-bit value from
+ * it.
+ *
+ * @np: device node from which the property value is to be read.
+ * @propname: name of the property to be searched.
+ * @index: index of the u32 in the list of values
+ * @outp: pointer to return value, modified only if return value is 0.
+ *
+ * @return 0 on success, -EINVAL if the property does not exist,
+ * -ENODATA if property does not have a value, and -EOVERFLOW if the
+ * property data isn't large enough.
+ */
+int of_read_u32_index(const struct device_node *np, const char *propname,
+ int index, u32 *outp);
+
+/**
* of_read_u64() - Find and read a 64-bit integer from a property
*
* Search for a property in a device node and read a 64-bit value from
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index b5a50e8849..ce5e366c06 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -203,6 +203,18 @@ static inline ofnode ofnode_null(void)
int ofnode_read_u32(ofnode node, const char *propname, u32 *outp);
/**
+ * ofnode_read_u32_index() - Read a 32-bit integer from a multi-value property
+ *
+ * @ref: valid node reference to read property from
+ * @propname: name of the property to read from
+ * @index: index of the integer to return
+ * @outp: place to put value (if found)
+ * @return 0 if OK, -ve on error
+ */
+int ofnode_read_u32_index(ofnode node, const char *propname, int index,
+ u32 *outp);
+
+/**
* ofnode_read_s32() - Read a 32-bit integer from a property
*
* @ref: valid node reference to read property from
@@ -227,6 +239,19 @@ static inline int ofnode_read_s32(ofnode node, const char *propname,
u32 ofnode_read_u32_default(ofnode ref, const char *propname, u32 def);
/**
+ * ofnode_read_u32_index_default() - Read a 32-bit integer from a multi-value
+ * property
+ *
+ * @ref: valid node reference to read property from
+ * @propname: name of the property to read from
+ * @index: index of the integer to return
+ * @def: default value to return if the property has no value
+ * @return property value, or @def if not found
+ */
+u32 ofnode_read_u32_index_default(ofnode ref, const char *propname, int index,
+ u32 def);
+
+/**
* ofnode_read_s32_default() - Read a 32-bit integer from a property
*
* @ref: valid node reference to read property from
diff --git a/include/dm/read.h b/include/dm/read.h
index da8c7f25e7..77d3bc8db5 100644
--- a/include/dm/read.h
+++ b/include/dm/read.h
@@ -67,6 +67,32 @@ int dev_read_u32_default(const struct udevice *dev, const char *propname,
int def);
/**
+ * dev_read_u32_index() - read an indexed 32-bit integer from a device's DT
+ * property
+ *
+ * @dev: device to read DT property from
+ * @propname: name of the property to read from
+ * @index: index of the integer to return
+ * @outp: place to put value (if found)
+ * @return 0 if OK, -ve on error
+ */
+int dev_read_u32_index(struct udevice *dev, const char *propname, int index,
+ u32 *outp);
+
+/**
+ * dev_read_u32_index_default() - read an indexed 32-bit integer from a device's
+ * DT property
+ *
+ * @dev: device to read DT property from
+ * @propname: name of the property to read from
+ * @index: index of the integer to return
+ * @def: default value to return if the property has no value
+ * @return property value, or @def if not found
+ */
+u32 dev_read_u32_index_default(struct udevice *dev, const char *propname,
+ int index, u32 def);
+
+/**
* dev_read_s32() - read a signed 32-bit integer from a device's DT property
*
* @dev: device to read DT property from
@@ -621,6 +647,20 @@ static inline int dev_read_u32_default(const struct udevice *dev,
return ofnode_read_u32_default(dev_ofnode(dev), propname, def);
}
+static inline int dev_read_u32_index(struct udevice *dev,
+ const char *propname, int index, u32 *outp)
+{
+ return ofnode_read_u32_index(dev_ofnode(dev), propname, index, outp);
+}
+
+static inline u32 dev_read_u32_index_default(struct udevice *dev,
+ const char *propname, int index,
+ u32 def)
+{
+ return ofnode_read_u32_index_default(dev_ofnode(dev), propname, index,
+ def);
+}
+
static inline int dev_read_s32(const struct udevice *dev,
const char *propname, s32 *outp)
{
diff --git a/include/dm/util.h b/include/dm/util.h
index 0ccb3fbadf..23f8deb14e 100644
--- a/include/dm/util.h
+++ b/include/dm/util.h
@@ -42,31 +42,4 @@ static inline void dm_dump_devres(void)
/* Dump out a list of drivers */
void dm_dump_drivers(void);
-/**
- * Check if an of node should be or was bound before relocation.
- *
- * Devicetree nodes can be marked as needed to be bound
- * in the loader stages via special devicetree properties.
- *
- * Before relocation this function can be used to check if nodes
- * are required in either SPL or TPL stages.
- *
- * After relocation and jumping into the real U-Boot binary
- * it is possible to determine if a node was bound in one of
- * SPL/TPL stages.
- *
- * There are 4 settings currently in use
- * - u-boot,dm-pre-proper: U-Boot proper pre-relocation only
- * - u-boot,dm-pre-reloc: legacy and indicates any of TPL or SPL
- * Existing platforms only use it to indicate nodes needed in
- * SPL. Should probably be replaced by u-boot,dm-spl for
- * existing platforms.
- * - u-boot,dm-spl: SPL and U-Boot pre-relocation
- * - u-boot,dm-tpl: TPL and U-Boot pre-relocation
- * @node: of node
- *
- * Returns true if node is needed in SPL/TL, false otherwise.
- */
-bool dm_ofnode_pre_reloc(ofnode node);
-
#endif
diff --git a/include/log.h b/include/log.h
index fbcbd42fb4..cf32351134 100644
--- a/include/log.h
+++ b/include/log.h
@@ -117,11 +117,11 @@ static inline int _log_nop(enum log_category_t cat, enum log_level_t level,
#define log_io(_fmt...) log(LOG_CATEGORY, LOGL_DEBUG_IO, ##_fmt)
#else
#define _LOG_MAX_LEVEL LOGL_INFO
-#define log_err(_fmt...) log_nop(LOG_CATEGORY, LOGL_ERR, ##_fmt)
-#define log_warning(_fmt...) log_nop(LOG_CATEGORY, LOGL_WARNING, ##_fmt)
-#define log_notice(_fmt...) log_nop(LOG_CATEGORY, LOGL_NOTICE, ##_fmt)
-#define log_info(_fmt...) log_nop(LOG_CATEGORY, LOGL_INFO, ##_fmt)
-#define log_debug(_fmt...) log_nop(LOG_CATEGORY, LOGL_DEBUG, ##_fmt)
+#define log_err(_fmt, ...) printf(_fmt, ##__VA_ARGS__)
+#define log_warning(_fmt, ...) printf(_fmt, ##__VA_ARGS__)
+#define log_notice(_fmt, ...) printf(_fmt, ##__VA_ARGS__)
+#define log_info(_fmt, ...) printf(_fmt, ##__VA_ARGS__)
+#define log_debug(_fmt, ...) debug(_fmt, ##__VA_ARGS__)
#define log_content(_fmt...) log_nop(LOG_CATEGORY, \
LOGL_DEBUG_CONTENT, ##_fmt)
#define log_io(_fmt...) log_nop(LOG_CATEGORY, LOGL_DEBUG_IO, ##_fmt)
diff --git a/include/test/log.h b/include/test/log.h
new file mode 100644
index 0000000000..c661cde75a
--- /dev/null
+++ b/include/test/log.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2020, Heinrich Schuchardt <xypron.glpk@gmx.de>
+ *
+ * Tests for logging functions
+ */
+
+#ifndef __TEST_LOG_H__
+#define __TEST_LOG_H__
+
+#include <test/test.h>
+
+/* Declare a new logging test */
+#define LOG_TEST(_name) UNIT_TEST(_name, 0, log_test)
+
+#endif /* __TEST_LOG_H__ */
diff --git a/include/test/suites.h b/include/test/suites.h
index 0748185eaf..39ad81a90f 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -30,6 +30,7 @@ int do_ut_compression(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
int do_ut_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
int do_ut_lib(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
+int do_ut_log(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
int do_ut_optee(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
int do_ut_overlay(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
int do_ut_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
diff --git a/include/test/ut.h b/include/test/ut.h
index 39d15953ed..b05d719ed0 100644
--- a/include/test/ut.h
+++ b/include/test/ut.h
@@ -105,6 +105,22 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
} \
}
+/* Assert that two 64 int expressions are equal */
+#define ut_asserteq_64(expr1, expr2) { \
+ u64 _val1 = (expr1), _val2 = (expr2); \
+ \
+ if (_val1 != _val2) { \
+ ut_failf(uts, __FILE__, __LINE__, __func__, \
+ #expr1 " == " #expr2, \
+ "Expected %#llx (%lld), got %#llx (%lld)", \
+ (unsigned long long)_val1, \
+ (unsigned long long)_val1, \
+ (unsigned long long)_val2, \
+ (unsigned long long)_val2); \
+ return CMD_RET_FAILURE; \
+ } \
+}
+
/* Assert that two string expressions are equal */
#define ut_asserteq_str(expr1, expr2) { \
const char *_val1 = (expr1), *_val2 = (expr2); \