1
2#ifndef _LINUX_RESET_H_
3#define _LINUX_RESET_H_
4
5#include <linux/device.h>
6
7struct reset_control;
8
9#ifdef CONFIG_RESET_CONTROLLER
10
11int reset_control_reset(struct reset_control *rstc);
12int reset_control_assert(struct reset_control *rstc);
13int reset_control_deassert(struct reset_control *rstc);
14int reset_control_status(struct reset_control *rstc);
15
16struct reset_control *__of_reset_control_get(struct device_node *node,
17 const char *id, int index, bool shared,
18 bool optional);
19struct reset_control *__reset_control_get(struct device *dev, const char *id,
20 int index, bool shared,
21 bool optional);
22void reset_control_put(struct reset_control *rstc);
23struct reset_control *__devm_reset_control_get(struct device *dev,
24 const char *id, int index, bool shared,
25 bool optional);
26
27int __must_check device_reset(struct device *dev);
28
29struct reset_control *devm_reset_control_array_get(struct device *dev,
30 bool shared, bool optional);
31struct reset_control *of_reset_control_array_get(struct device_node *np,
32 bool shared, bool optional);
33
34static inline int device_reset_optional(struct device *dev)
35{
36 return device_reset(dev);
37}
38
39#else
40
41static inline int reset_control_reset(struct reset_control *rstc)
42{
43 return 0;
44}
45
46static inline int reset_control_assert(struct reset_control *rstc)
47{
48 return 0;
49}
50
51static inline int reset_control_deassert(struct reset_control *rstc)
52{
53 return 0;
54}
55
56static inline int reset_control_status(struct reset_control *rstc)
57{
58 return 0;
59}
60
61static inline void reset_control_put(struct reset_control *rstc)
62{
63}
64
65static inline int __must_check device_reset(struct device *dev)
66{
67 WARN_ON(1);
68 return -ENOTSUPP;
69}
70
71static inline int device_reset_optional(struct device *dev)
72{
73 return -ENOTSUPP;
74}
75
76static inline struct reset_control *__of_reset_control_get(
77 struct device_node *node,
78 const char *id, int index, bool shared,
79 bool optional)
80{
81 return optional ? NULL : ERR_PTR(-ENOTSUPP);
82}
83
84static inline struct reset_control *__reset_control_get(
85 struct device *dev, const char *id,
86 int index, bool shared, bool optional)
87{
88 return optional ? NULL : ERR_PTR(-ENOTSUPP);
89}
90
91static inline struct reset_control *__devm_reset_control_get(
92 struct device *dev, const char *id,
93 int index, bool shared, bool optional)
94{
95 return optional ? NULL : ERR_PTR(-ENOTSUPP);
96}
97
98static inline struct reset_control *
99devm_reset_control_array_get(struct device *dev, bool shared, bool optional)
100{
101 return optional ? NULL : ERR_PTR(-ENOTSUPP);
102}
103
104static inline struct reset_control *
105of_reset_control_array_get(struct device_node *np, bool shared, bool optional)
106{
107 return optional ? NULL : ERR_PTR(-ENOTSUPP);
108}
109
110#endif
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127static inline struct reset_control *
128__must_check reset_control_get_exclusive(struct device *dev, const char *id)
129{
130#ifndef CONFIG_RESET_CONTROLLER
131 WARN_ON(1);
132#endif
133 return __reset_control_get(dev, id, 0, false, false);
134}
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158static inline struct reset_control *reset_control_get_shared(
159 struct device *dev, const char *id)
160{
161 return __reset_control_get(dev, id, 0, true, false);
162}
163
164static inline struct reset_control *reset_control_get_optional_exclusive(
165 struct device *dev, const char *id)
166{
167 return __reset_control_get(dev, id, 0, false, true);
168}
169
170static inline struct reset_control *reset_control_get_optional_shared(
171 struct device *dev, const char *id)
172{
173 return __reset_control_get(dev, id, 0, true, true);
174}
175
176
177
178
179
180
181
182
183
184
185
186static inline struct reset_control *of_reset_control_get_exclusive(
187 struct device_node *node, const char *id)
188{
189 return __of_reset_control_get(node, id, 0, false, false);
190}
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211static inline struct reset_control *of_reset_control_get_shared(
212 struct device_node *node, const char *id)
213{
214 return __of_reset_control_get(node, id, 0, true, false);
215}
216
217
218
219
220
221
222
223
224
225
226
227
228static inline struct reset_control *of_reset_control_get_exclusive_by_index(
229 struct device_node *node, int index)
230{
231 return __of_reset_control_get(node, NULL, index, false, false);
232}
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256static inline struct reset_control *of_reset_control_get_shared_by_index(
257 struct device_node *node, int index)
258{
259 return __of_reset_control_get(node, NULL, index, true, false);
260}
261
262
263
264
265
266
267
268
269
270
271
272
273
274static inline struct reset_control *
275__must_check devm_reset_control_get_exclusive(struct device *dev,
276 const char *id)
277{
278#ifndef CONFIG_RESET_CONTROLLER
279 WARN_ON(1);
280#endif
281 return __devm_reset_control_get(dev, id, 0, false, false);
282}
283
284
285
286
287
288
289
290
291
292
293static inline struct reset_control *devm_reset_control_get_shared(
294 struct device *dev, const char *id)
295{
296 return __devm_reset_control_get(dev, id, 0, true, false);
297}
298
299static inline struct reset_control *devm_reset_control_get_optional_exclusive(
300 struct device *dev, const char *id)
301{
302 return __devm_reset_control_get(dev, id, 0, false, true);
303}
304
305static inline struct reset_control *devm_reset_control_get_optional_shared(
306 struct device *dev, const char *id)
307{
308 return __devm_reset_control_get(dev, id, 0, true, true);
309}
310
311
312
313
314
315
316
317
318
319
320
321
322
323static inline struct reset_control *
324devm_reset_control_get_exclusive_by_index(struct device *dev, int index)
325{
326 return __devm_reset_control_get(dev, NULL, index, false, false);
327}
328
329
330
331
332
333
334
335
336
337
338
339static inline struct reset_control *
340devm_reset_control_get_shared_by_index(struct device *dev, int index)
341{
342 return __devm_reset_control_get(dev, NULL, index, true, false);
343}
344
345
346
347
348
349
350
351
352
353static inline struct reset_control *reset_control_get(
354 struct device *dev, const char *id)
355{
356 return reset_control_get_exclusive(dev, id);
357}
358
359static inline struct reset_control *reset_control_get_optional(
360 struct device *dev, const char *id)
361{
362 return reset_control_get_optional_exclusive(dev, id);
363}
364
365static inline struct reset_control *of_reset_control_get(
366 struct device_node *node, const char *id)
367{
368 return of_reset_control_get_exclusive(node, id);
369}
370
371static inline struct reset_control *of_reset_control_get_by_index(
372 struct device_node *node, int index)
373{
374 return of_reset_control_get_exclusive_by_index(node, index);
375}
376
377static inline struct reset_control *devm_reset_control_get(
378 struct device *dev, const char *id)
379{
380 return devm_reset_control_get_exclusive(dev, id);
381}
382
383static inline struct reset_control *devm_reset_control_get_optional(
384 struct device *dev, const char *id)
385{
386 return devm_reset_control_get_optional_exclusive(dev, id);
387
388}
389
390static inline struct reset_control *devm_reset_control_get_by_index(
391 struct device *dev, int index)
392{
393 return devm_reset_control_get_exclusive_by_index(dev, index);
394}
395
396
397
398
399static inline struct reset_control *
400devm_reset_control_array_get_exclusive(struct device *dev)
401{
402 return devm_reset_control_array_get(dev, false, false);
403}
404
405static inline struct reset_control *
406devm_reset_control_array_get_shared(struct device *dev)
407{
408 return devm_reset_control_array_get(dev, true, false);
409}
410
411static inline struct reset_control *
412devm_reset_control_array_get_optional_exclusive(struct device *dev)
413{
414 return devm_reset_control_array_get(dev, false, true);
415}
416
417static inline struct reset_control *
418devm_reset_control_array_get_optional_shared(struct device *dev)
419{
420 return devm_reset_control_array_get(dev, true, true);
421}
422
423static inline struct reset_control *
424of_reset_control_array_get_exclusive(struct device_node *node)
425{
426 return of_reset_control_array_get(node, false, false);
427}
428
429static inline struct reset_control *
430of_reset_control_array_get_shared(struct device_node *node)
431{
432 return of_reset_control_array_get(node, true, false);
433}
434
435static inline struct reset_control *
436of_reset_control_array_get_optional_exclusive(struct device_node *node)
437{
438 return of_reset_control_array_get(node, false, true);
439}
440
441static inline struct reset_control *
442of_reset_control_array_get_optional_shared(struct device_node *node)
443{
444 return of_reset_control_array_get(node, true, true);
445}
446#endif
447