memblock: don't mark memblock_phys_mem_size() as __init
[linux/fpc-iii.git] / drivers / virtio / virtio_mmio.c
blob745c6ee1bb3eab1259522d2833b350aa33ceb1f7
1 /*
2 * Virtio memory mapped device driver
4 * Copyright 2011-2014, ARM Ltd.
6 * This module allows virtio devices to be used over a virtual, memory mapped
7 * platform device.
9 * The guest device(s) may be instantiated in one of three equivalent ways:
11 * 1. Static platform device in board's code, eg.:
13 * static struct platform_device v2m_virtio_device = {
14 * .name = "virtio-mmio",
15 * .id = -1,
16 * .num_resources = 2,
17 * .resource = (struct resource []) {
18 * {
19 * .start = 0x1001e000,
20 * .end = 0x1001e0ff,
21 * .flags = IORESOURCE_MEM,
22 * }, {
23 * .start = 42 + 32,
24 * .end = 42 + 32,
25 * .flags = IORESOURCE_IRQ,
26 * },
27 * }
28 * };
30 * 2. Device Tree node, eg.:
32 * virtio_block@1e000 {
33 * compatible = "virtio,mmio";
34 * reg = <0x1e000 0x100>;
35 * interrupts = <42>;
36 * }
38 * 3. Kernel module (or command line) parameter. Can be used more than once -
39 * one device will be created for each one. Syntax:
41 * [virtio_mmio.]device=<size>@<baseaddr>:<irq>[:<id>]
42 * where:
43 * <size> := size (can use standard suffixes like K, M or G)
44 * <baseaddr> := physical base address
45 * <irq> := interrupt number (as passed to request_irq())
46 * <id> := (optional) platform device id
47 * eg.:
48 * virtio_mmio.device=0x100@0x100b0000:48 \
49 * virtio_mmio.device=1K@0x1001e000:74
53 * Based on Virtio PCI driver by Anthony Liguori, copyright IBM Corp. 2007
55 * This work is licensed under the terms of the GNU GPL, version 2 or later.
56 * See the COPYING file in the top-level directory.
59 #define pr_fmt(fmt) "virtio-mmio: " fmt
61 #include <linux/acpi.h>
62 #include <linux/highmem.h>
63 #include <linux/interrupt.h>
64 #include <linux/io.h>
65 #include <linux/list.h>
66 #include <linux/module.h>
67 #include <linux/platform_device.h>
68 #include <linux/slab.h>
69 #include <linux/spinlock.h>
70 #include <linux/virtio.h>
71 #include <linux/virtio_config.h>
72 #include <linux/virtio_mmio.h>
73 #include <linux/virtio_ring.h>
77 /* The alignment to use between consumer and producer parts of vring.
78 * Currently hardcoded to the page size. */
79 #define VIRTIO_MMIO_VRING_ALIGN PAGE_SIZE
83 #define to_virtio_mmio_device(_plat_dev) \
84 container_of(_plat_dev, struct virtio_mmio_device, vdev)
86 struct virtio_mmio_device {
87 struct virtio_device vdev;
88 struct platform_device *pdev;
90 void __iomem *base;
91 unsigned long version;
93 /* a list of queues so we can dispatch IRQs */
94 spinlock_t lock;
95 struct list_head virtqueues;
98 struct virtio_mmio_vq_info {
99 /* the actual virtqueue */
100 struct virtqueue *vq;
102 /* the number of entries in the queue */
103 unsigned int num;
105 /* the virtual address of the ring queue */
106 void *queue;
108 /* the list node for the virtqueues list */
109 struct list_head node;
114 /* Configuration interface */
116 static u64 vm_get_features(struct virtio_device *vdev)
118 struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
119 u64 features;
121 writel(1, vm_dev->base + VIRTIO_MMIO_DEVICE_FEATURES_SEL);
122 features = readl(vm_dev->base + VIRTIO_MMIO_DEVICE_FEATURES);
123 features <<= 32;
125 writel(0, vm_dev->base + VIRTIO_MMIO_DEVICE_FEATURES_SEL);
126 features |= readl(vm_dev->base + VIRTIO_MMIO_DEVICE_FEATURES);
128 return features;
131 static int vm_finalize_features(struct virtio_device *vdev)
133 struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
135 /* Give virtio_ring a chance to accept features. */
136 vring_transport_features(vdev);
138 /* Make sure there is are no mixed devices */
139 if (vm_dev->version == 2 &&
140 !__virtio_test_bit(vdev, VIRTIO_F_VERSION_1)) {
141 dev_err(&vdev->dev, "New virtio-mmio devices (version 2) must provide VIRTIO_F_VERSION_1 feature!\n");
142 return -EINVAL;
145 writel(1, vm_dev->base + VIRTIO_MMIO_DRIVER_FEATURES_SEL);
146 writel((u32)(vdev->features >> 32),
147 vm_dev->base + VIRTIO_MMIO_DRIVER_FEATURES);
149 writel(0, vm_dev->base + VIRTIO_MMIO_DRIVER_FEATURES_SEL);
150 writel((u32)vdev->features,
151 vm_dev->base + VIRTIO_MMIO_DRIVER_FEATURES);
153 return 0;
156 static void vm_get(struct virtio_device *vdev, unsigned offset,
157 void *buf, unsigned len)
159 struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
160 void __iomem *base = vm_dev->base + VIRTIO_MMIO_CONFIG;
161 u8 b;
162 __le16 w;
163 __le32 l;
165 if (vm_dev->version == 1) {
166 u8 *ptr = buf;
167 int i;
169 for (i = 0; i < len; i++)
170 ptr[i] = readb(base + offset + i);
171 return;
174 switch (len) {
175 case 1:
176 b = readb(base + offset);
177 memcpy(buf, &b, sizeof b);
178 break;
179 case 2:
180 w = cpu_to_le16(readw(base + offset));
181 memcpy(buf, &w, sizeof w);
182 break;
183 case 4:
184 l = cpu_to_le32(readl(base + offset));
185 memcpy(buf, &l, sizeof l);
186 break;
187 case 8:
188 l = cpu_to_le32(readl(base + offset));
189 memcpy(buf, &l, sizeof l);
190 l = cpu_to_le32(ioread32(base + offset + sizeof l));
191 memcpy(buf + sizeof l, &l, sizeof l);
192 break;
193 default:
194 BUG();
198 static void vm_set(struct virtio_device *vdev, unsigned offset,
199 const void *buf, unsigned len)
201 struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
202 void __iomem *base = vm_dev->base + VIRTIO_MMIO_CONFIG;
203 u8 b;
204 __le16 w;
205 __le32 l;
207 if (vm_dev->version == 1) {
208 const u8 *ptr = buf;
209 int i;
211 for (i = 0; i < len; i++)
212 writeb(ptr[i], base + offset + i);
214 return;
217 switch (len) {
218 case 1:
219 memcpy(&b, buf, sizeof b);
220 writeb(b, base + offset);
221 break;
222 case 2:
223 memcpy(&w, buf, sizeof w);
224 writew(le16_to_cpu(w), base + offset);
225 break;
226 case 4:
227 memcpy(&l, buf, sizeof l);
228 writel(le32_to_cpu(l), base + offset);
229 break;
230 case 8:
231 memcpy(&l, buf, sizeof l);
232 writel(le32_to_cpu(l), base + offset);
233 memcpy(&l, buf + sizeof l, sizeof l);
234 writel(le32_to_cpu(l), base + offset + sizeof l);
235 break;
236 default:
237 BUG();
241 static u32 vm_generation(struct virtio_device *vdev)
243 struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
245 if (vm_dev->version == 1)
246 return 0;
247 else
248 return readl(vm_dev->base + VIRTIO_MMIO_CONFIG_GENERATION);
251 static u8 vm_get_status(struct virtio_device *vdev)
253 struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
255 return readl(vm_dev->base + VIRTIO_MMIO_STATUS) & 0xff;
258 static void vm_set_status(struct virtio_device *vdev, u8 status)
260 struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
262 /* We should never be setting status to 0. */
263 BUG_ON(status == 0);
265 writel(status, vm_dev->base + VIRTIO_MMIO_STATUS);
268 static void vm_reset(struct virtio_device *vdev)
270 struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
272 /* 0 status means a reset. */
273 writel(0, vm_dev->base + VIRTIO_MMIO_STATUS);
278 /* Transport interface */
280 /* the notify function used when creating a virt queue */
281 static bool vm_notify(struct virtqueue *vq)
283 struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vq->vdev);
285 /* We write the queue's selector into the notification register to
286 * signal the other end */
287 writel(vq->index, vm_dev->base + VIRTIO_MMIO_QUEUE_NOTIFY);
288 return true;
291 /* Notify all virtqueues on an interrupt. */
292 static irqreturn_t vm_interrupt(int irq, void *opaque)
294 struct virtio_mmio_device *vm_dev = opaque;
295 struct virtio_mmio_vq_info *info;
296 unsigned long status;
297 unsigned long flags;
298 irqreturn_t ret = IRQ_NONE;
300 /* Read and acknowledge interrupts */
301 status = readl(vm_dev->base + VIRTIO_MMIO_INTERRUPT_STATUS);
302 writel(status, vm_dev->base + VIRTIO_MMIO_INTERRUPT_ACK);
304 if (unlikely(status & VIRTIO_MMIO_INT_CONFIG)) {
305 virtio_config_changed(&vm_dev->vdev);
306 ret = IRQ_HANDLED;
309 if (likely(status & VIRTIO_MMIO_INT_VRING)) {
310 spin_lock_irqsave(&vm_dev->lock, flags);
311 list_for_each_entry(info, &vm_dev->virtqueues, node)
312 ret |= vring_interrupt(irq, info->vq);
313 spin_unlock_irqrestore(&vm_dev->lock, flags);
316 return ret;
321 static void vm_del_vq(struct virtqueue *vq)
323 struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vq->vdev);
324 struct virtio_mmio_vq_info *info = vq->priv;
325 unsigned long flags, size;
326 unsigned int index = vq->index;
328 spin_lock_irqsave(&vm_dev->lock, flags);
329 list_del(&info->node);
330 spin_unlock_irqrestore(&vm_dev->lock, flags);
332 vring_del_virtqueue(vq);
334 /* Select and deactivate the queue */
335 writel(index, vm_dev->base + VIRTIO_MMIO_QUEUE_SEL);
336 if (vm_dev->version == 1) {
337 writel(0, vm_dev->base + VIRTIO_MMIO_QUEUE_PFN);
338 } else {
339 writel(0, vm_dev->base + VIRTIO_MMIO_QUEUE_READY);
340 WARN_ON(readl(vm_dev->base + VIRTIO_MMIO_QUEUE_READY));
343 size = PAGE_ALIGN(vring_size(info->num, VIRTIO_MMIO_VRING_ALIGN));
344 free_pages_exact(info->queue, size);
345 kfree(info);
348 static void vm_del_vqs(struct virtio_device *vdev)
350 struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
351 struct virtqueue *vq, *n;
353 list_for_each_entry_safe(vq, n, &vdev->vqs, list)
354 vm_del_vq(vq);
356 free_irq(platform_get_irq(vm_dev->pdev, 0), vm_dev);
361 static struct virtqueue *vm_setup_vq(struct virtio_device *vdev, unsigned index,
362 void (*callback)(struct virtqueue *vq),
363 const char *name)
365 struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
366 struct virtio_mmio_vq_info *info;
367 struct virtqueue *vq;
368 unsigned long flags, size;
369 int err;
371 if (!name)
372 return NULL;
374 /* Select the queue we're interested in */
375 writel(index, vm_dev->base + VIRTIO_MMIO_QUEUE_SEL);
377 /* Queue shouldn't already be set up. */
378 if (readl(vm_dev->base + (vm_dev->version == 1 ?
379 VIRTIO_MMIO_QUEUE_PFN : VIRTIO_MMIO_QUEUE_READY))) {
380 err = -ENOENT;
381 goto error_available;
384 /* Allocate and fill out our active queue description */
385 info = kmalloc(sizeof(*info), GFP_KERNEL);
386 if (!info) {
387 err = -ENOMEM;
388 goto error_kmalloc;
391 /* Allocate pages for the queue - start with a queue as big as
392 * possible (limited by maximum size allowed by device), drop down
393 * to a minimal size, just big enough to fit descriptor table
394 * and two rings (which makes it "alignment_size * 2")
396 info->num = readl(vm_dev->base + VIRTIO_MMIO_QUEUE_NUM_MAX);
398 /* If the device reports a 0 entry queue, we won't be able to
399 * use it to perform I/O, and vring_new_virtqueue() can't create
400 * empty queues anyway, so don't bother to set up the device.
402 if (info->num == 0) {
403 err = -ENOENT;
404 goto error_alloc_pages;
407 while (1) {
408 size = PAGE_ALIGN(vring_size(info->num,
409 VIRTIO_MMIO_VRING_ALIGN));
410 /* Did the last iter shrink the queue below minimum size? */
411 if (size < VIRTIO_MMIO_VRING_ALIGN * 2) {
412 err = -ENOMEM;
413 goto error_alloc_pages;
416 info->queue = alloc_pages_exact(size, GFP_KERNEL | __GFP_ZERO);
417 if (info->queue)
418 break;
420 info->num /= 2;
423 /* Create the vring */
424 vq = vring_new_virtqueue(index, info->num, VIRTIO_MMIO_VRING_ALIGN, vdev,
425 true, info->queue, vm_notify, callback, name);
426 if (!vq) {
427 err = -ENOMEM;
428 goto error_new_virtqueue;
431 /* Activate the queue */
432 writel(info->num, vm_dev->base + VIRTIO_MMIO_QUEUE_NUM);
433 if (vm_dev->version == 1) {
434 writel(PAGE_SIZE, vm_dev->base + VIRTIO_MMIO_QUEUE_ALIGN);
435 writel(virt_to_phys(info->queue) >> PAGE_SHIFT,
436 vm_dev->base + VIRTIO_MMIO_QUEUE_PFN);
437 } else {
438 u64 addr;
440 addr = virt_to_phys(info->queue);
441 writel((u32)addr, vm_dev->base + VIRTIO_MMIO_QUEUE_DESC_LOW);
442 writel((u32)(addr >> 32),
443 vm_dev->base + VIRTIO_MMIO_QUEUE_DESC_HIGH);
445 addr = virt_to_phys(virtqueue_get_avail(vq));
446 writel((u32)addr, vm_dev->base + VIRTIO_MMIO_QUEUE_AVAIL_LOW);
447 writel((u32)(addr >> 32),
448 vm_dev->base + VIRTIO_MMIO_QUEUE_AVAIL_HIGH);
450 addr = virt_to_phys(virtqueue_get_used(vq));
451 writel((u32)addr, vm_dev->base + VIRTIO_MMIO_QUEUE_USED_LOW);
452 writel((u32)(addr >> 32),
453 vm_dev->base + VIRTIO_MMIO_QUEUE_USED_HIGH);
455 writel(1, vm_dev->base + VIRTIO_MMIO_QUEUE_READY);
458 vq->priv = info;
459 info->vq = vq;
461 spin_lock_irqsave(&vm_dev->lock, flags);
462 list_add(&info->node, &vm_dev->virtqueues);
463 spin_unlock_irqrestore(&vm_dev->lock, flags);
465 return vq;
467 error_new_virtqueue:
468 if (vm_dev->version == 1) {
469 writel(0, vm_dev->base + VIRTIO_MMIO_QUEUE_PFN);
470 } else {
471 writel(0, vm_dev->base + VIRTIO_MMIO_QUEUE_READY);
472 WARN_ON(readl(vm_dev->base + VIRTIO_MMIO_QUEUE_READY));
474 free_pages_exact(info->queue, size);
475 error_alloc_pages:
476 kfree(info);
477 error_kmalloc:
478 error_available:
479 return ERR_PTR(err);
482 static int vm_find_vqs(struct virtio_device *vdev, unsigned nvqs,
483 struct virtqueue *vqs[],
484 vq_callback_t *callbacks[],
485 const char * const names[])
487 struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
488 unsigned int irq = platform_get_irq(vm_dev->pdev, 0);
489 int i, err;
491 err = request_irq(irq, vm_interrupt, IRQF_SHARED,
492 dev_name(&vdev->dev), vm_dev);
493 if (err)
494 return err;
496 for (i = 0; i < nvqs; ++i) {
497 vqs[i] = vm_setup_vq(vdev, i, callbacks[i], names[i]);
498 if (IS_ERR(vqs[i])) {
499 vm_del_vqs(vdev);
500 return PTR_ERR(vqs[i]);
504 return 0;
507 static const char *vm_bus_name(struct virtio_device *vdev)
509 struct virtio_mmio_device *vm_dev = to_virtio_mmio_device(vdev);
511 return vm_dev->pdev->name;
514 static const struct virtio_config_ops virtio_mmio_config_ops = {
515 .get = vm_get,
516 .set = vm_set,
517 .generation = vm_generation,
518 .get_status = vm_get_status,
519 .set_status = vm_set_status,
520 .reset = vm_reset,
521 .find_vqs = vm_find_vqs,
522 .del_vqs = vm_del_vqs,
523 .get_features = vm_get_features,
524 .finalize_features = vm_finalize_features,
525 .bus_name = vm_bus_name,
530 /* Platform device */
532 static int virtio_mmio_probe(struct platform_device *pdev)
534 struct virtio_mmio_device *vm_dev;
535 struct resource *mem;
536 unsigned long magic;
538 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
539 if (!mem)
540 return -EINVAL;
542 if (!devm_request_mem_region(&pdev->dev, mem->start,
543 resource_size(mem), pdev->name))
544 return -EBUSY;
546 vm_dev = devm_kzalloc(&pdev->dev, sizeof(*vm_dev), GFP_KERNEL);
547 if (!vm_dev)
548 return -ENOMEM;
550 vm_dev->vdev.dev.parent = &pdev->dev;
551 vm_dev->vdev.config = &virtio_mmio_config_ops;
552 vm_dev->pdev = pdev;
553 INIT_LIST_HEAD(&vm_dev->virtqueues);
554 spin_lock_init(&vm_dev->lock);
556 vm_dev->base = devm_ioremap(&pdev->dev, mem->start, resource_size(mem));
557 if (vm_dev->base == NULL)
558 return -EFAULT;
560 /* Check magic value */
561 magic = readl(vm_dev->base + VIRTIO_MMIO_MAGIC_VALUE);
562 if (magic != ('v' | 'i' << 8 | 'r' << 16 | 't' << 24)) {
563 dev_warn(&pdev->dev, "Wrong magic value 0x%08lx!\n", magic);
564 return -ENODEV;
567 /* Check device version */
568 vm_dev->version = readl(vm_dev->base + VIRTIO_MMIO_VERSION);
569 if (vm_dev->version < 1 || vm_dev->version > 2) {
570 dev_err(&pdev->dev, "Version %ld not supported!\n",
571 vm_dev->version);
572 return -ENXIO;
575 vm_dev->vdev.id.device = readl(vm_dev->base + VIRTIO_MMIO_DEVICE_ID);
576 if (vm_dev->vdev.id.device == 0) {
578 * virtio-mmio device with an ID 0 is a (dummy) placeholder
579 * with no function. End probing now with no error reported.
581 return -ENODEV;
583 vm_dev->vdev.id.vendor = readl(vm_dev->base + VIRTIO_MMIO_VENDOR_ID);
585 if (vm_dev->version == 1)
586 writel(PAGE_SIZE, vm_dev->base + VIRTIO_MMIO_GUEST_PAGE_SIZE);
588 platform_set_drvdata(pdev, vm_dev);
590 return register_virtio_device(&vm_dev->vdev);
593 static int virtio_mmio_remove(struct platform_device *pdev)
595 struct virtio_mmio_device *vm_dev = platform_get_drvdata(pdev);
597 unregister_virtio_device(&vm_dev->vdev);
599 return 0;
604 /* Devices list parameter */
606 #if defined(CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES)
608 static struct device vm_cmdline_parent = {
609 .init_name = "virtio-mmio-cmdline",
612 static int vm_cmdline_parent_registered;
613 static int vm_cmdline_id;
615 static int vm_cmdline_set(const char *device,
616 const struct kernel_param *kp)
618 int err;
619 struct resource resources[2] = {};
620 char *str;
621 long long int base, size;
622 unsigned int irq;
623 int processed, consumed = 0;
624 struct platform_device *pdev;
626 /* Consume "size" part of the command line parameter */
627 size = memparse(device, &str);
629 /* Get "@<base>:<irq>[:<id>]" chunks */
630 processed = sscanf(str, "@%lli:%u%n:%d%n",
631 &base, &irq, &consumed,
632 &vm_cmdline_id, &consumed);
635 * sscanf() must processes at least 2 chunks; also there
636 * must be no extra characters after the last chunk, so
637 * str[consumed] must be '\0'
639 if (processed < 2 || str[consumed])
640 return -EINVAL;
642 resources[0].flags = IORESOURCE_MEM;
643 resources[0].start = base;
644 resources[0].end = base + size - 1;
646 resources[1].flags = IORESOURCE_IRQ;
647 resources[1].start = resources[1].end = irq;
649 if (!vm_cmdline_parent_registered) {
650 err = device_register(&vm_cmdline_parent);
651 if (err) {
652 pr_err("Failed to register parent device!\n");
653 return err;
655 vm_cmdline_parent_registered = 1;
658 pr_info("Registering device virtio-mmio.%d at 0x%llx-0x%llx, IRQ %d.\n",
659 vm_cmdline_id,
660 (unsigned long long)resources[0].start,
661 (unsigned long long)resources[0].end,
662 (int)resources[1].start);
664 pdev = platform_device_register_resndata(&vm_cmdline_parent,
665 "virtio-mmio", vm_cmdline_id++,
666 resources, ARRAY_SIZE(resources), NULL, 0);
667 if (IS_ERR(pdev))
668 return PTR_ERR(pdev);
670 return 0;
673 static int vm_cmdline_get_device(struct device *dev, void *data)
675 char *buffer = data;
676 unsigned int len = strlen(buffer);
677 struct platform_device *pdev = to_platform_device(dev);
679 snprintf(buffer + len, PAGE_SIZE - len, "0x%llx@0x%llx:%llu:%d\n",
680 pdev->resource[0].end - pdev->resource[0].start + 1ULL,
681 (unsigned long long)pdev->resource[0].start,
682 (unsigned long long)pdev->resource[1].start,
683 pdev->id);
684 return 0;
687 static int vm_cmdline_get(char *buffer, const struct kernel_param *kp)
689 buffer[0] = '\0';
690 device_for_each_child(&vm_cmdline_parent, buffer,
691 vm_cmdline_get_device);
692 return strlen(buffer) + 1;
695 static const struct kernel_param_ops vm_cmdline_param_ops = {
696 .set = vm_cmdline_set,
697 .get = vm_cmdline_get,
700 device_param_cb(device, &vm_cmdline_param_ops, NULL, S_IRUSR);
702 static int vm_unregister_cmdline_device(struct device *dev,
703 void *data)
705 platform_device_unregister(to_platform_device(dev));
707 return 0;
710 static void vm_unregister_cmdline_devices(void)
712 if (vm_cmdline_parent_registered) {
713 device_for_each_child(&vm_cmdline_parent, NULL,
714 vm_unregister_cmdline_device);
715 device_unregister(&vm_cmdline_parent);
716 vm_cmdline_parent_registered = 0;
720 #else
722 static void vm_unregister_cmdline_devices(void)
726 #endif
728 /* Platform driver */
730 static struct of_device_id virtio_mmio_match[] = {
731 { .compatible = "virtio,mmio", },
734 MODULE_DEVICE_TABLE(of, virtio_mmio_match);
736 #ifdef CONFIG_ACPI
737 static const struct acpi_device_id virtio_mmio_acpi_match[] = {
738 { "LNRO0005", },
741 MODULE_DEVICE_TABLE(acpi, virtio_mmio_acpi_match);
742 #endif
744 static struct platform_driver virtio_mmio_driver = {
745 .probe = virtio_mmio_probe,
746 .remove = virtio_mmio_remove,
747 .driver = {
748 .name = "virtio-mmio",
749 .of_match_table = virtio_mmio_match,
750 .acpi_match_table = ACPI_PTR(virtio_mmio_acpi_match),
754 static int __init virtio_mmio_init(void)
756 return platform_driver_register(&virtio_mmio_driver);
759 static void __exit virtio_mmio_exit(void)
761 platform_driver_unregister(&virtio_mmio_driver);
762 vm_unregister_cmdline_devices();
765 module_init(virtio_mmio_init);
766 module_exit(virtio_mmio_exit);
768 MODULE_AUTHOR("Pawel Moll <pawel.moll@arm.com>");
769 MODULE_DESCRIPTION("Platform bus driver for memory mapped virtio devices");
770 MODULE_LICENSE("GPL");