hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/include/linux/reset.h
....@@ -2,6 +2,8 @@
22 #ifndef _LINUX_RESET_H_
33 #define _LINUX_RESET_H_
44
5
+#include <linux/err.h>
6
+#include <linux/errno.h>
57 #include <linux/types.h>
68
79 struct device;
....@@ -14,23 +16,28 @@
1416 int reset_control_assert(struct reset_control *rstc);
1517 int reset_control_deassert(struct reset_control *rstc);
1618 int reset_control_status(struct reset_control *rstc);
19
+int reset_control_acquire(struct reset_control *rstc);
20
+void reset_control_release(struct reset_control *rstc);
1721
1822 struct reset_control *__of_reset_control_get(struct device_node *node,
1923 const char *id, int index, bool shared,
20
- bool optional);
24
+ bool optional, bool acquired);
2125 struct reset_control *__reset_control_get(struct device *dev, const char *id,
2226 int index, bool shared,
23
- bool optional);
27
+ bool optional, bool acquired);
2428 void reset_control_put(struct reset_control *rstc);
2529 int __device_reset(struct device *dev, bool optional);
2630 struct reset_control *__devm_reset_control_get(struct device *dev,
2731 const char *id, int index, bool shared,
28
- bool optional);
32
+ bool optional, bool acquired);
2933
3034 struct reset_control *devm_reset_control_array_get(struct device *dev,
3135 bool shared, bool optional);
3236 struct reset_control *of_reset_control_array_get(struct device_node *np,
33
- bool shared, bool optional);
37
+ bool shared, bool optional,
38
+ bool acquired);
39
+
40
+int reset_control_get_count(struct device *dev);
3441
3542 #else
3643
....@@ -54,6 +61,15 @@
5461 return 0;
5562 }
5663
64
+static inline int reset_control_acquire(struct reset_control *rstc)
65
+{
66
+ return 0;
67
+}
68
+
69
+static inline void reset_control_release(struct reset_control *rstc)
70
+{
71
+}
72
+
5773 static inline void reset_control_put(struct reset_control *rstc)
5874 {
5975 }
....@@ -66,21 +82,23 @@
6682 static inline struct reset_control *__of_reset_control_get(
6783 struct device_node *node,
6884 const char *id, int index, bool shared,
69
- bool optional)
85
+ bool optional, bool acquired)
7086 {
7187 return optional ? NULL : ERR_PTR(-ENOTSUPP);
7288 }
7389
7490 static inline struct reset_control *__reset_control_get(
7591 struct device *dev, const char *id,
76
- int index, bool shared, bool optional)
92
+ int index, bool shared, bool optional,
93
+ bool acquired)
7794 {
7895 return optional ? NULL : ERR_PTR(-ENOTSUPP);
7996 }
8097
8198 static inline struct reset_control *__devm_reset_control_get(
8299 struct device *dev, const char *id,
83
- int index, bool shared, bool optional)
100
+ int index, bool shared, bool optional,
101
+ bool acquired)
84102 {
85103 return optional ? NULL : ERR_PTR(-ENOTSUPP);
86104 }
....@@ -92,9 +110,15 @@
92110 }
93111
94112 static inline struct reset_control *
95
-of_reset_control_array_get(struct device_node *np, bool shared, bool optional)
113
+of_reset_control_array_get(struct device_node *np, bool shared, bool optional,
114
+ bool acquired)
96115 {
97116 return optional ? NULL : ERR_PTR(-ENOTSUPP);
117
+}
118
+
119
+static inline int reset_control_get_count(struct device *dev)
120
+{
121
+ return -ENOENT;
98122 }
99123
100124 #endif /* CONFIG_RESET_CONTROLLER */
....@@ -116,10 +140,10 @@
116140 * @id: reset line name
117141 *
118142 * Returns a struct reset_control or IS_ERR() condition containing errno.
119
- * If this function is called more then once for the same reset_control it will
143
+ * If this function is called more than once for the same reset_control it will
120144 * return -EBUSY.
121145 *
122
- * See reset_control_get_shared for details on shared references to
146
+ * See reset_control_get_shared() for details on shared references to
123147 * reset-controls.
124148 *
125149 * Use of id names is optional.
....@@ -127,7 +151,28 @@
127151 static inline struct reset_control *
128152 __must_check reset_control_get_exclusive(struct device *dev, const char *id)
129153 {
130
- return __reset_control_get(dev, id, 0, false, false);
154
+ return __reset_control_get(dev, id, 0, false, false, true);
155
+}
156
+
157
+/**
158
+ * reset_control_get_exclusive_released - Lookup and obtain a temoprarily
159
+ * exclusive reference to a reset
160
+ * controller.
161
+ * @dev: device to be reset by the controller
162
+ * @id: reset line name
163
+ *
164
+ * Returns a struct reset_control or IS_ERR() condition containing errno.
165
+ * reset-controls returned by this function must be acquired via
166
+ * reset_control_acquire() before they can be used and should be released
167
+ * via reset_control_release() afterwards.
168
+ *
169
+ * Use of id names is optional.
170
+ */
171
+static inline struct reset_control *
172
+__must_check reset_control_get_exclusive_released(struct device *dev,
173
+ const char *id)
174
+{
175
+ return __reset_control_get(dev, id, 0, false, false, false);
131176 }
132177
133178 /**
....@@ -138,7 +183,7 @@
138183 *
139184 * Returns a struct reset_control or IS_ERR() condition containing errno.
140185 * This function is intended for use with reset-controls which are shared
141
- * between hardware-blocks.
186
+ * between hardware blocks.
142187 *
143188 * When a reset-control is shared, the behavior of reset_control_assert /
144189 * deassert is changed, the reset-core will keep track of a deassert_count
....@@ -155,19 +200,41 @@
155200 static inline struct reset_control *reset_control_get_shared(
156201 struct device *dev, const char *id)
157202 {
158
- return __reset_control_get(dev, id, 0, true, false);
203
+ return __reset_control_get(dev, id, 0, true, false, false);
159204 }
160205
206
+/**
207
+ * reset_control_get_optional_exclusive - optional reset_control_get_exclusive()
208
+ * @dev: device to be reset by the controller
209
+ * @id: reset line name
210
+ *
211
+ * Optional variant of reset_control_get_exclusive(). If the requested reset
212
+ * is not specified in the device tree, this function returns NULL instead of
213
+ * an error.
214
+ *
215
+ * See reset_control_get_exclusive() for more information.
216
+ */
161217 static inline struct reset_control *reset_control_get_optional_exclusive(
162218 struct device *dev, const char *id)
163219 {
164
- return __reset_control_get(dev, id, 0, false, true);
220
+ return __reset_control_get(dev, id, 0, false, true, true);
165221 }
166222
223
+/**
224
+ * reset_control_get_optional_shared - optional reset_control_get_shared()
225
+ * @dev: device to be reset by the controller
226
+ * @id: reset line name
227
+ *
228
+ * Optional variant of reset_control_get_shared(). If the requested reset
229
+ * is not specified in the device tree, this function returns NULL instead of
230
+ * an error.
231
+ *
232
+ * See reset_control_get_shared() for more information.
233
+ */
167234 static inline struct reset_control *reset_control_get_optional_shared(
168235 struct device *dev, const char *id)
169236 {
170
- return __reset_control_get(dev, id, 0, true, true);
237
+ return __reset_control_get(dev, id, 0, true, true, false);
171238 }
172239
173240 /**
....@@ -183,11 +250,11 @@
183250 static inline struct reset_control *of_reset_control_get_exclusive(
184251 struct device_node *node, const char *id)
185252 {
186
- return __of_reset_control_get(node, id, 0, false, false);
253
+ return __of_reset_control_get(node, id, 0, false, false, true);
187254 }
188255
189256 /**
190
- * of_reset_control_get_shared - Lookup and obtain an shared reference
257
+ * of_reset_control_get_shared - Lookup and obtain a shared reference
191258 * to a reset controller.
192259 * @node: device to be reset by the controller
193260 * @id: reset line name
....@@ -208,7 +275,7 @@
208275 static inline struct reset_control *of_reset_control_get_shared(
209276 struct device_node *node, const char *id)
210277 {
211
- return __of_reset_control_get(node, id, 0, true, false);
278
+ return __of_reset_control_get(node, id, 0, true, false, false);
212279 }
213280
214281 /**
....@@ -225,11 +292,11 @@
225292 static inline struct reset_control *of_reset_control_get_exclusive_by_index(
226293 struct device_node *node, int index)
227294 {
228
- return __of_reset_control_get(node, NULL, index, false, false);
295
+ return __of_reset_control_get(node, NULL, index, false, false, true);
229296 }
230297
231298 /**
232
- * of_reset_control_get_shared_by_index - Lookup and obtain an shared
299
+ * of_reset_control_get_shared_by_index - Lookup and obtain a shared
233300 * reference to a reset controller
234301 * by index.
235302 * @node: device to be reset by the controller
....@@ -253,7 +320,7 @@
253320 static inline struct reset_control *of_reset_control_get_shared_by_index(
254321 struct device_node *node, int index)
255322 {
256
- return __of_reset_control_get(node, NULL, index, true, false);
323
+ return __of_reset_control_get(node, NULL, index, true, false, false);
257324 }
258325
259326 /**
....@@ -272,7 +339,26 @@
272339 __must_check devm_reset_control_get_exclusive(struct device *dev,
273340 const char *id)
274341 {
275
- return __devm_reset_control_get(dev, id, 0, false, false);
342
+ return __devm_reset_control_get(dev, id, 0, false, false, true);
343
+}
344
+
345
+/**
346
+ * devm_reset_control_get_exclusive_released - resource managed
347
+ * reset_control_get_exclusive_released()
348
+ * @dev: device to be reset by the controller
349
+ * @id: reset line name
350
+ *
351
+ * Managed reset_control_get_exclusive_released(). For reset controllers
352
+ * returned from this function, reset_control_put() is called automatically on
353
+ * driver detach.
354
+ *
355
+ * See reset_control_get_exclusive_released() for more information.
356
+ */
357
+static inline struct reset_control *
358
+__must_check devm_reset_control_get_exclusive_released(struct device *dev,
359
+ const char *id)
360
+{
361
+ return __devm_reset_control_get(dev, id, 0, false, false, false);
276362 }
277363
278364 /**
....@@ -287,19 +373,43 @@
287373 static inline struct reset_control *devm_reset_control_get_shared(
288374 struct device *dev, const char *id)
289375 {
290
- return __devm_reset_control_get(dev, id, 0, true, false);
376
+ return __devm_reset_control_get(dev, id, 0, true, false, false);
291377 }
292378
379
+/**
380
+ * devm_reset_control_get_optional_exclusive - resource managed
381
+ * reset_control_get_optional_exclusive()
382
+ * @dev: device to be reset by the controller
383
+ * @id: reset line name
384
+ *
385
+ * Managed reset_control_get_optional_exclusive(). For reset controllers
386
+ * returned from this function, reset_control_put() is called automatically on
387
+ * driver detach.
388
+ *
389
+ * See reset_control_get_optional_exclusive() for more information.
390
+ */
293391 static inline struct reset_control *devm_reset_control_get_optional_exclusive(
294392 struct device *dev, const char *id)
295393 {
296
- return __devm_reset_control_get(dev, id, 0, false, true);
394
+ return __devm_reset_control_get(dev, id, 0, false, true, true);
297395 }
298396
397
+/**
398
+ * devm_reset_control_get_optional_shared - resource managed
399
+ * reset_control_get_optional_shared()
400
+ * @dev: device to be reset by the controller
401
+ * @id: reset line name
402
+ *
403
+ * Managed reset_control_get_optional_shared(). For reset controllers returned
404
+ * from this function, reset_control_put() is called automatically on driver
405
+ * detach.
406
+ *
407
+ * See reset_control_get_optional_shared() for more information.
408
+ */
299409 static inline struct reset_control *devm_reset_control_get_optional_shared(
300410 struct device *dev, const char *id)
301411 {
302
- return __devm_reset_control_get(dev, id, 0, true, true);
412
+ return __devm_reset_control_get(dev, id, 0, true, true, false);
303413 }
304414
305415 /**
....@@ -317,12 +427,12 @@
317427 static inline struct reset_control *
318428 devm_reset_control_get_exclusive_by_index(struct device *dev, int index)
319429 {
320
- return __devm_reset_control_get(dev, NULL, index, false, false);
430
+ return __devm_reset_control_get(dev, NULL, index, false, false, true);
321431 }
322432
323433 /**
324434 * devm_reset_control_get_shared_by_index - resource managed
325
- * reset_control_get_shared
435
+ * reset_control_get_shared
326436 * @dev: device to be reset by the controller
327437 * @index: index of the reset controller
328438 *
....@@ -333,7 +443,7 @@
333443 static inline struct reset_control *
334444 devm_reset_control_get_shared_by_index(struct device *dev, int index)
335445 {
336
- return __devm_reset_control_get(dev, NULL, index, true, false);
446
+ return __devm_reset_control_get(dev, NULL, index, true, false, false);
337447 }
338448
339449 /*
....@@ -405,24 +515,30 @@
405515 static inline struct reset_control *
406516 of_reset_control_array_get_exclusive(struct device_node *node)
407517 {
408
- return of_reset_control_array_get(node, false, false);
518
+ return of_reset_control_array_get(node, false, false, true);
519
+}
520
+
521
+static inline struct reset_control *
522
+of_reset_control_array_get_exclusive_released(struct device_node *node)
523
+{
524
+ return of_reset_control_array_get(node, false, false, false);
409525 }
410526
411527 static inline struct reset_control *
412528 of_reset_control_array_get_shared(struct device_node *node)
413529 {
414
- return of_reset_control_array_get(node, true, false);
530
+ return of_reset_control_array_get(node, true, false, true);
415531 }
416532
417533 static inline struct reset_control *
418534 of_reset_control_array_get_optional_exclusive(struct device_node *node)
419535 {
420
- return of_reset_control_array_get(node, false, true);
536
+ return of_reset_control_array_get(node, false, true, true);
421537 }
422538
423539 static inline struct reset_control *
424540 of_reset_control_array_get_optional_shared(struct device_node *node)
425541 {
426
- return of_reset_control_array_get(node, true, true);
542
+ return of_reset_control_array_get(node, true, true, true);
427543 }
428544 #endif