public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clk: bulk: export of_clk_bulk_get_all
@ 2021-12-21  3:16 Peng Fan (OSS)
  2022-01-06  1:17 ` Stephen Boyd
  0 siblings, 1 reply; 3+ messages in thread
From: Peng Fan (OSS) @ 2021-12-21  3:16 UTC (permalink / raw)
  To: sboyd, bjorn.andersson, s.nawrocki, jbrunet, aisheng.dong,
	ulf.hansson, shawn.lin, linux-clk
  Cc: linux-kernel, van.freenix, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

There are cases that need to get the bulk clks of a device_node which not
has device created, so export of_clk_bulk_get_all to let consumers could
use it.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---

V1:
     An example here, mediamix node has clocks property, but it will not
     have device of it, so we need of_X api to get the clks.
     src: src@0x30390000 {
          compatible = "fsl,imx[X]-src";
          reg = <0x30390000 0x10000>;

          slice {
                #address-cells = <1>;
                #size-cells = <0>;

                mediamix: slice@2400 {
                   reg = <IMX93_POWER_DOMAIN_MEDIAMIX>;
                   #power-domain-cells = <0>;
		   clocks = <&clk IMX_MEDIAMIX_ROOT>, <&clk IMX_MEDIAMIX_AHB>;
          };
      };

 drivers/clk/clk-bulk.c |  5 +++--
 include/linux/clk.h    | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/clk-bulk.c b/drivers/clk/clk-bulk.c
index e9e16425c739..6dd7aac0b84c 100644
--- a/drivers/clk/clk-bulk.c
+++ b/drivers/clk/clk-bulk.c
@@ -43,8 +43,8 @@ static int __must_check of_clk_bulk_get(struct device_node *np, int num_clks,
 	return ret;
 }
 
-static int __must_check of_clk_bulk_get_all(struct device_node *np,
-					    struct clk_bulk_data **clks)
+int __must_check of_clk_bulk_get_all(struct device_node *np,
+				     struct clk_bulk_data **clks)
 {
 	struct clk_bulk_data *clk_bulk;
 	int num_clks;
@@ -68,6 +68,7 @@ static int __must_check of_clk_bulk_get_all(struct device_node *np,
 
 	return num_clks;
 }
+EXPORT_SYMBOL_GPL(of_clk_bulk_get_all);
 
 void clk_bulk_put(int num_clks, struct clk_bulk_data *clks)
 {
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 266e8de3cb51..c49c7918d6ef 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -372,6 +372,18 @@ int __must_check clk_bulk_get(struct device *dev, int num_clks,
 int __must_check clk_bulk_get_all(struct device *dev,
 				  struct clk_bulk_data **clks);
 
+/**
+ * of_clk_bulk_get_all - lookup and obtain all available references to clock
+ *			 producer.
+ * @np: device node for clock "consumer"
+ * @clks: pointer to the clk_bulk_data table of consumer
+ *
+ * Same with clk_bulk_get_all except the first parameter use device node
+ * pointer.
+ */
+int __must_check of_clk_bulk_get_all(struct device_node *np,
+				     struct clk_bulk_data **clks);
+
 /**
  * clk_bulk_get_optional - lookup and obtain a number of references to clock producer
  * @dev: device for clock "consumer"
@@ -808,6 +820,12 @@ static inline int __must_check clk_bulk_get_all(struct device *dev,
 	return 0;
 }
 
+static inline int __must_check of_clk_bulk_get_all(struct device *dev,
+						   struct clk_bulk_data **clks)
+{
+	return 0;
+}
+
 static inline struct clk *devm_clk_get(struct device *dev, const char *id)
 {
 	return NULL;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-06  2:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-21  3:16 [PATCH] clk: bulk: export of_clk_bulk_get_all Peng Fan (OSS)
2022-01-06  1:17 ` Stephen Boyd
2022-01-06  2:19   ` Peng Fan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox