hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/linux/clk.h
....@@ -1,13 +1,10 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * linux/include/linux/clk.h
34 *
45 * Copyright (C) 2004 ARM Limited.
56 * Written by Deep Blue Solutions Limited.
67 * Copyright (C) 2011-2012 Linaro Ltd <mturquette@linaro.org>
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License version 2 as
10
- * published by the Free Software Foundation.
118 */
129 #ifndef __LINUX_CLK_H
1310 #define __LINUX_CLK_H
....@@ -113,6 +110,17 @@
113110 int clk_notifier_unregister(struct clk *clk, struct notifier_block *nb);
114111
115112 /**
113
+ * devm_clk_notifier_register - register a managed rate-change notifier callback
114
+ * @dev: device for clock "consumer"
115
+ * @clk: clock whose rate we are interested in
116
+ * @nb: notifier block with callback function pointer
117
+ *
118
+ * Returns 0 on success, -EERROR otherwise
119
+ */
120
+int devm_clk_notifier_register(struct device *dev, struct clk *clk,
121
+ struct notifier_block *nb);
122
+
123
+/**
116124 * clk_get_accuracy - obtain the clock accuracy in ppb (parts per billion)
117125 * for a clock source.
118126 * @clk: clock source
....@@ -189,6 +197,13 @@
189197 return -ENOTSUPP;
190198 }
191199
200
+static inline int devm_clk_notifier_register(struct device *dev,
201
+ struct clk *clk,
202
+ struct notifier_block *nb)
203
+{
204
+ return -ENOTSUPP;
205
+}
206
+
192207 static inline long clk_get_accuracy(struct clk *clk)
193208 {
194209 return -ENOTSUPP;
....@@ -242,7 +257,8 @@
242257 return 0;
243258 }
244259
245
-static inline int __must_check clk_bulk_prepare(int num_clks, struct clk_bulk_data *clks)
260
+static inline int __must_check
261
+clk_bulk_prepare(int num_clks, const struct clk_bulk_data *clks)
246262 {
247263 might_sleep();
248264 return 0;
....@@ -266,7 +282,8 @@
266282 {
267283 might_sleep();
268284 }
269
-static inline void clk_bulk_unprepare(int num_clks, struct clk_bulk_data *clks)
285
+static inline void clk_bulk_unprepare(int num_clks,
286
+ const struct clk_bulk_data *clks)
270287 {
271288 might_sleep();
272289 }
....@@ -362,6 +379,7 @@
362379 /**
363380 * devm_clk_bulk_get_optional - managed get multiple optional consumer clocks
364381 * @dev: device for clock "consumer"
382
+ * @num_clks: the number of clk_bulk_data
365383 * @clks: pointer to the clk_bulk_data table of consumer
366384 *
367385 * Behaves the same as devm_clk_bulk_get() except where there is no clock
....@@ -627,6 +645,9 @@
627645 * @clk: clock source
628646 * @rate: desired clock rate in Hz
629647 *
648
+ * Updating the rate starts at the top-most affected clock and then
649
+ * walks the tree down to the bottom-most clock that needs updating.
650
+ *
630651 * Returns success (0) or negative errno.
631652 */
632653 int clk_set_rate(struct clk *clk, unsigned long rate);
....@@ -723,6 +744,23 @@
723744 */
724745 struct clk *clk_get_sys(const char *dev_id, const char *con_id);
725746
747
+/**
748
+ * clk_save_context - save clock context for poweroff
749
+ *
750
+ * Saves the context of the clock register for powerstates in which the
751
+ * contents of the registers will be lost. Occurs deep within the suspend
752
+ * code so locking is not necessary.
753
+ */
754
+int clk_save_context(void);
755
+
756
+/**
757
+ * clk_restore_context - restore clock context after poweroff
758
+ *
759
+ * This occurs with all clocks enabled. Occurs deep within the resume code
760
+ * so locking is not necessary.
761
+ */
762
+void clk_restore_context(void);
763
+
726764 #else /* !CONFIG_HAVE_CLK */
727765
728766 static inline struct clk *clk_get(struct device *dev, const char *id)
....@@ -805,7 +843,8 @@
805843 return 0;
806844 }
807845
808
-static inline int __must_check clk_bulk_enable(int num_clks, struct clk_bulk_data *clks)
846
+static inline int __must_check clk_bulk_enable(int num_clks,
847
+ const struct clk_bulk_data *clks)
809848 {
810849 return 0;
811850 }
....@@ -814,7 +853,7 @@
814853
815854
816855 static inline void clk_bulk_disable(int num_clks,
817
- struct clk_bulk_data *clks) {}
856
+ const struct clk_bulk_data *clks) {}
818857
819858 static inline unsigned long clk_get_rate(struct clk *clk)
820859 {
....@@ -841,6 +880,22 @@
841880 return true;
842881 }
843882
883
+static inline int clk_set_rate_range(struct clk *clk, unsigned long min,
884
+ unsigned long max)
885
+{
886
+ return 0;
887
+}
888
+
889
+static inline int clk_set_min_rate(struct clk *clk, unsigned long rate)
890
+{
891
+ return 0;
892
+}
893
+
894
+static inline int clk_set_max_rate(struct clk *clk, unsigned long rate)
895
+{
896
+ return 0;
897
+}
898
+
844899 static inline int clk_set_parent(struct clk *clk, struct clk *parent)
845900 {
846901 return 0;
....@@ -855,6 +910,14 @@
855910 {
856911 return NULL;
857912 }
913
+
914
+static inline int clk_save_context(void)
915
+{
916
+ return 0;
917
+}
918
+
919
+static inline void clk_restore_context(void) {}
920
+
858921 #endif
859922
860923 /* clk_prepare_enable helps cases using clk_enable in non-atomic context. */
....@@ -879,8 +942,8 @@
879942 clk_unprepare(clk);
880943 }
881944
882
-static inline int __must_check clk_bulk_prepare_enable(int num_clks,
883
- struct clk_bulk_data *clks)
945
+static inline int __must_check
946
+clk_bulk_prepare_enable(int num_clks, const struct clk_bulk_data *clks)
884947 {
885948 int ret;
886949
....@@ -895,7 +958,7 @@
895958 }
896959
897960 static inline void clk_bulk_disable_unprepare(int num_clks,
898
- struct clk_bulk_data *clks)
961
+ const struct clk_bulk_data *clks)
899962 {
900963 clk_bulk_disable(num_clks, clks);
901964 clk_bulk_unprepare(num_clks, clks);