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