summaryrefslogtreecommitdiff
path: root/include/dm
diff options
context:
space:
mode:
Diffstat (limited to 'include/dm')
-rw-r--r--include/dm/device.h2
-rw-r--r--include/dm/of_access.h20
-rw-r--r--include/dm/ofnode.h50
-rw-r--r--include/dm/pinctrl.h28
4 files changed, 99 insertions, 1 deletions
diff --git a/include/dm/device.h b/include/dm/device.h
index 7bcf6df2892..5d700888503 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -388,7 +388,7 @@ struct driver {
const void *ops; /* driver-specific operations */
uint32_t flags;
#if CONFIG_IS_ENABLED(ACPIGEN)
- struct acpi_ops *acpi_ops;
+ const struct acpi_ops *acpi_ops;
#endif
};
diff --git a/include/dm/of_access.h b/include/dm/of_access.h
index 44143a5a391..fe0de73d7e2 100644
--- a/include/dm/of_access.h
+++ b/include/dm/of_access.h
@@ -386,6 +386,23 @@ int of_read_u32_array(const struct device_node *np, const char *propname,
u32 *out_values, size_t sz);
/**
+ * of_read_u64_array() - Find and read an array of 64 bit integers
+ *
+ * Search for a property in a device node and read 64-bit value(s) from
+ * it.
+ *
+ * @np: device node from which the property value is to be read.
+ * @propname: name of the property to be searched.
+ * @out_values: pointer to return value, modified only if return value is 0.
+ * @sz: number of array elements to read
+ * Return:
+ * 0 on success, -EINVAL if the property does not exist, or -EOVERFLOW if
+ * longer than sz.
+ */
+int of_read_u64_array(const struct device_node *np, const char *propname,
+ u64 *out_values, size_t sz);
+
+/**
* of_property_match_string() - Find string in a list and return index
*
* This function searches a string list property and returns the index
@@ -616,6 +633,9 @@ int of_count_phandle_with_args(const struct device_node *np,
const char *list_name, const char *cells_name,
int cells_count);
+int of_property_count_elems_of_size(const struct device_node *np,
+ const char *propname, int elem_size);
+
/**
* of_alias_scan() - Scan all properties of the 'aliases' node
*
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index 120393426db..c905e86b283 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -375,6 +375,13 @@ static inline oftree oftree_from_np(struct device_node *root)
return tree;
}
+/* Dummy put for Linux compat */
+static inline void ofnode_put(ofnode node)
+{
+ if (ofnode_is_np(node))
+ of_node_put(node.np);
+}
+
/**
* oftree_dispose() - Dispose of an oftree
*
@@ -589,6 +596,25 @@ int ofnode_read_u32_array(ofnode node, const char *propname,
u32 *out_values, size_t sz);
/**
+ * ofnode_read_u64_array() - Find and read an array of 64 bit integers
+ *
+ * @node: valid node reference to read property from
+ * @propname: name of the property to read
+ * @out_values: pointer to return value, modified only if return value is 0
+ * @sz: number of array elements to read
+ * 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
+ *
+ * Search for a property in a device node and read 64-bit value(s) from
+ * it.
+ *
+ * The out_values is modified only if a valid u64 value can be decoded.
+ */
+int ofnode_read_u64_array(ofnode node, const char *propname,
+ u64 *out_values, size_t sz);
+
+/**
* ofnode_read_bool() - read a boolean value from a property
*
* @node: valid node reference to read property from
@@ -652,6 +678,30 @@ static inline ofnode ofnode_next_subnode(ofnode node)
fdt_next_subnode(gd->fdt_blob, ofnode_to_offset(node)));
}
#else
+
+/**
+ * ofnode_count_elems_of_size() - count the number of elements of size @elem_size
+ * in the property @propname.
+ *
+ * @node: ofnode to check
+ * @propname: the name of the property to count
+ * @elem_size: the size of each element
+ *
+ * Returns: the number of elements or -EINVAL if the property size is not a
+ * multiple of elem_size.
+ */
+int ofnode_count_elems_of_size(ofnode node, const char *propname, int elem_size);
+
+static inline int ofnode_count_u32_elems(ofnode node, const char *propname)
+{
+ return ofnode_count_elems_of_size(node, propname, 4);
+}
+
+static inline int ofnode_count_u64_elems(ofnode node, const char *propname)
+{
+ return ofnode_count_elems_of_size(node, propname, 8);
+}
+
/**
* ofnode_is_enabled() - Checks whether a node is enabled.
* This looks for a 'status' property. If this exists, then returns true if
diff --git a/include/dm/pinctrl.h b/include/dm/pinctrl.h
index e41baea6200..36db47802c7 100644
--- a/include/dm/pinctrl.h
+++ b/include/dm/pinctrl.h
@@ -481,6 +481,34 @@ enum pin_config_param {
PIN_CONFIG_MAX = 255, /* 0xFF */
};
+/*
+ * Helpful configuration macro to be used in tables etc.
+ */
+#define PIN_CONF_PACKED(p, a) ((a << 8) | ((unsigned long) p & 0xffUL))
+
+/*
+ * The following inlines stuffs a configuration parameter and data value
+ * into and out of an unsigned long argument, as used by the generic pin config
+ * system. We put the parameter in the lower 8 bits and the argument in the
+ * upper 24 bits.
+ */
+
+static inline enum pin_config_param pinconf_to_config_param(unsigned long config)
+{
+ return (enum pin_config_param) (config & 0xffUL);
+}
+
+static inline u32 pinconf_to_config_argument(unsigned long config)
+{
+ return (u32) ((config >> 8) & 0xffffffUL);
+}
+
+static inline unsigned long pinconf_to_config_packed(enum pin_config_param param,
+ u32 argument)
+{
+ return PIN_CONF_PACKED(param, argument);
+}
+
#if CONFIG_IS_ENABLED(PINCTRL_GENERIC)
/**
* pinctrl_generic_set_state() - Generic set_state operation