printf: Remove unused 'bprintf'
[drm/drm-misc.git] / include / linux / reset.h
blob2986ced69a026947c8aafa89cdddf1e4088caef7
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_RESET_H_
3 #define _LINUX_RESET_H_
5 #include <linux/err.h>
6 #include <linux/errno.h>
7 #include <linux/types.h>
9 struct device;
10 struct device_node;
11 struct reset_control;
13 /**
14 * struct reset_control_bulk_data - Data used for bulk reset control operations.
16 * @id: reset control consumer ID
17 * @rstc: struct reset_control * to store the associated reset control
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.
23 struct reset_control_bulk_data {
24 const char *id;
25 struct reset_control *rstc;
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 #define RESET_CONTROL_FLAGS_BIT_DEASSERTED BIT(3)
33 /**
34 * enum reset_control_flags - Flags that can be passed to the reset_control_get functions
35 * to determine the type of reset control.
36 * These values cannot be OR'd.
38 * @RESET_CONTROL_EXCLUSIVE: exclusive, acquired,
39 * @RESET_CONTROL_EXCLUSIVE_DEASSERTED: exclusive, acquired, deasserted
40 * @RESET_CONTROL_EXCLUSIVE_RELEASED: exclusive, released,
41 * @RESET_CONTROL_SHARED: shared
42 * @RESET_CONTROL_SHARED_DEASSERTED: shared, deasserted
43 * @RESET_CONTROL_OPTIONAL_EXCLUSIVE: optional, exclusive, acquired
44 * @RESET_CONTROL_OPTIONAL_EXCLUSIVE_DEASSERTED: optional, exclusive, acquired, deasserted
45 * @RESET_CONTROL_OPTIONAL_EXCLUSIVE_RELEASED: optional, exclusive, released
46 * @RESET_CONTROL_OPTIONAL_SHARED: optional, shared
47 * @RESET_CONTROL_OPTIONAL_SHARED_DEASSERTED: optional, shared, deasserted
49 enum reset_control_flags {
50 RESET_CONTROL_EXCLUSIVE = RESET_CONTROL_FLAGS_BIT_ACQUIRED,
51 RESET_CONTROL_EXCLUSIVE_DEASSERTED = RESET_CONTROL_FLAGS_BIT_ACQUIRED |
52 RESET_CONTROL_FLAGS_BIT_DEASSERTED,
53 RESET_CONTROL_EXCLUSIVE_RELEASED = 0,
54 RESET_CONTROL_SHARED = RESET_CONTROL_FLAGS_BIT_SHARED,
55 RESET_CONTROL_SHARED_DEASSERTED = RESET_CONTROL_FLAGS_BIT_SHARED |
56 RESET_CONTROL_FLAGS_BIT_DEASSERTED,
57 RESET_CONTROL_OPTIONAL_EXCLUSIVE = RESET_CONTROL_FLAGS_BIT_OPTIONAL |
58 RESET_CONTROL_FLAGS_BIT_ACQUIRED,
59 RESET_CONTROL_OPTIONAL_EXCLUSIVE_DEASSERTED = RESET_CONTROL_FLAGS_BIT_OPTIONAL |
60 RESET_CONTROL_FLAGS_BIT_ACQUIRED |
61 RESET_CONTROL_FLAGS_BIT_DEASSERTED,
62 RESET_CONTROL_OPTIONAL_EXCLUSIVE_RELEASED = RESET_CONTROL_FLAGS_BIT_OPTIONAL,
63 RESET_CONTROL_OPTIONAL_SHARED = RESET_CONTROL_FLAGS_BIT_OPTIONAL |
64 RESET_CONTROL_FLAGS_BIT_SHARED,
65 RESET_CONTROL_OPTIONAL_SHARED_DEASSERTED = RESET_CONTROL_FLAGS_BIT_OPTIONAL |
66 RESET_CONTROL_FLAGS_BIT_SHARED |
67 RESET_CONTROL_FLAGS_BIT_DEASSERTED,
70 #ifdef CONFIG_RESET_CONTROLLER
72 int reset_control_reset(struct reset_control *rstc);
73 int reset_control_rearm(struct reset_control *rstc);
74 int reset_control_assert(struct reset_control *rstc);
75 int reset_control_deassert(struct reset_control *rstc);
76 int reset_control_status(struct reset_control *rstc);
77 int reset_control_acquire(struct reset_control *rstc);
78 void reset_control_release(struct reset_control *rstc);
80 int reset_control_bulk_reset(int num_rstcs, struct reset_control_bulk_data *rstcs);
81 int reset_control_bulk_assert(int num_rstcs, struct reset_control_bulk_data *rstcs);
82 int reset_control_bulk_deassert(int num_rstcs, struct reset_control_bulk_data *rstcs);
83 int reset_control_bulk_acquire(int num_rstcs, struct reset_control_bulk_data *rstcs);
84 void reset_control_bulk_release(int num_rstcs, struct reset_control_bulk_data *rstcs);
86 struct reset_control *__of_reset_control_get(struct device_node *node,
87 const char *id, int index, enum reset_control_flags flags);
88 struct reset_control *__reset_control_get(struct device *dev, const char *id,
89 int index, enum reset_control_flags flags);
90 void reset_control_put(struct reset_control *rstc);
91 int __reset_control_bulk_get(struct device *dev, int num_rstcs,
92 struct reset_control_bulk_data *rstcs,
93 enum reset_control_flags flags);
94 void reset_control_bulk_put(int num_rstcs, struct reset_control_bulk_data *rstcs);
96 int __device_reset(struct device *dev, bool optional);
97 struct reset_control *__devm_reset_control_get(struct device *dev,
98 const char *id, int index, enum reset_control_flags flags);
99 int __devm_reset_control_bulk_get(struct device *dev, int num_rstcs,
100 struct reset_control_bulk_data *rstcs,
101 enum reset_control_flags flags);
103 struct reset_control *devm_reset_control_array_get(struct device *dev,
104 enum reset_control_flags flags);
105 struct reset_control *of_reset_control_array_get(struct device_node *np, enum reset_control_flags);
107 int reset_control_get_count(struct device *dev);
109 #else
111 static inline int reset_control_reset(struct reset_control *rstc)
113 return 0;
116 static inline int reset_control_rearm(struct reset_control *rstc)
118 return 0;
121 static inline int reset_control_assert(struct reset_control *rstc)
123 return 0;
126 static inline int reset_control_deassert(struct reset_control *rstc)
128 return 0;
131 static inline int reset_control_status(struct reset_control *rstc)
133 return 0;
136 static inline int reset_control_acquire(struct reset_control *rstc)
138 return 0;
141 static inline void reset_control_release(struct reset_control *rstc)
145 static inline void reset_control_put(struct reset_control *rstc)
149 static inline int __device_reset(struct device *dev, bool optional)
151 return optional ? 0 : -ENOTSUPP;
154 static inline struct reset_control *__of_reset_control_get(
155 struct device_node *node,
156 const char *id, int index, enum reset_control_flags flags)
158 bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL;
160 return optional ? NULL : ERR_PTR(-ENOTSUPP);
163 static inline struct reset_control *__reset_control_get(
164 struct device *dev, const char *id,
165 int index, enum reset_control_flags flags)
167 bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL;
169 return optional ? NULL : ERR_PTR(-ENOTSUPP);
172 static inline int
173 reset_control_bulk_reset(int num_rstcs, struct reset_control_bulk_data *rstcs)
175 return 0;
178 static inline int
179 reset_control_bulk_assert(int num_rstcs, struct reset_control_bulk_data *rstcs)
181 return 0;
184 static inline int
185 reset_control_bulk_deassert(int num_rstcs, struct reset_control_bulk_data *rstcs)
187 return 0;
190 static inline int
191 reset_control_bulk_acquire(int num_rstcs, struct reset_control_bulk_data *rstcs)
193 return 0;
196 static inline void
197 reset_control_bulk_release(int num_rstcs, struct reset_control_bulk_data *rstcs)
201 static inline int
202 __reset_control_bulk_get(struct device *dev, int num_rstcs,
203 struct reset_control_bulk_data *rstcs,
204 enum reset_control_flags flags)
206 bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL;
208 return optional ? 0 : -EOPNOTSUPP;
211 static inline void
212 reset_control_bulk_put(int num_rstcs, struct reset_control_bulk_data *rstcs)
216 static inline struct reset_control *__devm_reset_control_get(
217 struct device *dev, const char *id,
218 int index, enum reset_control_flags flags)
220 bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL;
222 return optional ? NULL : ERR_PTR(-ENOTSUPP);
225 static inline int
226 __devm_reset_control_bulk_get(struct device *dev, int num_rstcs,
227 struct reset_control_bulk_data *rstcs,
228 enum reset_control_flags flags)
230 bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL;
232 return optional ? 0 : -EOPNOTSUPP;
235 static inline struct reset_control *
236 devm_reset_control_array_get(struct device *dev, enum reset_control_flags flags)
238 bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL;
240 return optional ? NULL : ERR_PTR(-ENOTSUPP);
243 static inline struct reset_control *
244 of_reset_control_array_get(struct device_node *np, enum reset_control_flags flags)
246 bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL;
248 return optional ? NULL : ERR_PTR(-ENOTSUPP);
251 static inline int reset_control_get_count(struct device *dev)
253 return -ENOENT;
256 #endif /* CONFIG_RESET_CONTROLLER */
258 static inline int __must_check device_reset(struct device *dev)
260 return __device_reset(dev, false);
263 static inline int device_reset_optional(struct device *dev)
265 return __device_reset(dev, true);
269 * reset_control_get_exclusive - Lookup and obtain an exclusive reference
270 * to a reset controller.
271 * @dev: device to be reset by the controller
272 * @id: reset line name
274 * Returns a struct reset_control or IS_ERR() condition containing errno.
275 * If this function is called more than once for the same reset_control it will
276 * return -EBUSY.
278 * See reset_control_get_shared() for details on shared references to
279 * reset-controls.
281 * Use of id names is optional.
283 static inline struct reset_control *
284 __must_check reset_control_get_exclusive(struct device *dev, const char *id)
286 return __reset_control_get(dev, id, 0, RESET_CONTROL_EXCLUSIVE);
290 * reset_control_bulk_get_exclusive - Lookup and obtain exclusive references to
291 * multiple reset controllers.
292 * @dev: device to be reset by the controller
293 * @num_rstcs: number of entries in rstcs array
294 * @rstcs: array of struct reset_control_bulk_data with reset line names set
296 * Fills the rstcs array with pointers to exclusive reset controls and
297 * returns 0, or an IS_ERR() condition containing errno.
299 static inline int __must_check
300 reset_control_bulk_get_exclusive(struct device *dev, int num_rstcs,
301 struct reset_control_bulk_data *rstcs)
303 return __reset_control_bulk_get(dev, num_rstcs, rstcs, RESET_CONTROL_EXCLUSIVE);
307 * reset_control_get_exclusive_released - Lookup and obtain a temoprarily
308 * exclusive reference to a reset
309 * controller.
310 * @dev: device to be reset by the controller
311 * @id: reset line name
313 * Returns a struct reset_control or IS_ERR() condition containing errno.
314 * reset-controls returned by this function must be acquired via
315 * reset_control_acquire() before they can be used and should be released
316 * via reset_control_release() afterwards.
318 * Use of id names is optional.
320 static inline struct reset_control *
321 __must_check reset_control_get_exclusive_released(struct device *dev,
322 const char *id)
324 return __reset_control_get(dev, id, 0, RESET_CONTROL_EXCLUSIVE_RELEASED);
328 * reset_control_bulk_get_exclusive_released - Lookup and obtain temporarily
329 * exclusive references to multiple reset
330 * controllers.
331 * @dev: device to be reset by the controller
332 * @num_rstcs: number of entries in rstcs array
333 * @rstcs: array of struct reset_control_bulk_data with reset line names set
335 * Fills the rstcs array with pointers to exclusive reset controls and
336 * returns 0, or an IS_ERR() condition containing errno.
337 * reset-controls returned by this function must be acquired via
338 * reset_control_bulk_acquire() before they can be used and should be released
339 * via reset_control_bulk_release() afterwards.
341 static inline int __must_check
342 reset_control_bulk_get_exclusive_released(struct device *dev, int num_rstcs,
343 struct reset_control_bulk_data *rstcs)
345 return __reset_control_bulk_get(dev, num_rstcs, rstcs, RESET_CONTROL_EXCLUSIVE_RELEASED);
349 * reset_control_bulk_get_optional_exclusive_released - Lookup and obtain optional
350 * temporarily exclusive references to multiple
351 * reset controllers.
352 * @dev: device to be reset by the controller
353 * @num_rstcs: number of entries in rstcs array
354 * @rstcs: array of struct reset_control_bulk_data with reset line names set
356 * Optional variant of reset_control_bulk_get_exclusive_released(). If the
357 * requested reset is not specified in the device tree, this function returns 0
358 * instead of an error and missing rtsc is set to NULL.
360 * See reset_control_bulk_get_exclusive_released() for more information.
362 static inline int __must_check
363 reset_control_bulk_get_optional_exclusive_released(struct device *dev, int num_rstcs,
364 struct reset_control_bulk_data *rstcs)
366 return __reset_control_bulk_get(dev, num_rstcs, rstcs,
367 RESET_CONTROL_OPTIONAL_EXCLUSIVE_RELEASED);
371 * reset_control_get_shared - Lookup and obtain a shared reference to a
372 * reset controller.
373 * @dev: device to be reset by the controller
374 * @id: reset line name
376 * Returns a struct reset_control or IS_ERR() condition containing errno.
377 * This function is intended for use with reset-controls which are shared
378 * between hardware blocks.
380 * When a reset-control is shared, the behavior of reset_control_assert /
381 * deassert is changed, the reset-core will keep track of a deassert_count
382 * and only (re-)assert the reset after reset_control_assert has been called
383 * as many times as reset_control_deassert was called. Also see the remark
384 * about shared reset-controls in the reset_control_assert docs.
386 * Calling reset_control_assert without first calling reset_control_deassert
387 * is not allowed on a shared reset control. Calling reset_control_reset is
388 * also not allowed on a shared reset control.
390 * Use of id names is optional.
392 static inline struct reset_control *reset_control_get_shared(
393 struct device *dev, const char *id)
395 return __reset_control_get(dev, id, 0, RESET_CONTROL_SHARED);
399 * reset_control_bulk_get_shared - Lookup and obtain shared references to
400 * multiple reset controllers.
401 * @dev: device to be reset by the controller
402 * @num_rstcs: number of entries in rstcs array
403 * @rstcs: array of struct reset_control_bulk_data with reset line names set
405 * Fills the rstcs array with pointers to shared reset controls and
406 * returns 0, or an IS_ERR() condition containing errno.
408 static inline int __must_check
409 reset_control_bulk_get_shared(struct device *dev, int num_rstcs,
410 struct reset_control_bulk_data *rstcs)
412 return __reset_control_bulk_get(dev, num_rstcs, rstcs, RESET_CONTROL_SHARED);
416 * reset_control_get_optional_exclusive - optional reset_control_get_exclusive()
417 * @dev: device to be reset by the controller
418 * @id: reset line name
420 * Optional variant of reset_control_get_exclusive(). If the requested reset
421 * is not specified in the device tree, this function returns NULL instead of
422 * an error.
424 * See reset_control_get_exclusive() for more information.
426 static inline struct reset_control *reset_control_get_optional_exclusive(
427 struct device *dev, const char *id)
429 return __reset_control_get(dev, id, 0, RESET_CONTROL_OPTIONAL_EXCLUSIVE);
433 * reset_control_bulk_get_optional_exclusive - optional
434 * reset_control_bulk_get_exclusive()
435 * @dev: device to be reset by the controller
436 * @num_rstcs: number of entries in rstcs array
437 * @rstcs: array of struct reset_control_bulk_data with reset line names set
439 * Optional variant of reset_control_bulk_get_exclusive(). If any of the
440 * requested resets are not specified in the device tree, this function sets
441 * them to NULL instead of returning an error.
443 * See reset_control_bulk_get_exclusive() for more information.
445 static inline int __must_check
446 reset_control_bulk_get_optional_exclusive(struct device *dev, int num_rstcs,
447 struct reset_control_bulk_data *rstcs)
449 return __reset_control_bulk_get(dev, num_rstcs, rstcs, RESET_CONTROL_OPTIONAL_EXCLUSIVE);
453 * reset_control_get_optional_shared - optional reset_control_get_shared()
454 * @dev: device to be reset by the controller
455 * @id: reset line name
457 * Optional variant of reset_control_get_shared(). If the requested reset
458 * is not specified in the device tree, this function returns NULL instead of
459 * an error.
461 * See reset_control_get_shared() for more information.
463 static inline struct reset_control *reset_control_get_optional_shared(
464 struct device *dev, const char *id)
466 return __reset_control_get(dev, id, 0, RESET_CONTROL_OPTIONAL_SHARED);
470 * reset_control_bulk_get_optional_shared - optional
471 * reset_control_bulk_get_shared()
472 * @dev: device to be reset by the controller
473 * @num_rstcs: number of entries in rstcs array
474 * @rstcs: array of struct reset_control_bulk_data with reset line names set
476 * Optional variant of reset_control_bulk_get_shared(). If the requested resets
477 * are not specified in the device tree, this function sets them to NULL
478 * instead of returning an error.
480 * See reset_control_bulk_get_shared() for more information.
482 static inline int __must_check
483 reset_control_bulk_get_optional_shared(struct device *dev, int num_rstcs,
484 struct reset_control_bulk_data *rstcs)
486 return __reset_control_bulk_get(dev, num_rstcs, rstcs, RESET_CONTROL_OPTIONAL_SHARED);
490 * of_reset_control_get_exclusive - Lookup and obtain an exclusive reference
491 * to a reset controller.
492 * @node: device to be reset by the controller
493 * @id: reset line name
495 * Returns a struct reset_control or IS_ERR() condition containing errno.
497 * Use of id names is optional.
499 static inline struct reset_control *of_reset_control_get_exclusive(
500 struct device_node *node, const char *id)
502 return __of_reset_control_get(node, id, 0, RESET_CONTROL_EXCLUSIVE);
506 * of_reset_control_get_optional_exclusive - Lookup and obtain an optional exclusive
507 * reference to a reset controller.
508 * @node: device to be reset by the controller
509 * @id: reset line name
511 * Optional variant of of_reset_control_get_exclusive(). If the requested reset
512 * is not specified in the device tree, this function returns NULL instead of
513 * an error.
515 * Returns a struct reset_control or IS_ERR() condition containing errno.
517 * Use of id names is optional.
519 static inline struct reset_control *of_reset_control_get_optional_exclusive(
520 struct device_node *node, const char *id)
522 return __of_reset_control_get(node, id, 0, RESET_CONTROL_OPTIONAL_EXCLUSIVE);
526 * of_reset_control_get_shared - Lookup and obtain a shared reference
527 * to a reset controller.
528 * @node: device to be reset by the controller
529 * @id: reset line name
531 * When a reset-control is shared, the behavior of reset_control_assert /
532 * deassert is changed, the reset-core will keep track of a deassert_count
533 * and only (re-)assert the reset after reset_control_assert has been called
534 * as many times as reset_control_deassert was called. Also see the remark
535 * about shared reset-controls in the reset_control_assert docs.
537 * Calling reset_control_assert without first calling reset_control_deassert
538 * is not allowed on a shared reset control. Calling reset_control_reset is
539 * also not allowed on a shared reset control.
540 * Returns a struct reset_control or IS_ERR() condition containing errno.
542 * Use of id names is optional.
544 static inline struct reset_control *of_reset_control_get_shared(
545 struct device_node *node, const char *id)
547 return __of_reset_control_get(node, id, 0, RESET_CONTROL_SHARED);
551 * of_reset_control_get_exclusive_by_index - Lookup and obtain an exclusive
552 * reference to a reset controller
553 * by index.
554 * @node: device to be reset by the controller
555 * @index: index of the reset controller
557 * This is to be used to perform a list of resets for a device or power domain
558 * in whatever order. Returns a struct reset_control or IS_ERR() condition
559 * containing errno.
561 static inline struct reset_control *of_reset_control_get_exclusive_by_index(
562 struct device_node *node, int index)
564 return __of_reset_control_get(node, NULL, index, RESET_CONTROL_EXCLUSIVE);
568 * of_reset_control_get_shared_by_index - Lookup and obtain a shared
569 * reference to a reset controller
570 * by index.
571 * @node: device to be reset by the controller
572 * @index: index of the reset controller
574 * When a reset-control is shared, the behavior of reset_control_assert /
575 * deassert is changed, the reset-core will keep track of a deassert_count
576 * and only (re-)assert the reset after reset_control_assert has been called
577 * as many times as reset_control_deassert was called. Also see the remark
578 * about shared reset-controls in the reset_control_assert docs.
580 * Calling reset_control_assert without first calling reset_control_deassert
581 * is not allowed on a shared reset control. Calling reset_control_reset is
582 * also not allowed on a shared reset control.
583 * Returns a struct reset_control or IS_ERR() condition containing errno.
585 * This is to be used to perform a list of resets for a device or power domain
586 * in whatever order. Returns a struct reset_control or IS_ERR() condition
587 * containing errno.
589 static inline struct reset_control *of_reset_control_get_shared_by_index(
590 struct device_node *node, int index)
592 return __of_reset_control_get(node, NULL, index, RESET_CONTROL_SHARED);
596 * devm_reset_control_get_exclusive - resource managed
597 * reset_control_get_exclusive()
598 * @dev: device to be reset by the controller
599 * @id: reset line name
601 * Managed reset_control_get_exclusive(). For reset controllers returned
602 * from this function, reset_control_put() is called automatically on driver
603 * detach.
605 * See reset_control_get_exclusive() for more information.
607 static inline struct reset_control *
608 __must_check devm_reset_control_get_exclusive(struct device *dev,
609 const char *id)
611 return __devm_reset_control_get(dev, id, 0, RESET_CONTROL_EXCLUSIVE);
615 * devm_reset_control_get_exclusive_deasserted - resource managed
616 * reset_control_get_exclusive() +
617 * reset_control_deassert()
618 * @dev: device to be reset by the controller
619 * @id: reset line name
621 * Managed reset_control_get_exclusive() + reset_control_deassert(). For reset
622 * controllers returned from this function, reset_control_assert() +
623 * reset_control_put() is called automatically on driver detach.
625 * See reset_control_get_exclusive() for more information.
627 static inline struct reset_control * __must_check
628 devm_reset_control_get_exclusive_deasserted(struct device *dev, const char *id)
630 return __devm_reset_control_get(dev, id, 0, RESET_CONTROL_EXCLUSIVE_DEASSERTED);
634 * devm_reset_control_bulk_get_exclusive - resource managed
635 * reset_control_bulk_get_exclusive()
636 * @dev: device to be reset by the controller
637 * @num_rstcs: number of entries in rstcs array
638 * @rstcs: array of struct reset_control_bulk_data with reset line names set
640 * Managed reset_control_bulk_get_exclusive(). For reset controllers returned
641 * from this function, reset_control_put() is called automatically on driver
642 * detach.
644 * See reset_control_bulk_get_exclusive() for more information.
646 static inline int __must_check
647 devm_reset_control_bulk_get_exclusive(struct device *dev, int num_rstcs,
648 struct reset_control_bulk_data *rstcs)
650 return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs,
651 RESET_CONTROL_EXCLUSIVE);
655 * devm_reset_control_get_exclusive_released - resource managed
656 * reset_control_get_exclusive_released()
657 * @dev: device to be reset by the controller
658 * @id: reset line name
660 * Managed reset_control_get_exclusive_released(). For reset controllers
661 * returned from this function, reset_control_put() is called automatically on
662 * driver detach.
664 * See reset_control_get_exclusive_released() for more information.
666 static inline struct reset_control *
667 __must_check devm_reset_control_get_exclusive_released(struct device *dev,
668 const char *id)
670 return __devm_reset_control_get(dev, id, 0, RESET_CONTROL_EXCLUSIVE_RELEASED);
674 * devm_reset_control_bulk_get_exclusive_released - resource managed
675 * reset_control_bulk_get_exclusive_released()
676 * @dev: device to be reset by the controller
677 * @num_rstcs: number of entries in rstcs array
678 * @rstcs: array of struct reset_control_bulk_data with reset line names set
680 * Managed reset_control_bulk_get_exclusive_released(). For reset controllers
681 * returned from this function, reset_control_put() is called automatically on
682 * driver detach.
684 * See reset_control_bulk_get_exclusive_released() for more information.
686 static inline int __must_check
687 devm_reset_control_bulk_get_exclusive_released(struct device *dev, int num_rstcs,
688 struct reset_control_bulk_data *rstcs)
690 return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs,
691 RESET_CONTROL_EXCLUSIVE_RELEASED);
695 * devm_reset_control_get_optional_exclusive_released - resource managed
696 * reset_control_get_optional_exclusive_released()
697 * @dev: device to be reset by the controller
698 * @id: reset line name
700 * Managed-and-optional variant of reset_control_get_exclusive_released(). For
701 * reset controllers returned from this function, reset_control_put() is called
702 * automatically on driver detach.
704 * See reset_control_get_exclusive_released() for more information.
706 static inline struct reset_control *
707 __must_check devm_reset_control_get_optional_exclusive_released(struct device *dev,
708 const char *id)
710 return __devm_reset_control_get(dev, id, 0, RESET_CONTROL_OPTIONAL_EXCLUSIVE_RELEASED);
714 * devm_reset_control_bulk_get_optional_exclusive_released - resource managed
715 * reset_control_bulk_optional_get_exclusive_released()
716 * @dev: device to be reset by the controller
717 * @num_rstcs: number of entries in rstcs array
718 * @rstcs: array of struct reset_control_bulk_data with reset line names set
720 * Managed reset_control_bulk_optional_get_exclusive_released(). For reset
721 * controllers returned from this function, reset_control_put() is called
722 * automatically on driver detach.
724 * See reset_control_bulk_optional_get_exclusive_released() for more information.
726 static inline int __must_check
727 devm_reset_control_bulk_get_optional_exclusive_released(struct device *dev, int num_rstcs,
728 struct reset_control_bulk_data *rstcs)
730 return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs,
731 RESET_CONTROL_OPTIONAL_EXCLUSIVE_RELEASED);
735 * devm_reset_control_get_shared - resource managed reset_control_get_shared()
736 * @dev: device to be reset by the controller
737 * @id: reset line name
739 * Managed reset_control_get_shared(). For reset controllers returned from
740 * this function, reset_control_put() is called automatically on driver detach.
741 * See reset_control_get_shared() for more information.
743 static inline struct reset_control *devm_reset_control_get_shared(
744 struct device *dev, const char *id)
746 return __devm_reset_control_get(dev, id, 0, RESET_CONTROL_SHARED);
750 * devm_reset_control_get_shared_deasserted - resource managed
751 * reset_control_get_shared() +
752 * reset_control_deassert()
753 * @dev: device to be reset by the controller
754 * @id: reset line name
756 * Managed reset_control_get_shared() + reset_control_deassert(). For reset
757 * controllers returned from this function, reset_control_assert() +
758 * reset_control_put() is called automatically on driver detach.
760 * See devm_reset_control_get_shared() for more information.
762 static inline struct reset_control * __must_check
763 devm_reset_control_get_shared_deasserted(struct device *dev, const char *id)
765 return __devm_reset_control_get(dev, id, 0, RESET_CONTROL_SHARED_DEASSERTED);
769 * devm_reset_control_bulk_get_shared - resource managed
770 * reset_control_bulk_get_shared()
771 * @dev: device to be reset by the controller
772 * @num_rstcs: number of entries in rstcs array
773 * @rstcs: array of struct reset_control_bulk_data with reset line names set
775 * Managed reset_control_bulk_get_shared(). For reset controllers returned
776 * from this function, reset_control_put() is called automatically on driver
777 * detach.
779 * See reset_control_bulk_get_shared() for more information.
781 static inline int __must_check
782 devm_reset_control_bulk_get_shared(struct device *dev, int num_rstcs,
783 struct reset_control_bulk_data *rstcs)
785 return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, RESET_CONTROL_SHARED);
789 * devm_reset_control_bulk_get_shared_deasserted - resource managed
790 * reset_control_bulk_get_shared() +
791 * reset_control_bulk_deassert()
792 * @dev: device to be reset by the controller
793 * @num_rstcs: number of entries in rstcs array
794 * @rstcs: array of struct reset_control_bulk_data with reset line names set
796 * Managed reset_control_bulk_get_shared() + reset_control_bulk_deassert(). For
797 * reset controllers returned from this function, reset_control_bulk_assert() +
798 * reset_control_bulk_put() are called automatically on driver detach.
800 * See devm_reset_control_bulk_get_shared() for more information.
802 static inline int __must_check
803 devm_reset_control_bulk_get_shared_deasserted(struct device *dev, int num_rstcs,
804 struct reset_control_bulk_data *rstcs)
806 return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs,
807 RESET_CONTROL_SHARED_DEASSERTED);
811 * devm_reset_control_get_optional_exclusive - resource managed
812 * reset_control_get_optional_exclusive()
813 * @dev: device to be reset by the controller
814 * @id: reset line name
816 * Managed reset_control_get_optional_exclusive(). For reset controllers
817 * returned from this function, reset_control_put() is called automatically on
818 * driver detach.
820 * See reset_control_get_optional_exclusive() for more information.
822 static inline struct reset_control *devm_reset_control_get_optional_exclusive(
823 struct device *dev, const char *id)
825 return __devm_reset_control_get(dev, id, 0, RESET_CONTROL_OPTIONAL_EXCLUSIVE);
829 * devm_reset_control_get_optional_exclusive_deasserted - resource managed
830 * reset_control_get_optional_exclusive() +
831 * reset_control_deassert()
832 * @dev: device to be reset by the controller
833 * @id: reset line name
835 * Managed reset_control_get_optional_exclusive() + reset_control_deassert().
836 * For reset controllers returned from this function, reset_control_assert() +
837 * reset_control_put() is called automatically on driver detach.
839 * See devm_reset_control_get_optional_exclusive() for more information.
841 static inline struct reset_control *
842 devm_reset_control_get_optional_exclusive_deasserted(struct device *dev, const char *id)
844 return __devm_reset_control_get(dev, id, 0, RESET_CONTROL_OPTIONAL_EXCLUSIVE_DEASSERTED);
848 * devm_reset_control_bulk_get_optional_exclusive - resource managed
849 * reset_control_bulk_get_optional_exclusive()
850 * @dev: device to be reset by the controller
851 * @num_rstcs: number of entries in rstcs array
852 * @rstcs: array of struct reset_control_bulk_data with reset line names set
854 * Managed reset_control_bulk_get_optional_exclusive(). For reset controllers
855 * returned from this function, reset_control_put() is called automatically on
856 * driver detach.
858 * See reset_control_bulk_get_optional_exclusive() for more information.
860 static inline int __must_check
861 devm_reset_control_bulk_get_optional_exclusive(struct device *dev, int num_rstcs,
862 struct reset_control_bulk_data *rstcs)
864 return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs,
865 RESET_CONTROL_OPTIONAL_EXCLUSIVE);
869 * devm_reset_control_get_optional_shared - resource managed
870 * reset_control_get_optional_shared()
871 * @dev: device to be reset by the controller
872 * @id: reset line name
874 * Managed reset_control_get_optional_shared(). For reset controllers returned
875 * from this function, reset_control_put() is called automatically on driver
876 * detach.
878 * See reset_control_get_optional_shared() for more information.
880 static inline struct reset_control *devm_reset_control_get_optional_shared(
881 struct device *dev, const char *id)
883 return __devm_reset_control_get(dev, id, 0, RESET_CONTROL_OPTIONAL_SHARED);
887 * devm_reset_control_get_optional_shared_deasserted - resource managed
888 * reset_control_get_optional_shared() +
889 * reset_control_deassert()
890 * @dev: device to be reset by the controller
891 * @id: reset line name
893 * Managed reset_control_get_optional_shared() + reset_control_deassert(). For
894 * reset controllers returned from this function, reset_control_assert() +
895 * reset_control_put() is called automatically on driver detach.
897 * See devm_reset_control_get_optional_shared() for more information.
899 static inline struct reset_control *
900 devm_reset_control_get_optional_shared_deasserted(struct device *dev, const char *id)
902 return __devm_reset_control_get(dev, id, 0, RESET_CONTROL_OPTIONAL_SHARED_DEASSERTED);
906 * devm_reset_control_bulk_get_optional_shared - resource managed
907 * reset_control_bulk_get_optional_shared()
908 * @dev: device to be reset by the controller
909 * @num_rstcs: number of entries in rstcs array
910 * @rstcs: array of struct reset_control_bulk_data with reset line names set
912 * Managed reset_control_bulk_get_optional_shared(). For reset controllers
913 * returned from this function, reset_control_put() is called automatically on
914 * driver detach.
916 * See reset_control_bulk_get_optional_shared() for more information.
918 static inline int __must_check
919 devm_reset_control_bulk_get_optional_shared(struct device *dev, int num_rstcs,
920 struct reset_control_bulk_data *rstcs)
922 return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, RESET_CONTROL_OPTIONAL_SHARED);
926 * devm_reset_control_get_exclusive_by_index - resource managed
927 * reset_control_get_exclusive()
928 * @dev: device to be reset by the controller
929 * @index: index of the reset controller
931 * Managed reset_control_get_exclusive(). For reset controllers returned from
932 * this function, reset_control_put() is called automatically on driver
933 * detach.
935 * See reset_control_get_exclusive() for more information.
937 static inline struct reset_control *
938 devm_reset_control_get_exclusive_by_index(struct device *dev, int index)
940 return __devm_reset_control_get(dev, NULL, index, RESET_CONTROL_EXCLUSIVE);
944 * devm_reset_control_get_shared_by_index - resource managed
945 * reset_control_get_shared
946 * @dev: device to be reset by the controller
947 * @index: index of the reset controller
949 * Managed reset_control_get_shared(). For reset controllers returned from
950 * this function, reset_control_put() is called automatically on driver detach.
951 * See reset_control_get_shared() for more information.
953 static inline struct reset_control *
954 devm_reset_control_get_shared_by_index(struct device *dev, int index)
956 return __devm_reset_control_get(dev, NULL, index, RESET_CONTROL_SHARED);
960 * TEMPORARY calls to use during transition:
962 * of_reset_control_get() => of_reset_control_get_exclusive()
964 * These inline function calls will be removed once all consumers
965 * have been moved over to the new explicit API.
967 static inline struct reset_control *of_reset_control_get(
968 struct device_node *node, const char *id)
970 return of_reset_control_get_exclusive(node, id);
973 static inline struct reset_control *of_reset_control_get_by_index(
974 struct device_node *node, int index)
976 return of_reset_control_get_exclusive_by_index(node, index);
979 static inline struct reset_control *devm_reset_control_get(
980 struct device *dev, const char *id)
982 return devm_reset_control_get_exclusive(dev, id);
985 static inline struct reset_control *devm_reset_control_get_optional(
986 struct device *dev, const char *id)
988 return devm_reset_control_get_optional_exclusive(dev, id);
992 static inline struct reset_control *devm_reset_control_get_by_index(
993 struct device *dev, int index)
995 return devm_reset_control_get_exclusive_by_index(dev, index);
999 * APIs to manage a list of reset controllers
1001 static inline struct reset_control *
1002 devm_reset_control_array_get_exclusive(struct device *dev)
1004 return devm_reset_control_array_get(dev, RESET_CONTROL_EXCLUSIVE);
1007 static inline struct reset_control *
1008 devm_reset_control_array_get_shared(struct device *dev)
1010 return devm_reset_control_array_get(dev, RESET_CONTROL_SHARED);
1013 static inline struct reset_control *
1014 devm_reset_control_array_get_optional_exclusive(struct device *dev)
1016 return devm_reset_control_array_get(dev, RESET_CONTROL_OPTIONAL_EXCLUSIVE);
1019 static inline struct reset_control *
1020 devm_reset_control_array_get_optional_shared(struct device *dev)
1022 return devm_reset_control_array_get(dev, RESET_CONTROL_OPTIONAL_SHARED);
1025 static inline struct reset_control *
1026 of_reset_control_array_get_exclusive(struct device_node *node)
1028 return of_reset_control_array_get(node, RESET_CONTROL_EXCLUSIVE);
1031 static inline struct reset_control *
1032 of_reset_control_array_get_exclusive_released(struct device_node *node)
1034 return of_reset_control_array_get(node, RESET_CONTROL_EXCLUSIVE_RELEASED);
1037 static inline struct reset_control *
1038 of_reset_control_array_get_shared(struct device_node *node)
1040 return of_reset_control_array_get(node, RESET_CONTROL_SHARED);
1043 static inline struct reset_control *
1044 of_reset_control_array_get_optional_exclusive(struct device_node *node)
1046 return of_reset_control_array_get(node, RESET_CONTROL_OPTIONAL_EXCLUSIVE);
1049 static inline struct reset_control *
1050 of_reset_control_array_get_optional_shared(struct device_node *node)
1052 return of_reset_control_array_get(node, RESET_CONTROL_OPTIONAL_SHARED);
1054 #endif