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()
400 struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev); in dprc_irq0_handler_thread() local
401 struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev); in dprc_irq0_handler_thread()
402 struct fsl_mc_io *mc_io = mc_dev->mc_io; in dprc_irq0_handler_thread()
403 int irq = mc_dev->irqs[0]->virq; in dprc_irq0_handler_thread()
408 if (!(mc_dev->flags & FSL_MC_IS_DPRC)) in dprc_irq0_handler_thread()
416 error = dprc_get_irq_status(mc_io, 0, mc_dev->mc_handle, 0, in dprc_irq0_handler_thread()
424 error = dprc_clear_irq_status(mc_io, 0, mc_dev->mc_handle, 0, in dprc_irq0_handler_thread()
438 error = dprc_scan_objects(mc_dev, true); in dprc_irq0_handler_thread()
463 int disable_dprc_irq(struct fsl_mc_device *mc_dev) in disable_dprc_irq() argument
465 struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev); in disable_dprc_irq()
467 struct fsl_mc_io *mc_io = mc_dev->mc_io; in disable_dprc_irq()
472 error = dprc_set_irq_enable(mc_io, 0, mc_dev->mc_handle, 0, 0); in disable_dprc_irq()
474 dev_err(&mc_dev->dev, in disable_dprc_irq()
483 error = dprc_set_irq_mask(mc_io, 0, mc_dev->mc_handle, 0, 0x0); in disable_dprc_irq()
485 dev_err(&mc_dev->dev, in disable_dprc_irq()
494 error = dprc_clear_irq_status(mc_io, 0, mc_dev->mc_handle, 0, ~0x0U); in disable_dprc_irq()
496 dev_err(&mc_dev->dev, in disable_dprc_irq()
507 int get_dprc_irq_state(struct fsl_mc_device *mc_dev) in get_dprc_irq_state() argument
509 struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev); in get_dprc_irq_state()
514 static int register_dprc_irq_handler(struct fsl_mc_device *mc_dev) in register_dprc_irq_handler() argument
517 struct fsl_mc_device_irq *irq = mc_dev->irqs[0]; in register_dprc_irq_handler()
523 error = devm_request_threaded_irq(&mc_dev->dev, in register_dprc_irq_handler()
528 dev_name(&mc_dev->dev), in register_dprc_irq_handler()
529 &mc_dev->dev); in register_dprc_irq_handler()
531 dev_err(&mc_dev->dev, in register_dprc_irq_handler()
540 int enable_dprc_irq(struct fsl_mc_device *mc_dev) in enable_dprc_irq() argument
542 struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev); in enable_dprc_irq()
548 error = dprc_set_irq_mask(mc_dev->mc_io, 0, mc_dev->mc_handle, 0, in enable_dprc_irq()
551 dev_err(&mc_dev->dev, in enable_dprc_irq()
561 error = dprc_set_irq_enable(mc_dev->mc_io, 0, mc_dev->mc_handle, 0, 1); in enable_dprc_irq()
563 dev_err(&mc_dev->dev, in enable_dprc_irq()
578 static int dprc_setup_irq(struct fsl_mc_device *mc_dev) in dprc_setup_irq() argument
582 error = fsl_mc_allocate_irqs(mc_dev); in dprc_setup_irq()
586 error = disable_dprc_irq(mc_dev); in dprc_setup_irq()
590 error = register_dprc_irq_handler(mc_dev); in dprc_setup_irq()
594 error = enable_dprc_irq(mc_dev); in dprc_setup_irq()
601 fsl_mc_free_irqs(mc_dev); in dprc_setup_irq()
614 int dprc_setup(struct fsl_mc_device *mc_dev) in dprc_setup() argument
616 struct device *parent_dev = mc_dev->dev.parent; in dprc_setup()
617 struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev); in dprc_setup()
626 if (!is_fsl_mc_bus_dprc(mc_dev)) in dprc_setup()
629 if (dev_get_msi_domain(&mc_dev->dev)) in dprc_setup()
632 if (!mc_dev->mc_io) { in dprc_setup()
639 if (mc_dev->obj_desc.region_count == 0) in dprc_setup()
642 region_size = resource_size(mc_dev->regions); in dprc_setup()
644 error = fsl_create_mc_io(&mc_dev->dev, in dprc_setup()
645 mc_dev->regions[0].start, in dprc_setup()
649 &mc_dev->mc_io); in dprc_setup()
661 mc_msi_domain = fsl_mc_find_msi_domain(&mc_dev->dev); in dprc_setup()
663 dev_warn(&mc_dev->dev, in dprc_setup()
666 dev_set_msi_domain(&mc_dev->dev, mc_msi_domain); in dprc_setup()
670 error = dprc_open(mc_dev->mc_io, 0, mc_dev->obj_desc.id, in dprc_setup()
671 &mc_dev->mc_handle); in dprc_setup()
673 dev_err(&mc_dev->dev, "dprc_open() failed: %d\n", error); in dprc_setup()
677 error = dprc_get_attributes(mc_dev->mc_io, 0, mc_dev->mc_handle, in dprc_setup()
680 dev_err(&mc_dev->dev, "dprc_get_attributes() failed: %d\n", in dprc_setup()
685 error = dprc_get_api_version(mc_dev->mc_io, 0, in dprc_setup()
689 dev_err(&mc_dev->dev, "dprc_get_api_version() failed: %d\n", in dprc_setup()
695 dev_err(&mc_dev->dev, in dprc_setup()
705 (void)dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle); in dprc_setup()
709 dev_set_msi_domain(&mc_dev->dev, NULL); in dprc_setup()
712 fsl_destroy_mc_io(mc_dev->mc_io); in dprc_setup()
713 mc_dev->mc_io = NULL; in dprc_setup()
733 static int dprc_probe(struct fsl_mc_device *mc_dev) in dprc_probe() argument
737 error = dprc_setup(mc_dev); in dprc_probe()
744 error = dprc_scan_container(mc_dev, true); in dprc_probe()
751 error = dprc_setup_irq(mc_dev); in dprc_probe()
755 dev_info(&mc_dev->dev, "DPRC device bound to driver"); in dprc_probe()
759 device_for_each_child(&mc_dev->dev, NULL, __fsl_mc_device_remove); in dprc_probe()
761 dprc_cleanup(mc_dev); in dprc_probe()
768 static void dprc_teardown_irq(struct fsl_mc_device *mc_dev) in dprc_teardown_irq() argument
770 struct fsl_mc_device_irq *irq = mc_dev->irqs[0]; in dprc_teardown_irq()
772 (void)disable_dprc_irq(mc_dev); in dprc_teardown_irq()
774 devm_free_irq(&mc_dev->dev, irq->virq, &mc_dev->dev); in dprc_teardown_irq()
776 fsl_mc_free_irqs(mc_dev); in dprc_teardown_irq()
788 int dprc_cleanup(struct fsl_mc_device *mc_dev) in dprc_cleanup() argument
790 struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev); in dprc_cleanup()
796 if (!is_fsl_mc_bus_dprc(mc_dev)) in dprc_cleanup()
799 if (dev_get_msi_domain(&mc_dev->dev)) { in dprc_cleanup()
800 fsl_mc_cleanup_irq_pool(mc_dev); in dprc_cleanup()
801 dev_set_msi_domain(&mc_dev->dev, NULL); in dprc_cleanup()
804 fsl_mc_cleanup_all_resource_pools(mc_dev); in dprc_cleanup()
809 if (!mc_dev->mc_io) { in dprc_cleanup()
810 dev_err(&mc_dev->dev, "mc_io is NULL, tear down cannot be performed in firmware\n"); in dprc_cleanup()
814 error = dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle); in dprc_cleanup()
816 dev_err(&mc_dev->dev, "dprc_close() failed: %d\n", error); in dprc_cleanup()
818 if (!fsl_mc_is_root_dprc(&mc_dev->dev)) { in dprc_cleanup()
819 fsl_destroy_mc_io(mc_dev->mc_io); in dprc_cleanup()
820 mc_dev->mc_io = NULL; in dprc_cleanup()
839 static int dprc_remove(struct fsl_mc_device *mc_dev) in dprc_remove() argument
841 struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev); in dprc_remove()
843 if (!is_fsl_mc_bus_dprc(mc_dev)) in dprc_remove()
849 if (dev_get_msi_domain(&mc_dev->dev)) in dprc_remove()
850 dprc_teardown_irq(mc_dev); in dprc_remove()
852 device_for_each_child(&mc_dev->dev, NULL, __fsl_mc_device_remove); in dprc_remove()
854 dprc_cleanup(mc_dev); in dprc_remove()
856 dev_info(&mc_dev->dev, "DPRC device unbound from driver"); in dprc_remove()