Lines Matching full:rstc
58 * @rstc: array of reset controls
63 struct reset_control *rstc[]; member
195 rstc_to_array(struct reset_control *rstc) { in rstc_to_array() argument
196 return container_of(rstc, struct reset_control_array, base); in rstc_to_array()
204 ret = reset_control_reset(resets->rstc[i]); in reset_control_array_reset()
214 struct reset_control *rstc; in reset_control_array_rearm() local
218 rstc = resets->rstc[i]; in reset_control_array_rearm()
220 if (!rstc) in reset_control_array_rearm()
223 if (WARN_ON(IS_ERR(rstc))) in reset_control_array_rearm()
226 if (rstc->shared) { in reset_control_array_rearm()
227 if (WARN_ON(atomic_read(&rstc->deassert_count) != 0)) in reset_control_array_rearm()
230 if (!rstc->acquired) in reset_control_array_rearm()
236 rstc = resets->rstc[i]; in reset_control_array_rearm()
238 if (rstc && rstc->shared) in reset_control_array_rearm()
239 WARN_ON(atomic_dec_return(&rstc->triggered_count) < 0); in reset_control_array_rearm()
250 ret = reset_control_assert(resets->rstc[i]); in reset_control_array_assert()
259 reset_control_deassert(resets->rstc[i]); in reset_control_array_assert()
268 ret = reset_control_deassert(resets->rstc[i]); in reset_control_array_deassert()
277 reset_control_assert(resets->rstc[i]); in reset_control_array_deassert()
287 err = reset_control_acquire(resets->rstc[i]); in reset_control_array_acquire()
296 reset_control_release(resets->rstc[i]); in reset_control_array_acquire()
306 reset_control_release(resets->rstc[i]); in reset_control_array_release()
309 static inline bool reset_control_is_array(struct reset_control *rstc) in reset_control_is_array() argument
311 return rstc->array; in reset_control_is_array()
316 * @rstc: reset controller
324 * If rstc is NULL it is an optional reset and the function will just
327 int reset_control_reset(struct reset_control *rstc) in reset_control_reset() argument
331 if (!rstc) in reset_control_reset()
334 if (WARN_ON(IS_ERR(rstc))) in reset_control_reset()
337 if (reset_control_is_array(rstc)) in reset_control_reset()
338 return reset_control_array_reset(rstc_to_array(rstc)); in reset_control_reset()
340 if (!rstc->rcdev->ops->reset) in reset_control_reset()
343 if (rstc->shared) { in reset_control_reset()
344 if (WARN_ON(atomic_read(&rstc->deassert_count) != 0)) in reset_control_reset()
347 if (atomic_inc_return(&rstc->triggered_count) != 1) in reset_control_reset()
350 if (!rstc->acquired) in reset_control_reset()
354 ret = rstc->rcdev->ops->reset(rstc->rcdev, rstc->id); in reset_control_reset()
355 if (rstc->shared && ret) in reset_control_reset()
356 atomic_dec(&rstc->triggered_count); in reset_control_reset()
377 ret = reset_control_reset(rstcs[i].rstc); in reset_control_bulk_reset()
388 * @rstc: reset controller
399 * If rstc is NULL the function will just return 0.
401 int reset_control_rearm(struct reset_control *rstc) in reset_control_rearm() argument
403 if (!rstc) in reset_control_rearm()
406 if (WARN_ON(IS_ERR(rstc))) in reset_control_rearm()
409 if (reset_control_is_array(rstc)) in reset_control_rearm()
410 return reset_control_array_rearm(rstc_to_array(rstc)); in reset_control_rearm()
412 if (rstc->shared) { in reset_control_rearm()
413 if (WARN_ON(atomic_read(&rstc->deassert_count) != 0)) in reset_control_rearm()
416 WARN_ON(atomic_dec_return(&rstc->triggered_count) < 0); in reset_control_rearm()
418 if (!rstc->acquired) in reset_control_rearm()
428 * @rstc: reset controller
439 * If rstc is NULL it is an optional reset and the function will just
442 int reset_control_assert(struct reset_control *rstc) in reset_control_assert() argument
444 if (!rstc) in reset_control_assert()
447 if (WARN_ON(IS_ERR(rstc))) in reset_control_assert()
450 if (reset_control_is_array(rstc)) in reset_control_assert()
451 return reset_control_array_assert(rstc_to_array(rstc)); in reset_control_assert()
453 if (rstc->shared) { in reset_control_assert()
454 if (WARN_ON(atomic_read(&rstc->triggered_count) != 0)) in reset_control_assert()
457 if (WARN_ON(atomic_read(&rstc->deassert_count) == 0)) in reset_control_assert()
460 if (atomic_dec_return(&rstc->deassert_count) != 0) in reset_control_assert()
467 if (!rstc->rcdev->ops->assert) in reset_control_assert()
475 if (!rstc->rcdev->ops->assert) in reset_control_assert()
478 if (!rstc->acquired) { in reset_control_assert()
480 rcdev_name(rstc->rcdev), rstc->id); in reset_control_assert()
485 return rstc->rcdev->ops->assert(rstc->rcdev, rstc->id); in reset_control_assert()
505 ret = reset_control_assert(rstcs[i].rstc); in reset_control_bulk_assert()
514 reset_control_deassert(rstcs[i].rstc); in reset_control_bulk_assert()
521 * @rstc: reset controller
527 * If rstc is NULL it is an optional reset and the function will just
530 int reset_control_deassert(struct reset_control *rstc) in reset_control_deassert() argument
532 if (!rstc) in reset_control_deassert()
535 if (WARN_ON(IS_ERR(rstc))) in reset_control_deassert()
538 if (reset_control_is_array(rstc)) in reset_control_deassert()
539 return reset_control_array_deassert(rstc_to_array(rstc)); in reset_control_deassert()
541 if (rstc->shared) { in reset_control_deassert()
542 if (WARN_ON(atomic_read(&rstc->triggered_count) != 0)) in reset_control_deassert()
545 if (atomic_inc_return(&rstc->deassert_count) != 1) in reset_control_deassert()
548 if (!rstc->acquired) { in reset_control_deassert()
550 rcdev_name(rstc->rcdev), rstc->id); in reset_control_deassert()
562 if (!rstc->rcdev->ops->deassert) in reset_control_deassert()
565 return rstc->rcdev->ops->deassert(rstc->rcdev, rstc->id); in reset_control_deassert()
585 ret = reset_control_deassert(rstcs[i].rstc); in reset_control_bulk_deassert()
594 reset_control_assert(rstcs[i++].rstc); in reset_control_bulk_deassert()
603 * @rstc: reset controller
605 int reset_control_status(struct reset_control *rstc) in reset_control_status() argument
607 if (!rstc) in reset_control_status()
610 if (WARN_ON(IS_ERR(rstc)) || reset_control_is_array(rstc)) in reset_control_status()
613 if (rstc->rcdev->ops->status) in reset_control_status()
614 return rstc->rcdev->ops->status(rstc->rcdev, rstc->id); in reset_control_status()
622 * @rstc: reset control
640 int reset_control_acquire(struct reset_control *rstc) in reset_control_acquire() argument
644 if (!rstc) in reset_control_acquire()
647 if (WARN_ON(IS_ERR(rstc))) in reset_control_acquire()
650 if (reset_control_is_array(rstc)) in reset_control_acquire()
651 return reset_control_array_acquire(rstc_to_array(rstc)); in reset_control_acquire()
655 if (rstc->acquired) { in reset_control_acquire()
660 list_for_each_entry(rc, &rstc->rcdev->reset_control_head, list) { in reset_control_acquire()
661 if (rstc != rc && rstc->id == rc->id) { in reset_control_acquire()
669 rstc->acquired = true; in reset_control_acquire()
692 ret = reset_control_acquire(rstcs[i].rstc); in reset_control_bulk_acquire()
701 reset_control_release(rstcs[i].rstc); in reset_control_bulk_acquire()
708 * @rstc: reset control
716 void reset_control_release(struct reset_control *rstc) in reset_control_release() argument
718 if (!rstc || WARN_ON(IS_ERR(rstc))) in reset_control_release()
721 if (reset_control_is_array(rstc)) in reset_control_release()
722 reset_control_array_release(rstc_to_array(rstc)); in reset_control_release()
724 rstc->acquired = false; in reset_control_release()
744 reset_control_release(rstcs[i].rstc); in reset_control_bulk_release()
752 struct reset_control *rstc; in __reset_control_get_internal() local
756 list_for_each_entry(rstc, &rcdev->reset_control_head, list) { in __reset_control_get_internal()
757 if (rstc->id == index) { in __reset_control_get_internal()
763 if (!rstc->shared && !shared && !acquired) in __reset_control_get_internal()
766 if (WARN_ON(!rstc->shared || !shared)) in __reset_control_get_internal()
769 kref_get(&rstc->refcnt); in __reset_control_get_internal()
770 return rstc; in __reset_control_get_internal()
774 rstc = kzalloc(sizeof(*rstc), GFP_KERNEL); in __reset_control_get_internal()
775 if (!rstc) in __reset_control_get_internal()
779 kfree(rstc); in __reset_control_get_internal()
783 rstc->rcdev = rcdev; in __reset_control_get_internal()
784 list_add(&rstc->list, &rcdev->reset_control_head); in __reset_control_get_internal()
785 rstc->id = index; in __reset_control_get_internal()
786 kref_init(&rstc->refcnt); in __reset_control_get_internal()
787 rstc->acquired = acquired; in __reset_control_get_internal()
788 rstc->shared = shared; in __reset_control_get_internal()
790 return rstc; in __reset_control_get_internal()
795 struct reset_control *rstc = container_of(kref, struct reset_control, in __reset_control_release() local
800 module_put(rstc->rcdev->owner); in __reset_control_release()
802 list_del(&rstc->list); in __reset_control_release()
803 kfree(rstc); in __reset_control_release()
806 static void __reset_control_put_internal(struct reset_control *rstc) in __reset_control_put_internal() argument
810 kref_put(&rstc->refcnt, __reset_control_release); in __reset_control_put_internal()
817 struct reset_control *rstc; in __of_reset_control_get() local
852 rstc = ERR_PTR(-EPROBE_DEFER); in __of_reset_control_get()
857 rstc = ERR_PTR(-EINVAL); in __of_reset_control_get()
863 rstc = ERR_PTR(rstc_id); in __of_reset_control_get()
868 rstc = __reset_control_get_internal(rcdev, rstc_id, shared, acquired); in __of_reset_control_get()
874 return rstc; in __of_reset_control_get()
903 struct reset_control *rstc = NULL; in __reset_control_get_from_lookup() local
923 rstc = __reset_control_get_internal(rcdev, in __reset_control_get_from_lookup()
933 if (!rstc) in __reset_control_get_from_lookup()
936 return rstc; in __reset_control_get_from_lookup()
962 rstcs[i].rstc = __reset_control_get(dev, rstcs[i].id, 0, in __reset_control_bulk_get()
964 if (IS_ERR(rstcs[i].rstc)) { in __reset_control_bulk_get()
965 ret = PTR_ERR(rstcs[i].rstc); in __reset_control_bulk_get()
975 __reset_control_put_internal(rstcs[i].rstc); in __reset_control_bulk_get()
987 __reset_control_put_internal(resets->rstc[i]); in reset_control_array_put()
994 * @rstc: reset controller
996 void reset_control_put(struct reset_control *rstc) in reset_control_put() argument
998 if (IS_ERR_OR_NULL(rstc)) in reset_control_put()
1001 if (reset_control_is_array(rstc)) { in reset_control_put()
1002 reset_control_array_put(rstc_to_array(rstc)); in reset_control_put()
1007 __reset_control_put_internal(rstc); in reset_control_put()
1021 if (IS_ERR_OR_NULL(rstcs[num_rstcs].rstc)) in reset_control_bulk_put()
1023 __reset_control_put_internal(rstcs[num_rstcs].rstc); in reset_control_bulk_put()
1038 struct reset_control **ptr, *rstc; in __devm_reset_control_get() local
1045 rstc = __reset_control_get(dev, id, index, shared, optional, acquired); in __devm_reset_control_get()
1046 if (IS_ERR_OR_NULL(rstc)) { in __devm_reset_control_get()
1048 return rstc; in __devm_reset_control_get()
1051 *ptr = rstc; in __devm_reset_control_get()
1054 return rstc; in __devm_reset_control_get()
1108 struct reset_control *rstc; in __device_reset() local
1123 rstc = __reset_control_get(dev, NULL, 0, 0, optional, true); in __device_reset()
1124 if (IS_ERR(rstc)) in __device_reset()
1125 return PTR_ERR(rstc); in __device_reset()
1127 ret = reset_control_reset(rstc); in __device_reset()
1129 reset_control_put(rstc); in __device_reset()
1178 struct reset_control *rstc; in of_reset_control_array_get() local
1185 resets = kzalloc(struct_size(resets, rstc, num), GFP_KERNEL); in of_reset_control_array_get()
1190 rstc = __of_reset_control_get(np, NULL, i, shared, optional, in of_reset_control_array_get()
1192 if (IS_ERR(rstc)) in of_reset_control_array_get()
1194 resets->rstc[i] = rstc; in of_reset_control_array_get()
1204 __reset_control_put_internal(resets->rstc[i]); in of_reset_control_array_get()
1209 return rstc; in of_reset_control_array_get()
1229 struct reset_control **ptr, *rstc; in devm_reset_control_array_get() local
1236 rstc = of_reset_control_array_get(dev->of_node, shared, optional, true); in devm_reset_control_array_get()
1237 if (IS_ERR_OR_NULL(rstc)) { in devm_reset_control_array_get()
1239 return rstc; in devm_reset_control_array_get()
1242 *ptr = rstc; in devm_reset_control_array_get()
1245 return rstc; in devm_reset_control_array_get()