xref: /linux-6.15/include/linux/reset.h (revision dad35f7d)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_RESET_H_
3 #define _LINUX_RESET_H_
4 
5 #include <linux/err.h>
6 #include <linux/errno.h>
7 #include <linux/types.h>
8 
9 struct device;
10 struct device_node;
11 struct reset_control;
12 
13 /**
14  * struct reset_control_bulk_data - Data used for bulk reset control operations.
15  *
16  * @id: reset control consumer ID
17  * @rstc: struct reset_control * to store the associated reset control
18  *
19  * The reset APIs provide a series of reset_control_bulk_*() API calls as
20  * a convenience to consumers which require multiple reset controls.
21  * This structure is used to manage data for these calls.
22  */
23 struct reset_control_bulk_data {
24 	const char			*id;
25 	struct reset_control		*rstc;
26 };
27 
28 #define RESET_CONTROL_FLAGS_BIT_SHARED		BIT(0)	/* not exclusive */
29 #define RESET_CONTROL_FLAGS_BIT_OPTIONAL	BIT(1)
30 #define RESET_CONTROL_FLAGS_BIT_ACQUIRED	BIT(2)	/* iff exclusive, not released */
31 
32 /**
33  * enum reset_control_flags - Flags that can be passed to the reset_control_get functions
34  *                    to determine the type of reset control.
35  *                    These values cannot be OR'd.
36  *
37  * @RESET_CONTROL_EXCLUSIVE:				exclusive, acquired,
38  * @RESET_CONTROL_EXCLUSIVE_RELEASED:			exclusive, released,
39  * @RESET_CONTROL_SHARED:				shared
40  * @RESET_CONTROL_OPTIONAL_EXCLUSIVE:			optional, exclusive, acquired
41  * @RESET_CONTROL_OPTIONAL_EXCLUSIVE_RELEASED:		optional, exclusive, released
42  * @RESET_CONTROL_OPTIONAL_SHARED:			optional, shared
43  */
44 enum reset_control_flags {
45 	RESET_CONTROL_EXCLUSIVE				= RESET_CONTROL_FLAGS_BIT_ACQUIRED,
46 	RESET_CONTROL_EXCLUSIVE_RELEASED		= 0,
47 	RESET_CONTROL_SHARED				= RESET_CONTROL_FLAGS_BIT_SHARED,
48 	RESET_CONTROL_OPTIONAL_EXCLUSIVE		= RESET_CONTROL_FLAGS_BIT_OPTIONAL |
49 							  RESET_CONTROL_FLAGS_BIT_ACQUIRED,
50 	RESET_CONTROL_OPTIONAL_EXCLUSIVE_RELEASED	= RESET_CONTROL_FLAGS_BIT_OPTIONAL,
51 	RESET_CONTROL_OPTIONAL_SHARED			= RESET_CONTROL_FLAGS_BIT_OPTIONAL |
52 							  RESET_CONTROL_FLAGS_BIT_SHARED,
53 };
54 
55 #ifdef CONFIG_RESET_CONTROLLER
56 
57 int reset_control_reset(struct reset_control *rstc);
58 int reset_control_rearm(struct reset_control *rstc);
59 int reset_control_assert(struct reset_control *rstc);
60 int reset_control_deassert(struct reset_control *rstc);
61 int reset_control_status(struct reset_control *rstc);
62 int reset_control_acquire(struct reset_control *rstc);
63 void reset_control_release(struct reset_control *rstc);
64 
65 int reset_control_bulk_reset(int num_rstcs, struct reset_control_bulk_data *rstcs);
66 int reset_control_bulk_assert(int num_rstcs, struct reset_control_bulk_data *rstcs);
67 int reset_control_bulk_deassert(int num_rstcs, struct reset_control_bulk_data *rstcs);
68 int reset_control_bulk_acquire(int num_rstcs, struct reset_control_bulk_data *rstcs);
69 void reset_control_bulk_release(int num_rstcs, struct reset_control_bulk_data *rstcs);
70 
71 struct reset_control *__of_reset_control_get(struct device_node *node,
72 				     const char *id, int index, enum reset_control_flags flags);
73 struct reset_control *__reset_control_get(struct device *dev, const char *id,
74 					  int index, enum reset_control_flags flags);
75 void reset_control_put(struct reset_control *rstc);
76 int __reset_control_bulk_get(struct device *dev, int num_rstcs,
77 			     struct reset_control_bulk_data *rstcs,
78 			     enum reset_control_flags flags);
79 void reset_control_bulk_put(int num_rstcs, struct reset_control_bulk_data *rstcs);
80 
81 int __device_reset(struct device *dev, bool optional);
82 struct reset_control *__devm_reset_control_get(struct device *dev,
83 				     const char *id, int index, enum reset_control_flags flags);
84 int __devm_reset_control_bulk_get(struct device *dev, int num_rstcs,
85 				  struct reset_control_bulk_data *rstcs,
86 				  enum reset_control_flags flags);
87 
88 struct reset_control *devm_reset_control_array_get(struct device *dev,
89 						   enum reset_control_flags flags);
90 struct reset_control *of_reset_control_array_get(struct device_node *np, enum reset_control_flags);
91 
92 int reset_control_get_count(struct device *dev);
93 
94 #else
95 
96 static inline int reset_control_reset(struct reset_control *rstc)
97 {
98 	return 0;
99 }
100 
101 static inline int reset_control_rearm(struct reset_control *rstc)
102 {
103 	return 0;
104 }
105 
106 static inline int reset_control_assert(struct reset_control *rstc)
107 {
108 	return 0;
109 }
110 
111 static inline int reset_control_deassert(struct reset_control *rstc)
112 {
113 	return 0;
114 }
115 
116 static inline int reset_control_status(struct reset_control *rstc)
117 {
118 	return 0;
119 }
120 
121 static inline int reset_control_acquire(struct reset_control *rstc)
122 {
123 	return 0;
124 }
125 
126 static inline void reset_control_release(struct reset_control *rstc)
127 {
128 }
129 
130 static inline void reset_control_put(struct reset_control *rstc)
131 {
132 }
133 
134 static inline int __device_reset(struct device *dev, bool optional)
135 {
136 	return optional ? 0 : -ENOTSUPP;
137 }
138 
139 static inline struct reset_control *__of_reset_control_get(
140 					struct device_node *node,
141 					const char *id, int index, enum reset_control_flags flags)
142 {
143 	bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL;
144 
145 	return optional ? NULL : ERR_PTR(-ENOTSUPP);
146 }
147 
148 static inline struct reset_control *__reset_control_get(
149 					struct device *dev, const char *id,
150 					int index, enum reset_control_flags flags)
151 {
152 	bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL;
153 
154 	return optional ? NULL : ERR_PTR(-ENOTSUPP);
155 }
156 
157 static inline int
158 reset_control_bulk_reset(int num_rstcs, struct reset_control_bulk_data *rstcs)
159 {
160 	return 0;
161 }
162 
163 static inline int
164 reset_control_bulk_assert(int num_rstcs, struct reset_control_bulk_data *rstcs)
165 {
166 	return 0;
167 }
168 
169 static inline int
170 reset_control_bulk_deassert(int num_rstcs, struct reset_control_bulk_data *rstcs)
171 {
172 	return 0;
173 }
174 
175 static inline int
176 reset_control_bulk_acquire(int num_rstcs, struct reset_control_bulk_data *rstcs)
177 {
178 	return 0;
179 }
180 
181 static inline void
182 reset_control_bulk_release(int num_rstcs, struct reset_control_bulk_data *rstcs)
183 {
184 }
185 
186 static inline int
187 __reset_control_bulk_get(struct device *dev, int num_rstcs,
188 			 struct reset_control_bulk_data *rstcs,
189 			 enum reset_control_flags flags)
190 {
191 	bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL;
192 
193 	return optional ? 0 : -EOPNOTSUPP;
194 }
195 
196 static inline void
197 reset_control_bulk_put(int num_rstcs, struct reset_control_bulk_data *rstcs)
198 {
199 }
200 
201 static inline struct reset_control *__devm_reset_control_get(
202 					struct device *dev, const char *id,
203 					int index, enum reset_control_flags flags)
204 {
205 	bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL;
206 
207 	return optional ? NULL : ERR_PTR(-ENOTSUPP);
208 }
209 
210 static inline int
211 __devm_reset_control_bulk_get(struct device *dev, int num_rstcs,
212 			      struct reset_control_bulk_data *rstcs,
213 			      enum reset_control_flags flags)
214 {
215 	bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL;
216 
217 	return optional ? 0 : -EOPNOTSUPP;
218 }
219 
220 static inline struct reset_control *
221 devm_reset_control_array_get(struct device *dev, enum reset_control_flags flags)
222 {
223 	bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL;
224 
225 	return optional ? NULL : ERR_PTR(-ENOTSUPP);
226 }
227 
228 static inline struct reset_control *
229 of_reset_control_array_get(struct device_node *np, enum reset_control_flags flags)
230 {
231 	bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL;
232 
233 	return optional ? NULL : ERR_PTR(-ENOTSUPP);
234 }
235 
236 static inline int reset_control_get_count(struct device *dev)
237 {
238 	return -ENOENT;
239 }
240 
241 #endif /* CONFIG_RESET_CONTROLLER */
242 
243 static inline int __must_check device_reset(struct device *dev)
244 {
245 	return __device_reset(dev, false);
246 }
247 
248 static inline int device_reset_optional(struct device *dev)
249 {
250 	return __device_reset(dev, true);
251 }
252 
253 /**
254  * reset_control_get_exclusive - Lookup and obtain an exclusive reference
255  *                               to a reset controller.
256  * @dev: device to be reset by the controller
257  * @id: reset line name
258  *
259  * Returns a struct reset_control or IS_ERR() condition containing errno.
260  * If this function is called more than once for the same reset_control it will
261  * return -EBUSY.
262  *
263  * See reset_control_get_shared() for details on shared references to
264  * reset-controls.
265  *
266  * Use of id names is optional.
267  */
268 static inline struct reset_control *
269 __must_check reset_control_get_exclusive(struct device *dev, const char *id)
270 {
271 	return __reset_control_get(dev, id, 0, RESET_CONTROL_EXCLUSIVE);
272 }
273 
274 /**
275  * reset_control_bulk_get_exclusive - Lookup and obtain exclusive references to
276  *                                    multiple reset controllers.
277  * @dev: device to be reset by the controller
278  * @num_rstcs: number of entries in rstcs array
279  * @rstcs: array of struct reset_control_bulk_data with reset line names set
280  *
281  * Fills the rstcs array with pointers to exclusive reset controls and
282  * returns 0, or an IS_ERR() condition containing errno.
283  */
284 static inline int __must_check
285 reset_control_bulk_get_exclusive(struct device *dev, int num_rstcs,
286 				 struct reset_control_bulk_data *rstcs)
287 {
288 	return __reset_control_bulk_get(dev, num_rstcs, rstcs, RESET_CONTROL_EXCLUSIVE);
289 }
290 
291 /**
292  * reset_control_get_exclusive_released - Lookup and obtain a temoprarily
293  *                                        exclusive reference to a reset
294  *                                        controller.
295  * @dev: device to be reset by the controller
296  * @id: reset line name
297  *
298  * Returns a struct reset_control or IS_ERR() condition containing errno.
299  * reset-controls returned by this function must be acquired via
300  * reset_control_acquire() before they can be used and should be released
301  * via reset_control_release() afterwards.
302  *
303  * Use of id names is optional.
304  */
305 static inline struct reset_control *
306 __must_check reset_control_get_exclusive_released(struct device *dev,
307 						  const char *id)
308 {
309 	return __reset_control_get(dev, id, 0, RESET_CONTROL_EXCLUSIVE_RELEASED);
310 }
311 
312 /**
313  * reset_control_bulk_get_exclusive_released - Lookup and obtain temporarily
314  *                                    exclusive references to multiple reset
315  *                                    controllers.
316  * @dev: device to be reset by the controller
317  * @num_rstcs: number of entries in rstcs array
318  * @rstcs: array of struct reset_control_bulk_data with reset line names set
319  *
320  * Fills the rstcs array with pointers to exclusive reset controls and
321  * returns 0, or an IS_ERR() condition containing errno.
322  * reset-controls returned by this function must be acquired via
323  * reset_control_bulk_acquire() before they can be used and should be released
324  * via reset_control_bulk_release() afterwards.
325  */
326 static inline int __must_check
327 reset_control_bulk_get_exclusive_released(struct device *dev, int num_rstcs,
328 					  struct reset_control_bulk_data *rstcs)
329 {
330 	return __reset_control_bulk_get(dev, num_rstcs, rstcs, RESET_CONTROL_EXCLUSIVE_RELEASED);
331 }
332 
333 /**
334  * reset_control_bulk_get_optional_exclusive_released - Lookup and obtain optional
335  *                                    temporarily exclusive references to multiple
336  *                                    reset controllers.
337  * @dev: device to be reset by the controller
338  * @num_rstcs: number of entries in rstcs array
339  * @rstcs: array of struct reset_control_bulk_data with reset line names set
340  *
341  * Optional variant of reset_control_bulk_get_exclusive_released(). If the
342  * requested reset is not specified in the device tree, this function returns 0
343  * instead of an error and missing rtsc is set to NULL.
344  *
345  * See reset_control_bulk_get_exclusive_released() for more information.
346  */
347 static inline int __must_check
348 reset_control_bulk_get_optional_exclusive_released(struct device *dev, int num_rstcs,
349 						   struct reset_control_bulk_data *rstcs)
350 {
351 	return __reset_control_bulk_get(dev, num_rstcs, rstcs,
352 					RESET_CONTROL_OPTIONAL_EXCLUSIVE_RELEASED);
353 }
354 
355 /**
356  * reset_control_get_shared - Lookup and obtain a shared reference to a
357  *                            reset controller.
358  * @dev: device to be reset by the controller
359  * @id: reset line name
360  *
361  * Returns a struct reset_control or IS_ERR() condition containing errno.
362  * This function is intended for use with reset-controls which are shared
363  * between hardware blocks.
364  *
365  * When a reset-control is shared, the behavior of reset_control_assert /
366  * deassert is changed, the reset-core will keep track of a deassert_count
367  * and only (re-)assert the reset after reset_control_assert has been called
368  * as many times as reset_control_deassert was called. Also see the remark
369  * about shared reset-controls in the reset_control_assert docs.
370  *
371  * Calling reset_control_assert without first calling reset_control_deassert
372  * is not allowed on a shared reset control. Calling reset_control_reset is
373  * also not allowed on a shared reset control.
374  *
375  * Use of id names is optional.
376  */
377 static inline struct reset_control *reset_control_get_shared(
378 					struct device *dev, const char *id)
379 {
380 	return __reset_control_get(dev, id, 0, RESET_CONTROL_SHARED);
381 }
382 
383 /**
384  * reset_control_bulk_get_shared - Lookup and obtain shared references to
385  *                                 multiple reset controllers.
386  * @dev: device to be reset by the controller
387  * @num_rstcs: number of entries in rstcs array
388  * @rstcs: array of struct reset_control_bulk_data with reset line names set
389  *
390  * Fills the rstcs array with pointers to shared reset controls and
391  * returns 0, or an IS_ERR() condition containing errno.
392  */
393 static inline int __must_check
394 reset_control_bulk_get_shared(struct device *dev, int num_rstcs,
395 			      struct reset_control_bulk_data *rstcs)
396 {
397 	return __reset_control_bulk_get(dev, num_rstcs, rstcs, RESET_CONTROL_SHARED);
398 }
399 
400 /**
401  * reset_control_get_optional_exclusive - optional reset_control_get_exclusive()
402  * @dev: device to be reset by the controller
403  * @id: reset line name
404  *
405  * Optional variant of reset_control_get_exclusive(). If the requested reset
406  * is not specified in the device tree, this function returns NULL instead of
407  * an error.
408  *
409  * See reset_control_get_exclusive() for more information.
410  */
411 static inline struct reset_control *reset_control_get_optional_exclusive(
412 					struct device *dev, const char *id)
413 {
414 	return __reset_control_get(dev, id, 0, RESET_CONTROL_OPTIONAL_EXCLUSIVE);
415 }
416 
417 /**
418  * reset_control_bulk_get_optional_exclusive - optional
419  *                                             reset_control_bulk_get_exclusive()
420  * @dev: device to be reset by the controller
421  * @num_rstcs: number of entries in rstcs array
422  * @rstcs: array of struct reset_control_bulk_data with reset line names set
423  *
424  * Optional variant of reset_control_bulk_get_exclusive(). If any of the
425  * requested resets are not specified in the device tree, this function sets
426  * them to NULL instead of returning an error.
427  *
428  * See reset_control_bulk_get_exclusive() for more information.
429  */
430 static inline int __must_check
431 reset_control_bulk_get_optional_exclusive(struct device *dev, int num_rstcs,
432 					  struct reset_control_bulk_data *rstcs)
433 {
434 	return __reset_control_bulk_get(dev, num_rstcs, rstcs, RESET_CONTROL_OPTIONAL_EXCLUSIVE);
435 }
436 
437 /**
438  * reset_control_get_optional_shared - optional reset_control_get_shared()
439  * @dev: device to be reset by the controller
440  * @id: reset line name
441  *
442  * Optional variant of reset_control_get_shared(). If the requested reset
443  * is not specified in the device tree, this function returns NULL instead of
444  * an error.
445  *
446  * See reset_control_get_shared() for more information.
447  */
448 static inline struct reset_control *reset_control_get_optional_shared(
449 					struct device *dev, const char *id)
450 {
451 	return __reset_control_get(dev, id, 0, RESET_CONTROL_OPTIONAL_SHARED);
452 }
453 
454 /**
455  * reset_control_bulk_get_optional_shared - optional
456  *                                             reset_control_bulk_get_shared()
457  * @dev: device to be reset by the controller
458  * @num_rstcs: number of entries in rstcs array
459  * @rstcs: array of struct reset_control_bulk_data with reset line names set
460  *
461  * Optional variant of reset_control_bulk_get_shared(). If the requested resets
462  * are not specified in the device tree, this function sets them to NULL
463  * instead of returning an error.
464  *
465  * See reset_control_bulk_get_shared() for more information.
466  */
467 static inline int __must_check
468 reset_control_bulk_get_optional_shared(struct device *dev, int num_rstcs,
469 				       struct reset_control_bulk_data *rstcs)
470 {
471 	return __reset_control_bulk_get(dev, num_rstcs, rstcs, RESET_CONTROL_OPTIONAL_SHARED);
472 }
473 
474 /**
475  * of_reset_control_get_exclusive - Lookup and obtain an exclusive reference
476  *                                  to a reset controller.
477  * @node: device to be reset by the controller
478  * @id: reset line name
479  *
480  * Returns a struct reset_control or IS_ERR() condition containing errno.
481  *
482  * Use of id names is optional.
483  */
484 static inline struct reset_control *of_reset_control_get_exclusive(
485 				struct device_node *node, const char *id)
486 {
487 	return __of_reset_control_get(node, id, 0, RESET_CONTROL_EXCLUSIVE);
488 }
489 
490 /**
491  * of_reset_control_get_optional_exclusive - Lookup and obtain an optional exclusive
492  *                                           reference to a reset controller.
493  * @node: device to be reset by the controller
494  * @id: reset line name
495  *
496  * Optional variant of of_reset_control_get_exclusive(). If the requested reset
497  * is not specified in the device tree, this function returns NULL instead of
498  * an error.
499  *
500  * Returns a struct reset_control or IS_ERR() condition containing errno.
501  *
502  * Use of id names is optional.
503  */
504 static inline struct reset_control *of_reset_control_get_optional_exclusive(
505 				struct device_node *node, const char *id)
506 {
507 	return __of_reset_control_get(node, id, 0, RESET_CONTROL_OPTIONAL_EXCLUSIVE);
508 }
509 
510 /**
511  * of_reset_control_get_shared - Lookup and obtain a shared reference
512  *                               to a reset controller.
513  * @node: device to be reset by the controller
514  * @id: reset line name
515  *
516  * When a reset-control is shared, the behavior of reset_control_assert /
517  * deassert is changed, the reset-core will keep track of a deassert_count
518  * and only (re-)assert the reset after reset_control_assert has been called
519  * as many times as reset_control_deassert was called. Also see the remark
520  * about shared reset-controls in the reset_control_assert docs.
521  *
522  * Calling reset_control_assert without first calling reset_control_deassert
523  * is not allowed on a shared reset control. Calling reset_control_reset is
524  * also not allowed on a shared reset control.
525  * Returns a struct reset_control or IS_ERR() condition containing errno.
526  *
527  * Use of id names is optional.
528  */
529 static inline struct reset_control *of_reset_control_get_shared(
530 				struct device_node *node, const char *id)
531 {
532 	return __of_reset_control_get(node, id, 0, RESET_CONTROL_SHARED);
533 }
534 
535 /**
536  * of_reset_control_get_exclusive_by_index - Lookup and obtain an exclusive
537  *                                           reference to a reset controller
538  *                                           by index.
539  * @node: device to be reset by the controller
540  * @index: index of the reset controller
541  *
542  * This is to be used to perform a list of resets for a device or power domain
543  * in whatever order. Returns a struct reset_control or IS_ERR() condition
544  * containing errno.
545  */
546 static inline struct reset_control *of_reset_control_get_exclusive_by_index(
547 					struct device_node *node, int index)
548 {
549 	return __of_reset_control_get(node, NULL, index, RESET_CONTROL_EXCLUSIVE);
550 }
551 
552 /**
553  * of_reset_control_get_shared_by_index - Lookup and obtain a shared
554  *                                        reference to a reset controller
555  *                                        by index.
556  * @node: device to be reset by the controller
557  * @index: index of the reset controller
558  *
559  * When a reset-control is shared, the behavior of reset_control_assert /
560  * deassert is changed, the reset-core will keep track of a deassert_count
561  * and only (re-)assert the reset after reset_control_assert has been called
562  * as many times as reset_control_deassert was called. Also see the remark
563  * about shared reset-controls in the reset_control_assert docs.
564  *
565  * Calling reset_control_assert without first calling reset_control_deassert
566  * is not allowed on a shared reset control. Calling reset_control_reset is
567  * also not allowed on a shared reset control.
568  * Returns a struct reset_control or IS_ERR() condition containing errno.
569  *
570  * This is to be used to perform a list of resets for a device or power domain
571  * in whatever order. Returns a struct reset_control or IS_ERR() condition
572  * containing errno.
573  */
574 static inline struct reset_control *of_reset_control_get_shared_by_index(
575 					struct device_node *node, int index)
576 {
577 	return __of_reset_control_get(node, NULL, index, RESET_CONTROL_SHARED);
578 }
579 
580 /**
581  * devm_reset_control_get_exclusive - resource managed
582  *                                    reset_control_get_exclusive()
583  * @dev: device to be reset by the controller
584  * @id: reset line name
585  *
586  * Managed reset_control_get_exclusive(). For reset controllers returned
587  * from this function, reset_control_put() is called automatically on driver
588  * detach.
589  *
590  * See reset_control_get_exclusive() for more information.
591  */
592 static inline struct reset_control *
593 __must_check devm_reset_control_get_exclusive(struct device *dev,
594 					      const char *id)
595 {
596 	return __devm_reset_control_get(dev, id, 0, RESET_CONTROL_EXCLUSIVE);
597 }
598 
599 /**
600  * devm_reset_control_bulk_get_exclusive - resource managed
601  *                                         reset_control_bulk_get_exclusive()
602  * @dev: device to be reset by the controller
603  * @num_rstcs: number of entries in rstcs array
604  * @rstcs: array of struct reset_control_bulk_data with reset line names set
605  *
606  * Managed reset_control_bulk_get_exclusive(). For reset controllers returned
607  * from this function, reset_control_put() is called automatically on driver
608  * detach.
609  *
610  * See reset_control_bulk_get_exclusive() for more information.
611  */
612 static inline int __must_check
613 devm_reset_control_bulk_get_exclusive(struct device *dev, int num_rstcs,
614 				      struct reset_control_bulk_data *rstcs)
615 {
616 	return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs,
617 					     RESET_CONTROL_EXCLUSIVE);
618 }
619 
620 /**
621  * devm_reset_control_get_exclusive_released - resource managed
622  *                                             reset_control_get_exclusive_released()
623  * @dev: device to be reset by the controller
624  * @id: reset line name
625  *
626  * Managed reset_control_get_exclusive_released(). For reset controllers
627  * returned from this function, reset_control_put() is called automatically on
628  * driver detach.
629  *
630  * See reset_control_get_exclusive_released() for more information.
631  */
632 static inline struct reset_control *
633 __must_check devm_reset_control_get_exclusive_released(struct device *dev,
634 						       const char *id)
635 {
636 	return __devm_reset_control_get(dev, id, 0, RESET_CONTROL_EXCLUSIVE_RELEASED);
637 }
638 
639 /**
640  * devm_reset_control_bulk_get_exclusive_released - resource managed
641  *                                                  reset_control_bulk_get_exclusive_released()
642  * @dev: device to be reset by the controller
643  * @num_rstcs: number of entries in rstcs array
644  * @rstcs: array of struct reset_control_bulk_data with reset line names set
645  *
646  * Managed reset_control_bulk_get_exclusive_released(). For reset controllers
647  * returned from this function, reset_control_put() is called automatically on
648  * driver detach.
649  *
650  * See reset_control_bulk_get_exclusive_released() for more information.
651  */
652 static inline int __must_check
653 devm_reset_control_bulk_get_exclusive_released(struct device *dev, int num_rstcs,
654 					       struct reset_control_bulk_data *rstcs)
655 {
656 	return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs,
657 					     RESET_CONTROL_EXCLUSIVE_RELEASED);
658 }
659 
660 /**
661  * devm_reset_control_get_optional_exclusive_released - resource managed
662  *                                                      reset_control_get_optional_exclusive_released()
663  * @dev: device to be reset by the controller
664  * @id: reset line name
665  *
666  * Managed-and-optional variant of reset_control_get_exclusive_released(). For
667  * reset controllers returned from this function, reset_control_put() is called
668  * automatically on driver detach.
669  *
670  * See reset_control_get_exclusive_released() for more information.
671  */
672 static inline struct reset_control *
673 __must_check devm_reset_control_get_optional_exclusive_released(struct device *dev,
674 								const char *id)
675 {
676 	return __devm_reset_control_get(dev, id, 0, RESET_CONTROL_OPTIONAL_EXCLUSIVE_RELEASED);
677 }
678 
679 /**
680  * devm_reset_control_bulk_get_optional_exclusive_released - resource managed
681  *                                                           reset_control_bulk_optional_get_exclusive_released()
682  * @dev: device to be reset by the controller
683  * @num_rstcs: number of entries in rstcs array
684  * @rstcs: array of struct reset_control_bulk_data with reset line names set
685  *
686  * Managed reset_control_bulk_optional_get_exclusive_released(). For reset
687  * controllers returned from this function, reset_control_put() is called
688  * automatically on driver detach.
689  *
690  * See reset_control_bulk_optional_get_exclusive_released() for more information.
691  */
692 static inline int __must_check
693 devm_reset_control_bulk_get_optional_exclusive_released(struct device *dev, int num_rstcs,
694 							struct reset_control_bulk_data *rstcs)
695 {
696 	return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs,
697 					     RESET_CONTROL_OPTIONAL_EXCLUSIVE_RELEASED);
698 }
699 
700 /**
701  * devm_reset_control_get_shared - resource managed reset_control_get_shared()
702  * @dev: device to be reset by the controller
703  * @id: reset line name
704  *
705  * Managed reset_control_get_shared(). For reset controllers returned from
706  * this function, reset_control_put() is called automatically on driver detach.
707  * See reset_control_get_shared() for more information.
708  */
709 static inline struct reset_control *devm_reset_control_get_shared(
710 					struct device *dev, const char *id)
711 {
712 	return __devm_reset_control_get(dev, id, 0, RESET_CONTROL_SHARED);
713 }
714 
715 /**
716  * devm_reset_control_bulk_get_shared - resource managed
717  *                                      reset_control_bulk_get_shared()
718  * @dev: device to be reset by the controller
719  * @num_rstcs: number of entries in rstcs array
720  * @rstcs: array of struct reset_control_bulk_data with reset line names set
721  *
722  * Managed reset_control_bulk_get_shared(). For reset controllers returned
723  * from this function, reset_control_put() is called automatically on driver
724  * detach.
725  *
726  * See reset_control_bulk_get_shared() for more information.
727  */
728 static inline int __must_check
729 devm_reset_control_bulk_get_shared(struct device *dev, int num_rstcs,
730 				   struct reset_control_bulk_data *rstcs)
731 {
732 	return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, RESET_CONTROL_SHARED);
733 }
734 
735 /**
736  * devm_reset_control_get_optional_exclusive - resource managed
737  *                                             reset_control_get_optional_exclusive()
738  * @dev: device to be reset by the controller
739  * @id: reset line name
740  *
741  * Managed reset_control_get_optional_exclusive(). For reset controllers
742  * returned from this function, reset_control_put() is called automatically on
743  * driver detach.
744  *
745  * See reset_control_get_optional_exclusive() for more information.
746  */
747 static inline struct reset_control *devm_reset_control_get_optional_exclusive(
748 					struct device *dev, const char *id)
749 {
750 	return __devm_reset_control_get(dev, id, 0, RESET_CONTROL_OPTIONAL_EXCLUSIVE);
751 }
752 
753 /**
754  * devm_reset_control_bulk_get_optional_exclusive - resource managed
755  *                                                  reset_control_bulk_get_optional_exclusive()
756  * @dev: device to be reset by the controller
757  * @num_rstcs: number of entries in rstcs array
758  * @rstcs: array of struct reset_control_bulk_data with reset line names set
759  *
760  * Managed reset_control_bulk_get_optional_exclusive(). For reset controllers
761  * returned from this function, reset_control_put() is called automatically on
762  * driver detach.
763  *
764  * See reset_control_bulk_get_optional_exclusive() for more information.
765  */
766 static inline int __must_check
767 devm_reset_control_bulk_get_optional_exclusive(struct device *dev, int num_rstcs,
768 					       struct reset_control_bulk_data *rstcs)
769 {
770 	return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs,
771 					     RESET_CONTROL_OPTIONAL_EXCLUSIVE);
772 }
773 
774 /**
775  * devm_reset_control_get_optional_shared - resource managed
776  *                                          reset_control_get_optional_shared()
777  * @dev: device to be reset by the controller
778  * @id: reset line name
779  *
780  * Managed reset_control_get_optional_shared(). For reset controllers returned
781  * from this function, reset_control_put() is called automatically on driver
782  * detach.
783  *
784  * See reset_control_get_optional_shared() for more information.
785  */
786 static inline struct reset_control *devm_reset_control_get_optional_shared(
787 					struct device *dev, const char *id)
788 {
789 	return __devm_reset_control_get(dev, id, 0, RESET_CONTROL_OPTIONAL_SHARED);
790 }
791 
792 /**
793  * devm_reset_control_bulk_get_optional_shared - resource managed
794  *                                               reset_control_bulk_get_optional_shared()
795  * @dev: device to be reset by the controller
796  * @num_rstcs: number of entries in rstcs array
797  * @rstcs: array of struct reset_control_bulk_data with reset line names set
798  *
799  * Managed reset_control_bulk_get_optional_shared(). For reset controllers
800  * returned from this function, reset_control_put() is called automatically on
801  * driver detach.
802  *
803  * See reset_control_bulk_get_optional_shared() for more information.
804  */
805 static inline int __must_check
806 devm_reset_control_bulk_get_optional_shared(struct device *dev, int num_rstcs,
807 					    struct reset_control_bulk_data *rstcs)
808 {
809 	return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, RESET_CONTROL_OPTIONAL_SHARED);
810 }
811 
812 /**
813  * devm_reset_control_get_exclusive_by_index - resource managed
814  *                                             reset_control_get_exclusive()
815  * @dev: device to be reset by the controller
816  * @index: index of the reset controller
817  *
818  * Managed reset_control_get_exclusive(). For reset controllers returned from
819  * this function, reset_control_put() is called automatically on driver
820  * detach.
821  *
822  * See reset_control_get_exclusive() for more information.
823  */
824 static inline struct reset_control *
825 devm_reset_control_get_exclusive_by_index(struct device *dev, int index)
826 {
827 	return __devm_reset_control_get(dev, NULL, index, RESET_CONTROL_EXCLUSIVE);
828 }
829 
830 /**
831  * devm_reset_control_get_shared_by_index - resource managed
832  *                                          reset_control_get_shared
833  * @dev: device to be reset by the controller
834  * @index: index of the reset controller
835  *
836  * Managed reset_control_get_shared(). For reset controllers returned from
837  * this function, reset_control_put() is called automatically on driver detach.
838  * See reset_control_get_shared() for more information.
839  */
840 static inline struct reset_control *
841 devm_reset_control_get_shared_by_index(struct device *dev, int index)
842 {
843 	return __devm_reset_control_get(dev, NULL, index, RESET_CONTROL_SHARED);
844 }
845 
846 /*
847  * TEMPORARY calls to use during transition:
848  *
849  *   of_reset_control_get() => of_reset_control_get_exclusive()
850  *
851  * These inline function calls will be removed once all consumers
852  * have been moved over to the new explicit API.
853  */
854 static inline struct reset_control *of_reset_control_get(
855 				struct device_node *node, const char *id)
856 {
857 	return of_reset_control_get_exclusive(node, id);
858 }
859 
860 static inline struct reset_control *of_reset_control_get_by_index(
861 				struct device_node *node, int index)
862 {
863 	return of_reset_control_get_exclusive_by_index(node, index);
864 }
865 
866 static inline struct reset_control *devm_reset_control_get(
867 				struct device *dev, const char *id)
868 {
869 	return devm_reset_control_get_exclusive(dev, id);
870 }
871 
872 static inline struct reset_control *devm_reset_control_get_optional(
873 				struct device *dev, const char *id)
874 {
875 	return devm_reset_control_get_optional_exclusive(dev, id);
876 
877 }
878 
879 static inline struct reset_control *devm_reset_control_get_by_index(
880 				struct device *dev, int index)
881 {
882 	return devm_reset_control_get_exclusive_by_index(dev, index);
883 }
884 
885 /*
886  * APIs to manage a list of reset controllers
887  */
888 static inline struct reset_control *
889 devm_reset_control_array_get_exclusive(struct device *dev)
890 {
891 	return devm_reset_control_array_get(dev, RESET_CONTROL_EXCLUSIVE);
892 }
893 
894 static inline struct reset_control *
895 devm_reset_control_array_get_shared(struct device *dev)
896 {
897 	return devm_reset_control_array_get(dev, RESET_CONTROL_SHARED);
898 }
899 
900 static inline struct reset_control *
901 devm_reset_control_array_get_optional_exclusive(struct device *dev)
902 {
903 	return devm_reset_control_array_get(dev, RESET_CONTROL_OPTIONAL_EXCLUSIVE);
904 }
905 
906 static inline struct reset_control *
907 devm_reset_control_array_get_optional_shared(struct device *dev)
908 {
909 	return devm_reset_control_array_get(dev, RESET_CONTROL_OPTIONAL_SHARED);
910 }
911 
912 static inline struct reset_control *
913 of_reset_control_array_get_exclusive(struct device_node *node)
914 {
915 	return of_reset_control_array_get(node, RESET_CONTROL_EXCLUSIVE);
916 }
917 
918 static inline struct reset_control *
919 of_reset_control_array_get_exclusive_released(struct device_node *node)
920 {
921 	return of_reset_control_array_get(node, RESET_CONTROL_EXCLUSIVE_RELEASED);
922 }
923 
924 static inline struct reset_control *
925 of_reset_control_array_get_shared(struct device_node *node)
926 {
927 	return of_reset_control_array_get(node, RESET_CONTROL_SHARED);
928 }
929 
930 static inline struct reset_control *
931 of_reset_control_array_get_optional_exclusive(struct device_node *node)
932 {
933 	return of_reset_control_array_get(node, RESET_CONTROL_OPTIONAL_EXCLUSIVE);
934 }
935 
936 static inline struct reset_control *
937 of_reset_control_array_get_optional_shared(struct device_node *node)
938 {
939 	return of_reset_control_array_get(node, RESET_CONTROL_OPTIONAL_SHARED);
940 }
941 #endif
942