1#ifndef _LINUX_RESET_H_
2#define _LINUX_RESET_H_
3
4#include <linux/device.h>
5
6struct reset_control;
7
8#ifdef CONFIG_RESET_CONTROLLER
9
10int reset_control_reset(struct reset_control *rstc);
11int reset_control_assert(struct reset_control *rstc);
12int reset_control_deassert(struct reset_control *rstc);
13int reset_control_status(struct reset_control *rstc);
14
15struct reset_control *__of_reset_control_get(struct device_node *node,
16 const char *id, int index, bool shared,
17 bool optional);
18struct reset_control *__reset_control_get(struct device *dev, const char *id,
19 int index, bool shared,
20 bool optional);
21void reset_control_put(struct reset_control *rstc);
22struct reset_control *__devm_reset_control_get(struct device *dev,
23 const char *id, int index, bool shared,
24 bool optional);
25
26int __must_check device_reset(struct device *dev);
27
28static inline int device_reset_optional(struct device *dev)
29{
30 return device_reset(dev);
31}
32
33#else
34
35static inline int reset_control_reset(struct reset_control *rstc)
36{
37 return 0;
38}
39
40static inline int reset_control_assert(struct reset_control *rstc)
41{
42 return 0;
43}
44
45static inline int reset_control_deassert(struct reset_control *rstc)
46{
47 return 0;
48}
49
50static inline int reset_control_status(struct reset_control *rstc)
51{
52 return 0;
53}
54
55static inline void reset_control_put(struct reset_control *rstc)
56{
57}
58
59static inline int __must_check device_reset(struct device *dev)
60{
61 WARN_ON(1);
62 return -ENOTSUPP;
63}
64
65static inline int device_reset_optional(struct device *dev)
66{
67 return -ENOTSUPP;
68}
69
70static inline struct reset_control *__of_reset_control_get(
71 struct device_node *node,
72 const char *id, int index, bool shared,
73 bool optional)
74{
75 return optional ? NULL : ERR_PTR(-ENOTSUPP);
76}
77
78static inline struct reset_control *__reset_control_get(
79 struct device *dev, const char *id,
80 int index, bool shared, bool optional)
81{
82 return optional ? NULL : ERR_PTR(-ENOTSUPP);
83}
84
85static inline struct reset_control *__devm_reset_control_get(
86 struct device *dev, const char *id,
87 int index, bool shared, bool optional)
88{
89 return optional ? NULL : ERR_PTR(-ENOTSUPP);
90}
91
92#endif
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109static inline struct reset_control *
110__must_check reset_control_get_exclusive(struct device *dev, const char *id)
111{
112#ifndef CONFIG_RESET_CONTROLLER
113 WARN_ON(1);
114#endif
115 return __reset_control_get(dev, id, 0, false, false);
116}
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140static inline struct reset_control *reset_control_get_shared(
141 struct device *dev, const char *id)
142{
143 return __reset_control_get(dev, id, 0, true, false);
144}
145
146static inline struct reset_control *reset_control_get_optional_exclusive(
147 struct device *dev, const char *id)
148{
149 return __reset_control_get(dev, id, 0, false, true);
150}
151
152static inline struct reset_control *reset_control_get_optional_shared(
153 struct device *dev, const char *id)
154{
155 return __reset_control_get(dev, id, 0, true, true);
156}
157
158
159
160
161
162
163
164
165
166
167
168static inline struct reset_control *of_reset_control_get_exclusive(
169 struct device_node *node, const char *id)
170{
171 return __of_reset_control_get(node, id, 0, false, false);
172}
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193static inline struct reset_control *of_reset_control_get_shared(
194 struct device_node *node, const char *id)
195{
196 return __of_reset_control_get(node, id, 0, true, false);
197}
198
199
200
201
202
203
204
205
206
207
208
209
210static inline struct reset_control *of_reset_control_get_exclusive_by_index(
211 struct device_node *node, int index)
212{
213 return __of_reset_control_get(node, NULL, index, false, false);
214}
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238static inline struct reset_control *of_reset_control_get_shared_by_index(
239 struct device_node *node, int index)
240{
241 return __of_reset_control_get(node, NULL, index, true, false);
242}
243
244
245
246
247
248
249
250
251
252
253
254
255
256static inline struct reset_control *
257__must_check devm_reset_control_get_exclusive(struct device *dev,
258 const char *id)
259{
260#ifndef CONFIG_RESET_CONTROLLER
261 WARN_ON(1);
262#endif
263 return __devm_reset_control_get(dev, id, 0, false, false);
264}
265
266
267
268
269
270
271
272
273
274
275static inline struct reset_control *devm_reset_control_get_shared(
276 struct device *dev, const char *id)
277{
278 return __devm_reset_control_get(dev, id, 0, true, false);
279}
280
281static inline struct reset_control *devm_reset_control_get_optional_exclusive(
282 struct device *dev, const char *id)
283{
284 return __devm_reset_control_get(dev, id, 0, false, true);
285}
286
287static inline struct reset_control *devm_reset_control_get_optional_shared(
288 struct device *dev, const char *id)
289{
290 return __devm_reset_control_get(dev, id, 0, true, true);
291}
292
293
294
295
296
297
298
299
300
301
302
303
304
305static inline struct reset_control *
306devm_reset_control_get_exclusive_by_index(struct device *dev, int index)
307{
308 return __devm_reset_control_get(dev, NULL, index, false, false);
309}
310
311
312
313
314
315
316
317
318
319
320
321static inline struct reset_control *
322devm_reset_control_get_shared_by_index(struct device *dev, int index)
323{
324 return __devm_reset_control_get(dev, NULL, index, true, false);
325}
326
327
328
329
330
331
332
333
334
335static inline struct reset_control *reset_control_get(
336 struct device *dev, const char *id)
337{
338 return reset_control_get_exclusive(dev, id);
339}
340
341static inline struct reset_control *reset_control_get_optional(
342 struct device *dev, const char *id)
343{
344 return reset_control_get_optional_exclusive(dev, id);
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#endif
378