Lines Matching full:dpll

3  *  dpll_core.c - DPLL subsystem kernel-space interface implementation.
19 /* Mutex lock to protect DPLL subsystem devices and pins */
146 dpll_xa_ref_dpll_add(struct xarray *xa_dplls, struct dpll_device *dpll, in dpll_xa_ref_dpll_add() argument
156 if (ref->dpll != dpll) in dpll_xa_ref_dpll_add()
171 ref->dpll = dpll; in dpll_xa_ref_dpll_add()
173 ret = xa_insert(xa_dplls, dpll->id, ref, GFP_KERNEL); in dpll_xa_ref_dpll_add()
184 xa_erase(xa_dplls, dpll->id); in dpll_xa_ref_dpll_add()
199 dpll_xa_ref_dpll_del(struct xarray *xa_dplls, struct dpll_device *dpll, in dpll_xa_ref_dpll_del() argument
207 if (ref->dpll != dpll) in dpll_xa_ref_dpll_del()
236 struct dpll_device *dpll; in dpll_device_alloc() local
239 dpll = kzalloc(sizeof(*dpll), GFP_KERNEL); in dpll_device_alloc()
240 if (!dpll) in dpll_device_alloc()
242 refcount_set(&dpll->refcount, 1); in dpll_device_alloc()
243 INIT_LIST_HEAD(&dpll->registration_list); in dpll_device_alloc()
244 dpll->device_idx = device_idx; in dpll_device_alloc()
245 dpll->clock_id = clock_id; in dpll_device_alloc()
246 dpll->module = module; in dpll_device_alloc()
247 ret = xa_alloc_cyclic(&dpll_device_xa, &dpll->id, dpll, xa_limit_32b, in dpll_device_alloc()
250 kfree(dpll); in dpll_device_alloc()
253 xa_init_flags(&dpll->pin_refs, XA_FLAGS_ALLOC); in dpll_device_alloc()
255 return dpll; in dpll_device_alloc()
259 * dpll_device_get - find existing or create new dpll device
264 * Get existing object of a dpll device, unique for given arguments.
275 struct dpll_device *dpll, *ret = NULL; in dpll_device_get() local
279 xa_for_each(&dpll_device_xa, index, dpll) { in dpll_device_get()
280 if (dpll->clock_id == clock_id && in dpll_device_get()
281 dpll->device_idx == device_idx && in dpll_device_get()
282 dpll->module == module) { in dpll_device_get()
283 ret = dpll; in dpll_device_get()
298 * @dpll: dpll_device struct pointer
301 * Drop reference for a dpll device, if all references are gone, delete
302 * dpll device object.
304 void dpll_device_put(struct dpll_device *dpll) in dpll_device_put() argument
307 if (refcount_dec_and_test(&dpll->refcount)) { in dpll_device_put()
308 ASSERT_DPLL_NOT_REGISTERED(dpll); in dpll_device_put()
309 WARN_ON_ONCE(!xa_empty(&dpll->pin_refs)); in dpll_device_put()
310 xa_destroy(&dpll->pin_refs); in dpll_device_put()
311 xa_erase(&dpll_device_xa, dpll->id); in dpll_device_put()
312 WARN_ON(!list_empty(&dpll->registration_list)); in dpll_device_put()
313 kfree(dpll); in dpll_device_put()
320 dpll_device_registration_find(struct dpll_device *dpll, in dpll_device_registration_find() argument
325 list_for_each_entry(reg, &dpll->registration_list, list) { in dpll_device_registration_find()
333 * dpll_device_register - register the dpll device in the subsystem
334 * @dpll: pointer to a dpll
335 * @type: type of a dpll
336 * @ops: ops for a dpll device
339 * Make dpll device available for user space.
346 int dpll_device_register(struct dpll_device *dpll, enum dpll_type type, in dpll_device_register() argument
362 reg = dpll_device_registration_find(dpll, ops, priv); in dpll_device_register()
375 dpll->type = type; in dpll_device_register()
376 first_registration = list_empty(&dpll->registration_list); in dpll_device_register()
377 list_add_tail(&reg->list, &dpll->registration_list); in dpll_device_register()
383 xa_set_mark(&dpll_device_xa, dpll->id, DPLL_REGISTERED); in dpll_device_register()
384 dpll_device_create_ntf(dpll); in dpll_device_register()
392 * dpll_device_unregister - unregister dpll device
393 * @dpll: registered dpll pointer
394 * @ops: ops for a dpll device
401 void dpll_device_unregister(struct dpll_device *dpll, in dpll_device_unregister() argument
407 ASSERT_DPLL_REGISTERED(dpll); in dpll_device_unregister()
408 dpll_device_delete_ntf(dpll); in dpll_device_unregister()
409 reg = dpll_device_registration_find(dpll, ops, priv); in dpll_device_unregister()
417 if (!list_empty(&dpll->registration_list)) { in dpll_device_unregister()
421 xa_clear_mark(&dpll_device_xa, dpll->id, DPLL_REGISTERED); in dpll_device_unregister()
532 * dpll_pin_get - find existing or create new dpll pin
536 * @prop: dpll pin properties
594 __dpll_pin_register(struct dpll_device *dpll, struct dpll_pin *pin, in __dpll_pin_register() argument
599 ret = dpll_xa_ref_pin_add(&dpll->pin_refs, pin, ops, priv); in __dpll_pin_register()
602 ret = dpll_xa_ref_dpll_add(&pin->dpll_refs, dpll, ops, priv); in __dpll_pin_register()
611 dpll_xa_ref_pin_del(&dpll->pin_refs, pin, ops, priv); in __dpll_pin_register()
616 * dpll_pin_register - register the dpll pin in the subsystem
617 * @dpll: pointer to a dpll
618 * @pin: pointer to a dpll pin
619 * @ops: ops for a dpll pin ops
628 dpll_pin_register(struct dpll_device *dpll, struct dpll_pin *pin, in dpll_pin_register() argument
639 if (WARN_ON(!(dpll->module == pin->module && in dpll_pin_register()
640 dpll->clock_id == pin->clock_id))) in dpll_pin_register()
643 ret = __dpll_pin_register(dpll, pin, ops, priv); in dpll_pin_register()
651 __dpll_pin_unregister(struct dpll_device *dpll, struct dpll_pin *pin, in __dpll_pin_unregister() argument
654 dpll_xa_ref_pin_del(&dpll->pin_refs, pin, ops, priv); in __dpll_pin_unregister()
655 dpll_xa_ref_dpll_del(&pin->dpll_refs, dpll, ops, priv); in __dpll_pin_unregister()
661 * dpll_pin_unregister - unregister dpll pin from dpll device
662 * @dpll: registered dpll pointer
664 * @ops: ops for a dpll pin
670 void dpll_pin_unregister(struct dpll_device *dpll, struct dpll_pin *pin, in dpll_pin_unregister() argument
673 if (WARN_ON(xa_empty(&dpll->pin_refs))) in dpll_pin_unregister()
680 __dpll_pin_unregister(dpll, pin, ops, priv); in dpll_pin_unregister()
689 * @ops: ops for a dpll pin
721 ret = __dpll_pin_register(ref->dpll, pin, ops, priv); in dpll_pin_on_pin_register()
735 __dpll_pin_unregister(ref->dpll, pin, ops, priv); in dpll_pin_on_pin_register()
747 * dpll_pin_on_pin_unregister - unregister dpll pin from a parent pin
750 * @ops: ops for a dpll pin
767 __dpll_pin_unregister(ref->dpll, pin, ops, priv); in dpll_pin_on_pin_unregister()
773 dpll_device_registration_first(struct dpll_device *dpll) in dpll_device_registration_first() argument
777 reg = list_first_entry_or_null((struct list_head *)&dpll->registration_list, in dpll_device_registration_first()
783 void *dpll_priv(struct dpll_device *dpll) in dpll_priv() argument
787 reg = dpll_device_registration_first(dpll); in dpll_priv()
791 const struct dpll_device_ops *dpll_device_ops(struct dpll_device *dpll) in dpll_device_ops() argument
795 reg = dpll_device_registration_first(dpll); in dpll_device_ops()
810 void *dpll_pin_on_dpll_priv(struct dpll_device *dpll, in dpll_pin_on_dpll_priv() argument
816 ref = xa_load(&dpll->pin_refs, pin->pin_idx); in dpll_pin_on_dpll_priv()