virtio_mmio.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (C) 2018, Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
  4. * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
  5. *
  6. * From Linux kernel include/uapi/linux/virtio_mmio.h
  7. */
  8. #ifndef _LINUX_VIRTIO_MMIO_H
  9. #define _LINUX_VIRTIO_MMIO_H
  10. /* Control registers */
  11. /* Magic value ("virt" string) - Read Only */
  12. #include <linux/bitops.h>
  13. #define VIRTIO_MMIO_MAGIC_VALUE 0x000
  14. /* Virtio device version - Read Only */
  15. #define VIRTIO_MMIO_VERSION 0x004
  16. /* Virtio device ID - Read Only */
  17. #define VIRTIO_MMIO_DEVICE_ID 0x008
  18. /* Virtio vendor ID - Read Only */
  19. #define VIRTIO_MMIO_VENDOR_ID 0x00c
  20. /*
  21. * Bitmask of the features supported by the device (host)
  22. * (32 bits per set) - Read Only
  23. */
  24. #define VIRTIO_MMIO_DEVICE_FEATURES 0x010
  25. /* Device (host) features set selector - Write Only */
  26. #define VIRTIO_MMIO_DEVICE_FEATURES_SEL 0x014
  27. /*
  28. * Bitmask of features activated by the driver (guest)
  29. * (32 bits per set) - Write Only
  30. */
  31. #define VIRTIO_MMIO_DRIVER_FEATURES 0x020
  32. /* Activated features set selector - Write Only */
  33. #define VIRTIO_MMIO_DRIVER_FEATURES_SEL 0x024
  34. #ifndef VIRTIO_MMIO_NO_LEGACY /* LEGACY DEVICES ONLY! */
  35. /* Guest's memory page size in bytes - Write Only */
  36. #define VIRTIO_MMIO_GUEST_PAGE_SIZE 0x028
  37. #endif
  38. /* Queue selector - Write Only */
  39. #define VIRTIO_MMIO_QUEUE_SEL 0x030
  40. /* Maximum size of the currently selected queue - Read Only */
  41. #define VIRTIO_MMIO_QUEUE_NUM_MAX 0x034
  42. /* Queue size for the currently selected queue - Write Only */
  43. #define VIRTIO_MMIO_QUEUE_NUM 0x038
  44. #ifndef VIRTIO_MMIO_NO_LEGACY /* LEGACY DEVICES ONLY! */
  45. /* Used Ring alignment for the currently selected queue - Write Only */
  46. #define VIRTIO_MMIO_QUEUE_ALIGN 0x03c
  47. /* Guest's PFN for the currently selected queue - Read Write */
  48. #define VIRTIO_MMIO_QUEUE_PFN 0x040
  49. #endif
  50. /* Ready bit for the currently selected queue - Read Write */
  51. #define VIRTIO_MMIO_QUEUE_READY 0x044
  52. /* Queue notifier - Write Only */
  53. #define VIRTIO_MMIO_QUEUE_NOTIFY 0x050
  54. /* Interrupt status - Read Only */
  55. #define VIRTIO_MMIO_INTERRUPT_STATUS 0x060
  56. /* Interrupt acknowledge - Write Only */
  57. #define VIRTIO_MMIO_INTERRUPT_ACK 0x064
  58. /* Device status register - Read Write */
  59. #define VIRTIO_MMIO_STATUS 0x070
  60. /* Selected queue's Descriptor Table address, 64 bits in two halves */
  61. #define VIRTIO_MMIO_QUEUE_DESC_LOW 0x080
  62. #define VIRTIO_MMIO_QUEUE_DESC_HIGH 0x084
  63. /* Selected queue's Available Ring address, 64 bits in two halves */
  64. #define VIRTIO_MMIO_QUEUE_AVAIL_LOW 0x090
  65. #define VIRTIO_MMIO_QUEUE_AVAIL_HIGH 0x094
  66. /* Selected queue's Used Ring address, 64 bits in two halves */
  67. #define VIRTIO_MMIO_QUEUE_USED_LOW 0x0a0
  68. #define VIRTIO_MMIO_QUEUE_USED_HIGH 0x0a4
  69. /* Configuration atomicity value */
  70. #define VIRTIO_MMIO_CONFIG_GENERATION 0x0fc
  71. /*
  72. * The config space is defined by each driver as
  73. * the per-driver configuration space - Read Write
  74. */
  75. #define VIRTIO_MMIO_CONFIG 0x100
  76. /* Interrupt flags (re: interrupt status & acknowledge registers) */
  77. #define VIRTIO_MMIO_INT_VRING BIT(0)
  78. #define VIRTIO_MMIO_INT_CONFIG BIT(1)
  79. /*
  80. * The alignment to use between consumer and producer parts of vring.
  81. * Currently hardcoded to the page size.
  82. */
  83. #define PAGE_SHIFT 12
  84. #define VIRTIO_MMIO_VRING_ALIGN PAGE_SIZE
  85. /**
  86. * virtio mmio transport driver private data
  87. *
  88. * @base: mmio transport device register base
  89. * @version: mmio transport device version
  90. */
  91. struct virtio_mmio_priv {
  92. void __iomem *base;
  93. u32 version;
  94. };
  95. #endif /* _LINUX_VIRTIO_MMIO_H */