Lines Matching refs:mc_dev

26 static bool fsl_mc_device_match(struct fsl_mc_device *mc_dev,  in fsl_mc_device_match()  argument
29 return mc_dev->obj_desc.id == obj_desc->id && in fsl_mc_device_match()
30 strcmp(mc_dev->obj_desc.type, obj_desc->type) == 0; in fsl_mc_device_match()
47 struct fsl_mc_device *mc_dev; in __fsl_mc_device_remove_if_not_in_mc() local
49 mc_dev = to_fsl_mc_device(dev); in __fsl_mc_device_remove_if_not_in_mc()
56 fsl_mc_device_match(mc_dev, obj_desc)) in __fsl_mc_device_remove_if_not_in_mc()
61 fsl_mc_device_remove(mc_dev); in __fsl_mc_device_remove_if_not_in_mc()
113 struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev); in __fsl_mc_device_match() local
115 return fsl_mc_device_match(mc_dev, obj_desc); in __fsl_mc_device_match()
140 static void check_plugged_state_change(struct fsl_mc_device *mc_dev, in check_plugged_state_change() argument
148 (mc_dev->obj_desc.state & FSL_MC_OBJ_STATE_PLUGGED)) { in check_plugged_state_change()
150 mc_dev->obj_desc.state |= FSL_MC_OBJ_STATE_PLUGGED; in check_plugged_state_change()
151 error = device_attach(&mc_dev->dev); in check_plugged_state_change()
153 dev_err(&mc_dev->dev, in check_plugged_state_change()
158 mc_dev->obj_desc.state &= ~FSL_MC_OBJ_STATE_PLUGGED; in check_plugged_state_change()
159 device_release_driver(&mc_dev->dev); in check_plugged_state_change()
398 struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev); in dprc_irq0_handler_thread() local
399 struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev); in dprc_irq0_handler_thread()
400 struct fsl_mc_io *mc_io = mc_dev->mc_io; in dprc_irq0_handler_thread()
401 struct msi_desc *msi_desc = mc_dev->irqs[0]->msi_desc; in dprc_irq0_handler_thread()
406 if (!(mc_dev->flags & FSL_MC_IS_DPRC)) in dprc_irq0_handler_thread()
414 error = dprc_get_irq_status(mc_io, 0, mc_dev->mc_handle, 0, in dprc_irq0_handler_thread()
422 error = dprc_clear_irq_status(mc_io, 0, mc_dev->mc_handle, 0, in dprc_irq0_handler_thread()
436 error = dprc_scan_objects(mc_dev, true); in dprc_irq0_handler_thread()
461 static int disable_dprc_irq(struct fsl_mc_device *mc_dev) in disable_dprc_irq() argument
464 struct fsl_mc_io *mc_io = mc_dev->mc_io; in disable_dprc_irq()
469 error = dprc_set_irq_enable(mc_io, 0, mc_dev->mc_handle, 0, 0); in disable_dprc_irq()
471 dev_err(&mc_dev->dev, in disable_dprc_irq()
480 error = dprc_set_irq_mask(mc_io, 0, mc_dev->mc_handle, 0, 0x0); in disable_dprc_irq()
482 dev_err(&mc_dev->dev, in disable_dprc_irq()
491 error = dprc_clear_irq_status(mc_io, 0, mc_dev->mc_handle, 0, ~0x0U); in disable_dprc_irq()
493 dev_err(&mc_dev->dev, in disable_dprc_irq()
502 static int register_dprc_irq_handler(struct fsl_mc_device *mc_dev) in register_dprc_irq_handler() argument
505 struct fsl_mc_device_irq *irq = mc_dev->irqs[0]; in register_dprc_irq_handler()
511 error = devm_request_threaded_irq(&mc_dev->dev, in register_dprc_irq_handler()
516 dev_name(&mc_dev->dev), in register_dprc_irq_handler()
517 &mc_dev->dev); in register_dprc_irq_handler()
519 dev_err(&mc_dev->dev, in register_dprc_irq_handler()
528 static int enable_dprc_irq(struct fsl_mc_device *mc_dev) in enable_dprc_irq() argument
535 error = dprc_set_irq_mask(mc_dev->mc_io, 0, mc_dev->mc_handle, 0, in enable_dprc_irq()
538 dev_err(&mc_dev->dev, in enable_dprc_irq()
548 error = dprc_set_irq_enable(mc_dev->mc_io, 0, mc_dev->mc_handle, 0, 1); in enable_dprc_irq()
550 dev_err(&mc_dev->dev, in enable_dprc_irq()
563 static int dprc_setup_irq(struct fsl_mc_device *mc_dev) in dprc_setup_irq() argument
567 error = fsl_mc_allocate_irqs(mc_dev); in dprc_setup_irq()
571 error = disable_dprc_irq(mc_dev); in dprc_setup_irq()
575 error = register_dprc_irq_handler(mc_dev); in dprc_setup_irq()
579 error = enable_dprc_irq(mc_dev); in dprc_setup_irq()
586 fsl_mc_free_irqs(mc_dev); in dprc_setup_irq()
599 int dprc_setup(struct fsl_mc_device *mc_dev) in dprc_setup() argument
601 struct device *parent_dev = mc_dev->dev.parent; in dprc_setup()
602 struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev); in dprc_setup()
610 if (!is_fsl_mc_bus_dprc(mc_dev)) in dprc_setup()
613 if (dev_get_msi_domain(&mc_dev->dev)) in dprc_setup()
616 if (!mc_dev->mc_io) { in dprc_setup()
623 if (mc_dev->obj_desc.region_count == 0) in dprc_setup()
626 region_size = resource_size(mc_dev->regions); in dprc_setup()
628 error = fsl_create_mc_io(&mc_dev->dev, in dprc_setup()
629 mc_dev->regions[0].start, in dprc_setup()
633 &mc_dev->mc_io); in dprc_setup()
640 mc_msi_domain = fsl_mc_find_msi_domain(&mc_dev->dev); in dprc_setup()
642 dev_warn(&mc_dev->dev, in dprc_setup()
645 dev_set_msi_domain(&mc_dev->dev, mc_msi_domain); in dprc_setup()
649 error = dprc_open(mc_dev->mc_io, 0, mc_dev->obj_desc.id, in dprc_setup()
650 &mc_dev->mc_handle); in dprc_setup()
652 dev_err(&mc_dev->dev, "dprc_open() failed: %d\n", error); in dprc_setup()
656 error = dprc_get_attributes(mc_dev->mc_io, 0, mc_dev->mc_handle, in dprc_setup()
659 dev_err(&mc_dev->dev, "dprc_get_attributes() failed: %d\n", in dprc_setup()
664 error = dprc_get_api_version(mc_dev->mc_io, 0, in dprc_setup()
668 dev_err(&mc_dev->dev, "dprc_get_api_version() failed: %d\n", in dprc_setup()
676 dev_err(&mc_dev->dev, in dprc_setup()
686 (void)dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle); in dprc_setup()
690 dev_set_msi_domain(&mc_dev->dev, NULL); in dprc_setup()
693 fsl_destroy_mc_io(mc_dev->mc_io); in dprc_setup()
694 mc_dev->mc_io = NULL; in dprc_setup()
711 static int dprc_probe(struct fsl_mc_device *mc_dev) in dprc_probe() argument
715 error = dprc_setup(mc_dev); in dprc_probe()
722 error = dprc_scan_container(mc_dev, true); in dprc_probe()
729 error = dprc_setup_irq(mc_dev); in dprc_probe()
733 dev_info(&mc_dev->dev, "DPRC device bound to driver"); in dprc_probe()
737 device_for_each_child(&mc_dev->dev, NULL, __fsl_mc_device_remove); in dprc_probe()
739 dprc_cleanup(mc_dev); in dprc_probe()
746 static void dprc_teardown_irq(struct fsl_mc_device *mc_dev) in dprc_teardown_irq() argument
748 struct fsl_mc_device_irq *irq = mc_dev->irqs[0]; in dprc_teardown_irq()
750 (void)disable_dprc_irq(mc_dev); in dprc_teardown_irq()
752 devm_free_irq(&mc_dev->dev, irq->msi_desc->irq, &mc_dev->dev); in dprc_teardown_irq()
754 fsl_mc_free_irqs(mc_dev); in dprc_teardown_irq()
766 int dprc_cleanup(struct fsl_mc_device *mc_dev) in dprc_cleanup() argument
773 if (!is_fsl_mc_bus_dprc(mc_dev)) in dprc_cleanup()
776 if (dev_get_msi_domain(&mc_dev->dev)) { in dprc_cleanup()
777 fsl_mc_cleanup_irq_pool(mc_dev); in dprc_cleanup()
778 dev_set_msi_domain(&mc_dev->dev, NULL); in dprc_cleanup()
781 fsl_mc_cleanup_all_resource_pools(mc_dev); in dprc_cleanup()
786 if (!mc_dev->mc_io) { in dprc_cleanup()
787 dev_err(&mc_dev->dev, "mc_io is NULL, tear down cannot be performed in firmware\n"); in dprc_cleanup()
791 error = dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle); in dprc_cleanup()
793 dev_err(&mc_dev->dev, "dprc_close() failed: %d\n", error); in dprc_cleanup()
795 if (!fsl_mc_is_root_dprc(&mc_dev->dev)) { in dprc_cleanup()
796 fsl_destroy_mc_io(mc_dev->mc_io); in dprc_cleanup()
797 mc_dev->mc_io = NULL; in dprc_cleanup()
814 static int dprc_remove(struct fsl_mc_device *mc_dev) in dprc_remove() argument
816 struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev); in dprc_remove()
818 if (!is_fsl_mc_bus_dprc(mc_dev)) in dprc_remove()
824 if (dev_get_msi_domain(&mc_dev->dev)) in dprc_remove()
825 dprc_teardown_irq(mc_dev); in dprc_remove()
827 device_for_each_child(&mc_dev->dev, NULL, __fsl_mc_device_remove); in dprc_remove()
829 dprc_cleanup(mc_dev); in dprc_remove()
831 dev_info(&mc_dev->dev, "DPRC device unbound from driver"); in dprc_remove()