Lines Matching refs:rstc

61 	struct reset_control *rstc[];  member
190 rstc_to_array(struct reset_control *rstc) { in rstc_to_array() argument
191 return container_of(rstc, struct reset_control_array, base); in rstc_to_array()
199 ret = reset_control_reset(resets->rstc[i]); in reset_control_array_reset()
212 ret = reset_control_assert(resets->rstc[i]); in reset_control_array_assert()
221 reset_control_deassert(resets->rstc[i]); in reset_control_array_assert()
230 ret = reset_control_deassert(resets->rstc[i]); in reset_control_array_deassert()
239 reset_control_assert(resets->rstc[i]); in reset_control_array_deassert()
249 err = reset_control_acquire(resets->rstc[i]); in reset_control_array_acquire()
258 reset_control_release(resets->rstc[i]); in reset_control_array_acquire()
268 reset_control_release(resets->rstc[i]); in reset_control_array_release()
271 static inline bool reset_control_is_array(struct reset_control *rstc) in reset_control_is_array() argument
273 return rstc->array; in reset_control_is_array()
289 int reset_control_reset(struct reset_control *rstc) in reset_control_reset() argument
293 if (!rstc) in reset_control_reset()
296 if (WARN_ON(IS_ERR(rstc))) in reset_control_reset()
299 if (reset_control_is_array(rstc)) in reset_control_reset()
300 return reset_control_array_reset(rstc_to_array(rstc)); in reset_control_reset()
302 if (!rstc->rcdev->ops->reset) in reset_control_reset()
305 if (rstc->shared) { in reset_control_reset()
306 if (WARN_ON(atomic_read(&rstc->deassert_count) != 0)) in reset_control_reset()
309 if (atomic_inc_return(&rstc->triggered_count) != 1) in reset_control_reset()
312 if (!rstc->acquired) in reset_control_reset()
316 ret = rstc->rcdev->ops->reset(rstc->rcdev, rstc->id); in reset_control_reset()
317 if (rstc->shared && ret) in reset_control_reset()
318 atomic_dec(&rstc->triggered_count); in reset_control_reset()
341 int reset_control_assert(struct reset_control *rstc) in reset_control_assert() argument
343 if (!rstc) in reset_control_assert()
346 if (WARN_ON(IS_ERR(rstc))) in reset_control_assert()
349 if (reset_control_is_array(rstc)) in reset_control_assert()
350 return reset_control_array_assert(rstc_to_array(rstc)); in reset_control_assert()
352 if (rstc->shared) { in reset_control_assert()
353 if (WARN_ON(atomic_read(&rstc->triggered_count) != 0)) in reset_control_assert()
356 if (WARN_ON(atomic_read(&rstc->deassert_count) == 0)) in reset_control_assert()
359 if (atomic_dec_return(&rstc->deassert_count) != 0) in reset_control_assert()
366 if (!rstc->rcdev->ops->assert) in reset_control_assert()
374 if (!rstc->rcdev->ops->assert) in reset_control_assert()
377 if (!rstc->acquired) { in reset_control_assert()
379 rcdev_name(rstc->rcdev), rstc->id); in reset_control_assert()
384 return rstc->rcdev->ops->assert(rstc->rcdev, rstc->id); in reset_control_assert()
400 int reset_control_deassert(struct reset_control *rstc) in reset_control_deassert() argument
402 if (!rstc) in reset_control_deassert()
405 if (WARN_ON(IS_ERR(rstc))) in reset_control_deassert()
408 if (reset_control_is_array(rstc)) in reset_control_deassert()
409 return reset_control_array_deassert(rstc_to_array(rstc)); in reset_control_deassert()
411 if (rstc->shared) { in reset_control_deassert()
412 if (WARN_ON(atomic_read(&rstc->triggered_count) != 0)) in reset_control_deassert()
415 if (atomic_inc_return(&rstc->deassert_count) != 1) in reset_control_deassert()
418 if (!rstc->acquired) { in reset_control_deassert()
420 rcdev_name(rstc->rcdev), rstc->id); in reset_control_deassert()
432 if (!rstc->rcdev->ops->deassert) in reset_control_deassert()
435 return rstc->rcdev->ops->deassert(rstc->rcdev, rstc->id); in reset_control_deassert()
445 int reset_control_status(struct reset_control *rstc) in reset_control_status() argument
447 if (!rstc) in reset_control_status()
450 if (WARN_ON(IS_ERR(rstc)) || reset_control_is_array(rstc)) in reset_control_status()
453 if (rstc->rcdev->ops->status) in reset_control_status()
454 return rstc->rcdev->ops->status(rstc->rcdev, rstc->id); in reset_control_status()
480 int reset_control_acquire(struct reset_control *rstc) in reset_control_acquire() argument
484 if (!rstc) in reset_control_acquire()
487 if (WARN_ON(IS_ERR(rstc))) in reset_control_acquire()
490 if (reset_control_is_array(rstc)) in reset_control_acquire()
491 return reset_control_array_acquire(rstc_to_array(rstc)); in reset_control_acquire()
495 if (rstc->acquired) { in reset_control_acquire()
500 list_for_each_entry(rc, &rstc->rcdev->reset_control_head, list) { in reset_control_acquire()
501 if (rstc != rc && rstc->id == rc->id) { in reset_control_acquire()
509 rstc->acquired = true; in reset_control_acquire()
526 void reset_control_release(struct reset_control *rstc) in reset_control_release() argument
528 if (!rstc || WARN_ON(IS_ERR(rstc))) in reset_control_release()
531 if (reset_control_is_array(rstc)) in reset_control_release()
532 reset_control_array_release(rstc_to_array(rstc)); in reset_control_release()
534 rstc->acquired = false; in reset_control_release()
542 struct reset_control *rstc; in __reset_control_get_internal() local
546 list_for_each_entry(rstc, &rcdev->reset_control_head, list) { in __reset_control_get_internal()
547 if (rstc->id == index) { in __reset_control_get_internal()
553 if (!rstc->shared && !shared && !acquired) in __reset_control_get_internal()
556 if (WARN_ON(!rstc->shared || !shared)) in __reset_control_get_internal()
559 kref_get(&rstc->refcnt); in __reset_control_get_internal()
560 return rstc; in __reset_control_get_internal()
564 rstc = kzalloc(sizeof(*rstc), GFP_KERNEL); in __reset_control_get_internal()
565 if (!rstc) in __reset_control_get_internal()
570 rstc->rcdev = rcdev; in __reset_control_get_internal()
571 list_add(&rstc->list, &rcdev->reset_control_head); in __reset_control_get_internal()
572 rstc->id = index; in __reset_control_get_internal()
573 kref_init(&rstc->refcnt); in __reset_control_get_internal()
574 rstc->acquired = acquired; in __reset_control_get_internal()
575 rstc->shared = shared; in __reset_control_get_internal()
577 return rstc; in __reset_control_get_internal()
582 struct reset_control *rstc = container_of(kref, struct reset_control, in __reset_control_release() local
587 module_put(rstc->rcdev->owner); in __reset_control_release()
589 list_del(&rstc->list); in __reset_control_release()
590 kfree(rstc); in __reset_control_release()
593 static void __reset_control_put_internal(struct reset_control *rstc) in __reset_control_put_internal() argument
597 kref_put(&rstc->refcnt, __reset_control_release); in __reset_control_put_internal()
604 struct reset_control *rstc; in __of_reset_control_get() local
639 rstc = ERR_PTR(-EPROBE_DEFER); in __of_reset_control_get()
644 rstc = ERR_PTR(-EINVAL); in __of_reset_control_get()
650 rstc = ERR_PTR(rstc_id); in __of_reset_control_get()
655 rstc = __reset_control_get_internal(rcdev, rstc_id, shared, acquired); in __of_reset_control_get()
661 return rstc; in __of_reset_control_get()
690 struct reset_control *rstc = NULL; in __reset_control_get_from_lookup() local
710 rstc = __reset_control_get_internal(rcdev, in __reset_control_get_from_lookup()
720 if (!rstc) in __reset_control_get_from_lookup()
723 return rstc; in __reset_control_get_from_lookup()
748 __reset_control_put_internal(resets->rstc[i]); in reset_control_array_put()
757 void reset_control_put(struct reset_control *rstc) in reset_control_put() argument
759 if (IS_ERR_OR_NULL(rstc)) in reset_control_put()
762 if (reset_control_is_array(rstc)) { in reset_control_put()
763 reset_control_array_put(rstc_to_array(rstc)); in reset_control_put()
768 __reset_control_put_internal(rstc); in reset_control_put()
782 struct reset_control **ptr, *rstc; in __devm_reset_control_get() local
789 rstc = __reset_control_get(dev, id, index, shared, optional, acquired); in __devm_reset_control_get()
790 if (!IS_ERR(rstc)) { in __devm_reset_control_get()
791 *ptr = rstc; in __devm_reset_control_get()
797 return rstc; in __devm_reset_control_get()
813 struct reset_control *rstc; in __device_reset() local
816 rstc = __reset_control_get(dev, NULL, 0, 0, optional, true); in __device_reset()
817 if (IS_ERR(rstc)) in __device_reset()
818 return PTR_ERR(rstc); in __device_reset()
820 ret = reset_control_reset(rstc); in __device_reset()
822 reset_control_put(rstc); in __device_reset()
872 struct reset_control *rstc; in of_reset_control_array_get() local
879 resets = kzalloc(struct_size(resets, rstc, num), GFP_KERNEL); in of_reset_control_array_get()
884 rstc = __of_reset_control_get(np, NULL, i, shared, optional, in of_reset_control_array_get()
886 if (IS_ERR(rstc)) in of_reset_control_array_get()
888 resets->rstc[i] = rstc; in of_reset_control_array_get()
898 __reset_control_put_internal(resets->rstc[i]); in of_reset_control_array_get()
903 return rstc; in of_reset_control_array_get()
925 struct reset_control *rstc; in devm_reset_control_array_get() local
932 rstc = of_reset_control_array_get(dev->of_node, shared, optional, true); in devm_reset_control_array_get()
933 if (IS_ERR(rstc)) { in devm_reset_control_array_get()
935 return rstc; in devm_reset_control_array_get()
938 *devres = rstc; in devm_reset_control_array_get()
941 return rstc; in devm_reset_control_array_get()