Lines Matching defs:rstc

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