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