0001
0002 #ifndef _LINUX_RESET_H_
0003 #define _LINUX_RESET_H_
0004
0005 #include <linux/err.h>
0006 #include <linux/errno.h>
0007 #include <linux/types.h>
0008
0009 struct device;
0010 struct device_node;
0011 struct reset_control;
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 struct reset_control_bulk_data {
0024 const char *id;
0025 struct reset_control *rstc;
0026 };
0027
0028 #ifdef CONFIG_RESET_CONTROLLER
0029
0030 int reset_control_reset(struct reset_control *rstc);
0031 int reset_control_rearm(struct reset_control *rstc);
0032 int reset_control_assert(struct reset_control *rstc);
0033 int reset_control_deassert(struct reset_control *rstc);
0034 int reset_control_status(struct reset_control *rstc);
0035 int reset_control_acquire(struct reset_control *rstc);
0036 void reset_control_release(struct reset_control *rstc);
0037
0038 int reset_control_bulk_reset(int num_rstcs, struct reset_control_bulk_data *rstcs);
0039 int reset_control_bulk_assert(int num_rstcs, struct reset_control_bulk_data *rstcs);
0040 int reset_control_bulk_deassert(int num_rstcs, struct reset_control_bulk_data *rstcs);
0041 int reset_control_bulk_acquire(int num_rstcs, struct reset_control_bulk_data *rstcs);
0042 void reset_control_bulk_release(int num_rstcs, struct reset_control_bulk_data *rstcs);
0043
0044 struct reset_control *__of_reset_control_get(struct device_node *node,
0045 const char *id, int index, bool shared,
0046 bool optional, bool acquired);
0047 struct reset_control *__reset_control_get(struct device *dev, const char *id,
0048 int index, bool shared,
0049 bool optional, bool acquired);
0050 void reset_control_put(struct reset_control *rstc);
0051 int __reset_control_bulk_get(struct device *dev, int num_rstcs,
0052 struct reset_control_bulk_data *rstcs,
0053 bool shared, bool optional, bool acquired);
0054 void reset_control_bulk_put(int num_rstcs, struct reset_control_bulk_data *rstcs);
0055
0056 int __device_reset(struct device *dev, bool optional);
0057 struct reset_control *__devm_reset_control_get(struct device *dev,
0058 const char *id, int index, bool shared,
0059 bool optional, bool acquired);
0060 int __devm_reset_control_bulk_get(struct device *dev, int num_rstcs,
0061 struct reset_control_bulk_data *rstcs,
0062 bool shared, bool optional, bool acquired);
0063
0064 struct reset_control *devm_reset_control_array_get(struct device *dev,
0065 bool shared, bool optional);
0066 struct reset_control *of_reset_control_array_get(struct device_node *np,
0067 bool shared, bool optional,
0068 bool acquired);
0069
0070 int reset_control_get_count(struct device *dev);
0071
0072 #else
0073
0074 static inline int reset_control_reset(struct reset_control *rstc)
0075 {
0076 return 0;
0077 }
0078
0079 static inline int reset_control_rearm(struct reset_control *rstc)
0080 {
0081 return 0;
0082 }
0083
0084 static inline int reset_control_assert(struct reset_control *rstc)
0085 {
0086 return 0;
0087 }
0088
0089 static inline int reset_control_deassert(struct reset_control *rstc)
0090 {
0091 return 0;
0092 }
0093
0094 static inline int reset_control_status(struct reset_control *rstc)
0095 {
0096 return 0;
0097 }
0098
0099 static inline int reset_control_acquire(struct reset_control *rstc)
0100 {
0101 return 0;
0102 }
0103
0104 static inline void reset_control_release(struct reset_control *rstc)
0105 {
0106 }
0107
0108 static inline void reset_control_put(struct reset_control *rstc)
0109 {
0110 }
0111
0112 static inline int __device_reset(struct device *dev, bool optional)
0113 {
0114 return optional ? 0 : -ENOTSUPP;
0115 }
0116
0117 static inline struct reset_control *__of_reset_control_get(
0118 struct device_node *node,
0119 const char *id, int index, bool shared,
0120 bool optional, bool acquired)
0121 {
0122 return optional ? NULL : ERR_PTR(-ENOTSUPP);
0123 }
0124
0125 static inline struct reset_control *__reset_control_get(
0126 struct device *dev, const char *id,
0127 int index, bool shared, bool optional,
0128 bool acquired)
0129 {
0130 return optional ? NULL : ERR_PTR(-ENOTSUPP);
0131 }
0132
0133 static inline int
0134 reset_control_bulk_reset(int num_rstcs, struct reset_control_bulk_data *rstcs)
0135 {
0136 return 0;
0137 }
0138
0139 static inline int
0140 reset_control_bulk_assert(int num_rstcs, struct reset_control_bulk_data *rstcs)
0141 {
0142 return 0;
0143 }
0144
0145 static inline int
0146 reset_control_bulk_deassert(int num_rstcs, struct reset_control_bulk_data *rstcs)
0147 {
0148 return 0;
0149 }
0150
0151 static inline int
0152 reset_control_bulk_acquire(int num_rstcs, struct reset_control_bulk_data *rstcs)
0153 {
0154 return 0;
0155 }
0156
0157 static inline void
0158 reset_control_bulk_release(int num_rstcs, struct reset_control_bulk_data *rstcs)
0159 {
0160 }
0161
0162 static inline int
0163 __reset_control_bulk_get(struct device *dev, int num_rstcs,
0164 struct reset_control_bulk_data *rstcs,
0165 bool shared, bool optional, bool acquired)
0166 {
0167 return optional ? 0 : -EOPNOTSUPP;
0168 }
0169
0170 static inline void
0171 reset_control_bulk_put(int num_rstcs, struct reset_control_bulk_data *rstcs)
0172 {
0173 }
0174
0175 static inline struct reset_control *__devm_reset_control_get(
0176 struct device *dev, const char *id,
0177 int index, bool shared, bool optional,
0178 bool acquired)
0179 {
0180 return optional ? NULL : ERR_PTR(-ENOTSUPP);
0181 }
0182
0183 static inline int
0184 __devm_reset_control_bulk_get(struct device *dev, int num_rstcs,
0185 struct reset_control_bulk_data *rstcs,
0186 bool shared, bool optional, bool acquired)
0187 {
0188 return optional ? 0 : -EOPNOTSUPP;
0189 }
0190
0191 static inline struct reset_control *
0192 devm_reset_control_array_get(struct device *dev, bool shared, bool optional)
0193 {
0194 return optional ? NULL : ERR_PTR(-ENOTSUPP);
0195 }
0196
0197 static inline struct reset_control *
0198 of_reset_control_array_get(struct device_node *np, bool shared, bool optional,
0199 bool acquired)
0200 {
0201 return optional ? NULL : ERR_PTR(-ENOTSUPP);
0202 }
0203
0204 static inline int reset_control_get_count(struct device *dev)
0205 {
0206 return -ENOENT;
0207 }
0208
0209 #endif
0210
0211 static inline int __must_check device_reset(struct device *dev)
0212 {
0213 return __device_reset(dev, false);
0214 }
0215
0216 static inline int device_reset_optional(struct device *dev)
0217 {
0218 return __device_reset(dev, true);
0219 }
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236 static inline struct reset_control *
0237 __must_check reset_control_get_exclusive(struct device *dev, const char *id)
0238 {
0239 return __reset_control_get(dev, id, 0, false, false, true);
0240 }
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252 static inline int __must_check
0253 reset_control_bulk_get_exclusive(struct device *dev, int num_rstcs,
0254 struct reset_control_bulk_data *rstcs)
0255 {
0256 return __reset_control_bulk_get(dev, num_rstcs, rstcs, false, false, true);
0257 }
0258
0259
0260
0261
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273 static inline struct reset_control *
0274 __must_check reset_control_get_exclusive_released(struct device *dev,
0275 const char *id)
0276 {
0277 return __reset_control_get(dev, id, 0, false, false, false);
0278 }
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294 static inline int __must_check
0295 reset_control_bulk_get_exclusive_released(struct device *dev, int num_rstcs,
0296 struct reset_control_bulk_data *rstcs)
0297 {
0298 return __reset_control_bulk_get(dev, num_rstcs, rstcs, false, false, false);
0299 }
0300
0301
0302
0303
0304
0305
0306
0307
0308
0309
0310
0311
0312
0313
0314
0315 static inline int __must_check
0316 reset_control_bulk_get_optional_exclusive_released(struct device *dev, int num_rstcs,
0317 struct reset_control_bulk_data *rstcs)
0318 {
0319 return __reset_control_bulk_get(dev, num_rstcs, rstcs, false, true, false);
0320 }
0321
0322
0323
0324
0325
0326
0327
0328
0329
0330
0331
0332
0333
0334
0335
0336
0337
0338
0339
0340
0341
0342
0343
0344 static inline struct reset_control *reset_control_get_shared(
0345 struct device *dev, const char *id)
0346 {
0347 return __reset_control_get(dev, id, 0, true, false, false);
0348 }
0349
0350
0351
0352
0353
0354
0355
0356
0357
0358
0359
0360 static inline int __must_check
0361 reset_control_bulk_get_shared(struct device *dev, int num_rstcs,
0362 struct reset_control_bulk_data *rstcs)
0363 {
0364 return __reset_control_bulk_get(dev, num_rstcs, rstcs, true, false, false);
0365 }
0366
0367
0368
0369
0370
0371
0372
0373
0374
0375
0376
0377
0378 static inline struct reset_control *reset_control_get_optional_exclusive(
0379 struct device *dev, const char *id)
0380 {
0381 return __reset_control_get(dev, id, 0, false, true, true);
0382 }
0383
0384
0385
0386
0387
0388
0389
0390
0391
0392
0393
0394
0395
0396
0397 static inline int __must_check
0398 reset_control_bulk_get_optional_exclusive(struct device *dev, int num_rstcs,
0399 struct reset_control_bulk_data *rstcs)
0400 {
0401 return __reset_control_bulk_get(dev, num_rstcs, rstcs, false, true, true);
0402 }
0403
0404
0405
0406
0407
0408
0409
0410
0411
0412
0413
0414
0415 static inline struct reset_control *reset_control_get_optional_shared(
0416 struct device *dev, const char *id)
0417 {
0418 return __reset_control_get(dev, id, 0, true, true, false);
0419 }
0420
0421
0422
0423
0424
0425
0426
0427
0428
0429
0430
0431
0432
0433
0434 static inline int __must_check
0435 reset_control_bulk_get_optional_shared(struct device *dev, int num_rstcs,
0436 struct reset_control_bulk_data *rstcs)
0437 {
0438 return __reset_control_bulk_get(dev, num_rstcs, rstcs, true, true, false);
0439 }
0440
0441
0442
0443
0444
0445
0446
0447
0448
0449
0450
0451 static inline struct reset_control *of_reset_control_get_exclusive(
0452 struct device_node *node, const char *id)
0453 {
0454 return __of_reset_control_get(node, id, 0, false, false, true);
0455 }
0456
0457
0458
0459
0460
0461
0462
0463
0464
0465
0466
0467
0468
0469
0470
0471 static inline struct reset_control *of_reset_control_get_optional_exclusive(
0472 struct device_node *node, const char *id)
0473 {
0474 return __of_reset_control_get(node, id, 0, false, true, true);
0475 }
0476
0477
0478
0479
0480
0481
0482
0483
0484
0485
0486
0487
0488
0489
0490
0491
0492
0493
0494
0495
0496 static inline struct reset_control *of_reset_control_get_shared(
0497 struct device_node *node, const char *id)
0498 {
0499 return __of_reset_control_get(node, id, 0, true, false, false);
0500 }
0501
0502
0503
0504
0505
0506
0507
0508
0509
0510
0511
0512
0513 static inline struct reset_control *of_reset_control_get_exclusive_by_index(
0514 struct device_node *node, int index)
0515 {
0516 return __of_reset_control_get(node, NULL, index, false, false, true);
0517 }
0518
0519
0520
0521
0522
0523
0524
0525
0526
0527
0528
0529
0530
0531
0532
0533
0534
0535
0536
0537
0538
0539
0540
0541 static inline struct reset_control *of_reset_control_get_shared_by_index(
0542 struct device_node *node, int index)
0543 {
0544 return __of_reset_control_get(node, NULL, index, true, false, false);
0545 }
0546
0547
0548
0549
0550
0551
0552
0553
0554
0555
0556
0557
0558
0559 static inline struct reset_control *
0560 __must_check devm_reset_control_get_exclusive(struct device *dev,
0561 const char *id)
0562 {
0563 return __devm_reset_control_get(dev, id, 0, false, false, true);
0564 }
0565
0566
0567
0568
0569
0570
0571
0572
0573
0574
0575
0576
0577
0578
0579 static inline int __must_check
0580 devm_reset_control_bulk_get_exclusive(struct device *dev, int num_rstcs,
0581 struct reset_control_bulk_data *rstcs)
0582 {
0583 return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, false, false, true);
0584 }
0585
0586
0587
0588
0589
0590
0591
0592
0593
0594
0595
0596
0597
0598 static inline struct reset_control *
0599 __must_check devm_reset_control_get_exclusive_released(struct device *dev,
0600 const char *id)
0601 {
0602 return __devm_reset_control_get(dev, id, 0, false, false, false);
0603 }
0604
0605
0606
0607
0608
0609
0610
0611
0612
0613
0614
0615
0616
0617
0618 static inline int __must_check
0619 devm_reset_control_bulk_get_exclusive_released(struct device *dev, int num_rstcs,
0620 struct reset_control_bulk_data *rstcs)
0621 {
0622 return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, false, false, false);
0623 }
0624
0625
0626
0627
0628
0629
0630
0631
0632
0633
0634
0635
0636
0637 static inline struct reset_control *
0638 __must_check devm_reset_control_get_optional_exclusive_released(struct device *dev,
0639 const char *id)
0640 {
0641 return __devm_reset_control_get(dev, id, 0, false, true, false);
0642 }
0643
0644
0645
0646
0647
0648
0649
0650
0651
0652
0653
0654
0655
0656
0657 static inline int __must_check
0658 devm_reset_control_bulk_get_optional_exclusive_released(struct device *dev, int num_rstcs,
0659 struct reset_control_bulk_data *rstcs)
0660 {
0661 return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, false, true, false);
0662 }
0663
0664
0665
0666
0667
0668
0669
0670
0671
0672
0673 static inline struct reset_control *devm_reset_control_get_shared(
0674 struct device *dev, const char *id)
0675 {
0676 return __devm_reset_control_get(dev, id, 0, true, false, false);
0677 }
0678
0679
0680
0681
0682
0683
0684
0685
0686
0687
0688
0689
0690
0691
0692 static inline int __must_check
0693 devm_reset_control_bulk_get_shared(struct device *dev, int num_rstcs,
0694 struct reset_control_bulk_data *rstcs)
0695 {
0696 return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, true, false, false);
0697 }
0698
0699
0700
0701
0702
0703
0704
0705
0706
0707
0708
0709
0710
0711 static inline struct reset_control *devm_reset_control_get_optional_exclusive(
0712 struct device *dev, const char *id)
0713 {
0714 return __devm_reset_control_get(dev, id, 0, false, true, true);
0715 }
0716
0717
0718
0719
0720
0721
0722
0723
0724
0725
0726
0727
0728
0729
0730 static inline int __must_check
0731 devm_reset_control_bulk_get_optional_exclusive(struct device *dev, int num_rstcs,
0732 struct reset_control_bulk_data *rstcs)
0733 {
0734 return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, false, true, true);
0735 }
0736
0737
0738
0739
0740
0741
0742
0743
0744
0745
0746
0747
0748
0749 static inline struct reset_control *devm_reset_control_get_optional_shared(
0750 struct device *dev, const char *id)
0751 {
0752 return __devm_reset_control_get(dev, id, 0, true, true, false);
0753 }
0754
0755
0756
0757
0758
0759
0760
0761
0762
0763
0764
0765
0766
0767
0768 static inline int __must_check
0769 devm_reset_control_bulk_get_optional_shared(struct device *dev, int num_rstcs,
0770 struct reset_control_bulk_data *rstcs)
0771 {
0772 return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, true, true, false);
0773 }
0774
0775
0776
0777
0778
0779
0780
0781
0782
0783
0784
0785
0786
0787 static inline struct reset_control *
0788 devm_reset_control_get_exclusive_by_index(struct device *dev, int index)
0789 {
0790 return __devm_reset_control_get(dev, NULL, index, false, false, true);
0791 }
0792
0793
0794
0795
0796
0797
0798
0799
0800
0801
0802
0803 static inline struct reset_control *
0804 devm_reset_control_get_shared_by_index(struct device *dev, int index)
0805 {
0806 return __devm_reset_control_get(dev, NULL, index, true, false, false);
0807 }
0808
0809
0810
0811
0812
0813
0814
0815
0816
0817 static inline struct reset_control *of_reset_control_get(
0818 struct device_node *node, const char *id)
0819 {
0820 return of_reset_control_get_exclusive(node, id);
0821 }
0822
0823 static inline struct reset_control *of_reset_control_get_by_index(
0824 struct device_node *node, int index)
0825 {
0826 return of_reset_control_get_exclusive_by_index(node, index);
0827 }
0828
0829 static inline struct reset_control *devm_reset_control_get(
0830 struct device *dev, const char *id)
0831 {
0832 return devm_reset_control_get_exclusive(dev, id);
0833 }
0834
0835 static inline struct reset_control *devm_reset_control_get_optional(
0836 struct device *dev, const char *id)
0837 {
0838 return devm_reset_control_get_optional_exclusive(dev, id);
0839
0840 }
0841
0842 static inline struct reset_control *devm_reset_control_get_by_index(
0843 struct device *dev, int index)
0844 {
0845 return devm_reset_control_get_exclusive_by_index(dev, index);
0846 }
0847
0848
0849
0850
0851 static inline struct reset_control *
0852 devm_reset_control_array_get_exclusive(struct device *dev)
0853 {
0854 return devm_reset_control_array_get(dev, false, false);
0855 }
0856
0857 static inline struct reset_control *
0858 devm_reset_control_array_get_shared(struct device *dev)
0859 {
0860 return devm_reset_control_array_get(dev, true, false);
0861 }
0862
0863 static inline struct reset_control *
0864 devm_reset_control_array_get_optional_exclusive(struct device *dev)
0865 {
0866 return devm_reset_control_array_get(dev, false, true);
0867 }
0868
0869 static inline struct reset_control *
0870 devm_reset_control_array_get_optional_shared(struct device *dev)
0871 {
0872 return devm_reset_control_array_get(dev, true, true);
0873 }
0874
0875 static inline struct reset_control *
0876 of_reset_control_array_get_exclusive(struct device_node *node)
0877 {
0878 return of_reset_control_array_get(node, false, false, true);
0879 }
0880
0881 static inline struct reset_control *
0882 of_reset_control_array_get_exclusive_released(struct device_node *node)
0883 {
0884 return of_reset_control_array_get(node, false, false, false);
0885 }
0886
0887 static inline struct reset_control *
0888 of_reset_control_array_get_shared(struct device_node *node)
0889 {
0890 return of_reset_control_array_get(node, true, false, true);
0891 }
0892
0893 static inline struct reset_control *
0894 of_reset_control_array_get_optional_exclusive(struct device_node *node)
0895 {
0896 return of_reset_control_array_get(node, false, true, true);
0897 }
0898
0899 static inline struct reset_control *
0900 of_reset_control_array_get_optional_shared(struct device_node *node)
0901 {
0902 return of_reset_control_array_get(node, true, true, true);
0903 }
0904 #endif