Lines Matching refs:rstc
62 struct reset_control *rstc[]; member
194 rstc_to_array(struct reset_control *rstc) { in rstc_to_array() argument
195 return container_of(rstc, struct reset_control_array, base); in rstc_to_array()
203 ret = reset_control_reset(resets->rstc[i]); in reset_control_array_reset()
213 struct reset_control *rstc; in reset_control_array_rearm() local
217 rstc = resets->rstc[i]; in reset_control_array_rearm()
219 if (!rstc) in reset_control_array_rearm()
222 if (WARN_ON(IS_ERR(rstc))) in reset_control_array_rearm()
225 if (rstc->shared) { in reset_control_array_rearm()
226 if (WARN_ON(atomic_read(&rstc->deassert_count) != 0)) in reset_control_array_rearm()
229 if (!rstc->acquired) in reset_control_array_rearm()
235 rstc = resets->rstc[i]; in reset_control_array_rearm()
237 if (rstc && rstc->shared) in reset_control_array_rearm()
238 WARN_ON(atomic_dec_return(&rstc->triggered_count) < 0); in reset_control_array_rearm()
249 ret = reset_control_assert(resets->rstc[i]); in reset_control_array_assert()
258 reset_control_deassert(resets->rstc[i]); in reset_control_array_assert()
267 ret = reset_control_deassert(resets->rstc[i]); in reset_control_array_deassert()
276 reset_control_assert(resets->rstc[i]); in reset_control_array_deassert()
286 err = reset_control_acquire(resets->rstc[i]); in reset_control_array_acquire()
295 reset_control_release(resets->rstc[i]); in reset_control_array_acquire()
305 reset_control_release(resets->rstc[i]); in reset_control_array_release()
308 static inline bool reset_control_is_array(struct reset_control *rstc) in reset_control_is_array() argument
310 return rstc->array; in reset_control_is_array()
326 int reset_control_reset(struct reset_control *rstc) in reset_control_reset() argument
330 if (!rstc) in reset_control_reset()
333 if (WARN_ON(IS_ERR(rstc))) in reset_control_reset()
336 if (reset_control_is_array(rstc)) in reset_control_reset()
337 return reset_control_array_reset(rstc_to_array(rstc)); in reset_control_reset()
339 if (!rstc->rcdev->ops->reset) in reset_control_reset()
342 if (rstc->shared) { in reset_control_reset()
343 if (WARN_ON(atomic_read(&rstc->deassert_count) != 0)) in reset_control_reset()
346 if (atomic_inc_return(&rstc->triggered_count) != 1) in reset_control_reset()
349 if (!rstc->acquired) in reset_control_reset()
353 ret = rstc->rcdev->ops->reset(rstc->rcdev, rstc->id); in reset_control_reset()
354 if (rstc->shared && ret) in reset_control_reset()
355 atomic_dec(&rstc->triggered_count); in reset_control_reset()
376 ret = reset_control_reset(rstcs[i].rstc); in reset_control_bulk_reset()
400 int reset_control_rearm(struct reset_control *rstc) in reset_control_rearm() argument
402 if (!rstc) in reset_control_rearm()
405 if (WARN_ON(IS_ERR(rstc))) in reset_control_rearm()
408 if (reset_control_is_array(rstc)) in reset_control_rearm()
409 return reset_control_array_rearm(rstc_to_array(rstc)); in reset_control_rearm()
411 if (rstc->shared) { in reset_control_rearm()
412 if (WARN_ON(atomic_read(&rstc->deassert_count) != 0)) in reset_control_rearm()
415 WARN_ON(atomic_dec_return(&rstc->triggered_count) < 0); in reset_control_rearm()
417 if (!rstc->acquired) in reset_control_rearm()
441 int reset_control_assert(struct reset_control *rstc) in reset_control_assert() argument
443 if (!rstc) in reset_control_assert()
446 if (WARN_ON(IS_ERR(rstc))) in reset_control_assert()
449 if (reset_control_is_array(rstc)) in reset_control_assert()
450 return reset_control_array_assert(rstc_to_array(rstc)); in reset_control_assert()
452 if (rstc->shared) { in reset_control_assert()
453 if (WARN_ON(atomic_read(&rstc->triggered_count) != 0)) in reset_control_assert()
456 if (WARN_ON(atomic_read(&rstc->deassert_count) == 0)) in reset_control_assert()
459 if (atomic_dec_return(&rstc->deassert_count) != 0) in reset_control_assert()
466 if (!rstc->rcdev->ops->assert) in reset_control_assert()
474 if (!rstc->rcdev->ops->assert) in reset_control_assert()
477 if (!rstc->acquired) { in reset_control_assert()
479 rcdev_name(rstc->rcdev), rstc->id); in reset_control_assert()
484 return rstc->rcdev->ops->assert(rstc->rcdev, rstc->id); in reset_control_assert()
504 ret = reset_control_assert(rstcs[i].rstc); in reset_control_bulk_assert()
513 reset_control_deassert(rstcs[i].rstc); in reset_control_bulk_assert()
529 int reset_control_deassert(struct reset_control *rstc) in reset_control_deassert() argument
531 if (!rstc) in reset_control_deassert()
534 if (WARN_ON(IS_ERR(rstc))) in reset_control_deassert()
537 if (reset_control_is_array(rstc)) in reset_control_deassert()
538 return reset_control_array_deassert(rstc_to_array(rstc)); in reset_control_deassert()
540 if (rstc->shared) { in reset_control_deassert()
541 if (WARN_ON(atomic_read(&rstc->triggered_count) != 0)) in reset_control_deassert()
544 if (atomic_inc_return(&rstc->deassert_count) != 1) in reset_control_deassert()
547 if (!rstc->acquired) { in reset_control_deassert()
549 rcdev_name(rstc->rcdev), rstc->id); in reset_control_deassert()
561 if (!rstc->rcdev->ops->deassert) in reset_control_deassert()
564 return rstc->rcdev->ops->deassert(rstc->rcdev, rstc->id); in reset_control_deassert()
584 ret = reset_control_deassert(rstcs[i].rstc); in reset_control_bulk_deassert()
593 reset_control_assert(rstcs[i++].rstc); in reset_control_bulk_deassert()
604 int reset_control_status(struct reset_control *rstc) in reset_control_status() argument
606 if (!rstc) in reset_control_status()
609 if (WARN_ON(IS_ERR(rstc)) || reset_control_is_array(rstc)) in reset_control_status()
612 if (rstc->rcdev->ops->status) in reset_control_status()
613 return rstc->rcdev->ops->status(rstc->rcdev, rstc->id); in reset_control_status()
639 int reset_control_acquire(struct reset_control *rstc) in reset_control_acquire() argument
643 if (!rstc) in reset_control_acquire()
646 if (WARN_ON(IS_ERR(rstc))) in reset_control_acquire()
649 if (reset_control_is_array(rstc)) in reset_control_acquire()
650 return reset_control_array_acquire(rstc_to_array(rstc)); in reset_control_acquire()
654 if (rstc->acquired) { in reset_control_acquire()
659 list_for_each_entry(rc, &rstc->rcdev->reset_control_head, list) { in reset_control_acquire()
660 if (rstc != rc && rstc->id == rc->id) { in reset_control_acquire()
668 rstc->acquired = true; in reset_control_acquire()
691 ret = reset_control_acquire(rstcs[i].rstc); in reset_control_bulk_acquire()
700 reset_control_release(rstcs[i].rstc); in reset_control_bulk_acquire()
715 void reset_control_release(struct reset_control *rstc) in reset_control_release() argument
717 if (!rstc || WARN_ON(IS_ERR(rstc))) in reset_control_release()
720 if (reset_control_is_array(rstc)) in reset_control_release()
721 reset_control_array_release(rstc_to_array(rstc)); in reset_control_release()
723 rstc->acquired = false; in reset_control_release()
743 reset_control_release(rstcs[i].rstc); in reset_control_bulk_release()
751 struct reset_control *rstc; in __reset_control_get_internal() local
755 list_for_each_entry(rstc, &rcdev->reset_control_head, list) { in __reset_control_get_internal()
756 if (rstc->id == index) { in __reset_control_get_internal()
762 if (!rstc->shared && !shared && !acquired) in __reset_control_get_internal()
765 if (WARN_ON(!rstc->shared || !shared)) in __reset_control_get_internal()
768 kref_get(&rstc->refcnt); in __reset_control_get_internal()
769 return rstc; in __reset_control_get_internal()
773 rstc = kzalloc(sizeof(*rstc), GFP_KERNEL); in __reset_control_get_internal()
774 if (!rstc) in __reset_control_get_internal()
778 kfree(rstc); in __reset_control_get_internal()
782 rstc->rcdev = rcdev; in __reset_control_get_internal()
783 list_add(&rstc->list, &rcdev->reset_control_head); in __reset_control_get_internal()
784 rstc->id = index; in __reset_control_get_internal()
785 kref_init(&rstc->refcnt); in __reset_control_get_internal()
786 rstc->acquired = acquired; in __reset_control_get_internal()
787 rstc->shared = shared; in __reset_control_get_internal()
789 return rstc; in __reset_control_get_internal()
794 struct reset_control *rstc = container_of(kref, struct reset_control, in __reset_control_release() local
799 module_put(rstc->rcdev->owner); in __reset_control_release()
801 list_del(&rstc->list); in __reset_control_release()
802 kfree(rstc); in __reset_control_release()
805 static void __reset_control_put_internal(struct reset_control *rstc) in __reset_control_put_internal() argument
809 kref_put(&rstc->refcnt, __reset_control_release); in __reset_control_put_internal()
816 struct reset_control *rstc; in __of_reset_control_get() local
851 rstc = ERR_PTR(-EPROBE_DEFER); in __of_reset_control_get()
856 rstc = ERR_PTR(-EINVAL); in __of_reset_control_get()
862 rstc = ERR_PTR(rstc_id); in __of_reset_control_get()
867 rstc = __reset_control_get_internal(rcdev, rstc_id, shared, acquired); in __of_reset_control_get()
873 return rstc; in __of_reset_control_get()
902 struct reset_control *rstc = NULL; in __reset_control_get_from_lookup() local
922 rstc = __reset_control_get_internal(rcdev, in __reset_control_get_from_lookup()
932 if (!rstc) in __reset_control_get_from_lookup()
935 return rstc; in __reset_control_get_from_lookup()
961 rstcs[i].rstc = __reset_control_get(dev, rstcs[i].id, 0, in __reset_control_bulk_get()
963 if (IS_ERR(rstcs[i].rstc)) { in __reset_control_bulk_get()
964 ret = PTR_ERR(rstcs[i].rstc); in __reset_control_bulk_get()
974 __reset_control_put_internal(rstcs[i].rstc); in __reset_control_bulk_get()
986 __reset_control_put_internal(resets->rstc[i]); in reset_control_array_put()
995 void reset_control_put(struct reset_control *rstc) in reset_control_put() argument
997 if (IS_ERR_OR_NULL(rstc)) in reset_control_put()
1000 if (reset_control_is_array(rstc)) { in reset_control_put()
1001 reset_control_array_put(rstc_to_array(rstc)); in reset_control_put()
1006 __reset_control_put_internal(rstc); in reset_control_put()
1020 if (IS_ERR_OR_NULL(rstcs[num_rstcs].rstc)) in reset_control_bulk_put()
1022 __reset_control_put_internal(rstcs[num_rstcs].rstc); in reset_control_bulk_put()
1037 struct reset_control **ptr, *rstc; in __devm_reset_control_get() local
1044 rstc = __reset_control_get(dev, id, index, shared, optional, acquired); in __devm_reset_control_get()
1045 if (IS_ERR_OR_NULL(rstc)) { in __devm_reset_control_get()
1047 return rstc; in __devm_reset_control_get()
1050 *ptr = rstc; in __devm_reset_control_get()
1053 return rstc; in __devm_reset_control_get()
1107 struct reset_control *rstc; in __device_reset() local
1110 rstc = __reset_control_get(dev, NULL, 0, 0, optional, true); in __device_reset()
1111 if (IS_ERR(rstc)) in __device_reset()
1112 return PTR_ERR(rstc); in __device_reset()
1114 ret = reset_control_reset(rstc); in __device_reset()
1116 reset_control_put(rstc); in __device_reset()
1165 struct reset_control *rstc; in of_reset_control_array_get() local
1172 resets = kzalloc(struct_size(resets, rstc, num), GFP_KERNEL); in of_reset_control_array_get()
1177 rstc = __of_reset_control_get(np, NULL, i, shared, optional, in of_reset_control_array_get()
1179 if (IS_ERR(rstc)) in of_reset_control_array_get()
1181 resets->rstc[i] = rstc; in of_reset_control_array_get()
1191 __reset_control_put_internal(resets->rstc[i]); in of_reset_control_array_get()
1196 return rstc; in of_reset_control_array_get()
1216 struct reset_control **ptr, *rstc; in devm_reset_control_array_get() local
1223 rstc = of_reset_control_array_get(dev->of_node, shared, optional, true); in devm_reset_control_array_get()
1224 if (IS_ERR_OR_NULL(rstc)) { in devm_reset_control_array_get()
1226 return rstc; in devm_reset_control_array_get()
1229 *ptr = rstc; in devm_reset_control_array_get()
1232 return rstc; in devm_reset_control_array_get()