Lines Matching +full:virtio +full:- +full:device
1 // SPDX-License-Identifier: GPL-2.0-or-later
10 * vp_legacy_probe: probe the legacy virtio pci device, note that the
11 * caller is required to enable PCI device before calling this function.
12 * @ldev: the legacy virtio-pci device
18 struct pci_dev *pci_dev = ldev->pci_dev; in vp_legacy_probe()
22 if (pci_dev->device < 0x1000 || pci_dev->device > 0x103f) in vp_legacy_probe()
23 return -ENODEV; in vp_legacy_probe()
25 if (pci_dev->revision != VIRTIO_PCI_ABI_VERSION) in vp_legacy_probe()
26 return -ENODEV; in vp_legacy_probe()
28 rc = dma_set_mask(&pci_dev->dev, DMA_BIT_MASK(64)); in vp_legacy_probe()
30 rc = dma_set_mask_and_coherent(&pci_dev->dev, DMA_BIT_MASK(32)); in vp_legacy_probe()
33 * The virtio ring base address is expressed as a 32-bit PFN, in vp_legacy_probe()
36 dma_set_coherent_mask(&pci_dev->dev, in vp_legacy_probe()
41 …dev_warn(&pci_dev->dev, "Failed to enable 64-bit or 32-bit DMA. Trying to continue, but this migh… in vp_legacy_probe()
43 rc = pci_request_region(pci_dev, 0, "virtio-pci-legacy"); in vp_legacy_probe()
47 ldev->ioaddr = pci_iomap(pci_dev, 0, 0); in vp_legacy_probe()
48 if (!ldev->ioaddr) { in vp_legacy_probe()
49 rc = -EIO; in vp_legacy_probe()
53 ldev->isr = ldev->ioaddr + VIRTIO_PCI_ISR; in vp_legacy_probe()
55 ldev->id.vendor = pci_dev->subsystem_vendor; in vp_legacy_probe()
56 ldev->id.device = pci_dev->subsystem_device; in vp_legacy_probe()
66 * vp_legacy_probe: remove and cleanup the legacy virtio pci device
67 * @ldev: the legacy virtio-pci device
71 struct pci_dev *pci_dev = ldev->pci_dev; in vp_legacy_remove()
73 pci_iounmap(pci_dev, ldev->ioaddr); in vp_legacy_remove()
79 * vp_legacy_get_features - get features from device
80 * @ldev: the legacy virtio-pci device
82 * Returns the features read from the device
87 return ioread32(ldev->ioaddr + VIRTIO_PCI_HOST_FEATURES); in vp_legacy_get_features()
92 * vp_legacy_get_driver_features - get driver features from device
93 * @ldev: the legacy virtio-pci device
95 * Returns the driver features read from the device
99 return ioread32(ldev->ioaddr + VIRTIO_PCI_GUEST_FEATURES); in vp_legacy_get_driver_features()
104 * vp_legacy_set_features - set features to device
105 * @ldev: the legacy virtio-pci device
106 * @features: the features set to device
111 iowrite32(features, ldev->ioaddr + VIRTIO_PCI_GUEST_FEATURES); in vp_legacy_set_features()
116 * vp_legacy_get_status - get the device status
117 * @ldev: the legacy virtio-pci device
119 * Returns the status read from device
123 return ioread8(ldev->ioaddr + VIRTIO_PCI_STATUS); in vp_legacy_get_status()
128 * vp_legacy_set_status - set status to device
129 * @ldev: the legacy virtio-pci device
130 * @status: the status set to device
135 iowrite8(status, ldev->ioaddr + VIRTIO_PCI_STATUS); in vp_legacy_set_status()
140 * vp_legacy_queue_vector - set the MSIX vector for a specific virtqueue
141 * @ldev: the legacy virtio-pci device
145 * Returns the config vector read from the device
150 iowrite16(index, ldev->ioaddr + VIRTIO_PCI_QUEUE_SEL); in vp_legacy_queue_vector()
151 iowrite16(vector, ldev->ioaddr + VIRTIO_MSI_QUEUE_VECTOR); in vp_legacy_queue_vector()
152 /* Flush the write out to device */ in vp_legacy_queue_vector()
153 return ioread16(ldev->ioaddr + VIRTIO_MSI_QUEUE_VECTOR); in vp_legacy_queue_vector()
158 * vp_legacy_config_vector - set the vector for config interrupt
159 * @ldev: the legacy virtio-pci device
162 * Returns the config vector read from the device
168 iowrite16(vector, ldev->ioaddr + VIRTIO_MSI_CONFIG_VECTOR); in vp_legacy_config_vector()
170 /* Will also flush the write out to device */ in vp_legacy_config_vector()
171 return ioread16(ldev->ioaddr + VIRTIO_MSI_CONFIG_VECTOR); in vp_legacy_config_vector()
176 * vp_legacy_set_queue_address - set the virtqueue address
177 * @ldev: the legacy virtio-pci device
184 iowrite16(index, ldev->ioaddr + VIRTIO_PCI_QUEUE_SEL); in vp_legacy_set_queue_address()
185 iowrite32(queue_pfn, ldev->ioaddr + VIRTIO_PCI_QUEUE_PFN); in vp_legacy_set_queue_address()
190 * vp_legacy_get_queue_enable - enable a virtqueue
191 * @ldev: the legacy virtio-pci device
199 iowrite16(index, ldev->ioaddr + VIRTIO_PCI_QUEUE_SEL); in vp_legacy_get_queue_enable()
200 return ioread32(ldev->ioaddr + VIRTIO_PCI_QUEUE_PFN); in vp_legacy_get_queue_enable()
205 * vp_legacy_get_queue_size - get size for a virtqueue
206 * @ldev: the legacy virtio-pci device
214 iowrite16(index, ldev->ioaddr + VIRTIO_PCI_QUEUE_SEL); in vp_legacy_get_queue_size()
215 return ioread16(ldev->ioaddr + VIRTIO_PCI_QUEUE_NUM); in vp_legacy_get_queue_size()
220 MODULE_DESCRIPTION("Legacy Virtio PCI Device");