Lines Matching defs:pin

72 dpll_xa_ref_pin_add(struct xarray *xa_pins, struct dpll_pin *pin,
83 if (ref->pin != pin)
98 ref->pin = pin;
100 ret = xa_insert(xa_pins, pin->pin_idx, ref, GFP_KERNEL);
111 xa_erase(xa_pins, pin->pin_idx);
126 static int dpll_xa_ref_pin_del(struct xarray *xa_pins, struct dpll_pin *pin,
135 if (ref->pin != pin)
489 struct dpll_pin *pin;
492 pin = kzalloc(sizeof(*pin), GFP_KERNEL);
493 if (!pin)
495 pin->pin_idx = pin_idx;
496 pin->clock_id = clock_id;
497 pin->module = module;
503 ret = dpll_pin_prop_dup(prop, &pin->prop);
506 refcount_set(&pin->refcount, 1);
507 xa_init_flags(&pin->dpll_refs, XA_FLAGS_ALLOC);
508 xa_init_flags(&pin->parent_refs, XA_FLAGS_ALLOC);
509 xa_init_flags(&pin->ref_sync_pins, XA_FLAGS_ALLOC);
510 ret = xa_alloc_cyclic(&dpll_pin_xa, &pin->id, pin, xa_limit_32b,
514 return pin;
516 xa_destroy(&pin->dpll_refs);
517 xa_destroy(&pin->parent_refs);
518 xa_destroy(&pin->ref_sync_pins);
519 dpll_pin_prop_free(&pin->prop);
521 kfree(pin);
546 * dpll_pin_get - find existing or create new dpll pin
550 * @prop: dpll pin properties
552 * Get existing object of a pin (unique for given arguments) or create new
587 * @pin: pointer to a pin to be put
589 * Drop reference for a pin, if all references are gone, delete pin object.
593 void dpll_pin_put(struct dpll_pin *pin)
596 if (refcount_dec_and_test(&pin->refcount)) {
597 xa_erase(&dpll_pin_xa, pin->id);
598 xa_destroy(&pin->dpll_refs);
599 xa_destroy(&pin->parent_refs);
600 xa_destroy(&pin->ref_sync_pins);
601 dpll_pin_prop_free(&pin->prop);
602 kfree_rcu(pin, rcu);
609 __dpll_pin_register(struct dpll_device *dpll, struct dpll_pin *pin,
614 ret = dpll_xa_ref_pin_add(&dpll->pin_refs, pin, ops, priv, cookie);
617 ret = dpll_xa_ref_dpll_add(&pin->dpll_refs, dpll, ops, priv, cookie);
620 xa_set_mark(&dpll_pin_xa, pin->id, DPLL_REGISTERED);
621 dpll_pin_create_ntf(pin);
626 dpll_xa_ref_pin_del(&dpll->pin_refs, pin, ops, priv, cookie);
631 * dpll_pin_register - register the dpll pin in the subsystem
633 * @pin: pointer to a dpll pin
634 * @ops: ops for a dpll pin ops
643 dpll_pin_register(struct dpll_device *dpll, struct dpll_pin *pin,
654 if (WARN_ON(!(dpll->module == pin->module &&
655 dpll->clock_id == pin->clock_id)))
658 ret = __dpll_pin_register(dpll, pin, ops, priv, NULL);
667 struct dpll_pin *pin, *ref_sync_pin;
670 xa_for_each(&dpll_pin_xa, i, pin) {
671 ref_sync_pin = xa_load(&pin->ref_sync_pins, ref_sync_pin_id);
673 xa_erase(&pin->ref_sync_pins, ref_sync_pin_id);
674 __dpll_pin_change_ntf(pin);
680 __dpll_pin_unregister(struct dpll_device *dpll, struct dpll_pin *pin,
683 ASSERT_DPLL_PIN_REGISTERED(pin);
684 dpll_pin_ref_sync_pair_del(pin->id);
685 dpll_xa_ref_pin_del(&dpll->pin_refs, pin, ops, priv, cookie);
686 dpll_xa_ref_dpll_del(&pin->dpll_refs, dpll, ops, priv, cookie);
687 if (xa_empty(&pin->dpll_refs))
688 xa_clear_mark(&dpll_pin_xa, pin->id, DPLL_REGISTERED);
692 * dpll_pin_unregister - unregister dpll pin from dpll device
694 * @pin: pointer to a pin
695 * @ops: ops for a dpll pin
701 void dpll_pin_unregister(struct dpll_device *dpll, struct dpll_pin *pin,
706 if (WARN_ON(!xa_empty(&pin->parent_refs)))
710 dpll_pin_delete_ntf(pin);
711 __dpll_pin_unregister(dpll, pin, ops, priv, NULL);
717 * dpll_pin_on_pin_register - register a pin with a parent pin
718 * @parent: pointer to a parent pin
719 * @pin: pointer to a pin
720 * @ops: ops for a dpll pin
723 * Register a pin with a parent pin, create references between them and
724 * between newly registered pin and dplls connected with a parent pin.
731 int dpll_pin_on_pin_register(struct dpll_pin *parent, struct dpll_pin *pin,
747 ret = dpll_xa_ref_pin_add(&pin->parent_refs, parent, ops, priv, pin);
750 refcount_inc(&pin->refcount);
752 ret = __dpll_pin_register(ref->dpll, pin, ops, priv, parent);
757 dpll_pin_create_ntf(pin);
766 __dpll_pin_unregister(ref->dpll, pin, ops, priv,
768 dpll_pin_delete_ntf(pin);
770 refcount_dec(&pin->refcount);
771 dpll_xa_ref_pin_del(&pin->parent_refs, parent, ops, priv, pin);
779 * dpll_pin_on_pin_unregister - unregister dpll pin from a parent pin
780 * @parent: pointer to a parent pin
781 * @pin: pointer to a pin
782 * @ops: ops for a dpll pin
788 void dpll_pin_on_pin_unregister(struct dpll_pin *parent, struct dpll_pin *pin,
795 dpll_pin_delete_ntf(pin);
796 dpll_xa_ref_pin_del(&pin->parent_refs, parent, ops, priv, pin);
797 refcount_dec(&pin->refcount);
798 xa_for_each(&pin->dpll_refs, i, ref)
799 __dpll_pin_unregister(ref->dpll, pin, ops, priv, parent);
805 * dpll_pin_ref_sync_pair_add - create a reference sync signal pin pair
806 * @pin: pin which produces the base frequency
807 * @ref_sync_pin: pin which produces the sync signal
816 int dpll_pin_ref_sync_pair_add(struct dpll_pin *pin,
822 ret = xa_insert(&pin->ref_sync_pins, ref_sync_pin->id,
824 __dpll_pin_change_ntf(pin);
870 struct dpll_pin *pin)
875 ref = xa_load(&dpll->pin_refs, pin->pin_idx);
883 struct dpll_pin *pin)
888 ref = xa_load(&pin->parent_refs, parent->pin_idx);