• Home
  • Raw
  • Download

Lines Matching full:rstc

57  * @rstc: array of reset controls
62 struct reset_control *rstc[]; member
194 rstc_to_array(struct reset_control *rstc) { in rstc_to_array() argument
195 return container_of(rstc, struct reset_control_array, base); in rstc_to_array()
203 ret = reset_control_reset(resets->rstc[i]); in reset_control_array_reset()
216 ret = reset_control_assert(resets->rstc[i]); in reset_control_array_assert()
225 reset_control_deassert(resets->rstc[i]); in reset_control_array_assert()
234 ret = reset_control_deassert(resets->rstc[i]); in reset_control_array_deassert()
243 reset_control_assert(resets->rstc[i]); in reset_control_array_deassert()
253 err = reset_control_acquire(resets->rstc[i]); in reset_control_array_acquire()
262 reset_control_release(resets->rstc[i]); in reset_control_array_acquire()
272 reset_control_release(resets->rstc[i]); in reset_control_array_release()
275 static inline bool reset_control_is_array(struct reset_control *rstc) in reset_control_is_array() argument
277 return rstc->array; in reset_control_is_array()
282 * @rstc: reset controller
290 * If rstc is NULL it is an optional reset and the function will just
293 int reset_control_reset(struct reset_control *rstc) in reset_control_reset() argument
297 if (!rstc) in reset_control_reset()
300 if (WARN_ON(IS_ERR(rstc))) in reset_control_reset()
303 if (reset_control_is_array(rstc)) in reset_control_reset()
304 return reset_control_array_reset(rstc_to_array(rstc)); in reset_control_reset()
306 if (!rstc->rcdev->ops->reset) in reset_control_reset()
309 if (rstc->shared) { in reset_control_reset()
310 if (WARN_ON(atomic_read(&rstc->deassert_count) != 0)) in reset_control_reset()
313 if (atomic_inc_return(&rstc->triggered_count) != 1) in reset_control_reset()
316 if (!rstc->acquired) in reset_control_reset()
320 ret = rstc->rcdev->ops->reset(rstc->rcdev, rstc->id); in reset_control_reset()
321 if (rstc->shared && ret) in reset_control_reset()
322 atomic_dec(&rstc->triggered_count); in reset_control_reset()
330 * @rstc: reset controller
341 * If rstc is NULL it is an optional reset and the function will just
344 int reset_control_assert(struct reset_control *rstc) in reset_control_assert() argument
346 if (!rstc) in reset_control_assert()
349 if (WARN_ON(IS_ERR(rstc))) in reset_control_assert()
352 if (reset_control_is_array(rstc)) in reset_control_assert()
353 return reset_control_array_assert(rstc_to_array(rstc)); in reset_control_assert()
355 if (rstc->shared) { in reset_control_assert()
356 if (WARN_ON(atomic_read(&rstc->triggered_count) != 0)) in reset_control_assert()
359 if (WARN_ON(atomic_read(&rstc->deassert_count) == 0)) in reset_control_assert()
362 if (atomic_dec_return(&rstc->deassert_count) != 0) in reset_control_assert()
369 if (!rstc->rcdev->ops->assert) in reset_control_assert()
377 if (!rstc->rcdev->ops->assert) in reset_control_assert()
380 if (!rstc->acquired) { in reset_control_assert()
382 rcdev_name(rstc->rcdev), rstc->id); in reset_control_assert()
387 return rstc->rcdev->ops->assert(rstc->rcdev, rstc->id); in reset_control_assert()
393 * @rstc: reset controller
399 * If rstc is NULL it is an optional reset and the function will just
402 int reset_control_deassert(struct reset_control *rstc) in reset_control_deassert() argument
404 if (!rstc) in reset_control_deassert()
407 if (WARN_ON(IS_ERR(rstc))) in reset_control_deassert()
410 if (reset_control_is_array(rstc)) in reset_control_deassert()
411 return reset_control_array_deassert(rstc_to_array(rstc)); in reset_control_deassert()
413 if (rstc->shared) { in reset_control_deassert()
414 if (WARN_ON(atomic_read(&rstc->triggered_count) != 0)) in reset_control_deassert()
417 if (atomic_inc_return(&rstc->deassert_count) != 1) in reset_control_deassert()
420 if (!rstc->acquired) { in reset_control_deassert()
422 rcdev_name(rstc->rcdev), rstc->id); in reset_control_deassert()
434 if (!rstc->rcdev->ops->deassert) in reset_control_deassert()
437 return rstc->rcdev->ops->deassert(rstc->rcdev, rstc->id); in reset_control_deassert()
445 * @rstc: reset controller
447 int reset_control_status(struct reset_control *rstc) in reset_control_status() argument
449 if (!rstc) in reset_control_status()
452 if (WARN_ON(IS_ERR(rstc)) || reset_control_is_array(rstc)) in reset_control_status()
455 if (rstc->rcdev->ops->status) in reset_control_status()
456 return rstc->rcdev->ops->status(rstc->rcdev, rstc->id); in reset_control_status()
464 * @rstc: reset control
482 int reset_control_acquire(struct reset_control *rstc) in reset_control_acquire() argument
486 if (!rstc) in reset_control_acquire()
489 if (WARN_ON(IS_ERR(rstc))) in reset_control_acquire()
492 if (reset_control_is_array(rstc)) in reset_control_acquire()
493 return reset_control_array_acquire(rstc_to_array(rstc)); in reset_control_acquire()
497 if (rstc->acquired) { in reset_control_acquire()
502 list_for_each_entry(rc, &rstc->rcdev->reset_control_head, list) { in reset_control_acquire()
503 if (rstc != rc && rstc->id == rc->id) { in reset_control_acquire()
511 rstc->acquired = true; in reset_control_acquire()
520 * @rstc: reset control
528 void reset_control_release(struct reset_control *rstc) in reset_control_release() argument
530 if (!rstc || WARN_ON(IS_ERR(rstc))) in reset_control_release()
533 if (reset_control_is_array(rstc)) in reset_control_release()
534 reset_control_array_release(rstc_to_array(rstc)); in reset_control_release()
536 rstc->acquired = false; in reset_control_release()
544 struct reset_control *rstc; in __reset_control_get_internal() local
548 list_for_each_entry(rstc, &rcdev->reset_control_head, list) { in __reset_control_get_internal()
549 if (rstc->id == index) { in __reset_control_get_internal()
555 if (!rstc->shared && !shared && !acquired) in __reset_control_get_internal()
558 if (WARN_ON(!rstc->shared || !shared)) in __reset_control_get_internal()
561 kref_get(&rstc->refcnt); in __reset_control_get_internal()
562 return rstc; in __reset_control_get_internal()
566 rstc = kzalloc(sizeof(*rstc), GFP_KERNEL); in __reset_control_get_internal()
567 if (!rstc) in __reset_control_get_internal()
571 kfree(rstc); in __reset_control_get_internal()
575 rstc->rcdev = rcdev; in __reset_control_get_internal()
576 list_add(&rstc->list, &rcdev->reset_control_head); in __reset_control_get_internal()
577 rstc->id = index; in __reset_control_get_internal()
578 kref_init(&rstc->refcnt); in __reset_control_get_internal()
579 rstc->acquired = acquired; in __reset_control_get_internal()
580 rstc->shared = shared; in __reset_control_get_internal()
582 return rstc; in __reset_control_get_internal()
587 struct reset_control *rstc = container_of(kref, struct reset_control, in __reset_control_release() local
592 module_put(rstc->rcdev->owner); in __reset_control_release()
594 list_del(&rstc->list); in __reset_control_release()
595 kfree(rstc); in __reset_control_release()
598 static void __reset_control_put_internal(struct reset_control *rstc) in __reset_control_put_internal() argument
602 if (IS_ERR_OR_NULL(rstc)) in __reset_control_put_internal()
605 kref_put(&rstc->refcnt, __reset_control_release); in __reset_control_put_internal()
612 struct reset_control *rstc; in __of_reset_control_get() local
647 rstc = ERR_PTR(-EPROBE_DEFER); in __of_reset_control_get()
652 rstc = ERR_PTR(-EINVAL); in __of_reset_control_get()
658 rstc = ERR_PTR(rstc_id); in __of_reset_control_get()
663 rstc = __reset_control_get_internal(rcdev, rstc_id, shared, acquired); in __of_reset_control_get()
669 return rstc; in __of_reset_control_get()
698 struct reset_control *rstc = NULL; in __reset_control_get_from_lookup() local
718 rstc = __reset_control_get_internal(rcdev, in __reset_control_get_from_lookup()
728 if (!rstc) in __reset_control_get_from_lookup()
731 return rstc; in __reset_control_get_from_lookup()
756 __reset_control_put_internal(resets->rstc[i]); in reset_control_array_put()
763 * @rstc: reset controller
765 void reset_control_put(struct reset_control *rstc) in reset_control_put() argument
767 if (IS_ERR_OR_NULL(rstc)) in reset_control_put()
770 if (reset_control_is_array(rstc)) { in reset_control_put()
771 reset_control_array_put(rstc_to_array(rstc)); in reset_control_put()
776 __reset_control_put_internal(rstc); in reset_control_put()
790 struct reset_control **ptr, *rstc; in __devm_reset_control_get() local
797 rstc = __reset_control_get(dev, id, index, shared, optional, acquired); in __devm_reset_control_get()
798 if (IS_ERR_OR_NULL(rstc)) { in __devm_reset_control_get()
800 return rstc; in __devm_reset_control_get()
803 *ptr = rstc; in __devm_reset_control_get()
806 return rstc; in __devm_reset_control_get()
822 struct reset_control *rstc; in __device_reset() local
825 rstc = __reset_control_get(dev, NULL, 0, 0, optional, true); in __device_reset()
826 if (IS_ERR(rstc)) in __device_reset()
827 return PTR_ERR(rstc); in __device_reset()
829 ret = reset_control_reset(rstc); in __device_reset()
831 reset_control_put(rstc); in __device_reset()
880 struct reset_control *rstc; in of_reset_control_array_get() local
887 resets = kzalloc(struct_size(resets, rstc, num), GFP_KERNEL); in of_reset_control_array_get()
892 rstc = __of_reset_control_get(np, NULL, i, shared, optional, in of_reset_control_array_get()
894 if (IS_ERR(rstc)) in of_reset_control_array_get()
896 resets->rstc[i] = rstc; in of_reset_control_array_get()
906 __reset_control_put_internal(resets->rstc[i]); in of_reset_control_array_get()
911 return rstc; in of_reset_control_array_get()
931 struct reset_control **ptr, *rstc; in devm_reset_control_array_get() local
938 rstc = of_reset_control_array_get(dev->of_node, shared, optional, true); in devm_reset_control_array_get()
939 if (IS_ERR_OR_NULL(rstc)) { in devm_reset_control_array_get()
941 return rstc; in devm_reset_control_array_get()
944 *ptr = rstc; in devm_reset_control_array_get()
947 return rstc; in devm_reset_control_array_get()