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