linux/drivers/virtio/virtio_mmio.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Virtio memory mapped device driver
 *
 * Copyright 2011-2014, ARM Ltd.
 *
 * This module allows virtio devices to be used over a virtual, memory mapped
 * platform device.
 *
 * The guest device(s) may be instantiated in one of three equivalent ways:
 *
 * 1. Static platform device in board's code, eg.:
 *
 *	static struct platform_device v2m_virtio_device = {
 *		.name = "virtio-mmio",
 *		.id = -1,
 *		.num_resources = 2,
 *		.resource = (struct resource []) {
 *			{
 *				.start = 0x1001e000,
 *				.end = 0x1001e0ff,
 *				.flags = IORESOURCE_MEM,
 *			}, {
 *				.start = 42 + 32,
 *				.end = 42 + 32,
 *				.flags = IORESOURCE_IRQ,
 *			},
 *		}
 *	};
 *
 * 2. Device Tree node, eg.:
 *
 *		virtio_block@1e000 {
 *			compatible = "virtio,mmio";
 *			reg = <0x1e000 0x100>;
 *			interrupts = <42>;
 *		}
 *
 * 3. Kernel module (or command line) parameter. Can be used more than once -
 *    one device will be created for each one. Syntax:
 *
 *		[virtio_mmio.]device=<size>@<baseaddr>:<irq>[:<id>]
 *    where:
 *		<size>     := size (can use standard suffixes like K, M or G)
 *		<baseaddr> := physical base address
 *		<irq>      := interrupt number (as passed to request_irq())
 *		<id>       := (optional) platform device id
 *    eg.:
 *		virtio_mmio.device=0x100@0x100b0000:48 \
 *				virtio_mmio.device=1K@0x1001e000:74
 *
 * Based on Virtio PCI driver by Anthony Liguori, copyright IBM Corp. 2007
 */

#define pr_fmt(fmt)

#include <linux/acpi.h>
#include <linux/dma-mapping.h>
#include <linux/highmem.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/virtio.h>
#include <linux/virtio_config.h>
#include <uapi/linux/virtio_mmio.h>
#include <linux/virtio_ring.h>



/* The alignment to use between consumer and producer parts of vring.
 * Currently hardcoded to the page size. */
#define VIRTIO_MMIO_VRING_ALIGN



#define to_virtio_mmio_device(_plat_dev)

struct virtio_mmio_device {};

struct virtio_mmio_vq_info {};



/* Configuration interface */

static u64 vm_get_features(struct virtio_device *vdev)
{}

static int vm_finalize_features(struct virtio_device *vdev)
{}

static void vm_get(struct virtio_device *vdev, unsigned int offset,
		   void *buf, unsigned int len)
{}

static void vm_set(struct virtio_device *vdev, unsigned int offset,
		   const void *buf, unsigned int len)
{}

static u32 vm_generation(struct virtio_device *vdev)
{}

static u8 vm_get_status(struct virtio_device *vdev)
{}

static void vm_set_status(struct virtio_device *vdev, u8 status)
{}

static void vm_reset(struct virtio_device *vdev)
{}



/* Transport interface */

/* the notify function used when creating a virt queue */
static bool vm_notify(struct virtqueue *vq)
{}

static bool vm_notify_with_data(struct virtqueue *vq)
{}

/* Notify all virtqueues on an interrupt. */
static irqreturn_t vm_interrupt(int irq, void *opaque)
{}



static void vm_del_vq(struct virtqueue *vq)
{}

static void vm_del_vqs(struct virtio_device *vdev)
{}

static void vm_synchronize_cbs(struct virtio_device *vdev)
{}

static struct virtqueue *vm_setup_vq(struct virtio_device *vdev, unsigned int index,
				  void (*callback)(struct virtqueue *vq),
				  const char *name, bool ctx)
{}

static int vm_find_vqs(struct virtio_device *vdev, unsigned int nvqs,
		       struct virtqueue *vqs[],
		       struct virtqueue_info vqs_info[],
		       struct irq_affinity *desc)
{}

static const char *vm_bus_name(struct virtio_device *vdev)
{}

static bool vm_get_shm_region(struct virtio_device *vdev,
			      struct virtio_shm_region *region, u8 id)
{}

static const struct virtio_config_ops virtio_mmio_config_ops =;

#ifdef CONFIG_PM_SLEEP
static int virtio_mmio_freeze(struct device *dev)
{}

static int virtio_mmio_restore(struct device *dev)
{}

static const struct dev_pm_ops virtio_mmio_pm_ops =;
#endif

static void virtio_mmio_release_dev(struct device *_d)
{}

/* Platform device */

static int virtio_mmio_probe(struct platform_device *pdev)
{}

static void virtio_mmio_remove(struct platform_device *pdev)
{}



/* Devices list parameter */

#if defined(CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES)

static struct device vm_cmdline_parent =;

static int vm_cmdline_parent_registered;
static int vm_cmdline_id;

static int vm_cmdline_set(const char *device,
		const struct kernel_param *kp)
{}

static int vm_cmdline_get_device(struct device *dev, void *data)
{}

static int vm_cmdline_get(char *buffer, const struct kernel_param *kp)
{}

static const struct kernel_param_ops vm_cmdline_param_ops =;

device_param_cb();

static int vm_unregister_cmdline_device(struct device *dev,
		void *data)
{}

static void vm_unregister_cmdline_devices(void)
{}

#else

static void vm_unregister_cmdline_devices(void)
{
}

#endif

/* Platform driver */

static const struct of_device_id virtio_mmio_match[] =;
MODULE_DEVICE_TABLE(of, virtio_mmio_match);

#ifdef CONFIG_ACPI
static const struct acpi_device_id virtio_mmio_acpi_match[] =;
MODULE_DEVICE_TABLE(acpi, virtio_mmio_acpi_match);
#endif

static struct platform_driver virtio_mmio_driver =;

static int __init virtio_mmio_init(void)
{}

static void __exit virtio_mmio_exit(void)
{}

module_init();
module_exit(virtio_mmio_exit);

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();