Linux 4.18.10
[linux/fpc-iii.git] / drivers / bus / fsl-mc / dprc-driver.c
blob52c7e15143d6d6e62087f8ad4db6fcdca3d1e4d9
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Freescale data path resource container (DPRC) driver
5 * Copyright (C) 2014-2016 Freescale Semiconductor, Inc.
6 * Author: German Rivera <German.Rivera@freescale.com>
8 */
10 #include <linux/module.h>
11 #include <linux/slab.h>
12 #include <linux/interrupt.h>
13 #include <linux/msi.h>
14 #include <linux/fsl/mc.h>
16 #include "fsl-mc-private.h"
18 #define FSL_MC_DPRC_DRIVER_NAME "fsl_mc_dprc"
20 struct fsl_mc_child_objs {
21 int child_count;
22 struct fsl_mc_obj_desc *child_array;
25 static bool fsl_mc_device_match(struct fsl_mc_device *mc_dev,
26 struct fsl_mc_obj_desc *obj_desc)
28 return mc_dev->obj_desc.id == obj_desc->id &&
29 strcmp(mc_dev->obj_desc.type, obj_desc->type) == 0;
33 static int __fsl_mc_device_remove_if_not_in_mc(struct device *dev, void *data)
35 int i;
36 struct fsl_mc_child_objs *objs;
37 struct fsl_mc_device *mc_dev;
39 mc_dev = to_fsl_mc_device(dev);
40 objs = data;
42 for (i = 0; i < objs->child_count; i++) {
43 struct fsl_mc_obj_desc *obj_desc = &objs->child_array[i];
45 if (strlen(obj_desc->type) != 0 &&
46 fsl_mc_device_match(mc_dev, obj_desc))
47 break;
50 if (i == objs->child_count)
51 fsl_mc_device_remove(mc_dev);
53 return 0;
56 static int __fsl_mc_device_remove(struct device *dev, void *data)
58 fsl_mc_device_remove(to_fsl_mc_device(dev));
59 return 0;
62 /**
63 * dprc_remove_devices - Removes devices for objects removed from a DPRC
65 * @mc_bus_dev: pointer to the fsl-mc device that represents a DPRC object
66 * @obj_desc_array: array of object descriptors for child objects currently
67 * present in the DPRC in the MC.
68 * @num_child_objects_in_mc: number of entries in obj_desc_array
70 * Synchronizes the state of the Linux bus driver with the actual state of
71 * the MC by removing devices that represent MC objects that have
72 * been dynamically removed in the physical DPRC.
74 static void dprc_remove_devices(struct fsl_mc_device *mc_bus_dev,
75 struct fsl_mc_obj_desc *obj_desc_array,
76 int num_child_objects_in_mc)
78 if (num_child_objects_in_mc != 0) {
80 * Remove child objects that are in the DPRC in Linux,
81 * but not in the MC:
83 struct fsl_mc_child_objs objs;
85 objs.child_count = num_child_objects_in_mc;
86 objs.child_array = obj_desc_array;
87 device_for_each_child(&mc_bus_dev->dev, &objs,
88 __fsl_mc_device_remove_if_not_in_mc);
89 } else {
91 * There are no child objects for this DPRC in the MC.
92 * So, remove all the child devices from Linux:
94 device_for_each_child(&mc_bus_dev->dev, NULL,
95 __fsl_mc_device_remove);
99 static int __fsl_mc_device_match(struct device *dev, void *data)
101 struct fsl_mc_obj_desc *obj_desc = data;
102 struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
104 return fsl_mc_device_match(mc_dev, obj_desc);
107 static struct fsl_mc_device *fsl_mc_device_lookup(struct fsl_mc_obj_desc
108 *obj_desc,
109 struct fsl_mc_device
110 *mc_bus_dev)
112 struct device *dev;
114 dev = device_find_child(&mc_bus_dev->dev, obj_desc,
115 __fsl_mc_device_match);
117 return dev ? to_fsl_mc_device(dev) : NULL;
121 * check_plugged_state_change - Check change in an MC object's plugged state
123 * @mc_dev: pointer to the fsl-mc device for a given MC object
124 * @obj_desc: pointer to the MC object's descriptor in the MC
126 * If the plugged state has changed from unplugged to plugged, the fsl-mc
127 * device is bound to the corresponding device driver.
128 * If the plugged state has changed from plugged to unplugged, the fsl-mc
129 * device is unbound from the corresponding device driver.
131 static void check_plugged_state_change(struct fsl_mc_device *mc_dev,
132 struct fsl_mc_obj_desc *obj_desc)
134 int error;
135 u32 plugged_flag_at_mc =
136 obj_desc->state & FSL_MC_OBJ_STATE_PLUGGED;
138 if (plugged_flag_at_mc !=
139 (mc_dev->obj_desc.state & FSL_MC_OBJ_STATE_PLUGGED)) {
140 if (plugged_flag_at_mc) {
141 mc_dev->obj_desc.state |= FSL_MC_OBJ_STATE_PLUGGED;
142 error = device_attach(&mc_dev->dev);
143 if (error < 0) {
144 dev_err(&mc_dev->dev,
145 "device_attach() failed: %d\n",
146 error);
148 } else {
149 mc_dev->obj_desc.state &= ~FSL_MC_OBJ_STATE_PLUGGED;
150 device_release_driver(&mc_dev->dev);
156 * dprc_add_new_devices - Adds devices to the logical bus for a DPRC
158 * @mc_bus_dev: pointer to the fsl-mc device that represents a DPRC object
159 * @obj_desc_array: array of device descriptors for child devices currently
160 * present in the physical DPRC.
161 * @num_child_objects_in_mc: number of entries in obj_desc_array
163 * Synchronizes the state of the Linux bus driver with the actual
164 * state of the MC by adding objects that have been newly discovered
165 * in the physical DPRC.
167 static void dprc_add_new_devices(struct fsl_mc_device *mc_bus_dev,
168 struct fsl_mc_obj_desc *obj_desc_array,
169 int num_child_objects_in_mc)
171 int error;
172 int i;
174 for (i = 0; i < num_child_objects_in_mc; i++) {
175 struct fsl_mc_device *child_dev;
176 struct fsl_mc_obj_desc *obj_desc = &obj_desc_array[i];
178 if (strlen(obj_desc->type) == 0)
179 continue;
182 * Check if device is already known to Linux:
184 child_dev = fsl_mc_device_lookup(obj_desc, mc_bus_dev);
185 if (child_dev) {
186 check_plugged_state_change(child_dev, obj_desc);
187 put_device(&child_dev->dev);
188 continue;
191 error = fsl_mc_device_add(obj_desc, NULL, &mc_bus_dev->dev,
192 &child_dev);
193 if (error < 0)
194 continue;
199 * dprc_scan_objects - Discover objects in a DPRC
201 * @mc_bus_dev: pointer to the fsl-mc device that represents a DPRC object
202 * @total_irq_count: If argument is provided the function populates the
203 * total number of IRQs created by objects in the DPRC.
205 * Detects objects added and removed from a DPRC and synchronizes the
206 * state of the Linux bus driver, MC by adding and removing
207 * devices accordingly.
208 * Two types of devices can be found in a DPRC: allocatable objects (e.g.,
209 * dpbp, dpmcp) and non-allocatable devices (e.g., dprc, dpni).
210 * All allocatable devices needed to be probed before all non-allocatable
211 * devices, to ensure that device drivers for non-allocatable
212 * devices can allocate any type of allocatable devices.
213 * That is, we need to ensure that the corresponding resource pools are
214 * populated before they can get allocation requests from probe callbacks
215 * of the device drivers for the non-allocatable devices.
217 static int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev,
218 unsigned int *total_irq_count)
220 int num_child_objects;
221 int dprc_get_obj_failures;
222 int error;
223 unsigned int irq_count = mc_bus_dev->obj_desc.irq_count;
224 struct fsl_mc_obj_desc *child_obj_desc_array = NULL;
225 struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev);
227 error = dprc_get_obj_count(mc_bus_dev->mc_io,
229 mc_bus_dev->mc_handle,
230 &num_child_objects);
231 if (error < 0) {
232 dev_err(&mc_bus_dev->dev, "dprc_get_obj_count() failed: %d\n",
233 error);
234 return error;
237 if (num_child_objects != 0) {
238 int i;
240 child_obj_desc_array =
241 devm_kmalloc_array(&mc_bus_dev->dev, num_child_objects,
242 sizeof(*child_obj_desc_array),
243 GFP_KERNEL);
244 if (!child_obj_desc_array)
245 return -ENOMEM;
248 * Discover objects currently present in the physical DPRC:
250 dprc_get_obj_failures = 0;
251 for (i = 0; i < num_child_objects; i++) {
252 struct fsl_mc_obj_desc *obj_desc =
253 &child_obj_desc_array[i];
255 error = dprc_get_obj(mc_bus_dev->mc_io,
257 mc_bus_dev->mc_handle,
258 i, obj_desc);
259 if (error < 0) {
260 dev_err(&mc_bus_dev->dev,
261 "dprc_get_obj(i=%d) failed: %d\n",
262 i, error);
264 * Mark the obj entry as "invalid", by using the
265 * empty string as obj type:
267 obj_desc->type[0] = '\0';
268 obj_desc->id = error;
269 dprc_get_obj_failures++;
270 continue;
274 * add a quirk for all versions of dpsec < 4.0...none
275 * are coherent regardless of what the MC reports.
277 if ((strcmp(obj_desc->type, "dpseci") == 0) &&
278 (obj_desc->ver_major < 4))
279 obj_desc->flags |=
280 FSL_MC_OBJ_FLAG_NO_MEM_SHAREABILITY;
282 irq_count += obj_desc->irq_count;
283 dev_dbg(&mc_bus_dev->dev,
284 "Discovered object: type %s, id %d\n",
285 obj_desc->type, obj_desc->id);
288 if (dprc_get_obj_failures != 0) {
289 dev_err(&mc_bus_dev->dev,
290 "%d out of %d devices could not be retrieved\n",
291 dprc_get_obj_failures, num_child_objects);
296 * Allocate IRQ's before binding the scanned devices with their
297 * respective drivers.
299 if (dev_get_msi_domain(&mc_bus_dev->dev) && !mc_bus->irq_resources) {
300 if (irq_count > FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS) {
301 dev_warn(&mc_bus_dev->dev,
302 "IRQs needed (%u) exceed IRQs preallocated (%u)\n",
303 irq_count, FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS);
306 error = fsl_mc_populate_irq_pool(mc_bus,
307 FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS);
308 if (error < 0)
309 return error;
312 if (total_irq_count)
313 *total_irq_count = irq_count;
315 dprc_remove_devices(mc_bus_dev, child_obj_desc_array,
316 num_child_objects);
318 dprc_add_new_devices(mc_bus_dev, child_obj_desc_array,
319 num_child_objects);
321 if (child_obj_desc_array)
322 devm_kfree(&mc_bus_dev->dev, child_obj_desc_array);
324 return 0;
328 * dprc_scan_container - Scans a physical DPRC and synchronizes Linux bus state
330 * @mc_bus_dev: pointer to the fsl-mc device that represents a DPRC object
332 * Scans the physical DPRC and synchronizes the state of the Linux
333 * bus driver with the actual state of the MC by adding and removing
334 * devices as appropriate.
336 static int dprc_scan_container(struct fsl_mc_device *mc_bus_dev)
338 int error;
339 struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev);
341 fsl_mc_init_all_resource_pools(mc_bus_dev);
344 * Discover objects in the DPRC:
346 mutex_lock(&mc_bus->scan_mutex);
347 error = dprc_scan_objects(mc_bus_dev, NULL);
348 mutex_unlock(&mc_bus->scan_mutex);
349 if (error < 0) {
350 fsl_mc_cleanup_all_resource_pools(mc_bus_dev);
351 return error;
354 return 0;
358 * dprc_irq0_handler - Regular ISR for DPRC interrupt 0
360 * @irq: IRQ number of the interrupt being handled
361 * @arg: Pointer to device structure
363 static irqreturn_t dprc_irq0_handler(int irq_num, void *arg)
365 return IRQ_WAKE_THREAD;
369 * dprc_irq0_handler_thread - Handler thread function for DPRC interrupt 0
371 * @irq: IRQ number of the interrupt being handled
372 * @arg: Pointer to device structure
374 static irqreturn_t dprc_irq0_handler_thread(int irq_num, void *arg)
376 int error;
377 u32 status;
378 struct device *dev = arg;
379 struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
380 struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
381 struct fsl_mc_io *mc_io = mc_dev->mc_io;
382 struct msi_desc *msi_desc = mc_dev->irqs[0]->msi_desc;
384 dev_dbg(dev, "DPRC IRQ %d triggered on CPU %u\n",
385 irq_num, smp_processor_id());
387 if (!(mc_dev->flags & FSL_MC_IS_DPRC))
388 return IRQ_HANDLED;
390 mutex_lock(&mc_bus->scan_mutex);
391 if (!msi_desc || msi_desc->irq != (u32)irq_num)
392 goto out;
394 status = 0;
395 error = dprc_get_irq_status(mc_io, 0, mc_dev->mc_handle, 0,
396 &status);
397 if (error < 0) {
398 dev_err(dev,
399 "dprc_get_irq_status() failed: %d\n", error);
400 goto out;
403 error = dprc_clear_irq_status(mc_io, 0, mc_dev->mc_handle, 0,
404 status);
405 if (error < 0) {
406 dev_err(dev,
407 "dprc_clear_irq_status() failed: %d\n", error);
408 goto out;
411 if (status & (DPRC_IRQ_EVENT_OBJ_ADDED |
412 DPRC_IRQ_EVENT_OBJ_REMOVED |
413 DPRC_IRQ_EVENT_CONTAINER_DESTROYED |
414 DPRC_IRQ_EVENT_OBJ_DESTROYED |
415 DPRC_IRQ_EVENT_OBJ_CREATED)) {
416 unsigned int irq_count;
418 error = dprc_scan_objects(mc_dev, &irq_count);
419 if (error < 0) {
421 * If the error is -ENXIO, we ignore it, as it indicates
422 * that the object scan was aborted, as we detected that
423 * an object was removed from the DPRC in the MC, while
424 * we were scanning the DPRC.
426 if (error != -ENXIO) {
427 dev_err(dev, "dprc_scan_objects() failed: %d\n",
428 error);
431 goto out;
434 if (irq_count > FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS) {
435 dev_warn(dev,
436 "IRQs needed (%u) exceed IRQs preallocated (%u)\n",
437 irq_count, FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS);
441 out:
442 mutex_unlock(&mc_bus->scan_mutex);
443 return IRQ_HANDLED;
447 * Disable and clear interrupt for a given DPRC object
449 static int disable_dprc_irq(struct fsl_mc_device *mc_dev)
451 int error;
452 struct fsl_mc_io *mc_io = mc_dev->mc_io;
455 * Disable generation of interrupt, while we configure it:
457 error = dprc_set_irq_enable(mc_io, 0, mc_dev->mc_handle, 0, 0);
458 if (error < 0) {
459 dev_err(&mc_dev->dev,
460 "Disabling DPRC IRQ failed: dprc_set_irq_enable() failed: %d\n",
461 error);
462 return error;
466 * Disable all interrupt causes for the interrupt:
468 error = dprc_set_irq_mask(mc_io, 0, mc_dev->mc_handle, 0, 0x0);
469 if (error < 0) {
470 dev_err(&mc_dev->dev,
471 "Disabling DPRC IRQ failed: dprc_set_irq_mask() failed: %d\n",
472 error);
473 return error;
477 * Clear any leftover interrupts:
479 error = dprc_clear_irq_status(mc_io, 0, mc_dev->mc_handle, 0, ~0x0U);
480 if (error < 0) {
481 dev_err(&mc_dev->dev,
482 "Disabling DPRC IRQ failed: dprc_clear_irq_status() failed: %d\n",
483 error);
484 return error;
487 return 0;
490 static int register_dprc_irq_handler(struct fsl_mc_device *mc_dev)
492 int error;
493 struct fsl_mc_device_irq *irq = mc_dev->irqs[0];
496 * NOTE: devm_request_threaded_irq() invokes the device-specific
497 * function that programs the MSI physically in the device
499 error = devm_request_threaded_irq(&mc_dev->dev,
500 irq->msi_desc->irq,
501 dprc_irq0_handler,
502 dprc_irq0_handler_thread,
503 IRQF_NO_SUSPEND | IRQF_ONESHOT,
504 dev_name(&mc_dev->dev),
505 &mc_dev->dev);
506 if (error < 0) {
507 dev_err(&mc_dev->dev,
508 "devm_request_threaded_irq() failed: %d\n",
509 error);
510 return error;
513 return 0;
516 static int enable_dprc_irq(struct fsl_mc_device *mc_dev)
518 int error;
521 * Enable all interrupt causes for the interrupt:
523 error = dprc_set_irq_mask(mc_dev->mc_io, 0, mc_dev->mc_handle, 0,
524 ~0x0u);
525 if (error < 0) {
526 dev_err(&mc_dev->dev,
527 "Enabling DPRC IRQ failed: dprc_set_irq_mask() failed: %d\n",
528 error);
530 return error;
534 * Enable generation of the interrupt:
536 error = dprc_set_irq_enable(mc_dev->mc_io, 0, mc_dev->mc_handle, 0, 1);
537 if (error < 0) {
538 dev_err(&mc_dev->dev,
539 "Enabling DPRC IRQ failed: dprc_set_irq_enable() failed: %d\n",
540 error);
542 return error;
545 return 0;
549 * Setup interrupt for a given DPRC device
551 static int dprc_setup_irq(struct fsl_mc_device *mc_dev)
553 int error;
555 error = fsl_mc_allocate_irqs(mc_dev);
556 if (error < 0)
557 return error;
559 error = disable_dprc_irq(mc_dev);
560 if (error < 0)
561 goto error_free_irqs;
563 error = register_dprc_irq_handler(mc_dev);
564 if (error < 0)
565 goto error_free_irqs;
567 error = enable_dprc_irq(mc_dev);
568 if (error < 0)
569 goto error_free_irqs;
571 return 0;
573 error_free_irqs:
574 fsl_mc_free_irqs(mc_dev);
575 return error;
579 * dprc_probe - callback invoked when a DPRC is being bound to this driver
581 * @mc_dev: Pointer to fsl-mc device representing a DPRC
583 * It opens the physical DPRC in the MC.
584 * It scans the DPRC to discover the MC objects contained in it.
585 * It creates the interrupt pool for the MC bus associated with the DPRC.
586 * It configures the interrupts for the DPRC device itself.
588 static int dprc_probe(struct fsl_mc_device *mc_dev)
590 int error;
591 size_t region_size;
592 struct device *parent_dev = mc_dev->dev.parent;
593 struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
594 bool mc_io_created = false;
595 bool msi_domain_set = false;
596 u16 major_ver, minor_ver;
598 if (!is_fsl_mc_bus_dprc(mc_dev))
599 return -EINVAL;
601 if (dev_get_msi_domain(&mc_dev->dev))
602 return -EINVAL;
604 if (!mc_dev->mc_io) {
606 * This is a child DPRC:
608 if (!dev_is_fsl_mc(parent_dev))
609 return -EINVAL;
611 if (mc_dev->obj_desc.region_count == 0)
612 return -EINVAL;
614 region_size = resource_size(mc_dev->regions);
616 error = fsl_create_mc_io(&mc_dev->dev,
617 mc_dev->regions[0].start,
618 region_size,
619 NULL,
620 FSL_MC_IO_ATOMIC_CONTEXT_PORTAL,
621 &mc_dev->mc_io);
622 if (error < 0)
623 return error;
625 mc_io_created = true;
628 * Inherit parent MSI domain:
630 dev_set_msi_domain(&mc_dev->dev,
631 dev_get_msi_domain(parent_dev));
632 msi_domain_set = true;
633 } else {
635 * This is a root DPRC
637 struct irq_domain *mc_msi_domain;
639 if (dev_is_fsl_mc(parent_dev))
640 return -EINVAL;
642 error = fsl_mc_find_msi_domain(parent_dev,
643 &mc_msi_domain);
644 if (error < 0) {
645 dev_warn(&mc_dev->dev,
646 "WARNING: MC bus without interrupt support\n");
647 } else {
648 dev_set_msi_domain(&mc_dev->dev, mc_msi_domain);
649 msi_domain_set = true;
653 error = dprc_open(mc_dev->mc_io, 0, mc_dev->obj_desc.id,
654 &mc_dev->mc_handle);
655 if (error < 0) {
656 dev_err(&mc_dev->dev, "dprc_open() failed: %d\n", error);
657 goto error_cleanup_msi_domain;
660 error = dprc_get_attributes(mc_dev->mc_io, 0, mc_dev->mc_handle,
661 &mc_bus->dprc_attr);
662 if (error < 0) {
663 dev_err(&mc_dev->dev, "dprc_get_attributes() failed: %d\n",
664 error);
665 goto error_cleanup_open;
668 error = dprc_get_api_version(mc_dev->mc_io, 0,
669 &major_ver,
670 &minor_ver);
671 if (error < 0) {
672 dev_err(&mc_dev->dev, "dprc_get_api_version() failed: %d\n",
673 error);
674 goto error_cleanup_open;
677 if (major_ver < DPRC_MIN_VER_MAJOR ||
678 (major_ver == DPRC_MIN_VER_MAJOR &&
679 minor_ver < DPRC_MIN_VER_MINOR)) {
680 dev_err(&mc_dev->dev,
681 "ERROR: DPRC version %d.%d not supported\n",
682 major_ver, minor_ver);
683 error = -ENOTSUPP;
684 goto error_cleanup_open;
687 mutex_init(&mc_bus->scan_mutex);
690 * Discover MC objects in DPRC object:
692 error = dprc_scan_container(mc_dev);
693 if (error < 0)
694 goto error_cleanup_open;
697 * Configure interrupt for the DPRC object associated with this MC bus:
699 error = dprc_setup_irq(mc_dev);
700 if (error < 0)
701 goto error_cleanup_open;
703 dev_info(&mc_dev->dev, "DPRC device bound to driver");
704 return 0;
706 error_cleanup_open:
707 (void)dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle);
709 error_cleanup_msi_domain:
710 if (msi_domain_set)
711 dev_set_msi_domain(&mc_dev->dev, NULL);
713 if (mc_io_created) {
714 fsl_destroy_mc_io(mc_dev->mc_io);
715 mc_dev->mc_io = NULL;
718 return error;
722 * Tear down interrupt for a given DPRC object
724 static void dprc_teardown_irq(struct fsl_mc_device *mc_dev)
726 struct fsl_mc_device_irq *irq = mc_dev->irqs[0];
728 (void)disable_dprc_irq(mc_dev);
730 devm_free_irq(&mc_dev->dev, irq->msi_desc->irq, &mc_dev->dev);
732 fsl_mc_free_irqs(mc_dev);
736 * dprc_remove - callback invoked when a DPRC is being unbound from this driver
738 * @mc_dev: Pointer to fsl-mc device representing the DPRC
740 * It removes the DPRC's child objects from Linux (not from the MC) and
741 * closes the DPRC device in the MC.
742 * It tears down the interrupts that were configured for the DPRC device.
743 * It destroys the interrupt pool associated with this MC bus.
745 static int dprc_remove(struct fsl_mc_device *mc_dev)
747 int error;
748 struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
750 if (!is_fsl_mc_bus_dprc(mc_dev))
751 return -EINVAL;
752 if (!mc_dev->mc_io)
753 return -EINVAL;
755 if (!mc_bus->irq_resources)
756 return -EINVAL;
758 if (dev_get_msi_domain(&mc_dev->dev))
759 dprc_teardown_irq(mc_dev);
761 device_for_each_child(&mc_dev->dev, NULL, __fsl_mc_device_remove);
763 if (dev_get_msi_domain(&mc_dev->dev)) {
764 fsl_mc_cleanup_irq_pool(mc_bus);
765 dev_set_msi_domain(&mc_dev->dev, NULL);
768 fsl_mc_cleanup_all_resource_pools(mc_dev);
770 error = dprc_close(mc_dev->mc_io, 0, mc_dev->mc_handle);
771 if (error < 0)
772 dev_err(&mc_dev->dev, "dprc_close() failed: %d\n", error);
774 if (!fsl_mc_is_root_dprc(&mc_dev->dev)) {
775 fsl_destroy_mc_io(mc_dev->mc_io);
776 mc_dev->mc_io = NULL;
779 dev_info(&mc_dev->dev, "DPRC device unbound from driver");
780 return 0;
783 static const struct fsl_mc_device_id match_id_table[] = {
785 .vendor = FSL_MC_VENDOR_FREESCALE,
786 .obj_type = "dprc"},
787 {.vendor = 0x0},
790 static struct fsl_mc_driver dprc_driver = {
791 .driver = {
792 .name = FSL_MC_DPRC_DRIVER_NAME,
793 .owner = THIS_MODULE,
794 .pm = NULL,
796 .match_id_table = match_id_table,
797 .probe = dprc_probe,
798 .remove = dprc_remove,
801 int __init dprc_driver_init(void)
803 return fsl_mc_driver_register(&dprc_driver);
806 void dprc_driver_exit(void)
808 fsl_mc_driver_unregister(&dprc_driver);