1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _LINUX_RESET_H_ 3 #define _LINUX_RESET_H_ 4 5 #include <linux/err.h> 6 #include <linux/errno.h> 7 #include <linux/types.h> 8 9 struct device; 10 struct device_node; 11 struct reset_control; 12 13 /** 14 * struct reset_control_bulk_data - Data used for bulk reset control operations. 15 * 16 * @id: reset control consumer ID 17 * @rstc: struct reset_control * to store the associated reset control 18 * 19 * The reset APIs provide a series of reset_control_bulk_*() API calls as 20 * a convenience to consumers which require multiple reset controls. 21 * This structure is used to manage data for these calls. 22 */ 23 struct reset_control_bulk_data { 24 const char *id; 25 struct reset_control *rstc; 26 }; 27 28 #ifdef CONFIG_RESET_CONTROLLER 29 30 int reset_control_reset(struct reset_control *rstc); 31 int reset_control_rearm(struct reset_control *rstc); 32 int reset_control_assert(struct reset_control *rstc); 33 int reset_control_deassert(struct reset_control *rstc); 34 int reset_control_status(struct reset_control *rstc); 35 int reset_control_acquire(struct reset_control *rstc); 36 void reset_control_release(struct reset_control *rstc); 37 38 int reset_control_bulk_reset(int num_rstcs, struct reset_control_bulk_data *rstcs); 39 int reset_control_bulk_assert(int num_rstcs, struct reset_control_bulk_data *rstcs); 40 int reset_control_bulk_deassert(int num_rstcs, struct reset_control_bulk_data *rstcs); 41 int reset_control_bulk_acquire(int num_rstcs, struct reset_control_bulk_data *rstcs); 42 void reset_control_bulk_release(int num_rstcs, struct reset_control_bulk_data *rstcs); 43 44 struct reset_control *__of_reset_control_get(struct device_node *node, 45 const char *id, int index, bool shared, 46 bool optional, bool acquired); 47 struct reset_control *__reset_control_get(struct device *dev, const char *id, 48 int index, bool shared, 49 bool optional, bool acquired); 50 void reset_control_put(struct reset_control *rstc); 51 int __reset_control_bulk_get(struct device *dev, int num_rstcs, 52 struct reset_control_bulk_data *rstcs, 53 bool shared, bool optional, bool acquired); 54 void reset_control_bulk_put(int num_rstcs, struct reset_control_bulk_data *rstcs); 55 56 int __device_reset(struct device *dev, bool optional); 57 struct reset_control *__devm_reset_control_get(struct device *dev, 58 const char *id, int index, bool shared, 59 bool optional, bool acquired); 60 int __devm_reset_control_bulk_get(struct device *dev, int num_rstcs, 61 struct reset_control_bulk_data *rstcs, 62 bool shared, bool optional, bool acquired); 63 64 struct reset_control *devm_reset_control_array_get(struct device *dev, 65 bool shared, bool optional); 66 struct reset_control *of_reset_control_array_get(struct device_node *np, 67 bool shared, bool optional, 68 bool acquired); 69 70 int reset_control_get_count(struct device *dev); 71 72 #else 73 74 static inline int reset_control_reset(struct reset_control *rstc) 75 { 76 return 0; 77 } 78 79 static inline int reset_control_rearm(struct reset_control *rstc) 80 { 81 return 0; 82 } 83 84 static inline int reset_control_assert(struct reset_control *rstc) 85 { 86 return 0; 87 } 88 89 static inline int reset_control_deassert(struct reset_control *rstc) 90 { 91 return 0; 92 } 93 94 static inline int reset_control_status(struct reset_control *rstc) 95 { 96 return 0; 97 } 98 99 static inline int reset_control_acquire(struct reset_control *rstc) 100 { 101 return 0; 102 } 103 104 static inline void reset_control_release(struct reset_control *rstc) 105 { 106 } 107 108 static inline void reset_control_put(struct reset_control *rstc) 109 { 110 } 111 112 static inline int __device_reset(struct device *dev, bool optional) 113 { 114 return optional ? 0 : -ENOTSUPP; 115 } 116 117 static inline struct reset_control *__of_reset_control_get( 118 struct device_node *node, 119 const char *id, int index, bool shared, 120 bool optional, bool acquired) 121 { 122 return optional ? NULL : ERR_PTR(-ENOTSUPP); 123 } 124 125 static inline struct reset_control *__reset_control_get( 126 struct device *dev, const char *id, 127 int index, bool shared, bool optional, 128 bool acquired) 129 { 130 return optional ? NULL : ERR_PTR(-ENOTSUPP); 131 } 132 133 static inline int 134 reset_control_bulk_reset(int num_rstcs, struct reset_control_bulk_data *rstcs) 135 { 136 return 0; 137 } 138 139 static inline int 140 reset_control_bulk_assert(int num_rstcs, struct reset_control_bulk_data *rstcs) 141 { 142 return 0; 143 } 144 145 static inline int 146 reset_control_bulk_deassert(int num_rstcs, struct reset_control_bulk_data *rstcs) 147 { 148 return 0; 149 } 150 151 static inline int 152 reset_control_bulk_acquire(int num_rstcs, struct reset_control_bulk_data *rstcs) 153 { 154 return 0; 155 } 156 157 static inline void 158 reset_control_bulk_release(int num_rstcs, struct reset_control_bulk_data *rstcs) 159 { 160 } 161 162 static inline int 163 __reset_control_bulk_get(struct device *dev, int num_rstcs, 164 struct reset_control_bulk_data *rstcs, 165 bool shared, bool optional, bool acquired) 166 { 167 return optional ? 0 : -EOPNOTSUPP; 168 } 169 170 static inline void 171 reset_control_bulk_put(int num_rstcs, struct reset_control_bulk_data *rstcs) 172 { 173 } 174 175 static inline struct reset_control *__devm_reset_control_get( 176 struct device *dev, const char *id, 177 int index, bool shared, bool optional, 178 bool acquired) 179 { 180 return optional ? NULL : ERR_PTR(-ENOTSUPP); 181 } 182 183 static inline int 184 __devm_reset_control_bulk_get(struct device *dev, int num_rstcs, 185 struct reset_control_bulk_data *rstcs, 186 bool shared, bool optional, bool acquired) 187 { 188 return optional ? 0 : -EOPNOTSUPP; 189 } 190 191 static inline struct reset_control * 192 devm_reset_control_array_get(struct device *dev, bool shared, bool optional) 193 { 194 return optional ? NULL : ERR_PTR(-ENOTSUPP); 195 } 196 197 static inline struct reset_control * 198 of_reset_control_array_get(struct device_node *np, bool shared, bool optional, 199 bool acquired) 200 { 201 return optional ? NULL : ERR_PTR(-ENOTSUPP); 202 } 203 204 static inline int reset_control_get_count(struct device *dev) 205 { 206 return -ENOENT; 207 } 208 209 #endif /* CONFIG_RESET_CONTROLLER */ 210 211 static inline int __must_check device_reset(struct device *dev) 212 { 213 return __device_reset(dev, false); 214 } 215 216 static inline int device_reset_optional(struct device *dev) 217 { 218 return __device_reset(dev, true); 219 } 220 221 /** 222 * reset_control_get_exclusive - Lookup and obtain an exclusive reference 223 * to a reset controller. 224 * @dev: device to be reset by the controller 225 * @id: reset line name 226 * 227 * Returns a struct reset_control or IS_ERR() condition containing errno. 228 * If this function is called more than once for the same reset_control it will 229 * return -EBUSY. 230 * 231 * See reset_control_get_shared() for details on shared references to 232 * reset-controls. 233 * 234 * Use of id names is optional. 235 */ 236 static inline struct reset_control * 237 __must_check reset_control_get_exclusive(struct device *dev, const char *id) 238 { 239 return __reset_control_get(dev, id, 0, false, false, true); 240 } 241 242 /** 243 * reset_control_bulk_get_exclusive - Lookup and obtain exclusive references to 244 * multiple reset controllers. 245 * @dev: device to be reset by the controller 246 * @num_rstcs: number of entries in rstcs array 247 * @rstcs: array of struct reset_control_bulk_data with reset line names set 248 * 249 * Fills the rstcs array with pointers to exclusive reset controls and 250 * returns 0, or an IS_ERR() condition containing errno. 251 */ 252 static inline int __must_check 253 reset_control_bulk_get_exclusive(struct device *dev, int num_rstcs, 254 struct reset_control_bulk_data *rstcs) 255 { 256 return __reset_control_bulk_get(dev, num_rstcs, rstcs, false, false, true); 257 } 258 259 /** 260 * reset_control_get_exclusive_released - Lookup and obtain a temoprarily 261 * exclusive reference to a reset 262 * controller. 263 * @dev: device to be reset by the controller 264 * @id: reset line name 265 * 266 * Returns a struct reset_control or IS_ERR() condition containing errno. 267 * reset-controls returned by this function must be acquired via 268 * reset_control_acquire() before they can be used and should be released 269 * via reset_control_release() afterwards. 270 * 271 * Use of id names is optional. 272 */ 273 static inline struct reset_control * 274 __must_check reset_control_get_exclusive_released(struct device *dev, 275 const char *id) 276 { 277 return __reset_control_get(dev, id, 0, false, false, false); 278 } 279 280 /** 281 * reset_control_bulk_get_exclusive_released - Lookup and obtain temporarily 282 * exclusive references to multiple reset 283 * controllers. 284 * @dev: device to be reset by the controller 285 * @num_rstcs: number of entries in rstcs array 286 * @rstcs: array of struct reset_control_bulk_data with reset line names set 287 * 288 * Fills the rstcs array with pointers to exclusive reset controls and 289 * returns 0, or an IS_ERR() condition containing errno. 290 * reset-controls returned by this function must be acquired via 291 * reset_control_bulk_acquire() before they can be used and should be released 292 * via reset_control_bulk_release() afterwards. 293 */ 294 static inline int __must_check 295 reset_control_bulk_get_exclusive_released(struct device *dev, int num_rstcs, 296 struct reset_control_bulk_data *rstcs) 297 { 298 return __reset_control_bulk_get(dev, num_rstcs, rstcs, false, false, false); 299 } 300 301 /** 302 * reset_control_bulk_get_optional_exclusive_released - Lookup and obtain optional 303 * temporarily exclusive references to multiple 304 * reset controllers. 305 * @dev: device to be reset by the controller 306 * @num_rstcs: number of entries in rstcs array 307 * @rstcs: array of struct reset_control_bulk_data with reset line names set 308 * 309 * Optional variant of reset_control_bulk_get_exclusive_released(). If the 310 * requested reset is not specified in the device tree, this function returns 0 311 * instead of an error and missing rtsc is set to NULL. 312 * 313 * See reset_control_bulk_get_exclusive_released() for more information. 314 */ 315 static inline int __must_check 316 reset_control_bulk_get_optional_exclusive_released(struct device *dev, int num_rstcs, 317 struct reset_control_bulk_data *rstcs) 318 { 319 return __reset_control_bulk_get(dev, num_rstcs, rstcs, false, true, false); 320 } 321 322 /** 323 * reset_control_get_shared - Lookup and obtain a shared reference to a 324 * reset controller. 325 * @dev: device to be reset by the controller 326 * @id: reset line name 327 * 328 * Returns a struct reset_control or IS_ERR() condition containing errno. 329 * This function is intended for use with reset-controls which are shared 330 * between hardware blocks. 331 * 332 * When a reset-control is shared, the behavior of reset_control_assert / 333 * deassert is changed, the reset-core will keep track of a deassert_count 334 * and only (re-)assert the reset after reset_control_assert has been called 335 * as many times as reset_control_deassert was called. Also see the remark 336 * about shared reset-controls in the reset_control_assert docs. 337 * 338 * Calling reset_control_assert without first calling reset_control_deassert 339 * is not allowed on a shared reset control. Calling reset_control_reset is 340 * also not allowed on a shared reset control. 341 * 342 * Use of id names is optional. 343 */ 344 static inline struct reset_control *reset_control_get_shared( 345 struct device *dev, const char *id) 346 { 347 return __reset_control_get(dev, id, 0, true, false, false); 348 } 349 350 /** 351 * reset_control_bulk_get_shared - Lookup and obtain shared references to 352 * multiple reset controllers. 353 * @dev: device to be reset by the controller 354 * @num_rstcs: number of entries in rstcs array 355 * @rstcs: array of struct reset_control_bulk_data with reset line names set 356 * 357 * Fills the rstcs array with pointers to shared reset controls and 358 * returns 0, or an IS_ERR() condition containing errno. 359 */ 360 static inline int __must_check 361 reset_control_bulk_get_shared(struct device *dev, int num_rstcs, 362 struct reset_control_bulk_data *rstcs) 363 { 364 return __reset_control_bulk_get(dev, num_rstcs, rstcs, true, false, false); 365 } 366 367 /** 368 * reset_control_get_optional_exclusive - optional reset_control_get_exclusive() 369 * @dev: device to be reset by the controller 370 * @id: reset line name 371 * 372 * Optional variant of reset_control_get_exclusive(). If the requested reset 373 * is not specified in the device tree, this function returns NULL instead of 374 * an error. 375 * 376 * See reset_control_get_exclusive() for more information. 377 */ 378 static inline struct reset_control *reset_control_get_optional_exclusive( 379 struct device *dev, const char *id) 380 { 381 return __reset_control_get(dev, id, 0, false, true, true); 382 } 383 384 /** 385 * reset_control_bulk_get_optional_exclusive - optional 386 * reset_control_bulk_get_exclusive() 387 * @dev: device to be reset by the controller 388 * @num_rstcs: number of entries in rstcs array 389 * @rstcs: array of struct reset_control_bulk_data with reset line names set 390 * 391 * Optional variant of reset_control_bulk_get_exclusive(). If any of the 392 * requested resets are not specified in the device tree, this function sets 393 * them to NULL instead of returning an error. 394 * 395 * See reset_control_bulk_get_exclusive() for more information. 396 */ 397 static inline int __must_check 398 reset_control_bulk_get_optional_exclusive(struct device *dev, int num_rstcs, 399 struct reset_control_bulk_data *rstcs) 400 { 401 return __reset_control_bulk_get(dev, num_rstcs, rstcs, false, true, true); 402 } 403 404 /** 405 * reset_control_get_optional_shared - optional reset_control_get_shared() 406 * @dev: device to be reset by the controller 407 * @id: reset line name 408 * 409 * Optional variant of reset_control_get_shared(). If the requested reset 410 * is not specified in the device tree, this function returns NULL instead of 411 * an error. 412 * 413 * See reset_control_get_shared() for more information. 414 */ 415 static inline struct reset_control *reset_control_get_optional_shared( 416 struct device *dev, const char *id) 417 { 418 return __reset_control_get(dev, id, 0, true, true, false); 419 } 420 421 /** 422 * reset_control_bulk_get_optional_shared - optional 423 * reset_control_bulk_get_shared() 424 * @dev: device to be reset by the controller 425 * @num_rstcs: number of entries in rstcs array 426 * @rstcs: array of struct reset_control_bulk_data with reset line names set 427 * 428 * Optional variant of reset_control_bulk_get_shared(). If the requested resets 429 * are not specified in the device tree, this function sets them to NULL 430 * instead of returning an error. 431 * 432 * See reset_control_bulk_get_shared() for more information. 433 */ 434 static inline int __must_check 435 reset_control_bulk_get_optional_shared(struct device *dev, int num_rstcs, 436 struct reset_control_bulk_data *rstcs) 437 { 438 return __reset_control_bulk_get(dev, num_rstcs, rstcs, true, true, false); 439 } 440 441 /** 442 * of_reset_control_get_exclusive - Lookup and obtain an exclusive reference 443 * to a reset controller. 444 * @node: device to be reset by the controller 445 * @id: reset line name 446 * 447 * Returns a struct reset_control or IS_ERR() condition containing errno. 448 * 449 * Use of id names is optional. 450 */ 451 static inline struct reset_control *of_reset_control_get_exclusive( 452 struct device_node *node, const char *id) 453 { 454 return __of_reset_control_get(node, id, 0, false, false, true); 455 } 456 457 /** 458 * of_reset_control_get_shared - Lookup and obtain a shared reference 459 * to a reset controller. 460 * @node: device to be reset by the controller 461 * @id: reset line name 462 * 463 * When a reset-control is shared, the behavior of reset_control_assert / 464 * deassert is changed, the reset-core will keep track of a deassert_count 465 * and only (re-)assert the reset after reset_control_assert has been called 466 * as many times as reset_control_deassert was called. Also see the remark 467 * about shared reset-controls in the reset_control_assert docs. 468 * 469 * Calling reset_control_assert without first calling reset_control_deassert 470 * is not allowed on a shared reset control. Calling reset_control_reset is 471 * also not allowed on a shared reset control. 472 * Returns a struct reset_control or IS_ERR() condition containing errno. 473 * 474 * Use of id names is optional. 475 */ 476 static inline struct reset_control *of_reset_control_get_shared( 477 struct device_node *node, const char *id) 478 { 479 return __of_reset_control_get(node, id, 0, true, false, false); 480 } 481 482 /** 483 * of_reset_control_get_exclusive_by_index - Lookup and obtain an exclusive 484 * reference to a reset controller 485 * by index. 486 * @node: device to be reset by the controller 487 * @index: index of the reset controller 488 * 489 * This is to be used to perform a list of resets for a device or power domain 490 * in whatever order. Returns a struct reset_control or IS_ERR() condition 491 * containing errno. 492 */ 493 static inline struct reset_control *of_reset_control_get_exclusive_by_index( 494 struct device_node *node, int index) 495 { 496 return __of_reset_control_get(node, NULL, index, false, false, true); 497 } 498 499 /** 500 * of_reset_control_get_shared_by_index - Lookup and obtain a shared 501 * reference to a reset controller 502 * by index. 503 * @node: device to be reset by the controller 504 * @index: index of the reset controller 505 * 506 * When a reset-control is shared, the behavior of reset_control_assert / 507 * deassert is changed, the reset-core will keep track of a deassert_count 508 * and only (re-)assert the reset after reset_control_assert has been called 509 * as many times as reset_control_deassert was called. Also see the remark 510 * about shared reset-controls in the reset_control_assert docs. 511 * 512 * Calling reset_control_assert without first calling reset_control_deassert 513 * is not allowed on a shared reset control. Calling reset_control_reset is 514 * also not allowed on a shared reset control. 515 * Returns a struct reset_control or IS_ERR() condition containing errno. 516 * 517 * This is to be used to perform a list of resets for a device or power domain 518 * in whatever order. Returns a struct reset_control or IS_ERR() condition 519 * containing errno. 520 */ 521 static inline struct reset_control *of_reset_control_get_shared_by_index( 522 struct device_node *node, int index) 523 { 524 return __of_reset_control_get(node, NULL, index, true, false, false); 525 } 526 527 /** 528 * devm_reset_control_get_exclusive - resource managed 529 * reset_control_get_exclusive() 530 * @dev: device to be reset by the controller 531 * @id: reset line name 532 * 533 * Managed reset_control_get_exclusive(). For reset controllers returned 534 * from this function, reset_control_put() is called automatically on driver 535 * detach. 536 * 537 * See reset_control_get_exclusive() for more information. 538 */ 539 static inline struct reset_control * 540 __must_check devm_reset_control_get_exclusive(struct device *dev, 541 const char *id) 542 { 543 return __devm_reset_control_get(dev, id, 0, false, false, true); 544 } 545 546 /** 547 * devm_reset_control_bulk_get_exclusive - resource managed 548 * reset_control_bulk_get_exclusive() 549 * @dev: device to be reset by the controller 550 * @num_rstcs: number of entries in rstcs array 551 * @rstcs: array of struct reset_control_bulk_data with reset line names set 552 * 553 * Managed reset_control_bulk_get_exclusive(). For reset controllers returned 554 * from this function, reset_control_put() is called automatically on driver 555 * detach. 556 * 557 * See reset_control_bulk_get_exclusive() for more information. 558 */ 559 static inline int __must_check 560 devm_reset_control_bulk_get_exclusive(struct device *dev, int num_rstcs, 561 struct reset_control_bulk_data *rstcs) 562 { 563 return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, false, false, true); 564 } 565 566 /** 567 * devm_reset_control_get_exclusive_released - resource managed 568 * reset_control_get_exclusive_released() 569 * @dev: device to be reset by the controller 570 * @id: reset line name 571 * 572 * Managed reset_control_get_exclusive_released(). For reset controllers 573 * returned from this function, reset_control_put() is called automatically on 574 * driver detach. 575 * 576 * See reset_control_get_exclusive_released() for more information. 577 */ 578 static inline struct reset_control * 579 __must_check devm_reset_control_get_exclusive_released(struct device *dev, 580 const char *id) 581 { 582 return __devm_reset_control_get(dev, id, 0, false, false, false); 583 } 584 585 /** 586 * devm_reset_control_bulk_get_exclusive_released - resource managed 587 * reset_control_bulk_get_exclusive_released() 588 * @dev: device to be reset by the controller 589 * @num_rstcs: number of entries in rstcs array 590 * @rstcs: array of struct reset_control_bulk_data with reset line names set 591 * 592 * Managed reset_control_bulk_get_exclusive_released(). For reset controllers 593 * returned from this function, reset_control_put() is called automatically on 594 * driver detach. 595 * 596 * See reset_control_bulk_get_exclusive_released() for more information. 597 */ 598 static inline int __must_check 599 devm_reset_control_bulk_get_exclusive_released(struct device *dev, int num_rstcs, 600 struct reset_control_bulk_data *rstcs) 601 { 602 return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, false, false, false); 603 } 604 605 /** 606 * devm_reset_control_get_optional_exclusive_released - resource managed 607 * reset_control_get_optional_exclusive_released() 608 * @dev: device to be reset by the controller 609 * @id: reset line name 610 * 611 * Managed-and-optional variant of reset_control_get_exclusive_released(). For 612 * reset controllers returned from this function, reset_control_put() is called 613 * automatically on driver detach. 614 * 615 * See reset_control_get_exclusive_released() for more information. 616 */ 617 static inline struct reset_control * 618 __must_check devm_reset_control_get_optional_exclusive_released(struct device *dev, 619 const char *id) 620 { 621 return __devm_reset_control_get(dev, id, 0, false, true, false); 622 } 623 624 /** 625 * devm_reset_control_bulk_get_optional_exclusive_released - resource managed 626 * reset_control_bulk_optional_get_exclusive_released() 627 * @dev: device to be reset by the controller 628 * @num_rstcs: number of entries in rstcs array 629 * @rstcs: array of struct reset_control_bulk_data with reset line names set 630 * 631 * Managed reset_control_bulk_optional_get_exclusive_released(). For reset 632 * controllers returned from this function, reset_control_put() is called 633 * automatically on driver detach. 634 * 635 * See reset_control_bulk_optional_get_exclusive_released() for more information. 636 */ 637 static inline int __must_check 638 devm_reset_control_bulk_get_optional_exclusive_released(struct device *dev, int num_rstcs, 639 struct reset_control_bulk_data *rstcs) 640 { 641 return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, false, true, false); 642 } 643 644 /** 645 * devm_reset_control_get_shared - resource managed reset_control_get_shared() 646 * @dev: device to be reset by the controller 647 * @id: reset line name 648 * 649 * Managed reset_control_get_shared(). For reset controllers returned from 650 * this function, reset_control_put() is called automatically on driver detach. 651 * See reset_control_get_shared() for more information. 652 */ 653 static inline struct reset_control *devm_reset_control_get_shared( 654 struct device *dev, const char *id) 655 { 656 return __devm_reset_control_get(dev, id, 0, true, false, false); 657 } 658 659 /** 660 * devm_reset_control_bulk_get_shared - resource managed 661 * reset_control_bulk_get_shared() 662 * @dev: device to be reset by the controller 663 * @num_rstcs: number of entries in rstcs array 664 * @rstcs: array of struct reset_control_bulk_data with reset line names set 665 * 666 * Managed reset_control_bulk_get_shared(). For reset controllers returned 667 * from this function, reset_control_put() is called automatically on driver 668 * detach. 669 * 670 * See reset_control_bulk_get_shared() for more information. 671 */ 672 static inline int __must_check 673 devm_reset_control_bulk_get_shared(struct device *dev, int num_rstcs, 674 struct reset_control_bulk_data *rstcs) 675 { 676 return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, true, false, false); 677 } 678 679 /** 680 * devm_reset_control_get_optional_exclusive - resource managed 681 * reset_control_get_optional_exclusive() 682 * @dev: device to be reset by the controller 683 * @id: reset line name 684 * 685 * Managed reset_control_get_optional_exclusive(). For reset controllers 686 * returned from this function, reset_control_put() is called automatically on 687 * driver detach. 688 * 689 * See reset_control_get_optional_exclusive() for more information. 690 */ 691 static inline struct reset_control *devm_reset_control_get_optional_exclusive( 692 struct device *dev, const char *id) 693 { 694 return __devm_reset_control_get(dev, id, 0, false, true, true); 695 } 696 697 /** 698 * devm_reset_control_bulk_get_optional_exclusive - resource managed 699 * reset_control_bulk_get_optional_exclusive() 700 * @dev: device to be reset by the controller 701 * @num_rstcs: number of entries in rstcs array 702 * @rstcs: array of struct reset_control_bulk_data with reset line names set 703 * 704 * Managed reset_control_bulk_get_optional_exclusive(). For reset controllers 705 * returned from this function, reset_control_put() is called automatically on 706 * driver detach. 707 * 708 * See reset_control_bulk_get_optional_exclusive() for more information. 709 */ 710 static inline int __must_check 711 devm_reset_control_bulk_get_optional_exclusive(struct device *dev, int num_rstcs, 712 struct reset_control_bulk_data *rstcs) 713 { 714 return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, true, false, true); 715 } 716 717 /** 718 * devm_reset_control_get_optional_shared - resource managed 719 * reset_control_get_optional_shared() 720 * @dev: device to be reset by the controller 721 * @id: reset line name 722 * 723 * Managed reset_control_get_optional_shared(). For reset controllers returned 724 * from this function, reset_control_put() is called automatically on driver 725 * detach. 726 * 727 * See reset_control_get_optional_shared() for more information. 728 */ 729 static inline struct reset_control *devm_reset_control_get_optional_shared( 730 struct device *dev, const char *id) 731 { 732 return __devm_reset_control_get(dev, id, 0, true, true, false); 733 } 734 735 /** 736 * devm_reset_control_bulk_get_optional_shared - resource managed 737 * reset_control_bulk_get_optional_shared() 738 * @dev: device to be reset by the controller 739 * @num_rstcs: number of entries in rstcs array 740 * @rstcs: array of struct reset_control_bulk_data with reset line names set 741 * 742 * Managed reset_control_bulk_get_optional_shared(). For reset controllers 743 * returned from this function, reset_control_put() is called automatically on 744 * driver detach. 745 * 746 * See reset_control_bulk_get_optional_shared() for more information. 747 */ 748 static inline int __must_check 749 devm_reset_control_bulk_get_optional_shared(struct device *dev, int num_rstcs, 750 struct reset_control_bulk_data *rstcs) 751 { 752 return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, true, true, false); 753 } 754 755 /** 756 * devm_reset_control_get_exclusive_by_index - resource managed 757 * reset_control_get_exclusive() 758 * @dev: device to be reset by the controller 759 * @index: index of the reset controller 760 * 761 * Managed reset_control_get_exclusive(). For reset controllers returned from 762 * this function, reset_control_put() is called automatically on driver 763 * detach. 764 * 765 * See reset_control_get_exclusive() for more information. 766 */ 767 static inline struct reset_control * 768 devm_reset_control_get_exclusive_by_index(struct device *dev, int index) 769 { 770 return __devm_reset_control_get(dev, NULL, index, false, false, true); 771 } 772 773 /** 774 * devm_reset_control_get_shared_by_index - resource managed 775 * reset_control_get_shared 776 * @dev: device to be reset by the controller 777 * @index: index of the reset controller 778 * 779 * Managed reset_control_get_shared(). For reset controllers returned from 780 * this function, reset_control_put() is called automatically on driver detach. 781 * See reset_control_get_shared() for more information. 782 */ 783 static inline struct reset_control * 784 devm_reset_control_get_shared_by_index(struct device *dev, int index) 785 { 786 return __devm_reset_control_get(dev, NULL, index, true, false, false); 787 } 788 789 /* 790 * TEMPORARY calls to use during transition: 791 * 792 * of_reset_control_get() => of_reset_control_get_exclusive() 793 * 794 * These inline function calls will be removed once all consumers 795 * have been moved over to the new explicit API. 796 */ 797 static inline struct reset_control *of_reset_control_get( 798 struct device_node *node, const char *id) 799 { 800 return of_reset_control_get_exclusive(node, id); 801 } 802 803 static inline struct reset_control *of_reset_control_get_by_index( 804 struct device_node *node, int index) 805 { 806 return of_reset_control_get_exclusive_by_index(node, index); 807 } 808 809 static inline struct reset_control *devm_reset_control_get( 810 struct device *dev, const char *id) 811 { 812 return devm_reset_control_get_exclusive(dev, id); 813 } 814 815 static inline struct reset_control *devm_reset_control_get_optional( 816 struct device *dev, const char *id) 817 { 818 return devm_reset_control_get_optional_exclusive(dev, id); 819 820 } 821 822 static inline struct reset_control *devm_reset_control_get_by_index( 823 struct device *dev, int index) 824 { 825 return devm_reset_control_get_exclusive_by_index(dev, index); 826 } 827 828 /* 829 * APIs to manage a list of reset controllers 830 */ 831 static inline struct reset_control * 832 devm_reset_control_array_get_exclusive(struct device *dev) 833 { 834 return devm_reset_control_array_get(dev, false, false); 835 } 836 837 static inline struct reset_control * 838 devm_reset_control_array_get_shared(struct device *dev) 839 { 840 return devm_reset_control_array_get(dev, true, false); 841 } 842 843 static inline struct reset_control * 844 devm_reset_control_array_get_optional_exclusive(struct device *dev) 845 { 846 return devm_reset_control_array_get(dev, false, true); 847 } 848 849 static inline struct reset_control * 850 devm_reset_control_array_get_optional_shared(struct device *dev) 851 { 852 return devm_reset_control_array_get(dev, true, true); 853 } 854 855 static inline struct reset_control * 856 of_reset_control_array_get_exclusive(struct device_node *node) 857 { 858 return of_reset_control_array_get(node, false, false, true); 859 } 860 861 static inline struct reset_control * 862 of_reset_control_array_get_exclusive_released(struct device_node *node) 863 { 864 return of_reset_control_array_get(node, false, false, false); 865 } 866 867 static inline struct reset_control * 868 of_reset_control_array_get_shared(struct device_node *node) 869 { 870 return of_reset_control_array_get(node, true, false, true); 871 } 872 873 static inline struct reset_control * 874 of_reset_control_array_get_optional_exclusive(struct device_node *node) 875 { 876 return of_reset_control_array_get(node, false, true, true); 877 } 878 879 static inline struct reset_control * 880 of_reset_control_array_get_optional_shared(struct device_node *node) 881 { 882 return of_reset_control_array_get(node, true, true, true); 883 } 884 #endif 885