Lines Matching defs:rstc
58 * @rstc: array of reset controls
63 struct reset_control *rstc[];
195 rstc_to_array(struct reset_control *rstc) {
196 return container_of(rstc, struct reset_control_array, base);
204 ret = reset_control_reset(resets->rstc[i]);
214 struct reset_control *rstc;
218 rstc = resets->rstc[i];
220 if (!rstc)
223 if (WARN_ON(IS_ERR(rstc)))
226 if (rstc->shared) {
227 if (WARN_ON(atomic_read(&rstc->deassert_count) != 0))
230 if (!rstc->acquired)
236 rstc = resets->rstc[i];
238 if (rstc && rstc->shared)
239 WARN_ON(atomic_dec_return(&rstc->triggered_count) < 0);
250 ret = reset_control_assert(resets->rstc[i]);
259 reset_control_deassert(resets->rstc[i]);
268 ret = reset_control_deassert(resets->rstc[i]);
277 reset_control_assert(resets->rstc[i]);
287 err = reset_control_acquire(resets->rstc[i]);
296 reset_control_release(resets->rstc[i]);
306 reset_control_release(resets->rstc[i]);
309 static inline bool reset_control_is_array(struct reset_control *rstc)
311 return rstc->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)
331 if (!rstc)
334 if (WARN_ON(IS_ERR(rstc)))
337 if (reset_control_is_array(rstc))
338 return reset_control_array_reset(rstc_to_array(rstc));
340 if (!rstc->rcdev->ops->reset)
343 if (rstc->shared) {
344 if (WARN_ON(atomic_read(&rstc->deassert_count) != 0))
347 if (atomic_inc_return(&rstc->triggered_count) != 1)
350 if (!rstc->acquired)
354 ret = rstc->rcdev->ops->reset(rstc->rcdev, rstc->id);
355 if (rstc->shared && ret)
356 atomic_dec(&rstc->triggered_count);
377 ret = reset_control_reset(rstcs[i].rstc);
388 * @rstc: reset controller
399 * If rstc is NULL the function will just return 0.
401 int reset_control_rearm(struct reset_control *rstc)
403 if (!rstc)
406 if (WARN_ON(IS_ERR(rstc)))
409 if (reset_control_is_array(rstc))
410 return reset_control_array_rearm(rstc_to_array(rstc));
412 if (rstc->shared) {
413 if (WARN_ON(atomic_read(&rstc->deassert_count) != 0))
416 WARN_ON(atomic_dec_return(&rstc->triggered_count) < 0);
418 if (!rstc->acquired)
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)
444 if (!rstc)
447 if (WARN_ON(IS_ERR(rstc)))
450 if (reset_control_is_array(rstc))
451 return reset_control_array_assert(rstc_to_array(rstc));
453 if (rstc->shared) {
454 if (WARN_ON(atomic_read(&rstc->triggered_count) != 0))
457 if (WARN_ON(atomic_read(&rstc->deassert_count) == 0))
460 if (atomic_dec_return(&rstc->deassert_count) != 0)
467 if (!rstc->rcdev->ops->assert)
475 if (!rstc->rcdev->ops->assert)
478 if (!rstc->acquired) {
480 rcdev_name(rstc->rcdev), rstc->id);
485 return rstc->rcdev->ops->assert(rstc->rcdev, rstc->id);
505 ret = reset_control_assert(rstcs[i].rstc);
514 reset_control_deassert(rstcs[i].rstc);
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)
532 if (!rstc)
535 if (WARN_ON(IS_ERR(rstc)))
538 if (reset_control_is_array(rstc))
539 return reset_control_array_deassert(rstc_to_array(rstc));
541 if (rstc->shared) {
542 if (WARN_ON(atomic_read(&rstc->triggered_count) != 0))
545 if (atomic_inc_return(&rstc->deassert_count) != 1)
548 if (!rstc->acquired) {
550 rcdev_name(rstc->rcdev), rstc->id);
562 if (!rstc->rcdev->ops->deassert)
565 return rstc->rcdev->ops->deassert(rstc->rcdev, rstc->id);
585 ret = reset_control_deassert(rstcs[i].rstc);
594 reset_control_assert(rstcs[i++].rstc);
603 * @rstc: reset controller
605 int reset_control_status(struct reset_control *rstc)
607 if (!rstc)
610 if (WARN_ON(IS_ERR(rstc)) || reset_control_is_array(rstc))
613 if (rstc->rcdev->ops->status)
614 return rstc->rcdev->ops->status(rstc->rcdev, rstc->id);
622 * @rstc: reset control
640 int reset_control_acquire(struct reset_control *rstc)
644 if (!rstc)
647 if (WARN_ON(IS_ERR(rstc)))
650 if (reset_control_is_array(rstc))
651 return reset_control_array_acquire(rstc_to_array(rstc));
655 if (rstc->acquired) {
660 list_for_each_entry(rc, &rstc->rcdev->reset_control_head, list) {
661 if (rstc != rc && rstc->id == rc->id) {
669 rstc->acquired = true;
692 ret = reset_control_acquire(rstcs[i].rstc);
701 reset_control_release(rstcs[i].rstc);
708 * @rstc: reset control
716 void reset_control_release(struct reset_control *rstc)
718 if (!rstc || WARN_ON(IS_ERR(rstc)))
721 if (reset_control_is_array(rstc))
722 reset_control_array_release(rstc_to_array(rstc));
724 rstc->acquired = false;
744 reset_control_release(rstcs[i].rstc);
752 struct reset_control *rstc;
756 list_for_each_entry(rstc, &rcdev->reset_control_head, list) {
757 if (rstc->id == index) {
763 if (!rstc->shared && !shared && !acquired)
766 if (WARN_ON(!rstc->shared || !shared))
769 kref_get(&rstc->refcnt);
770 return rstc;
774 rstc = kzalloc(sizeof(*rstc), GFP_KERNEL);
775 if (!rstc)
779 kfree(rstc);
783 rstc->rcdev = rcdev;
784 list_add(&rstc->list, &rcdev->reset_control_head);
785 rstc->id = index;
786 kref_init(&rstc->refcnt);
787 rstc->acquired = acquired;
788 rstc->shared = shared;
790 return rstc;
795 struct reset_control *rstc = container_of(kref, struct reset_control,
800 module_put(rstc->rcdev->owner);
802 list_del(&rstc->list);
803 kfree(rstc);
806 static void __reset_control_put_internal(struct reset_control *rstc)
810 if (IS_ERR_OR_NULL(rstc))
813 kref_put(&rstc->refcnt, __reset_control_release);
820 struct reset_control *rstc;
855 rstc = ERR_PTR(-EPROBE_DEFER);
860 rstc = ERR_PTR(-EINVAL);
866 rstc = ERR_PTR(rstc_id);
871 rstc = __reset_control_get_internal(rcdev, rstc_id, shared, acquired);
877 return rstc;
906 struct reset_control *rstc = NULL;
926 rstc = __reset_control_get_internal(rcdev,
936 if (!rstc)
939 return rstc;
965 rstcs[i].rstc = __reset_control_get(dev, rstcs[i].id, 0,
967 if (IS_ERR(rstcs[i].rstc)) {
968 ret = PTR_ERR(rstcs[i].rstc);
978 __reset_control_put_internal(rstcs[i].rstc);
990 __reset_control_put_internal(resets->rstc[i]);
997 * @rstc: reset controller
999 void reset_control_put(struct reset_control *rstc)
1001 if (IS_ERR_OR_NULL(rstc))
1004 if (reset_control_is_array(rstc)) {
1005 reset_control_array_put(rstc_to_array(rstc));
1010 __reset_control_put_internal(rstc);
1024 __reset_control_put_internal(rstcs[num_rstcs].rstc);
1038 struct reset_control **ptr, *rstc;
1045 rstc = __reset_control_get(dev, id, index, shared, optional, acquired);
1046 if (IS_ERR_OR_NULL(rstc)) {
1048 return rstc;
1051 *ptr = rstc;
1054 return rstc;
1108 struct reset_control *rstc;
1123 rstc = __reset_control_get(dev, NULL, 0, 0, optional, true);
1124 if (IS_ERR(rstc))
1125 return PTR_ERR(rstc);
1127 ret = reset_control_reset(rstc);
1129 reset_control_put(rstc);
1178 struct reset_control *rstc;
1185 resets = kzalloc(struct_size(resets, rstc, num), GFP_KERNEL);
1190 rstc = __of_reset_control_get(np, NULL, i, shared, optional,
1192 if (IS_ERR(rstc))
1194 resets->rstc[i] = rstc;
1204 __reset_control_put_internal(resets->rstc[i]);
1209 return rstc;
1229 struct reset_control **ptr, *rstc;
1236 rstc = of_reset_control_array_get(dev->of_node, shared, optional, true);
1237 if (IS_ERR_OR_NULL(rstc)) {
1239 return rstc;
1242 *ptr = rstc;
1245 return rstc;