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