Lines Matching refs:rstc
73 struct reset_control *rstc[] __counted_by(num_rstcs);
221 rstc_to_array(struct reset_control *rstc) { in rstc_to_array() argument
222 return container_of(rstc, struct reset_control_array, base); in rstc_to_array()
230 ret = reset_control_reset(resets->rstc[i]); in reset_control_array_reset()
240 struct reset_control *rstc; in reset_control_array_rearm() local
244 rstc = resets->rstc[i]; in reset_control_array_rearm()
246 if (!rstc) in reset_control_array_rearm()
249 if (WARN_ON(IS_ERR(rstc))) in reset_control_array_rearm()
252 if (rstc->shared) { in reset_control_array_rearm()
253 if (WARN_ON(atomic_read(&rstc->deassert_count) != 0)) in reset_control_array_rearm()
256 if (!rstc->acquired) in reset_control_array_rearm()
262 rstc = resets->rstc[i]; in reset_control_array_rearm()
264 if (rstc && rstc->shared) in reset_control_array_rearm()
265 WARN_ON(atomic_dec_return(&rstc->triggered_count) < 0); in reset_control_array_rearm()
276 ret = reset_control_assert(resets->rstc[i]); in reset_control_array_assert()
285 reset_control_deassert(resets->rstc[i]); in reset_control_array_assert()
294 ret = reset_control_deassert(resets->rstc[i]); in reset_control_array_deassert()
303 reset_control_assert(resets->rstc[i]); in reset_control_array_deassert()
313 err = reset_control_acquire(resets->rstc[i]); in reset_control_array_acquire()
322 reset_control_release(resets->rstc[i]); in reset_control_array_acquire()
332 reset_control_release(resets->rstc[i]); in reset_control_array_release()
335 static inline bool reset_control_is_array(struct reset_control *rstc) in reset_control_is_array() argument
337 return rstc->array; in reset_control_is_array()
353 int reset_control_reset(struct reset_control *rstc) in reset_control_reset() argument
357 if (!rstc) in reset_control_reset()
360 if (WARN_ON(IS_ERR(rstc))) in reset_control_reset()
363 if (reset_control_is_array(rstc)) in reset_control_reset()
364 return reset_control_array_reset(rstc_to_array(rstc)); in reset_control_reset()
366 if (!rstc->rcdev->ops->reset) in reset_control_reset()
369 if (rstc->shared) { in reset_control_reset()
370 if (WARN_ON(atomic_read(&rstc->deassert_count) != 0)) in reset_control_reset()
373 if (atomic_inc_return(&rstc->triggered_count) != 1) in reset_control_reset()
376 if (!rstc->acquired) in reset_control_reset()
380 ret = rstc->rcdev->ops->reset(rstc->rcdev, rstc->id); in reset_control_reset()
381 if (rstc->shared && ret) in reset_control_reset()
382 atomic_dec(&rstc->triggered_count); in reset_control_reset()
403 ret = reset_control_reset(rstcs[i].rstc); in reset_control_bulk_reset()
427 int reset_control_rearm(struct reset_control *rstc) in reset_control_rearm() argument
429 if (!rstc) in reset_control_rearm()
432 if (WARN_ON(IS_ERR(rstc))) in reset_control_rearm()
435 if (reset_control_is_array(rstc)) in reset_control_rearm()
436 return reset_control_array_rearm(rstc_to_array(rstc)); in reset_control_rearm()
438 if (rstc->shared) { in reset_control_rearm()
439 if (WARN_ON(atomic_read(&rstc->deassert_count) != 0)) in reset_control_rearm()
442 WARN_ON(atomic_dec_return(&rstc->triggered_count) < 0); in reset_control_rearm()
444 if (!rstc->acquired) in reset_control_rearm()
468 int reset_control_assert(struct reset_control *rstc) in reset_control_assert() argument
470 if (!rstc) in reset_control_assert()
473 if (WARN_ON(IS_ERR(rstc))) in reset_control_assert()
476 if (reset_control_is_array(rstc)) in reset_control_assert()
477 return reset_control_array_assert(rstc_to_array(rstc)); in reset_control_assert()
479 if (rstc->shared) { in reset_control_assert()
480 if (WARN_ON(atomic_read(&rstc->triggered_count) != 0)) in reset_control_assert()
483 if (WARN_ON(atomic_read(&rstc->deassert_count) == 0)) in reset_control_assert()
486 if (atomic_dec_return(&rstc->deassert_count) != 0) in reset_control_assert()
493 if (!rstc->rcdev->ops->assert) in reset_control_assert()
501 if (!rstc->rcdev->ops->assert) in reset_control_assert()
504 if (!rstc->acquired) { in reset_control_assert()
506 rcdev_name(rstc->rcdev), rstc->id); in reset_control_assert()
511 return rstc->rcdev->ops->assert(rstc->rcdev, rstc->id); in reset_control_assert()
531 ret = reset_control_assert(rstcs[i].rstc); in reset_control_bulk_assert()
540 reset_control_deassert(rstcs[i].rstc); in reset_control_bulk_assert()
556 int reset_control_deassert(struct reset_control *rstc) in reset_control_deassert() argument
558 if (!rstc) in reset_control_deassert()
561 if (WARN_ON(IS_ERR(rstc))) in reset_control_deassert()
564 if (reset_control_is_array(rstc)) in reset_control_deassert()
565 return reset_control_array_deassert(rstc_to_array(rstc)); in reset_control_deassert()
567 if (rstc->shared) { in reset_control_deassert()
568 if (WARN_ON(atomic_read(&rstc->triggered_count) != 0)) in reset_control_deassert()
571 if (atomic_inc_return(&rstc->deassert_count) != 1) in reset_control_deassert()
574 if (!rstc->acquired) { in reset_control_deassert()
576 rcdev_name(rstc->rcdev), rstc->id); in reset_control_deassert()
588 if (!rstc->rcdev->ops->deassert) in reset_control_deassert()
591 return rstc->rcdev->ops->deassert(rstc->rcdev, rstc->id); in reset_control_deassert()
611 ret = reset_control_deassert(rstcs[i].rstc); in reset_control_bulk_deassert()
620 reset_control_assert(rstcs[i++].rstc); in reset_control_bulk_deassert()
631 int reset_control_status(struct reset_control *rstc) in reset_control_status() argument
633 if (!rstc) in reset_control_status()
636 if (WARN_ON(IS_ERR(rstc)) || reset_control_is_array(rstc)) in reset_control_status()
639 if (rstc->rcdev->ops->status) in reset_control_status()
640 return rstc->rcdev->ops->status(rstc->rcdev, rstc->id); in reset_control_status()
666 int reset_control_acquire(struct reset_control *rstc) in reset_control_acquire() argument
670 if (!rstc) in reset_control_acquire()
673 if (WARN_ON(IS_ERR(rstc))) in reset_control_acquire()
676 if (reset_control_is_array(rstc)) in reset_control_acquire()
677 return reset_control_array_acquire(rstc_to_array(rstc)); in reset_control_acquire()
681 if (rstc->acquired) { in reset_control_acquire()
686 list_for_each_entry(rc, &rstc->rcdev->reset_control_head, list) { in reset_control_acquire()
687 if (rstc != rc && rstc->id == rc->id) { in reset_control_acquire()
695 rstc->acquired = true; in reset_control_acquire()
718 ret = reset_control_acquire(rstcs[i].rstc); in reset_control_bulk_acquire()
727 reset_control_release(rstcs[i].rstc); in reset_control_bulk_acquire()
742 void reset_control_release(struct reset_control *rstc) in reset_control_release() argument
744 if (!rstc || WARN_ON(IS_ERR(rstc))) in reset_control_release()
747 if (reset_control_is_array(rstc)) in reset_control_release()
748 reset_control_array_release(rstc_to_array(rstc)); in reset_control_release()
750 rstc->acquired = false; in reset_control_release()
770 reset_control_release(rstcs[i].rstc); in reset_control_bulk_release()
778 struct reset_control *rstc; in __reset_control_get_internal() local
782 list_for_each_entry(rstc, &rcdev->reset_control_head, list) { in __reset_control_get_internal()
783 if (rstc->id == index) { in __reset_control_get_internal()
789 if (!rstc->shared && !shared && !acquired) in __reset_control_get_internal()
792 if (WARN_ON(!rstc->shared || !shared)) in __reset_control_get_internal()
795 kref_get(&rstc->refcnt); in __reset_control_get_internal()
796 return rstc; in __reset_control_get_internal()
800 rstc = kzalloc(sizeof(*rstc), GFP_KERNEL); in __reset_control_get_internal()
801 if (!rstc) in __reset_control_get_internal()
805 kfree(rstc); in __reset_control_get_internal()
809 rstc->rcdev = rcdev; in __reset_control_get_internal()
810 list_add(&rstc->list, &rcdev->reset_control_head); in __reset_control_get_internal()
811 rstc->id = index; in __reset_control_get_internal()
812 kref_init(&rstc->refcnt); in __reset_control_get_internal()
813 rstc->acquired = acquired; in __reset_control_get_internal()
814 rstc->shared = shared; in __reset_control_get_internal()
817 return rstc; in __reset_control_get_internal()
822 struct reset_control *rstc = container_of(kref, struct reset_control, in __reset_control_release() local
827 module_put(rstc->rcdev->owner); in __reset_control_release()
829 list_del(&rstc->list); in __reset_control_release()
830 put_device(rstc->rcdev->dev); in __reset_control_release()
831 kfree(rstc); in __reset_control_release()
834 static void __reset_control_put_internal(struct reset_control *rstc) in __reset_control_put_internal() argument
838 if (IS_ERR_OR_NULL(rstc)) in __reset_control_put_internal()
841 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()
1063 rstc = __reset_control_get_internal(rcdev, rstc_id, shared, acquired); in __of_reset_control_get()
1070 return rstc; in __of_reset_control_get()
1099 struct reset_control *rstc = NULL; in __reset_control_get_from_lookup() local
1119 rstc = __reset_control_get_internal(rcdev, in __reset_control_get_from_lookup()
1129 if (!rstc) in __reset_control_get_from_lookup()
1132 return rstc; in __reset_control_get_from_lookup()
1158 rstcs[i].rstc = __reset_control_get(dev, rstcs[i].id, 0, in __reset_control_bulk_get()
1160 if (IS_ERR(rstcs[i].rstc)) { in __reset_control_bulk_get()
1161 ret = PTR_ERR(rstcs[i].rstc); in __reset_control_bulk_get()
1171 __reset_control_put_internal(rstcs[i].rstc); in __reset_control_bulk_get()
1183 __reset_control_put_internal(resets->rstc[i]); in reset_control_array_put()
1192 void reset_control_put(struct reset_control *rstc) in reset_control_put() argument
1194 if (IS_ERR_OR_NULL(rstc)) in reset_control_put()
1197 if (reset_control_is_array(rstc)) { in reset_control_put()
1198 reset_control_array_put(rstc_to_array(rstc)); in reset_control_put()
1203 __reset_control_put_internal(rstc); in reset_control_put()
1217 __reset_control_put_internal(rstcs[num_rstcs].rstc); in reset_control_bulk_put()
1231 struct reset_control **ptr, *rstc; in __devm_reset_control_get() local
1238 rstc = __reset_control_get(dev, id, index, shared, optional, acquired); in __devm_reset_control_get()
1239 if (IS_ERR_OR_NULL(rstc)) { in __devm_reset_control_get()
1241 return rstc; in __devm_reset_control_get()
1244 *ptr = rstc; in __devm_reset_control_get()
1247 return rstc; in __devm_reset_control_get()
1301 struct reset_control *rstc; in __device_reset() local
1316 rstc = __reset_control_get(dev, NULL, 0, 0, optional, true); in __device_reset()
1317 if (IS_ERR(rstc)) in __device_reset()
1318 return PTR_ERR(rstc); in __device_reset()
1320 ret = reset_control_reset(rstc); in __device_reset()
1322 reset_control_put(rstc); in __device_reset()
1371 struct reset_control *rstc; in of_reset_control_array_get() local
1378 resets = kzalloc(struct_size(resets, rstc, num), GFP_KERNEL); in of_reset_control_array_get()
1384 rstc = __of_reset_control_get(np, NULL, i, shared, optional, in of_reset_control_array_get()
1386 if (IS_ERR(rstc)) in of_reset_control_array_get()
1388 resets->rstc[i] = rstc; in of_reset_control_array_get()
1397 __reset_control_put_internal(resets->rstc[i]); in of_reset_control_array_get()
1402 return rstc; in of_reset_control_array_get()
1422 struct reset_control **ptr, *rstc; in devm_reset_control_array_get() local
1429 rstc = of_reset_control_array_get(dev->of_node, shared, optional, true); in devm_reset_control_array_get()
1430 if (IS_ERR_OR_NULL(rstc)) { in devm_reset_control_array_get()
1432 return rstc; in devm_reset_control_array_get()
1435 *ptr = rstc; in devm_reset_control_array_get()
1438 return rstc; in devm_reset_control_array_get()