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