Lines Matching full:rstc
68 * @rstc: array of reset controls
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()
342 * @rstc: reset controller
350 * If rstc is NULL it is an optional reset and the function will just
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()
414 * @rstc: reset controller
425 * If rstc is NULL the function will just return 0.
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()
454 * @rstc: reset controller
465 * If rstc is NULL it is an optional reset and the function will just
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()
547 * @rstc: reset controller
553 * If rstc is NULL it is an optional reset and the function will just
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()
629 * @rstc: reset controller
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()
648 * @rstc: reset control
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()
734 * @rstc: reset control
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()
780 struct reset_control *rstc; in __reset_control_get_internal() local
789 list_for_each_entry(rstc, &rcdev->reset_control_head, list) { in __reset_control_get_internal()
790 if (rstc->id == index) { in __reset_control_get_internal()
796 if (!rstc->shared && !shared && !acquired) in __reset_control_get_internal()
799 if (WARN_ON(!rstc->shared || !shared)) in __reset_control_get_internal()
802 kref_get(&rstc->refcnt); in __reset_control_get_internal()
803 return rstc; in __reset_control_get_internal()
807 rstc = kzalloc(sizeof(*rstc), GFP_KERNEL); in __reset_control_get_internal()
808 if (!rstc) in __reset_control_get_internal()
812 kfree(rstc); in __reset_control_get_internal()
816 rstc->rcdev = rcdev; in __reset_control_get_internal()
817 list_add(&rstc->list, &rcdev->reset_control_head); in __reset_control_get_internal()
818 rstc->id = index; in __reset_control_get_internal()
819 kref_init(&rstc->refcnt); in __reset_control_get_internal()
820 rstc->acquired = acquired; in __reset_control_get_internal()
821 rstc->shared = shared; in __reset_control_get_internal()
824 return rstc; in __reset_control_get_internal()
829 struct reset_control *rstc = container_of(kref, struct reset_control, in __reset_control_release() local
834 module_put(rstc->rcdev->owner); in __reset_control_release()
836 list_del(&rstc->list); in __reset_control_release()
837 put_device(rstc->rcdev->dev); in __reset_control_release()
838 kfree(rstc); in __reset_control_release()
841 static void __reset_control_put_internal(struct reset_control *rstc) in __reset_control_put_internal() argument
845 if (IS_ERR_OR_NULL(rstc)) in __reset_control_put_internal()
848 kref_put(&rstc->refcnt, __reset_control_release); in __reset_control_put_internal()
1008 struct reset_control *rstc; in __of_reset_control_get() local
1047 rstc = ERR_PTR(ret); in __of_reset_control_get()
1055 rstc = ERR_PTR(-EPROBE_DEFER); in __of_reset_control_get()
1060 rstc = ERR_PTR(-EINVAL); in __of_reset_control_get()
1066 rstc = ERR_PTR(rstc_id); in __of_reset_control_get()
1073 rstc = __reset_control_get_internal(rcdev, rstc_id, flags); in __of_reset_control_get()
1080 return rstc; in __of_reset_control_get()
1110 struct reset_control *rstc = NULL; in __reset_control_get_from_lookup() local
1132 rstc = __reset_control_get_internal(rcdev, in __reset_control_get_from_lookup()
1142 if (!rstc) in __reset_control_get_from_lookup()
1145 return rstc; in __reset_control_get_from_lookup()
1171 rstcs[i].rstc = __reset_control_get(dev, rstcs[i].id, 0, flags); in __reset_control_bulk_get()
1172 if (IS_ERR(rstcs[i].rstc)) { in __reset_control_bulk_get()
1173 ret = PTR_ERR(rstcs[i].rstc); in __reset_control_bulk_get()
1183 __reset_control_put_internal(rstcs[i].rstc); in __reset_control_bulk_get()
1195 __reset_control_put_internal(resets->rstc[i]); in reset_control_array_put()
1202 * @rstc: reset controller
1204 void reset_control_put(struct reset_control *rstc) in reset_control_put() argument
1206 if (IS_ERR_OR_NULL(rstc)) in reset_control_put()
1209 if (reset_control_is_array(rstc)) { in reset_control_put()
1210 reset_control_array_put(rstc_to_array(rstc)); in reset_control_put()
1215 __reset_control_put_internal(rstc); in reset_control_put()
1229 __reset_control_put_internal(rstcs[num_rstcs].rstc); in reset_control_bulk_put()
1241 struct reset_control *rstc = *(struct reset_control **)res; in devm_reset_control_release_deasserted() local
1243 reset_control_assert(rstc); in devm_reset_control_release_deasserted()
1244 reset_control_put(rstc); in devm_reset_control_release_deasserted()
1251 struct reset_control **ptr, *rstc; in __devm_reset_control_get() local
1262 rstc = __reset_control_get(dev, id, index, flags); in __devm_reset_control_get()
1263 if (IS_ERR_OR_NULL(rstc)) { in __devm_reset_control_get()
1265 return rstc; in __devm_reset_control_get()
1271 ret = reset_control_deassert(rstc); in __devm_reset_control_get()
1273 reset_control_put(rstc); in __devm_reset_control_get()
1279 *ptr = rstc; in __devm_reset_control_get()
1282 return rstc; in __devm_reset_control_get()
1358 struct reset_control *rstc; in __device_reset() local
1374 rstc = __reset_control_get(dev, NULL, 0, flags); in __device_reset()
1375 if (IS_ERR(rstc)) in __device_reset()
1376 return PTR_ERR(rstc); in __device_reset()
1378 ret = reset_control_reset(rstc); in __device_reset()
1380 reset_control_put(rstc); in __device_reset()
1426 struct reset_control *rstc; in of_reset_control_array_get() local
1433 resets = kzalloc(struct_size(resets, rstc, num), GFP_KERNEL); in of_reset_control_array_get()
1439 rstc = __of_reset_control_get(np, NULL, i, flags); in of_reset_control_array_get()
1440 if (IS_ERR(rstc)) in of_reset_control_array_get()
1442 resets->rstc[i] = rstc; in of_reset_control_array_get()
1451 __reset_control_put_internal(resets->rstc[i]); in of_reset_control_array_get()
1456 return rstc; in of_reset_control_array_get()
1475 struct reset_control **ptr, *rstc; in devm_reset_control_array_get() local
1482 rstc = of_reset_control_array_get(dev->of_node, flags); in devm_reset_control_array_get()
1483 if (IS_ERR_OR_NULL(rstc)) { in devm_reset_control_array_get()
1485 return rstc; in devm_reset_control_array_get()
1488 *ptr = rstc; in devm_reset_control_array_get()
1491 return rstc; in devm_reset_control_array_get()