15878b136SMichael S. Tsirkin /*
25878b136SMichael S. Tsirkin  * Virtio platform device driver
35878b136SMichael S. Tsirkin  *
45878b136SMichael S. Tsirkin  * Copyright 2011, ARM Ltd.
55878b136SMichael S. Tsirkin  *
65878b136SMichael S. Tsirkin  * Based on Virtio PCI driver by Anthony Liguori, copyright IBM Corp. 2007
75878b136SMichael S. Tsirkin  *
85878b136SMichael S. Tsirkin  * This header is BSD licensed so anyone can use the definitions to implement
95878b136SMichael S. Tsirkin  * compatible drivers/servers.
105878b136SMichael S. Tsirkin  *
115878b136SMichael S. Tsirkin  * Redistribution and use in source and binary forms, with or without
125878b136SMichael S. Tsirkin  * modification, are permitted provided that the following conditions
135878b136SMichael S. Tsirkin  * are met:
145878b136SMichael S. Tsirkin  * 1. Redistributions of source code must retain the above copyright
155878b136SMichael S. Tsirkin  *    notice, this list of conditions and the following disclaimer.
165878b136SMichael S. Tsirkin  * 2. Redistributions in binary form must reproduce the above copyright
175878b136SMichael S. Tsirkin  *    notice, this list of conditions and the following disclaimer in the
185878b136SMichael S. Tsirkin  *    documentation and/or other materials provided with the distribution.
195878b136SMichael S. Tsirkin  * 3. Neither the name of IBM nor the names of its contributors
205878b136SMichael S. Tsirkin  *    may be used to endorse or promote products derived from this software
215878b136SMichael S. Tsirkin  *    without specific prior written permission.
225878b136SMichael S. Tsirkin  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
235878b136SMichael S. Tsirkin  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
245878b136SMichael S. Tsirkin  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
255878b136SMichael S. Tsirkin  * ARE DISCLAIMED.  IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE
265878b136SMichael S. Tsirkin  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
275878b136SMichael S. Tsirkin  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
285878b136SMichael S. Tsirkin  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
295878b136SMichael S. Tsirkin  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
305878b136SMichael S. Tsirkin  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
315878b136SMichael S. Tsirkin  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
325878b136SMichael S. Tsirkin  * SUCH DAMAGE.
335878b136SMichael S. Tsirkin  */
345878b136SMichael S. Tsirkin 
355878b136SMichael S. Tsirkin #ifndef _LINUX_VIRTIO_MMIO_H
365878b136SMichael S. Tsirkin #define _LINUX_VIRTIO_MMIO_H
375878b136SMichael S. Tsirkin 
385878b136SMichael S. Tsirkin /*
395878b136SMichael S. Tsirkin  * Control registers
405878b136SMichael S. Tsirkin  */
415878b136SMichael S. Tsirkin 
425878b136SMichael S. Tsirkin /* Magic value ("virt" string) - Read Only */
435878b136SMichael S. Tsirkin #define VIRTIO_MMIO_MAGIC_VALUE		0x000
445878b136SMichael S. Tsirkin 
455878b136SMichael S. Tsirkin /* Virtio device version - Read Only */
465878b136SMichael S. Tsirkin #define VIRTIO_MMIO_VERSION		0x004
475878b136SMichael S. Tsirkin 
485878b136SMichael S. Tsirkin /* Virtio device ID - Read Only */
495878b136SMichael S. Tsirkin #define VIRTIO_MMIO_DEVICE_ID		0x008
505878b136SMichael S. Tsirkin 
515878b136SMichael S. Tsirkin /* Virtio vendor ID - Read Only */
525878b136SMichael S. Tsirkin #define VIRTIO_MMIO_VENDOR_ID		0x00c
535878b136SMichael S. Tsirkin 
545878b136SMichael S. Tsirkin /* Bitmask of the features supported by the device (host)
555878b136SMichael S. Tsirkin  * (32 bits per set) - Read Only */
565878b136SMichael S. Tsirkin #define VIRTIO_MMIO_DEVICE_FEATURES	0x010
575878b136SMichael S. Tsirkin 
585878b136SMichael S. Tsirkin /* Device (host) features set selector - Write Only */
595878b136SMichael S. Tsirkin #define VIRTIO_MMIO_DEVICE_FEATURES_SEL	0x014
605878b136SMichael S. Tsirkin 
615878b136SMichael S. Tsirkin /* Bitmask of features activated by the driver (guest)
625878b136SMichael S. Tsirkin  * (32 bits per set) - Write Only */
635878b136SMichael S. Tsirkin #define VIRTIO_MMIO_DRIVER_FEATURES	0x020
645878b136SMichael S. Tsirkin 
655878b136SMichael S. Tsirkin /* Activated features set selector - Write Only */
665878b136SMichael S. Tsirkin #define VIRTIO_MMIO_DRIVER_FEATURES_SEL	0x024
675878b136SMichael S. Tsirkin 
685878b136SMichael S. Tsirkin 
695878b136SMichael S. Tsirkin #ifndef VIRTIO_MMIO_NO_LEGACY /* LEGACY DEVICES ONLY! */
705878b136SMichael S. Tsirkin 
715878b136SMichael S. Tsirkin /* Guest's memory page size in bytes - Write Only */
725878b136SMichael S. Tsirkin #define VIRTIO_MMIO_GUEST_PAGE_SIZE	0x028
735878b136SMichael S. Tsirkin 
745878b136SMichael S. Tsirkin #endif
755878b136SMichael S. Tsirkin 
765878b136SMichael S. Tsirkin 
775878b136SMichael S. Tsirkin /* Queue selector - Write Only */
785878b136SMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_SEL		0x030
795878b136SMichael S. Tsirkin 
805878b136SMichael S. Tsirkin /* Maximum size of the currently selected queue - Read Only */
815878b136SMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_NUM_MAX	0x034
825878b136SMichael S. Tsirkin 
835878b136SMichael S. Tsirkin /* Queue size for the currently selected queue - Write Only */
845878b136SMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_NUM		0x038
855878b136SMichael S. Tsirkin 
865878b136SMichael S. Tsirkin 
875878b136SMichael S. Tsirkin #ifndef VIRTIO_MMIO_NO_LEGACY /* LEGACY DEVICES ONLY! */
885878b136SMichael S. Tsirkin 
895878b136SMichael S. Tsirkin /* Used Ring alignment for the currently selected queue - Write Only */
905878b136SMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_ALIGN		0x03c
915878b136SMichael S. Tsirkin 
925878b136SMichael S. Tsirkin /* Guest's PFN for the currently selected queue - Read Write */
935878b136SMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_PFN		0x040
945878b136SMichael S. Tsirkin 
955878b136SMichael S. Tsirkin #endif
965878b136SMichael S. Tsirkin 
975878b136SMichael S. Tsirkin 
985878b136SMichael S. Tsirkin /* Ready bit for the currently selected queue - Read Write */
995878b136SMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_READY		0x044
1005878b136SMichael S. Tsirkin 
1015878b136SMichael S. Tsirkin /* Queue notifier - Write Only */
1025878b136SMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_NOTIFY	0x050
1035878b136SMichael S. Tsirkin 
1045878b136SMichael S. Tsirkin /* Interrupt status - Read Only */
1055878b136SMichael S. Tsirkin #define VIRTIO_MMIO_INTERRUPT_STATUS	0x060
1065878b136SMichael S. Tsirkin 
1075878b136SMichael S. Tsirkin /* Interrupt acknowledge - Write Only */
1085878b136SMichael S. Tsirkin #define VIRTIO_MMIO_INTERRUPT_ACK	0x064
1095878b136SMichael S. Tsirkin 
1105878b136SMichael S. Tsirkin /* Device status register - Read Write */
1115878b136SMichael S. Tsirkin #define VIRTIO_MMIO_STATUS		0x070
1125878b136SMichael S. Tsirkin 
1135878b136SMichael S. Tsirkin /* Selected queue's Descriptor Table address, 64 bits in two halves */
1145878b136SMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_DESC_LOW	0x080
1155878b136SMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_DESC_HIGH	0x084
1165878b136SMichael S. Tsirkin 
1175878b136SMichael S. Tsirkin /* Selected queue's Available Ring address, 64 bits in two halves */
1185878b136SMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_AVAIL_LOW	0x090
1195878b136SMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_AVAIL_HIGH	0x094
1205878b136SMichael S. Tsirkin 
1215878b136SMichael S. Tsirkin /* Selected queue's Used Ring address, 64 bits in two halves */
1225878b136SMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_USED_LOW	0x0a0
1235878b136SMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_USED_HIGH	0x0a4
1245878b136SMichael S. Tsirkin 
125*53ba2eeeSMatthew Rosato /* Shared memory region id */
126*53ba2eeeSMatthew Rosato #define VIRTIO_MMIO_SHM_SEL             0x0ac
127*53ba2eeeSMatthew Rosato 
128*53ba2eeeSMatthew Rosato /* Shared memory region length, 64 bits in two halves */
129*53ba2eeeSMatthew Rosato #define VIRTIO_MMIO_SHM_LEN_LOW         0x0b0
130*53ba2eeeSMatthew Rosato #define VIRTIO_MMIO_SHM_LEN_HIGH        0x0b4
131*53ba2eeeSMatthew Rosato 
132*53ba2eeeSMatthew Rosato /* Shared memory region base address, 64 bits in two halves */
133*53ba2eeeSMatthew Rosato #define VIRTIO_MMIO_SHM_BASE_LOW        0x0b8
134*53ba2eeeSMatthew Rosato #define VIRTIO_MMIO_SHM_BASE_HIGH       0x0bc
135*53ba2eeeSMatthew Rosato 
1365878b136SMichael S. Tsirkin /* Configuration atomicity value */
1375878b136SMichael S. Tsirkin #define VIRTIO_MMIO_CONFIG_GENERATION	0x0fc
1385878b136SMichael S. Tsirkin 
1395878b136SMichael S. Tsirkin /* The config space is defined by each driver as
1405878b136SMichael S. Tsirkin  * the per-driver configuration space - Read Write */
1415878b136SMichael S. Tsirkin #define VIRTIO_MMIO_CONFIG		0x100
1425878b136SMichael S. Tsirkin 
1435878b136SMichael S. Tsirkin 
1445878b136SMichael S. Tsirkin 
1455878b136SMichael S. Tsirkin /*
1465878b136SMichael S. Tsirkin  * Interrupt flags (re: interrupt status & acknowledge registers)
1475878b136SMichael S. Tsirkin  */
1485878b136SMichael S. Tsirkin 
1495878b136SMichael S. Tsirkin #define VIRTIO_MMIO_INT_VRING		(1 << 0)
1505878b136SMichael S. Tsirkin #define VIRTIO_MMIO_INT_CONFIG		(1 << 1)
1515878b136SMichael S. Tsirkin 
1525878b136SMichael S. Tsirkin #endif
153