aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/backport-5.15
diff options
context:
space:
mode:
authorRafał Miłecki <rafal@milecki.pl>2023-01-07 16:59:14 +0100
committerRafał Miłecki <rafal@milecki.pl>2023-01-07 17:45:17 +0100
commit11759a5bf3c62846ded3d8946322802d41ac8984 (patch)
tree259bc8ffb69f675df951a61bd4f5081651367697 /target/linux/generic/backport-5.15
parent98b09ba250d3f9e690e26ea65e9bbdcc2dc7d26d (diff)
downloadupstream-11759a5bf3c62846ded3d8946322802d41ac8984.tar.gz
upstream-11759a5bf3c62846ded3d8946322802d41ac8984.tar.bz2
upstream-11759a5bf3c62846ded3d8946322802d41ac8984.zip
kernel: backport of changes & helpers
This code is required for upcoming NVMEM changes. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Diffstat (limited to 'target/linux/generic/backport-5.15')
-rw-r--r--target/linux/generic/backport-5.15/826-v5.17-of-base-make-small-of_parse_phandle-variants-static-.patch359
-rw-r--r--target/linux/generic/backport-5.15/827-v6.3-0001-of-base-add-of_parse_phandle_with_optional_args.patch56
-rw-r--r--target/linux/generic/backport-5.15/827-v6.3-0002-of-property-make-.-cells-optional-for-simple-props.patch32
-rw-r--r--target/linux/generic/backport-5.15/827-v6.3-0003-of-property-add-nvmem-cell-cells-property.patch28
4 files changed, 475 insertions, 0 deletions
diff --git a/target/linux/generic/backport-5.15/826-v5.17-of-base-make-small-of_parse_phandle-variants-static-.patch b/target/linux/generic/backport-5.15/826-v5.17-of-base-make-small-of_parse_phandle-variants-static-.patch
new file mode 100644
index 0000000000..b00cf57419
--- /dev/null
+++ b/target/linux/generic/backport-5.15/826-v5.17-of-base-make-small-of_parse_phandle-variants-static-.patch
@@ -0,0 +1,359 @@
+From 66a8f7f04979f4ad739085f01d99c8caf620b4f5 Mon Sep 17 00:00:00 2001
+From: Michael Walle <michael@walle.cc>
+Date: Tue, 18 Jan 2022 18:35:02 +0100
+Subject: [PATCH] of: base: make small of_parse_phandle() variants static
+ inline
+
+Make all the smaller variants of the of_parse_phandle() static inline.
+This also let us remove the empty function stubs if CONFIG_OF is not
+defined.
+
+Suggested-by: Rob Herring <robh@kernel.org>
+Signed-off-by: Michael Walle <michael@walle.cc>
+[robh: move index < 0 check into __of_parse_phandle_with_args]
+Signed-off-by: Rob Herring <robh@kernel.org>
+Link: https://lore.kernel.org/r/20220118173504.2867523-2-michael@walle.cc
+---
+ drivers/of/base.c | 131 +++------------------------------------
+ include/linux/of.h | 148 ++++++++++++++++++++++++++++++++++++---------
+ 2 files changed, 129 insertions(+), 150 deletions(-)
+
+--- a/drivers/of/base.c
++++ b/drivers/of/base.c
+@@ -1371,15 +1371,18 @@ int of_phandle_iterator_args(struct of_p
+ return count;
+ }
+
+-static int __of_parse_phandle_with_args(const struct device_node *np,
+- const char *list_name,
+- const char *cells_name,
+- int cell_count, int index,
+- struct of_phandle_args *out_args)
++int __of_parse_phandle_with_args(const struct device_node *np,
++ const char *list_name,
++ const char *cells_name,
++ int cell_count, int index,
++ struct of_phandle_args *out_args)
+ {
+ struct of_phandle_iterator it;
+ int rc, cur_index = 0;
+
++ if (index < 0)
++ return -EINVAL;
++
+ /* Loop over the phandles until all the requested entry is found */
+ of_for_each_phandle(&it, rc, np, list_name, cells_name, cell_count) {
+ /*
+@@ -1422,82 +1425,7 @@ static int __of_parse_phandle_with_args(
+ of_node_put(it.node);
+ return rc;
+ }
+-
+-/**
+- * of_parse_phandle - Resolve a phandle property to a device_node pointer
+- * @np: Pointer to device node holding phandle property
+- * @phandle_name: Name of property holding a phandle value
+- * @index: For properties holding a table of phandles, this is the index into
+- * the table
+- *
+- * Return: The device_node pointer with refcount incremented. Use
+- * of_node_put() on it when done.
+- */
+-struct device_node *of_parse_phandle(const struct device_node *np,
+- const char *phandle_name, int index)
+-{
+- struct of_phandle_args args;
+-
+- if (index < 0)
+- return NULL;
+-
+- if (__of_parse_phandle_with_args(np, phandle_name, NULL, 0,
+- index, &args))
+- return NULL;
+-
+- return args.np;
+-}
+-EXPORT_SYMBOL(of_parse_phandle);
+-
+-/**
+- * of_parse_phandle_with_args() - Find a node pointed by phandle in a list
+- * @np: pointer to a device tree node containing a list
+- * @list_name: property name that contains a list
+- * @cells_name: property name that specifies phandles' arguments count
+- * @index: index of a phandle to parse out
+- * @out_args: optional pointer to output arguments structure (will be filled)
+- *
+- * This function is useful to parse lists of phandles and their arguments.
+- * Returns 0 on success and fills out_args, on error returns appropriate
+- * errno value.
+- *
+- * Caller is responsible to call of_node_put() on the returned out_args->np
+- * pointer.
+- *
+- * Example::
+- *
+- * phandle1: node1 {
+- * #list-cells = <2>;
+- * };
+- *
+- * phandle2: node2 {
+- * #list-cells = <1>;
+- * };
+- *
+- * node3 {
+- * list = <&phandle1 1 2 &phandle2 3>;
+- * };
+- *
+- * To get a device_node of the ``node2`` node you may call this:
+- * of_parse_phandle_with_args(node3, "list", "#list-cells", 1, &args);
+- */
+-int of_parse_phandle_with_args(const struct device_node *np, const char *list_name,
+- const char *cells_name, int index,
+- struct of_phandle_args *out_args)
+-{
+- int cell_count = -1;
+-
+- if (index < 0)
+- return -EINVAL;
+-
+- /* If cells_name is NULL we assume a cell count of 0 */
+- if (!cells_name)
+- cell_count = 0;
+-
+- return __of_parse_phandle_with_args(np, list_name, cells_name,
+- cell_count, index, out_args);
+-}
+-EXPORT_SYMBOL(of_parse_phandle_with_args);
++EXPORT_SYMBOL(__of_parse_phandle_with_args);
+
+ /**
+ * of_parse_phandle_with_args_map() - Find a node pointed by phandle in a list and remap it
+@@ -1684,47 +1612,6 @@ free:
+ EXPORT_SYMBOL(of_parse_phandle_with_args_map);
+
+ /**
+- * of_parse_phandle_with_fixed_args() - Find a node pointed by phandle in a list
+- * @np: pointer to a device tree node containing a list
+- * @list_name: property name that contains a list
+- * @cell_count: number of argument cells following the phandle
+- * @index: index of a phandle to parse out
+- * @out_args: optional pointer to output arguments structure (will be filled)
+- *
+- * This function is useful to parse lists of phandles and their arguments.
+- * Returns 0 on success and fills out_args, on error returns appropriate
+- * errno value.
+- *
+- * Caller is responsible to call of_node_put() on the returned out_args->np
+- * pointer.
+- *
+- * Example::
+- *
+- * phandle1: node1 {
+- * };
+- *
+- * phandle2: node2 {
+- * };
+- *
+- * node3 {
+- * list = <&phandle1 0 2 &phandle2 2 3>;
+- * };
+- *
+- * To get a device_node of the ``node2`` node you may call this:
+- * of_parse_phandle_with_fixed_args(node3, "list", 2, 1, &args);
+- */
+-int of_parse_phandle_with_fixed_args(const struct device_node *np,
+- const char *list_name, int cell_count,
+- int index, struct of_phandle_args *out_args)
+-{
+- if (index < 0)
+- return -EINVAL;
+- return __of_parse_phandle_with_args(np, list_name, NULL, cell_count,
+- index, out_args);
+-}
+-EXPORT_SYMBOL(of_parse_phandle_with_fixed_args);
+-
+-/**
+ * of_count_phandle_with_args() - Find the number of phandles references in a property
+ * @np: pointer to a device tree node containing a list
+ * @list_name: property name that contains a list
+--- a/include/linux/of.h
++++ b/include/linux/of.h
+@@ -363,18 +363,12 @@ extern const struct of_device_id *of_mat
+ const struct of_device_id *matches, const struct device_node *node);
+ extern int of_modalias_node(struct device_node *node, char *modalias, int len);
+ extern void of_print_phandle_args(const char *msg, const struct of_phandle_args *args);
+-extern struct device_node *of_parse_phandle(const struct device_node *np,
+- const char *phandle_name,
+- int index);
+-extern int of_parse_phandle_with_args(const struct device_node *np,
+- const char *list_name, const char *cells_name, int index,
+- struct of_phandle_args *out_args);
++extern int __of_parse_phandle_with_args(const struct device_node *np,
++ const char *list_name, const char *cells_name, int cell_count,
++ int index, struct of_phandle_args *out_args);
+ extern int of_parse_phandle_with_args_map(const struct device_node *np,
+ const char *list_name, const char *stem_name, int index,
+ struct of_phandle_args *out_args);
+-extern int of_parse_phandle_with_fixed_args(const struct device_node *np,
+- const char *list_name, int cells_count, int index,
+- struct of_phandle_args *out_args);
+ extern int of_count_phandle_with_args(const struct device_node *np,
+ const char *list_name, const char *cells_name);
+
+@@ -864,18 +858,12 @@ static inline int of_property_read_strin
+ return -ENOSYS;
+ }
+
+-static inline struct device_node *of_parse_phandle(const struct device_node *np,
+- const char *phandle_name,
+- int index)
+-{
+- return NULL;
+-}
+-
+-static inline int of_parse_phandle_with_args(const struct device_node *np,
+- const char *list_name,
+- const char *cells_name,
+- int index,
+- struct of_phandle_args *out_args)
++static inline int __of_parse_phandle_with_args(const struct device_node *np,
++ const char *list_name,
++ const char *cells_name,
++ int cell_count,
++ int index,
++ struct of_phandle_args *out_args)
+ {
+ return -ENOSYS;
+ }
+@@ -889,13 +877,6 @@ static inline int of_parse_phandle_with_
+ return -ENOSYS;
+ }
+
+-static inline int of_parse_phandle_with_fixed_args(const struct device_node *np,
+- const char *list_name, int cells_count, int index,
+- struct of_phandle_args *out_args)
+-{
+- return -ENOSYS;
+-}
+-
+ static inline int of_count_phandle_with_args(const struct device_node *np,
+ const char *list_name,
+ const char *cells_name)
+@@ -1077,6 +1058,117 @@ static inline bool of_node_is_type(const
+ }
+
+ /**
++ * of_parse_phandle - Resolve a phandle property to a device_node pointer
++ * @np: Pointer to device node holding phandle property
++ * @phandle_name: Name of property holding a phandle value
++ * @index: For properties holding a table of phandles, this is the index into
++ * the table
++ *
++ * Return: The device_node pointer with refcount incremented. Use
++ * of_node_put() on it when done.
++ */
++static inline struct device_node *of_parse_phandle(const struct device_node *np,
++ const char *phandle_name,
++ int index)
++{
++ struct of_phandle_args args;
++
++ if (__of_parse_phandle_with_args(np, phandle_name, NULL, 0,
++ index, &args))
++ return NULL;
++
++ return args.np;
++}
++
++/**
++ * of_parse_phandle_with_args() - Find a node pointed by phandle in a list
++ * @np: pointer to a device tree node containing a list
++ * @list_name: property name that contains a list
++ * @cells_name: property name that specifies phandles' arguments count
++ * @index: index of a phandle to parse out
++ * @out_args: optional pointer to output arguments structure (will be filled)
++ *
++ * This function is useful to parse lists of phandles and their arguments.
++ * Returns 0 on success and fills out_args, on error returns appropriate
++ * errno value.
++ *
++ * Caller is responsible to call of_node_put() on the returned out_args->np
++ * pointer.
++ *
++ * Example::
++ *
++ * phandle1: node1 {
++ * #list-cells = <2>;
++ * };
++ *
++ * phandle2: node2 {
++ * #list-cells = <1>;
++ * };
++ *
++ * node3 {
++ * list = <&phandle1 1 2 &phandle2 3>;
++ * };
++ *
++ * To get a device_node of the ``node2`` node you may call this:
++ * of_parse_phandle_with_args(node3, "list", "#list-cells", 1, &args);
++ */
++static inline int of_parse_phandle_with_args(const struct device_node *np,
++ const char *list_name,
++ const char *cells_name,
++ int index,
++ struct of_phandle_args *out_args)
++{
++ int cell_count = -1;
++
++ /* If cells_name is NULL we assume a cell count of 0 */
++ if (!cells_name)
++ cell_count = 0;
++
++ return __of_parse_phandle_with_args(np, list_name, cells_name,
++ cell_count, index, out_args);
++}
++
++/**
++ * of_parse_phandle_with_fixed_args() - Find a node pointed by phandle in a list
++ * @np: pointer to a device tree node containing a list
++ * @list_name: property name that contains a list
++ * @cell_count: number of argument cells following the phandle
++ * @index: index of a phandle to parse out
++ * @out_args: optional pointer to output arguments structure (will be filled)
++ *
++ * This function is useful to parse lists of phandles and their arguments.
++ * Returns 0 on success and fills out_args, on error returns appropriate
++ * errno value.
++ *
++ * Caller is responsible to call of_node_put() on the returned out_args->np
++ * pointer.
++ *
++ * Example::
++ *
++ * phandle1: node1 {
++ * };
++ *
++ * phandle2: node2 {
++ * };
++ *
++ * node3 {
++ * list = <&phandle1 0 2 &phandle2 2 3>;
++ * };
++ *
++ * To get a device_node of the ``node2`` node you may call this:
++ * of_parse_phandle_with_fixed_args(node3, "list", 2, 1, &args);
++ */
++static inline int of_parse_phandle_with_fixed_args(const struct device_node *np,
++ const char *list_name,
++ int cell_count,
++ int index,
++ struct of_phandle_args *out_args)
++{
++ return __of_parse_phandle_with_args(np, list_name, NULL, cell_count,
++ index, out_args);
++}
++
++/**
+ * of_property_count_u8_elems - Count the number of u8 elements in a property
+ *
+ * @np: device node from which the property value is to be read.
diff --git a/target/linux/generic/backport-5.15/827-v6.3-0001-of-base-add-of_parse_phandle_with_optional_args.patch b/target/linux/generic/backport-5.15/827-v6.3-0001-of-base-add-of_parse_phandle_with_optional_args.patch
new file mode 100644
index 0000000000..b829f21cfa
--- /dev/null
+++ b/target/linux/generic/backport-5.15/827-v6.3-0001-of-base-add-of_parse_phandle_with_optional_args.patch
@@ -0,0 +1,56 @@
+From 8eddceb280f5deb8046fcb660de9f9f683b408b9 Mon Sep 17 00:00:00 2001
+From: Michael Walle <michael@walle.cc>
+Date: Tue, 6 Dec 2022 21:07:21 +0100
+Subject: [PATCH] of: base: add of_parse_phandle_with_optional_args()
+
+Add a new variant of the of_parse_phandle_with_args() which treats the
+cells name as optional. If it's missing, it is assumed that the phandle
+has no arguments.
+
+Up until now, a nvmem node didn't have any arguments, so all the device
+trees haven't any '#*-cells' property. But there is a need for an
+additional argument for the phandle, for which we need a '#*-cells'
+property. Therefore, we need to support nvmem nodes with and without
+this property.
+
+Signed-off-by: Michael Walle <michael@walle.cc>
+Reviewed-by: Rob Herring <robh@kernel.org>
+Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
+---
+ include/linux/of.h | 25 +++++++++++++++++++++++++
+ 1 file changed, 25 insertions(+)
+
+--- a/include/linux/of.h
++++ b/include/linux/of.h
+@@ -1169,6 +1169,31 @@ static inline int of_parse_phandle_with_
+ }
+
+ /**
++ * of_parse_phandle_with_optional_args() - Find a node pointed by phandle in a list
++ * @np: pointer to a device tree node containing a list
++ * @list_name: property name that contains a list
++ * @cells_name: property name that specifies phandles' arguments count
++ * @index: index of a phandle to parse out
++ * @out_args: optional pointer to output arguments structure (will be filled)
++ *
++ * Same as of_parse_phandle_with_args() except that if the cells_name property
++ * is not found, cell_count of 0 is assumed.
++ *
++ * This is used to useful, if you have a phandle which didn't have arguments
++ * before and thus doesn't have a '#*-cells' property but is now migrated to
++ * having arguments while retaining backwards compatibility.
++ */
++static inline int of_parse_phandle_with_optional_args(const struct device_node *np,
++ const char *list_name,
++ const char *cells_name,
++ int index,
++ struct of_phandle_args *out_args)
++{
++ return __of_parse_phandle_with_args(np, list_name, cells_name,
++ 0, index, out_args);
++}
++
++/**
+ * of_property_count_u8_elems - Count the number of u8 elements in a property
+ *
+ * @np: device node from which the property value is to be read.
diff --git a/target/linux/generic/backport-5.15/827-v6.3-0002-of-property-make-.-cells-optional-for-simple-props.patch b/target/linux/generic/backport-5.15/827-v6.3-0002-of-property-make-.-cells-optional-for-simple-props.patch
new file mode 100644
index 0000000000..4cf11ca34b
--- /dev/null
+++ b/target/linux/generic/backport-5.15/827-v6.3-0002-of-property-make-.-cells-optional-for-simple-props.patch
@@ -0,0 +1,32 @@
+From 4f4145c9fee8c7a445dbbbadceccce5391e6b287 Mon Sep 17 00:00:00 2001
+From: Michael Walle <michael@walle.cc>
+Date: Tue, 6 Dec 2022 21:07:22 +0100
+Subject: [PATCH] of: property: make #.*-cells optional for simple props
+
+Sometimes, future bindings for phandles will get additional arguments.
+Thus the target node of the phandle will need a new #.*-cells property.
+To be backwards compatible, this needs to be optional.
+
+Prepare the DEFINE_SIMPLE_PROPS() to handle the cells name as optional.
+
+Signed-off-by: Michael Walle <michael@walle.cc>
+Tested-by: Miquel Raynal <miquel.raynal@bootlin.com>
+Reviewed-by: Rob Herring <robh@kernel.org>
+Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
+---
+ drivers/of/property.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/of/property.c
++++ b/drivers/of/property.c
+@@ -1227,8 +1227,8 @@ static struct device_node *parse_suffix_
+ if (strcmp_suffix(prop_name, suffix))
+ return NULL;
+
+- if (of_parse_phandle_with_args(np, prop_name, cells_name, index,
+- &sup_args))
++ if (__of_parse_phandle_with_args(np, prop_name, cells_name, 0, index,
++ &sup_args))
+ return NULL;
+
+ return sup_args.np;
diff --git a/target/linux/generic/backport-5.15/827-v6.3-0003-of-property-add-nvmem-cell-cells-property.patch b/target/linux/generic/backport-5.15/827-v6.3-0003-of-property-add-nvmem-cell-cells-property.patch
new file mode 100644
index 0000000000..8c047e685d
--- /dev/null
+++ b/target/linux/generic/backport-5.15/827-v6.3-0003-of-property-add-nvmem-cell-cells-property.patch
@@ -0,0 +1,28 @@
+From 9cf9486a6a7e8a3d76154d0c506051ba3740e8b6 Mon Sep 17 00:00:00 2001
+From: Michael Walle <michael@walle.cc>
+Date: Tue, 6 Dec 2022 21:07:23 +0100
+Subject: [PATCH] of: property: add #nvmem-cell-cells property
+
+Bindings describe the new '#nvmem-cell-cells' property. Now that the
+arguments count property is optional, we just add this property to the
+nvmem-cells.
+
+Signed-off-by: Michael Walle <michael@walle.cc>
+Tested-by: Miquel Raynal <miquel.raynal@bootlin.com>
+Reviewed-by: Rob Herring <robh@kernel.org>
+Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
+---
+ drivers/of/property.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/of/property.c
++++ b/drivers/of/property.c
+@@ -1276,7 +1276,7 @@ DEFINE_SIMPLE_PROP(dmas, "dmas", "#dma-c
+ DEFINE_SIMPLE_PROP(power_domains, "power-domains", "#power-domain-cells")
+ DEFINE_SIMPLE_PROP(hwlocks, "hwlocks", "#hwlock-cells")
+ DEFINE_SIMPLE_PROP(extcon, "extcon", NULL)
+-DEFINE_SIMPLE_PROP(nvmem_cells, "nvmem-cells", NULL)
++DEFINE_SIMPLE_PROP(nvmem_cells, "nvmem-cells", "#nvmem-cell-cells")
+ DEFINE_SIMPLE_PROP(phys, "phys", "#phy-cells")
+ DEFINE_SIMPLE_PROP(wakeup_parent, "wakeup-parent", NULL)
+ DEFINE_SIMPLE_PROP(pinctrl0, "pinctrl-0", NULL)