Lines Matching defs:rstc

68  * @rstc: array of reset controls
73 struct reset_control *rstc[] __counted_by(num_rstcs);
221 rstc_to_array(struct reset_control *rstc) {
222 return container_of(rstc, struct reset_control_array, base);
230 ret = reset_control_reset(resets->rstc[i]);
240 struct reset_control *rstc;
244 rstc = resets->rstc[i];
246 if (!rstc)
249 if (WARN_ON(IS_ERR(rstc)))
252 if (rstc->shared) {
253 if (WARN_ON(atomic_read(&rstc->deassert_count) != 0))
256 if (!rstc->acquired)
262 rstc = resets->rstc[i];
264 if (rstc && rstc->shared)
265 WARN_ON(atomic_dec_return(&rstc->triggered_count) < 0);
276 ret = reset_control_assert(resets->rstc[i]);
285 reset_control_deassert(resets->rstc[i]);
294 ret = reset_control_deassert(resets->rstc[i]);
303 reset_control_assert(resets->rstc[i]);
313 err = reset_control_acquire(resets->rstc[i]);
322 reset_control_release(resets->rstc[i]);
332 reset_control_release(resets->rstc[i]);
335 static inline bool reset_control_is_array(struct reset_control *rstc)
337 return rstc->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)
357 if (!rstc)
360 if (WARN_ON(IS_ERR(rstc)))
363 if (reset_control_is_array(rstc))
364 return reset_control_array_reset(rstc_to_array(rstc));
366 if (!rstc->rcdev->ops->reset)
369 if (rstc->shared) {
370 if (WARN_ON(atomic_read(&rstc->deassert_count) != 0))
373 if (atomic_inc_return(&rstc->triggered_count) != 1)
376 if (!rstc->acquired)
380 ret = rstc->rcdev->ops->reset(rstc->rcdev, rstc->id);
381 if (rstc->shared && ret)
382 atomic_dec(&rstc->triggered_count);
403 ret = reset_control_reset(rstcs[i].rstc);
414 * @rstc: reset controller
425 * If rstc is NULL the function will just return 0.
427 int reset_control_rearm(struct reset_control *rstc)
429 if (!rstc)
432 if (WARN_ON(IS_ERR(rstc)))
435 if (reset_control_is_array(rstc))
436 return reset_control_array_rearm(rstc_to_array(rstc));
438 if (rstc->shared) {
439 if (WARN_ON(atomic_read(&rstc->deassert_count) != 0))
442 WARN_ON(atomic_dec_return(&rstc->triggered_count) < 0);
444 if (!rstc->acquired)
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)
470 if (!rstc)
473 if (WARN_ON(IS_ERR(rstc)))
476 if (reset_control_is_array(rstc))
477 return reset_control_array_assert(rstc_to_array(rstc));
479 if (rstc->shared) {
480 if (WARN_ON(atomic_read(&rstc->triggered_count) != 0))
483 if (WARN_ON(atomic_read(&rstc->deassert_count) == 0))
486 if (atomic_dec_return(&rstc->deassert_count) != 0)
493 if (!rstc->rcdev->ops->assert)
501 if (!rstc->rcdev->ops->assert)
504 if (!rstc->acquired) {
506 rcdev_name(rstc->rcdev), rstc->id);
511 return rstc->rcdev->ops->assert(rstc->rcdev, rstc->id);
531 ret = reset_control_assert(rstcs[i].rstc);
540 reset_control_deassert(rstcs[i].rstc);
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)
558 if (!rstc)
561 if (WARN_ON(IS_ERR(rstc)))
564 if (reset_control_is_array(rstc))
565 return reset_control_array_deassert(rstc_to_array(rstc));
567 if (rstc->shared) {
568 if (WARN_ON(atomic_read(&rstc->triggered_count) != 0))
571 if (atomic_inc_return(&rstc->deassert_count) != 1)
574 if (!rstc->acquired) {
576 rcdev_name(rstc->rcdev), rstc->id);
588 if (!rstc->rcdev->ops->deassert)
591 return rstc->rcdev->ops->deassert(rstc->rcdev, rstc->id);
611 ret = reset_control_deassert(rstcs[i].rstc);
620 reset_control_assert(rstcs[i++].rstc);
629 * @rstc: reset controller
631 int reset_control_status(struct reset_control *rstc)
633 if (!rstc)
636 if (WARN_ON(IS_ERR(rstc)) || reset_control_is_array(rstc))
639 if (rstc->rcdev->ops->status)
640 return rstc->rcdev->ops->status(rstc->rcdev, rstc->id);
648 * @rstc: reset control
666 int reset_control_acquire(struct reset_control *rstc)
670 if (!rstc)
673 if (WARN_ON(IS_ERR(rstc)))
676 if (reset_control_is_array(rstc))
677 return reset_control_array_acquire(rstc_to_array(rstc));
681 if (rstc->acquired) {
686 list_for_each_entry(rc, &rstc->rcdev->reset_control_head, list) {
687 if (rstc != rc && rstc->id == rc->id) {
695 rstc->acquired = true;
718 ret = reset_control_acquire(rstcs[i].rstc);
727 reset_control_release(rstcs[i].rstc);
734 * @rstc: reset control
742 void reset_control_release(struct reset_control *rstc)
744 if (!rstc || WARN_ON(IS_ERR(rstc)))
747 if (reset_control_is_array(rstc))
748 reset_control_array_release(rstc_to_array(rstc));
750 rstc->acquired = false;
770 reset_control_release(rstcs[i].rstc);
778 struct reset_control *rstc;
782 list_for_each_entry(rstc, &rcdev->reset_control_head, list) {
783 if (rstc->id == index) {
789 if (!rstc->shared && !shared && !acquired)
792 if (WARN_ON(!rstc->shared || !shared))
795 kref_get(&rstc->refcnt);
796 return rstc;
800 rstc = kzalloc(sizeof(*rstc), GFP_KERNEL);
801 if (!rstc)
805 kfree(rstc);
809 rstc->rcdev = rcdev;
810 list_add(&rstc->list, &rcdev->reset_control_head);
811 rstc->id = index;
812 kref_init(&rstc->refcnt);
813 rstc->acquired = acquired;
814 rstc->shared = shared;
816 return rstc;
821 struct reset_control *rstc = container_of(kref, struct reset_control,
826 module_put(rstc->rcdev->owner);
828 list_del(&rstc->list);
829 kfree(rstc);
832 static void __reset_control_put_internal(struct reset_control *rstc)
836 if (IS_ERR_OR_NULL(rstc))
839 kref_put(&rstc->refcnt, __reset_control_release);
1005 struct reset_control *rstc;
1044 rstc = ERR_PTR(ret);
1052 rstc = ERR_PTR(-EPROBE_DEFER);
1057 rstc = ERR_PTR(-EINVAL);
1063 rstc = ERR_PTR(rstc_id);
1068 rstc = __reset_control_get_internal(rcdev, rstc_id, shared, acquired);
1075 return rstc;
1104 struct reset_control *rstc = NULL;
1124 rstc = __reset_control_get_internal(rcdev,
1134 if (!rstc)
1137 return rstc;
1163 rstcs[i].rstc = __reset_control_get(dev, rstcs[i].id, 0,
1165 if (IS_ERR(rstcs[i].rstc)) {
1166 ret = PTR_ERR(rstcs[i].rstc);
1176 __reset_control_put_internal(rstcs[i].rstc);
1188 __reset_control_put_internal(resets->rstc[i]);
1195 * @rstc: reset controller
1197 void reset_control_put(struct reset_control *rstc)
1199 if (IS_ERR_OR_NULL(rstc))
1202 if (reset_control_is_array(rstc)) {
1203 reset_control_array_put(rstc_to_array(rstc));
1208 __reset_control_put_internal(rstc);
1222 __reset_control_put_internal(rstcs[num_rstcs].rstc);
1236 struct reset_control **ptr, *rstc;
1243 rstc = __reset_control_get(dev, id, index, shared, optional, acquired);
1244 if (IS_ERR_OR_NULL(rstc)) {
1246 return rstc;
1249 *ptr = rstc;
1252 return rstc;
1306 struct reset_control *rstc;
1321 rstc = __reset_control_get(dev, NULL, 0, 0, optional, true);
1322 if (IS_ERR(rstc))
1323 return PTR_ERR(rstc);
1325 ret = reset_control_reset(rstc);
1327 reset_control_put(rstc);
1376 struct reset_control *rstc;
1383 resets = kzalloc(struct_size(resets, rstc, num), GFP_KERNEL);
1389 rstc = __of_reset_control_get(np, NULL, i, shared, optional,
1391 if (IS_ERR(rstc))
1393 resets->rstc[i] = rstc;
1402 __reset_control_put_internal(resets->rstc[i]);
1407 return rstc;
1427 struct reset_control **ptr, *rstc;
1434 rstc = of_reset_control_array_get(dev->of_node, shared, optional, true);
1435 if (IS_ERR_OR_NULL(rstc)) {
1437 return rstc;
1440 *ptr = rstc;
1443 return rstc;