Lines Matching refs:mc_dev
25 static bool fsl_mc_device_match(struct fsl_mc_device *mc_dev,
28 return mc_dev->obj_desc.id == obj_desc->id &&
29 strcmp(mc_dev->obj_desc.type, obj_desc->type) == 0;
46 struct fsl_mc_device *mc_dev;
51 mc_dev = to_fsl_mc_device(dev);
58 fsl_mc_device_match(mc_dev, obj_desc))
63 fsl_mc_device_remove(mc_dev);
118 struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
120 return fsl_mc_device_match(mc_dev, obj_desc);
137 * @mc_dev: pointer to the fsl-mc device for a given MC object
145 static void check_plugged_state_change(struct fsl_mc_device *mc_dev,
153 (mc_dev->obj_desc.state & FSL_MC_OBJ_STATE_PLUGGED)) {
155 mc_dev->obj_desc.state |= FSL_MC_OBJ_STATE_PLUGGED;
156 error = device_attach(&mc_dev->dev);
158 dev_err(&mc_dev->dev,
163 mc_dev->obj_desc.state &= ~FSL_MC_OBJ_STATE_PLUGGED;
164 device_release_driver(&mc_dev->dev);
405 struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
406 struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
407 struct fsl_mc_io *mc_io = mc_dev->mc_io;
408 int irq = mc_dev->irqs[0]->virq;
413 if (!(mc_dev->flags & FSL_MC_IS_DPRC))
421 error = dprc_get_irq_status(mc_io, 0, mc_dev->mc_handle, 0,
429 error = dprc_clear_irq_status(mc_io, 0, mc_dev->mc_handle, 0,
443 error = dprc_scan_objects(mc_dev, true);
468 int disable_dprc_irq(struct fsl_mc_device *mc_dev)
470 struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
472 struct fsl_mc_io *mc_io = mc_dev->mc_io;
477 error = dprc_set_irq_enable(mc_io, 0, mc_dev->mc_handle, 0, 0);
479 dev_err(&mc_dev->dev,
488 error = dprc_set_irq_mask(mc_io, 0, mc_dev->mc_handle, 0, 0x0);
490 dev_err(&mc_dev->dev,
499 error = dprc_clear_irq_status(mc_io, 0, mc_dev->mc_handle, 0, ~0x0U);
501 dev_err(&mc_dev->dev,
512 int get_dprc_irq_state(struct fsl_mc_device *mc_dev)
514 struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
519 static int register_dprc_irq_handler(struct fsl_mc_device *mc_dev)
522 struct fsl_mc_device_irq *irq = mc_dev->irqs[0];
528 error = devm_request_threaded_irq(&mc_dev->dev,
533 dev_name(&mc_dev->dev),
534 &mc_dev->dev);
536 dev_err(&mc_dev->dev,
545 int enable_dprc_irq(struct fsl_mc_device *mc_dev)
547 struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
553 error = dprc_set_irq_mask(mc_dev->mc_io, 0, mc_dev->mc_handle, 0,
556 dev_err(&mc_dev->dev,
566 error = dprc_set_irq_enable(mc_dev->mc_io, 0, mc_dev->mc_handle, 0, 1);
568 dev_err(&mc_dev->dev,
583 static int dprc_setup_irq(struct fsl_mc_device *mc_dev)
587 error = fsl_mc_allocate_irqs(mc_dev);
591 error = disable_dprc_irq(mc_dev);
595 error = register_dprc_irq_handler(mc_dev);
599 error = enable_dprc_irq(mc_dev);
606 fsl_mc_free_irqs(mc_dev);
613 * @mc_dev: Pointer to fsl-mc device representing a DPRC
619 int dprc_setup(struct fsl_mc_device *mc_dev)
621 struct device *parent_dev = mc_dev->dev.parent;
622 struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
631 if (!is_fsl_mc_bus_dprc(mc_dev))
634 if (dev_get_msi_domain(&mc_dev->dev))
637 if (!mc_dev->mc_io) {
644 if (mc_dev->obj_desc.region_count == 0)
647 region_size = resource_size(mc_dev->regions);
649 error = fsl_create_mc_io(&mc_dev->dev,
650 mc_dev->regions[0].start,
654 &mc_dev->mc_io);
666 mc_msi_domain = fsl_mc_find_msi_domain(&mc_dev->dev);
668 dev_warn(&mc_dev->dev,
671 dev_set_msi_domain(&mc_dev->dev, mc_msi_domain);
675 error = dprc_open(mc_dev->mc_io, 0, mc_dev->obj_desc.id,
676 &mc_dev->mc_handle);
678 dev_err(&mc_dev->dev, "dprc_open() failed: %d\n", error);
682 error = dprc_get_attributes(mc_dev->mc_io, 0, mc_dev->mc_handle,
685 dev_err(&mc_dev->dev, "dprc_get_attributes() failed: %d\n",
690 error = dprc_get_api_version(mc_dev->mc_io, 0,
694 dev_err(&mc_dev->dev, "dprc_get_api_version() failed: %d\n",
700 dev_err(&mc_dev->dev,
710 (void)dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle);
714 dev_set_msi_domain(&mc_dev->dev, NULL);
717 fsl_destroy_mc_io(mc_dev->mc_io);
718 mc_dev->mc_io = NULL;
731 * @mc_dev: Pointer to fsl-mc device representing a DPRC
738 static int dprc_probe(struct fsl_mc_device *mc_dev)
742 error = dprc_setup(mc_dev);
749 error = dprc_scan_container(mc_dev, true);
756 error = dprc_setup_irq(mc_dev);
760 dev_info(&mc_dev->dev, "DPRC device bound to driver");
764 device_for_each_child(&mc_dev->dev, NULL, __fsl_mc_device_remove);
766 dprc_cleanup(mc_dev);
773 static void dprc_teardown_irq(struct fsl_mc_device *mc_dev)
775 struct fsl_mc_device_irq *irq = mc_dev->irqs[0];
777 (void)disable_dprc_irq(mc_dev);
779 devm_free_irq(&mc_dev->dev, irq->virq, &mc_dev->dev);
781 fsl_mc_free_irqs(mc_dev);
787 * @mc_dev: Pointer to fsl-mc device representing the DPRC
793 int dprc_cleanup(struct fsl_mc_device *mc_dev)
795 struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
801 if (!is_fsl_mc_bus_dprc(mc_dev))
804 if (dev_get_msi_domain(&mc_dev->dev)) {
805 fsl_mc_cleanup_irq_pool(mc_dev);
806 dev_set_msi_domain(&mc_dev->dev, NULL);
809 fsl_mc_cleanup_all_resource_pools(mc_dev);
814 if (!mc_dev->mc_io) {
815 dev_err(&mc_dev->dev, "mc_io is NULL, tear down cannot be performed in firmware\n");
819 error = dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle);
821 dev_err(&mc_dev->dev, "dprc_close() failed: %d\n", error);
823 if (!fsl_mc_is_root_dprc(&mc_dev->dev)) {
824 fsl_destroy_mc_io(mc_dev->mc_io);
825 mc_dev->mc_io = NULL;
837 * @mc_dev: Pointer to fsl-mc device representing the DPRC
844 static void dprc_remove(struct fsl_mc_device *mc_dev)
846 struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
849 dev_err(&mc_dev->dev, "No irq resources, so unbinding the device failed\n");
853 if (dev_get_msi_domain(&mc_dev->dev))
854 dprc_teardown_irq(mc_dev);
856 device_for_each_child(&mc_dev->dev, NULL, __fsl_mc_device_remove);
858 dprc_cleanup(mc_dev);
860 dev_info(&mc_dev->dev, "DPRC device unbound from driver");