Lines Matching refs:rstc
72 struct reset_control *rstc[] __counted_by(num_rstcs);
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()
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()
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()
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()
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()
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()
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()
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()
754 struct reset_control *rstc; in __reset_control_get_internal() local
763 list_for_each_entry(rstc, &rcdev->reset_control_head, list) { in __reset_control_get_internal()
764 if (rstc->id == index) { in __reset_control_get_internal()
770 if (!rstc->shared && !shared && !acquired) in __reset_control_get_internal()
773 if (WARN_ON(!rstc->shared || !shared)) in __reset_control_get_internal()
776 kref_get(&rstc->refcnt); in __reset_control_get_internal()
777 return rstc; in __reset_control_get_internal()
781 rstc = kzalloc(sizeof(*rstc), GFP_KERNEL); in __reset_control_get_internal()
782 if (!rstc) in __reset_control_get_internal()
786 kfree(rstc); in __reset_control_get_internal()
790 rstc->rcdev = rcdev; in __reset_control_get_internal()
791 list_add(&rstc->list, &rcdev->reset_control_head); in __reset_control_get_internal()
792 rstc->id = index; in __reset_control_get_internal()
793 kref_init(&rstc->refcnt); in __reset_control_get_internal()
794 rstc->acquired = acquired; in __reset_control_get_internal()
795 rstc->shared = shared; in __reset_control_get_internal()
798 return rstc; in __reset_control_get_internal()
803 struct reset_control *rstc = container_of(kref, struct reset_control, in __reset_control_release() local
808 module_put(rstc->rcdev->owner); in __reset_control_release()
810 list_del(&rstc->list); in __reset_control_release()
811 put_device(rstc->rcdev->dev); in __reset_control_release()
812 kfree(rstc); in __reset_control_release()
815 static void __reset_control_put_internal(struct reset_control *rstc) in __reset_control_put_internal() argument
819 if (IS_ERR_OR_NULL(rstc)) in __reset_control_put_internal()
822 kref_put(&rstc->refcnt, __reset_control_release); in __reset_control_put_internal()
1000 struct reset_control *rstc; in __of_reset_control_get() local
1039 rstc = ERR_PTR(ret); in __of_reset_control_get()
1047 rstc = ERR_PTR(-EPROBE_DEFER); in __of_reset_control_get()
1052 rstc = ERR_PTR(-EINVAL); in __of_reset_control_get()
1058 rstc = ERR_PTR(rstc_id); in __of_reset_control_get()
1065 rstc = __reset_control_get_internal(rcdev, rstc_id, flags); in __of_reset_control_get()
1072 return rstc; in __of_reset_control_get()
1100 rstcs[i].rstc = __reset_control_get(dev, rstcs[i].id, 0, flags); in __reset_control_bulk_get()
1101 if (IS_ERR(rstcs[i].rstc)) { in __reset_control_bulk_get()
1102 ret = PTR_ERR(rstcs[i].rstc); in __reset_control_bulk_get()
1112 __reset_control_put_internal(rstcs[i].rstc); in __reset_control_bulk_get()
1124 __reset_control_put_internal(resets->rstc[i]); in reset_control_array_put()
1133 void reset_control_put(struct reset_control *rstc) in reset_control_put() argument
1135 if (IS_ERR_OR_NULL(rstc)) in reset_control_put()
1138 if (reset_control_is_array(rstc)) { in reset_control_put()
1139 reset_control_array_put(rstc_to_array(rstc)); in reset_control_put()
1144 __reset_control_put_internal(rstc); in reset_control_put()
1158 __reset_control_put_internal(rstcs[num_rstcs].rstc); in reset_control_bulk_put()
1170 struct reset_control *rstc = *(struct reset_control **)res; in devm_reset_control_release_deasserted() local
1172 reset_control_assert(rstc); in devm_reset_control_release_deasserted()
1173 reset_control_put(rstc); in devm_reset_control_release_deasserted()
1180 struct reset_control **ptr, *rstc; in __devm_reset_control_get() local
1191 rstc = __reset_control_get(dev, id, index, flags); in __devm_reset_control_get()
1192 if (IS_ERR_OR_NULL(rstc)) { in __devm_reset_control_get()
1194 return rstc; in __devm_reset_control_get()
1200 ret = reset_control_deassert(rstc); in __devm_reset_control_get()
1202 reset_control_put(rstc); in __devm_reset_control_get()
1208 *ptr = rstc; in __devm_reset_control_get()
1211 return rstc; in __devm_reset_control_get()
1287 struct reset_control *rstc; in __device_reset() local
1303 rstc = __reset_control_get(dev, NULL, 0, flags); in __device_reset()
1304 if (IS_ERR(rstc)) in __device_reset()
1305 return PTR_ERR(rstc); in __device_reset()
1307 ret = reset_control_reset(rstc); in __device_reset()
1309 reset_control_put(rstc); in __device_reset()
1355 struct reset_control *rstc; in of_reset_control_array_get() local
1362 resets = kzalloc(struct_size(resets, rstc, num), GFP_KERNEL); in of_reset_control_array_get()
1368 rstc = __of_reset_control_get(np, NULL, i, flags); in of_reset_control_array_get()
1369 if (IS_ERR(rstc)) in of_reset_control_array_get()
1371 resets->rstc[i] = rstc; in of_reset_control_array_get()
1380 __reset_control_put_internal(resets->rstc[i]); in of_reset_control_array_get()
1385 return rstc; in of_reset_control_array_get()
1404 struct reset_control **ptr, *rstc; in devm_reset_control_array_get() local
1411 rstc = of_reset_control_array_get(dev->of_node, flags); in devm_reset_control_array_get()
1412 if (IS_ERR_OR_NULL(rstc)) { in devm_reset_control_array_get()
1414 return rstc; in devm_reset_control_array_get()
1417 *ptr = rstc; in devm_reset_control_array_get()
1420 return rstc; in devm_reset_control_array_get()