Blame view
include/linux/reset.h
13.8 KB
b24413180 License cleanup: ... |
1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
61fc41317 reset: Add reset ... |
2 3 |
#ifndef _LINUX_RESET_H_ #define _LINUX_RESET_H_ |
6c96f05c8 reset: Make [of_]... |
4 |
#include <linux/device.h> |
61fc41317 reset: Add reset ... |
5 |
struct reset_control; |
b424080a9 reset: Add option... |
6 |
#ifdef CONFIG_RESET_CONTROLLER |
61fc41317 reset: Add reset ... |
7 8 9 |
int reset_control_reset(struct reset_control *rstc); int reset_control_assert(struct reset_control *rstc); int reset_control_deassert(struct reset_control *rstc); |
729de41ba reset: add reset_... |
10 |
int reset_control_status(struct reset_control *rstc); |
61fc41317 reset: Add reset ... |
11 |
|
6c96f05c8 reset: Make [of_]... |
12 |
struct reset_control *__of_reset_control_get(struct device_node *node, |
bb475230b reset: make optio... |
13 14 |
const char *id, int index, bool shared, bool optional); |
62e24c577 reset: add export... |
15 16 17 |
struct reset_control *__reset_control_get(struct device *dev, const char *id, int index, bool shared, bool optional); |
61fc41317 reset: Add reset ... |
18 |
void reset_control_put(struct reset_control *rstc); |
6c96f05c8 reset: Make [of_]... |
19 |
struct reset_control *__devm_reset_control_get(struct device *dev, |
bb475230b reset: make optio... |
20 21 |
const char *id, int index, bool shared, bool optional); |
61fc41317 reset: Add reset ... |
22 |
|
b424080a9 reset: Add option... |
23 |
int __must_check device_reset(struct device *dev); |
17c82e206 reset: Add APIs t... |
24 25 26 27 |
struct reset_control *devm_reset_control_array_get(struct device *dev, bool shared, bool optional); struct reset_control *of_reset_control_array_get(struct device_node *np, bool shared, bool optional); |
b424080a9 reset: Add option... |
28 29 30 31 |
static inline int device_reset_optional(struct device *dev) { return device_reset(dev); } |
b424080a9 reset: Add option... |
32 33 34 35 |
#else static inline int reset_control_reset(struct reset_control *rstc) { |
b424080a9 reset: Add option... |
36 37 38 39 40 |
return 0; } static inline int reset_control_assert(struct reset_control *rstc) { |
b424080a9 reset: Add option... |
41 42 43 44 45 |
return 0; } static inline int reset_control_deassert(struct reset_control *rstc) { |
b424080a9 reset: Add option... |
46 47 |
return 0; } |
729de41ba reset: add reset_... |
48 49 |
static inline int reset_control_status(struct reset_control *rstc) { |
729de41ba reset: add reset_... |
50 51 |
return 0; } |
b424080a9 reset: Add option... |
52 53 |
static inline void reset_control_put(struct reset_control *rstc) { |
b424080a9 reset: Add option... |
54 |
} |
411365225 reset: Add missin... |
55 56 57 58 59 |
static inline int __must_check device_reset(struct device *dev) { WARN_ON(1); return -ENOTSUPP; } |
b424080a9 reset: Add option... |
60 61 |
static inline int device_reset_optional(struct device *dev) { |
39b4da71c reset: use ENOTSU... |
62 |
return -ENOTSUPP; |
b424080a9 reset: Add option... |
63 |
} |
6c96f05c8 reset: Make [of_]... |
64 65 |
static inline struct reset_control *__of_reset_control_get( struct device_node *node, |
bb475230b reset: make optio... |
66 67 |
const char *id, int index, bool shared, bool optional) |
5bcd0b7f3 reset: Add (devm_... |
68 |
{ |
0ca10b60c reset: fix option... |
69 |
return optional ? NULL : ERR_PTR(-ENOTSUPP); |
5bcd0b7f3 reset: Add (devm_... |
70 |
} |
62e24c577 reset: add export... |
71 72 73 74 75 76 |
static inline struct reset_control *__reset_control_get( struct device *dev, const char *id, int index, bool shared, bool optional) { return optional ? NULL : ERR_PTR(-ENOTSUPP); } |
6c96f05c8 reset: Make [of_]... |
77 |
static inline struct reset_control *__devm_reset_control_get( |
bb475230b reset: make optio... |
78 79 |
struct device *dev, const char *id, int index, bool shared, bool optional) |
5bcd0b7f3 reset: Add (devm_... |
80 |
{ |
0ca10b60c reset: fix option... |
81 |
return optional ? NULL : ERR_PTR(-ENOTSUPP); |
5bcd0b7f3 reset: Add (devm_... |
82 |
} |
17c82e206 reset: Add APIs t... |
83 84 85 86 87 88 89 90 91 92 93 |
static inline struct reset_control * devm_reset_control_array_get(struct device *dev, bool shared, bool optional) { return optional ? NULL : ERR_PTR(-ENOTSUPP); } static inline struct reset_control * of_reset_control_array_get(struct device_node *np, bool shared, bool optional) { return optional ? NULL : ERR_PTR(-ENOTSUPP); } |
6c96f05c8 reset: Make [of_]... |
94 95 96 |
#endif /* CONFIG_RESET_CONTROLLER */ /** |
a53e35db7 reset: Ensure dri... |
97 98 |
* reset_control_get_exclusive - Lookup and obtain an exclusive reference * to a reset controller. |
6c96f05c8 reset: Make [of_]... |
99 100 101 102 |
* @dev: device to be reset by the controller * @id: reset line name * * Returns a struct reset_control or IS_ERR() condition containing errno. |
0b52297f2 reset: Add suppor... |
103 104 105 106 107 |
* If this function is called more then once for the same reset_control it will * return -EBUSY. * * See reset_control_get_shared for details on shared references to * reset-controls. |
6c96f05c8 reset: Make [of_]... |
108 109 110 |
* * Use of id names is optional. */ |
a53e35db7 reset: Ensure dri... |
111 112 |
static inline struct reset_control * __must_check reset_control_get_exclusive(struct device *dev, const char *id) |
b424080a9 reset: Add option... |
113 |
{ |
6c96f05c8 reset: Make [of_]... |
114 115 116 |
#ifndef CONFIG_RESET_CONTROLLER WARN_ON(1); #endif |
62e24c577 reset: add export... |
117 |
return __reset_control_get(dev, id, 0, false, false); |
b424080a9 reset: Add option... |
118 |
} |
6c96f05c8 reset: Make [of_]... |
119 |
/** |
0b52297f2 reset: Add suppor... |
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
* reset_control_get_shared - Lookup and obtain a shared reference to a * reset controller. * @dev: device to be reset by the controller * @id: reset line name * * Returns a struct reset_control or IS_ERR() condition containing errno. * This function is intended for use with reset-controls which are shared * between hardware-blocks. * * When a reset-control is shared, the behavior of reset_control_assert / * deassert is changed, the reset-core will keep track of a deassert_count * and only (re-)assert the reset after reset_control_assert has been called * as many times as reset_control_deassert was called. Also see the remark * about shared reset-controls in the reset_control_assert docs. * * Calling reset_control_assert without first calling reset_control_deassert * is not allowed on a shared reset control. Calling reset_control_reset is * also not allowed on a shared reset control. * * Use of id names is optional. */ static inline struct reset_control *reset_control_get_shared( struct device *dev, const char *id) { |
62e24c577 reset: add export... |
144 |
return __reset_control_get(dev, id, 0, true, false); |
0b52297f2 reset: Add suppor... |
145 |
} |
a53e35db7 reset: Ensure dri... |
146 |
static inline struct reset_control *reset_control_get_optional_exclusive( |
3c35f6edc reset: Reorder in... |
147 148 |
struct device *dev, const char *id) { |
62e24c577 reset: add export... |
149 |
return __reset_control_get(dev, id, 0, false, true); |
3c35f6edc reset: Reorder in... |
150 |
} |
c33d61a0c reset: Supply *_s... |
151 152 153 |
static inline struct reset_control *reset_control_get_optional_shared( struct device *dev, const char *id) { |
62e24c577 reset: add export... |
154 |
return __reset_control_get(dev, id, 0, true, true); |
c33d61a0c reset: Supply *_s... |
155 |
} |
0b52297f2 reset: Add suppor... |
156 |
/** |
a53e35db7 reset: Ensure dri... |
157 158 |
* of_reset_control_get_exclusive - Lookup and obtain an exclusive reference * to a reset controller. |
6c96f05c8 reset: Make [of_]... |
159 160 161 162 163 164 165 |
* @node: device to be reset by the controller * @id: reset line name * * Returns a struct reset_control or IS_ERR() condition containing errno. * * Use of id names is optional. */ |
a53e35db7 reset: Ensure dri... |
166 |
static inline struct reset_control *of_reset_control_get_exclusive( |
e3ec0a8c6 reset: Add of_res... |
167 168 |
struct device_node *node, const char *id) { |
bb475230b reset: make optio... |
169 |
return __of_reset_control_get(node, id, 0, false, false); |
e3ec0a8c6 reset: Add of_res... |
170 |
} |
6c96f05c8 reset: Make [of_]... |
171 |
/** |
40faee8ee reset: Supply *_s... |
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
* of_reset_control_get_shared - Lookup and obtain an shared reference * to a reset controller. * @node: device to be reset by the controller * @id: reset line name * * When a reset-control is shared, the behavior of reset_control_assert / * deassert is changed, the reset-core will keep track of a deassert_count * and only (re-)assert the reset after reset_control_assert has been called * as many times as reset_control_deassert was called. Also see the remark * about shared reset-controls in the reset_control_assert docs. * * Calling reset_control_assert without first calling reset_control_deassert * is not allowed on a shared reset control. Calling reset_control_reset is * also not allowed on a shared reset control. * Returns a struct reset_control or IS_ERR() condition containing errno. * * Use of id names is optional. */ static inline struct reset_control *of_reset_control_get_shared( struct device_node *node, const char *id) { |
bb475230b reset: make optio... |
193 |
return __of_reset_control_get(node, id, 0, true, false); |
40faee8ee reset: Supply *_s... |
194 195 196 |
} /** |
a53e35db7 reset: Ensure dri... |
197 198 199 |
* of_reset_control_get_exclusive_by_index - Lookup and obtain an exclusive * reference to a reset controller * by index. |
6c96f05c8 reset: Make [of_]... |
200 201 202 203 204 205 206 |
* @node: device to be reset by the controller * @index: index of the reset controller * * This is to be used to perform a list of resets for a device or power domain * in whatever order. Returns a struct reset_control or IS_ERR() condition * containing errno. */ |
a53e35db7 reset: Ensure dri... |
207 |
static inline struct reset_control *of_reset_control_get_exclusive_by_index( |
6c96f05c8 reset: Make [of_]... |
208 |
struct device_node *node, int index) |
c0a13aa6d reset: add of_res... |
209 |
{ |
bb475230b reset: make optio... |
210 |
return __of_reset_control_get(node, NULL, index, false, false); |
c0a13aa6d reset: add of_res... |
211 |
} |
6c96f05c8 reset: Make [of_]... |
212 |
/** |
40faee8ee reset: Supply *_s... |
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
* of_reset_control_get_shared_by_index - Lookup and obtain an shared * reference to a reset controller * by index. * @node: device to be reset by the controller * @index: index of the reset controller * * When a reset-control is shared, the behavior of reset_control_assert / * deassert is changed, the reset-core will keep track of a deassert_count * and only (re-)assert the reset after reset_control_assert has been called * as many times as reset_control_deassert was called. Also see the remark * about shared reset-controls in the reset_control_assert docs. * * Calling reset_control_assert without first calling reset_control_deassert * is not allowed on a shared reset control. Calling reset_control_reset is * also not allowed on a shared reset control. * Returns a struct reset_control or IS_ERR() condition containing errno. |
6c96f05c8 reset: Make [of_]... |
229 |
* |
40faee8ee reset: Supply *_s... |
230 231 232 |
* This is to be used to perform a list of resets for a device or power domain * in whatever order. Returns a struct reset_control or IS_ERR() condition * containing errno. |
6c96f05c8 reset: Make [of_]... |
233 |
*/ |
40faee8ee reset: Supply *_s... |
234 235 |
static inline struct reset_control *of_reset_control_get_shared_by_index( struct device_node *node, int index) |
6c96f05c8 reset: Make [of_]... |
236 |
{ |
bb475230b reset: make optio... |
237 |
return __of_reset_control_get(node, NULL, index, true, false); |
6c96f05c8 reset: Make [of_]... |
238 239 240 |
} /** |
a53e35db7 reset: Ensure dri... |
241 242 |
* devm_reset_control_get_exclusive - resource managed * reset_control_get_exclusive() |
6c96f05c8 reset: Make [of_]... |
243 |
* @dev: device to be reset by the controller |
6c96f05c8 reset: Make [of_]... |
244 |
* @id: reset line name |
6c96f05c8 reset: Make [of_]... |
245 |
* |
a53e35db7 reset: Ensure dri... |
246 247 248 249 250 |
* Managed reset_control_get_exclusive(). For reset controllers returned * from this function, reset_control_put() is called automatically on driver * detach. * * See reset_control_get_exclusive() for more information. |
6c96f05c8 reset: Make [of_]... |
251 |
*/ |
a53e35db7 reset: Ensure dri... |
252 253 254 |
static inline struct reset_control * __must_check devm_reset_control_get_exclusive(struct device *dev, const char *id) |
6c96f05c8 reset: Make [of_]... |
255 |
{ |
6c96f05c8 reset: Make [of_]... |
256 257 258 |
#ifndef CONFIG_RESET_CONTROLLER WARN_ON(1); #endif |
bb475230b reset: make optio... |
259 |
return __devm_reset_control_get(dev, id, 0, false, false); |
0b52297f2 reset: Add suppor... |
260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
} /** * devm_reset_control_get_shared - resource managed reset_control_get_shared() * @dev: device to be reset by the controller * @id: reset line name * * Managed reset_control_get_shared(). For reset controllers returned from * this function, reset_control_put() is called automatically on driver detach. * See reset_control_get_shared() for more information. */ static inline struct reset_control *devm_reset_control_get_shared( struct device *dev, const char *id) { |
bb475230b reset: make optio... |
274 |
return __devm_reset_control_get(dev, id, 0, true, false); |
0b52297f2 reset: Add suppor... |
275 |
} |
a53e35db7 reset: Ensure dri... |
276 |
static inline struct reset_control *devm_reset_control_get_optional_exclusive( |
6c96f05c8 reset: Make [of_]... |
277 278 |
struct device *dev, const char *id) { |
bb475230b reset: make optio... |
279 |
return __devm_reset_control_get(dev, id, 0, false, true); |
6c96f05c8 reset: Make [of_]... |
280 |
} |
c33d61a0c reset: Supply *_s... |
281 282 283 |
static inline struct reset_control *devm_reset_control_get_optional_shared( struct device *dev, const char *id) { |
bb475230b reset: make optio... |
284 |
return __devm_reset_control_get(dev, id, 0, true, true); |
c33d61a0c reset: Supply *_s... |
285 |
} |
6c96f05c8 reset: Make [of_]... |
286 |
/** |
a53e35db7 reset: Ensure dri... |
287 288 |
* devm_reset_control_get_exclusive_by_index - resource managed * reset_control_get_exclusive() |
6c96f05c8 reset: Make [of_]... |
289 290 291 |
* @dev: device to be reset by the controller * @index: index of the reset controller * |
a53e35db7 reset: Ensure dri... |
292 293 294 295 296 |
* Managed reset_control_get_exclusive(). For reset controllers returned from * this function, reset_control_put() is called automatically on driver * detach. * * See reset_control_get_exclusive() for more information. |
6c96f05c8 reset: Make [of_]... |
297 |
*/ |
a53e35db7 reset: Ensure dri... |
298 299 |
static inline struct reset_control * devm_reset_control_get_exclusive_by_index(struct device *dev, int index) |
6c96f05c8 reset: Make [of_]... |
300 |
{ |
bb475230b reset: make optio... |
301 |
return __devm_reset_control_get(dev, NULL, index, false, false); |
0b52297f2 reset: Add suppor... |
302 |
} |
0b52297f2 reset: Add suppor... |
303 304 305 306 307 308 309 310 311 312 |
/** * devm_reset_control_get_shared_by_index - resource managed * reset_control_get_shared * @dev: device to be reset by the controller * @index: index of the reset controller * * Managed reset_control_get_shared(). For reset controllers returned from * this function, reset_control_put() is called automatically on driver detach. * See reset_control_get_shared() for more information. */ |
0bcc0eab3 reset: TRIVIAL: A... |
313 314 |
static inline struct reset_control * devm_reset_control_get_shared_by_index(struct device *dev, int index) |
0b52297f2 reset: Add suppor... |
315 |
{ |
bb475230b reset: make optio... |
316 |
return __devm_reset_control_get(dev, NULL, index, true, false); |
6c96f05c8 reset: Make [of_]... |
317 |
} |
61fc41317 reset: Add reset ... |
318 |
|
a53e35db7 reset: Ensure dri... |
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
/* * TEMPORARY calls to use during transition: * * of_reset_control_get() => of_reset_control_get_exclusive() * * These inline function calls will be removed once all consumers * have been moved over to the new explicit API. */ static inline struct reset_control *reset_control_get( struct device *dev, const char *id) { return reset_control_get_exclusive(dev, id); } static inline struct reset_control *reset_control_get_optional( struct device *dev, const char *id) { return reset_control_get_optional_exclusive(dev, id); } static inline struct reset_control *of_reset_control_get( struct device_node *node, const char *id) { return of_reset_control_get_exclusive(node, id); } static inline struct reset_control *of_reset_control_get_by_index( struct device_node *node, int index) { return of_reset_control_get_exclusive_by_index(node, index); } static inline struct reset_control *devm_reset_control_get( struct device *dev, const char *id) { return devm_reset_control_get_exclusive(dev, id); } static inline struct reset_control *devm_reset_control_get_optional( struct device *dev, const char *id) { return devm_reset_control_get_optional_exclusive(dev, id); } static inline struct reset_control *devm_reset_control_get_by_index( struct device *dev, int index) { return devm_reset_control_get_exclusive_by_index(dev, index); } |
17c82e206 reset: Add APIs t... |
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
/* * APIs to manage a list of reset controllers */ static inline struct reset_control * devm_reset_control_array_get_exclusive(struct device *dev) { return devm_reset_control_array_get(dev, false, false); } static inline struct reset_control * devm_reset_control_array_get_shared(struct device *dev) { return devm_reset_control_array_get(dev, true, false); } static inline struct reset_control * devm_reset_control_array_get_optional_exclusive(struct device *dev) { return devm_reset_control_array_get(dev, false, true); } static inline struct reset_control * devm_reset_control_array_get_optional_shared(struct device *dev) { return devm_reset_control_array_get(dev, true, true); } static inline struct reset_control * of_reset_control_array_get_exclusive(struct device_node *node) { return of_reset_control_array_get(node, false, false); } static inline struct reset_control * of_reset_control_array_get_shared(struct device_node *node) { return of_reset_control_array_get(node, true, false); } static inline struct reset_control * of_reset_control_array_get_optional_exclusive(struct device_node *node) { return of_reset_control_array_get(node, false, true); } static inline struct reset_control * of_reset_control_array_get_optional_shared(struct device_node *node) { return of_reset_control_array_get(node, true, true); } |
61fc41317 reset: Add reset ... |
420 |
#endif |