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#ifdef CONFIG_RESET_CONTROLLER
14
15int reset_control_reset(struct reset_control *rstc);
16int reset_control_assert(struct reset_control *rstc);
17int reset_control_deassert(struct reset_control *rstc);
18int reset_control_status(struct reset_control *rstc);
19int reset_control_acquire(struct reset_control *rstc);
20void reset_control_release(struct reset_control *rstc);
21
22struct reset_control *__of_reset_control_get(struct device_node *node,
23 const char *id, int index, bool shared,
24 bool optional, bool acquired);
25struct reset_control *__reset_control_get(struct device *dev, const char *id,
26 int index, bool shared,
27 bool optional, bool acquired);
28void reset_control_put(struct reset_control *rstc);
29int __device_reset(struct device *dev, bool optional);
30struct reset_control *__devm_reset_control_get(struct device *dev,
31 const char *id, int index, bool shared,
32 bool optional, bool acquired);
33
34struct reset_control *devm_reset_control_array_get(struct device *dev,
35 bool shared, bool optional);
36struct reset_control *of_reset_control_array_get(struct device_node *np,
37 bool shared, bool optional,
38 bool acquired);
39
40int reset_control_get_count(struct device *dev);
41
42#else
43
44static inline int reset_control_reset(struct reset_control *rstc)
45{
46 return 0;
47}
48
49static inline int reset_control_assert(struct reset_control *rstc)
50{
51 return 0;
52}
53
54static inline int reset_control_deassert(struct reset_control *rstc)
55{
56 return 0;
57}
58
59static inline int reset_control_status(struct reset_control *rstc)
60{
61 return 0;
62}
63
64static inline int reset_control_acquire(struct reset_control *rstc)
65{
66 return 0;
67}
68
69static inline void reset_control_release(struct reset_control *rstc)
70{
71}
72
73static inline void reset_control_put(struct reset_control *rstc)
74{
75}
76
77static inline int __device_reset(struct device *dev, bool optional)
78{
79 return optional ? 0 : -ENOTSUPP;
80}
81
82static inline struct reset_control *__of_reset_control_get(
83 struct device_node *node,
84 const char *id, int index, bool shared,
85 bool optional, bool acquired)
86{
87 return optional ? NULL : ERR_PTR(-ENOTSUPP);
88}
89
90static inline struct reset_control *__reset_control_get(
91 struct device *dev, const char *id,
92 int index, bool shared, bool optional,
93 bool acquired)
94{
95 return optional ? NULL : ERR_PTR(-ENOTSUPP);
96}
97
98static inline struct reset_control *__devm_reset_control_get(
99 struct device *dev, const char *id,
100 int index, bool shared, bool optional,
101 bool acquired)
102{
103 return optional ? NULL : ERR_PTR(-ENOTSUPP);
104}
105
106static inline struct reset_control *
107devm_reset_control_array_get(struct device *dev, bool shared, bool optional)
108{
109 return optional ? NULL : ERR_PTR(-ENOTSUPP);
110}
111
112static inline struct reset_control *
113of_reset_control_array_get(struct device_node *np, bool shared, bool optional,
114 bool acquired)
115{
116 return optional ? NULL : ERR_PTR(-ENOTSUPP);
117}
118
119static inline int reset_control_get_count(struct device *dev)
120{
121 return -ENOENT;
122}
123
124#endif
125
126static inline int __must_check device_reset(struct device *dev)
127{
128 return __device_reset(dev, false);
129}
130
131static inline int device_reset_optional(struct device *dev)
132{
133 return __device_reset(dev, true);
134}
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151static inline struct reset_control *
152__must_check reset_control_get_exclusive(struct device *dev, const char *id)
153{
154 return __reset_control_get(dev, id, 0, false, false, true);
155}
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171static inline struct reset_control *
172__must_check reset_control_get_exclusive_released(struct device *dev,
173 const char *id)
174{
175 return __reset_control_get(dev, id, 0, false, false, false);
176}
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200static inline struct reset_control *reset_control_get_shared(
201 struct device *dev, const char *id)
202{
203 return __reset_control_get(dev, id, 0, true, false, false);
204}
205
206
207
208
209
210
211
212
213
214
215
216
217static inline struct reset_control *reset_control_get_optional_exclusive(
218 struct device *dev, const char *id)
219{
220 return __reset_control_get(dev, id, 0, false, true, true);
221}
222
223
224
225
226
227
228
229
230
231
232
233
234static inline struct reset_control *reset_control_get_optional_shared(
235 struct device *dev, const char *id)
236{
237 return __reset_control_get(dev, id, 0, true, true, false);
238}
239
240
241
242
243
244
245
246
247
248
249
250static inline struct reset_control *of_reset_control_get_exclusive(
251 struct device_node *node, const char *id)
252{
253 return __of_reset_control_get(node, id, 0, false, false, true);
254}
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275static inline struct reset_control *of_reset_control_get_shared(
276 struct device_node *node, const char *id)
277{
278 return __of_reset_control_get(node, id, 0, true, false, false);
279}
280
281
282
283
284
285
286
287
288
289
290
291
292static inline struct reset_control *of_reset_control_get_exclusive_by_index(
293 struct device_node *node, int index)
294{
295 return __of_reset_control_get(node, NULL, index, false, false, true);
296}
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320static inline struct reset_control *of_reset_control_get_shared_by_index(
321 struct device_node *node, int index)
322{
323 return __of_reset_control_get(node, NULL, index, true, false, false);
324}
325
326
327
328
329
330
331
332
333
334
335
336
337
338static inline struct reset_control *
339__must_check devm_reset_control_get_exclusive(struct device *dev,
340 const char *id)
341{
342 return __devm_reset_control_get(dev, id, 0, false, false, true);
343}
344
345
346
347
348
349
350
351
352
353
354
355
356
357static inline struct reset_control *
358__must_check devm_reset_control_get_exclusive_released(struct device *dev,
359 const char *id)
360{
361 return __devm_reset_control_get(dev, id, 0, false, false, false);
362}
363
364
365
366
367
368
369
370
371
372
373static inline struct reset_control *devm_reset_control_get_shared(
374 struct device *dev, const char *id)
375{
376 return __devm_reset_control_get(dev, id, 0, true, false, false);
377}
378
379
380
381
382
383
384
385
386
387
388
389
390
391static inline struct reset_control *devm_reset_control_get_optional_exclusive(
392 struct device *dev, const char *id)
393{
394 return __devm_reset_control_get(dev, id, 0, false, true, true);
395}
396
397
398
399
400
401
402
403
404
405
406
407
408
409static inline struct reset_control *devm_reset_control_get_optional_shared(
410 struct device *dev, const char *id)
411{
412 return __devm_reset_control_get(dev, id, 0, true, true, false);
413}
414
415
416
417
418
419
420
421
422
423
424
425
426
427static inline struct reset_control *
428devm_reset_control_get_exclusive_by_index(struct device *dev, int index)
429{
430 return __devm_reset_control_get(dev, NULL, index, false, false, true);
431}
432
433
434
435
436
437
438
439
440
441
442
443static inline struct reset_control *
444devm_reset_control_get_shared_by_index(struct device *dev, int index)
445{
446 return __devm_reset_control_get(dev, NULL, index, true, false, false);
447}
448
449
450
451
452
453
454
455
456
457static inline struct reset_control *of_reset_control_get(
458 struct device_node *node, const char *id)
459{
460 return of_reset_control_get_exclusive(node, id);
461}
462
463static inline struct reset_control *of_reset_control_get_by_index(
464 struct device_node *node, int index)
465{
466 return of_reset_control_get_exclusive_by_index(node, index);
467}
468
469static inline struct reset_control *devm_reset_control_get(
470 struct device *dev, const char *id)
471{
472 return devm_reset_control_get_exclusive(dev, id);
473}
474
475static inline struct reset_control *devm_reset_control_get_optional(
476 struct device *dev, const char *id)
477{
478 return devm_reset_control_get_optional_exclusive(dev, id);
479
480}
481
482static inline struct reset_control *devm_reset_control_get_by_index(
483 struct device *dev, int index)
484{
485 return devm_reset_control_get_exclusive_by_index(dev, index);
486}
487
488
489
490
491static inline struct reset_control *
492devm_reset_control_array_get_exclusive(struct device *dev)
493{
494 return devm_reset_control_array_get(dev, false, false);
495}
496
497static inline struct reset_control *
498devm_reset_control_array_get_shared(struct device *dev)
499{
500 return devm_reset_control_array_get(dev, true, false);
501}
502
503static inline struct reset_control *
504devm_reset_control_array_get_optional_exclusive(struct device *dev)
505{
506 return devm_reset_control_array_get(dev, false, true);
507}
508
509static inline struct reset_control *
510devm_reset_control_array_get_optional_shared(struct device *dev)
511{
512 return devm_reset_control_array_get(dev, true, true);
513}
514
515static inline struct reset_control *
516of_reset_control_array_get_exclusive(struct device_node *node)
517{
518 return of_reset_control_array_get(node, false, false, true);
519}
520
521static inline struct reset_control *
522of_reset_control_array_get_exclusive_released(struct device_node *node)
523{
524 return of_reset_control_array_get(node, false, false, false);
525}
526
527static inline struct reset_control *
528of_reset_control_array_get_shared(struct device_node *node)
529{
530 return of_reset_control_array_get(node, true, false, true);
531}
532
533static inline struct reset_control *
534of_reset_control_array_get_optional_exclusive(struct device_node *node)
535{
536 return of_reset_control_array_get(node, false, true, true);
537}
538
539static inline struct reset_control *
540of_reset_control_array_get_optional_shared(struct device_node *node)
541{
542 return of_reset_control_array_get(node, true, true, true);
543}
544#endif
545